]> Cypherpunks.ru repositories - gogost.git/commitdiff
Panic on all possible hash write errors v4.2.3
authorSergey Matveev <stargrave@stargrave.org>
Wed, 22 Jan 2020 13:37:58 +0000 (16:37 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 22 Jan 2020 13:39:31 +0000 (16:39 +0300)
VERSION
cmd/streebog256/main.go
cmd/streebog512/main.go
gost3410/vko2001.go
gost3410/vko2012.go
gost34112012256/kdf.go
install.texi
news.texi
prfplus/gost.go

diff --git a/VERSION b/VERSION
index af8c8ec7c1341172f05d465d5f47eae59a604939..f2c6cb6af20f460be7d4b1f12a4cbe216a103535 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.2.2
+4.2.3
index efaae810553c8e8265f2a600f1e34d39eda65965..9db7c477afbf138a497cd25cb48efe14801374bd 100644 (file)
@@ -38,6 +38,8 @@ func main() {
                return
        }
        h := gost34112012256.New()
-       io.Copy(h, os.Stdin)
+       if _, err := io.Copy(h, os.Stdin); err != nil {
+               panic(err)
+       }
        fmt.Println(hex.EncodeToString(h.Sum(nil)))
 }
index d70506447b021b1cbf4920c4f6886fc5cec89557..052592f2b6efe6a700e88a40971a95e800524dc5 100644 (file)
@@ -38,6 +38,8 @@ func main() {
                return
        }
        h := gost34112012512.New()
-       io.Copy(h, os.Stdin)
+       if _, err := io.Copy(h, os.Stdin); err != nil {
+               panic(err)
+       }
        fmt.Println(hex.EncodeToString(h.Sum(nil)))
 }
index 02f976f9b286e0f27753baef60c7ca2dfe9a8f70..c9aeada21a90a36f782a49497aaa8c4af347a813 100644 (file)
@@ -34,6 +34,8 @@ func (prv *PrivateKey) KEK2001(pub *PublicKey, ukm *big.Int) ([]byte, error) {
                return nil, err
        }
        h := gost341194.New(&gost28147.SboxIdGostR341194CryptoProParamSet)
-       h.Write(key)
+       if _, err = h.Write(key); err != nil {
+               return nil, err
+       }
        return h.Sum(key[:0]), nil
 }
index 01f3e85770df3c7c14769845baea846b850cba82..78b9af59e036764e62bd82dd1d5e060bd6844f79 100644 (file)
@@ -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
 }
index 43c08aea7729147ffdcd6f7ba6131be6d4eaf9df..d818fb287102b403cb2cf8e7c05fdb9a40368b68 100644 (file)
@@ -29,12 +29,24 @@ func NewKDF(key []byte) *KDF {
 }
 
 func (kdf *KDF) Derive(dst, label, seed []byte) (r []byte) {
-       kdf.h.Write([]byte{0x01})
-       kdf.h.Write(label)
-       kdf.h.Write([]byte{0x00})
-       kdf.h.Write(seed)
-       kdf.h.Write([]byte{0x01})
-       kdf.h.Write([]byte{0x00})
+       if _, err := kdf.h.Write([]byte{0x01}); err != nil {
+               panic(err)
+       }
+       if _, err := kdf.h.Write(label); err != nil {
+               panic(err)
+       }
+       if _, err := kdf.h.Write([]byte{0x00}); err != nil {
+               panic(err)
+       }
+       if _, err := kdf.h.Write(seed); err != nil {
+               panic(err)
+       }
+       if _, err := kdf.h.Write([]byte{0x01}); err != nil {
+               panic(err)
+       }
+       if _, err := kdf.h.Write([]byte{0x00}); err != nil {
+               panic(err)
+       }
        r = kdf.h.Sum(dst)
        kdf.h.Reset()
        return r
index 93c181f364ff9088af5e8044c424565eff4bfa5c..7cf962cbb602c9b4c1416f19c87d2b4bec30956b 100644 (file)
@@ -1,7 +1,7 @@
 @node Download
 @unnumbered Download
 
-@set VERSION 4.2.2
+@set VERSION 4.2.3
 
 Preferable way is to download tarball with the signature from
 website and, for example, run tests with benchmarks:
index eb34c76796c6ece89939911768a9b7d24b3592a8..d2d1e82af79782a5b76755954971cc609882ec5d 100644 (file)
--- a/news.texi
+++ b/news.texi
@@ -3,6 +3,10 @@
 
 @table @strong
 
+@anchor{Release 4.2.3}
+@item 4.2.3
+    Panic on all possible hash @code{Write} errors.
+
 @anchor{Release 4.2.2}
 @item 4.2.2
     More 34.10-2012 test vectors.
index 86f4cac1f4f7d10024dfe48552605ae1cfe6af2b..4b1aed68a457fbe1f0f09a2e0203ce931b2f22e5 100644 (file)
@@ -39,7 +39,9 @@ func (prf PRFIPsecPRFPlusGOSTR34112012) BlockSize() int {
 }
 
 func (prf PRFIPsecPRFPlusGOSTR34112012) Derive(salt []byte) []byte {
-       prf.h.Write(salt)
+       if _, err := prf.h.Write(salt); err != nil {
+               panic(err)
+       }
        sum := prf.h.Sum(nil)
        prf.h.Reset()
        return sum