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:
2025-12-01 15:43:03 +03:00
parent fecab564b7
commit 1899284277

View File

@@ -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)
{