Remove line feed chars

This commit is contained in:
Jim Norman 2008-03-27 23:10:09 +00:00
parent a31cb2ba90
commit 54210a90b8
20 changed files with 2527 additions and 2527 deletions

View File

@ -35,38 +35,38 @@ using sscs.constants;
namespace sscs.common namespace sscs.common
{ {
class CSSSUtils class CSSSUtils
{ {
#if W32 #if W32
private static bool IsRegKeySet(string sPath, string sValue) private static bool IsRegKeySet(string sPath, string sValue)
{ {
Microsoft.Win32.RegistryKey key; Microsoft.Win32.RegistryKey key;
try try
{ {
key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sPath); key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sPath);
int iValue = (int)key.GetValue(sValue); int iValue = (int)key.GetValue(sValue);
key.Close(); key.Close();
if (iValue > 0) if (iValue > 0)
{ {
return true; return true;
} }
} }
catch (Exception e) catch (Exception e)
{ {
} }
return false; return false;
} }
#endif #endif
public static bool StoreDesktopPasswordInCache() public static bool StoreDesktopPasswordInCache()
{ {
#if LINUX #if LINUX
return true; return true;
#else #else
return IsRegKeySet("SOFTWARE\\Novell\\CASA", "CacheDesktopPassword"); return IsRegKeySet("SOFTWARE\\Novell\\CASA", "CacheDesktopPassword");
#endif #endif
} }
public static bool IsFileOwnedByRoot(string filePath) public static bool IsFileOwnedByRoot(string filePath)

View File

@ -20,132 +20,132 @@
* *
***********************************************************************/ ***********************************************************************/
using System; using System;
using System.Collections; using System.Collections;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using sscs.verbs; using sscs.verbs;
using sscs.common; using sscs.common;
using sscs.cache; using sscs.cache;
using sscs.constants; using sscs.constants;
namespace sscs.verbs namespace sscs.verbs
{ {
/* /*
* This class is implementation of AddKeyChain call. * This class is implementation of AddKeyChain call.
* There will be one instance existing for every call made by the client. * There will be one instance existing for every call made by the client.
*/ */
internal class AddKeyChain : SSVerb internal class AddKeyChain : SSVerb
{ {
private ushort msgId = 0; private ushort msgId = 0;
private uint inMsgLen = 0; private uint inMsgLen = 0;
private uint keyChainFlags = 0; private uint keyChainFlags = 0;
private uint keyChainIdLen = 0; private uint keyChainIdLen = 0;
private string keyChainId; private string keyChainId;
private uint outMsgLen = 0; private uint outMsgLen = 0;
private byte[] inBuf; private byte[] inBuf;
private byte[] outBuf; private byte[] outBuf;
private int retCode = 0; private int retCode = 0;
/* /*
* This method sets the class member with the byte array received. * This method sets the class member with the byte array received.
*/ */
public void SetMessageContent(byte[] ipcBytes) public void SetMessageContent(byte[] ipcBytes)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes; inBuf = ipcBytes;
} }
/* /*
* This method does the actual implementation of AddKeyChain * This method does the actual implementation of AddKeyChain
*/ */
public byte[] ProcessRequest(UserIdentifier userId) public byte[] ProcessRequest(UserIdentifier userId)
{ {
/* If an exception occurs in message format decoding, /* If an exception occurs in message format decoding,
* it is handled by AppHandler * it is handled by AppHandler
*/ */
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
// Message Format decipher - Start // Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0); msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2); inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length ) if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received."); throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainFlags = BitConverter.ToUInt32(inBuf,6); keyChainFlags = BitConverter.ToUInt32(inBuf,6);
keyChainIdLen = BitConverter.ToUInt32(inBuf,10); keyChainIdLen = BitConverter.ToUInt32(inBuf,10);
byte[] tempArr = new byte[keyChainIdLen]; byte[] tempArr = new byte[keyChainIdLen];
Array.Copy(inBuf,14,tempArr,0,keyChainIdLen); Array.Copy(inBuf,14,tempArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(tempArr); keyChainId = Encoding.UTF8.GetString(tempArr);
// Message Format decipher - End // Message Format decipher - End
try try
{ {
SecretStore ssStore = null; SecretStore ssStore = null;
KeyChain keyChain = null; KeyChain keyChain = null;
keyChain = new KeyChain(keyChainId); keyChain = new KeyChain(keyChainId);
ssStore = SessionManager.GetUserSecretStore(userId); ssStore = SessionManager.GetUserSecretStore(userId);
if( ssStore.CheckIfKeyChainExists(keyChainId) == false ) if( ssStore.CheckIfKeyChainExists(keyChainId) == false )
{ {
ssStore.AddKeyChain(keyChain); ssStore.AddKeyChain(keyChain);
} }
else else
{ {
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Keychain already present for keychain id " +keyChainId ); CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Keychain already present for keychain id " +keyChainId );
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_ALREADY_EXISTS; retCode = IPCRetCodes.SSCS_E_KEYCHAIN_ALREADY_EXISTS;
} }
} }
catch(UserNotInSessionException) catch(UserNotInSessionException)
{ {
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" ); CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
try try
{ {
msgId = 5; msgId = 5;
outMsgLen = 10; outMsgLen = 10;
outBuf = new byte[10]; outBuf = new byte[10];
byte[] t = new byte[10]; byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId); t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2); Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen); t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4); Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(retCode); t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,6,4); Array.Copy(t,0,outBuf,6,4);
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString()); throw new FormatException("Unable to form the response " + e.ToString());
} }
return outBuf; return outBuf;
} }
/* /*
* Gives the name of operation performed. Will be used in case * Gives the name of operation performed. Will be used in case
* of error. * of error.
*/ */
public string GetVerbName() public string GetVerbName()
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
return (this.ToString()); return (this.ToString());
} }
} }
} }

View File

@ -20,120 +20,120 @@
* *
***********************************************************************/ ***********************************************************************/
using System; using System;
using System.Collections; using System.Collections;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using sscs.verbs; using sscs.verbs;
using sscs.common; using sscs.common;
using sscs.cache; using sscs.cache;
using sscs.constants; using sscs.constants;
namespace sscs.verbs namespace sscs.verbs
{ {
/* /*
* This class is implementation of CloseSecretStore call. * This class is implementation of CloseSecretStore call.
* There will be one instance existing for every call made by the client. * There will be one instance existing for every call made by the client.
*/ */
internal class CloseSecretStore : SSVerb internal class CloseSecretStore : SSVerb
{ {
private ushort msgId = 0; private ushort msgId = 0;
private uint inMsgLen = 0; private uint inMsgLen = 0;
private uint outMsgLen = 0; private uint outMsgLen = 0;
private byte[] inBuf; private byte[] inBuf;
private byte[] outBuf; private byte[] outBuf;
private int retCode = 0; private int retCode = 0;
/* /*
* This method sets the class member with the byte array received. * This method sets the class member with the byte array received.
*/ */
public void SetMessageContent(byte[] ipcBytes) public void SetMessageContent(byte[] ipcBytes)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes; inBuf = ipcBytes;
} }
/* /*
* This method does the actual implementation of CloseSecretStore * This method does the actual implementation of CloseSecretStore
* *
*/ */
public byte[] ProcessRequest(UserIdentifier userId) public byte[] ProcessRequest(UserIdentifier userId)
{ {
/* If an exception occurs in message format decoding, /* If an exception occurs in message format decoding,
* it is handled by AppHandler * it is handled by AppHandler
*/ */
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
// Message Format decipher - Start // Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0); msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2); inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length ) if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received."); throw new FormatException(" MsgLen sent does not match the length of the message received.");
uint ssFlags = BitConverter.ToUInt32(inBuf,6); uint ssFlags = BitConverter.ToUInt32(inBuf,6);
// Message Format decipher - End // Message Format decipher - End
try try
{ {
if ((ssFlags & ConstFlags.SSFLAGS_DESTROY_SESSION_F) == ConstFlags.SSFLAGS_DESTROY_SESSION_F) if ((ssFlags & ConstFlags.SSFLAGS_DESTROY_SESSION_F) == ConstFlags.SSFLAGS_DESTROY_SESSION_F)
{ {
#if W32 #if W32
SessionManager.RemoveUserSession(userId, true); SessionManager.RemoveUserSession(userId, true);
#else #else
SessionManager.CheckAndDestroySession(userId, true); SessionManager.CheckAndDestroySession(userId, true);
#endif #endif
} }
else else
SessionManager.RemoveUserSession(userId, false); SessionManager.RemoveUserSession(userId, false);
} }
catch(Exception) catch(Exception)
{ {
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Exception encountered in removing user session."); CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Exception encountered in removing user session.");
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
// Construct a Reply. // Construct a Reply.
try try
{ {
msgId = 2; msgId = 2;
outMsgLen = 10; outMsgLen = 10;
outBuf = new byte[10]; outBuf = new byte[10];
byte[] t = new byte[10]; byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId); t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2); Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen); t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4); Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(retCode); t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,6,4); Array.Copy(t,0,outBuf,6,4);
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString()); throw new FormatException("Unable to form the response " + e.ToString());
} }
return outBuf; return outBuf;
} }
/* /*
* Gives the name of operation performed. Will be used in case * Gives the name of operation performed. Will be used in case
* of error. * of error.
*/ */
public string GetVerbName() public string GetVerbName()
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
return this.ToString(); return this.ToString();
} }
} }
} }

View File

@ -20,134 +20,134 @@
* *
***********************************************************************/ ***********************************************************************/
using System; using System;
using System.Collections; using System.Collections;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using sscs.verbs; using sscs.verbs;
using sscs.cache; using sscs.cache;
using sscs.common; using sscs.common;
using sscs.constants; using sscs.constants;
namespace sscs.verbs namespace sscs.verbs
{ {
/* /*
* This class is implementation of EnumerateKeyChainIds call. * This class is implementation of EnumerateKeyChainIds call.
* There will be one instance existing for every call made by the client. * There will be one instance existing for every call made by the client.
*/ */
internal class EnumerateKeyChainIds : SSVerb internal class EnumerateKeyChainIds : SSVerb
{ {
private ushort msgId = 0; private ushort msgId = 0;
private uint inMsgLen = 0; private uint inMsgLen = 0;
private uint outMsgLen = 0; private uint outMsgLen = 0;
private int retCode = 0; private int retCode = 0;
private byte[] inBuf; private byte[] inBuf;
private byte[] outBuf; private byte[] outBuf;
/* /*
* This method sets the class member with the byte array received. * This method sets the class member with the byte array received.
*/ */
public void SetMessageContent(byte[] ipcBytes) public void SetMessageContent(byte[] ipcBytes)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes; inBuf = ipcBytes;
} }
/* /*
* This method does the actual implementation of EnumerateKeyChainIds * This method does the actual implementation of EnumerateKeyChainIds
* *
*/ */
public byte[] ProcessRequest(UserIdentifier userId) public byte[] ProcessRequest(UserIdentifier userId)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
int keyChainIdsLen = 0; int keyChainIdsLen = 0;
StringBuilder keyChainIds = new StringBuilder(); StringBuilder keyChainIds = new StringBuilder();
/* If an exception occurs in message format decoding, /* If an exception occurs in message format decoding,
* it is handled by AppHandler * it is handled by AppHandler
*/ */
// Message Format decipher - Start // Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0); msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2); inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length ) if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received."); throw new FormatException(" MsgLen sent does not match the length of the message received.");
// Message Format decipher - End // Message Format decipher - End
try try
{ {
int index = 0; int index = 0;
SecretStore ssStore = SessionManager.GetUserSecretStore(userId); SecretStore ssStore = SessionManager.GetUserSecretStore(userId);
int numKeyChains = ssStore.GetNumKeyChains(); int numKeyChains = ssStore.GetNumKeyChains();
IDictionaryEnumerator etor = (IDictionaryEnumerator)ssStore.GetKeyChainEnumerator(); IDictionaryEnumerator etor = (IDictionaryEnumerator)ssStore.GetKeyChainEnumerator();
while(etor.MoveNext()) while(etor.MoveNext())
{ {
index++; index++;
keyChainIds.Append((string)etor.Key,0,(((string)(etor.Key)).Length)-1); keyChainIds.Append((string)etor.Key,0,(((string)(etor.Key)).Length)-1);
keyChainIdsLen += ((string)(etor.Key)).Length-1; keyChainIdsLen += ((string)(etor.Key)).Length-1;
if( index != numKeyChains ) if( index != numKeyChains )
{ {
keyChainIds.Append("*"); keyChainIds.Append("*");
keyChainIdsLen += 1; keyChainIdsLen += 1;
} }
} }
} }
catch(UserNotInSessionException) catch(UserNotInSessionException)
{ {
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" ); CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
// Construct a Reply. // Construct a Reply.
try try
{ {
msgId = 4; msgId = 4;
outMsgLen = 14 + (uint)keyChainIds.Length; outMsgLen = 14 + (uint)keyChainIds.Length;
outBuf = new byte[outMsgLen]; outBuf = new byte[outMsgLen];
byte[] t = new byte[10]; byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId); t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2); Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen); t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4); Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(keyChainIdsLen); t = BitConverter.GetBytes(keyChainIdsLen);
Array.Copy(t,0,outBuf,6,4); Array.Copy(t,0,outBuf,6,4);
Encoding.UTF8.GetBytes(keyChainIds.ToString(),0,keyChainIds.Length,outBuf,10); Encoding.UTF8.GetBytes(keyChainIds.ToString(),0,keyChainIds.Length,outBuf,10);
t = BitConverter.GetBytes(retCode); t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,(10+keyChainIds.Length),4); Array.Copy(t,0,outBuf,(10+keyChainIds.Length),4);
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString()); throw new FormatException("Unable to form the response " + e.ToString());
} }
return outBuf; return outBuf;
} }
/* /*
* Gives the name of operation performed. Will be used in case * Gives the name of operation performed. Will be used in case
* of error. * of error.
*/ */
public string GetVerbName() public string GetVerbName()
{ {
return this.ToString(); return this.ToString();
} }
} }
} }

