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

@ -92,11 +92,11 @@ namespace sscs.crypto
CSSSLogger.ExpLog(e.ToString());
CSSSLogger.DbgLog("Unable to store the generated key");
bRet = false;
}
}
if (csEncrypt != null)
csEncrypt.Close();
if( fsEncrypt != null )
fsEncrypt.Close();
if( csEncrypt != null )
csEncrypt.Close();
return bRet;
}
@ -137,9 +137,9 @@ namespace sscs.crypto
{
if(storedHash[i] != newHash[i])
{
CSSSLogger.DbgLog("Hash doesnot match");
fsDecrypt.Close();
CSSSLogger.DbgLog("Hash doesnot match");
csDecrypt.Close();
fsDecrypt.Close();
return null;
}
}
@ -149,12 +149,16 @@ namespace sscs.crypto
CSSSLogger.ExpLog(e.ToString());
CSSSLogger.DbgLog("Unable to get the stored key");
baSavedKey = null;
}
}
if (csDecrypt != null)
csDecrypt.Close();
if ( fsDecrypt != null )
fsDecrypt.Close();
if( csDecrypt != null )
csDecrypt.Close();
return baSavedKey;
}
@ -198,11 +202,11 @@ namespace sscs.crypto
{
CSSSLogger.ExpLog(e.ToString());
CSSSLogger.DbgLog("Encrypting and storing to file failed.");
}
}
if (csEncrypt != null)
csEncrypt.Close();
if( fsEncrypt != null )
fsEncrypt.Close();
if( csEncrypt != null )
csEncrypt.Close();
}
internal static byte[] ReadFileAndDecryptData(byte[] key,
@ -246,29 +250,29 @@ namespace sscs.crypto
{
if(storedHash[i] != newHash[i])
{
CSSSLogger.DbgLog("Hash doesnot match");
fsDecrypt.Close();
CSSSLogger.DbgLog("Hash doesnot match");
csDecrypt.Close();
fsDecrypt.Close();
return null;
}
}
fsDecrypt.Close();
}
csDecrypt.Close();
fsDecrypt.Close();
return tmpEncrypt;
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
if (csDecrypt != null)
{
csDecrypt.Close();
}
if( fsDecrypt != null )
{
fsDecrypt.Close();
}
if( csDecrypt != null )
{
csDecrypt.Close();
}
}
return null;
}
@ -394,22 +398,23 @@ namespace sscs.crypto
//Write all data to the crypto stream and flush it.
csEncrypt.Write(baMasterPasscode, 0, baMasterPasscode.Length);
csEncrypt.FlushFinalBlock();
fsEncrypt.Close();
csEncrypt.FlushFinalBlock();
csEncrypt.Close();
fsEncrypt.Close();
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
}
if (csEncrypt != null)
{
csEncrypt.Close();
}
if( fsEncrypt != null )
{
fsEncrypt.Close();
}
if( csEncrypt != null )
{
csEncrypt.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 )
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;
}