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,535 +14,461 @@
|
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
16
|
|
17
|
-
#include <bson/bson.h>
|
18
17
|
#include "mongocrypt-traverse-util-private.h"
|
19
18
|
#include "test-mongocrypt.h"
|
19
|
+
#include <bson/bson.h>
|
20
20
|
|
21
|
-
static void
|
22
|
-
|
23
|
-
|
24
|
-
uint8_t *data;
|
25
|
-
bson_t *marking_bson;
|
21
|
+
static void _append_marking(bson_t *bson, const char *key, int key_len) {
|
22
|
+
uint8_t *data;
|
23
|
+
bson_t *marking_bson;
|
26
24
|
|
27
|
-
|
28
|
-
BCON_INT32
|
25
|
+
marking_bson = BCON_NEW("a",
|
26
|
+
BCON_INT32(MONGOCRYPT_ENCRYPTION_ALGORITHM_RANDOM),
|
29
27
|
"v",
|
30
|
-
BCON_UTF8
|
28
|
+
BCON_UTF8("abc"),
|
31
29
|
"ka",
|
32
|
-
BCON_UTF8
|
30
|
+
BCON_UTF8("Nancy"));
|
33
31
|
|
34
|
-
|
35
|
-
|
32
|
+
data = bson_malloc0(marking_bson->len + 1);
|
33
|
+
BSON_ASSERT(data);
|
36
34
|
|
37
|
-
|
38
|
-
|
35
|
+
data[0] = 0;
|
36
|
+
memcpy(data + 1, marking_bson, marking_bson->len);
|
39
37
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
bson_destroy (marking_bson);
|
38
|
+
BSON_ASSERT(bson_append_binary(bson, key, key_len, 0x06, data, marking_bson->len + 1));
|
39
|
+
bson_free(data);
|
40
|
+
bson_destroy(marking_bson);
|
44
41
|
}
|
45
42
|
|
46
|
-
static void
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
bson_append_binary (bson, key, key_len, subtype, data, data_len));
|
72
|
-
|
73
|
-
bson_free (data);
|
43
|
+
static void _append_ciphertext_with_subtype(bson_t *bson,
|
44
|
+
const char *key,
|
45
|
+
int key_len,
|
46
|
+
int subtype,
|
47
|
+
int first_byte,
|
48
|
+
_mongocrypt_tester_t *tester) {
|
49
|
+
uint8_t *data;
|
50
|
+
char *utf8;
|
51
|
+
int data_len;
|
52
|
+
int key_id_len = 16;
|
53
|
+
|
54
|
+
utf8 = "Mary";
|
55
|
+
data_len = (int)(1 + key_id_len + 1 + strlen(utf8));
|
56
|
+
|
57
|
+
data = bson_malloc0(data_len);
|
58
|
+
BSON_ASSERT(data);
|
59
|
+
|
60
|
+
data[0] = first_byte;
|
61
|
+
memcpy(data + 1, (TEST_BIN(16))->data, key_id_len);
|
62
|
+
data[1 + key_id_len] = 0x02; /* BSON type UTF8 */
|
63
|
+
memcpy(data + key_id_len + 2, utf8, strlen(utf8));
|
64
|
+
|
65
|
+
BSON_ASSERT(bson_append_binary(bson, key, key_len, subtype, data, data_len));
|
66
|
+
|
67
|
+
bson_free(data);
|
74
68
|
}
|
75
69
|
|
76
70
|
typedef enum { NEST_IN_NONE, NEST_IN_DOCUMENT, NEST_IN_ARRAY } _nesting_t;
|
77
71
|
|
78
72
|
typedef struct {
|
79
|
-
|
80
|
-
|
73
|
+
_mongocrypt_tester_t *tester;
|
74
|
+
_nesting_t parent;
|
81
75
|
} _util_tester_t;
|
82
76
|
|
83
|
-
static void
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
bson_append_array_begin (parent, name, -1, bson);
|
92
|
-
}
|
77
|
+
static void _reset_nesting(bson_t *parent, bson_t *bson, _nesting_t nesting, char *name) {
|
78
|
+
if (nesting == NEST_IN_DOCUMENT) {
|
79
|
+
BSON_ASSERT(bson_append_document_end(parent, bson));
|
80
|
+
bson_append_document_begin(parent, name, -1, bson);
|
81
|
+
} else if (nesting == NEST_IN_ARRAY) {
|
82
|
+
BSON_ASSERT(bson_append_array_end(parent, bson));
|
83
|
+
bson_append_array_begin(parent, name, -1, bson);
|
84
|
+
}
|
93
85
|
}
|
94
86
|
|
95
|
-
static int
|
96
|
-
|
97
|
-
{
|
98
|
-
int i = 0;
|
87
|
+
static int _field_count(bson_iter_t *iter) {
|
88
|
+
int i = 0;
|
99
89
|
|
100
|
-
|
101
|
-
|
102
|
-
|
90
|
+
while (bson_iter_next(iter)) {
|
91
|
+
i++;
|
92
|
+
}
|
103
93
|
|
104
|
-
|
94
|
+
return i;
|
105
95
|
}
|
106
96
|
|
107
|
-
static void
|
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
|
-
BSON_ASSERT (_field_count (&iter) ==
|
161
|
-
(num_other + num_binary + num_markings + num_deterministic +
|
162
|
-
num_random));
|
163
|
-
}
|
97
|
+
static void _assert_correct_fields(bson_t *bson,
|
98
|
+
int num_markings,
|
99
|
+
int num_deterministic,
|
100
|
+
int num_random,
|
101
|
+
int num_binary,
|
102
|
+
int num_other,
|
103
|
+
_util_tester_t *tester) {
|
104
|
+
char name[36];
|
105
|
+
bson_iter_t iter;
|
106
|
+
bson_iter_t child;
|
107
|
+
int i;
|
108
|
+
|
109
|
+
BSON_ASSERT(num_markings < 10);
|
110
|
+
BSON_ASSERT(num_deterministic < 10);
|
111
|
+
BSON_ASSERT(num_random < 10);
|
112
|
+
BSON_ASSERT(num_binary < 10);
|
113
|
+
BSON_ASSERT(num_other < 10);
|
114
|
+
|
115
|
+
memset(name, 0, 36);
|
116
|
+
|
117
|
+
if (tester->parent != NEST_IN_NONE) {
|
118
|
+
for (i = 0; i < num_other; i++) {
|
119
|
+
snprintf(name, 13, "other.field%d", i);
|
120
|
+
bson_iter_init(&iter, bson);
|
121
|
+
BSON_ASSERT(bson_iter_find_descendant(&iter, name, &child));
|
122
|
+
}
|
123
|
+
|
124
|
+
for (i = 0; i < num_markings; i++) {
|
125
|
+
snprintf(name, 18, "markings.marking%d", i);
|
126
|
+
bson_iter_init(&iter, bson);
|
127
|
+
BSON_ASSERT(bson_iter_find_descendant(&iter, name, &child));
|
128
|
+
}
|
129
|
+
for (i = 0; i < num_random; i++) {
|
130
|
+
snprintf(name, 15, "random.random%d", i);
|
131
|
+
bson_iter_init(&iter, bson);
|
132
|
+
BSON_ASSERT(bson_iter_find_descendant(&iter, name, &child));
|
133
|
+
}
|
134
|
+
for (i = 0; i < num_deterministic; i++) {
|
135
|
+
snprintf(name, 29, "deterministic.deterministic%d", i);
|
136
|
+
bson_iter_init(&iter, bson);
|
137
|
+
BSON_ASSERT(bson_iter_find_descendant(&iter, name, &child));
|
138
|
+
}
|
139
|
+
for (i = 0; i < num_binary; i++) {
|
140
|
+
snprintf(name, 15, "binary.binary%d", i);
|
141
|
+
bson_iter_init(&iter, bson);
|
142
|
+
BSON_ASSERT(bson_iter_find_descendant(&iter, name, &child));
|
143
|
+
}
|
144
|
+
|
145
|
+
} else {
|
146
|
+
/* When there's no nesting, just count fields. */
|
147
|
+
bson_iter_init(&iter, bson);
|
148
|
+
BSON_ASSERT(_field_count(&iter) == (num_other + num_binary + num_markings + num_deterministic + num_random));
|
149
|
+
}
|
164
150
|
}
|
165
151
|
|
166
|
-
static bson_t *
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
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
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
}
|
252
|
-
|
253
|
-
if (tester->parent == NEST_IN_DOCUMENT) {
|
254
|
-
BSON_ASSERT (bson_append_document_end (parent, &bson));
|
255
|
-
return parent;
|
256
|
-
} else if (tester->parent == NEST_IN_ARRAY) {
|
257
|
-
BSON_ASSERT (bson_append_array_end (parent, &bson));
|
258
|
-
return parent;
|
259
|
-
}
|
260
|
-
|
261
|
-
parent = bson_copy (&bson);
|
262
|
-
bson_destroy (&bson);
|
263
|
-
return parent;
|
152
|
+
static bson_t *_assemble_bson(int num_markings,
|
153
|
+
int num_deterministic,
|
154
|
+
int num_random,
|
155
|
+
int num_binary,
|
156
|
+
int num_other,
|
157
|
+
_util_tester_t *tester) {
|
158
|
+
char name[24];
|
159
|
+
bson_t *parent = NULL;
|
160
|
+
bson_t bson;
|
161
|
+
int i;
|
162
|
+
|
163
|
+
/* Field names only take single-digit add-ons, for now */
|
164
|
+
BSON_ASSERT(num_markings < 10);
|
165
|
+
BSON_ASSERT(num_deterministic < 10);
|
166
|
+
BSON_ASSERT(num_random < 10);
|
167
|
+
BSON_ASSERT(num_binary < 10);
|
168
|
+
BSON_ASSERT(num_other < 10);
|
169
|
+
|
170
|
+
memset(name, 0, 24);
|
171
|
+
|
172
|
+
/* If we have a nesting type, nest each kind of field inside one */
|
173
|
+
if (tester->parent == NEST_IN_DOCUMENT) {
|
174
|
+
parent = bson_new();
|
175
|
+
bson_append_document_begin(parent, "other", -1, &bson);
|
176
|
+
} else if (tester->parent == NEST_IN_ARRAY) {
|
177
|
+
parent = bson_new();
|
178
|
+
bson_append_array_begin(parent, "other", -1, &bson);
|
179
|
+
} else {
|
180
|
+
bson_init(&bson);
|
181
|
+
}
|
182
|
+
|
183
|
+
/* Append some other filler fields */
|
184
|
+
for (i = 0; i < num_other; i++) {
|
185
|
+
snprintf(name, 7, "field%d", i);
|
186
|
+
BSON_ASSERT(bson_append_utf8(&bson, name, 6, "hi", -1));
|
187
|
+
}
|
188
|
+
|
189
|
+
_reset_nesting(parent, &bson, tester->parent, "markings");
|
190
|
+
|
191
|
+
/* Append some number of markings */
|
192
|
+
for (i = 0; i < num_markings; i++) {
|
193
|
+
snprintf(name, 9, "marking%d", i);
|
194
|
+
_append_marking(&bson, name, 8);
|
195
|
+
}
|
196
|
+
|
197
|
+
_reset_nesting(parent, &bson, tester->parent, "random");
|
198
|
+
|
199
|
+
/* Append some number of random ciphertexts */
|
200
|
+
for (i = 0; i < num_random; i++) {
|
201
|
+
snprintf(name, 8, "random%d", i);
|
202
|
+
_append_ciphertext_with_subtype(&bson, name, 7, 6, MONGOCRYPT_ENCRYPTION_ALGORITHM_RANDOM, tester->tester);
|
203
|
+
}
|
204
|
+
|
205
|
+
_reset_nesting(parent, &bson, tester->parent, "deterministic");
|
206
|
+
|
207
|
+
/* Append some number of deterministic ciphertexts */
|
208
|
+
for (i = 0; i < num_deterministic; i++) {
|
209
|
+
snprintf(name, 15, "deterministic%d", i);
|
210
|
+
_append_ciphertext_with_subtype(&bson,
|
211
|
+
name,
|
212
|
+
14,
|
213
|
+
6,
|
214
|
+
MONGOCRYPT_ENCRYPTION_ALGORITHM_DETERMINISTIC,
|
215
|
+
tester->tester);
|
216
|
+
}
|
217
|
+
|
218
|
+
_reset_nesting(parent, &bson, tester->parent, "binary");
|
219
|
+
|
220
|
+
/* Append some number of other bson subtype 6 fields */
|
221
|
+
for (i = 0; i < num_binary; i++) {
|
222
|
+
snprintf(name, 8, "binary%d", i);
|
223
|
+
_append_ciphertext_with_subtype(&bson, name, 7, 5, MONGOCRYPT_ENCRYPTION_ALGORITHM_NONE, tester->tester);
|
224
|
+
}
|
225
|
+
|
226
|
+
if (tester->parent == NEST_IN_DOCUMENT) {
|
227
|
+
BSON_ASSERT(bson_append_document_end(parent, &bson));
|
228
|
+
return parent;
|
229
|
+
} else if (tester->parent == NEST_IN_ARRAY) {
|
230
|
+
BSON_ASSERT(bson_append_array_end(parent, &bson));
|
231
|
+
return parent;
|
232
|
+
}
|
233
|
+
|
234
|
+
parent = bson_copy(&bson);
|
235
|
+
bson_destroy(&bson);
|
236
|
+
return parent;
|
264
237
|
}
|
265
238
|
|
266
|
-
static bool
|
267
|
-
|
268
|
-
_mongocrypt_buffer_t *in,
|
269
|
-
mongocrypt_status_t *status)
|
270
|
-
{
|
271
|
-
int *matched = (int *) ctx;
|
239
|
+
static bool test_traverse_cb(void *ctx, _mongocrypt_buffer_t *in, mongocrypt_status_t *status) {
|
240
|
+
int *matched = (int *)ctx;
|
272
241
|
|
273
|
-
|
242
|
+
*matched += 1;
|
274
243
|
|
275
|
-
|
244
|
+
return true;
|
276
245
|
}
|
277
246
|
|
278
|
-
static void
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
BSON_ASSERT (_mongocrypt_traverse_binary_in_bson (
|
305
|
-
test_traverse_cb, &matched, match, &iter, status));
|
306
|
-
|
307
|
-
/* Count matches */
|
308
|
-
BSON_ASSERT (matched == num_matches);
|
309
|
-
|
310
|
-
bson_destroy (bson);
|
311
|
-
mongocrypt_status_destroy (status);
|
247
|
+
static void test_traverse(int num_markings,
|
248
|
+
int num_deterministic,
|
249
|
+
int num_random,
|
250
|
+
int num_binary,
|
251
|
+
int num_other,
|
252
|
+
traversal_match_t match,
|
253
|
+
_util_tester_t *tester,
|
254
|
+
int num_matches) {
|
255
|
+
mongocrypt_status_t *status;
|
256
|
+
bson_iter_t iter;
|
257
|
+
bson_t *bson;
|
258
|
+
int matched = 0;
|
259
|
+
|
260
|
+
status = mongocrypt_status_new();
|
261
|
+
/* First, assemble the requested bson document */
|
262
|
+
bson = _assemble_bson(num_markings, num_deterministic, num_random, num_binary, num_other, tester);
|
263
|
+
|
264
|
+
/* Traverse */
|
265
|
+
BSON_ASSERT(bson_iter_init(&iter, bson));
|
266
|
+
BSON_ASSERT(_mongocrypt_traverse_binary_in_bson(test_traverse_cb, &matched, match, &iter, status));
|
267
|
+
|
268
|
+
/* Count matches */
|
269
|
+
BSON_ASSERT(matched == num_matches);
|
270
|
+
|
271
|
+
bson_destroy(bson);
|
272
|
+
mongocrypt_status_destroy(status);
|
312
273
|
}
|
313
274
|
|
314
|
-
static void
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
test_traverse (0, 0, 0, 0, 0, TRAVERSE_MATCH_CIPHERTEXT, tester, 0);
|
319
|
-
test_traverse (0, 0, 0, 0, 0, TRAVERSE_MATCH_MARKING, tester, 0);
|
275
|
+
static void test_mongocrypt_traverse_util_nesting(_util_tester_t *tester) {
|
276
|
+
/* Empty document */
|
277
|
+
test_traverse(0, 0, 0, 0, 0, TRAVERSE_MATCH_CIPHERTEXT, tester, 0);
|
278
|
+
test_traverse(0, 0, 0, 0, 0, TRAVERSE_MATCH_MARKING, tester, 0);
|
320
279
|
|
321
|
-
|
322
|
-
|
323
|
-
|
280
|
+
/* Document with only non-binary fields */
|
281
|
+
test_traverse(0, 0, 0, 0, 2, TRAVERSE_MATCH_CIPHERTEXT, tester, 0);
|
282
|
+
test_traverse(0, 0, 0, 0, 2, TRAVERSE_MATCH_MARKING, tester, 0);
|
324
283
|
|
325
|
-
|
326
|
-
|
327
|
-
|
284
|
+
/* Document with only binary fields that aren't subtype 0x06 */
|
285
|
+
test_traverse(0, 0, 0, 2, 0, TRAVERSE_MATCH_CIPHERTEXT, tester, 0);
|
286
|
+
test_traverse(0, 0, 0, 2, 0, TRAVERSE_MATCH_MARKING, tester, 0);
|
328
287
|
|
329
|
-
|
330
|
-
|
331
|
-
|
288
|
+
/* Document with a single marking */
|
289
|
+
test_traverse(1, 0, 0, 0, 0, TRAVERSE_MATCH_CIPHERTEXT, tester, 0);
|
290
|
+
test_traverse(1, 0, 0, 0, 0, TRAVERSE_MATCH_MARKING, tester, 1);
|
332
291
|
|
333
|
-
|
334
|
-
|
335
|
-
|
292
|
+
/* Document with multiple markings */
|
293
|
+
test_traverse(3, 0, 0, 0, 0, TRAVERSE_MATCH_CIPHERTEXT, tester, 0);
|
294
|
+
test_traverse(3, 0, 0, 0, 0, TRAVERSE_MATCH_MARKING, tester, 3);
|
336
295
|
|
337
|
-
|
338
|
-
|
339
|
-
|
296
|
+
/* Document with multiple markings and other fields */
|
297
|
+
test_traverse(2, 0, 0, 1, 1, TRAVERSE_MATCH_CIPHERTEXT, tester, 0);
|
298
|
+
test_traverse(2, 0, 0, 1, 1, TRAVERSE_MATCH_MARKING, tester, 2);
|
340
299
|
|
341
|
-
|
342
|
-
|
343
|
-
|
300
|
+
/* Document with a single random ciphertext */
|
301
|
+
test_traverse(0, 0, 1, 0, 0, TRAVERSE_MATCH_CIPHERTEXT, tester, 1);
|
302
|
+
test_traverse(0, 0, 1, 0, 0, TRAVERSE_MATCH_MARKING, tester, 0);
|
344
303
|
|
345
|
-
|
346
|
-
|
347
|
-
|
304
|
+
/* Document with a single deterministic ciphertext */
|
305
|
+
test_traverse(0, 1, 0, 0, 0, TRAVERSE_MATCH_CIPHERTEXT, tester, 1);
|
306
|
+
test_traverse(0, 1, 0, 0, 0, TRAVERSE_MATCH_MARKING, tester, 0);
|
348
307
|
|
349
|
-
|
350
|
-
|
351
|
-
|
308
|
+
/* Document with multiple ciphertexts */
|
309
|
+
test_traverse(0, 1, 1, 0, 0, TRAVERSE_MATCH_CIPHERTEXT, tester, 2);
|
310
|
+
test_traverse(0, 1, 1, 0, 0, TRAVERSE_MATCH_MARKING, tester, 0);
|
352
311
|
|
353
|
-
|
354
|
-
|
355
|
-
|
312
|
+
/* Document with multiple ciphertexts and other fields */
|
313
|
+
test_traverse(0, 1, 2, 0, 2, TRAVERSE_MATCH_CIPHERTEXT, tester, 3);
|
314
|
+
test_traverse(0, 1, 2, 0, 2, TRAVERSE_MATCH_MARKING, tester, 0);
|
356
315
|
|
357
|
-
|
358
|
-
|
359
|
-
|
316
|
+
/* Documents with all types of fields */
|
317
|
+
test_traverse(1, 1, 1, 1, 1, TRAVERSE_MATCH_CIPHERTEXT, tester, 2);
|
318
|
+
test_traverse(1, 1, 1, 1, 1, TRAVERSE_MATCH_MARKING, tester, 1);
|
360
319
|
}
|
361
320
|
|
362
|
-
static bool
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
*matches += 1;
|
374
|
-
}
|
375
|
-
|
376
|
-
return true;
|
321
|
+
static bool post_transform_traverse_check(void *ctx, _mongocrypt_buffer_t *in, mongocrypt_status_t *status) {
|
322
|
+
int *matches = (int *)ctx;
|
323
|
+
uint8_t *message;
|
324
|
+
|
325
|
+
message = in->data;
|
326
|
+
message += 1;
|
327
|
+
if (memcmp("secretmessage", message, 13) == 0) {
|
328
|
+
*matches += 1;
|
329
|
+
}
|
330
|
+
|
331
|
+
return true;
|
377
332
|
}
|
378
333
|
|
379
|
-
static bool
|
380
|
-
|
381
|
-
_mongocrypt_buffer_t *in,
|
382
|
-
bson_value_t *out,
|
383
|
-
mongocrypt_status_t *status)
|
384
|
-
{
|
385
|
-
int *matches = (int *) ctx;
|
334
|
+
static bool test_transform_cb(void *ctx, _mongocrypt_buffer_t *in, bson_value_t *out, mongocrypt_status_t *status) {
|
335
|
+
int *matches = (int *)ctx;
|
386
336
|
|
387
|
-
|
337
|
+
*matches += 1;
|
388
338
|
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
339
|
+
/* When we transform, keep first byte so we get the
|
340
|
+
same number of matches in the followup traverse */
|
341
|
+
out->value_type = BSON_TYPE_BINARY;
|
342
|
+
out->value.v_binary.subtype = 6;
|
343
|
+
out->value.v_binary.data = bson_malloc0(14);
|
344
|
+
BSON_ASSERT(out->value.v_binary.data);
|
395
345
|
|
396
|
-
|
397
|
-
|
398
|
-
|
346
|
+
out->value.v_binary.data[0] = in->data[0];
|
347
|
+
memcpy(out->value.v_binary.data + 1, "secretmessage", 13);
|
348
|
+
out->value.v_binary.data_len = 14;
|
399
349
|
|
400
|
-
|
350
|
+
return true;
|
401
351
|
}
|
402
352
|
|
403
|
-
static void
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
/* Also, make sure we have the correct number of
|
444
|
-
non-matching fields */
|
445
|
-
_assert_correct_fields (&out,
|
446
|
-
num_markings,
|
447
|
-
num_deterministic,
|
448
|
-
num_random,
|
449
|
-
num_binary,
|
450
|
-
num_other,
|
451
|
-
tester);
|
452
|
-
|
453
|
-
|
454
|
-
BSON_ASSERT (matches == num_matches);
|
455
|
-
|
456
|
-
bson_destroy (bson);
|
457
|
-
bson_destroy (&out);
|
458
|
-
mongocrypt_status_destroy (status);
|
353
|
+
static void test_transform(int num_markings,
|
354
|
+
int num_deterministic,
|
355
|
+
int num_random,
|
356
|
+
int num_binary,
|
357
|
+
int num_other,
|
358
|
+
traversal_match_t match,
|
359
|
+
_util_tester_t *tester,
|
360
|
+
int num_matches) {
|
361
|
+
mongocrypt_status_t *status;
|
362
|
+
bson_iter_t iter;
|
363
|
+
bson_t *bson;
|
364
|
+
bson_t out = BSON_INITIALIZER;
|
365
|
+
int matches = 0;
|
366
|
+
|
367
|
+
status = mongocrypt_status_new();
|
368
|
+
/* First, assemble the requested bson document */
|
369
|
+
bson = _assemble_bson(num_markings, num_deterministic, num_random, num_binary, num_other, tester);
|
370
|
+
|
371
|
+
/* Perform a transformation, count matches */
|
372
|
+
BSON_ASSERT(bson_iter_init(&iter, bson));
|
373
|
+
BSON_ASSERT(_mongocrypt_transform_binary_in_bson(test_transform_cb, &matches, match, &iter, &out, status));
|
374
|
+
|
375
|
+
/* Make sure we had the correct number of matches */
|
376
|
+
BSON_ASSERT(matches == num_matches);
|
377
|
+
|
378
|
+
/* Now, traverse through the document again and
|
379
|
+
count the actual transformations */
|
380
|
+
matches = 0;
|
381
|
+
BSON_ASSERT(bson_iter_init(&iter, &out));
|
382
|
+
BSON_ASSERT(_mongocrypt_traverse_binary_in_bson(post_transform_traverse_check, &matches, match, &iter, status));
|
383
|
+
|
384
|
+
/* Also, make sure we have the correct number of
|
385
|
+
non-matching fields */
|
386
|
+
_assert_correct_fields(&out, num_markings, num_deterministic, num_random, num_binary, num_other, tester);
|
387
|
+
|
388
|
+
BSON_ASSERT(matches == num_matches);
|
389
|
+
|
390
|
+
bson_destroy(bson);
|
391
|
+
bson_destroy(&out);
|
392
|
+
mongocrypt_status_destroy(status);
|
459
393
|
}
|
460
394
|
|
461
|
-
static void
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
test_transform (0, 0, 0, 0, 0, TRAVERSE_MATCH_CIPHERTEXT, tester, 0);
|
466
|
-
test_transform (0, 0, 0, 0, 0, TRAVERSE_MATCH_MARKING, tester, 0);
|
395
|
+
static void test_mongocrypt_transform_util_nesting(_util_tester_t *tester) {
|
396
|
+
/* Empty document */
|
397
|
+
test_transform(0, 0, 0, 0, 0, TRAVERSE_MATCH_CIPHERTEXT, tester, 0);
|
398
|
+
test_transform(0, 0, 0, 0, 0, TRAVERSE_MATCH_MARKING, tester, 0);
|
467
399
|
|
468
|
-
|
469
|
-
|
470
|
-
|
400
|
+
/* Document with only non-binary fields */
|
401
|
+
test_transform(0, 0, 0, 0, 2, TRAVERSE_MATCH_CIPHERTEXT, tester, 0);
|
402
|
+
test_transform(0, 0, 0, 0, 2, TRAVERSE_MATCH_MARKING, tester, 0);
|
471
403
|
|
472
|
-
|
473
|
-
|
474
|
-
|
404
|
+
/* Document with only binary fields that aren't subtype 0x06 */
|
405
|
+
test_transform(0, 0, 0, 2, 0, TRAVERSE_MATCH_CIPHERTEXT, tester, 0);
|
406
|
+
test_transform(0, 0, 0, 2, 0, TRAVERSE_MATCH_MARKING, tester, 0);
|
475
407
|
|
476
|
-
|
477
|
-
|
478
|
-
|
408
|
+
/* Document with a single marking */
|
409
|
+
test_transform(1, 0, 0, 0, 0, TRAVERSE_MATCH_CIPHERTEXT, tester, 0);
|
410
|
+
test_transform(1, 0, 0, 0, 0, TRAVERSE_MATCH_MARKING, tester, 1);
|
479
411
|
|
480
|
-
|
481
|
-
|
482
|
-
|
412
|
+
/* Document with multiple markings */
|
413
|
+
test_transform(3, 0, 0, 0, 0, TRAVERSE_MATCH_CIPHERTEXT, tester, 0);
|
414
|
+
test_transform(3, 0, 0, 0, 0, TRAVERSE_MATCH_MARKING, tester, 3);
|
483
415
|
|
484
|
-
|
485
|
-
|
486
|
-
|
416
|
+
/* Document with multiple markings and other fields */
|
417
|
+
test_transform(2, 0, 0, 1, 1, TRAVERSE_MATCH_CIPHERTEXT, tester, 0);
|
418
|
+
test_transform(2, 0, 0, 1, 1, TRAVERSE_MATCH_MARKING, tester, 2);
|
487
419
|
|
488
|
-
|
489
|
-
|
490
|
-
|
420
|
+
/* Document with a single random ciphertext */
|
421
|
+
test_transform(0, 0, 1, 0, 0, TRAVERSE_MATCH_CIPHERTEXT, tester, 1);
|
422
|
+
test_transform(0, 0, 1, 0, 0, TRAVERSE_MATCH_MARKING, tester, 0);
|
491
423
|
|
492
|
-
|
493
|
-
|
494
|
-
|
424
|
+
/* Document with a single deterministic ciphertext */
|
425
|
+
test_transform(0, 1, 0, 0, 0, TRAVERSE_MATCH_CIPHERTEXT, tester, 1);
|
426
|
+
test_transform(0, 1, 0, 0, 0, TRAVERSE_MATCH_MARKING, tester, 0);
|
495
427
|
|
496
|
-
|
497
|
-
|
498
|
-
|
428
|
+
/* Document with multiple ciphertexts */
|
429
|
+
test_transform(0, 1, 1, 0, 0, TRAVERSE_MATCH_CIPHERTEXT, tester, 2);
|
430
|
+
test_transform(0, 1, 1, 0, 0, TRAVERSE_MATCH_MARKING, tester, 0);
|
499
431
|
|
500
|
-
|
501
|
-
|
502
|
-
|
432
|
+
/* Document with multiple ciphertexts and other fields */
|
433
|
+
test_transform(0, 1, 2, 0, 2, TRAVERSE_MATCH_CIPHERTEXT, tester, 3);
|
434
|
+
test_transform(0, 1, 2, 0, 2, TRAVERSE_MATCH_MARKING, tester, 0);
|
503
435
|
|
504
|
-
|
505
|
-
|
506
|
-
|
436
|
+
/* Documents with all types of fields */
|
437
|
+
test_transform(1, 1, 1, 1, 1, TRAVERSE_MATCH_CIPHERTEXT, tester, 2);
|
438
|
+
test_transform(1, 1, 1, 1, 1, TRAVERSE_MATCH_MARKING, tester, 1);
|
507
439
|
}
|
508
440
|
|
509
|
-
static void
|
510
|
-
|
511
|
-
{
|
512
|
-
_util_tester_t ctx = {0};
|
441
|
+
static void test_mongocrypt_transform_util(_mongocrypt_tester_t *tester) {
|
442
|
+
_util_tester_t ctx = {0};
|
513
443
|
|
514
|
-
|
444
|
+
ctx.tester = tester;
|
515
445
|
|
516
|
-
|
517
|
-
|
446
|
+
ctx.parent = NEST_IN_NONE;
|
447
|
+
test_mongocrypt_transform_util_nesting(&ctx);
|
518
448
|
|
519
|
-
|
520
|
-
|
449
|
+
ctx.parent = NEST_IN_DOCUMENT;
|
450
|
+
test_mongocrypt_transform_util_nesting(&ctx);
|
521
451
|
|
522
|
-
|
523
|
-
|
452
|
+
ctx.parent = NEST_IN_ARRAY;
|
453
|
+
test_mongocrypt_transform_util_nesting(&ctx);
|
524
454
|
}
|
525
455
|
|
526
|
-
static void
|
527
|
-
|
528
|
-
{
|
529
|
-
_util_tester_t ctx;
|
456
|
+
static void test_mongocrypt_traverse_util(_mongocrypt_tester_t *tester) {
|
457
|
+
_util_tester_t ctx;
|
530
458
|
|
531
|
-
|
459
|
+
ctx.tester = tester;
|
532
460
|
|
533
|
-
|
534
|
-
|
461
|
+
ctx.parent = NEST_IN_NONE;
|
462
|
+
test_mongocrypt_traverse_util_nesting(&ctx);
|
535
463
|
|
536
|
-
|
537
|
-
|
464
|
+
ctx.parent = NEST_IN_DOCUMENT;
|
465
|
+
test_mongocrypt_traverse_util_nesting(&ctx);
|
538
466
|
|
539
|
-
|
540
|
-
|
467
|
+
ctx.parent = NEST_IN_ARRAY;
|
468
|
+
test_mongocrypt_traverse_util_nesting(&ctx);
|
541
469
|
}
|
542
470
|
|
543
|
-
void
|
544
|
-
|
545
|
-
|
546
|
-
INSTALL_TEST (test_mongocrypt_traverse_util);
|
547
|
-
INSTALL_TEST (test_mongocrypt_transform_util);
|
471
|
+
void _mongocrypt_tester_install_traverse_util(_mongocrypt_tester_t *tester) {
|
472
|
+
INSTALL_TEST(test_mongocrypt_traverse_util);
|
473
|
+
INSTALL_TEST(test_mongocrypt_transform_util);
|
548
474
|
}
|