Skip to content

testing/crypto: add crc8 and crc16 tests and parameterized crc32 vectors - #4094

Merged
xiaoxiang781216 merged 2 commits into
apache:masterfrom
ThePassionate:crypto-crc-tests
Nov 21, 2026
Merged

xiaoxiang781216 merged 2 commits into
apache:masterfrom
ThePassionate:crypto-crc-tests

Conversation

@ThePassionate

Copy link
Copy Markdown
Contributor

Summary

Test coverage for the CRC xforms of apache/nuttx#22063:

  • crc8 (new test): SAE J1850, AUTOSAR, ROHC and two reflected-input cases, each with one-shot and split updates
  • crc16 (new test): CCITT/KERMIT, CCITT-FALSE, IBM, XMODEM
  • crc32 (extended): four 5-parameter vectors and one 12-byte MPEG-2 vector on top of the existing 8 legacy vectors

All vectors extracted from the reference source with a script and independently verified on the host before being committed; the check values match the published catalog entries (SAE J1850 0x4b, AUTOSAR 0xdf, ROHC 0xd0, KERMIT 0x2189, CCITT-FALSE 0x29b1, IBM 0xbb3d, XMODEM 0x31c3, MPEG-2 0x0376e6e7).

Impact

  • Testing only. New TESTING_CRYPTO_CRC8 / TESTING_CRYPTO_CRC16 options (default n).

Testing

Depends on apache/nuttx#22063. On sim:sim/crypto with that kernel PR: crc32 legacy 8/8, crc32 parameterized 40/40, crc8 40/40, crc16 32/32.

tools/checkpatch.sh (via the paired nuttx tree) passes.

Add /dev/crypto tests for the CRYPTO_CRC8 and CRYPTO_CRC16 xforms,
following the crc32 test structure.  The session key carries the
{polynomial, initial, xorout} parameters and the vectors cover the
non-reflected CRC-8/SAE J1850, CRC-8/AUTOSAR, CRC-16/CCITT-FALSE and
CRC-16/XMODEM variants, including segmented updates.

Signed-off-by: makejian <makejian@xiaomi.com>
cederom
cederom previously approved these changes Nov 20, 2026

@cederom cederom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @ThePassionate :-)

Add the reflected CRC parameter cases to the crc8 and crc16 tests, and
extend the crc32 test with parameterized keys: the full parameter block
{polynomial, initial, xorout, reflect_in, reflect_out} plus a three-word
{polynomial, initial, xorout} CRC-32/MPEG-2 case.  The legacy
single-word crc32 key cases stay unchanged.

Signed-off-by: makejian <makejian@xiaomi.com>
@xiaoxiang781216
xiaoxiang781216 merged commit f0e7882 into apache:master Nov 21, 2026
41 checks passed
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.

4 participants