View File

@ -20,157 +20,157 @@
* *
***********************************************************************/ ***********************************************************************/
using System; using System;
using System.Collections; using System.Collections;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using sscs.verbs; using sscs.verbs;
using sscs.cache; using sscs.cache;
using sscs.common; using sscs.common;
using sscs.constants; using sscs.constants;
namespace sscs.verbs namespace sscs.verbs
{ {
/* /*
* This class is implementation of EnumerateSecretIds call. * This class is implementation of EnumerateSecretIds call.
* There will be one instance existing for every call made by the client. * There will be one instance existing for every call made by the client.
*/ */
internal class EnumerateSecretIds : SSVerb internal class EnumerateSecretIds : SSVerb
{ {
private ushort msgId = 0; private ushort msgId = 0;
private uint inMsgLen = 0; private uint inMsgLen = 0;
private uint outMsgLen = 0; private uint outMsgLen = 0;
private uint keyChainIdLen = 0; private uint keyChainIdLen = 0;
private string keyChainId; private string keyChainId;
private int retCode = 0; private int retCode = 0;
private byte[] inBuf; private byte[] inBuf;
private byte[] outBuf; private byte[] outBuf;
/* /*
* This method sets the class member with the byte array received. * This method sets the class member with the byte array received.
*/ */
public void SetMessageContent(byte[] ipcBytes) public void SetMessageContent(byte[] ipcBytes)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes; inBuf = ipcBytes;
} }
/* /*
* This method does the actual implementation of EnumerateSecretIds * This method does the actual implementation of EnumerateSecretIds
* *
*/ */
public byte[] ProcessRequest(UserIdentifier userId) public byte[] ProcessRequest(UserIdentifier userId)
{ {
/* If an exception occurs in message format decoding, /* If an exception occurs in message format decoding,
* it is handled by AppHandler * it is handled by AppHandler
*/ */
int secretIdsLen = 0; int secretIdsLen = 0;
StringBuilder secretIds = new StringBuilder(); StringBuilder secretIds = new StringBuilder();
// Message Format decipher - Start // Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0); msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2); inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length ) if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received."); throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6); keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen]; byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen); Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr); keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
// Message Format decipher - End // Message Format decipher - End
try try
{ {
SecretStore ssStore = SessionManager.GetUserSecretStore(userId); SecretStore ssStore = SessionManager.GetUserSecretStore(userId);
if (!ssStore.IsStoreLocked()) if (!ssStore.IsStoreLocked())
{ {
if( ssStore.CheckIfKeyChainExists(keyChainId) ) if( ssStore.CheckIfKeyChainExists(keyChainId) )
{ {
KeyChain keyChain = ssStore.GetKeyChain(keyChainId); KeyChain keyChain = ssStore.GetKeyChain(keyChainId);
int numSecrets = keyChain.GetNumSecrets(); int numSecrets = keyChain.GetNumSecrets();
int index = 0; int index = 0;
IDictionaryEnumerator etor = (IDictionaryEnumerator)keyChain.GetAllSecrets(); IDictionaryEnumerator etor = (IDictionaryEnumerator)keyChain.GetAllSecrets();
while(etor.MoveNext()) while(etor.MoveNext())
{ {
index++; index++;
secretIds.Append((string)etor.Key,0,(((string)(etor.Key)).Length)-1); secretIds.Append((string)etor.Key,0,(((string)(etor.Key)).Length)-1);
secretIdsLen += ((string)(etor.Key)).Length-1; secretIdsLen += ((string)(etor.Key)).Length-1;
if( index != numSecrets ) if( index != numSecrets )
{ {
secretIds.Append("*"); secretIds.Append("*");
secretIdsLen += 1; secretIdsLen += 1;
} }
} }
} }
else else
{ {
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST; retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
} }
} }
else else
{ {
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED; retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
} }
} }
catch(UserNotInSessionException) catch(UserNotInSessionException)
{ {
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" ); CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
catch(Exception) catch(Exception)
{ {
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
//Construct a reply. //Construct a reply.
try try
{ {
msgId = 7; msgId = 7;
outMsgLen = 14 + (uint)secretIds.Length; outMsgLen = 14 + (uint)secretIds.Length;
outBuf = new byte[outMsgLen]; outBuf = new byte[outMsgLen];
byte[] t = new byte[10]; byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId); t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2); Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen); t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4); Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(secretIdsLen); t = BitConverter.GetBytes(secretIdsLen);
Array.Copy(t,0,outBuf,6,4); Array.Copy(t,0,outBuf,6,4);
Encoding.UTF8.GetBytes(secretIds.ToString(),0,secretIds.Length,outBuf,10); Encoding.UTF8.GetBytes(secretIds.ToString(),0,secretIds.Length,outBuf,10);
t = BitConverter.GetBytes(retCode); t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,(10+secretIds.Length),4); Array.Copy(t,0,outBuf,(10+secretIds.Length),4);
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString()); throw new FormatException("Unable to form the response " + e.ToString());
} }
return outBuf; return outBuf;
} }
/* /*
* Gives the name of operation performed. Will be used in case * Gives the name of operation performed. Will be used in case
* of error. * of error.
*/ */
public string GetVerbName() public string GetVerbName()
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
return this.ToString(); return this.ToString();
} }
} }
} }

View File

@ -20,123 +20,123 @@
* *
***********************************************************************/ ***********************************************************************/
using System; using System;
using System.Collections; using System.Collections;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using sscs.verbs; using sscs.verbs;
using sscs.common; using sscs.common;
using sscs.cache; using sscs.cache;
using sscs.constants; using sscs.constants;
namespace sscs.verbs namespace sscs.verbs
{ {
/* /*
* This class is implementation of GetSecretStoreInfo call. * This class is implementation of GetSecretStoreInfo call.
* There will be one instance existing for every call made by the client. * There will be one instance existing for every call made by the client.
*/ */
internal class GetSecretStoreInfo : SSVerb internal class GetSecretStoreInfo : SSVerb
{ {
private ushort msgId = 0; private ushort msgId = 0;
private uint inMsgLen = 0; private uint inMsgLen = 0;
private uint outMsgLen = 0; private uint outMsgLen = 0;
private uint numKeyChains = 0; private uint numKeyChains = 0;
private byte[] inBuf; private byte[] inBuf;
private byte[] outBuf; private byte[] outBuf;
private int retCode = 0; private int retCode = 0;
/* /*
* This method sets the class member with the byte array received. * This method sets the class member with the byte array received.
*/ */
public void SetMessageContent(byte[] ipcBytes) public void SetMessageContent(byte[] ipcBytes)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes; inBuf = ipcBytes;
} }
/* /*
* This method does the actual implementation of GetSecretStoreInfo * This method does the actual implementation of GetSecretStoreInfo
* *
*/ */
public byte[] ProcessRequest(UserIdentifier userId) public byte[] ProcessRequest(UserIdentifier userId)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
/* If an exception occurs in message format decoding, /* If an exception occurs in message format decoding,
* it is handled by AppHandler * it is handled by AppHandler
*/ */
// Message Format decipher - Start // Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0); msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2); inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length ) if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received."); throw new FormatException(" MsgLen sent does not match the length of the message received.");
// Message Format decipher - End // Message Format decipher - End
try try
{ {
SecretStore ssStore = SessionManager.GetUserSecretStore(userId); SecretStore ssStore = SessionManager.GetUserSecretStore(userId);
numKeyChains = (uint) ssStore.GetNumKeyChains(); numKeyChains = (uint) ssStore.GetNumKeyChains();
} }
catch(UserNotInSessionException) catch(UserNotInSessionException)
{ {
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" ); CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
// Construct Response // Construct Response
try try
{ {
msgId = 11; msgId = 11;
outMsgLen = 14; outMsgLen = 14;
outBuf = new byte[outMsgLen]; outBuf = new byte[outMsgLen];
byte[] t = new byte[10]; byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId); t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2); Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen); t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4); Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(numKeyChains); t = BitConverter.GetBytes(numKeyChains);
Array.Copy(t,0,outBuf,6,4); Array.Copy(t,0,outBuf,6,4);
t = BitConverter.GetBytes(retCode); t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,10,4); Array.Copy(t,0,outBuf,10,4);
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString()); throw new FormatException("Unable to form the response " + e.ToString());
} }
return outBuf; return outBuf;
} }
/* /*
* Gives the name of operation performed. Will be used in case * Gives the name of operation performed. Will be used in case
* of error. * of error.
*/ */
public string GetVerbName() public string GetVerbName()
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
return this.ToString(); return this.ToString();
} }
} }
} }

View File

@ -20,37 +20,37 @@
* *
***********************************************************************/ ***********************************************************************/
using System; using System;
using System.Collections; using System.Collections;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using sscs.verbs; using sscs.verbs;
using sscs.common; using sscs.common;
namespace sscs.verbs namespace sscs.verbs
{ {
/* /*
* Defines the interfaces to be implemenetd by all Secret Store Verbs. * Defines the interfaces to be implemenetd by all Secret Store Verbs.
*/ */
interface SSVerb interface SSVerb
{ {
/* Takes in the raw bytes and sets them for a Verb, /* Takes in the raw bytes and sets them for a Verb,
* so that the verb will execute in the bytes given. * so that the verb will execute in the bytes given.
* TBD: In case we are able to send the byte[] through constructor, * TBD: In case we are able to send the byte[] through constructor,
* we can avoid this interface. * we can avoid this interface.
*/ */
void SetMessageContent(byte[] rawbytes); void SetMessageContent(byte[] rawbytes);
/* Takes in the SecretStore Reeference and returns the correct SSVerb /* Takes in the SecretStore Reeference and returns the correct SSVerb
*/ */
byte[] ProcessRequest(UserIdentifier userId); byte[] ProcessRequest(UserIdentifier userId);
//Gives the name of operation performed.Can be used in case of error. //Gives the name of operation performed.Can be used in case of error.
string GetVerbName(); string GetVerbName();
} }
} }

View File

