Improve persistence experience for the user
This commit is contained in:
parent
d17617d6fd
commit
d100d3d36f
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 )
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ namespace Novell.CASA.MiCasa.Common
|
||||
if (sSecretID != null)
|
||||
{
|
||||
if (sSecretID.StartsWith("SS_CredSet"))
|
||||
m_SecretID = "SS_CredSet:" + EscapeReservedChars(sSecretID.Substring(12)) + '\0';
|
||||
m_SecretID = "SS_CredSet:" + EscapeReservedChars(sSecretID.Substring(11)) + '\0';
|
||||
else
|
||||
m_SecretID = "SS_CredSet:" + EscapeReservedChars(sSecretID) + '\0';
|
||||
}
|
||||
|
@ -116,7 +116,12 @@ namespace sscs.lss
|
||||
if (File.Exists(fileName+".tmp"))
|
||||
File.Delete(fileName+".tmp");
|
||||
|
||||
byte[] baPasscode = CASACrypto.GetMasterPasscode(userStore.GetDesktopPasswd(),userStore.GetPasscodeByDesktopFilePath());
|
||||
byte[] baPasscode = null;
|
||||
if (null != m_baGeneratedKey)
|
||||
baPasscode = m_baGeneratedKey;
|
||||
else
|
||||
baPasscode = CASACrypto.GetMasterPasscode(userStore.GetDesktopPasswd(),userStore.GetPasscodeByDesktopFilePath());
|
||||
|
||||
if( null == baPasscode )
|
||||
return null;
|
||||
|
||||
|
@ -25,7 +25,6 @@ namespace sscs.verbs
|
||||
|
||||
private ushort msgId = 0;
|
||||
private uint inMsgLen = 0;
|
||||
|
||||
|
||||
private byte[] inBuf;
|
||||
private byte[] outBuf;
|
||||
@ -657,7 +656,7 @@ namespace sscs.verbs
|
||||
|
||||
private WrappedObject DoPing(WrappedObject wo)
|
||||
{
|
||||
Console.WriteLine("MICASAD received Ping from Client");
|
||||
//Console.WriteLine("MICASAD received Ping from Client");
|
||||
wo.SetError(IPCRetCodes.SSCS_REPLY_SUCCESS, null);
|
||||
|
||||
Ping ping = (Ping)wo.GetObject();
|
||||
|
Loading…
Reference in New Issue
Block a user