Changes per SRB. Using PKCS5 for encryption of MPC by DesktopPWD and MasterPWD

This commit is contained in:
Jim Norman
2005-10-14 16:49:15 +00:00
parent 8407cca2a4
commit 7da58ba915
6 changed files with 205 additions and 6 deletions

View File

@@ -9,13 +9,17 @@ namespace sscs.crypto
{
public class CASACrypto
{
internal static byte[] Generate16ByteKeyFromString(string TheString)
private const int SALTSIZE = 64;
private const int ITERATION_COUNT = 1000;
internal static byte[] Generate16ByteKeyFromString(string sTheString)
{
byte[] baKey = new byte[16]; //return value
try
{
Random rand = new Random(TheString.GetHashCode());
rand.NextBytes(baKey);
{
Rfc2898DeriveBytes pkcs5 = new Rfc2898DeriveBytes(sTheString, SALTSIZE, ITERATION_COUNT);
baKey = pkcs5.GetBytes(16);
}
catch(Exception e)
{
@@ -25,7 +29,7 @@ namespace sscs.crypto
}
return baKey;
}
internal static bool StoreKeySetUsingMasterPasscode(byte[] key,
byte[] IV, byte[] baMasterPasscode, string fileName)
{
@@ -440,7 +444,6 @@ namespace sscs.crypto
myRijndael.GenerateKey();
baPasscode = myRijndael.Key;
EncryptAndStoreMasterPasscodeUsingString(baPasscode,
desktopPasswd,
fileName);