@@ -41,6 +41,22 @@ type untrustedSignature struct {
4141 UntrustedTimestamp * int64
4242}
4343
44+ // UntrustedSignatureInformation is information available in an untrusted signature.
45+ // This may be useful when debugging signature verification failures,
46+ // or when managing a set of signatures on a single image.
47+ //
48+ // WARNING: Do not use the contents of this for ANY security decisions,
49+ // and be VERY CAREFUL about showing this information to humans in any way which suggest that these values “are probably” reliable.
50+ // There is NO REASON to expect the values to be correct, or not intentionally misleading
51+ // (including things like “✅ Verified by $authority”)
52+ type UntrustedSignatureInformation struct {
53+ UntrustedDockerManifestDigest digest.Digest
54+ UntrustedDockerReference string // FIXME: more precise type?
55+ UntrustedCreatorID * string
56+ UntrustedTimestamp * time.Time
57+ UntrustedShortKeyIdentifier string
58+ }
59+
4460// newUntrustedSignature returns an untrustedSignature object with
4561// the specified primary contents and appropriate metadata.
4662func newUntrustedSignature (dockerManifestDigest digest.Digest , dockerReference string ) untrustedSignature {
@@ -229,3 +245,42 @@ func verifyAndExtractSignature(mech SigningMechanism, unverifiedSignature []byte
229245 DockerReference : unmatchedSignature .UntrustedDockerReference ,
230246 }, nil
231247}
248+
249+ // GetUntrustedSignatureInformationWithoutVerifying extracts information available in an untrusted signature,
250+ // WITHOUT doing any cryptographic verification.
251+ // This may be useful when debugging signature verification failures,
252+ // or when managing a set of signatures on a single image.
253+ //
254+ // WARNING: Do not use the contents of this for ANY security decisions,
255+ // and be VERY CAREFUL about showing this information to humans in any way which suggest that these values “are probably” reliable.
256+ // There is NO REASON to expect the values to be correct, or not intentionally misleading
257+ // (including things like “✅ Verified by $authority”)
258+ func GetUntrustedSignatureInformationWithoutVerifying (untrustedSignatureBytes []byte ) (* UntrustedSignatureInformation , error ) {
259+ // NOTE: This should eventualy do format autodetection.
260+ mech , err := NewGPGSigningMechanism ()
261+ if err != nil {
262+ return nil , err
263+ }
264+
265+ untrustedContents , shortKeyIdentifier , err := mech .UntrustedSignatureContents (untrustedSignatureBytes )
266+ if err != nil {
267+ return nil , err
268+ }
269+ var untrustedDecodedContents untrustedSignature
270+ if err := json .Unmarshal (untrustedContents , & untrustedDecodedContents ); err != nil {
271+ return nil , InvalidSignatureError {msg : err .Error ()}
272+ }
273+
274+ var timestamp * time.Time // = nil
275+ if untrustedDecodedContents .UntrustedTimestamp != nil {
276+ ts := time .Unix (* untrustedDecodedContents .UntrustedTimestamp , 0 )
277+ timestamp = & ts
278+ }
279+ return & UntrustedSignatureInformation {
280+ UntrustedDockerManifestDigest : untrustedDecodedContents .UntrustedDockerManifestDigest ,
281+ UntrustedDockerReference : untrustedDecodedContents .UntrustedDockerReference ,
282+ UntrustedCreatorID : untrustedDecodedContents .UntrustedCreatorID ,
283+ UntrustedTimestamp : timestamp ,
284+ UntrustedShortKeyIdentifier : shortKeyIdentifier ,
285+ }, nil
286+ }
0 commit comments