Re: URL. Hash, Encrypt, ...
- From: shapper <mdmoura@xxxxxxxxx>
- Date: Sun, 4 Oct 2009 19:00:04 -0700 (PDT)
On Oct 4, 10:49 pm, rossum <rossu...@xxxxxxxxxxxx> wrote:
1 Generate a suitable large random number.
You mean considering that is a password?
For example with length equal to 8, which is the minimum length I
usually set to passwords ...
2 Encrypt this number with the user's public RSA key.
Doesn't the private key include the public key?
So I need to generate two keys, one private and one public and
save in the database?
Like so?
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
byte[] privateAndPublicKeys = RSA.ExportCspBlob(true);
byte[] publicKey = RSA.ExportCspBlob(false);
The ExportCspBlob says for the parameter:
"true to include the private key"
This is why I am not sure how to separate both.
3 Send the encrypted number to the user in an e-mail.
Got it.
4 The new password is the SHA-256 hash of the random number (in
Base-64 if you want to make it typeable on a keyboard).
I don't get the typeable part ...
If I understood correctly I get the encrypted number use Base64 to
convert to String and send it to user by email.
And I also turn it to byte[] and hash it using SHA 256. I save the
hash and the salt in the database.
Then when the user inserts that number I convert it to byte[] using
UTF8 and verify it against the hash I have on the database.
Correct?
5 Expire the new password the first time it is used to force the user
to change to their own new password when they log back on.
I can create a column on the database Users table: Bool
TemporaryPassword.
When I send the password I set it to true. When the user logins I
redirect him to the password change form and set it to false.
I suppose a column on the table for this is necessary. Correct?
This requires all users to have their own RSA public/private keys.
They could perhaps be generated as part of the sign-up process.
Yes, no problem in doing that on the signup process.
And I can use the RSA keys for other things if needed correct?
As is usual with security, how valuable is what you are trying to
protect? What is the cost to the business is the data is compromised?
Not a lot ... But the way I see it is if I am spending time learning
and implementing things then it would be better to do it the correct
way.
Thank You,
Miguel
.
- Follow-Ups:
- Re: URL. Hash, Encrypt, ...
- From: rossum
- Re: URL. Hash, Encrypt, ...
- References:
- URL. Hash, Encrypt, ...
- From: shapper
- Re: URL. Hash, Encrypt, ...
- From: rossum
- URL. Hash, Encrypt, ...
- Prev by Date: Re: URL. Hash, Encrypt, ...
- Next by Date: Re: URL. Hash, Encrypt, ...
- Previous by thread: Re: URL. Hash, Encrypt, ...
- Next by thread: Re: URL. Hash, Encrypt, ...
- Index(es):
Relevant Pages
|