Skip to content

Tighten wolfCOSE type safety for MISRA complaince - #79

Open
aidangarske wants to merge 8 commits into
wolfSSL:mainfrom
aidangarske:fenrir-misra-types-12185
Open

Tighten wolfCOSE type safety for MISRA complaince#79
aidangarske wants to merge 8 commits into
wolfSSL:mainfrom
aidangarske:fenrir-misra-types-12185

Conversation

@aidangarske

Copy link
Copy Markdown
Member
F-11110, F-11116, F-12185, F-12186, F-12187, F-12976, F-12977

@aidangarske aidangarske self-assigned this Sep 9, 2026
Copilot AI lite review requested due to automatic review settings September 9, 2026 21:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 int algorithm/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 char to uint8_t and 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.

Comment thread src/wolfcose_alg.c
Comment thread tests/test_cose.c
Comment thread tests/test_cose.c
Comment thread src/wolfcose_internal.h Outdated
Comment thread src/wolfcose_sign1.c
Comment thread src/wolfcose_sign1.c Outdated
Comment thread src/wolfcose_sign1.c Outdated
Comment thread src/wolfcose_sign1.c Outdated
Comment thread examples/sign1_mldsa.c
Comment on lines +38 to +39
static uint8_t gScratch[20000];
static uint8_t gMsg[8192];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You might want to make the same change in examples/sign1_lms.c too?

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