Skip to content

Commit 69a5267

Browse files
eramongodbkevinAlbs
authored andcommitted
CDRIVER-4416 Remove createKey in favor of createDataKey (#1052)
* Sync CSE unified test files with 6a015f59 * Remove createKey in favor of createDataKey
1 parent 79ee4b4 commit 69a5267

12 files changed

+62
-120
lines changed

src/libmongoc/doc/mongoc_client_encryption_create_datakey.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,25 @@ Synopsis
1616
bson_value_t *keyid,
1717
bson_error_t *error);
1818
19-
Alias function equivalent to :symbol:`mongoc_client_encryption_create_key`.
19+
Creates a new key document in the key vault collection and sets ``keyid`` to the UUID of the newly created key if ``keyid`` is not NULL. The new key can be used to configure automatic encryption (see :symbol:`mongoc_client_enable_auto_encryption()` and :symbol:`mongoc_client_pool_enable_auto_encryption()`) or for explicit encryption (see :symbol:`mongoc_client_encryption_encrypt()`).
20+
21+
The created key document is inserted into the key vault collection (identified via :symbol:`mongoc_client_encryption_opts_set_keyvault_namespace()`) with majority write concern.
22+
23+
``keyid`` is always initialized (even on error). Caller must call :symbol:`bson_value_destroy()` on ``keyid`` to free.
24+
25+
Parameters
26+
----------
27+
28+
* ``client_encryption``: A :symbol:`mongoc_client_encryption_t`.
29+
* ``kms_provider``: A string identifying the Key Management Service (KMS) provider used to encrypt the datakey (e.g. "aws" or "local").
30+
* ``opts``: A :symbol:`mongoc_client_encryption_datakey_opts_t`
31+
* ``keyid``: Optional. An uninitialized :symbol:`bson_value_t` set to the UUID (BSON binary subtype 0x04) of the newly created key. Must be freed by :symbol:`bson_value_destroy`.
32+
* ``error``: Optional. A :symbol:`bson_error_t`.
33+
34+
Returns
35+
-------
36+
37+
Returns ``true`` if successful. Returns ``false`` and sets ``error`` otherwise.
2038

2139
.. seealso::
2240

src/libmongoc/doc/mongoc_client_encryption_create_key.rst

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/libmongoc/doc/mongoc_client_encryption_datakey_opts_t.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@ Used to set options for :symbol:`mongoc_client_encryption_create_datakey()`.
2929

3030
.. seealso::
3131

32-
| :symbol:`mongoc_client_encryption_create_key()`
3332
| :symbol:`mongoc_client_encryption_create_datakey()`

src/libmongoc/doc/mongoc_client_encryption_delete_key.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ Returns ``true`` if successful. Returns ``false`` and sets ``error`` otherwise.
3333
.. seealso::
3434

3535
| :symbol:`mongoc_client_encryption_t`
36-
| :symbol:`mongoc_client_encryption_create_key`
36+
| :symbol:`mongoc_client_encryption_create_datakey`

