Skip to content
This repository has been archived by the owner on Aug 25, 2023. It is now read-only.

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
skynet2 committed Mar 22, 2023
1 parent c6f21d3 commit 44026ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/aws/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func WithKeyAliasPrefix(prefix string) Opts {
return func(opts *opts) { opts.keyAliasPrefix = prefix }
}

// WithAWSClient sets custom aws client
// WithAWSClient sets custom AWS client.
func WithAWSClient(client awsClient) Opts {
return func(opts *opts) { opts.awsClient = client }
}
11 changes: 8 additions & 3 deletions pkg/aws/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
arieskms "github.com/hyperledger/aries-framework-go/pkg/kms"
)

type awsClient interface { //nolint:dupl
type awsClient interface {
Sign(ctx context.Context, params *kms.SignInput, optFns ...func(*kms.Options)) (*kms.SignOutput, error)
GetPublicKey(ctx context.Context, params *kms.GetPublicKeyInput,
optFns ...func(*kms.Options)) (*kms.GetPublicKeyOutput, error)
Expand Down Expand Up @@ -90,6 +90,10 @@ var keySpecToCurve = map[types.KeySpec]elliptic.Curve{
types.KeySpecEccSecgP256k1: btcec.S256(),
}

const (
defaultNonceLength = 16
)

// New return aws service.
func New(
awsConfig *aws.Config,
Expand All @@ -102,6 +106,7 @@ func New(
for _, opt := range opts {
opt(options)
}

client := options.awsClient
if client == nil {
client = kms.NewFromConfig(*awsConfig)
Expand All @@ -113,7 +118,7 @@ func New(
metrics: metrics,
healthCheckKeyID: healthCheckKeyID,
encryptionAlgo: types.EncryptionAlgorithmSpecRsaesOaepSha256,
nonceLength: 16,
nonceLength: defaultNonceLength,
}
}

Expand Down Expand Up @@ -403,7 +408,7 @@ func (s *Service) getKeyID(keyURI string) (string, error) {

func generateNonce(length int) []byte {
key := make([]byte, length)
_, _ = rand.Read(key)
_, _ = rand.Read(key) //nolint: errcheck

return key
}
Expand Down

0 comments on commit 44026ea

Please sign in to comment.