]> Cypherpunks.ru repositories - gogost.git/blobdiff - gost3410/private.go
Raise copyright years
[gogost.git] / gost3410 / private.go
index 045c8185b94458e7ad2c9be153bd37eeb99f04ed..ae54424d7ef083c08fa9e2bdf5abc9cb17e59d38 100644 (file)
@@ -1,5 +1,5 @@
 // GoGOST -- Pure Go GOST cryptographic functions library
-// Copyright (C) 2015-2019 Sergey Matveev <stargrave@stargrave.org>
+// Copyright (C) 2015-2020 Sergey Matveev <stargrave@stargrave.org>
 //
 // This program is free software: you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -18,6 +18,7 @@ package gost3410
 import (
        "crypto"
        "errors"
+       "fmt"
        "io"
        "math/big"
 )
@@ -30,7 +31,7 @@ type PrivateKey struct {
 
 func NewPrivateKey(curve *Curve, mode Mode, raw []byte) (*PrivateKey, error) {
        if len(raw) != int(mode) {
-               return nil, errors.New("Invalid private key length")
+               return nil, fmt.Errorf("gogost/gost3410: len(key) != %d", mode)
        }
        key := make([]byte, int(mode))
        for i := 0; i < len(key); i++ {
@@ -38,7 +39,7 @@ func NewPrivateKey(curve *Curve, mode Mode, raw []byte) (*PrivateKey, error) {
        }
        k := bytes2big(key)
        if k.Cmp(zero) == 0 {
-               return nil, errors.New("Zero private key")
+               return nil, errors.New("gogost/gost3410: zero private key")
        }
        return &PrivateKey{curve, mode, k}, nil
 }