Skip to content

Commit 7eb2926

Browse files
authored
Update to go-kms-wrapping version 2, and plugin-based KMS (hashicorp#1901)
1 parent 89273a2 commit 7eb2926

File tree

209 files changed

+4052
-3023
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+4052
-3023
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ main
119119
/pkg/
120120
/bin/
121121
update-ui-assets*
122-
/plugins/kms/assets/
122+
/plugins/kms/assets/boundary-plugin*
123123
/plugins/host/assets/boundary-plugin*
124124

125125
# Test config file

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ tools:
2828
cleangen:
2929
@rm -f ${GENERATED_CODE}
3030

31+
.PHONY: install-no-plugins
32+
install-no-plugins: export SKIP_PLUGIN_BUILD=1
33+
install-no-plugins: install
34+
3135
.PHONY: dev
3236
dev:
3337
@echo "This command has changed. Please use:"

api/client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
"github.com/hashicorp/boundary/api/recovery"
2323
cleanhttp "github.com/hashicorp/go-cleanhttp"
24-
wrapping "github.com/hashicorp/go-kms-wrapping"
24+
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
2525
retryablehttp "github.com/hashicorp/go-retryablehttp"
2626
rootcerts "github.com/hashicorp/go-rootcerts"
2727
"github.com/hashicorp/go-secure-stdlib/parseutil"

api/go.mod

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,32 @@ go 1.17
55
require (
66
github.com/fatih/structs v1.1.0
77
github.com/hashicorp/go-cleanhttp v0.5.2
8-
github.com/hashicorp/go-kms-wrapping v0.6.6
8+
github.com/hashicorp/go-kms-wrapping/v2 v2.0.1
99
github.com/hashicorp/go-retryablehttp v0.6.8
1010
github.com/hashicorp/go-rootcerts v1.0.2
1111
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.1
1212
github.com/hashicorp/go-uuid v1.0.2
1313
github.com/mr-tron/base58 v1.2.0
1414
github.com/stretchr/testify v1.7.0
1515
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
16-
google.golang.org/grpc v1.35.0
16+
google.golang.org/grpc v1.38.0
1717
google.golang.org/protobuf v1.27.1
1818
)
1919

2020
require (
2121
github.com/davecgh/go-spew v1.1.1 // indirect
22-
github.com/fatih/color v1.7.0 // indirect
23-
github.com/golang/protobuf v1.5.0 // indirect
22+
github.com/golang/protobuf v1.5.2 // indirect
2423
github.com/hashicorp/go-hclog v0.16.2 // indirect
2524
github.com/hashicorp/go-secure-stdlib/strutil v0.1.1 // indirect
2625
github.com/hashicorp/go-sockaddr v1.0.2 // indirect
26+
github.com/kr/text v0.2.0 // indirect
2727
github.com/mattn/go-colorable v0.1.6 // indirect
2828
github.com/mattn/go-isatty v0.0.12 // indirect
2929
github.com/mitchellh/go-homedir v1.1.0 // indirect
3030
github.com/mitchellh/mapstructure v1.4.1 // indirect
3131
github.com/pmezard/go-difflib v1.0.0 // indirect
32+
github.com/rogpeppe/go-internal v1.6.1 // indirect
3233
github.com/ryanuber/go-glob v1.0.0 // indirect
33-
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a // indirect
34-
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 // indirect
34+
golang.org/x/crypto v0.0.0-20220313003712-b769efc7c000 // indirect
3535
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
3636
)

api/go.sum

+25-459
Large diffs are not rendered by default.

api/recovery/recovery.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"strings"
1010
"time"
1111

12-
wrapping "github.com/hashicorp/go-kms-wrapping"
12+
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
1313
"github.com/hashicorp/go-uuid"
1414
"github.com/mr-tron/base58"
1515
"google.golang.org/protobuf/proto"
@@ -51,7 +51,7 @@ func formatToken(ctx context.Context, wrapper wrapping.Wrapper, info *Info) (str
5151
return "", fmt.Errorf("error marshaling recovery info: %w", err)
5252
}
5353

54-
blobInfo, err := wrapper.Encrypt(ctx, marshaledInfo, nil)
54+
blobInfo, err := wrapper.Encrypt(ctx, marshaledInfo)
5555
if err != nil {
5656
return "", fmt.Errorf("error encrypting recovery info: %w", err)
5757
}
@@ -94,12 +94,12 @@ func ParseRecoveryToken(ctx context.Context, wrapper wrapping.Wrapper, versioned
9494
return nil, fmt.Errorf("length zero after base58-decoding token")
9595
}
9696

97-
blobInfo := new(wrapping.EncryptedBlobInfo)
97+
blobInfo := new(wrapping.BlobInfo)
9898
if err := proto.Unmarshal(marshaledBlob, blobInfo); err != nil {
9999
return nil, fmt.Errorf("error decoding encrypted blob: %w", err)
100100
}
101101

102-
marshaledInfo, err := wrapper.Decrypt(ctx, blobInfo, nil)
102+
marshaledInfo, err := wrapper.Decrypt(ctx, blobInfo)
103103
if err != nil {
104104
return nil, fmt.Errorf("error decrypting recovery info: %w", err)
105105
}

api/recovery/recovery_test.go

+8-13
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"testing"
88
"time"
99

10-
wrapping "github.com/hashicorp/go-kms-wrapping"
11-
"github.com/hashicorp/go-kms-wrapping/wrappers/aead"
10+
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
11+
aead "github.com/hashicorp/go-kms-wrapping/v2/aead"
1212
"github.com/hashicorp/go-uuid"
1313
"github.com/stretchr/testify/assert"
1414
"github.com/stretchr/testify/require"
@@ -17,20 +17,15 @@ import (
1717
func testWrapper(t *testing.T) wrapping.Wrapper {
1818
rootKey := make([]byte, 32)
1919
n, err := rand.Read(rootKey)
20+
require.NoError(t, err)
21+
require.Equal(t, n, 32)
22+
23+
root := aead.NewWrapper()
24+
_, err = root.SetConfig(context.Background(), wrapping.WithKeyId(base64.StdEncoding.EncodeToString(rootKey)))
2025
if err != nil {
2126
t.Fatal(err)
2227
}
23-
if n != 32 {
24-
t.Fatal(n)
25-
}
26-
root := aead.NewWrapper(nil)
27-
_, err = root.SetConfig(map[string]string{
28-
"key_id": base64.StdEncoding.EncodeToString(rootKey),
29-
})
30-
if err != nil {
31-
t.Fatal(err)
32-
}
33-
if err := root.SetAESGCMKeyBytes(rootKey); err != nil {
28+
if err := root.SetAesGcmKeyBytes(rootKey); err != nil {
3429
t.Fatal(err)
3530
}
3631
return root

depowners.md

-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ the first place.
9999
* Sarah
100100
* github.com/mitchellh/go-wordwrap
101101
* Jeff
102-
* github.com/mitchellh/gox
103-
* Jeff
104102
* github.com/mitchellh/mapstructure
105103
* Jeff
106104
* Louis

globals/kms.go

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package globals
2+
3+
const (
4+
KmsPurposeRoot = "root"
5+
KmsPurposeWorkerAuth = "worker-auth"
6+
KmsPurposeRecovery = "recovery"
7+
KmsPurposeConfig = "config"
8+
)

go.mod

+25-50
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,36 @@ require (
1616
github.com/golang-migrate/migrate/v4 v4.14.1
1717
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe
1818
github.com/golang/protobuf v1.5.2
19-
github.com/google/go-cmp v0.5.6
19+
github.com/google/go-cmp v0.5.7
2020
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
2121
github.com/grpc-ecosystem/grpc-gateway/v2 v2.6.0
22-
github.com/hashicorp/boundary/api v0.0.22
23-
github.com/hashicorp/boundary/sdk v0.0.13
22+
github.com/hashicorp/boundary/api v0.0.23-0.20220309215758-1a42592da498
23+
github.com/hashicorp/boundary/sdk v0.0.14-0.20220309214551-bb4528aa139b
2424
github.com/hashicorp/cap v0.1.1
2525
github.com/hashicorp/dawdle v0.4.0
2626
github.com/hashicorp/dbassert v0.0.0-20210708202608-ecf920cf1ed8
2727
github.com/hashicorp/eventlogger v0.1.1-0.20211106154408-4ff8da3a890c
28-
github.com/hashicorp/eventlogger/filters/encrypt v0.1.6-0.20211027211326-5db60a48f239
28+
github.com/hashicorp/eventlogger/filters/encrypt v0.1.7
2929
github.com/hashicorp/go-bexpr v0.1.10
3030
github.com/hashicorp/go-cleanhttp v0.5.2
31-
github.com/hashicorp/go-hclog v1.0.0
32-
github.com/hashicorp/go-kms-wrapping v0.6.6
31+
github.com/hashicorp/go-hclog v1.1.0
3332
github.com/hashicorp/go-multierror v1.1.1
3433
github.com/hashicorp/go-retryablehttp v0.7.0
3534
github.com/hashicorp/go-rootcerts v1.0.2
36-
github.com/hashicorp/go-secure-stdlib/awsutil v0.1.6 // indirect
3735
github.com/hashicorp/go-secure-stdlib/base62 v0.1.2
38-
github.com/hashicorp/go-secure-stdlib/configutil v0.1.2
36+
github.com/hashicorp/go-secure-stdlib/configutil/v2 v2.0.2
3937
github.com/hashicorp/go-secure-stdlib/gatedwriter v0.1.1
4038
github.com/hashicorp/go-secure-stdlib/kv-builder v0.1.1
41-
github.com/hashicorp/go-secure-stdlib/listenerutil v0.1.3-0.20211129134915-8f7e6fb52622
39+
github.com/hashicorp/go-secure-stdlib/listenerutil v0.1.4
4240
github.com/hashicorp/go-secure-stdlib/mlock v0.1.1
4341
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.2
4442
github.com/hashicorp/go-secure-stdlib/password v0.1.1
4543
github.com/hashicorp/go-secure-stdlib/reloadutil v0.1.1
4644
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2
45+
github.com/hashicorp/go-sockaddr v1.0.2
4746
github.com/hashicorp/go-uuid v1.0.2
4847
github.com/hashicorp/hcl v1.0.0
49-
github.com/hashicorp/vault/api v1.1.1
50-
github.com/hashicorp/vault/sdk v0.2.1
48+
github.com/hashicorp/vault/api v1.3.1
5149
github.com/iancoleman/strcase v0.2.0
5250
github.com/jackc/pgconn v1.10.1
5351
github.com/jackc/pgx/v4 v4.14.0
@@ -58,7 +56,6 @@ require (
5856
github.com/mitchellh/cli v1.1.2
5957
github.com/mitchellh/copystructure v1.2.0
6058
github.com/mitchellh/go-wordwrap v1.0.1
61-
github.com/mitchellh/gox v1.0.1
6259
github.com/mitchellh/mapstructure v1.4.2
6360
github.com/mitchellh/pointerstructure v1.2.0
6461
github.com/mr-tron/base58 v1.2.0
@@ -71,11 +68,12 @@ require (
7168
github.com/stretchr/testify v1.7.0
7269
github.com/zalando/go-keyring v0.1.1
7370
go.uber.org/atomic v1.9.0
74-
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871
75-
golang.org/x/term v0.0.0-20210916214954-140adaaadfaf
71+
golang.org/x/crypto v0.0.0-20220313003712-b769efc7c000
72+
golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a
73+
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
7674
golang.org/x/tools v0.1.8-0.20211102182255-bb4add04ddef
77-
google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83
78-
google.golang.org/grpc v1.41.0-dev.0.20210907181116-2f3355d2244e
75+
google.golang.org/genproto v0.0.0-20220208230804-65c12eb4c068
76+
google.golang.org/grpc v1.44.0
7977
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0
8078
google.golang.org/protobuf v1.27.1
8179
gorm.io/driver/postgres v1.2.2
@@ -87,35 +85,21 @@ require (
8785
require github.com/hashicorp/go-dbw v0.0.0-20211215222256-2ff0d37184ff // this is a branch and should be updated before merging
8886

8987
require (
90-
github.com/hashicorp/go-sockaddr v1.0.2
91-
golang.org/x/sys v0.0.0-20211210111614-af8b64212486
88+
github.com/hashicorp/go-kms-wrapping/v2 v2.0.4
89+
github.com/hashicorp/go-secure-stdlib/pluginutil/v2 v2.0.0
9290
)
9391

9492
require (
95-
cloud.google.com/go v0.81.0 // indirect
9693
github.com/AlecAivazis/survey/v2 v2.2.9 // indirect
97-
github.com/Azure/azure-sdk-for-go v58.0.0+incompatible // indirect
9894
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
99-
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
100-
github.com/Azure/go-autorest/autorest v0.11.21 // indirect
101-
github.com/Azure/go-autorest/autorest/adal v0.9.14 // indirect
102-
github.com/Azure/go-autorest/autorest/azure/auth v0.5.8 // indirect
103-
github.com/Azure/go-autorest/autorest/azure/cli v0.4.2 // indirect
104-
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
105-
github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect
106-
github.com/Azure/go-autorest/autorest/validation v0.3.1 // indirect
107-
github.com/Azure/go-autorest/logger v0.2.1 // indirect
108-
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
10995
github.com/Masterminds/goutils v1.1.1 // indirect
11096
github.com/Masterminds/semver v1.5.0 // indirect
11197
github.com/Masterminds/semver/v3 v3.1.1 // indirect
11298
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
11399
github.com/Microsoft/go-winio v0.4.16 // indirect
114100
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
115-
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190620160927-9418d7b0cd0f // indirect
116101
github.com/apex/log v1.9.0 // indirect
117102
github.com/armon/go-radix v1.0.0 // indirect
118-
github.com/aws/aws-sdk-go v1.40.55 // indirect
119103
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
120104
github.com/bgentry/speakeasy v0.1.0 // indirect
121105
github.com/cenkalti/backoff/v3 v3.0.0 // indirect
@@ -126,29 +110,28 @@ require (
126110
github.com/danieljoos/wincred v1.1.0 // indirect
127111
github.com/davecgh/go-spew v1.1.1 // indirect
128112
github.com/dhui/dktest v0.3.4 // indirect
129-
github.com/dimchansky/utfbom v1.1.1 // indirect
130113
github.com/docker/cli v20.10.7+incompatible // indirect
131114
github.com/docker/docker v20.10.7+incompatible // indirect
132115
github.com/docker/go-connections v0.4.0 // indirect
133116
github.com/docker/go-units v0.4.0 // indirect
134117
github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect
135-
github.com/form3tech-oss/jwt-go v3.2.2+incompatible // indirect
136118
github.com/ghodss/yaml v1.0.0 // indirect
137119
github.com/gofrs/flock v0.8.1 // indirect
138120
github.com/gofrs/uuid v4.0.0+incompatible // indirect
139121
github.com/gogo/protobuf v1.3.2 // indirect
140122
github.com/golang/glog v1.0.0 // indirect
141123
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
142-
github.com/golang/snappy v0.0.1 // indirect
124+
github.com/golang/snappy v0.0.4 // indirect
143125
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
144126
github.com/google/uuid v1.3.0 // indirect
145-
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
146127
github.com/hashicorp/errwrap v1.1.0 // indirect
147-
github.com/hashicorp/go-immutable-radix v1.1.0 // indirect
148-
github.com/hashicorp/go-plugin v1.0.1 // indirect
128+
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
129+
github.com/hashicorp/go-kms-wrapping/plugin/v2 v2.0.2 // indirect
130+
github.com/hashicorp/go-plugin v1.4.3 // indirect
149131
github.com/hashicorp/go-secure-stdlib/tlsutil v0.1.1 // indirect
150132
github.com/hashicorp/go-version v1.3.0 // indirect
151-
github.com/hashicorp/golang-lru v0.5.3 // indirect
133+
github.com/hashicorp/golang-lru v0.5.4 // indirect
134+
github.com/hashicorp/vault/sdk v0.3.0 // indirect
152135
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
153136
github.com/huandu/xstrings v1.3.2 // indirect
154137
github.com/imdario/mergo v0.3.12 // indirect
@@ -165,8 +148,6 @@ require (
165148
github.com/jinzhu/gorm v1.9.12 // indirect
166149
github.com/jinzhu/inflection v1.0.0 // indirect
167150
github.com/jinzhu/now v1.1.3 // indirect
168-
github.com/jmespath/go-jmespath v0.4.0 // indirect
169-
github.com/json-iterator/go v1.1.11 // indirect
170151
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
171152
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
172153
github.com/klauspost/compress v1.13.5 // indirect
@@ -177,21 +158,17 @@ require (
177158
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
178159
github.com/mitchellh/go-homedir v1.1.0 // indirect
179160
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
180-
github.com/mitchellh/iochan v1.0.0 // indirect
181161
github.com/mitchellh/reflectwalk v1.0.2 // indirect
182162
github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 // indirect
183-
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
184-
github.com/modern-go/reflect2 v1.0.1 // indirect
185163
github.com/mtibben/percent v0.2.1 // indirect
186164
github.com/oklog/run v1.0.0 // indirect
187165
github.com/opencontainers/go-digest v1.0.0 // indirect
188166
github.com/opencontainers/image-spec v1.0.1 // indirect
189167
github.com/opencontainers/runc v1.0.0-rc9 // indirect
190-
github.com/oracle/oci-go-sdk v12.5.0+incompatible // indirect
191168
github.com/pierrec/lz4 v2.5.2+incompatible // indirect
192169
github.com/pkg/profile v1.6.0 // indirect
193170
github.com/pmezard/go-difflib v1.0.0 // indirect
194-
github.com/rogpeppe/go-internal v1.8.1-0.20211023094830-115ce09fd6b4 // indirect
171+
github.com/rogpeppe/go-internal v1.8.1 // indirect
195172
github.com/russross/blackfriday/v2 v2.0.1 // indirect
196173
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
197174
github.com/sirupsen/logrus v1.7.0 // indirect
@@ -207,15 +184,13 @@ require (
207184
go.uber.org/multierr v1.7.0 // indirect
208185
go.uber.org/zap v1.19.0 // indirect
209186
golang.org/x/mod v0.5.1 // indirect
210-
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
211-
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
187+
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
188+
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
212189
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
213190
golang.org/x/text v0.3.7 // indirect
214191
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
215192
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
216-
google.golang.org/api v0.44.0 // indirect
217193
google.golang.org/appengine v1.6.7 // indirect
218-
gopkg.in/ini.v1 v1.62.0 // indirect
219194
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
220195
gopkg.in/yaml.v2 v2.4.0 // indirect
221196
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect

0 commit comments

Comments
 (0)