This document describes the Go implementation of the "Evidence Encoding for Hardware Security Modules" from
draft-ietf-rats-pkix-key-attestation.
The implementation provides the following:
- ASN.1 structures and OIDs according to
Pkix-Key-Attest-2025.asn - Parser/decoder for DER/PEM/Base64-encoded Evidence
- Validation of the most important structural rules from the specification
- Signature verification for RSA (PKCS#1 v1.5), RSA-PSS, ECDSA, and Ed25519
- CLI for decode/validate/verify plus a sample generator
Source code:
- CLI:
go-src/cmd/pkix-evidence/main.go - Evidence logic:
go-src/pkg/evidence/*.go
The core structures are defined in go-src/pkg/evidence/types.go and map directly to the ASN.1 structures:
PkixEvidenceRaw(envelope withtbs,signatures,intermediateCertificates)TbsPkixEvidenceReportedEntityReportedClaimSignatureBlock/SignerIdentifier
OIDs are defined in go-src/pkg/evidence/oids.go. In addition, metadata (ClaimSpecs)
is provided for known claim types so that decode output can use readable names.
ReadEvidencedetects DER/PEM/Base64 automatically, or via explicit-formatParsedecodes Evidence and returns both the structured form and the DER for the TBS blockDecodeClaimValueinterprets context-specific claim values (bytes,utf8String,bool,time,int,oid)EvidenceToJSONserializes the data into readable JSON
Validate checks, among other things:
version == 1- only one transaction entity and only one platform entity
- repeated claims according to the specification
- key entities must contain at least one
identifier - duplicate key identifiers across multiple key entities are detected
VerifyEvidence verifies signatures against:
- signer certificate (
SignerIdentifier.certificate) or SPKI - optionally: certificate chain validation against trust anchors (
-verify-chain -ca) - optionally: binding to
transaction.ak-spki
Supported algorithms:
- RSA (PKCS#1 v1.5): SHA-1/256/384/512
- RSA-PSS
- ECDSA: SHA-256/384/512
- Ed25519
Build:
go build ./go-src/cmd/pkix-evidence./pkix-evidence decode -in <file|-> [-format auto|der|pem|base64]Outputs JSON with entities and claims.
./pkix-evidence validate -in <file|-> [-format auto|der|pem|base64]Outputs ok or a list of validation errors.
./pkix-evidence verify -in <file|-> [-format auto|der|pem|base64] [-ca <pem>] [-verify-chain] [-require-all]-verify-chainverifies signer certificates against trust anchors from-ca-require-allrequires all signatures to be valid
A small unsigned sample in the current format:
./pkix-evidence generate -out <file|-> [-format der|pem|base64]A signed sample (ECDSA P-256, self-signed certificate) including transaction.ak-spki:
./pkix-evidence generate -out <file|-> -format der -signedWith external key/certificate input (PEM):
./pkix-evidence generate -out <file|-> -format der -signed -key signer.key -cert signer.crtOptionally, transaction.ak-spki can be omitted:
./pkix-evidence generate -out <file|-> -format der -signed -with-ak-spki=falseA simple test run was performed to check the CLI against a generated sample:
./pkix-evidence generate -out /tmp/sample-evidence.der -format der
./pkix-evidence decode -in /tmp/sample-evidence.der
./pkix-evidence validate -in /tmp/sample-evidence.derResult:
decodereturns valid JSONvalidatereturnsok
Note: the sample is unsigned (Signatures is empty). For signature tests, Evidence
must be generated or supplied with signatures present.
For signature tests, Evidence with at least one SignatureBlock is required, as well as
a trust anchor (CA) that validates the signer certificate. The CLI supports two levels:
- Signature verification against the certificate or SPKI contained in the
SignatureBlock - Certificate chain verification against trust anchors (
-verify-chain -ca)
Example flow (conceptual):
# Evidence (DER/PEM/Base64) is available and contains at least one signature
./pkix-evidence verify -in evidence.der
# Optional: also verify the certificate chain against trust anchors
./pkix-evidence verify -in evidence.der -verify-chain -ca roots.pem
# Optional: require all signatures to be valid
./pkix-evidence verify -in evidence.der -require-allExpected behavior:
- For a valid signature:
signature[i]: ok - For an invalid signature:
signature[i]: <error> - If signatures are missing: warning
evidence is unsigned - With
ak-spkibinding: warning if no signer SPKI matchestransaction.ak-spki
The CLI can generate a signed sample and verify it directly:
./pkix-evidence generate -out /tmp/sample-evidence-signed.der -format der -signed
./pkix-evidence verify -in /tmp/sample-evidence-signed.derExpected result:
signature[0]: ok