]> Cypherpunks.ru repositories - gogost.git/blobdiff - internal/gost34112012/hash.go
Raise copyright years
[gogost.git] / internal / gost34112012 / hash.go
index 5f6b707d87a05a001326d464693406e10aa60672..f50b3c15235fc2337a870e997f75cba088bf3b4d 100644 (file)
@@ -1,5 +1,5 @@
 // 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
@@ -21,6 +21,7 @@ import (
        "bytes"
        "encoding/binary"
        "errors"
+       "fmt"
 )
 
 const (
@@ -426,11 +427,12 @@ func (h *Hash) MarshalBinary() (data []byte, err error) {
 }
 
 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])