Skip to content

Conversation

@PruteanuVlad
Copy link

@PruteanuVlad PruteanuVlad commented Jan 24, 2026

Summary

This adds 2 cases to the HMAC driver test. They are taken from RFC4231 - Identifiers and Test Vectors for HMAC-SHA-224, HMAC-SHA-256, HMAC-SHA-384, and HMAC-SHA-512, test cases number 6 and 7.
Results for MD5 and SHA1, which aren't included in the RFC were generated using this online calculator, which was validated by checking it's SHA256 against the expected RFC result.

Impact

This update improves the test by covering an additional edge-case.

Testing

Development was done using ESP32 DevkitC.
Building was done on Ubuntu 24.04 VM.
Testing using current nuttx master branch, bug described in this PR present:

nsh> hmac
hmac md5 success
hmac md5 success
hmac md5 success
syshamc md5 failed
bfecaf4efff90a3a668f3922fec3762d
56be34521d144c88dbb8c733f0e8b3f6
match md5 failed
syshamc md5 failed
09b8ae7b15adbbb243aca3491b51512b
56be34521d144c88dbb8c733f0e8b3f6
match md5 failed
hmac sha1 success
hmac sha1 success
hmac sha1 success
syshamc sha1 failed
CIOCGSESSIONhmac mismatchCIOCGSESSIONhmac mismatchCIOCGSESSIONhm90d0dace1c1bdc957339307803160335bde6df2b
d730594d167e35d5956fd8003d0db3d3f46dc7bb
match sha1 failed
syshamc sha1 failed
217e44bb08b6e06a2d6c30f3cb9f537f97c63356
d730594d167e35d5956fd8003d0db3d3f46dc7bb
match sha1 failed
hmac sha256 success
hmac sha256 success
hmac sha256 success
syshamc sha256 failed
60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54
7dda3cc169743a6484649f94f0eda0f9f2ff496a9733fb796ed5adb40a44c3c1
match sha256 failed
ac mismatchCIOCGSESSIONhmac mismatchCIOCGSESSIONhmac mismatchCIOsyshamc sha256 failed
9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2
7dda3cc169743a6484649f94f0eda0f9f2ff496a9733fb796ed5adb40a44c3c1
match sha256 failed

Testing using the above mentioned PR fix:

nsh> hmac
hmac md5 success
hmac md5 success
hmac md5 success
hmac md5 success
hmac md5 success
hmac sha1 success
hmac sha1 success
hmac sha1 success
hmac sha1 success
hmac sha1 success
hmac sha256 success
hmac sha256 success
hmac sha256 success
hmac sha256 success
hmac sha256 success

This adds 2 tests, which include keys that are
longer than the SHA's block size.

Signed-off-by: Vlad Pruteanu <pruteanuvlad1611@yahoo.com>
Copy link
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

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

Thank you @PruteanuVlad :-)

Lets just make sure CI completes fine :-)

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.

3 participants