]> Cypherpunks.ru repositories - gogost.git/blobdiff - src/cypherpunks.ru/gogost/gost3410/public.go
Excess copy() usage
[gogost.git] / src / cypherpunks.ru / gogost / gost3410 / public.go
index 6af21af83b9156384a0bc25f88bbf8eaae185d4c..9589ef8d215261e76a31a6c210f5bd019c750bfa 100644 (file)
@@ -29,12 +29,13 @@ type PublicKey struct {
 }
 
 func NewPublicKey(curve *Curve, mode Mode, raw []byte) (*PublicKey, error) {
-       if len(raw) != 2*int(mode) {
+       key := make([]byte, 2*int(mode))
+       if len(raw) != len(key) {
                return nil, errors.New("Invalid public key length")
        }
-       key := make([]byte, 2*int(mode))
-       copy(key, raw)
-       reverse(key)
+       for i := 0; i < len(key); i++ {
+               key[i] = raw[len(raw)-i-1]
+       }
        return &PublicKey{
                curve,
                mode,