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