Pass ssFlags from NDK to micasad on WriteBinaryKey. Needed by AuthToken.
This commit is contained in:
		| @@ -3622,6 +3622,7 @@ int ipc_WriteBinaryKey | ||||
|           epPassword = &myPassword; | ||||
|  | ||||
|       msgLen = MSGID_LEN + MSG_LEN + | ||||
| 			   MSG_STRING_LEN + // ssFlags length | ||||
|                MSG_STRING_LEN + // KeychainID length | ||||
|                keychainIDLen + // Keychain ID | ||||
|                MSG_STRING_LEN + // SecretID length | ||||
| @@ -3687,6 +3688,8 @@ int ipc_WriteBinaryKey | ||||
|       pReq += MSGID_LEN; | ||||
|       memcpy(pReq, &msgLen, MSG_LEN); | ||||
|       pReq += MSG_LEN; | ||||
| 	  memcpy(pReq, &ssFlags, MSG_STRING_LEN); | ||||
| 	  pReq += MSG_STRING_LEN; | ||||
|       memcpy(pReq, &keychainIDLen, MSG_STRING_LEN); | ||||
|       pReq += MSG_STRING_LEN; | ||||
|       memcpy(pReq,keychainID->keychainID,keychainIDLen ); | ||||
|   | ||||
							
								
								
									
										13
									
								
								CASA/micasad/cache/KeyValue.cs
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								CASA/micasad/cache/KeyValue.cs
									
									
									
									
										vendored
									
									
								
							| @@ -35,6 +35,19 @@ namespace sscs.cache | ||||
