mirror of
https://github.com/KeyKeeperApp/KeyKeeper.git
synced 2026-04-26 10:06:28 +03:00
file write fixes
This commit is contained in:
@@ -30,7 +30,7 @@ public class AesKdf : MasterKeyDerivationFunction
|
||||
byte[] key = source.Hash()[..SEED_LENGTH];
|
||||
byte[] nextKey = new byte[SEED_LENGTH];
|
||||
Aes cipher = Aes.Create();
|
||||
cipher.KeySize = SEED_LENGTH;
|
||||
cipher.KeySize = SEED_LENGTH * 8;
|
||||
for (int i = 0; i < rounds; ++i)
|
||||
{
|
||||
cipher.Key = key;
|
||||
|
||||
@@ -85,19 +85,16 @@ public class OuterEncryptionWriter : Stream
|
||||
|
||||
public override void Write(ReadOnlySpan<byte> buffer)
|
||||
{
|
||||
Console.WriteLine("OE write " + buffer.Length);
|
||||
int written = 0;
|
||||
while (written < buffer.Length)
|
||||
{
|
||||
if (chunkPosition == currentChunk.Length)
|
||||
EncryptAndStoreCurrentFullChunk();
|
||||
int n = Math.Min(buffer.Length, currentChunk.Length - chunkPosition);
|
||||
Console.WriteLine("OEW: copy " + n + " bytes buffer+" + written + " -> chunk+" + chunkPosition);
|
||||
buffer.Slice(written, n).CopyTo(new Span<byte>(currentChunk, chunkPosition, n));
|
||||
written += n;
|
||||
chunkPosition += n;
|
||||
position += n;
|
||||
Console.WriteLine(string.Format("written={} pos={}", written, chunkPosition));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public abstract class PassStoreEntry
|
||||
timestamp = (ulong) new DateTimeOffset(ModificationDate.ToUniversalTime()).ToUnixTimeSeconds();
|
||||
FileFormatUtil.WriteVarUint16(tmp, timestamp);
|
||||
wr.Write(IconType.ToByteArray());
|
||||
FileFormatUtil.WriteU8TaggedString(tmp, Name);
|
||||
FileFormatUtil.WriteU16TaggedString(tmp, Name);
|
||||
wr.Write(InnerSerialize());
|
||||
byte[] serializedEntry = tmp.ToArray();
|
||||
tmp.Dispose();
|
||||
|
||||
@@ -122,6 +122,7 @@ public class PassStoreFileAccessor : IPassStore
|
||||
{
|
||||
byte[] randomPadding = new byte[randomPaddingLen];
|
||||
RandomNumberGenerator.Fill(randomPadding);
|
||||
file.Write(randomPadding);
|
||||
}
|
||||
|
||||
byte[] masterKey = newHeader.KdfInfo.GetKdf().Derive(options.Key, 32);
|
||||
@@ -196,7 +197,7 @@ public class PassStoreFileAccessor : IPassStore
|
||||
),
|
||||
new AesKdfHeader
|
||||
(
|
||||
MAX_AESKDF_ROUNDS,
|
||||
200000,
|
||||
aesKdfSeed
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user