fix code mix up.
This commit is contained in:
parent
6d5251fe02
commit
75d85518e9
222
c_micasad/cache/SecretStore.cs
vendored
222
c_micasad/cache/SecretStore.cs
vendored
@ -210,41 +210,29 @@ namespace sscs.cache
|
|||||||
|
|
||||||
}
|
}
|
||||||
baPasscode = CASACrypto.GetMasterPasscodeUsingDesktopPasswd(desktopPasswd, GetPasscodeByDesktopFilePath(), false);
|
baPasscode = CASACrypto.GetMasterPasscodeUsingDesktopPasswd(desktopPasswd, GetPasscodeByDesktopFilePath(), false);
|
||||||
//if(baPasscode != null)
|
if(CASACrypto.ValidatePasscode(baPasscode,GetValidationFilePath()))
|
||||||
if (true)
|
|
||||||
{
|
{
|
||||||
if(CASACrypto.ValidatePasscode(baPasscode,GetValidationFilePath()))
|
lss = new LocalStorage(this,baPasscode);
|
||||||
{
|
bIsStorePersistent = true;
|
||||||
lss = new LocalStorage(this,baPasscode);
|
|
||||||
bIsStorePersistent = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// try old encryption method
|
|
||||||
baPasscode = CASACrypto.GetMasterPasscodeUsingDesktopPasswd(desktopPasswd, GetPasscodeByDesktopFilePath(), true);
|
|
||||||
if (CASACrypto.ValidatePasscode(baPasscode, GetValidationFilePath()))
|
|
||||||
{
|
|
||||||
// rewrite file using new encryption
|
|
||||||
CASACrypto.EncryptAndStoreMasterPasscodeUsingString(baPasscode, desktopPasswd, GetPasscodeByDesktopFilePath());
|
|
||||||
lss = new LocalStorage(this, baPasscode);
|
|
||||||
bIsStorePersistent = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lss = null;
|
|
||||||
bIsStorePersistent = false; //till masterPasswd is verified
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CSSSLogger.DbgLog(CSSSLogger.GetExecutionPath(this) + " May be desktop passwd has changed");
|
// try old encryption method
|
||||||
lss = null;
|
baPasscode = CASACrypto.GetMasterPasscodeUsingDesktopPasswd(desktopPasswd, GetPasscodeByDesktopFilePath(), true);
|
||||||
bIsStorePersistent = false;
|
if (CASACrypto.ValidatePasscode(baPasscode, GetValidationFilePath()))
|
||||||
return false;
|
{
|
||||||
|
// rewrite file using new encryption
|
||||||
|
CASACrypto.EncryptAndStoreMasterPasscodeUsingString(baPasscode, desktopPasswd, GetPasscodeByDesktopFilePath());
|
||||||
|
lss = new LocalStorage(this, baPasscode);
|
||||||
|
bIsStorePersistent = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lss = null;
|
||||||
|
bIsStorePersistent = false; //till masterPasswd is verified
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
@ -255,7 +243,7 @@ namespace sscs.cache
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal bool GenerateAndStoreEncryptionKey(byte[] baPasscode)
|
internal bool GenerateAndStoreEncryptionKey(byte[] baPasscode)
|
||||||
{
|
{
|
||||||
RijndaelManaged myRijndael = new RijndaelManaged();
|
RijndaelManaged myRijndael = new RijndaelManaged();
|
||||||
byte[] key;
|
byte[] key;
|
||||||
byte[] IV = new byte[16];
|
byte[] IV = new byte[16];
|
||||||
@ -307,48 +295,48 @@ namespace sscs.cache
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// try old method
|
// try old method
|
||||||
baPasscode = CASACrypto.GetMasterPasscodeUsingDesktopPasswd(desktopPasswd, GetPasscodeByDesktopFilePath(), true);
|
baPasscode = CASACrypto.GetMasterPasscodeUsingDesktopPasswd(desktopPasswd, GetPasscodeByDesktopFilePath(), true);
|
||||||
if (CASACrypto.ValidatePasscode(baPasscode, GetValidationFilePath()))
|
if (CASACrypto.ValidatePasscode(baPasscode, GetValidationFilePath()))
|
||||||
{
|
{
|
||||||
// rewrite file using new method
|
// rewrite file using new method
|
||||||
CASACrypto.EncryptAndStoreMasterPasscodeUsingString(baPasscode, desktopPasswd, GetPasscodeByDesktopFilePath());
|
CASACrypto.EncryptAndStoreMasterPasscodeUsingString(baPasscode, desktopPasswd, GetPasscodeByDesktopFilePath());
|
||||||
|
|
||||||
|
|
||||||
CASACrypto.EncryptAndStoreMasterPasscodeUsingString(
|
CASACrypto.EncryptAndStoreMasterPasscodeUsingString(
|
||||||
baPasscode,
|
baPasscode,
|
||||||
mPasswd,
|
mPasswd,
|
||||||
GetPasscodeByMasterPasswdFilePath());
|
GetPasscodeByMasterPasswdFilePath());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Probably desktop passwd has changed.
|
//Probably desktop passwd has changed.
|
||||||
//But as even master passwd is being set only now,
|
//But as even master passwd is being set only now,
|
||||||
//the persistent store is lost.
|
//the persistent store is lost.
|
||||||
|
|
||||||
baPasscode = CASACrypto.GenerateMasterPasscodeUsingString(mPasswd, GetPasscodeByMasterPasswdFilePath(), GetValidationFilePath(), user.UserIdentifier);
|
baPasscode = CASACrypto.GenerateMasterPasscodeUsingString(mPasswd, GetPasscodeByMasterPasswdFilePath(), GetValidationFilePath(), user.UserIdentifier);
|
||||||
if (baPasscode != null)
|
if (baPasscode != null)
|
||||||
{
|
{
|
||||||
CASACrypto.EncryptAndStoreMasterPasscodeUsingString(baPasscode, mPasswd, GetPasscodeByMasterPasswdFilePath());
|
CASACrypto.EncryptAndStoreMasterPasscodeUsingString(baPasscode, mPasswd, GetPasscodeByMasterPasswdFilePath());
|
||||||
CASACrypto.EncryptAndStoreMasterPasscodeUsingString(baPasscode, desktopPasswd, GetPasscodeByDesktopFilePath());
|
CASACrypto.EncryptAndStoreMasterPasscodeUsingString(baPasscode, desktopPasswd, GetPasscodeByDesktopFilePath());
|
||||||
if (File.Exists(GetPersistenceFilePath()))
|
if (File.Exists(GetPersistenceFilePath()))
|
||||||
{
|
{
|
||||||
File.Delete(GetPersistenceFilePath());
|
File.Delete(GetPersistenceFilePath());
|
||||||
CSSSLogger.DbgLog("Removing the persistent storeas its meaningless now.");
|
CSSSLogger.DbgLog("Removing the persistent storeas its meaningless now.");
|
||||||
}
|
}
|
||||||
if (bIsStorePersistent == false)
|
if (bIsStorePersistent == false)
|
||||||
{
|
{
|
||||||
lss = new LocalStorage(this, baPasscode);
|
lss = new LocalStorage(this, baPasscode);
|
||||||
bIsStorePersistent = true;
|
bIsStorePersistent = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//return true;
|
//return true;
|
||||||
@ -409,23 +397,23 @@ namespace sscs.cache
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// try validation, if it fails, try decryption using the old method
|
// try validation, if it fails, try decryption using the old method
|
||||||
baPasscode = CASACrypto.DecryptMasterPasscodeUsingString(mPasswd, GetPasscodeByMasterPasswdFilePath(), true);
|
baPasscode = CASACrypto.DecryptMasterPasscodeUsingString(mPasswd, GetPasscodeByMasterPasswdFilePath(), true);
|
||||||
if (CASACrypto.ValidatePasscode(baPasscode, GetValidationFilePath()))
|
if (CASACrypto.ValidatePasscode(baPasscode, GetValidationFilePath()))
|
||||||
{
|
{
|
||||||
// rewrite file
|
// rewrite file
|
||||||
CASACrypto.EncryptAndStoreMasterPasscodeUsingString(baPasscode, mPasswd, GetPasscodeByMasterPasswdFilePath());
|
CASACrypto.EncryptAndStoreMasterPasscodeUsingString(baPasscode, mPasswd, GetPasscodeByMasterPasswdFilePath());
|
||||||
if (bIsStorePersistent == false)
|
if (bIsStorePersistent == false)
|
||||||
{
|
{
|
||||||
lss = new LocalStorage(this, baPasscode);
|
lss = new LocalStorage(this, baPasscode);
|
||||||
bIsStorePersistent = true;
|
bIsStorePersistent = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -444,17 +432,17 @@ namespace sscs.cache
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
baPasscode = CASACrypto.GetMasterPasscodeUsingMasterPasswd(mPasswd, GetPasscodeByMasterPasswdFilePath(), true);
|
baPasscode = CASACrypto.GetMasterPasscodeUsingMasterPasswd(mPasswd, GetPasscodeByMasterPasswdFilePath(), true);
|
||||||
if (CASACrypto.ValidatePasscode(baPasscode, GetValidationFilePath()))
|
if (CASACrypto.ValidatePasscode(baPasscode, GetValidationFilePath()))
|
||||||
{
|
{
|
||||||
RewriteDesktopPasswdFile(baPasscode, desktopPasswd);
|
RewriteDesktopPasswdFile(baPasscode, desktopPasswd);
|
||||||
if (bIsStorePersistent == false)
|
if (bIsStorePersistent == false)
|
||||||
{
|
{
|
||||||
lss = new LocalStorage(this, baPasscode);
|
lss = new LocalStorage(this, baPasscode);
|
||||||
bIsStorePersistent = true;
|
bIsStorePersistent = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -487,22 +475,22 @@ namespace sscs.cache
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
byte[] baPasscode = CASACrypto.GetMasterPasscodeUsingDesktopPasswd(oldDesktopPasswd, GetPasscodeByDesktopFilePath(), false);
|
byte[] baPasscode = CASACrypto.GetMasterPasscodeUsingDesktopPasswd(oldDesktopPasswd, GetPasscodeByDesktopFilePath(), false);
|
||||||
if (CASACrypto.ValidatePasscode(baPasscode, GetValidationFilePath()))
|
if (CASACrypto.ValidatePasscode(baPasscode, GetValidationFilePath()))
|
||||||
{
|
{
|
||||||
return baPasscode;
|
return baPasscode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// try old method
|
// try old method
|
||||||
baPasscode = CASACrypto.GetMasterPasscodeUsingDesktopPasswd(oldDesktopPasswd, GetPasscodeByDesktopFilePath(), true);
|
baPasscode = CASACrypto.GetMasterPasscodeUsingDesktopPasswd(oldDesktopPasswd, GetPasscodeByDesktopFilePath(), true);
|
||||||
if (CASACrypto.ValidatePasscode(baPasscode, GetValidationFilePath()))
|
if (CASACrypto.ValidatePasscode(baPasscode, GetValidationFilePath()))
|
||||||
{
|
{
|
||||||
// rewrite file now
|
// rewrite file now
|
||||||
CASACrypto.EncryptAndStoreMasterPasscodeUsingString(baPasscode, oldDesktopPasswd, GetPasscodeByDesktopFilePath());
|
CASACrypto.EncryptAndStoreMasterPasscodeUsingString(baPasscode, oldDesktopPasswd, GetPasscodeByDesktopFilePath());
|
||||||
return baPasscode;
|
return baPasscode;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
*
|
*
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace sscs.lss
|
namespace sscs.lss
|
||||||
|
Loading…
Reference in New Issue
Block a user