X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcypherpunks.ru%2Fgogost%2Fgost3410%2Fprivate.go;h=ced3b89527e86a6568fe85d1497f1446e5eb6869;hb=3f0105abe94dc598a5aa321abb6437f5b492d675;hp=d4c5c1e9e7d8015bf67c38c39d50373063ab6596;hpb=92e0d038de014c8b3eebc0beba3ef9fe906dd8e3;p=gogost.git diff --git a/src/cypherpunks.ru/gogost/gost3410/private.go b/src/cypherpunks.ru/gogost/gost3410/private.go index d4c5c1e..ced3b89 100644 --- a/src/cypherpunks.ru/gogost/gost3410/private.go +++ b/src/cypherpunks.ru/gogost/gost3410/private.go @@ -1,5 +1,5 @@ // GoGOST -- Pure Go GOST cryptographic functions library -// Copyright (C) 2015-2016 Sergey Matveev +// Copyright (C) 2015-2019 Sergey Matveev // // 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 @@ -30,11 +30,12 @@ type PrivateKey struct { func NewPrivateKey(curve *Curve, mode Mode, raw []byte) (*PrivateKey, error) { if len(raw) != int(mode) { - errors.New("Invalid private key length") + return nil, errors.New("Invalid private key length") } key := make([]byte, int(mode)) - copy(key, raw) - reverse(key) + for i := 0; i < len(key); i++ { + key[i] = raw[len(raw)-i-1] + } k := bytes2big(key) if k.Cmp(zero) == 0 { return nil, errors.New("Zero private key")