diff --git a/pkg/apierrors/apierrors.go b/pkg/apierrors/apierrors.go index 184bb12..1dc41a7 100644 --- a/pkg/apierrors/apierrors.go +++ b/pkg/apierrors/apierrors.go @@ -21,8 +21,6 @@ package apierrors import "errors" var ( - ErrCheck = errors.New("invalid checksum") ErrNoAsset = errors.New("asset not found for current platform") - ErrNoSum = errors.New("file checksum not found for current platform") ErrReturn = errors.New("unexpected value returned by API") ) diff --git a/pkg/check/sha256/check.go b/pkg/check/sha256/check.go index 68d97a5..b22b601 100644 --- a/pkg/check/sha256/check.go +++ b/pkg/check/sha256/check.go @@ -4,15 +4,19 @@ import ( "bytes" "crypto/sha256" "encoding/hex" + "errors" "strings" +) - "github.com/dvaumoron/gotofuenv/pkg/apierrors" +var ( + errCheck = errors.New("invalid sha256 checksum") + errNoSum = errors.New("file sha256 checksum not found for current platform") ) func Check(data []byte, dataSum []byte) error { hashed := sha256.Sum256(data) if !bytes.Equal(dataSum, hashed[:]) { - return apierrors.ErrCheck + return errCheck } return nil } @@ -26,5 +30,5 @@ func Extract(dataSums []byte, fileName string) ([]byte, error) { return hex.DecodeString(dataSumStr) } } - return nil, apierrors.ErrNoSum + return nil, errNoSum }