Skip to content

testing/crypto: cover AES-192/256-CBC, cipher streaming, GCM and AES-256-CMAC - #4078

Open
ThePassionate wants to merge 4 commits into
apache:masterfrom
ThePassionate:crypto-sym-tests
Open

ThePassionate wants to merge 4 commits into
apache:masterfrom
ThePassionate:crypto-sym-tests

Conversation

@ThePassionate

Copy link
Copy Markdown
Contributor

Summary

Test coverage for the symmetric capabilities added in apache/nuttx#21957:

  • aescbc: four AES-128 vectors (RFC 3602) plus the NIST SP 800-38A AES-192 and AES-256 vectors; every vector runs encrypt/decrypt one-shot and encrypt/decrypt as a 16-byte-block update chain.
  • aesctr: every vector additionally runs as an 8-byte-chunk update chain, which crosses block boundaries and verifies that the keystream tail carries over between requests.
  • aescmac: the four NIST 256-bit CMAC vectors next to the existing 128-bit ones.
  • aesgcm (new test): AES-GCM through the composite session with the GCM spec test case 4 parameters - encrypt/decrypt round trip plus a known-answer check of ciphertext and tag, once with the 96-bit IV and once with an 8-byte IV (GHASH-derived pre-counter block). AAD and payload are fed as separate update steps. The expected values are cross-checked against an independent host implementation.

Impact

  • Testing only. New TESTING_CRYPTO_AESGCM option (default n); the other tests extend existing files.

Testing

Depends on apache/nuttx#21957. On sim:sim/crypto with that kernel series, all of the above pass:

aescbc test vector 0..5 ok
OK test vector 0..8 / OK test vector 0..8 stream mode   (aesctr)
aes cmac test 0-3 (128 bits) ok / aes cmac test 0-3 (256 bits) ok
aesgcm test ok (iv length 12)
aesgcm test ok (iv length 8)

tools/checkpatch.sh -c -u -m -g <base>..HEAD (via the paired nuttx tree) passes.

Add the NIST SP 800-38A AES-192-CBC and AES-256-CBC vectors (extracted
from the kernel test-manager templates), pick the CRYPTO_AES_{192,256}_
CBC session id from the key length like the mbedtls aes_alt does, and
run every vector through a second pass that feeds one block per
CIOCCRYPT chained with COP_FLAG_UPDATE; the result must match the
one-shot run.

Signed-off-by: makejian <makejian@xiaomi.com>
Run every RFC 3686 vector a second time feeding 8 bytes per CIOCCRYPT
chained with COP_FLAG_UPDATE. 8-byte chunks end mid-keystream-block, so
matching the one-shot result verifies that the unused keystream tail is
kept in the session key schedule.

Signed-off-by: makejian <makejian@xiaomi.com>
Add the AES-256-CMAC key and the four NIST SP 800-38B expected tags for
the existing message lengths; syscrypt now derives the mac type from the
key size (128/256) and the test runs both key sizes.

Signed-off-by: makejian <makejian@xiaomi.com>
Exercise the AES-GCM composite session through /dev/crypto with the
GCM spec test case 4 parameters: encrypt/decrypt round trip plus a
known-answer check of the ciphertext and tag, once with the standard
96-bit IV and once with an 8-byte IV that exercises the GHASH-derived
pre-counter block.  The AAD and payload are fed as separate update
steps.

The expected values are cross-checked against an independent host
implementation (python cryptography) and match the published spec
values for the 96-bit IV case.

Signed-off-by: makejian <makejian@xiaomi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant