]> Cypherpunks.ru repositories - gogost.git/blobdiff - src/cypherpunks.ru/gogost/gost28147/ctr.go
Forbid any later GNU GPL versions autousage
[gogost.git] / src / cypherpunks.ru / gogost / gost28147 / ctr.go
index 1f8803c1737fe1245d64df5c07b589a163c54e84..45119fecd3245abaf793ad09da45e5607b703c66 100644 (file)
@@ -1,10 +1,9 @@
 // GoGOST -- Pure Go GOST cryptographic functions library
-// Copyright (C) 2015-2017 Sergey Matveev <stargrave@stargrave.org>
+// Copyright (C) 2015-2019 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
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
+// the Free Software Foundation, version 3 of the License.
 //
 // This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -22,8 +21,11 @@ type CTR struct {
        n2 nv
 }
 
-func (c *Cipher) NewCTR(iv [BlockSize]byte) *CTR {
-       n1, n2 := block2nvs(iv[:])
+func (c *Cipher) NewCTR(iv []byte) *CTR {
+       if len(iv) != BlockSize {
+               panic("iv length is not equal to blocksize")
+       }
+       n1, n2 := block2nvs(iv)
        n2, n1 = c.xcrypt(SeqEncrypt, n1, n2)
        return &CTR{c, n1, n2}
 }