Skip to content

Commit

Permalink
Put more info into error if signature len is not 64
Browse files Browse the repository at this point in the history
  • Loading branch information
artemskriabin committed Jan 3, 2025
1 parent 364697d commit 882aebe
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/types/signature_algorithm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/ecdsa"
"crypto/rsa"
"encoding/asn1"
"fmt"
"hash"
"math/big"

Expand Down Expand Up @@ -62,7 +63,7 @@ func verifyECDSA(data, sig []byte, publicKey *ecdsa.PublicKey) error {

// Handle raw (r || s) signature format
if len(sig) != 64 {
return errors.New("invalid ECDSA signature length")
return fmt.Errorf("ECDSA signature length is not 64, but %d, with key %s", len(sig), publicKey.Curve.Params().Name)
}

r, s := new(big.Int).SetBytes(sig[:32]), new(big.Int).SetBytes(sig[32:])
Expand Down

0 comments on commit 882aebe

Please sign in to comment.