Skip to content

Commit 6e7d374

Browse files
ret2libcwoodruffw
authored andcommitted
Add SHA384
Signed-off-by: William Woodruff <william@trailofbits.com>
1 parent ae1382e commit 6e7d374

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pkg/cosign/tlog.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ func rekorEntryHashAlgorithm(checksum crypto.SignerOpts) string {
271271
switch checksum.HashFunc() {
272272
case crypto.SHA256:
273273
return models.HashedrekordV001SchemaDataHashAlgorithmSha256
274+
case crypto.SHA384:
275+
return models.HashedrekordV001SchemaDataHashAlgorithmSha384
274276
case crypto.SHA512:
275277
return models.HashedrekordV001SchemaDataHashAlgorithmSha512
276278
default:

pkg/cosign/verify.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,9 @@ func VerifyBundle(sig oci.Signature, co *CheckOpts) (bool, error) {
11371137
case crypto.SHA256:
11381138
h := sha256.Sum256(payload)
11391139
payloadHash = hex.EncodeToString(h[:])
1140+
case crypto.SHA384:
1141+
h := sha512.Sum384(payload)
1142+
payloadHash = hex.EncodeToString(h[:])
11401143
case crypto.SHA512:
11411144
h := sha512.Sum512(payload)
11421145
payloadHash = hex.EncodeToString(h[:])
@@ -1267,8 +1270,8 @@ func extractEntryImpl(bundleBody string) (rekor_types.EntryImpl, error) {
12671270

12681271
func HashAlgorithmToCryptoHash(hashAlgorithm string) crypto.Hash {
12691272
switch hashAlgorithm {
1270-
case "sha256":
1271-
return crypto.SHA256
1273+
case "sha384":
1274+
return crypto.SHA384
12721275
case "sha512":
12731276
return crypto.SHA512
12741277
default:

0 commit comments

Comments
 (0)