X-Git-Url: http://www.git.cypherpunks.ru/?p=gogost.git;a=blobdiff_plain;f=gost3410%2Fpublic.go;h=de2d858c604d793d559c5b11fcdab47fdcc04761;hp=08e1414000bf6e3d42710b5485e002d74b6e46c7;hb=0da4d634ac5368d024489baf4bdd5d422b84dd84;hpb=ce6c45e481a59d843a3b9caab55608c738aac2f4 diff --git a/gost3410/public.go b/gost3410/public.go index 08e1414..de2d858 100644 --- a/gost3410/public.go +++ b/gost3410/public.go @@ -16,7 +16,7 @@ package gost3410 import ( - "errors" + "fmt" "math/big" ) @@ -30,7 +30,7 @@ type PublicKey struct { func NewPublicKey(curve *Curve, mode Mode, raw []byte) (*PublicKey, error) { key := make([]byte, 2*int(mode)) if len(raw) != len(key) { - return nil, errors.New("Invalid public key length") + return nil, fmt.Errorf("gogost/gost3410: len(key) != %d", len(key)) } for i := 0; i < len(key); i++ { key[i] = raw[len(raw)-i-1] @@ -54,11 +54,14 @@ func (pub *PublicKey) Raw() []byte { func (pub *PublicKey) VerifyDigest(digest, signature []byte) (bool, error) { if len(signature) != 2*int(pub.Mode) { - return false, errors.New("Invalid signature length") + return false, fmt.Errorf("gogost/gost3410: len(signature) != %d", 2*int(pub.Mode)) } s := bytes2big(signature[:pub.Mode]) r := bytes2big(signature[pub.Mode:]) - if r.Cmp(zero) <= 0 || r.Cmp(pub.C.Q) >= 0 || s.Cmp(zero) <= 0 || s.Cmp(pub.C.Q) >= 0 { + if r.Cmp(zero) <= 0 || + r.Cmp(pub.C.Q) >= 0 || + s.Cmp(zero) <= 0 || + s.Cmp(pub.C.Q) >= 0 { return false, nil } e := bytes2big(digest)