mirror of
https://github.com/KeyKeeperApp/KeyKeeper.git
synced 2026-04-17 18:16:28 +03:00
add IsLast property to PassStoreContentChunk
- add special handling of the bit 23 in the 24-bit ChunkSize field - make the constructor set the property depending on that bit
This commit is contained in:
@@ -14,6 +14,7 @@ namespace KeyKeeper.PasswordStore.Crypto;
|
||||
/// </summary>
|
||||
public class PassStoreContentChunk
|
||||
{
|
||||
public bool IsLast { get; }
|
||||
private byte[] chunk;
|
||||
private int chunkLen;
|
||||
|
||||
@@ -45,6 +46,9 @@ public class PassStoreContentChunk
|
||||
throw PassStoreFileException.UnexpectedEndOfFile;
|
||||
}
|
||||
|
||||
IsLast = (chunkLen & (1 << 23)) != 0;
|
||||
chunkLen &= ~(1 << 23);
|
||||
|
||||
if (chunk.Length != chunkLen + 3 + HMAC_SIZE)
|
||||
{
|
||||
throw PassStoreFileException.UnexpectedEndOfFile;
|
||||
@@ -104,6 +108,7 @@ public class PassStoreContentChunk
|
||||
{
|
||||
throw PassStoreFileException.UnexpectedEndOfFile;
|
||||
}
|
||||
chunkLen &= ~(1 << 23); // 23 бит имеет специальное значение
|
||||
byte[] chunk = new byte[3 + HMAC_SIZE + chunkLen];
|
||||
if (s.Read(chunk) < chunk.Length)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user