var prv any
if *reuseKey == "" {
prvRaw := make([]byte, curve.PointSize())
- if _, err := io.ReadFull(rand.Reader, prvRaw); err != nil {
+ if _, err = io.ReadFull(rand.Reader, prvRaw); err != nil {
log.Fatal(err)
}
prv, err = gost3410.NewPrivateKey(curve, prvRaw)
if err != nil {
log.Fatal(err)
}
- data, err := x509.MarshalPKCS8PrivateKey(prv)
+ var data []byte
+ data, err = x509.MarshalPKCS8PrivateKey(prv)
if err != nil {
log.Fatal(err)
}
)
type Cipher struct {
- key [KeySize]byte
sbox *Sbox
x [8]nv
+ key [KeySize]byte
}
func NewCipher(key []byte, sbox *Sbox) *Cipher {
type MAC struct {
c *Cipher
- size int
iv []byte
prev []byte
buf []byte
+ size int
n1 nv
n2 nv
}
)
type Curve struct {
- Name string // Just simple identifier
-
P *big.Int // Characteristic of the underlying prime field
Q *big.Int // Elliptic curve subgroup order
// Cached s/t parameters for Edwards curve points conversion
edS *big.Int
edT *big.Int
+
+ Name string // Just simple identifier
}
func NewCurve(p, q, a, b, x, y, e, d, co *big.Int) (*Curve, error) {
t.Fatal(err)
}
var _ crypto.Signer = prv
- var _ crypto.Signer = &PrivateKeyReverseDigest{prv}
- var _ crypto.Signer = &PrivateKeyReverseDigestAndSignature{prv}
+ var _ crypto.Signer = &PrivateKeyReverseDigest{}
+ var _ crypto.Signer = &PrivateKeyReverseDigestAndSignature{}
}
func TestSignerReverseDigest(t *testing.T) {
type ESPTree struct {
keyRoot []byte
- isPrev [5]byte
key []byte
+ isPrev [5]byte
}
func NewESPTree(keyRoot []byte) *ESPTree {
key := make([]byte, len(keyRoot))
copy(key, keyRoot)
- t := &ESPTree{
- keyRoot: key,
- key: make([]byte, Size),
- }
+ t := &ESPTree{keyRoot: key, key: make([]byte, Size)}
t.isPrev[0]++ // invalidate cache
t.DeriveCached([]byte{0x00, 0x00, 0x00, 0x00, 0x00})
return t
)
type TLSTree struct {
- params TLSTreeParams
keyRoot []byte
- seqNumPrev uint64
seq []byte
key []byte
+ params TLSTreeParams
+ seqNumPrev uint64
}
func NewTLSTree(params TLSTreeParams, keyRoot []byte) *TLSTree {
type Hash struct {
sbox *gost28147.Sbox
- size uint64
- hsh [BlockSize]byte
chk *big.Int
buf []byte
+ hsh [BlockSize]byte
tmp [BlockSize]byte
+ size uint64
}
func New(sbox *gost28147.Sbox) *Hash {
)
var (
- key []byte = []byte{
+ Key []byte = []byte{
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
}
func TestRoundKeys(t *testing.T) {
- c := NewCipher(key)
+ c := NewCipher(Key)
if !bytes.Equal(c.ks[0][:], []byte{
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
}
func TestVectorEncrypt(t *testing.T) {
- c := NewCipher(key)
+ c := NewCipher(Key)
dst := make([]byte, BlockSize)
c.Encrypt(dst, pt[:])
if !bytes.Equal(dst, ct[:]) {
}
func TestVectorDecrypt(t *testing.T) {
- c := NewCipher(key)
+ c := NewCipher(Key)
dst := make([]byte, BlockSize)
c.Decrypt(dst, ct[:])
if !bytes.Equal(dst, pt[:]) {
const BlockSize = 64
type Hash struct {
- size int
buf []byte
- n uint64
hsh []byte
chk []byte
+ n uint64
+ size int
}
// Create new hash object with specified size digest size.
}
type MGM struct {
- MaxSize uint64
- BlockSize int
- TagSize int
cipher cipher.Block
+ mul Mul
icn []byte
bufP []byte
bufC []byte
padded []byte
sum []byte
- mul Mul
+ MaxSize uint64
+ BlockSize int
+ TagSize int
}
func NewMGM(cipher cipher.Block, tagSize int) (cipher.AEAD, error) {