@ -1,165 +1,165 @@
using System; using System;
using System.Collections; using System.Collections;
using sscs.verbs; using sscs.verbs;
using sscs.cache; using sscs.cache;
using sscs.common; using sscs.common;
using sscs.constants; using sscs.constants;
using sscs.lss; using sscs.lss;
namespace sscs.verbs namespace sscs.verbs
{ {
/// <summary> /// <summary>
/// Summary description for MergeCache. /// Summary description for MergeCache.
/// </summary> /// </summary>
internal class MergeCache : SSVerb internal class MergeCache : SSVerb
{ {
private ushort msgId = 0; private ushort msgId = 0;
private uint inMsgLen = 0; private uint inMsgLen = 0;
private uint outMsgLen = 0; private uint outMsgLen = 0;
private int retCode = 0; private int retCode = 0;
private byte[] inBuf; private byte[] inBuf;
private byte[] outBuf; private byte[] outBuf;
public void SetMessageContent(byte[] ipcBytes) public void SetMessageContent(byte[] ipcBytes)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes; inBuf = ipcBytes;
} }
/* /*
* This method does the actual implementation of MergeSecret * This method does the actual implementation of MergeSecret
* *
*/ */
public byte[] ProcessRequest(UserIdentifier userId) public byte[] ProcessRequest(UserIdentifier userId)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
UserIdentifier tempUserId = userId; UserIdentifier tempUserId = userId;
/* If an exception occurs in message format decoding, /* If an exception occurs in message format decoding,
* it is handled by AppHandler * it is handled by AppHandler
*/ */
// Message Format decipher - Start // Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf, 0); msgId = BitConverter.ToUInt16(inBuf, 0);
inMsgLen = BitConverter.ToUInt32(inBuf, 2); inMsgLen = BitConverter.ToUInt32(inBuf, 2);
if (inMsgLen != inBuf.Length) if (inMsgLen != inBuf.Length)
throw new FormatException(" MsgLen sent does not match the length of the message received."); throw new FormatException(" MsgLen sent does not match the length of the message received.");
// get the src LUID // get the src LUID
int luidLow = BitConverter.ToInt32(inBuf, 14); int luidLow = BitConverter.ToInt32(inBuf, 14);
int luidHigh = BitConverter.ToInt32(inBuf, 18); int luidHigh = BitConverter.ToInt32(inBuf, 18);
// get the target LUID // get the target LUID
int targetLuidLow = BitConverter.ToInt32(inBuf, 30); int targetLuidLow = BitConverter.ToInt32(inBuf, 30);
int targetLuidHigh = BitConverter.ToInt32(inBuf, 34); int targetLuidHigh = BitConverter.ToInt32(inBuf, 34);
// get destroy flag // get destroy flag
int iDestroySrcCache = BitConverter.ToInt32(inBuf, 38); int iDestroySrcCache = BitConverter.ToInt32(inBuf, 38);
CSSSLogger.DbgLog(" SRC LUID found: " + luidHigh.ToString() + ":"+ luidLow.ToString()); CSSSLogger.DbgLog(" SRC LUID found: " + luidHigh.ToString() + ":"+ luidLow.ToString());
CSSSLogger.DbgLog("Target LUID found: " + targetLuidHigh.ToString() +":" + targetLuidLow.ToString()); CSSSLogger.DbgLog("Target LUID found: " + targetLuidHigh.ToString() +":" + targetLuidLow.ToString());
#if W32 #if W32
// only allow the merge if the calling process is "System" // only allow the merge if the calling process is "System"
WinUserIdentifier callingUser = (WinUserIdentifier)userId; WinUserIdentifier callingUser = (WinUserIdentifier)userId;
if ((callingUser.GetUIDLow() == 999) && (callingUser.GetUIDHigh() == 0)) if ((callingUser.GetUIDLow() == 999) && (callingUser.GetUIDHigh() == 0))
{ {
CSSSLogger.DbgLog("MergeSecrets: Caller is system process"); CSSSLogger.DbgLog("MergeSecrets: Caller is system process");
// get the store for the src // get the store for the src
try try
{ {
//WinUserIdentifier srcUser = new WinUserIdentifier(luidLow, luidHigh); //WinUserIdentifier srcUser = new WinUserIdentifier(luidLow, luidHigh);
SecretStore srcStore = SessionManager.GetUserSecretStore(userId); SecretStore srcStore = SessionManager.GetUserSecretStore(userId);
KeyChain kcSrc = null; KeyChain kcSrc = null;
KeyChain kcDest = null; KeyChain kcDest = null;
// rename keychainID from SRC LUID to Target LUID. // rename keychainID from SRC LUID to Target LUID.
if (srcStore.CheckIfKeyChainExists(luidHigh.ToString() + luidLow.ToString())) if (srcStore.CheckIfKeyChainExists(luidHigh.ToString() + luidLow.ToString()))
{ {
kcSrc = srcStore.GetKeyChain(luidHigh.ToString() + luidLow.ToString()); kcSrc = srcStore.GetKeyChain(luidHigh.ToString() + luidLow.ToString());
kcDest = new KeyChain(targetLuidHigh.ToString() + targetLuidLow.ToString()); kcDest = new KeyChain(targetLuidHigh.ToString() + targetLuidLow.ToString());
if (!srcStore.CheckIfKeyChainExists(targetLuidHigh.ToString() + targetLuidLow.ToString())) if (!srcStore.CheckIfKeyChainExists(targetLuidHigh.ToString() + targetLuidLow.ToString()))
{ {
srcStore.AddKeyChain(kcDest); srcStore.AddKeyChain(kcDest);
} }
// merge secrets from src to dest keychain // merge secrets from src to dest keychain
IDictionaryEnumerator secIter = (IDictionaryEnumerator)(kcSrc.GetAllSecrets()); IDictionaryEnumerator secIter = (IDictionaryEnumerator)(kcSrc.GetAllSecrets());
while (secIter.MoveNext()) while (secIter.MoveNext())
{ {
Secret secret = (Secret)secIter.Value; Secret secret = (Secret)secIter.Value;
kcDest.AddSecret(secret); kcDest.AddSecret(secret);
} }
if (iDestroySrcCache > 0) if (iDestroySrcCache > 0)
{ {
srcStore.RemoveKeyChain(luidHigh.ToString() + luidLow.ToString()); srcStore.RemoveKeyChain(luidHigh.ToString() + luidLow.ToString());
} }
} }
else else
{ {
retCode = IPCRetCodes.SSCS_E_INVALID_INPUT; retCode = IPCRetCodes.SSCS_E_INVALID_INPUT;
} }
} }
catch (Exception e) catch (Exception e)
{ {
CSSSLogger.DbgLog(e.ToString()); CSSSLogger.DbgLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_INVALID_INPUT; retCode = IPCRetCodes.SSCS_E_INVALID_INPUT;
} }
} }
else else
{ {
CSSSLogger.DbgLog("Caller is NOT system process, Merge not allowed!"); CSSSLogger.DbgLog("Caller is NOT system process, Merge not allowed!");
retCode = IPCRetCodes.SSCS_E_INVALID_INPUT; retCode = IPCRetCodes.SSCS_E_INVALID_INPUT;
} }
#else #else
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
#endif #endif
try try
{ {
msgId = 19; msgId = 19;
outMsgLen = 10; outMsgLen = 10;
outBuf = new byte[10]; outBuf = new byte[10];
byte[] t = new byte[10]; byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId); t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t, 0, outBuf, 0, 2); Array.Copy(t, 0, outBuf, 0, 2);
t = BitConverter.GetBytes((uint)outMsgLen); t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t, 0, outBuf, 2, 4); Array.Copy(t, 0, outBuf, 2, 4);
t = BitConverter.GetBytes(retCode); t = BitConverter.GetBytes(retCode);
Array.Copy(t, 0, outBuf, 6, 4); Array.Copy(t, 0, outBuf, 6, 4);
} }
catch (Exception e) catch (Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString()); throw new FormatException("Unable to form the response " + e.ToString());
} }
return outBuf; return outBuf;
} }
/* /*
* Gives the name of operation performed. Will be used in case * Gives the name of operation performed. Will be used in case
* of error. * of error.
*/ */
public string GetVerbName() public string GetVerbName()
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
return this.ToString(); return this.ToString();
} }
} }
} }

View File

@ -20,134 +20,134 @@
* *
***********************************************************************/ ***********************************************************************/
using System; using System;
using System.Collections; using System.Collections;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using sscs.verbs; using sscs.verbs;
using sscs.cache; using sscs.cache;
using sscs.common; using sscs.common;
using sscs.constants; using sscs.constants;
namespace sscs.verbs namespace sscs.verbs
{ {
/* /*
* This class is implementation of OpenSecretStore call. * This class is implementation of OpenSecretStore call.
* There will be one instance existing for every call made by the client. * There will be one instance existing for every call made by the client.
*/ */
internal class OpenSecretStore : SSVerb internal class OpenSecretStore : SSVerb
{ {
ushort msgId = 0; ushort msgId = 0;
uint inMsgLen = 0; uint inMsgLen = 0;
uint outMsgLen = 0; uint outMsgLen = 0;
uint ssVersion = 0; uint ssVersion = 0;
uint ssNameLen = 0; uint ssNameLen = 0;
private string ssName; //Name of SecretStore to open private string ssName; //Name of SecretStore to open
private byte[] inBuf; private byte[] inBuf;
private byte[] outBuf; private byte[] outBuf;
int retCode = 0; int retCode = 0;
private static int MAX_SS_NAME_LEN = 256; private static int MAX_SS_NAME_LEN = 256;
/* /*
* This method sets the class member with the byte array received. * This method sets the class member with the byte array received.
*/ */
public void SetMessageContent(byte[] ipcBytes) public void SetMessageContent(byte[] ipcBytes)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes; inBuf = ipcBytes;
} }
/* /*
* This method does the actual implementation of OpenSecretStore * This method does the actual implementation of OpenSecretStore
* *
*/ */
public byte[] ProcessRequest(UserIdentifier userId) public byte[] ProcessRequest(UserIdentifier userId)
{ {
/* If an exception occurs in message format decoding, /* If an exception occurs in message format decoding,
* it is handled by AppHandler * it is handled by AppHandler
*/ */
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
msgId = BitConverter.ToUInt16(inBuf,0); msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2); inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length ) if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received."); throw new FormatException(" MsgLen sent does not match the length of the message received.");
ssVersion = BitConverter.ToUInt32(inBuf,6); ssVersion = BitConverter.ToUInt32(inBuf,6);
ssNameLen = BitConverter.ToUInt32(inBuf,10); ssNameLen = BitConverter.ToUInt32(inBuf,10);
if (ssNameLen > MAX_SS_NAME_LEN) if (ssNameLen > MAX_SS_NAME_LEN)
throw new FormatException(" SecretStore Name length exceeds length allowed"); throw new FormatException(" SecretStore Name length exceeds length allowed");
byte[] tempArr = new byte[ssNameLen]; byte[] tempArr = new byte[ssNameLen];
Array.Copy(inBuf,14,tempArr,0,ssNameLen); Array.Copy(inBuf,14,tempArr,0,ssNameLen);
ssName = Encoding.UTF8.GetString(tempArr); ssName = Encoding.UTF8.GetString(tempArr);
try try
{ {
SecretStore ss = SessionManager.CreateUserSession(userId); SecretStore ss = SessionManager.CreateUserSession(userId);
if( null == ss ) if( null == ss )
{ {
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " SecretStore instance is null"); CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " SecretStore instance is null");
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
else else
{ {
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " + - Created a new Session entry"); CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " + - Created a new Session entry");
} }
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
try try
{ {
msgId = 1; msgId = 1;
outMsgLen = 14; outMsgLen = 14;
outBuf = new byte[14]; outBuf = new byte[14];
byte[] t = new byte[10]; byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId); t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2); Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen); t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4); Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes((uint)ssVersion); t = BitConverter.GetBytes((uint)ssVersion);
Array.Copy(t,0,outBuf,6,4); Array.Copy(t,0,outBuf,6,4);
t = BitConverter.GetBytes(retCode); t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,10,4); Array.Copy(t,0,outBuf,10,4);
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString()); throw new FormatException("Unable to form the response " + e.ToString());
} }
return outBuf; return outBuf;
} }
/* /*
* Gives the name of operation performed. Will be used in case * Gives the name of operation performed. Will be used in case
* of error. * of error.
*/ */
public string GetVerbName() public string GetVerbName()
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
return this.ToString(); return this.ToString();
} }
} }
} }

