Skip to content

Commit ea9cbc9

Browse files
Jim Kalafutncabatoff
authored andcommitted
Rename master key to root key (hashicorp#13324)
* See what it looks like to replace "master key" with "root key". There are two places that would require more challenging code changes: the storage path `core/master`, and its contents (the JSON-serialized EncodedKeyringtructure.) * Restore accidentally deleted line * Add changelog * Update root->recovery * Fix test Co-authored-by: Nick Cabatoff <ncabatoff@hashicorp.com>
1 parent 82aadc9 commit ea9cbc9

23 files changed

+182
-179
lines changed

changelog/13324.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:improvement
2+
core: Replace "master key" terminology with "root key"
3+
```

command/operator_init.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ Usage: vault operator init [options]
5757
same storage backend in HA mode, you only need to initialize one Vault to
5858
initialize the storage backend.
5959
60-
During initialization, Vault generates an in-memory master key and applies
61-
Shamir's secret sharing algorithm to disassemble that master key into a
60+
During initialization, Vault generates an in-memory root key and applies
61+
Shamir's secret sharing algorithm to disassemble that root key into a
6262
configuration number of key shares such that a configurable subset of those
63-
key shares must come together to regenerate the master key. These keys are
63+
key shares must come together to regenerate the root key. These keys are
6464
often called "unseal keys" in Vault's documentation.
6565
6666
This command cannot be run against an already-initialized Vault cluster.
@@ -105,7 +105,7 @@ func (c *OperatorInitCommand) Flags() *FlagSets {
105105
Target: &c.flagKeyShares,
106106
Default: defKeyShares,
107107
Completion: complete.PredictAnything,
108-
Usage: "Number of key shares to split the generated master key into. " +
108+
Usage: "Number of key shares to split the generated root key into. " +
109109
"This is the number of \"unseal keys\" to generate.",
110110
})
111111

@@ -115,7 +115,7 @@ func (c *OperatorInitCommand) Flags() *FlagSets {
115115
Target: &c.flagKeyThreshold,
116116
Default: defKeyThreshold,
117117
Completion: complete.PredictAnything,
118-
Usage: "Number of key shares required to reconstruct the master key. " +
118+
Usage: "Number of key shares required to reconstruct the root key. " +
119119
"This must be less than or equal to -key-shares.",
120120
})
121121

@@ -447,8 +447,8 @@ func (c *OperatorInitCommand) init(client *api.Client, req *api.InitRequest) int
447447

448448
c.UI.Output("")
449449
c.UI.Output(wrapAtLength(fmt.Sprintf(
450-
"Vault does not store the generated master key. Without at least %d "+
451-
"keys to reconstruct the master key, Vault will remain permanently "+
450+
"Vault does not store the generated root key. Without at least %d "+
451+
"keys to reconstruct the root key, Vault will remain permanently "+
452452
"sealed!",
453453
req.SecretThreshold)))
454454

command/operator_rekey.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Usage: vault operator rekey [options] [KEY]
5151
5252
Generates a new set of unseal keys. This can optionally change the total
5353
number of key shares or the required threshold of those key shares to
54-
reconstruct the master key. This operation is zero downtime, but it requires
54+
reconstruct the root key. This operation is zero downtime, but it requires
5555
the Vault is unsealed and a quorum of existing unseal keys are provided.
5656
5757
An unseal key may be provided directly on the command line as an argument to
@@ -129,7 +129,7 @@ func (c *OperatorRekeyCommand) Flags() *FlagSets {
129129
Target: &c.flagKeyShares,
130130
Default: 5,
131131
Completion: complete.PredictAnything,
132-
Usage: "Number of key shares to split the generated master key into. " +
132+
Usage: "Number of key shares to split the generated root key into. " +
133133
"This is the number of \"unseal keys\" to generate.",
134134
})
135135

@@ -139,7 +139,7 @@ func (c *OperatorRekeyCommand) Flags() *FlagSets {
139139
Target: &c.flagKeyThreshold,
140140
Default: 3,
141141
Completion: complete.PredictAnything,
142-
Usage: "Number of key shares required to reconstruct the master key. " +
142+
Usage: "Number of key shares required to reconstruct the root key. " +
143143
"This must be less than or equal to -key-shares.",
144144
})
145145

command/operator_seal.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ Usage: vault operator seal [options]
2727
2828
Seals the Vault server. Sealing tells the Vault server to stop responding
2929
to any operations until it is unsealed. When sealed, the Vault server
30-
discards its in-memory master key to unlock the data, so it is physically
30+
discards its in-memory root key to unlock the data, so it is physically
3131
blocked from responding to operations unsealed.
3232
3333
If an unseal is in progress, sealing the Vault will reset the unsealing
34-
process. Users will have to re-enter their portions of the master key again.
34+
process. Users will have to re-enter their portions of the root key again.
3535
3636
This command does nothing if the Vault server is already sealed.
3737

command/operator_unseal.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ func (c *OperatorUnsealCommand) Help() string {
3434
helpText := `
3535
Usage: vault operator unseal [options] [KEY]
3636
37-
Provide a portion of the master key to unseal a Vault server. Vault starts
37+
Provide a portion of the root key to unseal a Vault server. Vault starts
3838
in a sealed state. It cannot perform operations until it is unsealed. This
39-
command accepts a portion of the master key (an "unseal key").
39+
command accepts a portion of the root key (an "unseal key").
4040
4141
The unseal key can be supplied as an argument to the command, but this is
4242
not recommended as the unseal key will be available in your history:

physical/raft/raft.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ func (b *RaftBackend) SnapshotHTTP(out *logical.HTTPResponseWriter, access *seal
11441144

11451145
// Snapshot takes a raft snapshot, packages it into a archive file and writes it
11461146
// to the provided writer. Seal access is used to encrypt the SHASUM file so we
1147-
// can validate the snapshot was taken using the same master keys or not.
1147+
// can validate the snapshot was taken using the same root keys or not.
11481148
func (b *RaftBackend) Snapshot(out io.Writer, access *seal.Access) error {
11491149
b.l.RLock()
11501150
defer b.l.RUnlock()
@@ -1167,7 +1167,7 @@ func (b *RaftBackend) Snapshot(out io.Writer, access *seal.Access) error {
11671167
// WriteSnapshotToTemp reads a snapshot archive off the provided reader,
11681168
// extracts the data and writes the snapshot to a temporary file. The seal
11691169
// access is used to decrypt the SHASUM file in the archive to ensure this
1170-
// snapshot has the same master key as the running instance. If the provided
1170+
// snapshot has the same root key as the running instance. If the provided
11711171
// access is nil then it will skip that validation.
11721172
func (b *RaftBackend) WriteSnapshotToTemp(in io.ReadCloser, access *seal.Access) (*os.File, func(), raft.SnapshotMeta, error) {
11731173
b.l.RLock()

vault/barrier.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,33 @@ const (
3535
barrierInitPath = "barrier/init"
3636

3737
// keyringPath is the location of the keyring data. This is encrypted
38-
// by the master key.
38+
// by the root key.
3939
keyringPath = "core/keyring"
4040
keyringPrefix = "core/"
4141

4242
// keyringUpgradePrefix is the path used to store keyring update entries.
4343
// When running in HA mode, the active instance will install the new key
4444
// and re-write the keyring. For standby instances, they need an upgrade
45-
// path from key N to N+1. They cannot just use the master key because
46-
// in the event of a rekey, that master key can no longer decrypt the keyring.
45+
// path from key N to N+1. They cannot just use the root key because
46+
// in the event of a rekey, that root key can no longer decrypt the keyring.
4747
// When key N+1 is installed, we create an entry at "prefix/N" which uses
4848
// encryption key N to provide the N+1 key. The standby instances scan
4949
// for this periodically and refresh their keyring. The upgrade keys
5050
// are deleted after a few minutes, but this provides enough time for the
5151
// standby instances to upgrade without causing any disruption.
5252
keyringUpgradePrefix = "core/upgrade/"
5353

54-
// masterKeyPath is the location of the master key. This is encrypted
54+
// rootKeyPath is the location of the root key. This is encrypted
5555
// by the latest key in the keyring. This is only used by standby instances
5656
// to handle the case of a rekey. If the active instance does a rekey,
5757
// the standby instances can no longer reload the keyring since they
58-
// have the old master key. This key can be decrypted if you have the
59-
// keyring to discover the new master key. The new master key is then
58+
// have the old root key. This key can be decrypted if you have the
59+
// keyring to discover the new root key. The new root key is then
6060
// used to reload the keyring itself.
61-
masterKeyPath = "core/master"
61+
rootKeyPath = "core/master"
6262

6363
// shamirKekPath is used with Shamir in v1.3+ to store a copy of the
64-
// unseal key behind the barrier. As with masterKeyPath this is primarily
64+
// unseal key behind the barrier. As with rootKeyPath this is primarily
6565
// used by standbys to handle rekeys. It also comes into play when restoring
6666
// raft snapshots.
6767
shamirKekPath = "core/shamir-kek"
@@ -75,14 +75,14 @@ const (
7575
// a Vault. The barrier should only be Unlockable given its key.
7676
type SecurityBarrier interface {
7777
// Initialized checks if the barrier has been initialized
78-
// and has a master key set.
78+
// and has a root key set.
7979
Initialized(ctx context.Context) (bool, error)
8080

8181
// Initialize works only if the barrier has not been initialized
82-
// and makes use of the given master key. When sealKey is provided
83-
// it's because we're using a new-style Shamir seal, and masterKey
82+
// and makes use of the given root key. When sealKey is provided
83+
// it's because we're using a new-style Shamir seal, and rootKey
8484
// is to be stored using sealKey to encrypt it.
85-
Initialize(ctx context.Context, masterKey []byte, sealKey []byte, random io.Reader) error
85+
Initialize(ctx context.Context, rootKey []byte, sealKey []byte, random io.Reader) error
8686

8787
// GenerateKey is used to generate a new key
8888
GenerateKey(io.Reader) ([]byte, error)
@@ -94,27 +94,27 @@ type SecurityBarrier interface {
9494
// is not expected to be able to perform any CRUD until it is unsealed.
9595
Sealed() (bool, error)
9696

97-
// Unseal is used to provide the master key which permits the barrier
97+
// Unseal is used to provide the unseal key which permits the barrier
9898
// to be unsealed. If the key is not correct, the barrier remains sealed.
9999
Unseal(ctx context.Context, key []byte) error
100100

101-
// VerifyMaster is used to check if the given key matches the master key
102-
VerifyMaster(key []byte) error
101+
// VerifyRoot is used to check if the given key matches the root key
102+
VerifyRoot(key []byte) error
103103

104-
// SetMasterKey is used to directly set a new master key. This is used in
104+
// SetRootKey is used to directly set a new root key. This is used in
105105
// replicated scenarios due to the chicken and egg problem of reloading the
106-
// keyring from disk before we have the master key to decrypt it.
107-
SetMasterKey(key []byte) error
106+
// keyring from disk before we have the root key to decrypt it.
107+
SetRootKey(key []byte) error
108108

109109
// ReloadKeyring is used to re-read the underlying keyring.
110110
// This is used for HA deployments to ensure the latest keyring
111111
// is present in the leader.
112112
ReloadKeyring(ctx context.Context) error
113113

114-
// ReloadMasterKey is used to re-read the underlying masterkey.
115-
// This is used for HA deployments to ensure the latest master key
114+
// ReloadRootKey is used to re-read the underlying root key.
115+
// This is used for HA deployments to ensure the latest root key
116116
// is available for keyring reloading.
117-
ReloadMasterKey(ctx context.Context) error
117+
ReloadRootKey(ctx context.Context) error
118118

119119
// Seal is used to re-seal the barrier. This requires the barrier to
120120
// be unsealed again to perform any further operations.

0 commit comments

Comments
 (0)