Remove redundant returning of error
- Fix tests - Fix examples - SignECDSA doesn't used error in return
This commit is contained in:
parent
c1b927f26d
commit
5440298f21
3 changed files with 7 additions and 13 deletions
2
ecdsa.go
2
ecdsa.go
|
@ -14,7 +14,7 @@ import (
|
|||
// Note that FIPS 186-3 section 4.6 specifies that the hash should be truncated
|
||||
// to the byte-length of the subgroup. This function does not perform that
|
||||
// truncation itself.
|
||||
func SignECDSA(priv *ecdsa.PrivateKey, hash []byte, alg func() hash.Hash) (r, s *big.Int, err error) {
|
||||
func SignECDSA(priv *ecdsa.PrivateKey, hash []byte, alg func() hash.Hash) (r, s *big.Int) {
|
||||
c := priv.PublicKey.Curve
|
||||
N := c.Params().N
|
||||
|
||||
|
|
|
@ -428,12 +428,7 @@ func testEcsaFixture(f *ecdsaFixture, t *testing.T) {
|
|||
digest = digest[0:g]
|
||||
}
|
||||
|
||||
r, s, err := rfc6979.SignECDSA(f.key.key, digest, f.alg)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
r, s := rfc6979.SignECDSA(f.key.key, digest, f.alg)
|
||||
expectedR := ecdsaLoadInt(f.r)
|
||||
expectedS := ecdsaLoadInt(f.s)
|
||||
|
||||
|
|
|
@ -27,11 +27,7 @@ func ExampleSignECDSA() {
|
|||
hash := alg.Sum(nil)
|
||||
|
||||
// Sign the message. You don't need a PRNG for this.
|
||||
r, s, err := SignECDSA(k, hash, sha512.New)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
r, s := SignECDSA(k, hash, sha512.New)
|
||||
|
||||
if !ecdsa.Verify(&k.PublicKey, hash, r, s) {
|
||||
fmt.Println("Invalid signature!")
|
||||
|
@ -45,7 +41,10 @@ func ExampleSignDSA() {
|
|||
// Here I'm generating some DSA params, but you should really pre-generate
|
||||
// these and re-use them, since this takes a long time and isn't necessary.
|
||||
k := new(dsa.PrivateKey)
|
||||
dsa.GenerateParameters(&k.Parameters, rand.Reader, dsa.L1024N160)
|
||||
if err := dsa.GenerateParameters(&k.Parameters, rand.Reader, dsa.L1024N160); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
// Generate a key pair.
|
||||
// You need a high-quality PRNG for this.
|
||||
|
|
Loading…
Reference in a new issue