Skip to content

fix: parse ima-modsig d-modsig as d-ng like structured digest#8

Merged
hyperfinitism merged 1 commit into
mainfrom
codex/fix-code-for-d-modsig-handling
Apr 29, 2026
Merged

fix: parse ima-modsig d-modsig as d-ng like structured digest#8
hyperfinitism merged 1 commit into
mainfrom
codex/fix-code-for-d-modsig-handling

Conversation

@hyperfinitism
Copy link
Copy Markdown
Owner

@hyperfinitism hyperfinitism commented Apr 29, 2026

Motivation

  • The IMA spec defines d-modsig as a structured digest (hash algorithm + digest) analogous to d-ng, not as opaque bytes, so parsing and encoding must follow that format.
  • The change makes the ima-modsig representation able to express an absent d-modsig distinctly from an all-zero/empty blob.

Description

  • Model d-modsig as Option<Digest> in ImaModsigEntry and keep modsig as raw PKCS#7 DER bytes (Vec<u8>).
  • Update ASCII parser parse_ima_modsig() to parse the optional d-modsig with parse_prefixed_digest() instead of hex-decoding opaque bytes.
  • Update binary parser decode_ima_modsig() to decode fields[3] using decode_d_ng() when non-empty and map an empty field to None.
  • Update template encoding in collect_fields() to emit d-modsig using encode_d_ng() when present or an empty field when absent, and update the ima-modsig roundtrip test to use a real d-ng-encoded d-modsig value.

Testing

  • Ran cargo test -q which executed the unit test suite and all tests passed.
  • The updated parse_ima_modsig_roundtrip test validates decoding of a d-modsig with a real hash algorithm and digest and passed under the test run.

References

@hyperfinitism hyperfinitism added bug Something isn't working and removed codex labels Apr 29, 2026
@hyperfinitism hyperfinitism force-pushed the codex/fix-code-for-d-modsig-handling branch 2 times, most recently from 8b21059 to 0f38b28 Compare April 29, 2026 17:21
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
Signed-off-by: Takuma IMAMURA <209989118+hyperfinitism@users.noreply.github.com>
@hyperfinitism hyperfinitism force-pushed the codex/fix-code-for-d-modsig-handling branch from 0f38b28 to 4c36386 Compare April 29, 2026 17:22
@hyperfinitism hyperfinitism self-assigned this Apr 29, 2026
@hyperfinitism hyperfinitism changed the title Parse ima-modsig d-modsig as d-ng structured digest and adjust encoding/fields fix: parse ima-modsig d-modsig as d-ng like structured digest Apr 29, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the ima-modsig template handling by transitioning the modsig_digest field from a raw Vec<u8> to a structured Option<Digest>. This change affects the ASCII and binary parsers, template definitions, and hashing logic. A review comment identifies a non-idiomatic semicolon placement in src/log/ascii.rs that should be corrected for better code style.

Comment thread src/log/ascii.rs
@hyperfinitism hyperfinitism merged commit ab62b90 into main Apr 29, 2026
53 checks passed
@hyperfinitism hyperfinitism deleted the codex/fix-code-for-d-modsig-handling branch April 29, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant