-
Notifications
You must be signed in to change notification settings - Fork 100
MONGOCRYPT-432 Allow keyAltName in encryptedFieldsMap #1091
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| mongocrypt_status_destroy(status); | ||
| } | ||
|
|
||
| static void _test_qe_keyAltName(_mongocrypt_tester_t *tester) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect the "create" command is not translating a "keyAltName":
{
"create": "coll",
"encryptedFields": {
"fields": [
{
"path": "secret",
"bsonType": "string",
"keyAltName": "keyDocumentName"
}
]
}
}See this test to exercise this scenario.
Without support for the "create" command or ClientEncryption.createEncryptedCollection helper, I expect keyAltName may be difficult to use (creation would still require a key ID).
If this is a significant effort, consider filing a MONGOCRYPT ticket to track supporting "create", and update the scope to note this as future work.
| mongocrypt_binary_t *encrypted_fields_map = TEST_BSON_STR(BSON_STR({ | ||
| "db.coll" : {"fields" : [ {"path" : "secret", "bsonType" : "string", "keyAltName" : "keyDocumentName"} ]} | ||
| })); | ||
| mongocrypt_setopt_encrypted_field_config_map(crypt, encrypted_fields_map); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| mongocrypt_setopt_encrypted_field_config_map(crypt, encrypted_fields_map); | |
| ASSERT_OK(mongocrypt_setopt_encrypted_field_config_map(crypt, encrypted_fields_map), crypt); |
| } | ||
| mongocrypt_ctx_destroy(ctx); | ||
|
|
||
| ctx = mongocrypt_ctx_new(crypt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest noting purpose of encrypting again:
| ctx = mongocrypt_ctx_new(crypt); | |
| // Encrypt again to test flow where key is cached. | |
| ctx = mongocrypt_ctx_new(crypt); |
| } | ||
| mongocrypt_ctx_destroy(ctx); | ||
|
|
||
| // COPY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // COPY | |
| // Encrypt again to test flow where key is cached. |
| const mc_EncryptedFieldConfig_t * | ||
| mc_schema_broker_get_encryptedFields(const mc_schema_broker_t *sb, const char *coll, mongocrypt_status_t *status); | ||
|
|
||
| // mc_schema_broker_get_encryptedFields returns encryptedFields for a collection if any exists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // mc_schema_broker_get_encryptedFields returns encryptedFields for a collection if any exists. | |
| // mc_schema_broker_maybe_get_encryptedFields returns encryptedFields for a collection if any exists. |
| ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx); | ||
| } | ||
|
|
||
| // MONGOCRYPT_CTX_MARKINGS is entered to send command to mongocryptd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When mongocrypt_setopt_bypass_query_analysis is called, the MONGOCRYPT_CTX_MARKINGS state appears to be incorrectly entered. See this test.
Background
Adds
keyAltNametokeyIdclient-side translation to libmongocrypt that allows users to specify human-readablekeyAltNamestrings instead of binary key IDs.Implementation
Whenever
encryptionInformationis appended to at outgoing command, libmongocrypt looks through the encrypted fields forkeyAltNamefields and translates them tokeyId.Testing
Tested on the C driver with spec test: https://spruce.mongodb.com/version/697803dbc0c964000764d2a4/