The following pseudocode shows how to verify and extract metadata about a single artifact from a single attestation. The expectation is that consumers will feed the resulting metadata into a policy engine.
TODO: Explain how to process multiple artifacts and/or multiple attestations.
Inputs:
artifactToVerify
: blob of dataattestation
: JSON-encoded [Envelope]recognizedAttesters
: collection of (name
,publicKey
) pairsacceptableDigestAlgorithms
: collection of acceptable cryptographic hash algorithms (usually justsha256
)
Steps:
- Envelope layer:
envelope
:= decodeattestation
as a JSON-encoded [Envelope]; reject if decoding failsattesterNames
:= empty set of names- For each
signature
inenvelope.signatures
:- For each (
name
,publicKey
) inrecognizedAttesters
: - Optional: skip if
signature.keyid
does not matchpublicKey
- If
signature.sig
matchespublicKey
:- Add
name
toattesterNames
- Add
- If
- For each (
- Reject if
attesterNames
is empty
- Intermediate state:
envelope.payloadType
,envelope.payload
,attesterNames
- Statement layer:
- Reject if
envelope.payloadType
!=application/vnd.in-toto+json
statement
:= decodeenvelope.payload
as a JSON-encoded [Statement]; reject if decoding fails- Reject if
statement.type
!=https://in-toto.io/Statement/v1
matchedSubjects
:= the subset of entriess
instatement.subject
where:- there exists at least one
(alg, value)
ins.digest
where:alg
is inacceptableDigestAlgorithms
ANDhash(alg, artifactToVerify)
==hexDecode(value)
- there exists at least one
- Reject if
matchedSubjects
is empty
- Reject if
Output (to be fed into policy engine):
statement.predicateType
statement.predicate
matchedSubjects
attesterNames