You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -84,6 +85,30 @@ So that we can supply custom trust or use insecure testing modes (mock servers u
84
85
85
86
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
86
87
88
+
### Key Identifiers
89
+
90
+
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.
91
+
92
+
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
93
+
94
+
> For Vaults: https://{vault-name}.vault.azure.net/{object-type}/{object-name}/{object-version}
The Azure SDK then takes advantage of the fact this happens to be the base URL for various operations like wrap/unwrap.
99
+
100
+
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
101
+
`
102
+
103
+
To minimise EDEK bytes there are a couple of opportunities when encoding the EDEK:
104
+
1. we can exclude the vaultBaseUrl and have the limitation that we work only with a single key vault
105
+
2. we can encode just the keyName and keyVersion, and use that to decrypt
106
+
3. all documented examples of the keyVersion (and from my experimentation too) are 128bits encoded as a hexadecimal string.
107
+
108
+
So for the EDEK I think we could optimistically try to encode it as `versionByte,keyNameLength,keyName,keyVersionLength,128-bit-decoded,edek`
109
+
and fall back to using the string like `versionByte,keyNameLength,keyName,keyVersionLength,keyVersionString,edek`. So
110
+
we would have either a 16-byte version implying it's the bytes, or a 32 character string.
111
+
87
112
## Proposed Initial Implementation
88
113
89
114
1. Support all flavours of Key Vault. The APIs will be the same, just with a different vault base URI.
@@ -93,6 +118,7 @@ Another difference is that basic Key Vault cannot generate the DEK bytes for us.
93
118
5. Support TLS customization of the authentication client and key vault client.
94
119
6. DEK bytes will be generated proxy-side with a SecureRandom.
95
120
7. The Azure SDK pulls in netty/jackson/project-reactor, lets try implementing the APIs ourselves as we have for AWS
121
+
8. Edek stores the keyName, keyVersion, edek. We attempt to minimise keyVersion size by optimistically decoding it from hex string, else store the string.
0 commit comments