mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Change EcdsaVerify to specifically P-384 and compute the SHA384 digest.
PiperOrigin-RevId: 398336708
This commit is contained in:
committed by
gVisor bot
parent
5768a147b1
commit
4f67756752
@@ -19,14 +19,21 @@ package crypto
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"crypto/elliptic"
|
||||
"crypto/sha512"
|
||||
"fmt"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
// EcdsaVerify verifies the signature in r, s of hash using ECDSA and the
|
||||
// public key, pub. Its return value records whether the signature is valid.
|
||||
func EcdsaVerify(pub *ecdsa.PublicKey, hash []byte, r, s *big.Int) (bool, error) {
|
||||
return ecdsa.Verify(pub, hash, r, s), nil
|
||||
// EcdsaP384Sha384Verify verifies the signature in r, s of hash using ECDSA
|
||||
// P384 + SHA 384 and the public key, pub. Its return value records whether
|
||||
// the signature is valid.
|
||||
func EcdsaP384Sha384Verify(pub *ecdsa.PublicKey, data []byte, r, s *big.Int) (bool, error) {
|
||||
if pub.Curve != elliptic.P384() {
|
||||
return false, fmt.Errorf("unsupported key curve: want P-384, got %v", pub.Curve)
|
||||
}
|
||||
digest := sha512.Sum384(data)
|
||||
return ecdsa.Verify(pub, digest[:], r, s), nil
|
||||
}
|
||||
|
||||
// SumSha384 returns the SHA384 checksum of the data.
|
||||
|
||||
Reference in New Issue
Block a user