// 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
const (
BlockSize = 32
+ Size = 32
)
var (
- SboxDefault *gost28147.Sbox = &gost28147.GostR3411_94_TestParamSet
+ SboxDefault *gost28147.Sbox = &gost28147.SboxIdGostR341194TestParamSet
c2 [BlockSize]byte = [BlockSize]byte{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}
h.chk = big.NewInt(0)
- h.buf = nil
+ h.buf = h.buf[:0]
}
func (h *Hash) BlockSize() int {
blockXor(k, u, v)
k = fP(k)
blockReverse(k[:], k[:])
- kk := *k
- c := gost28147.NewCipher(kk, h.sbox)
+ c := gost28147.NewCipher(k[:], h.sbox)
s := make([]byte, gost28147.BlockSize)
c.Encrypt(s, []byte{
hin[31], hin[30], hin[29], hin[28], hin[27], hin[26], hin[25], hin[24],
blockXor(k, u, v)
k = fP(k)
blockReverse(k[:], k[:])
- c = gost28147.NewCipher(*k, h.sbox)
+ c = gost28147.NewCipher(k[:], h.sbox)
c.Encrypt(s, []byte{
hin[23], hin[22], hin[21], hin[20], hin[19], hin[18], hin[17], hin[16],
})
blockXor(k, u, v)
k = fP(k)
blockReverse(k[:], k[:])
- c = gost28147.NewCipher(*k, h.sbox)
+ c = gost28147.NewCipher(k[:], h.sbox)
c.Encrypt(s, []byte{
hin[15], hin[14], hin[13], hin[12], hin[11], hin[10], hin[9], hin[8],
})
blockXor(k, u, v)
k = fP(k)
blockReverse(k[:], k[:])
- c = gost28147.NewCipher(*k, h.sbox)
+ c = gost28147.NewCipher(k[:], h.sbox)
c.Encrypt(s, []byte{
hin[7], hin[6], hin[5], hin[4], hin[3], hin[2], hin[1], hin[0],
})
chkBytes := chk.Bytes()
copy(block[BlockSize-len(chkBytes):], chkBytes)
hsh = h.step(hsh, *block)
+ blockReverse(hsh[:], hsh[:])
return append(in, hsh[:]...)
}