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