// 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
import (
"crypto"
"errors"
+ "fmt"
"io"
"math/big"
)
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++ {
}
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
}