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
@@ -14,266 +14,239 @@
|
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
16
|
|
17
|
-
#include "mongocrypt.h"
|
18
17
|
#include "mongocrypt-cache-key-private.h"
|
19
18
|
#include "mongocrypt-crypto-private.h"
|
19
|
+
#include "mongocrypt.h"
|
20
20
|
#include "test-mongocrypt-assert-match-bson.h"
|
21
21
|
#include "test-mongocrypt.h"
|
22
22
|
|
23
23
|
typedef struct {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
_mongocrypt_buffer_t bson;
|
25
|
+
_mongocrypt_key_doc_t *parsed;
|
26
|
+
_mongocrypt_buffer_t kms_reply;
|
27
|
+
_mongocrypt_buffer_t uuid;
|
28
|
+
_mongocrypt_buffer_t marking;
|
29
29
|
} gen_key_t;
|
30
30
|
|
31
31
|
/* The JSON spec tests refer to key ids by a shorthand integer.
|
32
32
|
* This function maps that integer to a UUID buffer. */
|
33
|
-
void
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
buf->subtype = BSON_SUBTYPE_UUID;
|
43
|
-
BSON_ASSERT (_mongocrypt_buffer_is_uuid (buf));
|
33
|
+
void lookup_key_id(uint32_t index, _mongocrypt_buffer_t *buf) {
|
34
|
+
const char *key_ids[] = {"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
35
|
+
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
|
36
|
+
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"};
|
37
|
+
|
38
|
+
BSON_ASSERT(index < 3);
|
39
|
+
_mongocrypt_buffer_copy_from_hex(buf, key_ids[index]);
|
40
|
+
buf->subtype = BSON_SUBTYPE_UUID;
|
41
|
+
BSON_ASSERT(_mongocrypt_buffer_is_uuid(buf));
|
44
42
|
}
|
45
43
|
|
46
44
|
/* Generate a realistic key document given a @key_description, which contains an
|
47
45
|
* _id
|
48
46
|
* and possible keyAltNames. key_out and key_doc_out are NULLable outputs. */
|
49
|
-
void
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
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
|
-
status);
|
127
|
-
mongocrypt_status_destroy (status);
|
128
|
-
}
|
129
|
-
|
130
|
-
bson_destroy (&key);
|
131
|
-
_mongocrypt_buffer_cleanup (&key_id);
|
132
|
-
_mongocrypt_buffer_cleanup (&key_material);
|
47
|
+
void gen_key(_mongocrypt_tester_t *tester,
|
48
|
+
bson_t *key_description,
|
49
|
+
bson_t *key_out,
|
50
|
+
_mongocrypt_key_doc_t *key_doc_out) {
|
51
|
+
bson_iter_t iter;
|
52
|
+
_mongocrypt_buffer_t key_material;
|
53
|
+
_mongocrypt_buffer_t key_id;
|
54
|
+
bson_t key, masterkey;
|
55
|
+
bool local_kms;
|
56
|
+
|
57
|
+
bson_init(&key);
|
58
|
+
BSON_APPEND_INT32(&key, "status", 1);
|
59
|
+
BSON_APPEND_DATE_TIME(&key, "updateDate", 1234567890);
|
60
|
+
BSON_APPEND_DATE_TIME(&key, "creationDate", 1234567890);
|
61
|
+
BSON_APPEND_DOCUMENT_BEGIN(&key, "masterKey", &masterkey);
|
62
|
+
|
63
|
+
local_kms = bson_iter_init_find(&iter, key_description, "local") && bson_iter_as_bool(&iter);
|
64
|
+
|
65
|
+
if (local_kms) {
|
66
|
+
BSON_APPEND_UTF8(&masterkey, "provider", "local");
|
67
|
+
} else {
|
68
|
+
BSON_APPEND_UTF8(&masterkey, "provider", "aws");
|
69
|
+
BSON_APPEND_UTF8(&masterkey, "region", "us-east-1");
|
70
|
+
BSON_APPEND_UTF8(&masterkey,
|
71
|
+
"key",
|
72
|
+
"arn:aws:kms:us-east-1:579766882180:key/"
|
73
|
+
"89fcc2c4-08b0-4bd9-9f25-e30687b580d0");
|
74
|
+
}
|
75
|
+
bson_append_document_end(&key, &masterkey);
|
76
|
+
|
77
|
+
BSON_ASSERT(bson_iter_init_find(&iter, key_description, "_id"));
|
78
|
+
lookup_key_id(bson_iter_int32(&iter), &key_id);
|
79
|
+
BSON_ASSERT(_mongocrypt_buffer_append(&key_id, &key, "_id", 3));
|
80
|
+
|
81
|
+
if (bson_iter_init_find(&iter, key_description, "keyAltNames")) {
|
82
|
+
bson_t key_alt_name_bson;
|
83
|
+
int counter = 0;
|
84
|
+
|
85
|
+
BSON_APPEND_ARRAY_BEGIN(&key, "keyAltNames", &key_alt_name_bson);
|
86
|
+
for (bson_iter_recurse(&iter, &iter); bson_iter_next(&iter);) {
|
87
|
+
char *field;
|
88
|
+
|
89
|
+
field = bson_strdup_printf("%d", counter);
|
90
|
+
BSON_APPEND_UTF8(&key_alt_name_bson, field, bson_iter_utf8(&iter, NULL));
|
91
|
+
counter++;
|
92
|
+
bson_free(field);
|
93
|
+
}
|
94
|
+
bson_append_array_end(&key, &key_alt_name_bson);
|
95
|
+
}
|
96
|
+
|
97
|
+
/* Append a keyMaterial that is decryptable by the local KMS masterkey. For
|
98
|
+
* AWS it gets ignored since it is dictated by KMS response. */
|
99
|
+
_mongocrypt_buffer_copy_from_hex(&key_material,
|
100
|
+
"75bdbbaec862a8ae09aa16f6c67c0ae117dd15bf49b8a7947bac6de5a"
|
101
|
+
"610178a3adad4bbe5bec1e30c55378f7d80d0fd5152d46e954aa32528"
|
102
|
+
"69901e03cf7938434fdf7e5bf27f0ec1c85c4c5a92e38b7e3f7ce686d"
|
103
|
+
"7985102c85905da220a27ee01202de25b6831e64974baffb35b7c30c5"
|
104
|
+
"941dfb37b04fff6871d7208e4cde8d1bff0cd69a70dcb613dc27cfe84"
|
105
|
+
"7d7544b6d0d8b4f6c9a5b6fb9c1565c43ef");
|
106
|
+
key_material.subtype = BSON_SUBTYPE_BINARY;
|
107
|
+
BSON_ASSERT(_mongocrypt_buffer_append(&key_material, &key, "keyMaterial", -1));
|
108
|
+
|
109
|
+
if (key_out) {
|
110
|
+
bson_copy_to(&key, key_out);
|
111
|
+
}
|
112
|
+
|
113
|
+
if (key_doc_out) {
|
114
|
+
mongocrypt_status_t *status;
|
115
|
+
|
116
|
+
status = mongocrypt_status_new();
|
117
|
+
ASSERT_OK_STATUS(_mongocrypt_key_parse_owned(&key, key_doc_out, status), status);
|
118
|
+
mongocrypt_status_destroy(status);
|
119
|
+
}
|
120
|
+
|
121
|
+
bson_destroy(&key);
|
122
|
+
_mongocrypt_buffer_cleanup(&key_id);
|
123
|
+
_mongocrypt_buffer_cleanup(&key_material);
|
133
124
|
}
|
134
125
|
|
135
126
|
/* Append a realistic subtype 6 marking to a BSON document given a description
|
136
127
|
* of the requested key, which may contain either an _id or single keyAltName.
|
137
128
|
*/
|
138
|
-
static void
|
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
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
BSON_ASSERT (_mongocrypt_buffer_append (&marking_buf, appendee, key, -1));
|
174
|
-
|
175
|
-
bson_destroy (&marking_bson);
|
176
|
-
_mongocrypt_buffer_cleanup (&marking_buf);
|
129
|
+
static void _append_marking(bson_t *appendee, const char *key, const bson_t *request) {
|
130
|
+
/* Create a marking with a fixed value "v": 1 */
|
131
|
+
bson_t marking_bson;
|
132
|
+
_mongocrypt_buffer_t marking_buf;
|
133
|
+
bson_iter_t iter;
|
134
|
+
|
135
|
+
bson_init(&marking_bson);
|
136
|
+
|
137
|
+
if (bson_iter_init_find(&iter, request, "_id")) {
|
138
|
+
_mongocrypt_buffer_t key_id;
|
139
|
+
|
140
|
+
lookup_key_id(bson_iter_int32(&iter), &key_id);
|
141
|
+
BSON_ASSERT(_mongocrypt_buffer_append(&key_id, &marking_bson, "ki", 2));
|
142
|
+
_mongocrypt_buffer_cleanup(&key_id);
|
143
|
+
} else {
|
144
|
+
/* If no _id, then keyAltName must be specified. */
|
145
|
+
BSON_ASSERT(bson_iter_init_find(&iter, request, "keyAltName"));
|
146
|
+
BSON_APPEND_UTF8(&marking_bson, "ka", bson_iter_utf8(&iter, NULL));
|
147
|
+
}
|
148
|
+
|
149
|
+
/* Append an arbitrary value and algorithm. It won't be checked in the tests.
|
150
|
+
*/
|
151
|
+
BSON_APPEND_INT32(&marking_bson, "v", 123);
|
152
|
+
BSON_APPEND_INT32(&marking_bson, "a", MONGOCRYPT_ENCRYPTION_ALGORITHM_DETERMINISTIC);
|
153
|
+
|
154
|
+
/* Append the prefix 0 byte, per the marking binary format. */
|
155
|
+
_mongocrypt_buffer_init(&marking_buf);
|
156
|
+
_mongocrypt_buffer_resize(&marking_buf, marking_bson.len + 1);
|
157
|
+
marking_buf.data[0] = 0;
|
158
|
+
memcpy(marking_buf.data + 1, bson_get_data(&marking_bson), marking_bson.len);
|
159
|
+
marking_buf.subtype = 6;
|
160
|
+
BSON_ASSERT(_mongocrypt_buffer_append(&marking_buf, appendee, key, -1));
|
161
|
+
|
162
|
+
bson_destroy(&marking_bson);
|
163
|
+
_mongocrypt_buffer_cleanup(&marking_buf);
|
177
164
|
}
|
178
165
|
|
179
166
|
/* Manually add a cache entry given a description (_id and possible keyAltNames)
|
180
167
|
*/
|
181
|
-
static void
|
182
|
-
|
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
|
-
|
221
|
-
|
222
|
-
|
223
|
-
status);
|
224
|
-
|
225
|
-
_mongocrypt_key_destroy (key_doc);
|
226
|
-
_mongocrypt_buffer_cleanup (&key_material_placeholder);
|
227
|
-
_mongocrypt_cache_key_attr_destroy (cache_key_attr);
|
228
|
-
_mongocrypt_cache_key_value_destroy (cache_key_value);
|
229
|
-
_mongocrypt_key_alt_name_destroy_all (key_alt_names);
|
230
|
-
_mongocrypt_buffer_cleanup (&key_id);
|
231
|
-
mongocrypt_status_destroy (status);
|
168
|
+
static void _add_to_cache(_mongocrypt_tester_t *tester, mongocrypt_ctx_t *ctx, bson_t *cache_entry) {
|
169
|
+
bson_iter_t iter;
|
170
|
+
_mongocrypt_buffer_t key_id;
|
171
|
+
_mongocrypt_key_alt_name_t *key_alt_names = NULL;
|
172
|
+
_mongocrypt_cache_key_attr_t *cache_key_attr;
|
173
|
+
_mongocrypt_cache_key_value_t *cache_key_value;
|
174
|
+
_mongocrypt_key_doc_t *key_doc;
|
175
|
+
_mongocrypt_buffer_t key_material_placeholder;
|
176
|
+
mongocrypt_status_t *status;
|
177
|
+
|
178
|
+
status = mongocrypt_status_new();
|
179
|
+
BSON_ASSERT(bson_iter_init_find(&iter, cache_entry, "_id"));
|
180
|
+
lookup_key_id(bson_iter_int32(&iter), &key_id);
|
181
|
+
|
182
|
+
if (bson_iter_init_find(&iter, cache_entry, "keyAltNames")) {
|
183
|
+
ASSERT_OK_STATUS(_mongocrypt_key_alt_name_from_iter(&iter, &key_alt_names, status), status);
|
184
|
+
}
|
185
|
+
|
186
|
+
cache_key_attr = _mongocrypt_cache_key_attr_new(&key_id, key_alt_names);
|
187
|
+
/* TODO: consider improving these tests by identifying the decrypted and
|
188
|
+
* encrypted key material. That is a little tricky, since it will require
|
189
|
+
* parsing the KMS request to know which decrypted key material to respond
|
190
|
+
* with. */
|
191
|
+
_mongocrypt_buffer_init(&key_material_placeholder);
|
192
|
+
_mongocrypt_buffer_resize(&key_material_placeholder, MONGOCRYPT_KEY_LEN);
|
193
|
+
memset(key_material_placeholder.data, 0, MONGOCRYPT_KEY_LEN);
|
194
|
+
|
195
|
+
key_doc = _mongocrypt_key_new();
|
196
|
+
gen_key(tester, cache_entry, NULL, key_doc);
|
197
|
+
|
198
|
+
cache_key_value = _mongocrypt_cache_key_value_new(key_doc, &key_material_placeholder);
|
199
|
+
|
200
|
+
ASSERT_OK_STATUS(_mongocrypt_cache_add_copy(&ctx->crypt->cache_key, cache_key_attr, cache_key_value, status),
|
201
|
+
status);
|
202
|
+
|
203
|
+
_mongocrypt_key_destroy(key_doc);
|
204
|
+
_mongocrypt_buffer_cleanup(&key_material_placeholder);
|
205
|
+
_mongocrypt_cache_key_attr_destroy(cache_key_attr);
|
206
|
+
_mongocrypt_cache_key_value_destroy(cache_key_value);
|
207
|
+
_mongocrypt_key_alt_name_destroy_all(key_alt_names);
|
208
|
+
_mongocrypt_buffer_cleanup(&key_id);
|
209
|
+
mongocrypt_status_destroy(status);
|
232
210
|
}
|
233
211
|
|
234
212
|
/* Match a single cache entry against an expectation document (containing _id
|
235
213
|
* and
|
236
214
|
* possible list of keyAltNames)
|
237
215
|
*/
|
238
|
-
static bool
|
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
|
-
printf ("failed to match key alt names\n");
|
267
|
-
goto done;
|
268
|
-
}
|
269
|
-
|
270
|
-
matched = true;
|
216
|
+
static bool _match_one_cache_entry(_mongocrypt_cache_pair_t *pair, bson_t *expected_entry) {
|
217
|
+
bson_iter_t iter;
|
218
|
+
_mongocrypt_buffer_t key_id;
|
219
|
+
_mongocrypt_key_alt_name_t *key_alt_names = NULL;
|
220
|
+
_mongocrypt_cache_key_attr_t *attr;
|
221
|
+
mongocrypt_status_t *status;
|
222
|
+
bool matched = false;
|
223
|
+
|
224
|
+
_mongocrypt_buffer_init(&key_id);
|
225
|
+
attr = pair->attr;
|
226
|
+
status = mongocrypt_status_new();
|
227
|
+
|
228
|
+
bson_iter_init_find(&iter, expected_entry, "_id");
|
229
|
+
lookup_key_id(bson_iter_int32(&iter), &key_id);
|
230
|
+
if (0 != _mongocrypt_buffer_cmp(&key_id, &attr->id)) {
|
231
|
+
goto done;
|
232
|
+
}
|
233
|
+
|
234
|
+
if (bson_iter_init_find(&iter, expected_entry, "keyAltNames")) {
|
235
|
+
ASSERT_OK_STATUS(_mongocrypt_key_alt_name_from_iter(&iter, &key_alt_names, status), status);
|
236
|
+
}
|
237
|
+
|
238
|
+
if (!_mongocrypt_key_alt_name_unique_list_equal(key_alt_names, attr->alt_names)) {
|
239
|
+
printf("failed to match key alt names\n");
|
240
|
+
goto done;
|
241
|
+
}
|
242
|
+
|
243
|
+
matched = true;
|
271
244
|
|
272
245
|
done:
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
246
|
+
_mongocrypt_buffer_cleanup(&key_id);
|
247
|
+
_mongocrypt_key_alt_name_destroy_all(key_alt_names);
|
248
|
+
mongocrypt_status_destroy(status);
|
249
|
+
return matched;
|
277
250
|
}
|
278
251
|
|
279
252
|
/* Find exactly one cache entry matching expected_entry.
|
@@ -286,190 +259,164 @@ done:
|
|
286
259
|
* like a "count" method instead of a "return true iff there is a single match"
|
287
260
|
* method. We could also use a "count" method to assert no matches, etc.
|
288
261
|
*/
|
289
|
-
static void
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
if (!matched) {
|
313
|
-
printf ("could not match entry: %s\n",
|
314
|
-
bson_as_json (expected_entry, NULL));
|
315
|
-
BSON_ASSERT (false);
|
316
|
-
}
|
262
|
+
static void _match_cache_entry(_mongocrypt_tester_t *tester, mongocrypt_ctx_t *ctx, bson_t *expected_entry) {
|
263
|
+
_mongocrypt_cache_pair_t *pair;
|
264
|
+
bool matched = false;
|
265
|
+
|
266
|
+
pair = ctx->crypt->cache_key.pair;
|
267
|
+
|
268
|
+
while (pair) {
|
269
|
+
if (_match_one_cache_entry(pair, expected_entry)) {
|
270
|
+
if (matched) {
|
271
|
+
printf("double matched entry: %s\n", bson_as_json(expected_entry, NULL));
|
272
|
+
BSON_ASSERT(false);
|
273
|
+
}
|
274
|
+
matched = true;
|
275
|
+
}
|
276
|
+
|
277
|
+
pair = pair->next;
|
278
|
+
}
|
279
|
+
|
280
|
+
if (!matched) {
|
281
|
+
printf("could not match entry: %s\n", bson_as_json(expected_entry, NULL));
|
282
|
+
BSON_ASSERT(false);
|
283
|
+
}
|
317
284
|
}
|
318
285
|
|
319
|
-
static void
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
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
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
bson_t entry_description;
|
427
|
-
|
428
|
-
bson_iter_bson (&iter, &entry_description);
|
429
|
-
_match_cache_entry (tester, ctx, &entry_description);
|
430
|
-
|
431
|
-
count++;
|
432
|
-
}
|
433
|
-
BSON_ASSERT (count ==
|
434
|
-
_mongocrypt_cache_num_entries (&ctx->crypt->cache_key));
|
435
|
-
}
|
436
|
-
}
|
437
|
-
|
438
|
-
bson_destroy (&mongocryptd_reply);
|
439
|
-
mongocrypt_status_destroy (status);
|
286
|
+
static void _run_one_test(_mongocrypt_tester_t *tester, mongocrypt_ctx_t *ctx, bson_t *test) {
|
287
|
+
bson_iter_t iter;
|
288
|
+
bson_t mongocryptd_reply, tmp;
|
289
|
+
_mongocrypt_buffer_t buf;
|
290
|
+
int32_t counter;
|
291
|
+
mongocrypt_status_t *status;
|
292
|
+
|
293
|
+
if (bson_iter_init_find(&iter, test, "description")) {
|
294
|
+
printf("- %s\n", bson_iter_utf8(&iter, NULL));
|
295
|
+
}
|
296
|
+
|
297
|
+
if (bson_iter_init_find(&iter, test, "skipReason")) {
|
298
|
+
printf(" - skipping: %s\n", bson_iter_utf8(&iter, NULL));
|
299
|
+
return;
|
300
|
+
}
|
301
|
+
|
302
|
+
status = mongocrypt_status_new();
|
303
|
+
|
304
|
+
/* Set up cache */
|
305
|
+
if (bson_iter_init_find(&iter, test, "cached")) {
|
306
|
+
for (bson_iter_recurse(&iter, &iter); bson_iter_next(&iter);) {
|
307
|
+
bson_t cache_entry;
|
308
|
+
|
309
|
+
bson_iter_bson(&iter, &cache_entry);
|
310
|
+
_add_to_cache(tester, ctx, &cache_entry);
|
311
|
+
}
|
312
|
+
}
|
313
|
+
|
314
|
+
/* Supply the requests for keys through the mongocryptd reply */
|
315
|
+
BSON_ASSERT(bson_iter_init_find(&iter, test, "requests"));
|
316
|
+
counter = 0;
|
317
|
+
bson_init(&mongocryptd_reply);
|
318
|
+
BSON_APPEND_DOCUMENT_BEGIN(&mongocryptd_reply, "result", &tmp);
|
319
|
+
for (bson_iter_recurse(&iter, &iter); bson_iter_next(&iter);) {
|
320
|
+
bson_t request;
|
321
|
+
char *field;
|
322
|
+
|
323
|
+
bson_iter_bson(&iter, &request);
|
324
|
+
field = bson_strdup_printf("%d", counter);
|
325
|
+
_append_marking(&tmp, field, &request);
|
326
|
+
bson_free(field);
|
327
|
+
counter++;
|
328
|
+
}
|
329
|
+
bson_append_document_end(&mongocryptd_reply, &tmp);
|
330
|
+
|
331
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_NEED_MONGO_MARKINGS);
|
332
|
+
_mongocrypt_buffer_from_bson(&buf, &mongocryptd_reply);
|
333
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx, _mongocrypt_buffer_as_binary(&buf)), ctx);
|
334
|
+
BSON_ASSERT(mongocrypt_ctx_mongo_done(ctx));
|
335
|
+
|
336
|
+
/* If we're expected to supply keys back, do so. */
|
337
|
+
if (bson_iter_init_find(&iter, test, "replies")) {
|
338
|
+
BSON_ASSERT(mongocrypt_ctx_state(ctx) == MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
339
|
+
|
340
|
+
for (bson_iter_recurse(&iter, &iter); bson_iter_next(&iter);) {
|
341
|
+
bson_t key;
|
342
|
+
bson_t key_description;
|
343
|
+
|
344
|
+
bson_iter_bson(&iter, &key_description);
|
345
|
+
gen_key(tester, &key_description, &key, NULL);
|
346
|
+
_mongocrypt_buffer_from_bson(&buf, &key);
|
347
|
+
/* If expectations expect failure, fall through. */
|
348
|
+
if (!mongocrypt_ctx_mongo_feed(ctx, _mongocrypt_buffer_as_binary(&buf))) {
|
349
|
+
bson_destroy(&key);
|
350
|
+
break;
|
351
|
+
}
|
352
|
+
bson_destroy(&key);
|
353
|
+
}
|
354
|
+
|
355
|
+
/* We might have failed at this point. If so, do not continue so we keep
|
356
|
+
* original error message. */
|
357
|
+
if (mongocrypt_ctx_status(ctx, status)) {
|
358
|
+
(void)mongocrypt_ctx_mongo_done(ctx);
|
359
|
+
}
|
360
|
+
}
|
361
|
+
|
362
|
+
/* Check expectations */
|
363
|
+
if (bson_iter_init_find(&iter, test, "expect")) {
|
364
|
+
bson_t expectations;
|
365
|
+
|
366
|
+
mongocrypt_ctx_status(ctx, status);
|
367
|
+
bson_iter_bson(&iter, &expectations);
|
368
|
+
if (bson_iter_init_find(&iter, &expectations, "errmsg")) {
|
369
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_ERROR);
|
370
|
+
ASSERT_FAILS_STATUS(mongocrypt_status_ok(status), status, bson_iter_utf8(&iter, NULL));
|
371
|
+
} else {
|
372
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_DONE);
|
373
|
+
ASSERT_OK_STATUS(mongocrypt_status_ok(status), status);
|
374
|
+
}
|
375
|
+
|
376
|
+
if (bson_iter_init_find(&iter, &expectations, "cached")) {
|
377
|
+
uint32_t count = 0;
|
378
|
+
|
379
|
+
for (bson_iter_recurse(&iter, &iter); bson_iter_next(&iter);) {
|
380
|
+
bson_t entry_description;
|
381
|
+
|
382
|
+
bson_iter_bson(&iter, &entry_description);
|
383
|
+
_match_cache_entry(tester, ctx, &entry_description);
|
384
|
+
|
385
|
+
count++;
|
386
|
+
}
|
387
|
+
BSON_ASSERT(count == _mongocrypt_cache_num_entries(&ctx->crypt->cache_key));
|
388
|
+
}
|
389
|
+
}
|
390
|
+
|
391
|
+
bson_destroy(&mongocryptd_reply);
|
392
|
+
mongocrypt_status_destroy(status);
|
440
393
|
}
|
441
394
|
|
442
395
|
/* Run declarative JSON tests, like driver spec tests. */
|
443
|
-
static void
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
mongocrypt_ctx_destroy (ctx);
|
466
|
-
mongocrypt_destroy (crypt);
|
467
|
-
}
|
468
|
-
bson_destroy (&test_file);
|
396
|
+
static void _test_key_cache(_mongocrypt_tester_t *tester) {
|
397
|
+
mongocrypt_t *crypt;
|
398
|
+
mongocrypt_ctx_t *ctx;
|
399
|
+
bson_t test_file;
|
400
|
+
bson_iter_t iter;
|
401
|
+
|
402
|
+
_load_json_as_bson("./test/data/cache-tests.json", &test_file);
|
403
|
+
for (bson_iter_init(&iter, &test_file); bson_iter_next(&iter);) {
|
404
|
+
bson_t test;
|
405
|
+
crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
406
|
+
ctx = mongocrypt_ctx_new(crypt);
|
407
|
+
|
408
|
+
bson_iter_bson(&iter, &test);
|
409
|
+
|
410
|
+
BSON_ASSERT(mongocrypt_ctx_encrypt_init(ctx, "test", -1, TEST_BSON("{'insert': 'coll'}")));
|
411
|
+
_run_one_test(tester, ctx, &test);
|
412
|
+
bson_destroy(&test);
|
413
|
+
|
414
|
+
mongocrypt_ctx_destroy(ctx);
|
415
|
+
mongocrypt_destroy(crypt);
|
416
|
+
}
|
417
|
+
bson_destroy(&test_file);
|
469
418
|
}
|
470
419
|
|
471
|
-
void
|
472
|
-
|
473
|
-
{
|
474
|
-
INSTALL_TEST (_test_key_cache);
|
420
|
+
void _mongocrypt_tester_install_key_cache(_mongocrypt_tester_t *tester) {
|
421
|
+
INSTALL_TEST(_test_key_cache);
|
475
422
|
}
|