// GoGOST -- Pure Go GOST cryptographic functions library
-// Copyright (C) 2015-2019 Sergey Matveev <stargrave@stargrave.org>
+// Copyright (C) 2015-2020 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
"bytes"
"encoding/binary"
"errors"
+ "fmt"
)
const (
}
func (h *Hash) UnmarshalBinary(data []byte) error {
- if len(data) < len(MarshaledName)+1+8+3*BlockSize {
- return errors.New("too short data")
+ expectedLen := len(MarshaledName) + 1 + 8 + 3*BlockSize
+ if len(data) < expectedLen {
+ return fmt.Errorf("gogost/internal/gost34112012: len(data) != %d", expectedLen)
}
if !bytes.HasPrefix(data, []byte(MarshaledName)) {
- return errors.New("no hash name prefix")
+ return errors.New("gogost/internal/gost34112012: no hash name prefix")
}
idx := len(MarshaledName)
h.size = int(data[idx])