View File

@ -20,42 +20,42 @@
* *
***********************************************************************/ ***********************************************************************/
using System; using System;
using System.Collections; using System.Collections;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using sscs.verbs; using sscs.verbs;
using sscs.cache; using sscs.cache;
using sscs.common; using sscs.common;
using sscs.constants; using sscs.constants;
namespace sscs.verbs namespace sscs.verbs
{ {
/* /*
* This class is implementation of ReadKey call. * This class is implementation of ReadKey call.
* There will be one instance existing for every call made by the client. * There will be one instance existing for every call made by the client.
*/ */
internal class ReadBinaryKey : SSVerb internal class ReadBinaryKey : SSVerb
{ {
private ushort msgId = 0; private ushort msgId = 0;
private uint inMsgLen = 0; private uint inMsgLen = 0;
private uint outMsgLen = 0; private uint outMsgLen = 0;
private uint keyChainIdLen = 0; private uint keyChainIdLen = 0;
private uint secretIdLen = 0; private uint secretIdLen = 0;
private int retCode = 0; private int retCode = 0;
private string keyChainId; private string keyChainId;
private string secretId; private string secretId;
private uint keyLen; private uint keyLen;
private string key; private string key;
private uint valLen; private uint valLen;
private byte[] val; private byte[] val;
//private byte[] secretVal; //private byte[] secretVal;
private byte[] inBuf; private byte[] inBuf;
private byte[] outBuf; private byte[] outBuf;
// extension operations // extension operations
private uint extId = 0; private uint extId = 0;
#if W32 #if W32
@ -63,59 +63,59 @@ namespace sscs.verbs
private int luidHigh = 0; private int luidHigh = 0;
#endif #endif
/* /*
* This method sets the class member with the byte array received. * This method sets the class member with the byte array received.
*/ */
public void SetMessageContent(byte[] ipcBytes) public void SetMessageContent(byte[] ipcBytes)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes; inBuf = ipcBytes;
} }
/* /*
* This method does the actual implementation of ReadKey * This method does the actual implementation of ReadKey
* *
*/ */
public byte[] ProcessRequest(UserIdentifier userId) public byte[] ProcessRequest(UserIdentifier userId)
{ {
Secret secret = null; Secret secret = null;
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
UserIdentifier tempUserId = userId; UserIdentifier tempUserId = userId;
/* If an exception occurs in message format decoding, /* If an exception occurs in message format decoding,
* it is handled by AppHandler * it is handled by AppHandler
*/ */
// Message Format decipher - Start // Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0); msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2); inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length ) if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received."); throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6); keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen]; byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen); Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr); keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
secretIdLen = BitConverter.ToUInt32(inBuf, secretIdLen = BitConverter.ToUInt32(inBuf,
(10 + (int)keyChainIdLen)); (10 + (int)keyChainIdLen));
byte[] secretIdArr = new byte[secretIdLen]; byte[] secretIdArr = new byte[secretIdLen];
Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen); Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen);
secretId = Encoding.UTF8.GetString(secretIdArr); secretId = Encoding.UTF8.GetString(secretIdArr);
// Message Format decipher - End // Message Format decipher - End
keyLen = BitConverter.ToUInt32(inBuf,(14+(int)keyChainIdLen+(int)secretIdLen)); keyLen = BitConverter.ToUInt32(inBuf,(14+(int)keyChainIdLen+(int)secretIdLen));
byte[] keyArr = new byte[keyLen]; byte[] keyArr = new byte[keyLen];
Array.Copy(inBuf,(18+(int)keyChainIdLen+(int)secretIdLen),keyArr,0,keyLen); Array.Copy(inBuf,(18+(int)keyChainIdLen+(int)secretIdLen),keyArr,0,keyLen);
key = Encoding.UTF8.GetString(keyArr); key = Encoding.UTF8.GetString(keyArr);
try try
{ {
// get extension ID // get extension ID
@ -128,125 +128,125 @@ namespace sscs.verbs
} }
SecretStore ssStore; SecretStore ssStore;
if (extId == 1) if (extId == 1)
{ {
#if W32 #if W32
CSSSLogger.DbgLog("LUID ExtID found"); CSSSLogger.DbgLog("LUID ExtID found");
WinUserIdentifier test = (WinUserIdentifier)userId; WinUserIdentifier test = (WinUserIdentifier)userId;
// NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM" // NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM"
if ((test.GetUIDLow() == 999) && (test.GetUIDHigh() == 0)) if ((test.GetUIDLow() == 999) && (test.GetUIDHigh() == 0))
{ {
// WINDOWS LUID // WINDOWS LUID
// System Services, like DLU create fake UIDs, store credentials and then want to read that data. // System Services, like DLU create fake UIDs, store credentials and then want to read that data.
luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 8); luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 8);
luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 12); luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 12);
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in. // this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter. // ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString(); keyChainId = luidHigh.ToString() + luidLow.ToString();
CSSSLogger.DbgLog("ReadBinaryKey: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]"); CSSSLogger.DbgLog("ReadBinaryKey: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]");
} }
#endif #endif
} }
try try
{ {
KeyChain keyChain = null; KeyChain keyChain = null;
// Secret secret = null; // Secret secret = null;
ssStore = SessionManager.GetUserSecretStore(tempUserId); ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.IsStoreLocked()) if (!ssStore.IsStoreLocked())
{ {
if( ssStore.CheckIfKeyChainExists(keyChainId) ) if( ssStore.CheckIfKeyChainExists(keyChainId) )
{ {
keyChain = ssStore.GetKeyChain(keyChainId); keyChain = ssStore.GetKeyChain(keyChainId);
if( keyChain.CheckIfSecretExists(secretId) == false) if( keyChain.CheckIfSecretExists(secretId) == false)
{ {
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST; retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
} }
else else
{ {
secret = keyChain.GetSecret(secretId); secret = keyChain.GetSecret(secretId);
KeyValue kv = secret.GetKeyValue(key); KeyValue kv = secret.GetKeyValue(key);
if (kv != null) if (kv != null)
{ {
val = kv.GetValueAsBytes(); val = kv.GetValueAsBytes();
} }
else else
{ {
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST; retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
} }
} }
} }
else else
{ {
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST; retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
} }
} }
else else
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED; retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
} }
catch(UserNotInSessionException) catch(UserNotInSessionException)
{ {
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable user's secretstore" ); CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
try try
{ {
msgId = 16; msgId = 16;
if( 0 == retCode ) if( 0 == retCode )
{ {
valLen = (uint)val.Length; valLen = (uint)val.Length;
outMsgLen = 14 + valLen; outMsgLen = 14 + valLen;
} }
else else
{ {
outMsgLen = 14; //2+4+4+4 outMsgLen = 14; //2+4+4+4
} }
outBuf = new byte[outMsgLen]; outBuf = new byte[outMsgLen];
byte[] t = new byte[10]; byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId); t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2); Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen); t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4); Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(valLen); t = BitConverter.GetBytes(valLen);
Array.Copy(t,0,outBuf,6,4); Array.Copy(t,0,outBuf,6,4);
if( 0 == retCode ) if( 0 == retCode )
Array.Copy(val,0,outBuf,10,valLen); Array.Copy(val,0,outBuf,10,valLen);
t = BitConverter.GetBytes(retCode); t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,10+valLen,4); Array.Copy(t,0,outBuf,10+valLen,4);
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString()); throw new FormatException("Unable to form the response " + e.ToString());
} }
return outBuf; return outBuf;
} }
/* /*
* Gives the name of operation performed. Will be used in case * Gives the name of operation performed. Will be used in case
* of error. * of error.
*/ */
public string GetVerbName() public string GetVerbName()
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
return this.ToString(); return this.ToString();
} }
} }
} }

View File

@ -20,102 +20,102 @@
* *
***********************************************************************/ ***********************************************************************/
using System; using System;
using System.Collections; using System.Collections;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using sscs.verbs; using sscs.verbs;
using sscs.cache; using sscs.cache;
using sscs.common; using sscs.common;
using sscs.constants; using sscs.constants;
namespace sscs.verbs namespace sscs.verbs
{ {
/* /*
* This class is implementation of ReadKey call. * This class is implementation of ReadKey call.
* There will be one instance existing for every call made by the client. * There will be one instance existing for every call made by the client.
*/ */
internal class ReadKey : SSVerb internal class ReadKey : SSVerb
{ {
private ushort msgId = 0; private ushort msgId = 0;
private uint inMsgLen = 0; private uint inMsgLen = 0;
private uint outMsgLen = 0; private uint outMsgLen = 0;
private uint keyChainIdLen = 0; private uint keyChainIdLen = 0;
private uint secretIdLen = 0; private uint secretIdLen = 0;
private int retCode = 0; private int retCode = 0;
private string keyChainId; private string keyChainId;
private string secretId; private string secretId;
private uint keyLen; private uint keyLen;
private string key; private string key;
private uint valLen; private uint valLen;
private byte[] val; private byte[] val;
//private byte[] secretVal; //private byte[] secretVal;
private byte[] inBuf; private byte[] inBuf;
private byte[] outBuf; private byte[] outBuf;
// extension operations // extension operations
private uint extId = 0; private uint extId = 0;
#if W32 #if W32
private int luidLow = 0; private int luidLow = 0;
private int luidHigh = 0; private int luidHigh = 0;
#endif #endif
/* /*
* This method sets the class member with the byte array received. * This method sets the class member with the byte array received.
*/ */
public void SetMessageContent(byte[] ipcBytes) public void SetMessageContent(byte[] ipcBytes)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes; inBuf = ipcBytes;
} }
/* /*
* This method does the actual implementation of ReadKey * This method does the actual implementation of ReadKey
* *
*/ */
public byte[] ProcessRequest(UserIdentifier userId) public byte[] ProcessRequest(UserIdentifier userId)
{ {
Secret secret = null; Secret secret = null;
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
UserIdentifier tempUserId = userId; UserIdentifier tempUserId = userId;
/* If an exception occurs in message format decoding, /* If an exception occurs in message format decoding,
* it is handled by AppHandler * it is handled by AppHandler
*/ */
// Message Format decipher - Start // Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0); msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2); inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length ) if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received."); throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6); keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen]; byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen); Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr); keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
secretIdLen = BitConverter.ToUInt32(inBuf, secretIdLen = BitConverter.ToUInt32(inBuf,
(10 + (int)keyChainIdLen)); (10 + (int)keyChainIdLen));
byte[] secretIdArr = new byte[secretIdLen]; byte[] secretIdArr = new byte[secretIdLen];
Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen); Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen);
secretId = Encoding.UTF8.GetString(secretIdArr); secretId = Encoding.UTF8.GetString(secretIdArr);
// Message Format decipher - End // Message Format decipher - End
keyLen = BitConverter.ToUInt32(inBuf,(14+(int)keyChainIdLen+(int)secretIdLen)); keyLen = BitConverter.ToUInt32(inBuf,(14+(int)keyChainIdLen+(int)secretIdLen));
byte[] keyArr = new byte[keyLen]; byte[] keyArr = new byte[keyLen];
Array.Copy(inBuf,(18+(int)keyChainIdLen+(int)secretIdLen),keyArr,0,keyLen); Array.Copy(inBuf,(18+(int)keyChainIdLen+(int)secretIdLen),keyArr,0,keyLen);
key = Encoding.UTF8.GetString(keyArr); key = Encoding.UTF8.GetString(keyArr);
try try
{ {
// get extension ID // get extension ID
@ -130,124 +130,124 @@ namespace sscs.verbs
SecretStore ssStore; SecretStore ssStore;
if (extId == 1) if (extId == 1)
{ {
#if W32 #if W32
CSSSLogger.DbgLog("LUID ExtID found"); CSSSLogger.DbgLog("LUID ExtID found");
WinUserIdentifier test = (WinUserIdentifier)userId; WinUserIdentifier test = (WinUserIdentifier)userId;
// NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM" // NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM"
if ((test.GetUIDLow() == 999) && (test.GetUIDHigh() == 0)) if ((test.GetUIDLow() == 999) && (test.GetUIDHigh() == 0))
{ {
// WINDOWS LUID // WINDOWS LUID
// System Services, like DLU create fake UIDs, store credentials and then want to read that data. // System Services, like DLU create fake UIDs, store credentials and then want to read that data.
luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 8); luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 8);
luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 12); luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 12);
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in. // this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter. // ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString(); keyChainId = luidHigh.ToString() + luidLow.ToString();
CSSSLogger.DbgLog("ReadKey: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]"); CSSSLogger.DbgLog("ReadKey: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]");
} }
#endif #endif
} }
try try
{ {
KeyChain keyChain = null; KeyChain keyChain = null;
ssStore = SessionManager.GetUserSecretStore(tempUserId); ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.IsStoreLocked()) if (!ssStore.IsStoreLocked())
{ {
if( ssStore.CheckIfKeyChainExists(keyChainId) ) if( ssStore.CheckIfKeyChainExists(keyChainId) )
{ {
keyChain = ssStore.GetKeyChain(keyChainId); keyChain = ssStore.GetKeyChain(keyChainId);
if( keyChain.CheckIfSecretExists(secretId) == false) if( keyChain.CheckIfSecretExists(secretId) == false)
{ {
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST; retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
} }
else else
{ {
secret = keyChain.GetSecret(secretId); secret = keyChain.GetSecret(secretId);
KeyValue kv = secret.GetKeyValue(key); KeyValue kv = secret.GetKeyValue(key);
if ((kv != null) && (kv.GetValue().Length > 0)) if ((kv != null) && (kv.GetValue().Length > 0))
{ {
string valStr = secret.GetKeyValue(key).GetValue(); string valStr = secret.GetKeyValue(key).GetValue();
val = Encoding.UTF8.GetBytes(valStr); val = Encoding.UTF8.GetBytes(valStr);
} }
else else
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST; retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
} }
} }
else else
{ {
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST; retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
} }
} }
else else
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED; retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
} }
catch(UserNotInSessionException) catch(UserNotInSessionException)
{ {
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable user's secretstore" ); CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
try try
{ {
msgId = 16; msgId = 16;
if( 0 == retCode ) if( 0 == retCode )
{ {
valLen = (uint)val.Length; valLen = (uint)val.Length;
outMsgLen = 14 + valLen; outMsgLen = 14 + valLen;
} }
else else
{ {
outMsgLen = 14; //2+4+4+4 outMsgLen = 14; //2+4+4+4
} }
outBuf = new byte[outMsgLen]; outBuf = new byte[outMsgLen];
byte[] t = new byte[10]; byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId); t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2); Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen); t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4); Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(valLen); t = BitConverter.GetBytes(valLen);
Array.Copy(t,0,outBuf,6,4); Array.Copy(t,0,outBuf,6,4);
if( 0 == retCode ) if( 0 == retCode )
Array.Copy(val,0,outBuf,10,valLen); Array.Copy(val,0,outBuf,10,valLen);
t = BitConverter.GetBytes(retCode); t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,10+valLen,4); Array.Copy(t,0,outBuf,10+valLen,4);
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString()); throw new FormatException("Unable to form the response " + e.ToString());
} }
return outBuf; return outBuf;
} }
/* /*
* Gives the name of operation performed. Will be used in case * Gives the name of operation performed. Will be used in case
* of error. * of error.
*/ */
public string GetVerbName() public string GetVerbName()
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
return this.ToString(); return this.ToString();
} }
} }
} }

