Reverse order on close calls on filestream and cryptstream. Change lazy write of cache to 15 seconds from 30 seconds.

This commit is contained in:
Jim Norman 2006-02-01 15:57:13 +00:00
parent 92bfac50fc
commit 2277926029
2 changed files with 41 additions and 31 deletions

View File

@ -93,10 +93,10 @@ namespace sscs.crypto
CSSSLogger.DbgLog("Unable to store the generated key");
bRet = false;
}
if( fsEncrypt != null )
fsEncrypt.Close();
if (csEncrypt != null)
csEncrypt.Close();
if( fsEncrypt != null )
fsEncrypt.Close();
return bRet;
}
@ -138,8 +138,8 @@ namespace sscs.crypto
if(storedHash[i] != newHash[i])
{
CSSSLogger.DbgLog("Hash doesnot match");
fsDecrypt.Close();
csDecrypt.Close();
fsDecrypt.Close();
return null;
}
}
@ -150,11 +150,15 @@ namespace sscs.crypto
CSSSLogger.DbgLog("Unable to get the stored key");
baSavedKey = null;
}
if ( fsDecrypt != null )
fsDecrypt.Close();
if (csDecrypt != null)
csDecrypt.Close();
if ( fsDecrypt != null )
fsDecrypt.Close();
return baSavedKey;
}
@ -199,10 +203,10 @@ namespace sscs.crypto
CSSSLogger.ExpLog(e.ToString());
CSSSLogger.DbgLog("Encrypting and storing to file failed.");
}
if( fsEncrypt != null )
fsEncrypt.Close();
if (csEncrypt != null)
csEncrypt.Close();
if( fsEncrypt != null )
fsEncrypt.Close();
}
internal static byte[] ReadFileAndDecryptData(byte[] key,
@ -247,28 +251,28 @@ namespace sscs.crypto
if(storedHash[i] != newHash[i])
{
CSSSLogger.DbgLog("Hash doesnot match");
fsDecrypt.Close();
csDecrypt.Close();
fsDecrypt.Close();
return null;
}
}
fsDecrypt.Close();
csDecrypt.Close();
fsDecrypt.Close();
return tmpEncrypt;
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
if( fsDecrypt != null )
{
fsDecrypt.Close();
}
if (csDecrypt != null)
{
csDecrypt.Close();
}
if( fsDecrypt != null )
{
fsDecrypt.Close();
}
return null;
}
@ -395,21 +399,22 @@ namespace sscs.crypto
csEncrypt.Write(baMasterPasscode, 0, baMasterPasscode.Length);
csEncrypt.FlushFinalBlock();
fsEncrypt.Close();
csEncrypt.Close();
fsEncrypt.Close();
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
}
if( fsEncrypt != null )
{
fsEncrypt.Close();
}
if (csEncrypt != null)
{
csEncrypt.Close();
}
if( fsEncrypt != null )
{
fsEncrypt.Close();
}
}
public static byte[] DecryptMasterPasscodeUsingString(string passwd,
@ -443,10 +448,15 @@ namespace sscs.crypto
CSSSLogger.DbgLog("Unable to decrypt master passode");
baSavedMasterPasscode = null;
}
if( fsDecrypt != null )
fsDecrypt.Close();
if (csDecrypt != null)
csDecrypt.Close();
if ( fsDecrypt != null )
fsDecrypt.Close();
return baSavedMasterPasscode;
}

View File

@ -286,7 +286,7 @@ namespace sscs.lss
private void PersistStoreDelayThreadFn()
{
Thread.Sleep(30000);
Thread.Sleep(15000);
PersistStore();
persistThread = null;
}