mirror of
https://github.com/KeyKeeperApp/KeyKeeper.git
synced 2026-05-25 01:36:32 +03:00
slightly refactor OuterEncryptionUtil.CheckOuterEncryptionHeader
This commit is contained in:
@@ -18,15 +18,10 @@ public static class OuterEncryptionUtil
|
||||
public static void CheckOuterEncryptionHeader(FileStream f)
|
||||
{
|
||||
BinaryReader rd = new(f);
|
||||
byte masterSaltLen;
|
||||
try
|
||||
{
|
||||
masterSaltLen = rd.ReadByte();
|
||||
}
|
||||
catch (EndOfStreamException)
|
||||
{
|
||||
throw PassStoreFileException.UnexpectedEndOfFile;
|
||||
}
|
||||
byte masterSaltLen = rd.ReadByte();
|
||||
|
||||
if (masterSaltLen < MIN_MASTER_SALT_LEN || masterSaltLen > MAX_MASTER_SALT_LEN)
|
||||
{
|
||||
throw PassStoreFileException.InvalidCryptoHeader;
|
||||
@@ -34,15 +29,7 @@ public static class OuterEncryptionUtil
|
||||
|
||||
f.Seek(masterSaltLen, SeekOrigin.Current);
|
||||
|
||||
byte encryptAlgo;
|
||||
try
|
||||
{
|
||||
encryptAlgo = rd.ReadByte();
|
||||
}
|
||||
catch (EndOfStreamException)
|
||||
{
|
||||
throw PassStoreFileException.UnexpectedEndOfFile;
|
||||
}
|
||||
byte encryptAlgo = rd.ReadByte();
|
||||
|
||||
if (encryptAlgo == ENCRYPT_ALGO_AES)
|
||||
{
|
||||
@@ -54,15 +41,7 @@ public static class OuterEncryptionUtil
|
||||
throw PassStoreFileException.InvalidCryptoHeader;
|
||||
}
|
||||
|
||||
byte keyDerivationFunctionType;
|
||||
try
|
||||
{
|
||||
keyDerivationFunctionType = rd.ReadByte();
|
||||
}
|
||||
catch (EndOfStreamException)
|
||||
{
|
||||
throw PassStoreFileException.UnexpectedEndOfFile;
|
||||
}
|
||||
byte keyDerivationFunctionType = rd.ReadByte();
|
||||
|
||||
if (keyDerivationFunctionType == KDF_TYPE_AESKDF)
|
||||
{
|
||||
@@ -71,10 +50,6 @@ public static class OuterEncryptionUtil
|
||||
{
|
||||
nRounds = rd.Read7BitEncodedInt();
|
||||
}
|
||||
catch (EndOfStreamException)
|
||||
{
|
||||
throw PassStoreFileException.UnexpectedEndOfFile;
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
throw PassStoreFileException.InvalidCryptoHeader;
|
||||
@@ -87,4 +62,9 @@ public static class OuterEncryptionUtil
|
||||
f.Seek(32, SeekOrigin.Current);
|
||||
}
|
||||
}
|
||||
catch (EndOfStreamException)
|
||||
{
|
||||
throw PassStoreFileException.UnexpectedEndOfFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user