Skip to content

Add ADAC 1.1 serialization, validation, and CLI support#9

Merged
mathias-arm merged 21 commits into
mainfrom
adac-1.1
Jun 5, 2026
Merged

Add ADAC 1.1 serialization, validation, and CLI support#9
mathias-arm merged 21 commits into
mainfrom
adac-1.1

Conversation

@mathias-arm
Copy link
Copy Markdown
Collaborator

@mathias-arm mathias-arm commented May 29, 2026

This PR adds ADAC 1.1 support and tightens encoding, validation, and CLI verification behavior. The main changes are:

  • Add ADAC 1.1 certificate policy support and TLV flags, including critical-extension handling and TLV padding validation.
  • Replace implicit layout assumptions with explicit ADAC serialization/deserialization helpers for certificate headers, token headers, and TLV headers.
  • Add encoding diagnostics for certificates, certificate chains, tokens, and TLV sequences, with contextual issue reporting.
  • Centralize certificate-chain and token validation so CLI verification and library callers share consistent semantic checks.
  • Add adac-cli verify --strict for stricter local diagnostics, including requiring token validation to terminate at a leaf certificate and rejecting unknown/unprocessed critical extensions.
  • Add structured extension syntax for certificate/token creation, including token soc_id extension support.
  • Gate deterministic RSA-PSS signing behind the hazmat-deterministic feature.
  • Move larger adac-cli command tests into integration tests and add shell coverage for CLI/offline flows.
  • Align hybrid-array dependency versions to avoid duplicate versions.
  • Update aws-lc-rs to 1.17.0 and aws-lc-sys to 0.41.0.
  • Update RustCrypto ed448 and ml-dsa dependencies from release candidates to stable versions.
  • Add cli-test.sh to CI/check coverage.

A few fixes raised by Metis:

  • Reject non-integer certificate policies values in TOML instead of silently treating malformed values as zero.
  • Validate Ed25519 public key lengths before fixed-size slicing in ADAC public-key conversion paths.
  • Restrict the deterministic RSA-PSS test RNG so it is not used by mistake.
  • Harden RSA profile validation across RustCrypto, PKCS11, and public-key parsing paths using shared RSA modulus-size policy.
  • Classify RSA PKCS8 private keys by decoded modulus size instead of DER payload length.
  • Validate EC SEC1 encodings before stripping the uncompressed-point prefix.
  • Derive and verify Ed448 public keys from PKCS#8 private key material to reject mismatched embedded public keys.

- Parse and validate certificate policies from configuration file, allowing nonzero values only for ADAC 1.1 certificates.
- Emit policies from online and offline certificate signing flows.
- Report the effective policy bitmask during verification when it is nonzero.

Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
- Add explicit little-endian serialization and deserialization helpers for certificate, token, and TLV headers.
- Centralize validation of header versions, reserved fields, crypto consistency, and ADAC 1.0 policy constraints.
- Keep the old packed-layout path temporarily behind the serialization feature boundary.

Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
- Remove the native packed-layout serialization fallback and the associated feature gating.
- Route certificate, token, and TLV encoding through the explicit serialization helpers unconditionally.
- Rename serialized-size constants to the simpler SIZE form.

Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
- Replace the public deterministic constructor with an explicitly named test-only constructor.
- Gate deterministic signing behind hazmat-deterministic so normal consumers cannot accidentally enable deterministic RSA-PSS signing.
- Enable the hazmat feature only for tests that require byte-for-byte stable signatures.

Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
- Update TLV headers to include ADAC 1.1 flags, including the critical-extension flag.
- Add shared TLV sequence parsing that advances over padded values and rejects nonzero padding.
- Use the shared parser for certificate-chain decoding so TLV padding and alignment rules are applied consistently.

Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
- Add encoding validators for TLV sequences, certificate chains, individual certificates, and tokens.
- Report all detectable encoding issues with byte offsets and context instead of failing at the first parse error.
- Cover malformed TLVs, invalid padding, token header issues, and nested certificate/token extension encodings.

Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
- Introduce a reusable chain validator that tracks certificate order, role constraints, signatures, and effective chain constraints.
- Rework adac-cli verify and verify_chain to use the shared validation logic.
- Add token validation through the same validator so token permissions are combined with the effective certificate-chain constraints.

Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
- Split adac-cli command implementation into a library-backed binary so command functions can be tested from integration tests.
- Move most command-level tests out of module unit tests and into adac-cli/tests.
- Add shared integration-test scaffolding for certificate chains, token signing, offline signing, and verify diagnostics.

Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
- Add verify --strict to enable stricter diagnostic checks for token validation and critical extensions.
- Reject ADAC 1.0 artifacts that carry ADAC 1.1 TLV flags and reject unknown TLV flag bits.
- Distinguish token signature verification from full token validation when the certificate chain is invalid.

Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
- Add structured extension syntax for certificate and token config, while retaining legacy base16 TLV input.
- Support critical token soc_id extensions and fold them into effective verification output.
- Add CLI shell coverage for effective constraints, token SoC ID extensions, and offline token signing.

Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
Reject TOML section-level certificate policies when the value is present but not an integer instead of silently treating it as zero.

Reported-by: Metis (https://github.com/arm/metis)
Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
Reject TOML section-level certificate policies when the value is present but not an integer instead of silently treating it as zero.

Reported-by: Metis (https://github.com/arm/metis)
Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
Make the helper for deterministic RSA-PSS test output crate-private to avoid from being used by outside tests by mistake.

Reported-by: Metis (https://github.com/arm/metis)
Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
Move RSA modulus sizing policy into the shared adac crate and use it from RustCrypto, PKCS11, and public-key parsing paths.
The shared policy keeps ADAC RSA public-key encodings fixed-width while accepting decoded RSA modulus bit lengths within a one-byte leading-bit tolerance for 3072-bit and 4096-bit profiles.
Reject mismatched RSA private keys on load/import and clean up the public PKCS11 object if private-object creation fails.

Reported-by: Metis (https://github.com/arm/metis)
Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
Align adac-crypto key loading with the shared RSA profile policy introduced for provider validation. Decode RSA PKCS8 private keys and infer the ADAC RSA profile from the actual modulus size instead of relying on representation-dependent private-key DER payload lengths.

Reported-by: Metis (https://github.com/arm/metis)
Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
Align adac-crypto key loading with the shared RSA profile policy introduced for provider validation. Decode RSA PKCS8 private keys and infer the ADAC RSA profile from the actual modulus size instead of relying on representation-dependent private-key DER payload lengths.

Reported-by: Metis (https://github.com/arm/metis)
Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
Derive the Ed448 public key from the PKCS8 private key material and use that derived value for SPKI and ADAC public-key output.
If the PKCS8 structure also embeds a public key, validate that it matches the derived key and reject mismatched keypairs to avoid private/public key-binding confusion.

Reported-by: Metis (https://github.com/arm/metis)
Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
Avoid duplicated versions of the crate.

Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
Update the RustCrypto ed448 (0.5.0) and ml-dsa (0.1.0) from release candidates to their stable releases.

Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
Signed-off-by: Mathias Brossard <mathias.brossard@arm.com>
@mathias-arm mathias-arm requested a review from CaseyHillers June 5, 2026 17:04
Copy link
Copy Markdown
Collaborator

@CaseyHillers CaseyHillers left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for moving the tests to a dedicated directory. It made it much easier to review these PRs.

@mathias-arm mathias-arm merged commit 3e525ce into main Jun 5, 2026
2 checks passed
@mathias-arm mathias-arm deleted the adac-1.1 branch June 5, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants