Skip to content

Commit 429d53b

Browse files
committed
update proto snippets in kms v2
Signed-off-by: Anish Ramasekar <[email protected]>
1 parent b06dcfb commit 429d53b

File tree

1 file changed

+14
-20
lines changed
  • keps/sig-auth/3299-kms-v2-improvements

1 file changed

+14
-20
lines changed

keps/sig-auth/3299-kms-v2-improvements/README.md

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -150,25 +150,25 @@ Key Hierarchy in KMS plugin (reference implementation):
150150

151151
Since key hierarchy is implemented at the KMS plugin level, it should be seamless for the kube-apiserver. So whether the plugin is using a key hierarchy or not, the kube-apiserver should behave the same.
152152

153-
What is required of the kube-apiserver is to be able to tell the KMS plugin which KEK (local KEK or KMS KEK) it should use to decrypt the incoming DEK. To do so, upon encryption, the KMS plugin could provide the encrypted local KEK as part of the `annotations` field in the `EncryptResponse`. The kube-apiserver would then store it in etcd next to the DEK. Upon decryption, the kube-apiserver provides the encrypted local KEK in `annotations` and `observed_key_id` from the last encryption when calling Decrypt. In case no encrypted local KEK is provided in the `annotations`, then we can assume key hierarchy is not used. The KMS plugin would query the external KMS to use the remote KEK to decrypt the DEK (same behavior as today). No state coordination is required between different instances of the KMS plugin.
153+
What is required of the kube-apiserver is to be able to tell the KMS plugin which KEK (local KEK or KMS KEK) it should use to decrypt the incoming DEK. To do so, upon encryption, the KMS plugin could provide the encrypted local KEK as part of the `annotations` field in the `EncryptResponse`. The kube-apiserver would then store it in etcd next to the DEK. Upon decryption, the kube-apiserver provides the encrypted local KEK in `annotations` and `key_id` from the last encryption when calling Decrypt. In case no encrypted local KEK is provided in the `annotations`, then we can assume key hierarchy is not used. The KMS plugin would query the external KMS to use the remote KEK to decrypt the DEK (same behavior as today). No state coordination is required between different instances of the KMS plugin.
154154

155155
For the reference KMS plugin, the encrypted local KEK is stored in etcd via the `annotations` field, and once decrypted, it can be stored in memory as part of the KMS plugin cache to be used for encryption and decryption of DEKs. The encrypted local KEK is used as the key and the decrypted local KEK is stored as the value.
156156

157157
```proto
158158
message EncryptResponse {
159159
// The encrypted data.
160160
bytes ciphertext = 1;
161-
// The KMS key ID used for encryption operations.
162-
// This can be used to drive rotation.
161+
// The KMS key ID used to encrypt the data. This must always refer to the KMS KEK and not any local KEKs that may be in use.
162+
// This can be used to inform staleness of data updated via value.Transformer.TransformFromStorage.
163163
string key_id = 2;
164164
// Additional metadata to be stored with the encrypted data.
165-
// The annotations can contain the encrypted local KEK that was used to encrypt the DEK.
166-
// Stored unencrypted in etcd.
165+
// This metadata can contain the encrypted local KEK that was used to encrypt the DEK.
166+
// This data is stored in plaintext in etcd. KMS plugin implementations are responsible for pre-encrypting any sensitive data.
167167
map<string, bytes> annotations = 3;
168168
}
169169
```
170170

171-
The `DecryptRequest` passes the same `key_id` and `annotations` returned by the previous `EncryptResponse` of this data as its `observed_key_id` and `metadata` for the decryption request.
171+
The `DecryptRequest` passes the same `key_id` and `annotations` returned by the previous `EncryptResponse` of this data as its `key_id` and `metadata` for the decryption request.
172172

