Skip to content

Commit

Permalink
correct vocabulary
Browse files Browse the repository at this point in the history
  • Loading branch information
JackDoanRivian committed Oct 3, 2024
1 parent 5194e59 commit cf0db22
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cert/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type beingSignedCertificate interface {
setSignature([]byte) error
}

type SignerPredicate func(certBytes []byte) ([]byte, error)
type SignerLambda func(certBytes []byte) ([]byte, error)

// Sign will create a sealed certificate using details provided by the TBSCertificate as long as those
// details do not violate constraints of the signing certificate.
Expand All @@ -55,7 +55,7 @@ func (t *TBSCertificate) Sign(signWith Certificate, curve Curve, key []byte) (Ce
sig := ed25519.Sign(signer, certBytes)
return sig, nil
}
return t.SignWithPredicate(signWith, curve, sp)
return t.SignWith(signWith, curve, sp)
case Curve_P256:
signer := &ecdsa.PrivateKey{
PublicKey: ecdsa.PublicKey{
Expand All @@ -72,7 +72,7 @@ func (t *TBSCertificate) Sign(signWith Certificate, curve Curve, key []byte) (Ce
hashed := sha256.Sum256(certBytes)
return ecdsa.SignASN1(rand.Reader, signer, hashed[:])
}
return t.SignWithPredicate(signWith, curve, sp)
return t.SignWith(signWith, curve, sp)
default:
return nil, fmt.Errorf("invalid curve: %s", t.Curve)
}
Expand All @@ -87,13 +87,13 @@ func (t *TBSCertificate) SignPkcs11(signer Certificate, curve Curve, client *pkc
return nil, fmt.Errorf("only P256 is supported by PKCS#11")
case Curve_P256:
//todo: verify that pkcs11 hashes for you
return t.SignWithPredicate(signer, curve, client.SignASN1)
return t.SignWith(signer, curve, client.SignASN1)
default:
return nil, fmt.Errorf("invalid curve: %s", t.Curve)
}
}

func (t *TBSCertificate) SignWithPredicate(signer Certificate, curve Curve, sp SignerPredicate) (Certificate, error) {
func (t *TBSCertificate) SignWith(signer Certificate, curve Curve, sp SignerLambda) (Certificate, error) {
if curve != t.Curve {
return nil, fmt.Errorf("curve in cert and private key supplied don't match")
}
Expand Down

0 comments on commit cf0db22

Please sign in to comment.