Skip to content

Commit

Permalink
Add SHA384
Browse files Browse the repository at this point in the history
  • Loading branch information
ret2libc committed Jan 18, 2024
1 parent ae1382e commit 8da076a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pkg/cosign/tlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ func rekorEntryHashAlgorithm(checksum crypto.SignerOpts) string {
switch checksum.HashFunc() {
case crypto.SHA256:
return models.HashedrekordV001SchemaDataHashAlgorithmSha256
case crypto.SHA384:
return models.HashedrekordV001SchemaDataHashAlgorithmSha384
case crypto.SHA512:
return models.HashedrekordV001SchemaDataHashAlgorithmSha512
default:
Expand Down
7 changes: 5 additions & 2 deletions pkg/cosign/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,9 @@ func VerifyBundle(sig oci.Signature, co *CheckOpts) (bool, error) {
case crypto.SHA256:
h := sha256.Sum256(payload)
payloadHash = hex.EncodeToString(h[:])
case crypto.SHA384:
h := sha512.Sum384(payload)
payloadHash = hex.EncodeToString(h[:])
case crypto.SHA512:
h := sha512.Sum512(payload)
payloadHash = hex.EncodeToString(h[:])
Expand Down Expand Up @@ -1267,8 +1270,8 @@ func extractEntryImpl(bundleBody string) (rekor_types.EntryImpl, error) {

func HashAlgorithmToCryptoHash(hashAlgorithm string) crypto.Hash {
switch hashAlgorithm {
case "sha256":
return crypto.SHA256
case "sha384":
return crypto.SHA384
case "sha512":
return crypto.SHA512
default:
Expand Down

0 comments on commit 8da076a

Please sign in to comment.