Improve persistence experience for the user
This commit is contained in:
		
							
								
								
									
										52
									
								
								c_micasad/cache/SecretStore.cs
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										52
									
								
								c_micasad/cache/SecretStore.cs
									
									
									
									
										vendored
									
									
								
							| @@ -150,8 +150,15 @@ namespace sscs.cache | ||||
|                     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; | ||||
|  | ||||
|   | ||||
| @@ -26,7 +26,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(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user