Skip to content

Commit 8f8f897

Browse files
authored
Merge pull request opencontainers#97 from thaJeztah/remove_SHA384_default
do not register sha384 by default
2 parents 8ab41e4 + 528a663 commit 8f8f897

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

algorithm.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ func init() {
3434
// by implementations.
3535
RegisterAlgorithm(SHA256, crypto.SHA256)
3636
RegisterAlgorithm(SHA512, crypto.SHA512)
37-
// SHA384 is registered by default but is not part of the OCI image
38-
// specification, and its use should be discouraged for reasons other
39-
// than backward-compatibility.
40-
RegisterAlgorithm(SHA384, crypto.SHA384)
4137
}
4238

4339
// Algorithm identifies and implementation of a digester by an identifier.
@@ -83,9 +79,16 @@ const (
8379

8480
// SHA384 is the SHA-384 ([RFC 6234]) digest algorithm with hex encoding
8581
// (lower case only). Use of the SHA384 digest algorithm is not recommended,
86-
// and the [Canonical] algorithm is preferred.
82+
// for reasons other than backward-compatibility, and the [Canonical]
83+
// algorithm is preferred.
84+
//
85+
// SHA384 is not part of the [OCI image specification], and not registered
86+
// by default. Implementers must register it if needed;
87+
//
88+
// RegisterAlgorithm(SHA384, crypto.SHA384)
8789
//
8890
// [RFC 6234]: https://datatracker.ietf.org/doc/html/rfc6234
91+
// [OCI image specification]: https://github.com/opencontainers/image-spec/blob/v1.0.2/descriptor.md#registered-algorithms
8992
SHA384 Algorithm = "sha384" // sha384 with hex encoding (lower case only)
9093

9194
// BLAKE3 is the [BLAKE3 algorithm] with the default 256-bit output size.

digest_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package digest_test
1616

1717
import (
18+
"crypto"
1819
"crypto/sha256"
1920
"testing"
2021

@@ -23,6 +24,9 @@ import (
2324
)
2425

2526
func TestParseDigest(t *testing.T) {
27+
// SHA-384 is not registered by default, but used in this test.
28+
digest.RegisterAlgorithm(digest.SHA384, crypto.SHA384)
29+
2630
tests := []testdigest.TestCase{
2731
{
2832
Input: "sha256:e58fcf7418d4390dec8e8fb69d88c06ec07039d651fedd3aa72af9972e7d046b",

digestset/set_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package digestset
1717

1818
import (
19+
"crypto"
1920
"crypto/sha256"
2021
"encoding/binary"
2122
"math/rand"
@@ -135,6 +136,8 @@ func TestAddDuplication(t *testing.T) {
135136
t.Fatal("Duplicate digest insert should not increase entries size")
136137
}
137138

139+
// SHA-384 is not registered by default, but used in this test.
140+
digest.RegisterAlgorithm(digest.SHA384, crypto.SHA384)
138141
if err := dset.Add(digest.Digest("sha384:123451111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")); err != nil {
139142
t.Fatal(err)
140143
}

0 commit comments

Comments
 (0)