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:= decodeattestationas a JSON-encoded [Envelope]; reject if decoding failsattesterNames:= empty set of names- For each
signatureinenvelope.signatures:- For each (
name,publicKey) inrecognizedAttesters: - Optional: skip if
signature.keyiddoes not matchpublicKey- If
signature.sigmatchespublicKey:- Add
nametoattesterNames
- Add
- If
- For each (
- Reject if
attesterNamesis empty
- Intermediate state:
envelope.payloadType,envelope.payload,attesterNames - Statement layer:
- Reject if (
envelope.payloadType!=application/vnd.in-toto+jsonORenvelope.payloadTypedoes not matchapplication/vnd.in-toto.<predicate>+json) statement:= decodeenvelope.payloadas a JSON-encoded [Statement]; reject if decoding fails- Reject if
statement.type!=https://in-toto.io/Statement/v1 matchedSubjects:= the subset of entriessinstatement.subjectwhere:- there exists at least one
(alg, value)ins.digestwhere:algis inacceptableDigestAlgorithmsANDhash(alg, artifactToVerify)==hexDecode(value)
- there exists at least one
- Reject if
matchedSubjectsis empty
- Reject if (
Output (to be fed into policy engine):
statement.predicateTypestatement.predicatematchedSubjectsattesterNames