Improve persistence experience for the user

This commit is contained in:
Jim Norman
2005-10-31 20:21:32 +00:00
parent d17617d6fd
commit d100d3d36f
4 changed files with 49 additions and 17 deletions

View File

@@ -149,9 +149,16 @@ namespace sscs.cache
CSSSLogger.DbgLog("StartPersistenceByDesktopPasswd - Started");
return true;
}
if(!File.Exists(GetPasscodeByDesktopFilePath()))
{
{
if (File.Exists(GetPasscodeByMasterPasswdFilePath()))
{
// wait for the user to start the Persistence by entering MP
return false;
}
//Else passcode needs to be generated.
baPasscode = CASACrypto.GenerateMasterPasscodeUsingString(
desktopPasswd,
@@ -164,19 +171,12 @@ namespace sscs.cache
if(!File.Exists(GetKeyFilePath()))
{
RijndaelManaged myRijndael = new RijndaelManaged();
byte[] key;
byte[] IV = new byte[16];
//Create a new key and initialization vector.
myRijndael.GenerateKey();
key = myRijndael.Key;
CASACrypto.StoreKeySetUsingMasterPasscode(key,IV,
baPasscode,
GetKeyFilePath());
GenerateAndStoreEncryptionKey(baPasscode);
lss = new LocalStorage(this,baPasscode);
bIsStorePersistent = true;
return true;
}
lss = new LocalStorage(this,baPasscode);
bIsStorePersistent = true;
return true;
}
baPasscode = CASACrypto.GetMasterPasscodeUsingDesktopPasswd(desktopPasswd, GetPasscodeByDesktopFilePath());
if(baPasscode != null)
@@ -209,6 +209,29 @@ namespace sscs.cache
return false;
}
internal bool GenerateAndStoreEncryptionKey(byte[] baPasscode)
{
RijndaelManaged myRijndael = new RijndaelManaged();
byte[] key;
byte[] IV = new byte[16];
//Create a new key and initialization vector.
try
{
myRijndael.GenerateKey();
key = myRijndael.Key;
CASACrypto.StoreKeySetUsingMasterPasscode(key,IV,
baPasscode,
GetKeyFilePath());
}
catch (Exception e)
{
return false;
}
return true;
}
internal bool SetMasterPassword(string mPasswdFromIDK)
{
try
@@ -288,6 +311,11 @@ namespace sscs.cache
baPasscode = CASACrypto.GenerateMasterPasscodeUsingString(mPasswd,GetPasscodeByMasterPasswdFilePath(),GetValidationFilePath(), user.UserIdentifier);
if(baPasscode != null)
{
if(!File.Exists(GetKeyFilePath()))
{
GenerateAndStoreEncryptionKey(baPasscode);
}
CASACrypto.EncryptAndStoreMasterPasscodeUsingString(baPasscode,mPasswd,GetPasscodeByMasterPasswdFilePath());
if( bIsStorePersistent == false )
{