- Bug 169353. Prompt user for Desktop Password when Master Password is not present.

This commit is contained in:
Jim Norman
2006-05-08 02:38:42 +00:00
parent f6a659b7eb
commit 837669576a
9 changed files with 11900 additions and 11371 deletions

View File

@@ -123,7 +123,6 @@ namespace sscs.cache
//return true;
}
if (sMasterPassword != null)
{
// verify MasterPassword
@@ -136,6 +135,29 @@ namespace sscs.cache
return false;
}
public bool IsDesktopPassword(string sDesktopPassword)
{
try
{
byte[] baPasscode = CASACrypto.GetMasterPasscodeUsingDesktopPasswd(sDesktopPassword, GetPasscodeByDesktopFilePath(), false);
if(CASACrypto.ValidatePasscode(baPasscode,GetValidationFilePath()))
{
return true;
}
// try old salt
baPasscode = CASACrypto.GetMasterPasscodeUsingDesktopPasswd(sDesktopPassword, GetPasscodeByDesktopFilePath(), true);
if(CASACrypto.ValidatePasscode(baPasscode,GetValidationFilePath()))
{
return true;
}
}
catch
{
}
return false;
}
internal bool StartPersistenceByDesktopPasswd(string desktopPasswd)
{

View File

@@ -179,7 +179,10 @@ namespace sscs.crypto
{
//Get an encryptor.
RijndaelManaged myRijndael = new RijndaelManaged();
ICryptoTransform encryptor = myRijndael.CreateEncryptor(key, GenerateAndSaveIV(fileName, myRijndael));
byte[] baIV = GenerateAndSaveIV(fileName, myRijndael);
ICryptoTransform encryptor = myRijndael.CreateEncryptor(key, baIV);
//Encrypt the data to a file
fsEncrypt = new FileStream(fileName, FileMode.Create);
@@ -235,7 +238,10 @@ namespace sscs.crypto
//Get a decryptor that uses the same key and IV as the encryptor.
RijndaelManaged myRijndael = new RijndaelManaged();
ICryptoTransform decryptor = myRijndael.CreateDecryptor(key, RetrieveIV(fileName, key));
byte[] baIV = RetrieveIV(fileName, IV);
ICryptoTransform decryptor = myRijndael.CreateDecryptor(key, baIV);
#if LINUX
UnixFileInfo fsTest = new UnixFileInfo (fileName);
if((fsTest == null) || !(fsTest.Exists) || fsTest.IsSymbolicLink)
@@ -268,6 +274,7 @@ namespace sscs.crypto
for(int i = 0 ; i < bytesRead; i++ )
tmpEncrypt[i] = fromEncrypt[i];
SHA256 sha = new SHA256Managed();
byte[] newHash = sha.ComputeHash(tmpEncrypt);
@@ -300,13 +307,27 @@ namespace sscs.crypto
{
CSSSLogger.DbgLog(e.ToString());
}
if (csDecrypt != null)
{
csDecrypt.Close();
try
{
csDecrypt.Close();
}
catch
{
}
}
if( fsDecrypt != null )
{
fsDecrypt.Close();
try
{
fsDecrypt.Close();
}
catch
{
}
}
return null;
}
@@ -419,7 +440,7 @@ namespace sscs.crypto
//Get an encryptor.
RijndaelManaged myRijndael = new RijndaelManaged();
ICryptoTransform encryptor;
encryptor = myRijndael.CreateEncryptor(baKey, baKey);
encryptor = myRijndael.CreateEncryptor(baKey, GenerateAndSaveIV(fileName, myRijndael));
//Encrypt the data to a file
fsEncrypt = new FileStream(fileName,FileMode.Create);
@@ -647,8 +668,11 @@ namespace sscs.crypto
try
{
if (File.Exists(sFileName + ".IV"))
File.Delete(sFileName + ".IV");
// now save this
FileStream fs = new FileStream(sFileName + ".IV", FileMode.Create);
FileStream fs = new FileStream(sFileName + ".IV", FileMode.Create);
fs.Write(baIV, 0, 16);
fs.Flush();
fs.Close();
@@ -670,7 +694,7 @@ namespace sscs.crypto
// check for file existence
try
{
FileStream fs = new FileStream(sFileName + ".IV", FileMode.Open);
FileStream fs = new FileStream(sFileName + ".IV", FileMode.Open);
fs.Read(IV, 0, 16);
fs.Close();
return IV;
@@ -679,7 +703,29 @@ namespace sscs.crypto
{
CSSSLogger.DbgLog(e.ToString());
}
return (byte[])baOrigValue.Clone();
// original IV size was 16 bytes, copy that much
if (baOrigValue.Length == 16)
{
return (byte[])baOrigValue.Clone();
}
else
{
for (int i=0; i<16; i++)
{
IV[i] = baOrigValue[i];
}
return IV;
}
}
private static void DumpIV(byte[] iv)
{
for (int i=0; i<iv.Length; i++)
{
Console.Write(iv[i] + " ");
}
Console.WriteLine("\r\n");
}
}
}

View File

@@ -29,6 +29,7 @@ using sscs.verbs;
using sscs.cache;
using sscs.common;
using sscs.constants;
using sscs.lss;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
@@ -212,6 +213,10 @@ namespace sscs.verbs
{
return DoGetSecretIDs(ssStore, wo);
}
case MiCasaRequestReply.VERB_VALIDATE_DESKTOP_PWD:
{
return DoValidateDesktopPwd(ssStore, wo);
}
default:
{
@@ -229,6 +234,24 @@ namespace sscs.verbs
return wo;
}
private WrappedObject DoValidateDesktopPwd(SecretStore ssStore, WrappedObject wo)
{
// let's validate the Desktop pwd
String sDesktopPwd = (String)wo.GetObject();
bool bIsValid = ssStore.IsDesktopPassword(sDesktopPwd);
if (bIsValid)
{
wo.SetObject("true");
}
else
{
wo.SetObject("false");
}
return wo;
}
private WrappedObject DoGetSecretIDs(SecretStore ssStore, WrappedObject wo)
{
if (!ssStore.IsStoreLocked())

View File

@@ -154,6 +154,10 @@ namespace sscs.verbs
#endif
}
if (secretId.Length < 1 || key.Length < 1 || valStr.Length < 1)
{
CSSSLogger.DbgLog("Error in length");
}
try
{