View File

@ -20,37 +20,37 @@
* *
***********************************************************************/ ***********************************************************************/
using System; using System;
using System.Collections; using System.Collections;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using sscs.verbs; using sscs.verbs;
using sscs.cache; using sscs.cache;
using sscs.common; using sscs.common;
using sscs.constants; using sscs.constants;
namespace sscs.verbs namespace sscs.verbs
{ {
/* /*
* This class is implementation of ReadSecret call. * This class is implementation of ReadSecret call.
* There will be one instance existing for every call made by the client. * There will be one instance existing for every call made by the client.
*/ */
internal class ReadSecret : SSVerb internal class ReadSecret : SSVerb
{ {
private ushort msgId = 0; private ushort msgId = 0;
private uint inMsgLen = 0; private uint inMsgLen = 0;
private uint outMsgLen = 0; private uint outMsgLen = 0;
private uint keyChainIdLen = 0; private uint keyChainIdLen = 0;
private uint secretIdLen = 0; private uint secretIdLen = 0;
private uint secretValLen = 0; private uint secretValLen = 0;
private int retCode = 0; private int retCode = 0;
private string keyChainId; private string keyChainId;
private string secretId; private string secretId;
//private byte[] secretVal; //private byte[] secretVal;
private byte[] inBuf; private byte[] inBuf;
private byte[] outBuf; private byte[] outBuf;
// extension operations // extension operations
private uint extId = 0; private uint extId = 0;
@ -58,56 +58,56 @@ namespace sscs.verbs
private int luidLow = 0; private int luidLow = 0;
private int luidHigh = 0; private int luidHigh = 0;
#endif #endif
/* /*
* This method sets the class member with the byte array received. * This method sets the class member with the byte array received.
*/ */
public void SetMessageContent(byte[] ipcBytes) public void SetMessageContent(byte[] ipcBytes)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes; inBuf = ipcBytes;
} }
/* /*
* This method does the actual implementation of ReadSecret * This method does the actual implementation of ReadSecret
* *
*/ */
public byte[] ProcessRequest(UserIdentifier userId) public byte[] ProcessRequest(UserIdentifier userId)
{ {
Secret secret = null; Secret secret = null;
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
UserIdentifier tempUserId = userId; UserIdentifier tempUserId = userId;
/* If an exception occurs in message format decoding, /* If an exception occurs in message format decoding,
* it is handled by AppHandler * it is handled by AppHandler
*/ */
// Message Format decipher - Start // Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0); msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2); inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length ) if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received."); throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6); keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen]; byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen); Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr); keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
secretIdLen = BitConverter.ToUInt32(inBuf, secretIdLen = BitConverter.ToUInt32(inBuf,
(10 + (int)keyChainIdLen)); (10 + (int)keyChainIdLen));
byte[] secretIdArr = new byte[secretIdLen]; byte[] secretIdArr = new byte[secretIdLen];
Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen); Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen);
secretId = Encoding.UTF8.GetString(secretIdArr); secretId = Encoding.UTF8.GetString(secretIdArr);
// Message Format decipher - End // Message Format decipher - End
try try
{ {
// get extension ID // get extension ID
@ -119,12 +119,12 @@ namespace sscs.verbs
//CSSSLogger.ExpLog(e.ToString()); //CSSSLogger.ExpLog(e.ToString());
} }
SecretStore ssStore; SecretStore ssStore;
CSSSLogger.DbgLog("Reading Secret ID: " + secretId); CSSSLogger.DbgLog("Reading Secret ID: " + secretId);
if (extId == 1) if (extId == 1)
{ {
#if W32 #if W32
CSSSLogger.DbgLog("LUID ExtID found"); CSSSLogger.DbgLog("LUID ExtID found");
WinUserIdentifier test = (WinUserIdentifier)userId; WinUserIdentifier test = (WinUserIdentifier)userId;
// NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM" // NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM"
@ -134,108 +134,108 @@ namespace sscs.verbs
// WINDOWS LUID // WINDOWS LUID
// System Services, like DLU create fake UIDs, store credentials and then want to read that data. // System Services, like DLU create fake UIDs, store credentials and then want to read that data.
luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen)+((int)secretIdLen) + 8); luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen)+((int)secretIdLen) + 8);
luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen)+((int)secretIdLen) + 12); luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen)+((int)secretIdLen) + 12);
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in. // this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter. // ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString(); keyChainId = luidHigh.ToString() + luidLow.ToString();
CSSSLogger.DbgLog("ReadSecret: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]"); CSSSLogger.DbgLog("ReadSecret: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]");
} }
#endif #endif
} }
try try
{ {
KeyChain keyChain = null; KeyChain keyChain = null;
// Secret secret = null; // Secret secret = null;
ssStore = SessionManager.GetUserSecretStore(tempUserId); ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.IsStoreLocked()) if (!ssStore.IsStoreLocked())
{ {
if( ssStore.CheckIfKeyChainExists(keyChainId) ) if( ssStore.CheckIfKeyChainExists(keyChainId) )
{ {
keyChain = ssStore.GetKeyChain(keyChainId); keyChain = ssStore.GetKeyChain(keyChainId);
if( keyChain.CheckIfSecretExists(secretId) == false) if( keyChain.CheckIfSecretExists(secretId) == false)
{ {
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST; retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
} }
else else
{ {
secret = keyChain.GetSecret(secretId); secret = keyChain.GetSecret(secretId);
} }
} }
else else
{ {
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST; retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
} }
} }
else else
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED; retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
} }
catch(UserNotInSessionException) catch(UserNotInSessionException)
{ {
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable user's secretstore" ); CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
try try
{ {
msgId = 8; msgId = 8;
uint secretValLen = 0; uint secretValLen = 0;
byte[] baSecretValue = new byte[0]; byte[] baSecretValue = new byte[0];
if( 0 == retCode ) if( 0 == retCode )
{ {
baSecretValue = secret.GetValue(secretId); baSecretValue = secret.GetValue(secretId);
secretValLen = (uint)baSecretValue.Length; secretValLen = (uint)baSecretValue.Length;
outMsgLen = 14 + secretValLen; outMsgLen = 14 + secretValLen;
} }
else else
{ {
outMsgLen = 14; //2+4+4+4 outMsgLen = 14; //2+4+4+4
} }
outBuf = new byte[outMsgLen]; outBuf = new byte[outMsgLen];
byte[] t = new byte[10]; byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId); t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2); Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen); t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4); Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(secretValLen); t = BitConverter.GetBytes(secretValLen);
Array.Copy(t,0,outBuf,6,4); Array.Copy(t,0,outBuf,6,4);
if( 0 == retCode ) if( 0 == retCode )
Array.Copy(baSecretValue,0,outBuf,10,secretValLen); Array.Copy(baSecretValue,0,outBuf,10,secretValLen);
t = BitConverter.GetBytes(retCode); t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,10+secretValLen,4); Array.Copy(t,0,outBuf,10+secretValLen,4);
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString()); throw new FormatException("Unable to form the response " + e.ToString());
} }
return outBuf; return outBuf;
} }
/* /*
* Gives the name of operation performed. Will be used in case * Gives the name of operation performed. Will be used in case
* of error. * of error.
*/ */
public string GetVerbName() public string GetVerbName()
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
return this.ToString(); return this.ToString();
} }
} }
} }

View File

