diff --git a/keywrap/keyprovider/keyprovider_test.go b/keywrap/keyprovider/keyprovider_test.go index e648357..efbee30 100644 --- a/keywrap/keyprovider/keyprovider_test.go +++ b/keywrap/keyprovider/keyprovider_test.go @@ -68,14 +68,14 @@ func init() { func (*server) WrapKey(ctx context.Context, request *keyproviderpb.KeyProviderKeyWrapProtocolInput) (*keyproviderpb.KeyProviderKeyWrapProtocolOutput, error) { var keyP KeyProviderKeyWrapProtocolInput err := json.Unmarshal(request.KeyProviderKeyWrapProtocolInput, &keyP) - if err != nil{ + if err != nil { return nil, err } c, _ := aes.NewCipher(encryptingKey) gcm, _ := cipher.NewGCM(c) nonce := make([]byte, gcm.NonceSize()) _, err = io.ReadFull(rand.Reader, nonce) - if err != nil{ + if err != nil { return nil, err } @@ -100,12 +100,12 @@ func (*server) WrapKey(ctx context.Context, request *keyproviderpb.KeyProviderKe func (*server) UnWrapKey(ctx context.Context, request *keyproviderpb.KeyProviderKeyWrapProtocolInput) (*keyproviderpb.KeyProviderKeyWrapProtocolOutput, error) { var keyP KeyProviderKeyWrapProtocolInput err := json.Unmarshal(request.KeyProviderKeyWrapProtocolInput, &keyP) - if err != nil{ + if err != nil { return nil, err } apkt := annotationPacket{} err = json.Unmarshal(keyP.KeyUnwrapParams.Annotation, &apkt) - if err != nil{ + if err != nil { return nil, err } ciphertext := apkt.WrappedKey @@ -133,7 +133,7 @@ func (r TestRunner) Exec(cmdName string, args []string, input []byte) ([]byte, e if cmdName == "/usr/lib/keyprovider-1-wrapkey" { var keyP KeyProviderKeyWrapProtocolInput err := json.Unmarshal(input, &keyP) - if err != nil{ + if err != nil { return nil, err } c, _ := aes.NewCipher(encryptingKey) @@ -141,7 +141,7 @@ func (r TestRunner) Exec(cmdName string, args []string, input []byte) ([]byte, e nonce := make([]byte, gcm.NonceSize()) _, err = io.ReadFull(rand.Reader, nonce) - if err != nil{ + if err != nil { return nil, err } wrappedKey := gcm.Seal(nonce, nonce, keyP.KeyWrapParams.OptsData, nil) @@ -160,12 +160,12 @@ func (r TestRunner) Exec(cmdName string, args []string, input []byte) ([]byte, e } else if cmdName == "/usr/lib/keyprovider-1-unwrapkey" { var keyP KeyProviderKeyWrapProtocolInput err := json.Unmarshal(input, &keyP) - if err != nil{ + if err != nil { return nil, err } apkt := annotationPacket{} err = json.Unmarshal(keyP.KeyUnwrapParams.Annotation, &apkt) - if err != nil{ + if err != nil { return nil, err } ciphertext := apkt.WrappedKey @@ -364,7 +364,6 @@ func TestKeyWrapKeyProviderGRPCSuccess(t *testing.T) { keyWrapOutput, err := keyWrapper.WrapKeys(&ec, optsData) assert.NoError(t, err) - dp := make(map[string][][]byte) dp["keyprovider-1"] = append(dp["keyprovider-1"], []byte("Supported Protocol")) @@ -376,5 +375,3 @@ func TestKeyWrapKeyProviderGRPCSuccess(t *testing.T) { assert.Equal(t, optsData, keyUnWrapOutput) os.Remove(path) } - - diff --git a/keywrap/pkcs11/keywrapper_pkcs11.go b/keywrap/pkcs11/keywrapper_pkcs11.go index 803b908..c44c453 100644 --- a/keywrap/pkcs11/keywrapper_pkcs11.go +++ b/keywrap/pkcs11/keywrapper_pkcs11.go @@ -139,7 +139,7 @@ func addPubKeys(dc *config.DecryptConfig, pubKeys [][]byte) ([]interface{}, erro return pkcs11Keys, nil } -func p11confFromParameters(dcparameters map[string][][]byte) (*pkcs11.Pkcs11Config, error){ +func p11confFromParameters(dcparameters map[string][][]byte) (*pkcs11.Pkcs11Config, error) { if _, ok := dcparameters["pkcs11-config"]; ok { return pkcs11.ParsePkcs11ConfigFile(dcparameters["pkcs11-config"][0]) } diff --git a/keywrap/pkcs11/keywrapper_pkcs11_test.go b/keywrap/pkcs11/keywrapper_pkcs11_test.go index fe1b29e..4036296 100644 --- a/keywrap/pkcs11/keywrapper_pkcs11_test.go +++ b/keywrap/pkcs11/keywrapper_pkcs11_test.go @@ -22,8 +22,8 @@ import ( "testing" "github.com/containers/ocicrypt/config" - "github.com/containers/ocicrypt/utils" "github.com/containers/ocicrypt/crypto/pkcs11" + "github.com/containers/ocicrypt/utils" "github.com/containers/ocicrypt/utils/softhsm" ) diff --git a/utils/ioutils.go b/utils/ioutils.go index 078c347..e4107be 100644 --- a/utils/ioutils.go +++ b/utils/ioutils.go @@ -18,9 +18,9 @@ package utils import ( "bytes" + "github.com/pkg/errors" "io" "os/exec" - "github.com/pkg/errors" ) // FillBuffer fills the given buffer with as many bytes from the reader as possible. It returns