Update transit public keys for Ed25519 support (#20727)

* Refine documentation for public_key

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Support additional key types in importing version

This originally left off the custom support for Ed25519 and RSA-PSS
formatted keys that we've added manually.

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Add support for Ed25519 keys

Here, we prevent importing public-key only keys with derived Ed25519
keys. Notably, we still allow import of derived Ed25519 keys via private
key method, though this is a touch weird: this private key must have
been packaged in an Ed25519 format (and parseable through Go as such),
even though it is (strictly) an HKDF key and isn't ever used for Ed25519.

Outside of this, importing non-derived Ed25519 keys works as expected.

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Add public-key only export method to Transit

This allows the existing endpoints to retain private-key only, including
empty strings for versions which lack private keys. On the public-key
endpoint, all versions will have key material returned.

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Update tests for exporting via public-key interface

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Add public-key export option to docs

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

---------

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
This commit is contained in:
Alexander Scheel
2023-05-24 11:26:35 -04:00
committed by GitHub
parent 4b0d85e3bf
commit e82cc49071
5 changed files with 218 additions and 66 deletions

View File

@@ -109,7 +109,17 @@ $ curl \
This endpoint imports existing key material into a new transit-managed encryption key.
To import key material into an existing key, see the `import_version/` endpoint.
// TODO: Has to be updated.
This supports one of two forms:
1. Private/Symmetric Key import, requiring the `ciphertext`, `hash_function`
parameters be set (and automatically deriving the public key), or
2. Public Key-only import, restricting the operations that can be done with
this key, and requiring only the `public_key` parameter.
The remaining parameters (including `name`, `type`, `allow_rotation`,
`derived`, `context`, `exportable`, `allow_plaintext_backup`, and
`auto_rotate_period`) remain the same across both versions of this call.
| Method | Path |
| :----- | :--------------------------- |
@@ -153,8 +163,10 @@ the hash function defaults to SHA256.
- `rsa-3072` - RSA with bit size of 3072 (asymmetric)
- `rsa-4096` - RSA with bit size of 4096 (asymmetric)
- `public_key` `(string: "", optional)` - A plaintext PEM public key to be imported.
If `ciphertext` is set, this field is ignored.
- `public_key` `(string: "", optional)` - A plaintext PEM public key to be
imported. This limits the operations available under this key to verification
and encryption, depending on the key type and algorithm, as no private key
is available.
- `allow_rotation` `(bool: false)` - If set, the imported key can be rotated
within Vault by using the `rotate` endpoint.
@@ -203,7 +215,12 @@ $ curl \
## Import Key Version
This endpoint imports new key material into an existing imported key.
// TODO: Has to be updated.
See description and note in [Import Key](#import-key) above about importing
public and private keys.
Notably, using this method, a private key matching a public key can be
imported at a later date.
| Method | Path |
| :----- | :----------------------------------- |
@@ -225,15 +242,16 @@ provided AES key. The wrapped AES key should be the first 512 bytes of the
ciphertext, and the encrypted key material should be the remaining bytes.
See the BYOK section of the [Transit secrets engine documentation](/vault/docs/secrets/transit#bring-your-own-key-byok)
for more information on constructing the ciphertext.
// TODO: Update text
- `hash_function` `(string: "SHA256")` - The hash function used for the
RSA-OAEP step of creating the ciphertext. Supported hash functions are:
`SHA1`, `SHA224`, `SHA256`, `SHA384`, and `SHA512`. If not specified,
the hash function defaults to SHA256.
- `public_key` `(string: "", optional)` - A plaintext PEM public key to be imported.
If `ciphertext` is set, this field is ignored.
- `public_key` `(string: "", optional)` - A plaintext PEM public key to be
imported. This limits the operations available under this key to verification
and encryption, depending on the key type and algorithm, as no private key
is available.
- `bump_version` - By default, each operator will create a new key version.
If set to "false", will try to update the latest version of the key,
@@ -513,6 +531,8 @@ be valid.
- `encryption-key`
- `signing-key`
- `hmac-key`
- `public-key`, to return the corresponding public keys of private key
asymmetric keys (EC with NIST P-curves or Ed25519 and RSA).
- `name` `(string: <required>)` Specifies the name of the key to read
information about. This is specified as part of the URL.