@ -20,100 +20,100 @@
* *
***********************************************************************/ ***********************************************************************/
using System; using System;
using System.Collections; using System.Collections;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using sscs.verbs; using sscs.verbs;
using sscs.cache; using sscs.cache;
using sscs.common; using sscs.common;
using sscs.constants; using sscs.constants;
namespace sscs.verbs namespace sscs.verbs
{ {
/* /*
* This class is implementation of ReadKey call. * This class is implementation of ReadKey call.
* There will be one instance existing for every call made by the client. * There will be one instance existing for every call made by the client.
*/ */
internal class RemoveKey : SSVerb internal class RemoveKey : SSVerb
{ {
private ushort msgId = 0; private ushort msgId = 0;
private uint inMsgLen = 0; private uint inMsgLen = 0;
private uint outMsgLen = 0; private uint outMsgLen = 0;
private uint keyChainIdLen = 0; private uint keyChainIdLen = 0;
private uint secretIdLen = 0; private uint secretIdLen = 0;
private int retCode = 0; private int retCode = 0;
private string keyChainId; private string keyChainId;
private string secretId; private string secretId;
private uint keyLen; private uint keyLen;
private string key; private string key;
private byte[] inBuf; private byte[] inBuf;
private byte[] outBuf; private byte[] outBuf;
// extension operations // extension operations
private uint extId = 0; private uint extId = 0;
#if W32 #if W32
private int luidLow = 0; private int luidLow = 0;
private int luidHigh = 0; private int luidHigh = 0;
#endif #endif
/* /*
* This method sets the class member with the byte array received. * This method sets the class member with the byte array received.
*/ */
public void SetMessageContent(byte[] ipcBytes) public void SetMessageContent(byte[] ipcBytes)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes; inBuf = ipcBytes;
} }
/* /*
* This method does the actual implementation of ReadKey * This method does the actual implementation of ReadKey
* *
*/ */
public byte[] ProcessRequest(UserIdentifier userId) public byte[] ProcessRequest(UserIdentifier userId)
{ {
Secret secret = null; Secret secret = null;
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
/* If an exception occurs in message format decoding, /* If an exception occurs in message format decoding,
* it is handled by AppHandler * it is handled by AppHandler
*/ */
UserIdentifier tempUserId = userId; UserIdentifier tempUserId = userId;
// Message Format decipher - Start // Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0); msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2); inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length ) if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received."); throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6); keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen]; byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen); Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr); keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
secretIdLen = BitConverter.ToUInt32(inBuf, secretIdLen = BitConverter.ToUInt32(inBuf,
(10 + (int)keyChainIdLen)); (10 + (int)keyChainIdLen));
byte[] secretIdArr = new byte[secretIdLen]; byte[] secretIdArr = new byte[secretIdLen];
Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen); Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen);
secretId = Encoding.UTF8.GetString(secretIdArr); secretId = Encoding.UTF8.GetString(secretIdArr);
// Message Format decipher - End // Message Format decipher - End
keyLen = BitConverter.ToUInt32(inBuf,(14+(int)keyChainIdLen+(int)secretIdLen)); keyLen = BitConverter.ToUInt32(inBuf,(14+(int)keyChainIdLen+(int)secretIdLen));
byte[] keyArr = new byte[keyLen]; byte[] keyArr = new byte[keyLen];
Array.Copy(inBuf,(18+(int)keyChainIdLen+(int)secretIdLen),keyArr,0,keyLen); Array.Copy(inBuf,(18+(int)keyChainIdLen+(int)secretIdLen),keyArr,0,keyLen);
key = Encoding.UTF8.GetString(keyArr); key = Encoding.UTF8.GetString(keyArr);
try try
{ {
// get extension ID // get extension ID
@ -126,116 +126,116 @@ namespace sscs.verbs
} }
if (extId == 1) if (extId == 1)
{ {
#if W32 #if W32
CSSSLogger.DbgLog("LUID ExtID found"); CSSSLogger.DbgLog("LUID ExtID found");
WinUserIdentifier test = (WinUserIdentifier)userId; WinUserIdentifier test = (WinUserIdentifier)userId;
// NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM" // NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM"
if ((test.GetUIDLow() == 999) && (test.GetUIDHigh() == 0)) if ((test.GetUIDLow() == 999) && (test.GetUIDHigh() == 0))
{ {
// WINDOWS LUID // WINDOWS LUID
// System Services, like DLU create fake UIDs, store credentials and then want to read that data. // System Services, like DLU create fake UIDs, store credentials and then want to read that data.
luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 8); luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 8);
luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 12); luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 12);
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in. // this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter. // ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString(); keyChainId = luidHigh.ToString() + luidLow.ToString();
CSSSLogger.DbgLog("ReadSecret: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]"); CSSSLogger.DbgLog("ReadSecret: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]");
} }
#endif #endif
} }
try try
{ {
KeyChain keyChain = null; KeyChain keyChain = null;
// Secret secret = null; // Secret secret = null;
SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId); SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.IsStoreLocked()) if (!ssStore.IsStoreLocked())
{ {
if( ssStore.CheckIfKeyChainExists(keyChainId) ) if( ssStore.CheckIfKeyChainExists(keyChainId) )
{ {
keyChain = ssStore.GetKeyChain(keyChainId); keyChain = ssStore.GetKeyChain(keyChainId);
if( keyChain.CheckIfSecretExists(secretId) == false) if( keyChain.CheckIfSecretExists(secretId) == false)
{ {
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST; retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
} }
else else
{ {
secret = keyChain.GetSecret(secretId); secret = keyChain.GetSecret(secretId);
if (secret != null) if (secret != null)
{ {
try try
{ {
secret.RemoveKeyValue(keyChain, key); secret.RemoveKeyValue(keyChain, key);
} }
catch (Exception e) catch (Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
} }
} }
else else
{ {
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST; retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
} }
} }
} }
else else
{ {
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST; retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
} }
} }
else else
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED; retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
} }
catch(UserNotInSessionException) catch(UserNotInSessionException)
{ {
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable user's secretstore" ); CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
// Construct a Reply // Construct a Reply
try try
{ {
msgId = 17; msgId = 17;
outMsgLen = 10; outMsgLen = 10;
outBuf = new byte[outMsgLen]; outBuf = new byte[outMsgLen];
byte[] t = new byte[10]; byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId); t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t, 0, outBuf, 0, 2); Array.Copy(t, 0, outBuf, 0, 2);
t = BitConverter.GetBytes((uint)outMsgLen); t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t, 0, outBuf, 2, 4); Array.Copy(t, 0, outBuf, 2, 4);
t = BitConverter.GetBytes(retCode); t = BitConverter.GetBytes(retCode);
Array.Copy(t, 0, outBuf, 6, 4); Array.Copy(t, 0, outBuf, 6, 4);
} }
catch (Exception e) catch (Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString()); throw new FormatException("Unable to form the response " + e.ToString());
} }
return outBuf; return outBuf;
} }
/* /*
* Gives the name of operation performed. Will be used in case * Gives the name of operation performed. Will be used in case
* of error. * of error.
*/ */
public string GetVerbName() public string GetVerbName()
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
return this.ToString(); return this.ToString();
} }
} }
} }

View File

@ -20,131 +20,131 @@
* *
***********************************************************************/ ***********************************************************************/
using System; using System;
using System.Collections; using System.Collections;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using sscs.verbs; using sscs.verbs;
using sscs.common; using sscs.common;
using sscs.constants; using sscs.constants;
using sscs.cache; using sscs.cache;
namespace sscs.verbs namespace sscs.verbs
{ {
/* /*
* This class is implementation of RemoveKeyChain call. * This class is implementation of RemoveKeyChain call.
* There will be one instance existing for every call made by the client. * There will be one instance existing for every call made by the client.
*/ */
internal class RemoveKeyChain : SSVerb internal class RemoveKeyChain : SSVerb
{ {
private ushort msgId = 0; private ushort msgId = 0;
private uint inMsgLen = 0; private uint inMsgLen = 0;
private uint outMsgLen = 0; private uint outMsgLen = 0;
private uint keyChainIdLen = 0; private uint keyChainIdLen = 0;
private string keyChainId; private string keyChainId;
private int retCode = 0; private int retCode = 0;
private byte[] inBuf; private byte[] inBuf;
private byte[] outBuf; private byte[] outBuf;
/* /*
* This method sets the class member with the byte array received. * This method sets the class member with the byte array received.
*/ */
public void SetMessageContent(byte[] ipcBytes) public void SetMessageContent(byte[] ipcBytes)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes; inBuf = ipcBytes;
} }
/* /*
* This method does the actual implementation of RemoveKeyChain * This method does the actual implementation of RemoveKeyChain
* *
*/ */
public byte[] ProcessRequest(UserIdentifier userId) public byte[] ProcessRequest(UserIdentifier userId)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
/* If an exception occurs in message format decoding, /* If an exception occurs in message format decoding,
* it is handled by AppHandler * it is handled by AppHandler
*/ */
// Message Format decipher - Start // Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0); msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2); inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length ) if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received."); throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6); keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen]; byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen); Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr); keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
// Message Format decipher - End // Message Format decipher - End
try try
{ {
SecretStore ssStore = null; SecretStore ssStore = null;
ssStore = SessionManager.GetUserSecretStore(userId); ssStore = SessionManager.GetUserSecretStore(userId);
if( ssStore.CheckIfKeyChainExists(keyChainId) ) if( ssStore.CheckIfKeyChainExists(keyChainId) )
{ {
ssStore.RemoveKeyChain(keyChainId); ssStore.RemoveKeyChain(keyChainId);
} }
else else
{ {
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST; retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
} }
} }
catch(UserNotInSessionException) catch(UserNotInSessionException)
{ {
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" ); CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
try try
{ {
msgId = 6; msgId = 6;
outMsgLen = 10; outMsgLen = 10;
outBuf = new byte[10]; outBuf = new byte[10];
byte[] t = new byte[10]; byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId); t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2); Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen); t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4); Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(retCode); t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,6,4); Array.Copy(t,0,outBuf,6,4);
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString()); throw new FormatException("Unable to form the response " + e.ToString());
} }
return outBuf; return outBuf;
} }
/* /*
* Gives the name of operation performed. Will be used in case * Gives the name of operation performed. Will be used in case
* of error. * of error.
*/ */
public string GetVerbName() public string GetVerbName()
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
return this.ToString(); return this.ToString();
} }
} }
} }

View File

