mirror of
https://github.com/KeyKeeperApp/KeyKeeper.git
synced 2026-05-14 12:26:32 +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>
|
/// </summary>
|
||||||
public class PassStoreContentChunk
|
public class PassStoreContentChunk
|
||||||
{
|
{
|
||||||
|
public bool IsLast { get; }
|
||||||
private byte[] chunk;
|
private byte[] chunk;
|
||||||
private int chunkLen;
|
private int chunkLen;
|
||||||
|
|
||||||
@@ -45,6 +46,9 @@ public class PassStoreContentChunk
|
|||||||
throw PassStoreFileException.UnexpectedEndOfFile;
|
throw PassStoreFileException.UnexpectedEndOfFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IsLast = (chunkLen & (1 << 23)) != 0;
|
||||||
|
chunkLen &= ~(1 << 23);
|
||||||
|
|
||||||
if (chunk.Length != chunkLen + 3 + HMAC_SIZE)
|
if (chunk.Length != chunkLen + 3 + HMAC_SIZE)
|
||||||
{
|
{
|
||||||
throw PassStoreFileException.UnexpectedEndOfFile;
|
throw PassStoreFileException.UnexpectedEndOfFile;
|
||||||
@@ -104,6 +108,7 @@ public class PassStoreContentChunk
|
|||||||
{
|
{
|
||||||
throw PassStoreFileException.UnexpectedEndOfFile;
|
throw PassStoreFileException.UnexpectedEndOfFile;
|
||||||
}
|
}
|
||||||
|
chunkLen &= ~(1 << 23); // 23 бит имеет специальное значение
|
||||||
byte[] chunk = new byte[3 + HMAC_SIZE + chunkLen];
|
byte[] chunk = new byte[3 + HMAC_SIZE + chunkLen];
|
||||||
if (s.Read(chunk) < chunk.Length)
|
if (s.Read(chunk) < chunk.Length)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user