]> Cypherpunks.ru repositories - gogost.git/blobdiff - gost3410/vko2012.go
Panic on all possible hash write errors
[gogost.git] / gost3410 / vko2012.go
index 7a30b4ed367d07a34cec98cffbd5a04f5219e33e..78b9af59e036764e62bd82dd1d5e060bd6844f79 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
@@ -30,7 +30,9 @@ func (prv *PrivateKey) KEK2012256(pub *PublicKey, ukm *big.Int) ([]byte, error)
                return nil, err
        }
        h := gost34112012256.New()
-       h.Write(key)
+       if _, err = h.Write(key); err != nil {
+               return nil, err
+       }
        return h.Sum(key[:0]), nil
 }
 
@@ -42,6 +44,8 @@ func (prv *PrivateKey) KEK2012512(pub *PublicKey, ukm *big.Int) ([]byte, error)
                return nil, err
        }
        h := gost34112012512.New()
-       h.Write(key)
+       if _, err = h.Write(key); err != nil {
+               return nil, err
+       }
        return h.Sum(key[:0]), nil
 }