Tighten wolfCOSE type safety for MISRA complaince - #79
Conversation
aidangarske
commented
Sep 9, 2026
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Pull request overview
Tightens type usage across wolfCOSE for MISRA-driven type safety, especially around hash/HMAC identifiers, RSA-PSS MGF IDs, and example/test buffer element types.
Changes:
- Replaced several
intalgorithm/type variables with domain-specific types (enum wc_HashType,WOLFCOSE_MGF_ID,WOLFCOSE_PREHASH_FLAG). - Updated HMAC/RSA-PSS call sites to use explicit casts and updated constants (
WC_HASH_TYPE_*). - Converted example/test byte buffers from
unsigned chartouint8_tand adjusted a few expressions for unsigned correctness.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_cose.c | Updates test helpers to use enum wc_HashType for HMAC type handling. |
| src/wolfcose_sign1.c | Introduces typed prehash flag and MGF ID usage; adjusts comparisons/casts. |
| src/wolfcose_sign.c | Mirrors Sign1 typed prehash/MGF changes for COSE_Sign. |
| src/wolfcose_mac0.c | Uses enum wc_HashType for HMAC hash type and casts into wolfCrypt API. |
| src/wolfcose_mac.c | Same HMAC hash-type tightening for COSE_Mac create/verify. |
| src/wolfcose_internal.h | Changes internal helper signatures and adds typedefs for prehash flag/MGF ID. |
| src/wolfcose_alg.c | Updates HMAC hash mapping + changes RSA-PSS key check preprocessor paths + typed MGF mapping. |
| examples/sign1_verify_mldsa.c | Converts large static blobs and scratch buffer to uint8_t. |
| examples/sign1_verify_lean.c | Converts key/signature blobs and scratch buffer to uint8_t. |
| examples/sign1_mldsa.c | Converts global scratch/message buffers to uint8_t. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| static uint8_t gScratch[20000]; | ||
| static uint8_t gMsg[8192]; |
There was a problem hiding this comment.
You might want to make the same change in examples/sign1_lms.c too?