refactor: Move functions from kms pkg to new libs/crypto pkg (#1650)

This commit is contained in:
Jim authored and GitHub committed 2021-11-04 08:55:30 -04:00
1 parent a86ee59bcd
commit dd2c3807cd
16 files changed
+601 -186

No files matched your search

+5 -2
View File
@@ -4,7 +4,7 @@ import (
"crypto/ed25519"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/kms"
"github.com/hashicorp/boundary/internal/libs/crypto"
wrapping "github.com/hashicorp/go-kms-wrapping"
)
@@ -19,8 +19,11 @@ func DeriveED25519Key(wrapper wrapping.Wrapper, userId, jobId string) (ed25519.P
if jobId != "" {
jId = []byte(jobId)
}
if wrapper == nil {
return nil, nil, errors.NewDeprecated(errors.InvalidParameter, op, "missing wrapper")
}
reader, err := kms.NewDerivedReader(wrapper, 32, uId, jId)
reader, err := crypto.NewDerivedReader(wrapper, 32, uId, jId)
if err != nil {
return nil, nil, errors.WrapDeprecated(err, op)
}
+2 -2
View File
@@ -6,7 +6,7 @@ import (
"github.com/hashicorp/boundary/internal/db"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/kms"
"github.com/hashicorp/boundary/internal/libs/crypto"
wrapping "github.com/hashicorp/go-kms-wrapping"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -39,7 +39,7 @@ func TestDeriveED25519Key(t *testing.T) {
jobId: "jobId",
},
want: func() keys {
reader, err := kms.NewDerivedReader(wrapper, 32, []byte("userId"), []byte("jobId"))
reader, err := crypto.NewDerivedReader(wrapper, 32, []byte("userId"), []byte("jobId"))
require.NoError(t, err)
pub, priv, err := ed25519.GenerateKey(reader)
require.NoError(t, err)