@ -20,94 +20,94 @@
* *
***********************************************************************/ ***********************************************************************/
using System; using System;
using System.Collections; using System.Collections;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using sscs.verbs; using sscs.verbs;
using sscs.common; using sscs.common;
using sscs.cache; using sscs.cache;
using sscs.constants; using sscs.constants;
namespace sscs.verbs namespace sscs.verbs
{ {
/* /*
* This class is implementation of RemoveSecret call. * This class is implementation of RemoveSecret call.
* There will be one instance existing for every call made by the client. * There will be one instance existing for every call made by the client.
*/ */
internal class RemoveSecret : SSVerb internal class RemoveSecret : SSVerb
{ {
private ushort msgId = 0; private ushort msgId = 0;
private uint inMsgLen = 0; private uint inMsgLen = 0;
private uint outMsgLen = 0; private uint outMsgLen = 0;
private uint keyChainIdLen = 0; private uint keyChainIdLen = 0;
private uint secretIdLen = 0; private uint secretIdLen = 0;
private int retCode = 0; private int retCode = 0;
private string keyChainId; private string keyChainId;
private string secretId; private string secretId;
private byte[] inBuf; private byte[] inBuf;
private byte[] outBuf; private byte[] outBuf;
// extension operations // extension operations
private uint extId = 0; private uint extId = 0;
#if W32 #if W32
private int luidLow = 0; private int luidLow = 0;
private int luidHigh = 0; private int luidHigh = 0;
#endif #endif
/* /*
* This method sets the class member with the byte array received. * This method sets the class member with the byte array received.
*/ */
public void SetMessageContent(byte[] ipcBytes) public void SetMessageContent(byte[] ipcBytes)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes; inBuf = ipcBytes;
} }
/* /*
* This method does the actual implementation of RemoveSecret * This method does the actual implementation of RemoveSecret
* *
*/ */
public byte[] ProcessRequest(UserIdentifier userId) public byte[] ProcessRequest(UserIdentifier userId)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
UserIdentifier tempUserId = userId; UserIdentifier tempUserId = userId;
/* If an exception occurs in message format decoding, /* If an exception occurs in message format decoding,
* it is handled by AppHandler * it is handled by AppHandler
*/ */
// Message Format decipher - Start // Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0); msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2); inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length ) if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received."); throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6); keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen]; byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen); Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr); keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
secretIdLen = BitConverter.ToUInt32(inBuf, secretIdLen = BitConverter.ToUInt32(inBuf,
(10 + (int)keyChainIdLen)); (10 + (int)keyChainIdLen));
byte[] secretIdArr = new byte[secretIdLen]; byte[] secretIdArr = new byte[secretIdLen];
Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen); Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen);
secretId = Encoding.UTF8.GetString(secretIdArr); secretId = Encoding.UTF8.GetString(secretIdArr);
CSSSLogger.DbgLog("Deleting secret id: " + secretId); CSSSLogger.DbgLog("Deleting secret id: " + secretId);
try try
{ {
CSSSLogger.DbgLog("Looking for extention"); CSSSLogger.DbgLog("Looking for extention");
// get extension ID // get extension ID
int extLocation = 18 + ((int)keyChainIdLen) + ((int)secretIdLen); int extLocation = 18 + ((int)keyChainIdLen) + ((int)secretIdLen);
@ -116,107 +116,107 @@ namespace sscs.verbs
catch (Exception) catch (Exception)
{ {
//CSSSLogger.ExpLog(e.ToString()); //CSSSLogger.ExpLog(e.ToString());
} }
if (extId == 1) if (extId == 1)
{ {
#if W32 #if W32
CSSSLogger.DbgLog("LUID ExtID found"); CSSSLogger.DbgLog("LUID ExtID found");
WinUserIdentifier test = (WinUserIdentifier)userId; WinUserIdentifier test = (WinUserIdentifier)userId;
// NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM" // NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM"
if ((test.GetUIDLow() == 999) && (test.GetUIDHigh() == 0)) if ((test.GetUIDLow() == 999) && (test.GetUIDHigh() == 0))
{ {
// WINDOWS LUID // WINDOWS LUID
// System Services, like DLU create fake UIDs, store credentials and then want to read that data. // System Services, like DLU create fake UIDs, store credentials and then want to read that data.
luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 8); luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 8);
luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 12); luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 12);
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in. // this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter. // ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString(); keyChainId = luidHigh.ToString() + luidLow.ToString();
CSSSLogger.DbgLog("ReadSecret: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]"); CSSSLogger.DbgLog("ReadSecret: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]");
} }
#endif #endif
} }
// Message Format decipher - End // Message Format decipher - End
try try
{ {
SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId); SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.IsStoreLocked()) if (!ssStore.IsStoreLocked())
{ {
if (ssStore.CheckIfKeyChainExists(keyChainId)) if (ssStore.CheckIfKeyChainExists(keyChainId))
{ {
KeyChain keyChain = ssStore.GetKeyChain(keyChainId); KeyChain keyChain = ssStore.GetKeyChain(keyChainId);
if (keyChain.CheckIfSecretExists(secretId) == false) if (keyChain.CheckIfSecretExists(secretId) == false)
{ {
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST; retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
} }
else else
{ {
// TODO: get the secret and remove linked keys // TODO: get the secret and remove linked keys
keyChain.RemoveSecret(secretId); keyChain.RemoveSecret(secretId);
ssStore.UpdatePersistentStore(); ssStore.UpdatePersistentStore();
} }
} }
else else
{ {
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST; retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
} }
} }
else else
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED; retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
} }
catch(UserNotInSessionException) catch(UserNotInSessionException)
{ {
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" ); CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
catch(Exception) catch(Exception)
{ {
CSSSLogger.DbgLog( "In " + CSSSLogger.GetExecutionPath(this) + " - Secret ID not present" + secretId); CSSSLogger.DbgLog( "In " + CSSSLogger.GetExecutionPath(this) + " - Secret ID not present" + secretId);
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
// Construct a Reply // Construct a Reply
try try
{ {
msgId = 10; msgId = 10;
outMsgLen = 10; outMsgLen = 10;
outBuf = new byte[outMsgLen]; outBuf = new byte[outMsgLen];
byte[] t = new byte[10]; byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId); t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2); Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen); t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4); Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(retCode); t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,6,4); Array.Copy(t,0,outBuf,6,4);
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString()); throw new FormatException("Unable to form the response " + e.ToString());
} }
return outBuf; return outBuf;
} }
/* /*
* Gives the name of operation performed. Will be used in case * Gives the name of operation performed. Will be used in case
* of error. * of error.
*/ */
public string GetVerbName() public string GetVerbName()
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
return this.ToString(); return this.ToString();
} }
} }
} }

View File

@ -21,112 +21,112 @@
***********************************************************************/ ***********************************************************************/
using System; using System;
using System.Collections; using System.Collections;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using sscs.verbs; using sscs.verbs;
using sscs.common; using sscs.common;
using sscs.cache; using sscs.cache;
using sscs.constants; using sscs.constants;
namespace sscs.verbs namespace sscs.verbs
{ {
/* /*
* This class is implementation of RemoveSecretStore call. * This class is implementation of RemoveSecretStore call.
* There will be one instance existing for every call made by the client. * There will be one instance existing for every call made by the client.
*/ */
internal class RemoveSecretStore : SSVerb internal class RemoveSecretStore : SSVerb
{ {
private ushort msgId = 0; private ushort msgId = 0;
private uint inMsgLen = 0; private uint inMsgLen = 0;
private uint outMsgLen = 0; private uint outMsgLen = 0;
private byte[] inBuf; private byte[] inBuf;
private byte[] outBuf; private byte[] outBuf;
private int retCode = 0; private int retCode = 0;
/* /*
* This method sets the class member with the byte array received. * This method sets the class member with the byte array received.
*/ */
public void SetMessageContent(byte[] ipcBytes) public void SetMessageContent(byte[] ipcBytes)
{ {
inBuf = ipcBytes; inBuf = ipcBytes;
} }
/* /*
* This method does the actual implementation of RemoveSecretStore * This method does the actual implementation of RemoveSecretStore
* *
*/ */
public byte[] ProcessRequest(UserIdentifier userId) public byte[] ProcessRequest(UserIdentifier userId)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
/* If an exception occurs in message format decoding, /* If an exception occurs in message format decoding,
* it is handled by AppHandler * it is handled by AppHandler
*/ */
msgId = BitConverter.ToUInt16(inBuf,0); msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2) ; inMsgLen = BitConverter.ToUInt32(inBuf,2) ;
if( inMsgLen != inBuf.Length ) if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received."); throw new FormatException(" MsgLen sent does not match the length of the message received.");
try try
{ {
SessionManager.RemoveUserSession(userId, true); SessionManager.RemoveUserSession(userId, true);
} }
catch(UserNotInSessionException) catch(UserNotInSessionException)
{ {
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" ); CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
try try
{ {
msgId = 3; msgId = 3;
outMsgLen = 10; outMsgLen = 10;
outBuf = new byte[10]; outBuf = new byte[10];
byte[] t = new byte[10]; byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId); t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2); Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen); t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4); Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(retCode); t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,6,4); Array.Copy(t,0,outBuf,6,4);
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString()); throw new FormatException("Unable to form the response " + e.ToString());
} }
return outBuf; return outBuf;
} }
/* /*
* Gives the name of operation performed. Will be used in case * Gives the name of operation performed. Will be used in case
* of error. * of error.
*/ */
public string GetVerbName() public string GetVerbName()
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
return this.ToString(); return this.ToString();
} }
} }
} }

View File

@ -20,132 +20,132 @@
* *
***********************************************************************/ ***********************************************************************/
using System; using System;
using System.Collections; using System.Collections;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using sscs.verbs; using sscs.verbs;
using sscs.common; using sscs.common;
using sscs.cache; using sscs.cache;
using sscs.constants; using sscs.constants;
namespace sscs.verbs namespace sscs.verbs
{ {
/* /*
* This class is implementation of SetMasterPasscode call. * This class is implementation of SetMasterPasscode call.
* There will be one instance existing for every call made by the client. * There will be one instance existing for every call made by the client.
*/ */
internal class SetMasterPasscode : SSVerb internal class SetMasterPasscode : SSVerb
{ {
private ushort msgId = 0; private ushort msgId = 0;
private uint inMsgLen = 0; private uint inMsgLen = 0;
private uint passcodeLen = 0; private uint passcodeLen = 0;
private string passcode; private string passcode;
private uint passcodeType = 0; private uint passcodeType = 0;
private uint outMsgLen = 0; private uint outMsgLen = 0;
private byte[] inBuf; private byte[] inBuf;
private byte[] outBuf; private byte[] outBuf;
private int retCode = 0; private int retCode = 0;
/* /*
* This method sets the class member with the byte array received. * This method sets the class member with the byte array received.
*/ */
public void SetMessageContent(byte[] ipcBytes) public void SetMessageContent(byte[] ipcBytes)
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes; inBuf = ipcBytes;
} }
/* /*
* This method does the actual implementation of SetMasterPasscode * This method does the actual implementation of SetMasterPasscode
*/ */
public byte[] ProcessRequest(UserIdentifier userId) public byte[] ProcessRequest(UserIdentifier userId)
{ {
/* If an exception occurs in message format decoding, /* If an exception occurs in message format decoding,
* it is handled by AppHandler * it is handled by AppHandler
*/ */
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
// Message Format decipher - Start // Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0); msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2); inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length ) if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received."); throw new FormatException(" MsgLen sent does not match the length of the message received.");
passcodeType = BitConverter.ToUInt32(inBuf,6); passcodeType = BitConverter.ToUInt32(inBuf,6);
passcodeLen = BitConverter.ToUInt32(inBuf,10); passcodeLen = BitConverter.ToUInt32(inBuf,10);
if (passcodeLen < 64) if (passcodeLen < 64)
{ {
byte[] tempArr = new byte[passcodeLen]; byte[] tempArr = new byte[passcodeLen];
Array.Copy(inBuf, 14, tempArr, 0, passcodeLen); Array.Copy(inBuf, 14, tempArr, 0, passcodeLen);
passcode = Encoding.UTF8.GetString(tempArr); passcode = Encoding.UTF8.GetString(tempArr);
// Message Format decipher - End // Message Format decipher - End
try try
{ {
SecretStore ssStore = null; SecretStore ssStore = null;
ssStore = SessionManager.GetUserSecretStore(userId); ssStore = SessionManager.GetUserSecretStore(userId);
ssStore.PauseFileWatcher(); ssStore.PauseFileWatcher();
if (ssStore.SetMasterPasscode(passcode)) if (ssStore.SetMasterPasscode(passcode))
retCode = IPCRetCodes.SSCS_REPLY_SUCCESS; retCode = IPCRetCodes.SSCS_REPLY_SUCCESS;
else else
retCode = IPCRetCodes.SSCS_E_SETTING_PASSCODE_FAILED; retCode = IPCRetCodes.SSCS_E_SETTING_PASSCODE_FAILED;
ssStore.ResumeFileWatcher(); ssStore.ResumeFileWatcher();
} }
catch (UserNotInSessionException) catch (UserNotInSessionException)
{ {
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore"); CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore");
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
catch (Exception e) catch (Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR; retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
} }
} }
else else
{ {
retCode = IPCRetCodes.SSCS_E_INVALID_INPUT; retCode = IPCRetCodes.SSCS_E_INVALID_INPUT;
} }
try try
{ {
msgId = 15; msgId = 15;
outMsgLen = 10; outMsgLen = 10;
outBuf = new byte[10]; outBuf = new byte[10];
byte[] t = new byte[10]; byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId); t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2); Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen); t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4); Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(retCode); t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,6,4); Array.Copy(t,0,outBuf,6,4);
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString()); throw new FormatException("Unable to form the response " + e.ToString());
} }
return outBuf; return outBuf;
} }
/* /*
* Gives the name of operation performed. Will be used in case * Gives the name of operation performed. Will be used in case
* of error. * of error.
*/ */
public string GetVerbName() public string GetVerbName()
{ {
CSSSLogger.ExecutionTrace(this); CSSSLogger.ExecutionTrace(this);
return (this.ToString()); return (this.ToString());
} }
} }
} }

View File