173173
```proto
174174
message DecryptRequest {
@@ -178,18 +178,14 @@ message DecryptRequest {
178178
string uid = 2;
179179
// The keyID that was provided to the apiserver during encryption.
180180
// This represents the KMS KEK that was used to encrypt the data.
181-
string observed_key_id = 3;
181+
string key_id = 3;
182182
// Additional metadata that was sent by the KMS plugin during encryption.
183183
map<string, bytes> annotations = 4;
184184
}
185185
186186
message DecryptResponse {
187187
// The decrypted data.
188188
bytes plaintext = 1;
189-
// The KMS key ID used to decrypt the data.
190-
string key_id = 2;
191-
// Additional metadata that was sent by the KMS plugin.
192-
map<string, bytes> annotations = 3;
193189
}
194190
195191
message EncryptRequest {
@@ -230,13 +226,11 @@ To improve health check reliability, the new StatusResponse provides version, he
230226
message StatusRequest {}
231227
232228
message StatusResponse {
233-
// Version of the KMS plugin API.
229+
// Version of the KMS plugin API. Must match the configured .resources[].providers[].kms.apiVersion
234230
string version = 1;
235-
236-
// anything other than "ok" is failing healthz
231+
// Any value other than "ok" is failing healthz. On failure, the associated API server healthz endpoint will contain this value as part of the error message.
237232
string healthz = 2;
238-
239-
// the current write key, can be used to trigger rotation
233+
// the current write key, used to determine staleness of data updated via value.Transformer.TransformFromStorage.
240234
string key_id = 3;
241235
}
242236
```
@@ -314,7 +308,7 @@ sequenceDiagram
314308
participant externalkms
315309
%% if local KEK in annotations, then using hierarchy
316310
alt encrypted local KEK is in annotations
317-
kubeapiserver->>kmsplugin: decrypt request <br/> {"ciphertext": "<encrypted DEK>", observed_key_id: "<key_id gotten as part of EncryptResponse>", <br/> "annotations": {"kms.kubernetes.io/local-kek": "<encrypted local KEK>"}}
311+
kubeapiserver->>kmsplugin: decrypt request <br/> {"ciphertext": "<encrypted DEK>", key_id: "<key_id gotten as part of EncryptResponse>", <br/> "annotations": {"kms.kubernetes.io/local-kek": "<encrypted local KEK>"}}
318312
alt encrypted local KEK in cache
319313
kmsplugin->>kmsplugin: decrypt DEK with local KEK
320314
else encrypted local KEK not in cache
@@ -325,7 +319,7 @@ sequenceDiagram
325319
end
326320
kmsplugin->>kubeapiserver: return decrypt response <br/> {"plaintext": "<decrypted DEK>", key_id: "<remote KEK ID>", <br/> "annotations": {"kms.kubernetes.io/local-kek": "<encrypted local KEK>"}}
327321
else encrypted local KEK is not in annotations
328-
kubeapiserver->>kmsplugin: decrypt request <br/> {"ciphertext": "<encrypted DEK>", observed_key_id: "<key_id gotten as part of EncryptResponse>", <br/> "annotations": {}}
322+
kubeapiserver->>kmsplugin: decrypt request <br/> {"ciphertext": "<encrypted DEK>", key_id: "<key_id gotten as part of EncryptResponse>", <br/> "annotations": {}}
329323
kmsplugin->>externalkms: decrypt DEK with remote KEK (same behavior as today)
330324
externalkms->>kmsplugin: decrypted DEK
331325
kmsplugin->>kubeapiserver: return decrypt response <br/> {"plaintext": "<decrypted DEK>", key_id: "<remote KEK ID>", <br/> "annotations": {}}
@@ -489,7 +483,7 @@ N/A
489483

490484
- [x] Other (treat as last resort)
491485
- Details:
492-
- Logs in kube-apiserver, kms-plugin and KMS will be logged with the corresponding `observed_key_id`, `annotations`, and `UID`.
486+
- Logs in kube-apiserver, kms-plugin and KMS will be logged with the corresponding `key_id`, `annotations`, and `UID`.
493487
- count of encryption/decryption requests by resource and version
494488

495489
###### What are the reasonable SLOs (Service Level Objectives) for the enhancement?
@@ -500,7 +494,7 @@ There should be no impact on the SLO with this change.
500494

501495
- [x] Other (treat as last resort)
502496
- Details:
503-
- Logs in kube-apiserver, kms-plugin and KMS will be logged with the corresponding `observed_key_id`, `annotations`, and `UID`.
497+
- Logs in kube-apiserver, kms-plugin and KMS will be logged with the corresponding `key_id`, `annotations`, and `UID`.
504498
- Metrics for latency of encryption/decryption requests.
505499

506500
### Dependencies

0 commit comments

Comments
 (0)