@@ -138,7 +138,12 @@ func SignCmd(ro *options.RootOptions, ko options.KeyOpts, signOpts options.SignO
138138 ctx , cancel := context .WithTimeout (context .Background (), ro .Timeout )
139139 defer cancel ()
140140
141- sv , err := SignerFromKeyOpts (ctx , signOpts .Cert , signOpts .CertChain , ko )
141+ svOptions := []signature.LoadOption {
142+ signatureoptions .WithHash (crypto .SHA256 ),
143+ signatureoptions .WithED25519ph (),
144+ }
145+
146+ sv , err := signerFromKeyOptsWithSVOpts (ctx , signOpts .Cert , signOpts .CertChain , ko , svOptions ... )
142147 if err != nil {
143148 return fmt .Errorf ("getting signer: %w" , err )
144149 }
@@ -261,7 +266,12 @@ func signDigest(ctx context.Context, digest name.Digest, payload []byte, ko opti
261266 if err != nil {
262267 return err
263268 }
264- s = irekor .NewSigner (s , rClient )
269+
270+ hashAlgorithm , err := getHashAlgorithmFromSignerVerifier (sv )
271+ if err != nil {
272+ return err
273+ }
274+ s = irekor .NewSigner (s , rClient , hashAlgorithm )
265275 }
266276
267277 ociSig , _ , err := s .Sign (ctx , bytes .NewReader (payload ))
@@ -391,8 +401,8 @@ func signerFromSecurityKey(ctx context.Context, keySlot string) (*SignerVerifier
391401 }, nil
392402}
393403
394- func signerFromKeyRef (ctx context.Context , certPath , certChainPath , keyRef string , passFunc cosign.PassFunc ) (* SignerVerifier , error ) {
395- k , err := sigs .SignerVerifierFromKeyRef (ctx , keyRef , passFunc )
404+ func signerFromKeyRef (ctx context.Context , certPath , certChainPath , keyRef string , passFunc cosign.PassFunc , opts ... signature. LoadOption ) (* SignerVerifier , error ) {
405+ k , err := sigs .SignerVerifierFromKeyRefWithOpts (ctx , keyRef , passFunc , opts ... )
396406 if err != nil {
397407 return nil , fmt .Errorf ("reading key: %w" , err )
398408 }
@@ -521,12 +531,12 @@ func signerFromKeyRef(ctx context.Context, certPath, certChainPath, keyRef strin
521531 return certSigner , nil
522532}
523533
524- func signerFromNewKey () (* SignerVerifier , error ) {
534+ func signerFromNewKey (svOpts ... signature. LoadOption ) (* SignerVerifier , error ) {
525535 privKey , err := cosign .GeneratePrivateKey ()
526536 if err != nil {
527537 return nil , fmt .Errorf ("generating cert: %w" , err )
528538 }
529- sv , err := signature .LoadECDSASignerVerifier (privKey , crypto . SHA256 )
539+ sv , err := signature .LoadSignerVerifierWithOpts (privKey , svOpts ... )
530540 if err != nil {
531541 return nil , err
532542 }
@@ -559,19 +569,19 @@ func keylessSigner(ctx context.Context, ko options.KeyOpts, sv *SignerVerifier)
559569 }, nil
560570}
561571
562- func SignerFromKeyOpts (ctx context.Context , certPath string , certChainPath string , ko options.KeyOpts ) (* SignerVerifier , error ) {
572+ func signerFromKeyOptsWithSVOpts (ctx context.Context , certPath string , certChainPath string , ko options.KeyOpts , svOpts ... signature. LoadOption ) (* SignerVerifier , error ) {
563573 var sv * SignerVerifier
564574 var err error
565575 genKey := false
566576 switch {
567577 case ko .Sk :
568578 sv , err = signerFromSecurityKey (ctx , ko .Slot )
569579 case ko .KeyRef != "" :
570- sv , err = signerFromKeyRef (ctx , certPath , certChainPath , ko .KeyRef , ko .PassFunc )
580+ sv , err = signerFromKeyRef (ctx , certPath , certChainPath , ko .KeyRef , ko .PassFunc , svOpts ... )
571581 default :
572582 genKey = true
573583 ui .Infof (ctx , "Generating ephemeral keys..." )
574- sv , err = signerFromNewKey ()
584+ sv , err = signerFromNewKey (svOpts ... )
575585 }
576586 if err != nil {
577587 return nil , err
@@ -584,6 +594,10 @@ func SignerFromKeyOpts(ctx context.Context, certPath string, certChainPath strin
584594 return sv , nil
585595}
586596
597+ func SignerFromKeyOpts (ctx context.Context , certPath string , certChainPath string , ko options.KeyOpts ) (* SignerVerifier , error ) {
598+ return signerFromKeyOptsWithSVOpts (ctx , certPath , certChainPath , ko )
599+ }
600+
587601type SignerVerifier struct {
588602 Cert []byte
589603 Chain []byte
0 commit comments