Skip to content

Commit 811848e

Browse files
committed
Add EDEK details
Signed-off-by: Robert Young <[email protected]>
1 parent 1f29bc0 commit 811848e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

proposals/007-azure-kms.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,30 @@ So that we can supply custom trust or use insecure testing modes (mock servers u
8484

8585
Another difference is that basic Key Vault cannot generate the DEK bytes for us. Managed HSM does have an operation to generate random bytes for us https://learn.microsoft.com/en-us/rest/api/keyvault/?view=rest-keyvault-keys-7.4#key-operations-managed-hsm-only
8686

87+
### Key Identifiers
88+
89+
When we wrap/unwrap we have to identify a key by its name and version. You can obtain the latest version by https://learn.microsoft.com/en-us/rest/api/keyvault/keys/get-key/get-key?view=rest-keyvault-keys-7.4&tabs=HTTP.
90+
91+
The API usually returns it as a `kid` https://learn.microsoft.com/en-us/azure/key-vault/general/about-keys-secrets-certificates#object-identifiers. Like
92+
93+
> For Vaults: https://{vault-name}.vault.azure.net/{object-type}/{object-name}/{object-version}
94+
95+
eg. `https://my-vault.vault.azure.net/keys/my-key/78deebed173b48e48f55abf87ed4cf71`
96+
97+
The Azure SDK then takes advantage of the fact this happens to be the base URL for various operations like wrap/unwrap.
98+
99+
ed. for [wrap key](https://learn.microsoft.com/en-us/rest/api/keyvault/keys/wrap-key/wrap-key?view=rest-keyvault-keys-7.4&tabs=HTTP) the url is `POST {vaultBaseUrl}/keys/{key-name}/{key-version}/wrapkey?api-version=7.4
100+
`
101+
102+
To minimise EDEK bytes there are a couple of opportunities when encoding the EDEK:
103+
1. we can exclude the vaultBaseUrl and have the limitation that we work only with a single key vault
104+
2. we can encode just the keyName and keyVersion, and use that to decrypt
105+
3. all documented examples of the keyVersion (and from my experimentation too) are 128bits encoded as a hexadecimal string.
106+
107+
So for the EDEK I think we could optimistically try to encode it as `versionByte,keyNameLength,keyName,keyVersionLength,128-bit-decoded,edek`
108+
and fall back to using the string like `versionByte,keyNameLength,keyName,keyVersionLength,keyVersionString,edek`. So
109+
we would have either a 16-byte version implying it's the bytes, or a 32 character string.
110+
87111
## Proposed Initial Implementation
88112

89113
1. Support all flavours of Key Vault. The APIs will be the same, just with a different vault base URI.
@@ -93,6 +117,7 @@ Another difference is that basic Key Vault cannot generate the DEK bytes for us.
93117
5. Support TLS customization of the authentication client and key vault client.
94118
6. DEK bytes will be generated proxy-side with a SecureRandom.
95119
7. The Azure SDK pulls in netty/jackson/project-reactor, lets try implementing the APIs ourselves as we have for AWS
120+
8. Edek stores the keyName, keyVersion, edek. We attempt to minimise keyVersion size by optimistically decoding it from hex string, else store the string.
96121

97122
### Configuration
98123

0 commit comments

Comments
 (0)