libmongocrypt-helper 1.7.4.0.1002 → 1.8.0.0.1001
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +9 -7
- data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +17 -23
- data/ext/libmongocrypt/libmongocrypt/Earthfile +374 -0
- data/ext/libmongocrypt/libmongocrypt/README.md +7 -7
- data/ext/libmongocrypt/libmongocrypt/VERSION_CURRENT +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClient.cs +25 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Library.cs +25 -3
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Example/MongoDB.Libmongocrypt.Example.csproj +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/BasicTests.cs +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.cake +3 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/cs.sln +79 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/build.gradle.kts +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java +6 -4
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/CHANGELOG.md +24 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/README.md +134 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/build-static.sh +3 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/node/index.d.ts +203 -77
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/autoEncrypter.js +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/clientEncryption.js +165 -43
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/common.js +12 -14
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/errors.js +75 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/index.js +34 -3
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/aws.js +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/azure.js +178 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/gcp.js +24 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/index.js +54 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/utils.js +39 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/stateMachine.js +9 -4
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package-lock.json +4440 -5189
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package.json +27 -8
- data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.cc +65 -38
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/autoEncrypter.test.js +4 -7
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/clientEncryption.test.js +434 -42
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/common.test.js +94 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/cryptoCallbacks.test.js +1 -45
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/index.test.js +45 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/mongocryptdManager.test.js +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/providers/credentialsProvider.test.js +551 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/release.test.js +10 -3
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/requirements.helper.js +23 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/stateMachine.test.js +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/chai-addons.js +8 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/types/index.test-d.ts +63 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/README.rst +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/build-manylinux-wheel.sh +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +128 -238
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/compat.py +0 -27
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/explicit_encrypter.py +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +5 -21
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/release.sh +5 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/python/setup.py +14 -9
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/__init__.py +1 -10
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_mongocrypt.py +5 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test-requirements.txt +4 -12
- data/ext/libmongocrypt/libmongocrypt/cmake/ImportBSON.cmake +8 -6
- data/ext/libmongocrypt/libmongocrypt/cmake/IntelDFP.cmake +2 -1
- data/ext/libmongocrypt/libmongocrypt/cmake/Platform.cmake +50 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/mongocrypt-config.cmake +21 -0
- data/ext/libmongocrypt/libmongocrypt/debian/gbp.conf +2 -2
- data/ext/libmongocrypt/libmongocrypt/etc/c6-vault.repo +39 -0
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_aead_generate_tests.py +15 -24
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_crypto.py +66 -54
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_generate_tests.py +14 -23
- data/ext/libmongocrypt/libmongocrypt/etc/fle2v2_aead_generate_tests.py +32 -0
- data/ext/libmongocrypt/libmongocrypt/etc/format-all.sh +12 -0
- data/ext/libmongocrypt/libmongocrypt/etc/format.sh +16 -0
- data/ext/libmongocrypt/libmongocrypt/etc/install-package.sh +48 -0
- data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-libmongocrypt-pr-625.patch +13 -0
- data/ext/libmongocrypt/libmongocrypt/src/crypto/cng.c +381 -436
- data/ext/libmongocrypt/libmongocrypt/src/crypto/commoncrypto.c +162 -227
- data/ext/libmongocrypt/libmongocrypt/src/crypto/libcrypto.c +180 -248
- data/ext/libmongocrypt/libmongocrypt/src/crypto/none.c +33 -55
- data/ext/libmongocrypt/libmongocrypt/src/csfle-markup.cpp +175 -205
- data/ext/libmongocrypt/libmongocrypt/src/mc-array-private.h +10 -21
- data/ext/libmongocrypt/libmongocrypt/src/mc-array.c +44 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-check-conversions-private.h +4 -8
- data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.h +351 -463
- data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.test.cpp +59 -66
- data/ext/libmongocrypt/libmongocrypt/src/mc-efc-private.h +7 -11
- data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +80 -92
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle-blob-subtype-private.h +18 -10
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +59 -70
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +384 -439
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private-v2.h +41 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private.h +11 -18
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-v2.c +135 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload.c +109 -126
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private-v2.h +88 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private.h +24 -27
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-v2.c +137 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload.c +106 -125
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private-v2.h +117 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private.h +28 -36
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-v2.c +294 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload.c +237 -278
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private-v2.h +133 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private.h +67 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-v2.c +437 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev.c +476 -325
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common-private.h +69 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common.c +182 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-private.h +23 -31
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2-private.h +85 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2.c +142 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev.c +104 -231
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-range-operator-private.h +8 -7
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds-private.h +55 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +517 -580
- data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +36 -66
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +57 -76
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +158 -189
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +36 -42
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +515 -558
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +155 -191
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +43 -53
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +170 -240
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +29 -34
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +289 -338
- data/ext/libmongocrypt/libmongocrypt/src/mc-reader-private.h +36 -71
- data/ext/libmongocrypt/libmongocrypt/src/mc-reader.c +111 -164
- data/ext/libmongocrypt/libmongocrypt/src/mc-tokens-private.h +55 -49
- data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +109 -125
- data/ext/libmongocrypt/libmongocrypt/src/mc-writer-private.h +66 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-writer.c +141 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/check.hpp +37 -55
- data/ext/libmongocrypt/libmongocrypt/src/mlib/endian.h +11 -11
- data/ext/libmongocrypt/libmongocrypt/src/mlib/error.h +27 -32
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.h +444 -499
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +251 -334
- data/ext/libmongocrypt/libmongocrypt/src/mlib/macros.h +4 -5
- data/ext/libmongocrypt/libmongocrypt/src/mlib/path.h +196 -231
- data/ext/libmongocrypt/libmongocrypt/src/mlib/path.test.c +56 -79
- data/ext/libmongocrypt/libmongocrypt/src/mlib/str.h +411 -530
- data/ext/libmongocrypt/libmongocrypt/src/mlib/str.test.c +116 -131
- data/ext/libmongocrypt/libmongocrypt/src/mlib/thread.h +17 -26
- data/ext/libmongocrypt/libmongocrypt/src/mlib/user-check.h +2 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary-private.h +3 -6
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary.c +31 -48
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer-private.h +55 -131
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer.c +444 -565
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo-private.h +1 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo.c +28 -45
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key-private.h +11 -17
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key.c +103 -132
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth-private.h +8 -14
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth.c +78 -90
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-private.h +26 -45
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache.c +220 -273
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext-private.h +13 -25
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext.c +147 -166
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-compat.h +2 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto-private.h +110 -204
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto.c +1137 -1565
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +425 -472
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +817 -694
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +2394 -2697
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-private.h +166 -186
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-rewrap-many-datakey.c +308 -351
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +921 -1138
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +16 -24
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endian-private.h +44 -58
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint-private.h +21 -25
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint.c +167 -181
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek-private.h +37 -43
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek.c +215 -253
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker-private.h +73 -108
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +889 -1034
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-private.h +27 -44
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key.c +349 -402
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx-private.h +92 -120
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx.c +1397 -1612
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log-private.h +35 -67
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log.c +49 -83
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking-private.h +30 -36
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +1821 -1470
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-mutex-private.h +7 -12
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +80 -108
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +354 -424
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +101 -117
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status-private.h +3 -8
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status.c +92 -119
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util-private.h +19 -29
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util.c +136 -176
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util-private.h +11 -21
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util.c +96 -135
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +1092 -1320
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +130 -295
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +66 -78
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_mutex.c +20 -28
- data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +60 -73
- data/ext/libmongocrypt/libmongocrypt/src/os_win/os_mutex.c +8 -16
- data/ext/libmongocrypt/libmongocrypt/test/crypt_shared-stub.cpp +57 -87
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/encrypted-payload-v2.json +60 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/encrypted-payload-v2.json +67 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/encrypted-payload.json +2 -2
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-contentionFactor1-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-contentionFactor1-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-same-user-and-index-key-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-field-map.json +22 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-payload.json +40 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/mongocryptd-reply.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/cmd.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-payload.json +50 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/mongocryptd-reply.json +58 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/encrypted-payload-v2.json +16 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert/cmd.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/RNG_DATA.h +65 -65
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/cmd.json +13 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/RNG_DATA.h +132 -132
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/RNG_DATA.h +71 -71
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-payload.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/mongocryptd-reply.json +61 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/RNG_DATA.h +68 -68
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/RNG_DATA.h +19 -19
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-payload.json +47 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/mongocryptd-reply.json +55 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/RNG_DATA.h +25 -25
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/RNG_DATA.h +65 -65
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/RNG_DATA.h +68 -68
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/RNG_DATA.h +19 -19
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/RNG_DATA.h +25 -25
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/RNG_DATA.h +15 -15
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-field-map.json +18 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-payload.json +14 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/mongocryptd-reply.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-field-map.json +22 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-payload.json +39 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneRangeV2.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneV2.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/README.md +17 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/aes-ctr.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-fixed.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-generated.json +38 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-decrypt.json +35 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-fixed.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-generated.json +122 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-fixed.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-generated.json +122 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/mcgrew.json +12 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/nist.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/README.md +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/mc.json +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/server.json +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/example-no-bson.c +4 -4
- data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +278 -323
- data/ext/libmongocrypt/libmongocrypt/test/fuzz_kms.c +8 -7
- data/ext/libmongocrypt/libmongocrypt/test/test-dll.cpp +6 -7
- data/ext/libmongocrypt/libmongocrypt/test/test-gcp-auth.c +221 -283
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-efc.c +58 -73
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-equality-payload-v2.c +78 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-range-payload-v2.c +89 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev-v2.c +248 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev.c +467 -414
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup-v2.c +172 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup.c +141 -159
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev-v2.c +338 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev.c +238 -176
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-rfds.c +373 -474
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-edge-generation.c +346 -388
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +708 -825
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +417 -481
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +110 -144
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-reader.c +124 -207
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +223 -213
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-writer.c +176 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +634 -807
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.h +1 -2
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert.h +168 -189
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-buffer.c +187 -211
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache-oauth.c +34 -36
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache.c +210 -233
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ciphertext.c +185 -220
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-compact.c +331 -445
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +670 -814
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +102 -135
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.h +54 -71
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto.c +394 -846
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-csfle-lib.c +159 -183
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-decrypt.c +867 -1045
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +4349 -4713
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +750 -964
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +991 -1178
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +342 -419
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-dll.c +23 -30
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-endpoint.c +98 -111
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kek.c +49 -52
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-broker.c +770 -920
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-cache.c +354 -407
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key.c +197 -245
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-ctx.c +286 -370
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-responses.c +147 -166
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-local-kms.c +50 -61
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-log.c +85 -100
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-marking.c +656 -692
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-status.c +46 -58
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-traverse-util.c +377 -451
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.c +48 -67
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.h +4 -10
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +827 -918
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +111 -172
- data/ext/libmongocrypt/libmongocrypt/test/util/csfle.c +508 -559
- data/ext/libmongocrypt/libmongocrypt/test/util/util.c +735 -881
- data/ext/libmongocrypt/libmongocrypt/test/util/util.h +33 -55
- data/lib/libmongocrypt_helper/version.rb +2 -2
- data.tar.gz.sig +0 -0
- metadata +154 -26
- metadata.gz.sig +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/key-document.json +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/credentialsProvider.js +0 -33
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/credentialsProvider.test.js +0 -163
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/test/data/aes-ctr.cstructs +0 -359
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-aead.cstructs +0 -109
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/rangeopts.json +0 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/value-to-encrypt.json +0 -20
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/RNG_DATA.h +0 -70
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload.json +0 -8
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/rangeopts.json +0 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/value-to-encrypt.json +0 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2.cstructs +0 -33
- /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/key-filter.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/rangeopts.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/value-to-encrypt.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/rangeopts.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/value-to-encrypt.json +0 -0
@@ -16,474 +16,397 @@
|
|
16
16
|
|
17
17
|
#include <mongocrypt.h>
|
18
18
|
|
19
|
+
#include "mongocrypt-crypto-private.h"
|
19
20
|
#include "mongocrypt-private.h"
|
20
21
|
#include "test-mongocrypt.h"
|
21
|
-
#include "mongocrypt-crypto-private.h"
|
22
22
|
|
23
|
-
static void
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
out->data = bson_malloc0 (out->len);
|
28
|
-
BSON_ASSERT (out->data);
|
23
|
+
static void _init_buffer_with_count(_mongocrypt_buffer_t *out, uint32_t count) {
|
24
|
+
out->len = count;
|
25
|
+
out->data = bson_malloc0(out->len);
|
26
|
+
BSON_ASSERT(out->data);
|
29
27
|
|
30
|
-
|
28
|
+
out->owned = true;
|
31
29
|
}
|
32
30
|
|
33
|
-
static void
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
_mongocrypt_buffer_t out;
|
38
|
-
mongocrypt_status_t *status;
|
31
|
+
static void _test_random_generator(_mongocrypt_tester_t *tester) {
|
32
|
+
mongocrypt_t *crypt;
|
33
|
+
_mongocrypt_buffer_t out;
|
34
|
+
mongocrypt_status_t *status;
|
39
35
|
#define TEST_COUNT 32
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
crypt = _mongocrypt_tester_mongocrypt (TESTER_MONGOCRYPT_DEFAULT);
|
36
|
+
int mid = TEST_COUNT / 2;
|
37
|
+
char zero[TEST_COUNT];
|
44
38
|
|
45
|
-
|
46
|
-
* than the buffer by throwing an error. Because of that, no additional tests
|
47
|
-
* for this case is needed here. */
|
39
|
+
crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
48
40
|
|
49
|
-
|
50
|
-
|
51
|
-
|
41
|
+
/* _mongocrypt_random handles the case where the count size is greater
|
42
|
+
* than the buffer by throwing an error. Because of that, no additional tests
|
43
|
+
* for this case is needed here. */
|
52
44
|
|
53
|
-
|
54
|
-
|
45
|
+
memset(zero, 0, TEST_COUNT);
|
46
|
+
status = mongocrypt_status_new();
|
47
|
+
_init_buffer_with_count(&out, TEST_COUNT);
|
55
48
|
|
56
|
-
|
57
|
-
|
49
|
+
BSON_ASSERT(_mongocrypt_random(crypt->crypto, &out, TEST_COUNT, status));
|
50
|
+
BSON_ASSERT(0 != memcmp(zero, out.data, TEST_COUNT)); /* initialized */
|
58
51
|
|
59
|
-
|
60
|
-
|
52
|
+
mongocrypt_status_destroy(status);
|
53
|
+
_mongocrypt_buffer_cleanup(&out);
|
61
54
|
|
62
|
-
|
63
|
-
|
64
|
-
"out should have length 16");
|
55
|
+
status = mongocrypt_status_new();
|
56
|
+
_init_buffer_with_count(&out, TEST_COUNT);
|
65
57
|
|
58
|
+
ASSERT_FAILS_STATUS(_mongocrypt_random(crypt->crypto, &out, mid, status), status, "out should have length 16");
|
66
59
|
|
67
|
-
|
68
|
-
|
69
|
-
|
60
|
+
mongocrypt_status_destroy(status);
|
61
|
+
_mongocrypt_buffer_cleanup(&out);
|
62
|
+
mongocrypt_destroy(crypt);
|
70
63
|
}
|
71
64
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
BSON_ASSERT (bson_iter_init (&iter, &as_bson));
|
166
|
-
BSON_ASSERT (
|
167
|
-
bson_iter_find_descendant (&iter, "masterKey.region", &iter));
|
168
|
-
BSON_ASSERT (BSON_ITER_HOLDS_UTF8 (&iter));
|
169
|
-
BSON_ASSERT (0 == strcmp ("region", bson_iter_utf8 (&iter, NULL)));
|
170
|
-
BSON_ASSERT (bson_iter_init (&iter, &as_bson));
|
171
|
-
BSON_ASSERT (bson_iter_find_descendant (&iter, "masterKey.key", &iter));
|
172
|
-
BSON_ASSERT (BSON_ITER_HOLDS_UTF8 (&iter));
|
173
|
-
BSON_ASSERT (0 == strcmp ("cmk", bson_iter_utf8 (&iter, NULL)));
|
174
|
-
} else {
|
175
|
-
BSON_ASSERT (0 == strcmp ("local", bson_iter_utf8 (&iter, NULL)));
|
176
|
-
}
|
177
|
-
mongocrypt_binary_destroy (bin);
|
178
|
-
mongocrypt_ctx_destroy (ctx);
|
179
|
-
mongocrypt_destroy (crypt);
|
65
|
+
static void _test_create_data_key_with_provider(_mongocrypt_tester_t *tester,
|
66
|
+
_mongocrypt_kms_provider_t provider,
|
67
|
+
bool with_alt_name) {
|
68
|
+
mongocrypt_t *crypt;
|
69
|
+
mongocrypt_ctx_t *ctx;
|
70
|
+
mongocrypt_kms_ctx_t *kms;
|
71
|
+
mongocrypt_binary_t *bin;
|
72
|
+
bson_t as_bson;
|
73
|
+
bson_iter_t iter;
|
74
|
+
_mongocrypt_buffer_t buf;
|
75
|
+
int64_t created_date;
|
76
|
+
const int64_t current_epoch_time_ms = 1565097975532ll; /* the time this code was written */
|
77
|
+
const int64_t one_hundred_years_ms = (int64_t)1000ll * 60ll * 60ll * 24ll * 365ll * 100ll;
|
78
|
+
|
79
|
+
crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
80
|
+
ctx = mongocrypt_ctx_new(crypt);
|
81
|
+
if (provider == MONGOCRYPT_KMS_PROVIDER_AWS) {
|
82
|
+
ASSERT_OK(mongocrypt_ctx_setopt_masterkey_aws(ctx, "region", -1, "cmk", -1), ctx);
|
83
|
+
} else {
|
84
|
+
ASSERT_OK(mongocrypt_ctx_setopt_masterkey_local(ctx), ctx);
|
85
|
+
}
|
86
|
+
|
87
|
+
if (with_alt_name) {
|
88
|
+
ASSERT_OK(mongocrypt_ctx_setopt_key_alt_name(ctx, TEST_BSON("{'keyAltName': 'b'}")), ctx);
|
89
|
+
ASSERT_OK(mongocrypt_ctx_setopt_key_alt_name(ctx, TEST_BSON("{'keyAltName': 'a'}")), ctx);
|
90
|
+
}
|
91
|
+
|
92
|
+
ASSERT_OK(mongocrypt_ctx_datakey_init(ctx), ctx);
|
93
|
+
if (provider == MONGOCRYPT_KMS_PROVIDER_AWS) {
|
94
|
+
BSON_ASSERT(mongocrypt_ctx_state(ctx) == MONGOCRYPT_CTX_NEED_KMS);
|
95
|
+
kms = mongocrypt_ctx_next_kms_ctx(ctx);
|
96
|
+
BSON_ASSERT(kms);
|
97
|
+
ASSERT_OK(mongocrypt_kms_ctx_feed(kms, TEST_FILE("./test/data/kms-encrypt-reply.txt")), kms);
|
98
|
+
BSON_ASSERT(0 == mongocrypt_kms_ctx_bytes_needed(kms));
|
99
|
+
ASSERT_OK(mongocrypt_ctx_kms_done(ctx), ctx);
|
100
|
+
}
|
101
|
+
BSON_ASSERT(mongocrypt_ctx_state(ctx) == MONGOCRYPT_CTX_READY);
|
102
|
+
bin = mongocrypt_binary_new();
|
103
|
+
ASSERT_OK(mongocrypt_ctx_finalize(ctx, bin), ctx);
|
104
|
+
/* Check the BSON document created. */
|
105
|
+
BSON_ASSERT(_mongocrypt_binary_to_bson(bin, &as_bson));
|
106
|
+
CRYPT_TRACEF(&crypt->log, "created data key: %s\n", tmp_json(&as_bson));
|
107
|
+
/* _id is a UUID */
|
108
|
+
BSON_ASSERT(bson_iter_init_find(&iter, &as_bson, "_id"));
|
109
|
+
BSON_ASSERT(_mongocrypt_buffer_from_binary_iter(&buf, &iter));
|
110
|
+
BSON_ASSERT(buf.subtype == BSON_SUBTYPE_UUID);
|
111
|
+
/* keyMaterial is a binary blob of >= KEYMATERIAL_LEN bytes. */
|
112
|
+
BSON_ASSERT(bson_iter_init_find(&iter, &as_bson, "keyMaterial"));
|
113
|
+
BSON_ASSERT(_mongocrypt_buffer_from_binary_iter(&buf, &iter));
|
114
|
+
BSON_ASSERT(buf.subtype == BSON_SUBTYPE_BINARY);
|
115
|
+
BSON_ASSERT(buf.len >= MONGOCRYPT_KEY_LEN);
|
116
|
+
/* creationDate and updatedDate exist and have the same value. */
|
117
|
+
BSON_ASSERT(bson_iter_init_find(&iter, &as_bson, "creationDate"));
|
118
|
+
BSON_ASSERT(BSON_ITER_HOLDS_DATE_TIME(&iter));
|
119
|
+
created_date = bson_iter_date_time(&iter);
|
120
|
+
BSON_ASSERT(created_date > current_epoch_time_ms && created_date < current_epoch_time_ms + one_hundred_years_ms);
|
121
|
+
BSON_ASSERT(bson_iter_init_find(&iter, &as_bson, "updateDate"));
|
122
|
+
BSON_ASSERT(BSON_ITER_HOLDS_DATE_TIME(&iter));
|
123
|
+
BSON_ASSERT(created_date == bson_iter_date_time(&iter));
|
124
|
+
if (with_alt_name) {
|
125
|
+
BSON_ASSERT(bson_iter_init(&iter, &as_bson));
|
126
|
+
BSON_ASSERT(bson_iter_find_descendant(&iter, "keyAltNames.0", &iter));
|
127
|
+
BSON_ASSERT(BSON_ITER_HOLDS_UTF8(&iter));
|
128
|
+
BSON_ASSERT(0 == strcmp(bson_iter_utf8(&iter, NULL), "a"));
|
129
|
+
BSON_ASSERT(bson_iter_init(&iter, &as_bson));
|
130
|
+
BSON_ASSERT(bson_iter_find_descendant(&iter, "keyAltNames.1", &iter));
|
131
|
+
BSON_ASSERT(BSON_ITER_HOLDS_UTF8(&iter));
|
132
|
+
BSON_ASSERT(0 == strcmp(bson_iter_utf8(&iter, NULL), "b"));
|
133
|
+
BSON_ASSERT(BSON_ITER_HOLDS_UTF8(&iter));
|
134
|
+
} else {
|
135
|
+
BSON_ASSERT(!bson_iter_init_find(&iter, &as_bson, "keyAltNames"));
|
136
|
+
}
|
137
|
+
|
138
|
+
/* masterKey matches set options. */
|
139
|
+
BSON_ASSERT(bson_iter_init(&iter, &as_bson));
|
140
|
+
BSON_ASSERT(bson_iter_find_descendant(&iter, "masterKey.provider", &iter));
|
141
|
+
BSON_ASSERT(BSON_ITER_HOLDS_UTF8(&iter));
|
142
|
+
if (provider == MONGOCRYPT_KMS_PROVIDER_AWS) {
|
143
|
+
BSON_ASSERT(0 == strcmp("aws", bson_iter_utf8(&iter, NULL)));
|
144
|
+
BSON_ASSERT(bson_iter_init(&iter, &as_bson));
|
145
|
+
BSON_ASSERT(bson_iter_find_descendant(&iter, "masterKey.region", &iter));
|
146
|
+
BSON_ASSERT(BSON_ITER_HOLDS_UTF8(&iter));
|
147
|
+
BSON_ASSERT(0 == strcmp("region", bson_iter_utf8(&iter, NULL)));
|
148
|
+
BSON_ASSERT(bson_iter_init(&iter, &as_bson));
|
149
|
+
BSON_ASSERT(bson_iter_find_descendant(&iter, "masterKey.key", &iter));
|
150
|
+
BSON_ASSERT(BSON_ITER_HOLDS_UTF8(&iter));
|
151
|
+
BSON_ASSERT(0 == strcmp("cmk", bson_iter_utf8(&iter, NULL)));
|
152
|
+
} else {
|
153
|
+
BSON_ASSERT(0 == strcmp("local", bson_iter_utf8(&iter, NULL)));
|
154
|
+
}
|
155
|
+
mongocrypt_binary_destroy(bin);
|
156
|
+
mongocrypt_ctx_destroy(ctx);
|
157
|
+
mongocrypt_destroy(crypt);
|
180
158
|
}
|
181
159
|
|
182
|
-
static void
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
BSON_ASSERT (bson_iter_init (&iter, &key_bson));
|
221
|
-
BSON_ASSERT (bson_iter_find_descendant (&iter, "masterKey.endpoint", &iter));
|
222
|
-
BSON_ASSERT (0 == strcmp (bson_iter_utf8 (&iter, NULL), "example.com"));
|
223
|
-
|
224
|
-
mongocrypt_binary_destroy (bin);
|
225
|
-
mongocrypt_ctx_destroy (ctx);
|
226
|
-
mongocrypt_destroy (crypt);
|
160
|
+
static void _test_datakey_custom_endpoint(_mongocrypt_tester_t *tester) {
|
161
|
+
mongocrypt_t *crypt;
|
162
|
+
mongocrypt_ctx_t *ctx;
|
163
|
+
mongocrypt_kms_ctx_t *kms_ctx;
|
164
|
+
mongocrypt_binary_t *bin;
|
165
|
+
const char *endpoint;
|
166
|
+
bson_t key_bson;
|
167
|
+
bson_iter_t iter;
|
168
|
+
|
169
|
+
/* Success. */
|
170
|
+
crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
171
|
+
ctx = mongocrypt_ctx_new(crypt);
|
172
|
+
ASSERT_OK(mongocrypt_ctx_setopt_masterkey_aws(ctx, "region", -1, "cmk", -1), ctx);
|
173
|
+
ASSERT_OK(mongocrypt_ctx_setopt_masterkey_aws_endpoint(ctx, "example.com", -1), ctx);
|
174
|
+
ASSERT_OK(mongocrypt_ctx_datakey_init(ctx), ctx);
|
175
|
+
BSON_ASSERT(mongocrypt_ctx_state(ctx) == MONGOCRYPT_CTX_NEED_KMS);
|
176
|
+
kms_ctx = mongocrypt_ctx_next_kms_ctx(ctx);
|
177
|
+
BSON_ASSERT(kms_ctx);
|
178
|
+
ASSERT_OK(mongocrypt_kms_ctx_endpoint(kms_ctx, &endpoint), ctx);
|
179
|
+
BSON_ASSERT(0 == strcmp("example.com:443", endpoint));
|
180
|
+
bin = mongocrypt_binary_new();
|
181
|
+
ASSERT_OK(mongocrypt_kms_ctx_message(kms_ctx, bin), ctx);
|
182
|
+
BSON_ASSERT(NULL != strstr((char *)bin->data, "Host:example.com"));
|
183
|
+
ASSERT_OK(mongocrypt_kms_ctx_feed(kms_ctx, TEST_FILE("./test/data/kms-encrypt-reply.txt")), kms_ctx);
|
184
|
+
BSON_ASSERT(0 == mongocrypt_kms_ctx_bytes_needed(kms_ctx));
|
185
|
+
ASSERT_OK(mongocrypt_ctx_kms_done(ctx), ctx);
|
186
|
+
|
187
|
+
BSON_ASSERT(mongocrypt_ctx_state(ctx) == MONGOCRYPT_CTX_READY);
|
188
|
+
ASSERT_OK(mongocrypt_ctx_finalize(ctx, bin), ctx);
|
189
|
+
/* Check the BSON document created. */
|
190
|
+
BSON_ASSERT(_mongocrypt_binary_to_bson(bin, &key_bson));
|
191
|
+
BSON_ASSERT(bson_iter_init(&iter, &key_bson));
|
192
|
+
BSON_ASSERT(bson_iter_find_descendant(&iter, "masterKey.endpoint", &iter));
|
193
|
+
BSON_ASSERT(0 == strcmp(bson_iter_utf8(&iter, NULL), "example.com"));
|
194
|
+
|
195
|
+
mongocrypt_binary_destroy(bin);
|
196
|
+
mongocrypt_ctx_destroy(ctx);
|
197
|
+
mongocrypt_destroy(crypt);
|
227
198
|
}
|
228
199
|
|
229
|
-
static void
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
BSON_ASSERT (mongocrypt_ctx_state (ctx) == MONGOCRYPT_CTX_READY);
|
276
|
-
ASSERT_OK (mongocrypt_ctx_finalize (ctx, bin), ctx);
|
277
|
-
/* Check the BSON document created. */
|
278
|
-
BSON_ASSERT (_mongocrypt_binary_to_bson (bin, &key_bson));
|
279
|
-
BSON_ASSERT (bson_iter_init (&iter, &key_bson));
|
280
|
-
BSON_ASSERT (bson_iter_find_descendant (&iter, "masterKey.endpoint", &iter));
|
281
|
-
BSON_ASSERT (0 == strcmp (bson_iter_utf8 (&iter, NULL), "example.com"));
|
282
|
-
|
283
|
-
mongocrypt_binary_destroy (bin);
|
284
|
-
mongocrypt_ctx_destroy (ctx);
|
285
|
-
mongocrypt_destroy (crypt);
|
200
|
+
static void _test_datakey_kms_per_ctx_credentials(_mongocrypt_tester_t *tester) {
|
201
|
+
mongocrypt_t *crypt;
|
202
|
+
mongocrypt_ctx_t *ctx;
|
203
|
+
mongocrypt_kms_ctx_t *kms_ctx;
|
204
|
+
mongocrypt_binary_t *bin;
|
205
|
+
const char *endpoint;
|
206
|
+
bson_t key_bson;
|
207
|
+
bson_iter_t iter;
|
208
|
+
|
209
|
+
/* Success. */
|
210
|
+
crypt = mongocrypt_new();
|
211
|
+
mongocrypt_setopt_use_need_kms_credentials_state(crypt);
|
212
|
+
ASSERT_OK(mongocrypt_setopt_kms_providers(crypt, TEST_BSON("{'aws': {}}")), crypt);
|
213
|
+
ASSERT_OK(mongocrypt_init(crypt), crypt);
|
214
|
+
ctx = mongocrypt_ctx_new(crypt);
|
215
|
+
ASSERT_OK(mongocrypt_ctx_setopt_masterkey_aws(ctx, "region", -1, "cmk", -1), ctx);
|
216
|
+
ASSERT_OK(mongocrypt_ctx_setopt_masterkey_aws_endpoint(ctx, "example.com", -1), ctx);
|
217
|
+
ASSERT_OK(mongocrypt_ctx_datakey_init(ctx), ctx);
|
218
|
+
BSON_ASSERT(mongocrypt_ctx_state(ctx) == MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS);
|
219
|
+
ASSERT_OK(mongocrypt_ctx_provide_kms_providers(ctx,
|
220
|
+
TEST_BSON("{'aws':{'accessKeyId': 'example',"
|
221
|
+
"'secretAccessKey': 'example'}}")),
|
222
|
+
ctx);
|
223
|
+
BSON_ASSERT(mongocrypt_ctx_state(ctx) == MONGOCRYPT_CTX_NEED_KMS);
|
224
|
+
kms_ctx = mongocrypt_ctx_next_kms_ctx(ctx);
|
225
|
+
BSON_ASSERT(kms_ctx);
|
226
|
+
ASSERT_OK(mongocrypt_kms_ctx_endpoint(kms_ctx, &endpoint), ctx);
|
227
|
+
BSON_ASSERT(0 == strcmp("example.com:443", endpoint));
|
228
|
+
bin = mongocrypt_binary_new();
|
229
|
+
ASSERT_OK(mongocrypt_kms_ctx_message(kms_ctx, bin), ctx);
|
230
|
+
BSON_ASSERT(NULL != strstr((char *)bin->data, "Host:example.com"));
|
231
|
+
ASSERT_OK(mongocrypt_kms_ctx_feed(kms_ctx, TEST_FILE("./test/data/kms-encrypt-reply.txt")), kms_ctx);
|
232
|
+
BSON_ASSERT(0 == mongocrypt_kms_ctx_bytes_needed(kms_ctx));
|
233
|
+
ASSERT_OK(mongocrypt_ctx_kms_done(ctx), ctx);
|
234
|
+
|
235
|
+
BSON_ASSERT(mongocrypt_ctx_state(ctx) == MONGOCRYPT_CTX_READY);
|
236
|
+
ASSERT_OK(mongocrypt_ctx_finalize(ctx, bin), ctx);
|
237
|
+
/* Check the BSON document created. */
|
238
|
+
BSON_ASSERT(_mongocrypt_binary_to_bson(bin, &key_bson));
|
239
|
+
BSON_ASSERT(bson_iter_init(&iter, &key_bson));
|
240
|
+
BSON_ASSERT(bson_iter_find_descendant(&iter, "masterKey.endpoint", &iter));
|
241
|
+
BSON_ASSERT(0 == strcmp(bson_iter_utf8(&iter, NULL), "example.com"));
|
242
|
+
|
243
|
+
mongocrypt_binary_destroy(bin);
|
244
|
+
mongocrypt_ctx_destroy(ctx);
|
245
|
+
mongocrypt_destroy(crypt);
|
286
246
|
}
|
287
247
|
|
288
248
|
/* Test creating a data key with "azure" when only "aws" credentials are needed.
|
289
249
|
* Expect the context not to enter the MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS
|
290
250
|
* state. */
|
291
|
-
static void
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
ASSERT_OK (mongocrypt_setopt_kms_providers (
|
301
|
-
crypt,
|
302
|
-
TEST_BSON ("{'aws': {}, 'azure': {'tenantId': '', 'clientId': "
|
303
|
-
"'', 'clientSecret': '' }}")),
|
251
|
+
static void _test_datakey_kms_per_ctx_credentials_not_requested(_mongocrypt_tester_t *tester) {
|
252
|
+
mongocrypt_t *crypt;
|
253
|
+
mongocrypt_ctx_t *ctx;
|
254
|
+
|
255
|
+
crypt = mongocrypt_new();
|
256
|
+
mongocrypt_setopt_use_need_kms_credentials_state(crypt);
|
257
|
+
ASSERT_OK(mongocrypt_setopt_kms_providers(crypt,
|
258
|
+
TEST_BSON("{'aws': {}, 'azure': {'tenantId': '', 'clientId': "
|
259
|
+
"'', 'clientSecret': '' }}")),
|
304
260
|
crypt);
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
"'example.vault.azure.net', 'keyName': 'test'}")),
|
261
|
+
ASSERT_OK(mongocrypt_init(crypt), crypt);
|
262
|
+
ctx = mongocrypt_ctx_new(crypt);
|
263
|
+
ASSERT_OK(mongocrypt_ctx_setopt_key_encryption_key(ctx,
|
264
|
+
TEST_BSON("{'provider': 'azure', 'keyVaultEndpoint': "
|
265
|
+
"'example.vault.azure.net', 'keyName': 'test'}")),
|
311
266
|
ctx);
|
312
|
-
|
313
|
-
|
267
|
+
ASSERT_OK(mongocrypt_ctx_datakey_init(ctx), ctx);
|
268
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_KMS);
|
314
269
|
|
315
|
-
|
316
|
-
|
270
|
+
mongocrypt_ctx_destroy(ctx);
|
271
|
+
mongocrypt_destroy(crypt);
|
317
272
|
}
|
318
273
|
|
319
274
|
/* Test creating a data key with "local" when "local" credentials are required.
|
320
275
|
* Expect the context to enter the MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS
|
321
276
|
* state. */
|
322
|
-
static void
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
ASSERT_OK (mongocrypt_ctx_datakey_init (ctx), ctx);
|
345
|
-
ASSERT_STATE_EQUAL (mongocrypt_ctx_state (ctx),
|
346
|
-
MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS);
|
347
|
-
|
348
|
-
ASSERT_OK (mongocrypt_ctx_provide_kms_providers (
|
349
|
-
ctx,
|
350
|
-
TEST_BSON ("{'local':{'key': { '$binary': {'base64': '%s', "
|
351
|
-
"'subType': '00'}}}}",
|
352
|
-
local_kek)),
|
277
|
+
static void _test_datakey_kms_per_ctx_credentials_local(_mongocrypt_tester_t *tester) {
|
278
|
+
mongocrypt_t *crypt;
|
279
|
+
mongocrypt_ctx_t *ctx;
|
280
|
+
mongocrypt_binary_t *bin;
|
281
|
+
bson_t key_bson;
|
282
|
+
bson_iter_t iter;
|
283
|
+
const char *local_kek = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
284
|
+
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
|
285
|
+
|
286
|
+
crypt = mongocrypt_new();
|
287
|
+
mongocrypt_setopt_use_need_kms_credentials_state(crypt);
|
288
|
+
ASSERT_OK(mongocrypt_setopt_kms_providers(crypt, TEST_BSON("{'local': {}}")), crypt);
|
289
|
+
ASSERT_OK(mongocrypt_init(crypt), crypt);
|
290
|
+
ctx = mongocrypt_ctx_new(crypt);
|
291
|
+
ASSERT_OK(mongocrypt_ctx_setopt_key_encryption_key(ctx, TEST_BSON("{'provider': 'local' }")), ctx);
|
292
|
+
ASSERT_OK(mongocrypt_ctx_datakey_init(ctx), ctx);
|
293
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS);
|
294
|
+
|
295
|
+
ASSERT_OK(mongocrypt_ctx_provide_kms_providers(ctx,
|
296
|
+
TEST_BSON("{'local':{'key': { '$binary': {'base64': '%s', "
|
297
|
+
"'subType': '00'}}}}",
|
298
|
+
local_kek)),
|
353
299
|
ctx);
|
354
300
|
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
301
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_READY);
|
302
|
+
bin = mongocrypt_binary_new();
|
303
|
+
ASSERT_OK(mongocrypt_ctx_finalize(ctx, bin), ctx);
|
304
|
+
/* Check the BSON document created. */
|
305
|
+
BSON_ASSERT(_mongocrypt_binary_to_bson(bin, &key_bson));
|
306
|
+
BSON_ASSERT(bson_iter_init(&iter, &key_bson));
|
307
|
+
BSON_ASSERT(bson_iter_find_descendant(&iter, "masterKey.provider", &iter));
|
308
|
+
BSON_ASSERT(0 == strcmp(bson_iter_utf8(&iter, NULL), "local"));
|
309
|
+
|
310
|
+
mongocrypt_binary_destroy(bin);
|
311
|
+
mongocrypt_ctx_destroy(ctx);
|
312
|
+
mongocrypt_destroy(crypt);
|
367
313
|
}
|
368
314
|
|
315
|
+
static void _test_datakey_custom_key_material(_mongocrypt_tester_t *tester) {
|
316
|
+
const uint8_t expected_dek[MONGOCRYPT_KEY_LEN] = "0123456789abcdef"
|
317
|
+
"0123456789abcdef"
|
318
|
+
"0123456789abcdef"
|
319
|
+
"0123456789abcdef"
|
320
|
+
"0123456789abcdef"
|
321
|
+
"0123456789abcdef";
|
322
|
+
|
323
|
+
mongocrypt_t *const crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
324
|
+
|
325
|
+
_mongocrypt_buffer_t encrypted_dek_buf;
|
326
|
+
|
327
|
+
{
|
328
|
+
mongocrypt_ctx_t *ctx = mongocrypt_ctx_new(crypt);
|
329
|
+
|
330
|
+
/* Generate encrypted DEK using custom key material. */
|
331
|
+
{
|
332
|
+
mongocrypt_binary_t *const kek = TEST_BSON("{'provider': 'local'}");
|
333
|
+
|
334
|
+
bson_t bson;
|
335
|
+
_mongocrypt_buffer_t key_material_buf;
|
336
|
+
mongocrypt_binary_t key_material;
|
337
|
+
|
338
|
+
bson_init(&bson);
|
339
|
+
ASSERT(BSON_APPEND_BINARY(&bson, "keyMaterial", BSON_SUBTYPE_BINARY, expected_dek, MONGOCRYPT_KEY_LEN));
|
340
|
+
_mongocrypt_buffer_from_bson(&key_material_buf, &bson);
|
341
|
+
_mongocrypt_buffer_to_binary(&key_material_buf, &key_material);
|
369
342
|
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
ASSERT_OK (mongocrypt_ctx_datakey_init (ctx), ctx);
|
409
|
-
|
410
|
-
bson_destroy (&bson);
|
411
|
-
}
|
412
|
-
|
413
|
-
/* Extract encrypted DEK from datakey. */
|
414
|
-
{
|
415
|
-
mongocrypt_binary_t *const datakey = mongocrypt_binary_new ();
|
416
|
-
|
417
|
-
bson_t bson;
|
418
|
-
bson_iter_t iter;
|
419
|
-
const uint8_t *binary;
|
420
|
-
uint32_t len;
|
421
|
-
bson_subtype_t subtype;
|
422
|
-
|
423
|
-
_mongocrypt_tester_run_ctx_to (tester, ctx, MONGOCRYPT_CTX_READY);
|
424
|
-
ASSERT_OK (mongocrypt_ctx_finalize (ctx, datakey), ctx);
|
425
|
-
ASSERT (_mongocrypt_binary_to_bson (datakey, &bson));
|
426
|
-
|
427
|
-
ASSERT (bson_iter_init_find (&iter, &bson, "keyMaterial"));
|
428
|
-
ASSERT (BSON_ITER_HOLDS_BINARY (&iter));
|
429
|
-
bson_iter_binary (&iter, &subtype, &len, &binary);
|
430
|
-
ASSERT (_mongocrypt_buffer_copy_from_data_and_size (
|
431
|
-
&encrypted_dek_buf, binary, len));
|
432
|
-
|
433
|
-
mongocrypt_binary_destroy (datakey);
|
434
|
-
}
|
435
|
-
|
436
|
-
mongocrypt_ctx_destroy (ctx);
|
437
|
-
}
|
438
|
-
|
439
|
-
/* Decrypt key material and confirm it matches original DEK. */
|
440
|
-
{
|
441
|
-
_mongocrypt_buffer_t decrypted_dek_buf;
|
442
|
-
mongocrypt_binary_t decrypted_dek;
|
443
|
-
|
444
|
-
ASSERT (_mongocrypt_unwrap_key (crypt->crypto,
|
343
|
+
ASSERT_OK(mongocrypt_ctx_setopt_key_encryption_key(ctx, kek), ctx);
|
344
|
+
ASSERT_OK(mongocrypt_ctx_setopt_key_material(ctx, &key_material), ctx);
|
345
|
+
ASSERT_OK(mongocrypt_ctx_datakey_init(ctx), ctx);
|
346
|
+
|
347
|
+
bson_destroy(&bson);
|
348
|
+
}
|
349
|
+
|
350
|
+
/* Extract encrypted DEK from datakey. */
|
351
|
+
{
|
352
|
+
mongocrypt_binary_t *const datakey = mongocrypt_binary_new();
|
353
|
+
|
354
|
+
bson_t bson;
|
355
|
+
bson_iter_t iter;
|
356
|
+
const uint8_t *binary;
|
357
|
+
uint32_t len;
|
358
|
+
bson_subtype_t subtype;
|
359
|
+
|
360
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_READY);
|
361
|
+
ASSERT_OK(mongocrypt_ctx_finalize(ctx, datakey), ctx);
|
362
|
+
ASSERT(_mongocrypt_binary_to_bson(datakey, &bson));
|
363
|
+
|
364
|
+
ASSERT(bson_iter_init_find(&iter, &bson, "keyMaterial"));
|
365
|
+
ASSERT(BSON_ITER_HOLDS_BINARY(&iter));
|
366
|
+
bson_iter_binary(&iter, &subtype, &len, &binary);
|
367
|
+
ASSERT(_mongocrypt_buffer_copy_from_data_and_size(&encrypted_dek_buf, binary, len));
|
368
|
+
|
369
|
+
mongocrypt_binary_destroy(datakey);
|
370
|
+
}
|
371
|
+
|
372
|
+
mongocrypt_ctx_destroy(ctx);
|
373
|
+
}
|
374
|
+
|
375
|
+
/* Decrypt key material and confirm it matches original DEK. */
|
376
|
+
{
|
377
|
+
_mongocrypt_buffer_t decrypted_dek_buf;
|
378
|
+
mongocrypt_binary_t decrypted_dek;
|
379
|
+
|
380
|
+
ASSERT(_mongocrypt_unwrap_key(crypt->crypto,
|
445
381
|
&crypt->opts.kms_providers.local.key,
|
446
382
|
&encrypted_dek_buf,
|
447
383
|
&decrypted_dek_buf,
|
448
384
|
crypt->status));
|
449
385
|
|
450
|
-
|
386
|
+
_mongocrypt_buffer_to_binary(&decrypted_dek_buf, &decrypted_dek);
|
451
387
|
|
452
|
-
|
453
|
-
MONGOCRYPT_KEY_LEN,
|
454
|
-
decrypted_dek.data,
|
455
|
-
decrypted_dek.len);
|
388
|
+
ASSERT_CMPBYTES(expected_dek, MONGOCRYPT_KEY_LEN, decrypted_dek.data, decrypted_dek.len);
|
456
389
|
|
457
|
-
|
458
|
-
|
390
|
+
_mongocrypt_buffer_cleanup(&decrypted_dek_buf);
|
391
|
+
}
|
459
392
|
|
460
|
-
|
461
|
-
|
393
|
+
_mongocrypt_buffer_cleanup(&encrypted_dek_buf);
|
394
|
+
mongocrypt_destroy(crypt);
|
462
395
|
}
|
463
396
|
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
tester, MONGOCRYPT_KMS_PROVIDER_AWS, false /* with_alt_name */);
|
470
|
-
_test_create_data_key_with_provider (
|
471
|
-
tester, MONGOCRYPT_KMS_PROVIDER_LOCAL, false /* with_alt_name */);
|
472
|
-
_test_create_data_key_with_provider (
|
473
|
-
tester, MONGOCRYPT_KMS_PROVIDER_AWS, true /* with_alt_name */);
|
474
|
-
_test_create_data_key_with_provider (
|
475
|
-
tester, MONGOCRYPT_KMS_PROVIDER_LOCAL, true /* with_alt_name */);
|
397
|
+
static void _test_create_data_key(_mongocrypt_tester_t *tester) {
|
398
|
+
_test_create_data_key_with_provider(tester, MONGOCRYPT_KMS_PROVIDER_AWS, false /* with_alt_name */);
|
399
|
+
_test_create_data_key_with_provider(tester, MONGOCRYPT_KMS_PROVIDER_LOCAL, false /* with_alt_name */);
|
400
|
+
_test_create_data_key_with_provider(tester, MONGOCRYPT_KMS_PROVIDER_AWS, true /* with_alt_name */);
|
401
|
+
_test_create_data_key_with_provider(tester, MONGOCRYPT_KMS_PROVIDER_LOCAL, true /* with_alt_name */);
|
476
402
|
}
|
477
403
|
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
INSTALL_TEST (_test_datakey_kms_per_ctx_credentials);
|
487
|
-
INSTALL_TEST (_test_datakey_kms_per_ctx_credentials_not_requested);
|
488
|
-
INSTALL_TEST (_test_datakey_kms_per_ctx_credentials_local);
|
404
|
+
void _mongocrypt_tester_install_data_key(_mongocrypt_tester_t *tester) {
|
405
|
+
INSTALL_TEST(_test_random_generator);
|
406
|
+
INSTALL_TEST(_test_create_data_key);
|
407
|
+
INSTALL_TEST(_test_datakey_custom_endpoint);
|
408
|
+
INSTALL_TEST(_test_datakey_custom_key_material);
|
409
|
+
INSTALL_TEST(_test_datakey_kms_per_ctx_credentials);
|
410
|
+
INSTALL_TEST(_test_datakey_kms_per_ctx_credentials_not_requested);
|
411
|
+
INSTALL_TEST(_test_datakey_kms_per_ctx_credentials_local);
|
489
412
|
}
|