HMAC added to dgst#257
Conversation
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #257
Scan targets checked: wolfclu-bugs, wolfclu-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
914f90e to
87975ce
Compare
87975ce to
056a862
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #257
Scan targets checked: wolfclu-bugs, wolfclu-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
ee5ebd0 to
1883df8
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #257
Scan targets checked: wolfclu-bugs, wolfclu-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
1883df8 to
5776c2d
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #257
Scan targets checked: wolfclu-bugs, wolfclu-src
No new issues found in the changed files. ✅
5776c2d to
8c46617
Compare
There was a problem hiding this comment.
Pull request overview
Adds HMAC support to the existing dgst subcommand (alongside sign/verify), including new CLI flags, a streaming HMAC helper, and end-to-end RFC vector tests. It also updates dgst input handling so data can be supplied via stdin when no positional input file is present.
Changes:
- Add
-hmac/-mackeyflags todgstand update help text + stdin/positional input handling. - Introduce a streaming HMAC implementation (
wolfCLU_hmacHash) and an HMAC dispatch helper indgstsetup. - Add end-to-end Python tests covering RFC vectors, output-to-file behavior, and key parsing edge cases.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
wolfclu/clu_optargs.h |
Adds new option IDs for dgst HMAC flags. |
wolfclu/clu_header_main.h |
Exposes the new wolfCLU_hmacHash() API (with updated includes/docs). |
src/tools/clu_funcs.c |
Implements streaming HMAC helper used by dgst. |
src/sign-verify/clu_dgst_setup.c |
Extends dgst to support HMAC mode and stdin input dispatch. |
tests/dgst/dgst-test.py |
Adds HMAC RFC vector and behavior tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
billphipps
left a comment
There was a problem hiding this comment.
Copilot comments are pretty good. A few minor nits, but this looks like a great addition!
| /* wc_HashType values are not contiguous, so map each one explicitly. | ||
| * Cast to int so unrelated hash types don't trip -Wswitch-enum. */ | ||
| switch ((int)alg) { | ||
| case WC_HASH_TYPE_MD5: |
There was a problem hiding this comment.
Do you need to check for NO_MD5 or other conditional compilation flags?
There was a problem hiding this comment.
--enable-wolfclu option for wolfSSL turns on MD5 so we are good for now! And for the other hash alg guards it is a pretty pervasive issue Ill probably make a separate PR that guards all of the hash algs because it touches a lot of files. --disable-hmac won't build with --enable-wolfclu so we are safe there.
| /* return WOLFCLU_SUCCESS on success */ | ||
| int wolfCLU_dgst_setup(int argc, char** argv) | ||
| { | ||
| #ifndef WOLFCLU_NO_FILESYSTEM |
There was a problem hiding this comment.
Hrmm... If the input is stdin, the output is stdout, and all key materials are on command line, why do we need a filesystem? Ok to punt to a later feature request
There was a problem hiding this comment.
Very true! This is an upgrade we could make across a ton of functionalities so if it comes up in the future it would be easy to do it all at once.
| *sep = '\0'; /* terminate the type token */ | ||
| macKeyVal = sep + 1; /* value is the remainder, ':' included */ | ||
|
|
||
| if (XSTRCMP(hmacKey, "hexkey") == 0) { |
There was a problem hiding this comment.
consider using XSTRNCMP since you know the length of "hexkey"
| WOLFCLU_LOG(WOLFCLU_L0, "\t-mackey key:value for plain text " | ||
| "hexkey:value to have value encoded\n"); |
There was a problem hiding this comment.
| WOLFCLU_LOG(WOLFCLU_L0, "\t-mackey key:value for plain text " | |
| "hexkey:value to have value encoded\n"); | |
| WOLFCLU_LOG(WOLFCLU_L0, "\t-mackey key:value for plain text hmac key" | |
| "hexkey:value for hex-encoded hmac key\n"); |
added invalid argument tests increased plain test key size for FIPs build fix arg name conflict github fixes skoll fixes
8c46617 to
48c3ba3
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #257
Scan targets checked: wolfclu-bugs, wolfclu-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
|
Jenkins retest this please |
Added new flags to the dgst sub command.
Created 3 helper functions to make the HMAC and sign/verify functionalities easy to read and use.
Added end-to-end tests for HMAC RFC Vectors using hex key and plain text key.
Changed input to allow for data to be passed to stdin for dgst.