@@ -28,6 +28,7 @@ import (
28
28
"fmt"
29
29
"os"
30
30
"path/filepath"
31
+ "sort"
31
32
32
33
"github.com/secure-systems-lab/go-securesystemslib/encrypted"
33
34
"github.com/sigstore/cosign/v2/pkg/oci/static"
@@ -50,6 +51,16 @@ const (
50
51
RFC3161TimestampKey = static .RFC3161TimestampAnnotationKey
51
52
)
52
53
54
+ var SupportedKeyDetails = []v1.PublicKeyDetails {
55
+ v1 .PublicKeyDetails_PKIX_ECDSA_P256_SHA_256 ,
56
+ v1 .PublicKeyDetails_PKIX_ECDSA_P384_SHA_384 ,
57
+ v1 .PublicKeyDetails_PKIX_ECDSA_P521_SHA_512 ,
58
+ v1 .PublicKeyDetails_PKIX_RSA_PKCS1V15_2048_SHA256 ,
59
+ v1 .PublicKeyDetails_PKIX_RSA_PKCS1V15_3072_SHA256 ,
60
+ v1 .PublicKeyDetails_PKIX_RSA_PKCS1V15_4096_SHA256 ,
61
+ v1 .PublicKeyDetails_PKIX_ED25519_PH ,
62
+ }
63
+
53
64
// PassFunc is the function to be called to retrieve the signer password. If
54
65
// nil, then it assumes that no password is provided.
55
66
type PassFunc func (bool ) ([]byte , error )
@@ -292,3 +303,17 @@ func LoadPrivateKey(key []byte, pass []byte, defaultLoadOptions *[]signature.Loa
292
303
}
293
304
return signature .LoadDefaultSignerVerifier (pk , * defaultLoadOptions ... )
294
305
}
306
+
307
+ // GetSupportedAlgorithms returns a list of supported algorithms sorted alphabetically.
308
+ func GetSupportedAlgorithms () []string {
309
+ algorithms := make ([]string , 0 , len (SupportedKeyDetails ))
310
+ for _ , algorithm := range SupportedKeyDetails {
311
+ signatureFlag , err := signature .FormatSignatureAlgorithmFlag (algorithm )
312
+ if err != nil {
313
+ continue
314
+ }
315
+ algorithms = append (algorithms , signatureFlag )
316
+ }
317
+ sort .Strings (algorithms )
318
+ return algorithms
319
+ }
0 commit comments