feat(corim): add x5chain trust verification with PKIX and CRL support#276
Draft
magickli1 wants to merge 1 commit into
Draft
feat(corim): add x5chain trust verification with PKIX and CRL support#276magickli1 wants to merge 1 commit into
magickli1 wants to merge 1 commit into
Conversation
Validate x5chain-signed CoRIMs via TrustedRoots, TrustedRootPool, and SignedCorim.VerifyX509ChainTrust (PKIX, optional CRL, leaf-key signature). Fix FromCOSE x5chain stale state; regenerate PKIX test fixtures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds library support to verify CoRIMs signed with a COSE Sign1 x5chain header: PKIX path validation (explicit and/or system trust anchors), optional CRL checks, then COSE signature verification with the PKIX-validated leaf key. See sections below for API, trust-pool semantics, and verification order.
New API
TrustedRoots— root CA pool, optional CRLs, optionalCurrentTime(zero =time.Now())TrustedRootPool(readFile, rootPaths, crlPaths, includeSystemRoots)— load trust material from files; duplicate DER roots acrossrootPathsare added once; PEM root files may bundle multiple certificates (x509.CertPool.AppendCertsFromPEM); DER root files usex509.ParseCertificate; DER CRL files usex509.ParseRevocationList; PEM CRL files may contain multiple blocks (encoding/pem.Decode— no stdlib CRL bundle API)SignedCorim.VerifyX509ChainTrust(trusted)— validate x5chain (leaf-only or leaf + intermediates) and verify the COSE signatureCall
SignedCorim.FromCOSEfirst. Key-based verification without PKIX trust remainsSignedCorim.Verify.Trust pool semantics:
Pool == nilloads system roots at verify timeTrustedRootPool(..., includeSystemRoots: true)merges the OS trust store withrootPaths;falseuses only explicit rootsPrefer
TrustedRootPoolfor embedders loading trust material from files.Verification order
digitalSignaturewhen KeyUsage is present; certs without a KeyUsage extension pass this step)ExtKeyUsageAnyagainsttrusted.Pool— no standard EKU for CoRIM/RIM signing; leafKeyUsage(when present) and COSE verify still constrain signing usetrusted.CRLsis non-empty (CRLs from issuers outside the verified chain are ignored; in-chain issuers with no matching CRL are skipped — fail-open; provide a CRL per issuer you intend to check; multiple CRLs per issuer: check all valid ones, fail if all matching CRLs are invalid)kid)When PKIX returns multiple valid chains, pick the path with the most certificate (DER) overlap with the presented x5chain so CRL and signature steps follow the path attested in the COSE header, not an arbitrary equivalent path (ties: first best-scoring chain).
Other changes
FromCOSE/extractX5Chain:FromCOSEclears x5chain fields before decode; on success,extractX5Chainassigns directly (no longer viaAddSigningCert); a failedFromCOSEleaves x5chain fields nil; directextractX5Chaincalls preserve existing fields on parse failure; clear stale certs when the header is absent or the chain shrinksscripts/gen-certs.shadds PKIX extensions;make test-certs regenerate FORCE=1re-issuestestdata/*.der(keys unchanged)Out of scope
kidvs x5chain leaf cross-check (COSE treatskidas a hint; useVerifyfor external-key verify)VerifyX509ChainTrustonly)Test plan
make presubmitpasses (coverage ≥84.4%, lint clean)x509chain_test.go:VerifyX509ChainTrust,TrustedRootPool(DER/PEM roots and CRLs), unit tests forvalidateSigningCertificate,checkRevocation,selectVerifiedChain; happy path, untrusted root, expiry, revocation, tampered payload, signing-key mismatchsignedcorim_test.go: 5 appended tests —FromCOSE_x5chain_idempotent,resetsIntermediatesOnShrink,clearsX5ChainWhenHeaderAbsent,resetsStaleIntermediateCerts,extractX5Chain_preservesStateOnError