Skip to content

feat: added PKCS#7 envelope implementation #298

Open
dallasd1 wants to merge 3 commits intonotaryproject:mainfrom
dallasd1:dadelan/pkcs7-envelope
Open

feat: added PKCS#7 envelope implementation #298
dallasd1 wants to merge 3 commits intonotaryproject:mainfrom
dallasd1:dadelan/pkcs7-envelope

Conversation

@dallasd1
Copy link

@dallasd1 dallasd1 commented Mar 12, 2026

Add the PKCS#7 envelope implementation to support creating signatures for dm-verity. The kernel's dm-verity feature requires PKCS#7 signatures without authenticated attributes.

This PR leverages the open source mozilla pkcs7 package.

#298

Adds PKCS#7/CMS signature envelope implementation following the same
pattern as existing JWS and COSE envelopes.

Features:
- Implements signature.Envelope interface (Sign, Verify, Content)
- Uses go.mozilla.org/pkcs7 library for ASN.1 encoding
- Uses signerAdapter pattern to support both local and remote signers
- Works with Azure Key Vault and other plugins via signature.Signer
- Produces detached signatures for dm-verity kernel verification
- Supports RSA and ECDSA key types with SHA-256
- Registers media type application/pkcs7-signature

The signerAdapter wraps pre-computed signatures from any signature.Signer
to satisfy the crypto.Signer interface expected by the Mozilla library.
This enables remote signers (like Azure Key Vault) that don't expose
private keys to work with the library.

Signed-off-by: Dallas Delaney <[email protected]>
The base.Envelope wrapper validates that signing-time is present, but
PKCS#7 signatures for dm-verity must not include authenticated attributes
(including signing-time) per Linux kernel requirements. The kernel's
PKCS#7 verifier in crypto/asymmetric_keys/public_key.c expects raw
signature data without CMS authenticated attributes.

Remove the base.Envelope wrapper from NewEnvelope() and ParseEnvelope()
so the pkcs7 envelope implements signature.Envelope directly.

Signed-off-by: Dallas Delaney <[email protected]>
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.

1 participant