rename to PublicKeyHashAlgo

Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
This commit is contained in:
Ramon Petgrave
2024-06-20 16:49:43 +00:00
parent ad1b81dc5d
commit f5362e5a4a
4 changed files with 8 additions and 8 deletions

View File

@@ -202,7 +202,7 @@ func verifyVSACmd() *cobra.Command {
PrintAttestation: &o.PrintAttestation,
PublicKeyPath: &o.PublicKeyPath,
PublicKeyID: &o.PublicKeyID,
SignatureHashAlgo: &o.SignatureHashAlgo,
PublicKeyHashAlgo: &o.SignatureHashAlgo,
}
if _, err := v.Exec(cmd.Context()); err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", FAILURE, err)

View File

@@ -38,7 +38,7 @@ type VerifyVSACommand struct {
PrintAttestation *bool
PublicKeyPath *string
PublicKeyID *string
SignatureHashAlgo *string
PublicKeyHashAlgo *string
}
var hashAlgos = map[string]crypto.Hash{
@@ -72,16 +72,16 @@ func (c *VerifyVSACommand) Exec(ctx context.Context) (*utils.TrustedAttesterID,
printFailed(err)
return nil, err
}
hashHalgo, ok := hashAlgos[*c.SignatureHashAlgo]
hashHalgo, ok := hashAlgos[*c.PublicKeyHashAlgo]
if !ok {
err := fmt.Errorf("%w: %s", serrors.ErrorInvalidHashAlgo, *c.SignatureHashAlgo)
err := fmt.Errorf("%w: %s", serrors.ErrorInvalidHashAlgo, *c.PublicKeyHashAlgo)
printFailed(err)
return nil, err
}
VerificationOpts := &options.VerificationOpts{
PublicKey: pubKey,
PublicKeyID: *c.PublicKeyID,
SignatureHashAlgo: hashHalgo,
PublicKeyHashAlgo: hashHalgo,
}
attestations, err := os.ReadFile(*c.AttestationsPath)
if err != nil {

View File

@@ -62,6 +62,6 @@ type VerificationOpts struct {
// PublicKeyID is the ID of the public key
PublicKeyID string
// SignatureHashAlgo is the hash algorithm used to hash the signature
SignatureHashAlgo crypto.Hash
// PublicKeyHashAlgo is the hash algorithm used to hash the signature
PublicKeyHashAlgo crypto.Hash
}

View File

@@ -72,7 +72,7 @@ func VerifyVSA(ctx context.Context,
// verifyEnvelopeSignature verifies the signature of the envelope.
func verifyEnvelopeSignature(ctx context.Context, sigstoreEnvelope *sigstoreBundle.Envelope, verificationOpts *options.VerificationOpts) error {
signatureVerifier, err := sigstoreSignature.LoadVerifier(verificationOpts.PublicKey, verificationOpts.SignatureHashAlgo)
signatureVerifier, err := sigstoreSignature.LoadVerifier(verificationOpts.PublicKey, verificationOpts.PublicKeyHashAlgo)
if err != nil {
return fmt.Errorf("%w: loading sigstore DSSE envolope verifier %w", serrors.ErrorInvalidPublicKey, err)
}