Describe the bug
atcab_write_enc corrupts block 0 — When writing to an AES slot with WrCfg=4 (encrypted write), block 0 gets nonce-dependent garbage while block 1 writes correctly.
To Reproduce
Prerequisites: ATECC608B TrustFLEX, slot with WrCfg=4 (e.g. slot 5), IO protection key in slot 6.
Steps:
-
Write a known 16-byte key (e.g. all-zeros) to slot 5, block 0 via atcab_write_enc
uint8_t key[16] = {0}; uint8_t io_key[32] = { /* IO protection key from slot 6 */ }; atcab_write_enc(5, 0, key, io_key, 6); // block 0
-
Read back block 0 via atcab_aes_encrypt_ext with known plaintext (NIST FIPS 197: PT=all-zeros, expected CT=66e94bd4ef8a2c3b884cfa59ca342b2e):
uint8_t pt[16] = {0}, ct[16]; atcab_aes_encrypt_ext(atcab_get_device(), 5, 0, pt, ct); // ct does NOT match NIST expected — block 0 is corrupted
-
Repeat step 1 — block 0 produces different garbage each time (nonce-dependent).
-
Now write the same key to block 1:
atcab_write_enc(5, 1, key, io_key, 6); // block 1
-
Verify block 1:
atcab_aes_encrypt_ext(atcab_get_device(), 5, 1, pt, ct);
// ct MATCHES 66e94bd4ef8a2c3b884cfa59ca342b2e — block 1 is correct
Expected behavior
Expected: Block 0 should produce NIST-matching output.
Actual: Block 0 contains nonce-dependent garbage; only block 1 writes correctly.
Additional context
ATECC608B TrustFLEX, RPi4, USB HID
cryptoauthlib version (v3.8.0)
Describe the bug
atcab_write_enc corrupts block 0 — When writing to an AES slot with WrCfg=4 (encrypted write), block 0 gets nonce-dependent garbage while block 1 writes correctly.
To Reproduce
Prerequisites: ATECC608B TrustFLEX, slot with WrCfg=4 (e.g. slot 5), IO protection key in slot 6.
Steps:
Write a known 16-byte key (e.g. all-zeros) to slot 5, block 0 via atcab_write_enc
uint8_t key[16] = {0}; uint8_t io_key[32] = { /* IO protection key from slot 6 */ }; atcab_write_enc(5, 0, key, io_key, 6); // block 0Read back block 0 via atcab_aes_encrypt_ext with known plaintext (NIST FIPS 197: PT=all-zeros, expected CT=66e94bd4ef8a2c3b884cfa59ca342b2e):
uint8_t pt[16] = {0}, ct[16]; atcab_aes_encrypt_ext(atcab_get_device(), 5, 0, pt, ct); // ct does NOT match NIST expected — block 0 is corruptedRepeat step 1 — block 0 produces different garbage each time (nonce-dependent).
Now write the same key to block 1:
atcab_write_enc(5, 1, key, io_key, 6); // block 1Verify block 1:
Expected behavior
Expected: Block 0 should produce NIST-matching output.
Actual: Block 0 contains nonce-dependent garbage; only block 1 writes correctly.
Additional context
ATECC608B TrustFLEX, RPi4, USB HID
cryptoauthlib version (v3.8.0)