From 09ed141a0acf6a75205d161a2f0b555eb7d85fae Mon Sep 17 00:00:00 2001 From: Andrew Kozlik Date: Thu, 13 Jun 2024 14:28:09 +0200 Subject: [PATCH] test(storage): Update storage tests. --- storage/tests/c/norcow_config.h | 2 +- storage/tests/python/src/consts.py | 2 +- storage/tests/python/src/crypto.py | 12 ++++-------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/storage/tests/c/norcow_config.h b/storage/tests/c/norcow_config.h index 3aa99a827a..e850c8fdc9 100644 --- a/storage/tests/c/norcow_config.h +++ b/storage/tests/c/norcow_config.h @@ -41,6 +41,6 @@ /* * Current storage version. */ -#define NORCOW_VERSION ((uint32_t)0x00000004) +#define NORCOW_VERSION ((uint32_t)0x00000005) #endif diff --git a/storage/tests/python/src/consts.py b/storage/tests/python/src/consts.py index e2edb33cc6..baa0da83ff 100644 --- a/storage/tests/python/src/consts.py +++ b/storage/tests/python/src/consts.py @@ -113,7 +113,7 @@ NORCOW_SECTOR_SIZE = 64 * 1024 NORCOW_MAGIC = b"NRC2" # Norcow version, set in the storage header, but also as an encrypted item. -NORCOW_VERSION = b"\x04\x00\x00\x00" +NORCOW_VERSION = b"\x05\x00\x00\x00" # Norcow magic combined with the version, which is stored as its negation. NORCOW_MAGIC_AND_VERSION = NORCOW_MAGIC + bytes( diff --git a/storage/tests/python/src/crypto.py b/storage/tests/python/src/crypto.py index 30b1f851d2..173bd8a9c5 100644 --- a/storage/tests/python/src/crypto.py +++ b/storage/tests/python/src/crypto.py @@ -10,17 +10,13 @@ from . import consts, prng def derive_kek_keiv(salt: bytes, pin: str) -> (bytes, bytes): kdf = PBKDF2HMAC( algorithm=hashes.SHA256(), - length=consts.KEK_SIZE + consts.KEIV_SIZE, + length=consts.KEK_SIZE, salt=bytes(salt), - iterations=10000, + iterations=20000, backend=default_backend(), ) - pbkdf_output = kdf.derive(pin.encode()) - # the first 256b is Key Encryption Key - kek = pbkdf_output[: consts.KEK_SIZE] - # following with 96b of Initialization Vector - keiv = pbkdf_output[consts.KEK_SIZE :] - + kek = kdf.derive(pin.encode()) + keiv = b"\0" * consts.KEIV_SIZE return kek, keiv