src/libmongoc/doc/mongoc_client_encryption_t.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ The key vault client, configured via :symbol:`mongoc_client_encryption_opts_set_
3434

3535
mongoc_client_encryption_new
3636
mongoc_client_encryption_destroy
37-
mongoc_client_encryption_create_key
3837
mongoc_client_encryption_create_datakey
3938
mongoc_client_encryption_rewrap_many_datakey
4039
mongoc_client_encryption_delete_key

src/libmongoc/src/mongoc/mongoc-client-side-encryption.c

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ _mongoc_cse_client_pool_enable_auto_encryption (
594594

595595

596596
bool
597-
mongoc_client_encryption_create_key (
597+
mongoc_client_encryption_create_datakey (
598598
mongoc_client_encryption_t *client_encryption,
599599
const char *kms_provider,
600600
mongoc_client_encryption_datakey_opts_t *opts,
@@ -608,19 +608,6 @@ mongoc_client_encryption_create_key (
608608
}
609609

610610

611-
bool
612-
mongoc_client_encryption_create_datakey (
613-
mongoc_client_encryption_t *client_encryption,
614-
const char *kms_provider,
615-
mongoc_client_encryption_datakey_opts_t *opts,
616-
bson_value_t *keyid,
617-
bson_error_t *error)
618-
{
619-
return mongoc_client_encryption_create_key (
620-
client_encryption, kms_provider, opts, keyid, error);
621-
}
622-
623-
624611
bool
625612
mongoc_client_encryption_rewrap_many_datakey (
626613
mongoc_client_encryption_t *client_encryption,
@@ -1877,7 +1864,7 @@ _coll_has_read_concern_majority (const mongoc_collection_t *coll)
18771864
}
18781865

18791866
bool
1880-
mongoc_client_encryption_create_key (
1867+
mongoc_client_encryption_create_datakey (
18811868
mongoc_client_encryption_t *client_encryption,
18821869
const char *kms_provider,
18831870
mongoc_client_encryption_datakey_opts_t *opts,
@@ -1961,18 +1948,6 @@ mongoc_client_encryption_create_key (
19611948
RETURN (ret);
19621949
}
19631950

1964-
bool
1965-
mongoc_client_encryption_create_datakey (
1966-
mongoc_client_encryption_t *client_encryption,
1967-
const char *kms_provider,
1968-
mongoc_client_encryption_datakey_opts_t *opts,
1969-
bson_value_t *keyid,
1970-
bson_error_t *error)
1971-
{
1972-
return mongoc_client_encryption_create_key (
1973-
client_encryption, kms_provider, opts, keyid, error);
1974-
}
1975-
19761951
bool
19771952
mongoc_client_encryption_rewrap_many_datakey (
19781953
mongoc_client_encryption_t *client_encryption,

src/libmongoc/src/mongoc/mongoc-client-side-encryption.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,6 @@ mongoc_client_encryption_create_datakey (
147147
bson_value_t *keyid,
148148
bson_error_t *error);
149149

150-
MONGOC_EXPORT (bool)
151-
mongoc_client_encryption_create_key (
152-
mongoc_client_encryption_t *client_encryption,
153-
const char *kms_provider,
154-
mongoc_client_encryption_datakey_opts_t *opts,
155-
bson_value_t *keyid,
156-
bson_error_t *error);
157-
158150
MONGOC_EXPORT (bool)
159151
mongoc_client_encryption_rewrap_many_datakey (
160152
mongoc_client_encryption_t *client_encryption,

src/libmongoc/tests/json/client_side_encryption/unified/createKey-kms_providers-invalid.json renamed to src/libmongoc/tests/json/client_side_encryption/unified/createDataKey-kms_providers-invalid.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"description": "createKey-provider-invalid",
2+
"description": "createDataKey-provider-invalid",
33
"schemaVersion": "1.8",
44
"runOnRequirements": [
55
{
@@ -35,7 +35,7 @@
3535
"description": "create data key without required master key fields",
3636
"operations": [
3737
{
38-
"name": "createKey",
38+
"name": "createDataKey",
3939
"object": "clientEncryption0",
4040
"arguments": {
4141
"kmsProvider": "aws",
@@ -59,7 +59,7 @@
5959
"description": "create data key with invalid master key field",
6060
"operations": [
6161
{
62-
"name": "createKey",
62+
"name": "createDataKey",
6363
"object": "clientEncryption0",
6464
"arguments": {
6565
"kmsProvider": "local",
@@ -85,7 +85,7 @@
8585
"description": "create data key with invalid master key",
8686
"operations": [
8787
{
88-
"name": "createKey",
88+
"name": "createDataKey",
8989
"object": "clientEncryption0",
9090
"arguments": {
9191
"kmsProvider": "aws",

src/libmongoc/tests/json/client_side_encryption/unified/createKey.json renamed to src/libmongoc/tests/json/client_side_encryption/unified/createDataKey.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"description": "createKey",
2+
"description": "createDataKey",
33
"schemaVersion": "1.8",
44
"runOnRequirements": [
55
{
@@ -90,7 +90,7 @@
9090
"description": "create data key with AWS KMS provider",
9191
"operations": [
9292
{
93-
"name": "createKey",
93+
"name": "createDataKey",
9494
"object": "clientEncryption0",
9595
"arguments": {
9696
"kmsProvider": "aws",
@@ -153,7 +153,7 @@
153153
"description": "create datakey with Azure KMS provider",
154154
"operations": [
155155
{
156-
"name": "createKey",
156+
"name": "createDataKey",
157157
"object": "clientEncryption0",
158158
"arguments": {
159159
"kmsProvider": "azure",
@@ -216,7 +216,7 @@
216216
"description": "create datakey with GCP KMS provider",
217217
"operations": [
218218
{
219-
"name": "createKey",
219+
"name": "createDataKey",
220220
"object": "clientEncryption0",
221221
"arguments": {
222222
"kmsProvider": "gcp",
@@ -283,7 +283,7 @@
283283
"description": "create datakey with KMIP KMS provider",
284284
"operations": [
285285
{
286-
"name": "createKey",
286+
"name": "createDataKey",
287287
"object": "clientEncryption0",
288288
"arguments": {
289289
"kmsProvider": "kmip"
@@ -341,7 +341,7 @@
341341
"description": "create datakey with local KMS provider",
342342
"operations": [
343343
{
344-
"name": "createKey",
344+
"name": "createDataKey",
345345
"object": "clientEncryption0",
346346
"arguments": {
347347
"kmsProvider": "local"
@@ -396,7 +396,7 @@
396396
"description": "create datakey with no keyAltName",
397397
"operations": [
398398
{
399-
"name": "createKey",
399+
"name": "createDataKey",
400400
"object": "clientEncryption0",
401401
"arguments": {
402402
"kmsProvider": "local",
@@ -457,7 +457,7 @@
457457
"description": "create datakey with single keyAltName",
458458
"operations": [
459459
{
460-
"name": "createKey",
460+
"name": "createDataKey",
461461
"object": "clientEncryption0",
462462
"arguments": {
463463
"kmsProvider": "local",
@@ -520,7 +520,7 @@
520520
"description": "create datakey with multiple keyAltNames",
521521
"operations": [
522522
{
523-
"name": "createKey",
523+
"name": "createDataKey",
524524
"object": "clientEncryption0",
525525
"arguments": {
526526
"kmsProvider": "local",
@@ -619,7 +619,7 @@
619619
"description": "create datakey with custom key material",
620620
"operations": [
621621
{
622-
"name": "createKey",
622+
"name": "createDataKey",
623623
"object": "clientEncryption0",
624624
"arguments": {
625625
"kmsProvider": "local",
@@ -682,7 +682,7 @@
682682
"description": "create datakey with invalid custom key material (too short)",
683683
"operations": [
684684
{
685-
"name": "createKey",
685+
"name": "createDataKey",
686686
"object": "clientEncryption0",
687687
"arguments": {
688688
"kmsProvider": "local",

src/libmongoc/tests/json/client_side_encryption/unified/getKeys.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"description": "getKeys with single key documents",
8888
"operations": [
8989
{
90-
"name": "createKey",
90+
"name": "createDataKey",
9191
"object": "clientEncryption0",
9292
"arguments": {
9393
"kmsProvider": "local",
@@ -160,7 +160,7 @@
160160
"description": "getKeys with many key documents",
161161
"operations": [
162162
{
163-
"name": "createKey",
163+
"name": "createDataKey",
164164
"object": "clientEncryption0",
165165
"arguments": {
166166
"kmsProvider": "local"
@@ -170,7 +170,7 @@
170170
}
171171
},
172172
{
173-
"name": "createKey",
173+
"name": "createDataKey",
174174
"object": "clientEncryption0",
175175
"arguments": {
176176
"kmsProvider": "local"

0 commit comments

Comments
 (0)