]> Cypherpunks.ru repositories - gogost.git/blobdiff - src/cypherpunks.ru/gogost/gost28147/ctr.go
Simplify keys and IVs arguments passing: use slices instead of arrays
[gogost.git] / src / cypherpunks.ru / gogost / gost28147 / ctr.go
index 77d0950cec50844a2b9087887f7a55c86358af81..19564f9ddb0595afee0aaa8d66ee730da618837c 100644 (file)
@@ -1,5 +1,5 @@
 // GoGOST -- Pure Go GOST cryptographic functions library
-// Copyright (C) 2015-2016 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
@@ -22,8 +22,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}
 }