From 337596f6a27268a1a955b79cbe5c01bf5f602290 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Tue, 11 Sep 2018 12:16:18 +0200 Subject: [PATCH] Fix some linter warnings Signed-off-by: Knut Ahlers --- openssl.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openssl.go b/openssl.go index 1b5bf13..e99e747 100644 --- a/openssl.go +++ b/openssl.go @@ -14,6 +14,7 @@ import ( "io" ) +// ErrInvalidSalt is returned when a salt with a length of != 8 byte is passed var ErrInvalidSalt = errors.New("Salt needs to have exactly 8 byte") // OpenSSL is a helper to generate OpenSSL compatible encryption @@ -67,7 +68,7 @@ func (o OpenSSL) DecryptBytes(passphrase string, encryptedBase64Data []byte) ([] } saltHeader := data[:aes.BlockSize] if string(saltHeader[:8]) != o.openSSLSaltHeader { - return nil, fmt.Errorf("Does not appear to have been encrypted with OpenSSL, salt header missing.") + return nil, fmt.Errorf("Does not appear to have been encrypted with OpenSSL, salt header missing") } salt := saltHeader[8:] @@ -84,7 +85,7 @@ func (o OpenSSL) DecryptBytes(passphrase string, encryptedBase64Data []byte) ([] func (o OpenSSL) decrypt(key, iv, data []byte) ([]byte, error) { if len(data) == 0 || len(data)%aes.BlockSize != 0 { - return nil, fmt.Errorf("bad blocksize(%v), aes.BlockSize = %v\n", len(data), aes.BlockSize) + return nil, fmt.Errorf("bad blocksize(%v), aes.BlockSize = %v", len(data), aes.BlockSize) } c, err := aes.NewCipher(key) if err != nil { @@ -99,7 +100,7 @@ func (o OpenSSL) decrypt(key, iv, data []byte) ([]byte, error) { return out, nil } -// EncryptString encrypts a slice of bytes in a manner compatible to OpenSSL encryption +// EncryptBytes encrypts a slice of bytes in a manner compatible to OpenSSL encryption // functions using AES-256-CBC as encryption algorithm. This function generates // a random salt on every execution. func (o OpenSSL) EncryptBytes(passphrase string, plainData []byte) ([]byte, error) {