@ -92,12 +92,12 @@ namespace sscs.verbs
inMsgLen = BitConverter.ToUInt32(inBuf,2); inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length ) if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received."); throw new FormatException(" MsgLen sent does not match the length of the message received.");
// get flags // get flags
ssFlags = BitConverter.ToUInt32(inBuf, 6); ssFlags = BitConverter.ToUInt32(inBuf, 6);
// get keychain // get keychain
keyChainIdLen = BitConverter.ToUInt32(inBuf, 10); keyChainIdLen = BitConverter.ToUInt32(inBuf, 10);
byte[] keyChainIdArr = new byte[keyChainIdLen]; byte[] keyChainIdArr = new byte[keyChainIdLen];
@ -132,10 +132,10 @@ namespace sscs.verbs
} }
catch (Exception) catch (Exception)
{ {
//CSSSLogger.ExpLog(e.ToString()); //CSSSLogger.ExpLog(e.ToString());
} }
#if W32 #if W32
if (extId == 1) if (extId == 1)
{ {
// WINDOWS LUID // WINDOWS LUID
@ -143,45 +143,45 @@ namespace sscs.verbs
// we might be able to change this if/when we abstract the session. // 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] // [4 byte extID][4 byte length][4 byte luidLow][4 byte luidHigh]
luidLow = BitConverter.ToInt32(inBuf, 30 + ((int)keyChainIdLen)+((int)secretIdLen) +((int)keyLen) + (int)valLen + 8); 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); luidHigh = BitConverter.ToInt32(inBuf, 30 + ((int)keyChainIdLen)+((int)secretIdLen) +((int)keyLen) + (int)valLen + 12);
if (ConstStrings.MICASA_DESKTOP_PASSWD == secretId) if (ConstStrings.MICASA_DESKTOP_PASSWD == secretId)
{ {
tempUserId = new WinUserIdentifier(luidLow, luidHigh); tempUserId = new WinUserIdentifier(luidLow, luidHigh);
SecretStore ss = SessionManager.CreateUserSession(tempUserId); SecretStore ss = SessionManager.CreateUserSession(tempUserId);
try try
{ {
ss.AddKeyChain(new KeyChain("SSCS_SESSION_KEY_CHAIN_ID\0")); ss.AddKeyChain(new KeyChain("SSCS_SESSION_KEY_CHAIN_ID\0"));
} }
catch (Exception) catch (Exception)
{ {
} }
} }
else else
{ {
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in. // this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter. // ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString(); keyChainId = luidHigh.ToString() + luidLow.ToString();
SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId); SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.CheckIfKeyChainExists(keyChainId)) if (!ssStore.CheckIfKeyChainExists(keyChainId))
{ {
try try
{ {
KeyChain newKeyChain = new KeyChain(keyChainId); KeyChain newKeyChain = new KeyChain(keyChainId);
ssStore.AddKeyChain(newKeyChain); ssStore.AddKeyChain(newKeyChain);
} }
catch (Exception e) catch (Exception e)
{ {
CSSSLogger.DbgLog("WriteKey: Adding keychain returned error: " + e.ToString()); CSSSLogger.DbgLog("WriteKey: Adding keychain returned error: " + e.ToString());
} }
} }
} }
} }
#endif #endif
try try
{ {
KeyChain keyChain = null; KeyChain keyChain = null;
@ -208,22 +208,22 @@ namespace sscs.verbs
(ConstStrings.MICASA_DESKTOP_PASSWD_KEYNAME == key) (ConstStrings.MICASA_DESKTOP_PASSWD_KEYNAME == key)
) )
{ {
KeyValue kvDesktop = secret.GetKeyValue(ConstStrings.MICASA_DESKTOP_PASSWD_KEYNAME); KeyValue kvDesktop = secret.GetKeyValue(ConstStrings.MICASA_DESKTOP_PASSWD_KEYNAME);
if (null != kvDesktop) if (null != kvDesktop)
oldPasswd = kvDesktop.GetValue(); oldPasswd = kvDesktop.GetValue();
} }
secret.SetKeyValue(key,val); secret.SetKeyValue(key,val);
KeyValue kv = secret.GetKeyValue(key); KeyValue kv = secret.GetKeyValue(key);
if ((ssFlags & SSFLAGS.FLAG_DO_NOT_PERSIST) == SSFLAGS.FLAG_DO_NOT_PERSIST) if ((ssFlags & SSFLAGS.FLAG_DO_NOT_PERSIST) == SSFLAGS.FLAG_DO_NOT_PERSIST)
{ {
kv.IsPersistent = false; kv.IsPersistent = false;
} }
else else
{ {
kv.IsPersistent = true; kv.IsPersistent = true;
} }
if((ConstStrings.MICASA_DESKTOP_PASSWD == secretId) && if((ConstStrings.MICASA_DESKTOP_PASSWD == secretId) &&
@ -257,7 +257,7 @@ namespace sscs.verbs
} }
} }
else else
{ {
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED; retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
} }

View File

@ -118,7 +118,7 @@ namespace sscs.verbs
valLen = BitConverter.ToUInt32(inBuf,(18+(int)keyChainIdLen+(int)secretIdLen+(int)keyLen)); valLen = BitConverter.ToUInt32(inBuf,(18+(int)keyChainIdLen+(int)secretIdLen+(int)keyLen));
val = new byte[valLen]; val = new byte[valLen];
Array.Copy(inBuf,(22+keyChainIdLen+secretIdLen+keyLen),val,0,valLen); Array.Copy(inBuf,(22+keyChainIdLen+secretIdLen+keyLen),val,0,valLen);
valStr = Encoding.UTF8.GetString(val); valStr = Encoding.UTF8.GetString(val);
CSSSLogger.DbgLog("Writing Secret:Key [" + secretId + ":" + key + "]"); CSSSLogger.DbgLog("Writing Secret:Key [" + secretId + ":" + key + "]");
@ -130,13 +130,13 @@ namespace sscs.verbs
} }
catch (Exception) catch (Exception)
{ {
//CSSSLogger.ExpLog(e.ToString()); //CSSSLogger.ExpLog(e.ToString());
} }
#if W32 #if W32
if (extId == 1) if (extId == 1)
{ {
CSSSLogger.DbgLog("LUID ExtID found"); CSSSLogger.DbgLog("LUID ExtID found");
// WINDOWS LUID // WINDOWS LUID
@ -144,47 +144,47 @@ namespace sscs.verbs
// we might be able to change this if/when we abstract the session. // 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] // [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); 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); luidHigh = BitConverter.ToInt32(inBuf, 26 + ((int)keyChainIdLen)+((int)secretIdLen) +((int)keyLen) + (int)valLen + 12);
if (ConstStrings.MICASA_DESKTOP_PASSWD == secretId) if (ConstStrings.MICASA_DESKTOP_PASSWD == secretId)
{ {
tempUserId = new WinUserIdentifier(luidLow, luidHigh); tempUserId = new WinUserIdentifier(luidLow, luidHigh);
SecretStore ss = SessionManager.CreateUserSession(tempUserId); SecretStore ss = SessionManager.CreateUserSession(tempUserId);
CSSSLogger.DbgLog("Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]"); CSSSLogger.DbgLog("Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]");
try try
{ {
ss.AddKeyChain(new KeyChain("SSCS_SESSION_KEY_CHAIN_ID\0")); ss.AddKeyChain(new KeyChain("SSCS_SESSION_KEY_CHAIN_ID\0"));
} }
catch (Exception) catch (Exception)
{ {
} }
} }
else else
{ {
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in. // this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter. // ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString(); keyChainId = luidHigh.ToString() + luidLow.ToString();
SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId); SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.CheckIfKeyChainExists(keyChainId)) if (!ssStore.CheckIfKeyChainExists(keyChainId))
{ {
try try
{ {
KeyChain newKeyChain = new KeyChain(keyChainId); KeyChain newKeyChain = new KeyChain(keyChainId);
ssStore.AddKeyChain(newKeyChain); ssStore.AddKeyChain(newKeyChain);
} }
catch (Exception e) catch (Exception e)
{ {
CSSSLogger.DbgLog("WriteKey: Adding keychain returned error: " + e.ToString()); CSSSLogger.DbgLog("WriteKey: Adding keychain returned error: " + e.ToString());
} }
} }
} }
} }
#endif #endif
if (secretId.Length < 1 || key.Length < 1 || valStr.Length < 1) if (secretId.Length < 1 || key.Length < 1 || valStr.Length < 1)
{ {
CSSSLogger.DbgLog("Error in length"); CSSSLogger.DbgLog("Error in length");
@ -204,24 +204,24 @@ namespace sscs.verbs
if( ssStore.CheckIfKeyChainExists(keyChainId) ) if( ssStore.CheckIfKeyChainExists(keyChainId) )
{ {
keyChain = ssStore.GetKeyChain(keyChainId); keyChain = ssStore.GetKeyChain(keyChainId);
Secret secret = null; Secret secret = null;
if (ConstStrings.MICASA_DESKTOP_PASSWD == secretId) if (ConstStrings.MICASA_DESKTOP_PASSWD == secretId)
{ {
secret = ssStore.GetDesktopSecret(); secret = ssStore.GetDesktopSecret();
} }
else else
{ {
// add this secret if it doesn't already exist // add this secret if it doesn't already exist
if (keyChain.CheckIfSecretExists(secretId) == false) if (keyChain.CheckIfSecretExists(secretId) == false)
{ {
secret = new Secret(secretId); secret = new Secret(secretId);
keyChain.AddSecret(secret); keyChain.AddSecret(secret);
} }
else else
{ {
secret = keyChain.GetSecret(secretId); secret = keyChain.GetSecret(secretId);
} }
} }
string oldPasswd = null; string oldPasswd = null;

View File

@ -120,10 +120,10 @@ namespace sscs.verbs
} }
catch (Exception) catch (Exception)
{ {
//CSSSLogger.ExpLog(e.ToString()); //CSSSLogger.ExpLog(e.ToString());
} }
#if W32 #if W32
if (extId == 1) if (extId == 1)
{ {
// WINDOWS LUID // WINDOWS LUID
@ -131,43 +131,43 @@ namespace sscs.verbs
// we might be able to change this if/when we abstract the session. // 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] // [4 byte extID][4 byte length][4 byte luidLow][4 byte luidHigh]
luidLow = BitConverter.ToInt32(inBuf, 22 + ((int)keyChainIdLen)+((int)secretIdLen) +(int)secretValLen + 8); luidLow = BitConverter.ToInt32(inBuf, 22 + ((int)keyChainIdLen)+((int)secretIdLen) +(int)secretValLen + 8);
luidHigh = BitConverter.ToInt32(inBuf, 22 + ((int)keyChainIdLen)+((int)secretIdLen) +(int)secretValLen + 12); luidHigh = BitConverter.ToInt32(inBuf, 22 + ((int)keyChainIdLen)+((int)secretIdLen) +(int)secretValLen + 12);
if (ConstStrings.MICASA_DESKTOP_PASSWD == secretId) if (ConstStrings.MICASA_DESKTOP_PASSWD == secretId)
{ {
tempUserId = new WinUserIdentifier(luidLow, luidHigh); tempUserId = new WinUserIdentifier(luidLow, luidHigh);
SecretStore ss = SessionManager.CreateUserSession(tempUserId); SecretStore ss = SessionManager.CreateUserSession(tempUserId);
try try
{ {
ss.AddKeyChain(new KeyChain("SSCS_SESSION_KEY_CHAIN_ID\0")); ss.AddKeyChain(new KeyChain("SSCS_SESSION_KEY_CHAIN_ID\0"));
} }
catch (Exception) catch (Exception)
{ {
} }
} }
else else
{ {
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in. // this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter. // ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString(); keyChainId = luidHigh.ToString() + luidLow.ToString();
SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId); SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.CheckIfKeyChainExists(keyChainId)) if (!ssStore.CheckIfKeyChainExists(keyChainId))
{ {
try try
{ {
KeyChain newKeyChain = new KeyChain(keyChainId); KeyChain newKeyChain = new KeyChain(keyChainId);
ssStore.AddKeyChain(newKeyChain); ssStore.AddKeyChain(newKeyChain);
} }
catch (Exception e) catch (Exception e)
{ {
CSSSLogger.DbgLog("WriteSecret: Adding keychain returned error: " + e.ToString()); CSSSLogger.DbgLog("WriteSecret: Adding keychain returned error: " + e.ToString());
} }
} }
} }
} }
#endif #endif
try try
{ {