|  | ||||
| 		private int m_iValueType = VALUE_TYPE_STRING; | ||||
|  | ||||
|         private bool m_IsPersistent = true; | ||||
|         public bool IsPersistent | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return m_IsPersistent; | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 m_IsPersistent = value; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         private string m_key;         | ||||
|         public string Key | ||||
|         { | ||||
|   | ||||
| @@ -56,6 +56,14 @@ namespace sscs.constants | ||||
|         internal static int SSCS_SECRET_STORE_IS_LOCKED            = -26;         | ||||
|     } | ||||
|  | ||||
|     class SSFLAGS | ||||
|     { | ||||
|         // used internally by WriteBinaryKey | ||||
|         // these are not published in the NDK | ||||
|         internal static int FLAG_PERSIST = 0x10000000; | ||||
|         internal static int FLAG_DO_NOT_PERSIST = 0x20000000; | ||||
|     } | ||||
|  | ||||
|     internal class ReqMsgId | ||||
|     { | ||||
|          | ||||
|   | ||||
| @@ -804,7 +804,7 @@ namespace sscs.lss | ||||
|                                                          | ||||
|                             writer.WriteStartElement(XmlConsts.keyValueNode); | ||||
|  | ||||
|                             if (bSaveValues) | ||||
|                             if (kv.IsPersistent && bSaveValues) | ||||
|                             { | ||||
|                                 if (kv.GetValueType() == KeyValue.VALUE_TYPE_BINARY) | ||||
|                                 { | ||||
|   | ||||
| @@ -44,6 +44,7 @@ namespace sscs.verbs | ||||
|         private ushort msgId = 0; | ||||
|         private uint inMsgLen  = 0; | ||||
|         private uint outMsgLen = 0; | ||||
|         private uint ssFlags = 0; | ||||
|         private uint keyChainIdLen = 0; | ||||
|         private uint secretIdLen = 0; | ||||
|         private uint secretValLen = 0; | ||||
| @@ -93,36 +94,40 @@ namespace sscs.verbs | ||||
|             if( inMsgLen != inBuf.Length ) | ||||
|                 throw new FormatException(" MsgLen sent does not match the length of the message received."); | ||||
|  | ||||
|             keyChainIdLen  = BitConverter.ToUInt32(inBuf,6); | ||||
|             // get flags | ||||
|             ssFlags = BitConverter.ToUInt32(inBuf, 6); | ||||
|  | ||||
|             // get keychain | ||||
|             keyChainIdLen = BitConverter.ToUInt32(inBuf, 10); | ||||
|  | ||||
|             byte[] keyChainIdArr = new byte[keyChainIdLen]; | ||||
|             Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen); | ||||
|             Array.Copy(inBuf,14,keyChainIdArr,0,keyChainIdLen); | ||||
|             keyChainId     = Encoding.UTF8.GetString(keyChainIdArr); | ||||
|  | ||||
|             secretIdLen    = BitConverter.ToUInt32(inBuf, | ||||
|                              (10 + (int)keyChainIdLen )); | ||||
|                              (14 + (int)keyChainIdLen )); | ||||
|   | ||||
|             byte[] secretIdArr = new byte[secretIdLen]; | ||||
|             Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen); | ||||
|             Array.Copy(inBuf,(14+keyChainIdLen+4),secretIdArr,0,secretIdLen); | ||||
|             secretId = Encoding.UTF8.GetString(secretIdArr); | ||||
|  | ||||
| 			if (secretId.IndexOf("*") < 0) | ||||
| 			{ | ||||
|  | ||||
| 				keyLen   = BitConverter.ToUInt32(inBuf,(14+(int)keyChainIdLen+(int)secretIdLen));  | ||||
| 				keyLen   = BitConverter.ToUInt32(inBuf,(18+(int)keyChainIdLen+(int)secretIdLen));  | ||||
| 				byte[] keyArr = new byte[keyLen]; | ||||
| 				Array.Copy(inBuf,(18+keyChainIdLen+secretIdLen),keyArr,0,keyLen); | ||||
| 				Array.Copy(inBuf,(22+keyChainIdLen+secretIdLen),keyArr,0,keyLen); | ||||
| 				key = Encoding.UTF8.GetString(keyArr); | ||||
|              | ||||
|  | ||||
| 				valLen = BitConverter.ToUInt32(inBuf,(18+(int)keyChainIdLen+(int)secretIdLen+(int)keyLen)); | ||||
| 				valLen = BitConverter.ToUInt32(inBuf,(22+(int)keyChainIdLen+(int)secretIdLen+(int)keyLen)); | ||||
| 				val = new byte[valLen]; | ||||
| 				Array.Copy(inBuf,(22+keyChainIdLen+secretIdLen+keyLen),val,0,valLen); | ||||
| 				Array.Copy(inBuf,(26+keyChainIdLen+secretIdLen+keyLen),val,0,valLen); | ||||
| 				 | ||||
| 				try  | ||||
| 				{ | ||||
| 					// get extension ID | ||||
| 					int extLocation = 26 + ((int)keyChainIdLen) + ((int)secretIdLen) + ((int)keyLen) + ((int)valLen); | ||||
| 					int extLocation = 30 + ((int)keyChainIdLen) + ((int)secretIdLen) + ((int)keyLen) + ((int)valLen); | ||||
| 					extId = BitConverter.ToUInt32(inBuf, extLocation); | ||||
| 				} | ||||
| 				catch (Exception) | ||||
| @@ -138,8 +143,8 @@ namespace sscs.verbs | ||||
| 					// This is how the Login Capture module on windows, running as System, sets the Desktop Credential. | ||||
| 					// we might be able to change this if/when we abstract the session.     | ||||
| 					// [4 byte extID][4 byte length][4 byte luidLow][4 byte luidHigh] | ||||
| 					luidLow = BitConverter.ToInt32(inBuf, 26 + ((int)keyChainIdLen)+((int)secretIdLen) +((int)keyLen) + (int)valLen + 8); | ||||
| 					luidHigh = BitConverter.ToInt32(inBuf, 26 + ((int)keyChainIdLen)+((int)secretIdLen) +((int)keyLen) + (int)valLen + 12); | ||||
| 					luidLow = BitConverter.ToInt32(inBuf, 30 + ((int)keyChainIdLen)+((int)secretIdLen) +((int)keyLen) + (int)valLen + 8); | ||||
| 					luidHigh = BitConverter.ToInt32(inBuf, 30 + ((int)keyChainIdLen)+((int)secretIdLen) +((int)keyLen) + (int)valLen + 12); | ||||
| 					tempUserId = new WinUserIdentifier(luidLow, luidHigh); | ||||
| 					SecretStore ss = SessionManager.CreateUserSession(tempUserId); | ||||
| 					try  | ||||
| @@ -180,13 +185,24 @@ namespace sscs.verbs | ||||
| 								(ConstStrings.MICASA_DESKTOP_PASSWD_KEYNAME == key) | ||||
| 								) | ||||
| 							{ | ||||
| 								KeyValue kv = secret.GetKeyValue(ConstStrings.MICASA_DESKTOP_PASSWD_KEYNAME); | ||||
| 								if( null != kv ) | ||||
| 									oldPasswd = kv.GetValue(); | ||||
| 								KeyValue kvDesktop = secret.GetKeyValue(ConstStrings.MICASA_DESKTOP_PASSWD_KEYNAME); | ||||
|                                 if (null != kvDesktop) | ||||
|                                     oldPasswd = kvDesktop.GetValue(); | ||||
| 							} | ||||
|  | ||||
| 							secret.SetKeyValue(key,val); | ||||
|  | ||||
|                             KeyValue kv = secret.GetKeyValue(key); | ||||
|                             if ((ssFlags & SSFLAGS.FLAG_DO_NOT_PERSIST) == SSFLAGS.FLAG_DO_NOT_PERSIST) | ||||
|                             { | ||||
|                                 kv.IsPersistent = false; | ||||
|                             } | ||||
|                             else | ||||
|                             { | ||||
|                                 kv.IsPersistent = true; | ||||
|                             } | ||||
|                              | ||||
|  | ||||
| 							if((ConstStrings.MICASA_DESKTOP_PASSWD == secretId) &&  | ||||
| 								(ConstStrings.MICASA_DESKTOP_PASSWD_KEYNAME == key) | ||||
| 								) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user