Improve persistence experience for the user
This commit is contained in:
54
c_micasad/cache/SecretStore.cs
vendored
54
c_micasad/cache/SecretStore.cs
vendored
@@ -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 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user