Skip to content

Commit

Permalink
gofmt code
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Berger <[email protected]>
  • Loading branch information
stefanberger authored and lumjjb committed Aug 16, 2022
1 parent b2e09cd commit b2b6a74
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
19 changes: 8 additions & 11 deletions keywrap/keyprovider/keyprovider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
Expand Down Expand Up @@ -133,15 +133,15 @@ 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)
gcm, _ := cipher.NewGCM(c)

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)
Expand All @@ -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
Expand Down Expand Up @@ -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"))

Expand All @@ -376,5 +375,3 @@ func TestKeyWrapKeyProviderGRPCSuccess(t *testing.T) {
assert.Equal(t, optsData, keyUnWrapOutput)
os.Remove(path)
}


2 changes: 1 addition & 1 deletion keywrap/pkcs11/keywrapper_pkcs11.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
Expand Down
2 changes: 1 addition & 1 deletion keywrap/pkcs11/keywrapper_pkcs11_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion utils/ioutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b2b6a74

Please sign in to comment.