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
@@ -19,10 +19,10 @@
|
|
19
19
|
|
20
20
|
#include <bson/bson.h>
|
21
21
|
|
22
|
-
#include "mongocrypt.h"
|
23
22
|
#include "mongocrypt-config.h"
|
24
23
|
#include "mongocrypt-crypto-private.h"
|
25
24
|
#include "mongocrypt-marking-private.h"
|
25
|
+
#include "mongocrypt.h"
|
26
26
|
#include "test-mongocrypt.h"
|
27
27
|
|
28
28
|
#ifdef MONGOCRYPT_ENABLE_CRYPTO_COMMON_CRYPTO
|
@@ -30,496 +30,439 @@
|
|
30
30
|
#endif
|
31
31
|
|
32
32
|
/* Return a repeated character with no null terminator. */
|
33
|
-
char *
|
34
|
-
|
35
|
-
|
36
|
-
char *result;
|
37
|
-
uint32_t i;
|
33
|
+
char *_mongocrypt_repeat_char(char c, uint32_t times) {
|
34
|
+
char *result;
|
35
|
+
uint32_t i;
|
38
36
|
|
39
|
-
|
40
|
-
|
37
|
+
result = bson_malloc(times);
|
38
|
+
BSON_ASSERT(result);
|
41
39
|
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
for (i = 0; i < times; i++) {
|
41
|
+
result[i] = c;
|
42
|
+
}
|
45
43
|
|
46
|
-
|
44
|
+
return result;
|
47
45
|
}
|
48
46
|
|
49
|
-
void
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
bson_json_reader_destroy (reader);
|
47
|
+
void _load_json_as_bson(const char *path, bson_t *out) {
|
48
|
+
bson_error_t error;
|
49
|
+
bson_json_reader_t *reader;
|
50
|
+
bool ret;
|
51
|
+
|
52
|
+
reader = bson_json_reader_new_from_file(path, &error);
|
53
|
+
if (!reader) {
|
54
|
+
fprintf(stderr, "error reading: %s\n", path);
|
55
|
+
}
|
56
|
+
ASSERT_OR_PRINT_BSON(reader, error);
|
57
|
+
bson_init(out);
|
58
|
+
ret = bson_json_reader_read(reader, out, &error);
|
59
|
+
ASSERT_OR_PRINT_BSON(ret, error);
|
60
|
+
|
61
|
+
bson_json_reader_destroy(reader);
|
66
62
|
}
|
67
63
|
|
68
|
-
#define TEST_DATA_COUNT_INC(var)
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
{
|
78
|
-
bson_t as_bson;
|
79
|
-
_mongocrypt_buffer_t *buf;
|
80
|
-
|
81
|
-
_load_json_as_bson (path, &as_bson);
|
82
|
-
|
83
|
-
buf = &tester->file_bufs[tester->file_count];
|
84
|
-
_mongocrypt_buffer_steal_from_bson (buf, &as_bson);
|
85
|
-
tester->file_paths[tester->file_count] = bson_strdup (path);
|
86
|
-
TEST_DATA_COUNT_INC (tester->file_count);
|
87
|
-
}
|
64
|
+
#define TEST_DATA_COUNT_INC(var) \
|
65
|
+
(var)++; \
|
66
|
+
if ((var) >= TEST_DATA_COUNT) { \
|
67
|
+
TEST_ERROR("TEST_DATA_COUNT exceeded for %s. Increment TEST_DATA_COUNT.", #var); \
|
68
|
+
}
|
69
|
+
|
70
|
+
static void _load_json(_mongocrypt_tester_t *tester, const char *path) {
|
71
|
+
bson_t as_bson;
|
72
|
+
_mongocrypt_buffer_t *buf;
|
88
73
|
|
74
|
+
_load_json_as_bson(path, &as_bson);
|
89
75
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
char *contents;
|
95
|
-
int n_read;
|
96
|
-
int filesize;
|
97
|
-
char storage[512];
|
98
|
-
int i;
|
99
|
-
_mongocrypt_buffer_t *buf;
|
100
|
-
|
101
|
-
filesize = 0;
|
102
|
-
contents = NULL;
|
103
|
-
fd = open (path, O_RDONLY);
|
104
|
-
while ((n_read = read (fd, storage, sizeof (storage))) > 0) {
|
105
|
-
filesize += n_read;
|
106
|
-
/* Append storage. Performance does not matter. */
|
107
|
-
contents = bson_realloc (contents, filesize);
|
108
|
-
memcpy (contents + (filesize - n_read), storage, n_read);
|
109
|
-
}
|
110
|
-
|
111
|
-
if (n_read < 0) {
|
112
|
-
fprintf (stderr, "failed to read %s\n", path);
|
113
|
-
abort ();
|
114
|
-
}
|
115
|
-
|
116
|
-
close (fd);
|
117
|
-
|
118
|
-
buf = &tester->file_bufs[tester->file_count];
|
119
|
-
/* copy and fix newlines */
|
120
|
-
_mongocrypt_buffer_init (buf);
|
121
|
-
/* allocate twice the size since \n may become \r\n */
|
122
|
-
buf->data = bson_malloc0 (filesize * 2);
|
123
|
-
BSON_ASSERT (buf->data);
|
124
|
-
|
125
|
-
buf->len = 0;
|
126
|
-
buf->owned = true;
|
127
|
-
for (i = 0; i < filesize; i++) {
|
128
|
-
if (contents[i] == '\n' && contents[i - 1] != '\r') {
|
129
|
-
buf->data[buf->len++] = '\r';
|
130
|
-
}
|
131
|
-
buf->data[buf->len++] = contents[i];
|
132
|
-
}
|
133
|
-
|
134
|
-
bson_free (contents);
|
135
|
-
tester->file_paths[tester->file_count] = bson_strdup (path);
|
136
|
-
TEST_DATA_COUNT_INC (tester->file_count);
|
76
|
+
buf = &tester->file_bufs[tester->file_count];
|
77
|
+
_mongocrypt_buffer_steal_from_bson(buf, &as_bson);
|
78
|
+
tester->file_paths[tester->file_count] = bson_strdup(path);
|
79
|
+
TEST_DATA_COUNT_INC(tester->file_count);
|
137
80
|
}
|
138
81
|
|
82
|
+
static void _load_http(_mongocrypt_tester_t *tester, const char *path) {
|
83
|
+
int fd;
|
84
|
+
char *contents;
|
85
|
+
int n_read;
|
86
|
+
int filesize;
|
87
|
+
char storage[512];
|
88
|
+
int i;
|
89
|
+
_mongocrypt_buffer_t *buf;
|
90
|
+
|
91
|
+
filesize = 0;
|
92
|
+
contents = NULL;
|
93
|
+
fd = open(path, O_RDONLY);
|
94
|
+
while ((n_read = read(fd, storage, sizeof(storage))) > 0) {
|
95
|
+
filesize += n_read;
|
96
|
+
/* Append storage. Performance does not matter. */
|
97
|
+
contents = bson_realloc(contents, filesize);
|
98
|
+
memcpy(contents + (filesize - n_read), storage, n_read);
|
99
|
+
}
|
100
|
+
|
101
|
+
if (n_read < 0) {
|
102
|
+
fprintf(stderr, "failed to read %s\n", path);
|
103
|
+
abort();
|
104
|
+
}
|
105
|
+
|
106
|
+
close(fd);
|
107
|
+
|
108
|
+
buf = &tester->file_bufs[tester->file_count];
|
109
|
+
/* copy and fix newlines */
|
110
|
+
_mongocrypt_buffer_init(buf);
|
111
|
+
/* allocate twice the size since \n may become \r\n */
|
112
|
+
buf->data = bson_malloc0(filesize * 2);
|
113
|
+
BSON_ASSERT(buf->data);
|
114
|
+
|
115
|
+
buf->len = 0;
|
116
|
+
buf->owned = true;
|
117
|
+
for (i = 0; i < filesize; i++) {
|
118
|
+
if (contents[i] == '\n' && contents[i - 1] != '\r') {
|
119
|
+
buf->data[buf->len++] = '\r';
|
120
|
+
}
|
121
|
+
buf->data[buf->len++] = contents[i];
|
122
|
+
}
|
123
|
+
|
124
|
+
bson_free(contents);
|
125
|
+
tester->file_paths[tester->file_count] = bson_strdup(path);
|
126
|
+
TEST_DATA_COUNT_INC(tester->file_count);
|
127
|
+
}
|
139
128
|
|
140
|
-
void
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
{
|
146
|
-
bool crypto_enabled;
|
129
|
+
void _mongocrypt_tester_install(_mongocrypt_tester_t *tester,
|
130
|
+
char *name,
|
131
|
+
_mongocrypt_test_fn fn,
|
132
|
+
_mongocrypt_tester_crypto_spec_t crypto_spec) {
|
133
|
+
bool crypto_enabled;
|
147
134
|
|
148
135
|
#ifdef MONGOCRYPT_ENABLE_CRYPTO
|
149
|
-
|
136
|
+
crypto_enabled = true;
|
150
137
|
#else
|
151
|
-
|
138
|
+
crypto_enabled = false;
|
152
139
|
#endif
|
153
140
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
141
|
+
if (crypto_spec == CRYPTO_REQUIRED && !crypto_enabled) {
|
142
|
+
printf("Skipping test: %s – requires crypto to be enabled\n", name);
|
143
|
+
return;
|
144
|
+
}
|
158
145
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
146
|
+
if (crypto_spec == CRYPTO_PROHIBITED && crypto_enabled) {
|
147
|
+
printf("Skipping test: %s – requires crypto to be disabled\n", name);
|
148
|
+
return;
|
149
|
+
}
|
163
150
|
|
164
|
-
|
165
|
-
|
166
|
-
|
151
|
+
tester->test_fns[tester->test_count] = fn;
|
152
|
+
tester->test_names[tester->test_count] = bson_strdup(name);
|
153
|
+
TEST_DATA_COUNT_INC(tester->test_count);
|
167
154
|
}
|
168
155
|
|
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
|
-
_mongocrypt_buffer_to_binary (&tester->file_bufs[tester->file_count - 1],
|
195
|
-
to_return);
|
196
|
-
return to_return;
|
156
|
+
mongocrypt_binary_t *_mongocrypt_tester_file(_mongocrypt_tester_t *tester, const char *path) {
|
157
|
+
int i;
|
158
|
+
mongocrypt_binary_t *to_return;
|
159
|
+
|
160
|
+
to_return = mongocrypt_binary_new();
|
161
|
+
tester->test_bin[tester->bin_count] = to_return;
|
162
|
+
TEST_DATA_COUNT_INC(tester->bin_count);
|
163
|
+
|
164
|
+
for (i = 0; i < tester->file_count; i++) {
|
165
|
+
if (0 == strcmp(tester->file_paths[i], path)) {
|
166
|
+
_mongocrypt_buffer_to_binary(&tester->file_bufs[i], to_return);
|
167
|
+
return to_return;
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
/* File not found, load it. */
|
172
|
+
if (strstr(path, ".json")) {
|
173
|
+
_load_json(tester, path);
|
174
|
+
} else if (strstr(path, ".txt")) {
|
175
|
+
_load_http(tester, path);
|
176
|
+
}
|
177
|
+
|
178
|
+
_mongocrypt_buffer_to_binary(&tester->file_bufs[tester->file_count - 1], to_return);
|
179
|
+
return to_return;
|
197
180
|
}
|
198
181
|
|
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
|
-
fprintf (stderr, "%s", error.message);
|
225
|
-
abort ();
|
226
|
-
}
|
227
|
-
bson_free (full_json);
|
228
|
-
return bson;
|
182
|
+
bson_t *_mongocrypt_tester_bson_from_json(_mongocrypt_tester_t *tester, const char *json, ...) {
|
183
|
+
va_list ap;
|
184
|
+
char *full_json;
|
185
|
+
bson_t *bson;
|
186
|
+
bson_error_t error;
|
187
|
+
char *c;
|
188
|
+
|
189
|
+
va_start(ap, json);
|
190
|
+
full_json = bson_strdupv_printf(json, ap);
|
191
|
+
/* Replace ' with " */
|
192
|
+
for (c = full_json; *c; c++) {
|
193
|
+
if (*c == '\'') {
|
194
|
+
*c = '"';
|
195
|
+
}
|
196
|
+
}
|
197
|
+
|
198
|
+
va_end(ap);
|
199
|
+
bson = &tester->test_bson[tester->bson_count];
|
200
|
+
TEST_DATA_COUNT_INC(tester->bson_count);
|
201
|
+
if (!bson_init_from_json(bson, full_json, strlen(full_json), &error)) {
|
202
|
+
fprintf(stderr, "%s", error.message);
|
203
|
+
abort();
|
204
|
+
}
|
205
|
+
bson_free(full_json);
|
206
|
+
return bson;
|
229
207
|
}
|
230
208
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
TEST_DATA_COUNT_INC (tester->bin_count);
|
263
|
-
bin->data = (uint8_t *) bson_get_data (bson);
|
264
|
-
bin->len = bson->len;
|
265
|
-
bson_free (full_json);
|
266
|
-
return bin;
|
209
|
+
mongocrypt_binary_t *_mongocrypt_tester_bin_from_json(_mongocrypt_tester_t *tester, const char *json, ...) {
|
210
|
+
va_list ap;
|
211
|
+
char *full_json;
|
212
|
+
bson_t *bson;
|
213
|
+
mongocrypt_binary_t *bin;
|
214
|
+
bson_error_t error;
|
215
|
+
char *c;
|
216
|
+
|
217
|
+
va_start(ap, json);
|
218
|
+
full_json = bson_strdupv_printf(json, ap);
|
219
|
+
/* Replace ' with " */
|
220
|
+
for (c = full_json; *c; c++) {
|
221
|
+
if (*c == '\'') {
|
222
|
+
*c = '"';
|
223
|
+
}
|
224
|
+
}
|
225
|
+
|
226
|
+
va_end(ap);
|
227
|
+
bson = &tester->test_bson[tester->bson_count];
|
228
|
+
TEST_DATA_COUNT_INC(tester->bson_count);
|
229
|
+
if (!bson_init_from_json(bson, full_json, strlen(full_json), &error)) {
|
230
|
+
fprintf(stderr, "failed to parse JSON %s: %s", error.message, json);
|
231
|
+
abort();
|
232
|
+
}
|
233
|
+
bin = mongocrypt_binary_new();
|
234
|
+
tester->test_bin[tester->bin_count] = bin;
|
235
|
+
TEST_DATA_COUNT_INC(tester->bin_count);
|
236
|
+
bin->data = (uint8_t *)bson_get_data(bson);
|
237
|
+
bin->len = bson->len;
|
238
|
+
bson_free(full_json);
|
239
|
+
return bin;
|
267
240
|
}
|
268
241
|
|
242
|
+
mongocrypt_binary_t *_mongocrypt_tester_bin(_mongocrypt_tester_t *tester, int size) {
|
243
|
+
mongocrypt_binary_t *bin;
|
244
|
+
uint8_t *blob;
|
245
|
+
int i;
|
269
246
|
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
int i;
|
247
|
+
if (size == 0) {
|
248
|
+
return NULL;
|
249
|
+
}
|
250
|
+
blob = bson_malloc(size);
|
251
|
+
BSON_ASSERT(blob);
|
276
252
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
blob = bson_malloc (size);
|
281
|
-
BSON_ASSERT (blob);
|
253
|
+
for (i = 0; i < size; i++) {
|
254
|
+
blob[i] = (i % 3) + 1; /* 1, 2, 3, 1, 2, 3, ... */
|
255
|
+
}
|
282
256
|
|
283
|
-
|
284
|
-
blob[i] = (i % 3) + 1; /* 1, 2, 3, 1, 2, 3, ... */
|
285
|
-
}
|
257
|
+
bin = mongocrypt_binary_new_from_data(blob, size);
|
286
258
|
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
TEST_DATA_COUNT_INC (tester->bin_count);
|
293
|
-
return bin;
|
259
|
+
tester->test_blob[tester->blob_count] = blob;
|
260
|
+
TEST_DATA_COUNT_INC(tester->blob_count);
|
261
|
+
tester->test_bin[tester->bin_count] = bin;
|
262
|
+
TEST_DATA_COUNT_INC(tester->bin_count);
|
263
|
+
return bin;
|
294
264
|
}
|
295
265
|
|
296
|
-
void
|
297
|
-
|
298
|
-
mongocrypt_kms_ctx_t *kms)
|
299
|
-
{
|
300
|
-
const char *endpoint;
|
301
|
-
|
302
|
-
BSON_ASSERT (mongocrypt_kms_ctx_endpoint (kms, &endpoint));
|
303
|
-
BSON_ASSERT (endpoint == strstr (endpoint, "kms.") &&
|
304
|
-
strstr (endpoint, ".amazonaws.com"));
|
305
|
-
mongocrypt_kms_ctx_feed (kms,
|
306
|
-
TEST_FILE ("./test/example/kms-decrypt-reply.txt"));
|
307
|
-
BSON_ASSERT (0 == mongocrypt_kms_ctx_bytes_needed (kms));
|
308
|
-
}
|
266
|
+
void _mongocrypt_tester_satisfy_kms(_mongocrypt_tester_t *tester, mongocrypt_kms_ctx_t *kms) {
|
267
|
+
const char *endpoint;
|
309
268
|
|
269
|
+
BSON_ASSERT(mongocrypt_kms_ctx_endpoint(kms, &endpoint));
|
270
|
+
BSON_ASSERT(endpoint == strstr(endpoint, "kms.") && strstr(endpoint, ".amazonaws.com"));
|
271
|
+
mongocrypt_kms_ctx_feed(kms, TEST_FILE("./test/example/kms-decrypt-reply.txt"));
|
272
|
+
BSON_ASSERT(0 == mongocrypt_kms_ctx_bytes_needed(kms));
|
273
|
+
}
|
310
274
|
|
311
275
|
/* Run the state machine on example data until hitting stop_state or a
|
312
276
|
* terminal state. */
|
313
|
-
void
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
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
|
-
state = mongocrypt_ctx_state (ctx);
|
398
|
-
}
|
399
|
-
ASSERT_STATE_EQUAL (state, stop_state);
|
400
|
-
mongocrypt_status_destroy (status);
|
277
|
+
void _mongocrypt_tester_run_ctx_to(_mongocrypt_tester_t *tester,
|
278
|
+
mongocrypt_ctx_t *ctx,
|
279
|
+
mongocrypt_ctx_state_t stop_state) {
|
280
|
+
mongocrypt_ctx_state_t state;
|
281
|
+
mongocrypt_kms_ctx_t *kms;
|
282
|
+
mongocrypt_status_t *status;
|
283
|
+
mongocrypt_binary_t *bin;
|
284
|
+
bool res;
|
285
|
+
|
286
|
+
status = mongocrypt_status_new();
|
287
|
+
state = mongocrypt_ctx_state(ctx);
|
288
|
+
while (state != stop_state) {
|
289
|
+
switch (state) {
|
290
|
+
case MONGOCRYPT_CTX_NEED_MONGO_COLLINFO:
|
291
|
+
if (tester->paths.collection_info) {
|
292
|
+
bin = TEST_FILE(tester->paths.collection_info);
|
293
|
+
} else {
|
294
|
+
bin = TEST_FILE("./test/example/collection-info.json");
|
295
|
+
}
|
296
|
+
BSON_ASSERT(ctx->type == _MONGOCRYPT_TYPE_ENCRYPT);
|
297
|
+
BSON_ASSERT(mongocrypt_ctx_mongo_feed(ctx, bin));
|
298
|
+
BSON_ASSERT(mongocrypt_ctx_mongo_done(ctx));
|
299
|
+
break;
|
300
|
+
case MONGOCRYPT_CTX_NEED_MONGO_MARKINGS:
|
301
|
+
if (tester->paths.mongocryptd_reply) {
|
302
|
+
bin = TEST_FILE(tester->paths.mongocryptd_reply);
|
303
|
+
} else {
|
304
|
+
bin = TEST_FILE("./test/example/mongocryptd-reply.json");
|
305
|
+
}
|
306
|
+
BSON_ASSERT(ctx->type == _MONGOCRYPT_TYPE_ENCRYPT);
|
307
|
+
res = mongocrypt_ctx_mongo_feed(ctx, bin);
|
308
|
+
mongocrypt_ctx_status(ctx, status);
|
309
|
+
ASSERT_OR_PRINT(res, status);
|
310
|
+
BSON_ASSERT(mongocrypt_ctx_mongo_done(ctx));
|
311
|
+
break;
|
312
|
+
case MONGOCRYPT_CTX_NEED_MONGO_KEYS:
|
313
|
+
if (tester->paths.key_file) {
|
314
|
+
bin = TEST_FILE(tester->paths.key_file);
|
315
|
+
} else {
|
316
|
+
bin = TEST_FILE("./test/example/key-document.json");
|
317
|
+
}
|
318
|
+
res = mongocrypt_ctx_mongo_feed(ctx, bin);
|
319
|
+
mongocrypt_ctx_status(ctx, status);
|
320
|
+
ASSERT_OR_PRINT(res, status);
|
321
|
+
BSON_ASSERT(mongocrypt_ctx_mongo_done(ctx));
|
322
|
+
break;
|
323
|
+
case MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS:
|
324
|
+
bin = TEST_BSON("{}");
|
325
|
+
mongocrypt_ctx_provide_kms_providers(ctx, bin);
|
326
|
+
break;
|
327
|
+
case MONGOCRYPT_CTX_NEED_KMS:
|
328
|
+
kms = mongocrypt_ctx_next_kms_ctx(ctx);
|
329
|
+
while (kms) {
|
330
|
+
_mongocrypt_tester_satisfy_kms(tester, kms);
|
331
|
+
kms = mongocrypt_ctx_next_kms_ctx(ctx);
|
332
|
+
}
|
333
|
+
res = mongocrypt_ctx_kms_done(ctx);
|
334
|
+
mongocrypt_ctx_status(ctx, status);
|
335
|
+
ASSERT_OR_PRINT(res, status);
|
336
|
+
break;
|
337
|
+
case MONGOCRYPT_CTX_READY:
|
338
|
+
bin = mongocrypt_binary_new();
|
339
|
+
res = mongocrypt_ctx_finalize(ctx, bin);
|
340
|
+
mongocrypt_ctx_status(ctx, status);
|
341
|
+
ASSERT_OR_PRINT(res, status);
|
342
|
+
mongocrypt_binary_destroy(bin);
|
343
|
+
break;
|
344
|
+
case MONGOCRYPT_CTX_ERROR:
|
345
|
+
mongocrypt_ctx_status(ctx, status);
|
346
|
+
fprintf(stderr, "Got error: %s\n", mongocrypt_status_message(status, NULL));
|
347
|
+
ASSERT_STATE_EQUAL(state, stop_state);
|
348
|
+
mongocrypt_status_destroy(status);
|
349
|
+
return;
|
350
|
+
case MONGOCRYPT_CTX_DONE:
|
351
|
+
ASSERT_STATE_EQUAL(state, stop_state);
|
352
|
+
mongocrypt_status_destroy(status);
|
353
|
+
return;
|
354
|
+
default: BSON_ASSERT(false && "Invalid state");
|
355
|
+
}
|
356
|
+
state = mongocrypt_ctx_state(ctx);
|
357
|
+
}
|
358
|
+
ASSERT_STATE_EQUAL(state, stop_state);
|
359
|
+
mongocrypt_status_destroy(status);
|
401
360
|
}
|
402
361
|
|
403
|
-
|
404
362
|
/* Get the plaintext associated with the encrypted doc for assertions. */
|
405
|
-
const char *
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
status);
|
423
|
-
mongocrypt_status_destroy (status);
|
424
|
-
BSON_ASSERT (BSON_ITER_HOLDS_UTF8 (&marking.v_iter));
|
425
|
-
return bson_iter_utf8 (&marking.v_iter, NULL);
|
363
|
+
const char *_mongocrypt_tester_plaintext(_mongocrypt_tester_t *tester) {
|
364
|
+
bson_t as_bson;
|
365
|
+
bson_iter_t iter;
|
366
|
+
_mongocrypt_marking_t marking;
|
367
|
+
_mongocrypt_buffer_t buf;
|
368
|
+
mongocrypt_status_t *status;
|
369
|
+
|
370
|
+
BSON_ASSERT(_mongocrypt_binary_to_bson(TEST_FILE("./test/example/mongocryptd-reply.json"), &as_bson));
|
371
|
+
/* Underlying binary data lives on in tester */
|
372
|
+
BSON_ASSERT(bson_iter_init(&iter, &as_bson));
|
373
|
+
BSON_ASSERT(bson_iter_find_descendant(&iter, "result.filter.ssn", &iter));
|
374
|
+
BSON_ASSERT(_mongocrypt_buffer_from_binary_iter(&buf, &iter));
|
375
|
+
status = mongocrypt_status_new();
|
376
|
+
ASSERT_OR_PRINT(_mongocrypt_marking_parse_unowned(&buf, &marking, status), status);
|
377
|
+
mongocrypt_status_destroy(status);
|
378
|
+
BSON_ASSERT(BSON_ITER_HOLDS_UTF8(&marking.v_iter));
|
379
|
+
return bson_iter_utf8(&marking.v_iter, NULL);
|
426
380
|
}
|
427
381
|
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
_mongocrypt_buffer_copy_from_binary (&tester->encrypted_doc, bin);
|
452
|
-
mongocrypt_ctx_destroy (ctx);
|
453
|
-
mongocrypt_destroy (crypt);
|
454
|
-
_mongocrypt_buffer_to_binary (&tester->encrypted_doc, bin);
|
455
|
-
return bin;
|
382
|
+
mongocrypt_binary_t *_mongocrypt_tester_encrypted_doc(_mongocrypt_tester_t *tester) {
|
383
|
+
mongocrypt_t *crypt;
|
384
|
+
mongocrypt_ctx_t *ctx;
|
385
|
+
mongocrypt_binary_t *bin;
|
386
|
+
|
387
|
+
bin = mongocrypt_binary_new();
|
388
|
+
if (!_mongocrypt_buffer_empty(&tester->encrypted_doc)) {
|
389
|
+
_mongocrypt_buffer_to_binary(&tester->encrypted_doc, bin);
|
390
|
+
return bin;
|
391
|
+
}
|
392
|
+
|
393
|
+
crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
394
|
+
|
395
|
+
ctx = mongocrypt_ctx_new(crypt);
|
396
|
+
ASSERT_OK(mongocrypt_ctx_encrypt_init(ctx, "test", -1, TEST_FILE("./test/example/cmd.json")), ctx);
|
397
|
+
|
398
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_READY);
|
399
|
+
mongocrypt_ctx_finalize(ctx, bin);
|
400
|
+
_mongocrypt_buffer_copy_from_binary(&tester->encrypted_doc, bin);
|
401
|
+
mongocrypt_ctx_destroy(ctx);
|
402
|
+
mongocrypt_destroy(crypt);
|
403
|
+
_mongocrypt_buffer_to_binary(&tester->encrypted_doc, bin);
|
404
|
+
return bin;
|
456
405
|
}
|
457
406
|
|
407
|
+
void _mongocrypt_tester_fill_buffer(_mongocrypt_buffer_t *buf, int n) {
|
408
|
+
uint8_t i;
|
458
409
|
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
uint8_t i;
|
463
|
-
|
464
|
-
memset (buf, 0, sizeof (*buf));
|
465
|
-
buf->data = bson_malloc (n);
|
466
|
-
BSON_ASSERT (buf->data);
|
410
|
+
memset(buf, 0, sizeof(*buf));
|
411
|
+
buf->data = bson_malloc(n);
|
412
|
+
BSON_ASSERT(buf->data);
|
467
413
|
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
414
|
+
for (i = 0; i < n; i++) {
|
415
|
+
buf->data[i] = i;
|
416
|
+
}
|
417
|
+
buf->len = n;
|
418
|
+
buf->owned = true;
|
473
419
|
}
|
474
420
|
|
475
|
-
#define PRIVATE_KEY_FOR_TESTING
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
mongocrypt_t *
|
507
|
-
|
508
|
-
{
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
mongocrypt_setopt_kms_provider_local (crypt, localkey);
|
521
|
-
mongocrypt_binary_destroy (localkey);
|
522
|
-
kms_providers = BCON_NEW ("azure",
|
421
|
+
#define PRIVATE_KEY_FOR_TESTING \
|
422
|
+
"MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC4JOyv5z05cL18ztpknRC7C" \
|
423
|
+
"FY2gYol4DAKerdVUoDJxCTmFMf39dVUEqD0WDiw/qcRtSO1/" \
|
424
|
+
"FRut08PlSPmvbyKetsLoxlpS8lukSzEFpFK7+L+R4miFOl6HvECyg7lbC1H/" \
|
425
|
+
"WGAhIz9yZRlXhRo9qmO/" \
|
426
|
+
"fB6PV9IeYtU+" \
|
427
|
+
"1xYuXicjCDPp36uuxBAnCz7JfvxJ3mdVc0vpSkbSb141nWuKNYR1mgyvvL6KzxO6mYsCo4hRA" \
|
428
|
+
"dhuizD9C4jDHk0V2gDCFBk0h8SLEdzStX8L0jG90/Og4y7J1b/cPo/" \
|
429
|
+
"kbYokkYisxe8cPlsvGBf+rZex7XPxc1yWaP080qeABJb+S88O//" \
|
430
|
+
"LAgMBAAECggEBAKVxP1m3FzHBUe2NZ3fYCc0Qa2zjK7xl1KPFp2u4CU+" \
|
431
|
+
"9sy0oZJUqQHUdm5CMprqWwIHPTftWboFenmCwrSXFOFzujljBO7Z3yc1WD3NJl1ZNepLcsRJ3" \
|
432
|
+
"WWFH5V+NLJ8Bdxlj1DMEZCwr7PC5+vpnCuYWzvT0qOPTl9RNVaW9VVjHouJ9Fg+" \
|
433
|
+
"s2DrShXDegFabl1iZEDdI4xScHoYBob06A5lw0WOCTayzw0Naf37lM8Y4psRAmI46XLiF/" \
|
434
|
+
"Vbuorna4hcChxDePlNLEfMipICcuxTcei1RBSlBa2t1tcnvoTy6cuYDqqImRYjp1KnMKlKQBn" \
|
435
|
+
"Q1NjS2TsRGm+F0FbreVCECgYEA4IDJlm8q/hVyNcPe4OzIcL1rsdYN3bNm2Y2O/" \
|
436
|
+
"YtRPIkQ446ItyxD06d9VuXsQpFp9jNACAPfCMSyHpPApqlxdc8z/" \
|
437
|
+
"xATlgHkcGezEOd1r4E7NdTpGg8y6Rj9b8kVlED6v4grbRhKcU6moyKUQT3+" \
|
438
|
+
"1B6ENZTOKyxuyDEgTwZHtFECgYEA0fqdv9h9s77d6eWmIioP7FSymq93pC4umxf6TVicpjpME" \
|
439
|
+
"rdD2ZfJGulN37dq8FOsOFnSmFYJdICj/PbJm6p1i8O21lsFCltEqVoVabJ7/" \
|
440
|
+
"0alPfdG2U76OeBqI8ZubL4BMnWXAB/" \
|
441
|
+
"VVEYbyWCNpQSDTjHQYs54qa2I0dJB7OgJt1sCgYEArctFQ02/" \
|
442
|
+
"7H5Rscl1yo3DBXO94SeiCFSPdC8f2Kt3MfOxvVdkAtkjkMACSbkoUsgbTVqTYSEOEc2jTgR3i" \
|
443
|
+
"Q13JgpHaFbbsq64V0QP3TAxbLIQUjYGVgQaF1UfLOBv8hrzgj45z/ST/" \
|
444
|
+
"G80lOl595+0nCUbmBcgG1AEWrmdF0/" \
|
445
|
+
"3RmECgYAKvIzKXXB3+19vcT2ga5Qq2l3TiPtOGsppRb2XrNs9qKdxIYvHmXo/" \
|
446
|
+
"9QP1V3SRW0XoD7ez8FpFabp42cmPOxUNk3FK3paQZABLxH5pzCWI9PzIAVfPDrm+" \
|
447
|
+
"sdnbgG7vAnwfL2IMMJSA3aDYGCbF9EgefG+" \
|
448
|
+
"STcpfqq7fQ6f5TBgLFwKBgCd7gn1xYL696SaKVSm7VngpXlczHVEpz3kStWR5gfzriPBxXgMV" \
|
449
|
+
"cWmcbajRser7ARpCEfbxM1UJyv6oAYZWVSNErNzNVb4POqLYcCNySuC6xKhs9FrEQnyKjyk8w" \
|
450
|
+
"I4VnrEMGrQ8e+qYSwYk9Gh6dKGoRMAPYVXQAO0fIsHF/T0a"
|
451
|
+
|
452
|
+
mongocrypt_t *_mongocrypt_tester_mongocrypt(tester_mongocrypt_flags flags) {
|
453
|
+
mongocrypt_t *crypt;
|
454
|
+
char localkey_data[MONGOCRYPT_KEY_LEN] = {0};
|
455
|
+
mongocrypt_binary_t *localkey;
|
456
|
+
bson_t *kms_providers;
|
457
|
+
mongocrypt_binary_t *bin;
|
458
|
+
|
459
|
+
crypt = mongocrypt_new();
|
460
|
+
mongocrypt_setopt_log_handler(crypt, _mongocrypt_stdout_log_fn, NULL);
|
461
|
+
mongocrypt_setopt_kms_provider_aws(crypt, "example", -1, "example", -1);
|
462
|
+
localkey = mongocrypt_binary_new_from_data((uint8_t *)localkey_data, sizeof localkey_data);
|
463
|
+
mongocrypt_setopt_kms_provider_local(crypt, localkey);
|
464
|
+
mongocrypt_binary_destroy(localkey);
|
465
|
+
kms_providers = BCON_NEW("azure",
|
523
466
|
"{",
|
524
467
|
"tenantId",
|
525
468
|
"",
|
@@ -540,521 +483,487 @@ _mongocrypt_tester_mongocrypt (tester_mongocrypt_flags flags)
|
|
540
483
|
"endpoint",
|
541
484
|
"localhost",
|
542
485
|
"}");
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
486
|
+
bin = mongocrypt_binary_new_from_data((uint8_t *)bson_get_data(kms_providers), kms_providers->len);
|
487
|
+
ASSERT_OK(mongocrypt_setopt_kms_providers(crypt, bin), crypt);
|
488
|
+
bson_destroy(kms_providers);
|
489
|
+
mongocrypt_binary_destroy(bin);
|
490
|
+
if (flags & TESTER_MONGOCRYPT_WITH_CRYPT_V1) {
|
491
|
+
ASSERT(mongocrypt_setopt_fle2v2(crypt, false));
|
492
|
+
}
|
493
|
+
if (flags & TESTER_MONGOCRYPT_WITH_CRYPT_SHARED_LIB) {
|
494
|
+
mongocrypt_setopt_append_crypt_shared_lib_search_path(crypt, "$ORIGIN");
|
495
|
+
}
|
496
|
+
ASSERT_OK(mongocrypt_init(crypt), crypt);
|
497
|
+
if (flags & TESTER_MONGOCRYPT_WITH_CRYPT_SHARED_LIB) {
|
498
|
+
if (mongocrypt_crypt_shared_lib_version(crypt) == 0) {
|
499
|
+
BSON_ASSERT(false
|
500
|
+
&& "tester mongocrypt requested WITH_CRYPT_SHARED_LIB, but "
|
501
|
+
"no crypt_shared library was loaded by mongocrypt_init");
|
502
|
+
}
|
503
|
+
}
|
504
|
+
return crypt;
|
560
505
|
}
|
561
506
|
|
507
|
+
static void _test_mongocrypt_bad_init(_mongocrypt_tester_t *tester) {
|
508
|
+
mongocrypt_t *crypt;
|
509
|
+
mongocrypt_binary_t *local_key;
|
510
|
+
char tmp;
|
511
|
+
|
512
|
+
/* Omitting a KMS provider must fail. */
|
513
|
+
crypt = mongocrypt_new();
|
514
|
+
ASSERT_FAILS(mongocrypt_init(crypt), crypt, "no kms provider set");
|
515
|
+
mongocrypt_destroy(crypt);
|
562
516
|
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
mongocrypt_t *crypt;
|
567
|
-
mongocrypt_binary_t *local_key;
|
568
|
-
char tmp;
|
569
|
-
|
570
|
-
|
571
|
-
/* Omitting a KMS provider must fail. */
|
572
|
-
crypt = mongocrypt_new ();
|
573
|
-
ASSERT_FAILS (mongocrypt_init (crypt), crypt, "no kms provider set");
|
574
|
-
mongocrypt_destroy (crypt);
|
575
|
-
|
576
|
-
/* Bad KMS provider options must fail. */
|
577
|
-
crypt = mongocrypt_new ();
|
578
|
-
ASSERT_FAILS (
|
579
|
-
mongocrypt_setopt_kms_provider_aws (crypt, "example", -1, NULL, -1),
|
580
|
-
crypt,
|
581
|
-
"invalid aws secret access key");
|
582
|
-
mongocrypt_destroy (crypt);
|
583
|
-
|
584
|
-
crypt = mongocrypt_new ();
|
585
|
-
ASSERT_FAILS (
|
586
|
-
mongocrypt_setopt_kms_provider_aws (crypt, NULL, -1, "example", -1),
|
587
|
-
crypt,
|
588
|
-
"invalid aws access key id");
|
589
|
-
mongocrypt_destroy (crypt);
|
590
|
-
|
591
|
-
/* Malformed UTF8 */
|
592
|
-
/* An orphaned UTF-8 continuation byte (10xxxxxx) is malformed UTF-8. */
|
593
|
-
tmp = (char) 0x80;
|
594
|
-
crypt = mongocrypt_new ();
|
595
|
-
ASSERT_FAILS (
|
596
|
-
mongocrypt_setopt_kms_provider_aws (crypt, "example", -1, &tmp, 1),
|
597
|
-
crypt,
|
598
|
-
"invalid aws secret access key");
|
599
|
-
mongocrypt_destroy (crypt);
|
600
|
-
|
601
|
-
crypt = mongocrypt_new ();
|
602
|
-
ASSERT_FAILS (mongocrypt_setopt_kms_provider_local (crypt, NULL),
|
517
|
+
/* Bad KMS provider options must fail. */
|
518
|
+
crypt = mongocrypt_new();
|
519
|
+
ASSERT_FAILS(mongocrypt_setopt_kms_provider_aws(crypt, "example", -1, NULL, -1),
|
603
520
|
crypt,
|
604
|
-
"
|
605
|
-
|
521
|
+
"invalid aws secret access key");
|
522
|
+
mongocrypt_destroy(crypt);
|
606
523
|
|
607
|
-
|
608
|
-
|
609
|
-
ASSERT_FAILS (mongocrypt_setopt_kms_provider_local (crypt, local_key),
|
524
|
+
crypt = mongocrypt_new();
|
525
|
+
ASSERT_FAILS(mongocrypt_setopt_kms_provider_aws(crypt, NULL, -1, "example", -1),
|
610
526
|
crypt,
|
611
|
-
"
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
527
|
+
"invalid aws access key id");
|
528
|
+
mongocrypt_destroy(crypt);
|
529
|
+
|
530
|
+
/* Malformed UTF8 */
|
531
|
+
/* An orphaned UTF-8 continuation byte (10xxxxxx) is malformed UTF-8. */
|
532
|
+
tmp = (char)0x80;
|
533
|
+
crypt = mongocrypt_new();
|
534
|
+
ASSERT_FAILS(mongocrypt_setopt_kms_provider_aws(crypt, "example", -1, &tmp, 1),
|
535
|
+
crypt,
|
536
|
+
"invalid aws secret access key");
|
537
|
+
mongocrypt_destroy(crypt);
|
538
|
+
|
539
|
+
crypt = mongocrypt_new();
|
540
|
+
ASSERT_FAILS(mongocrypt_setopt_kms_provider_local(crypt, NULL), crypt, "passed null key");
|
541
|
+
mongocrypt_destroy(crypt);
|
542
|
+
|
543
|
+
crypt = mongocrypt_new();
|
544
|
+
local_key = mongocrypt_binary_new();
|
545
|
+
ASSERT_FAILS(mongocrypt_setopt_kms_provider_local(crypt, local_key), crypt, "local key must be 96 bytes");
|
546
|
+
mongocrypt_binary_destroy(local_key);
|
547
|
+
mongocrypt_destroy(crypt);
|
548
|
+
|
549
|
+
/* Reinitialization must fail. */
|
550
|
+
crypt = mongocrypt_new();
|
551
|
+
ASSERT_OK(mongocrypt_setopt_kms_provider_aws(crypt, "example", -1, "example", -1), crypt);
|
552
|
+
ASSERT_OK(mongocrypt_init(crypt), crypt);
|
553
|
+
ASSERT_FAILS(mongocrypt_init(crypt), crypt, "already initialized");
|
554
|
+
mongocrypt_destroy(crypt);
|
555
|
+
/* Setting options after initialization must fail. */
|
556
|
+
crypt = mongocrypt_new();
|
557
|
+
ASSERT_OK(mongocrypt_setopt_kms_provider_aws(crypt, "example", -1, "example", -1), crypt);
|
558
|
+
ASSERT_OK(mongocrypt_init(crypt), crypt);
|
559
|
+
ASSERT_FAILS(mongocrypt_setopt_kms_provider_aws(crypt, "example", -1, "example", -1),
|
560
|
+
crypt,
|
561
|
+
"options cannot be set after initialization");
|
562
|
+
mongocrypt_destroy(crypt);
|
634
563
|
}
|
635
564
|
|
565
|
+
static void _test_setopt_schema(_mongocrypt_tester_t *tester) {
|
566
|
+
mongocrypt_t *crypt;
|
636
567
|
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
/* Test double setting. */
|
643
|
-
crypt = mongocrypt_new ();
|
644
|
-
ASSERT_OK (mongocrypt_setopt_schema_map (
|
645
|
-
crypt, TEST_FILE ("./test/data/schema-map.json")),
|
646
|
-
crypt);
|
647
|
-
ASSERT_FAILS (mongocrypt_setopt_schema_map (
|
648
|
-
crypt, TEST_FILE ("./test/data/schema-map.json")),
|
568
|
+
/* Test double setting. */
|
569
|
+
crypt = mongocrypt_new();
|
570
|
+
ASSERT_OK(mongocrypt_setopt_schema_map(crypt, TEST_FILE("./test/data/schema-map.json")), crypt);
|
571
|
+
ASSERT_FAILS(mongocrypt_setopt_schema_map(crypt, TEST_FILE("./test/data/schema-map.json")),
|
649
572
|
crypt,
|
650
573
|
"already set schema");
|
651
574
|
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
mongocrypt_setopt_schema_map (crypt, NULL), crypt, "passed null schema");
|
575
|
+
/* Test NULL/empty input */
|
576
|
+
mongocrypt_destroy(crypt);
|
577
|
+
crypt = mongocrypt_new();
|
578
|
+
ASSERT_FAILS(mongocrypt_setopt_schema_map(crypt, NULL), crypt, "passed null schema");
|
657
579
|
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
crypt,
|
662
|
-
"passed null schema");
|
580
|
+
mongocrypt_destroy(crypt);
|
581
|
+
crypt = mongocrypt_new();
|
582
|
+
ASSERT_FAILS(mongocrypt_setopt_schema_map(crypt, TEST_BIN(0)), crypt, "passed null schema");
|
663
583
|
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
"invalid bson");
|
670
|
-
mongocrypt_destroy (crypt);
|
584
|
+
/* Test malformed BSON */
|
585
|
+
mongocrypt_destroy(crypt);
|
586
|
+
crypt = mongocrypt_new();
|
587
|
+
ASSERT_FAILS(mongocrypt_setopt_schema_map(crypt, TEST_BIN(10)), crypt, "invalid bson");
|
588
|
+
mongocrypt_destroy(crypt);
|
671
589
|
}
|
672
590
|
|
673
|
-
static void
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
crypt, TEST_FILE ("./test/data/encrypted-field-config-map.json")),
|
702
|
-
crypt,
|
703
|
-
"already set encrypted_field_config_map");
|
704
|
-
mongocrypt_destroy (crypt);
|
705
|
-
|
706
|
-
/* Test NULL/empty input */
|
707
|
-
crypt = mongocrypt_new ();
|
708
|
-
ASSERT_FAILS (mongocrypt_setopt_encrypted_field_config_map (crypt, NULL),
|
591
|
+
static void _test_setopt_encrypted_field_config_map(_mongocrypt_tester_t *tester) {
|
592
|
+
mongocrypt_t *crypt;
|
593
|
+
|
594
|
+
/* Test success. */
|
595
|
+
crypt = mongocrypt_new();
|
596
|
+
ASSERT_OK(
|
597
|
+
mongocrypt_setopt_kms_providers(crypt, TEST_BSON("{'aws': {'accessKeyId': 'foo', 'secretAccessKey': 'bar'}}")),
|
598
|
+
crypt);
|
599
|
+
ASSERT_OK(
|
600
|
+
mongocrypt_setopt_encrypted_field_config_map(crypt, TEST_FILE("./test/data/encrypted-field-config-map.json")),
|
601
|
+
crypt);
|
602
|
+
ASSERT_OK(mongocrypt_init(crypt), crypt);
|
603
|
+
mongocrypt_destroy(crypt);
|
604
|
+
|
605
|
+
/* Test double setting. */
|
606
|
+
crypt = mongocrypt_new();
|
607
|
+
ASSERT_OK(
|
608
|
+
mongocrypt_setopt_encrypted_field_config_map(crypt, TEST_FILE("./test/data/encrypted-field-config-map.json")),
|
609
|
+
crypt);
|
610
|
+
ASSERT_FAILS(
|
611
|
+
mongocrypt_setopt_encrypted_field_config_map(crypt, TEST_FILE("./test/data/encrypted-field-config-map.json")),
|
612
|
+
crypt,
|
613
|
+
"already set encrypted_field_config_map");
|
614
|
+
mongocrypt_destroy(crypt);
|
615
|
+
|
616
|
+
/* Test NULL/empty input */
|
617
|
+
crypt = mongocrypt_new();
|
618
|
+
ASSERT_FAILS(mongocrypt_setopt_encrypted_field_config_map(crypt, NULL),
|
709
619
|
crypt,
|
710
620
|
"passed null encrypted_field_config_map");
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
* map if there are no intersecting collections. */
|
730
|
-
crypt = mongocrypt_new ();
|
731
|
-
ASSERT_OK (mongocrypt_setopt_schema_map (
|
732
|
-
crypt, TEST_BSON ("{'db.coll1': {}, 'db.coll2': {}}")),
|
733
|
-
crypt);
|
734
|
-
ASSERT_OK (mongocrypt_setopt_encrypted_field_config_map (
|
735
|
-
crypt, TEST_BSON ("{'db.coll3': {}, 'db.coll3': {}}")),
|
736
|
-
crypt);
|
737
|
-
ASSERT_OK (
|
738
|
-
mongocrypt_setopt_kms_providers (
|
739
|
-
crypt,
|
740
|
-
TEST_BSON (
|
741
|
-
"{'aws': {'accessKeyId': 'foo', 'secretAccessKey': 'bar'}}")),
|
742
|
-
crypt);
|
743
|
-
ASSERT_OK (mongocrypt_init (crypt), crypt);
|
744
|
-
mongocrypt_destroy (crypt);
|
745
|
-
|
746
|
-
/* Test that it is an error to set both the encrypted field config map and
|
747
|
-
* schema map referencing the same collection. */
|
748
|
-
crypt = mongocrypt_new ();
|
749
|
-
ASSERT_OK (mongocrypt_setopt_schema_map (
|
750
|
-
crypt, TEST_BSON ("{'db.coll1': {}, 'db.coll2': {}}")),
|
621
|
+
mongocrypt_destroy(crypt);
|
622
|
+
|
623
|
+
crypt = mongocrypt_new();
|
624
|
+
ASSERT_FAILS(mongocrypt_setopt_encrypted_field_config_map(crypt, TEST_BIN(0)),
|
625
|
+
crypt,
|
626
|
+
"passed null encrypted_field_config_map");
|
627
|
+
mongocrypt_destroy(crypt);
|
628
|
+
|
629
|
+
/* Test malformed BSON */
|
630
|
+
crypt = mongocrypt_new();
|
631
|
+
ASSERT_FAILS(mongocrypt_setopt_encrypted_field_config_map(crypt, TEST_BIN(10)), crypt, "invalid bson");
|
632
|
+
mongocrypt_destroy(crypt);
|
633
|
+
|
634
|
+
/* Test that it is OK to set both the encrypted field config map and schema
|
635
|
+
* map if there are no intersecting collections. */
|
636
|
+
crypt = mongocrypt_new();
|
637
|
+
ASSERT_OK(mongocrypt_setopt_schema_map(crypt, TEST_BSON("{'db.coll1': {}, 'db.coll2': {}}")), crypt);
|
638
|
+
ASSERT_OK(mongocrypt_setopt_encrypted_field_config_map(crypt, TEST_BSON("{'db.coll3': {}, 'db.coll3': {}}")),
|
751
639
|
crypt);
|
752
|
-
|
753
|
-
|
640
|
+
ASSERT_OK(
|
641
|
+
mongocrypt_setopt_kms_providers(crypt, TEST_BSON("{'aws': {'accessKeyId': 'foo', 'secretAccessKey': 'bar'}}")),
|
642
|
+
crypt);
|
643
|
+
ASSERT_OK(mongocrypt_init(crypt), crypt);
|
644
|
+
mongocrypt_destroy(crypt);
|
645
|
+
|
646
|
+
/* Test that it is an error to set both the encrypted field config map and
|
647
|
+
* schema map referencing the same collection. */
|
648
|
+
crypt = mongocrypt_new();
|
649
|
+
ASSERT_OK(mongocrypt_setopt_schema_map(crypt, TEST_BSON("{'db.coll1': {}, 'db.coll2': {}}")), crypt);
|
650
|
+
ASSERT_OK(mongocrypt_setopt_encrypted_field_config_map(crypt, TEST_BSON("{'db.coll1': {}, 'db.coll3': {}}")),
|
754
651
|
crypt);
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
mongocrypt_init (crypt),
|
763
|
-
crypt,
|
764
|
-
"db.coll1 is present in both schema_map and encrypted_field_config_map");
|
765
|
-
mongocrypt_destroy (crypt);
|
652
|
+
ASSERT_OK(
|
653
|
+
mongocrypt_setopt_kms_providers(crypt, TEST_BSON("{'aws': {'accessKeyId': 'foo', 'secretAccessKey': 'bar'}}")),
|
654
|
+
crypt);
|
655
|
+
ASSERT_FAILS(mongocrypt_init(crypt),
|
656
|
+
crypt,
|
657
|
+
"db.coll1 is present in both schema_map and encrypted_field_config_map");
|
658
|
+
mongocrypt_destroy(crypt);
|
766
659
|
}
|
767
660
|
|
768
|
-
static void
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
ASSERT_OK (mongocrypt_setopt_kms_providers (crypt, TEST_BSON ("{}")), crypt);
|
796
|
-
ASSERT_FAILS (mongocrypt_init (crypt), crypt, "no kms provider set");
|
797
|
-
mongocrypt_destroy (crypt);
|
661
|
+
static void _test_setopt_invalid_kms_providers(_mongocrypt_tester_t *tester) {
|
662
|
+
mongocrypt_t *crypt;
|
663
|
+
mongocrypt_ctx_t *ctx;
|
664
|
+
mongocrypt_status_t *status;
|
665
|
+
|
666
|
+
crypt = mongocrypt_new();
|
667
|
+
ASSERT_OK(mongocrypt_setopt_kms_provider_aws(crypt, "", 0, "", 0), crypt);
|
668
|
+
ASSERT_OK(mongocrypt_init(crypt), crypt);
|
669
|
+
|
670
|
+
ctx = mongocrypt_ctx_new(crypt);
|
671
|
+
ASSERT_OK(mongocrypt_ctx_setopt_masterkey_aws(ctx, "region", -1, "cmk", 3), ctx);
|
672
|
+
mongocrypt_ctx_datakey_init(ctx);
|
673
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_ERROR);
|
674
|
+
|
675
|
+
status = mongocrypt_status_new();
|
676
|
+
BSON_ASSERT(!mongocrypt_ctx_status(ctx, status));
|
677
|
+
ASSERT_STATUS_CONTAINS(status, "failed to create KMS message");
|
678
|
+
|
679
|
+
mongocrypt_status_destroy(status);
|
680
|
+
mongocrypt_ctx_destroy(ctx);
|
681
|
+
mongocrypt_destroy(crypt);
|
682
|
+
|
683
|
+
crypt = mongocrypt_new();
|
684
|
+
mongocrypt_setopt_use_need_kms_credentials_state(crypt);
|
685
|
+
ASSERT_OK(mongocrypt_setopt_kms_providers(crypt, TEST_BSON("{}")), crypt);
|
686
|
+
ASSERT_FAILS(mongocrypt_init(crypt), crypt, "no kms provider set");
|
687
|
+
mongocrypt_destroy(crypt);
|
798
688
|
}
|
799
689
|
|
800
690
|
typedef struct {
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
691
|
+
char *value;
|
692
|
+
/* errmsg is the expected error message from mongocrypt_setopt_kms_providers
|
693
|
+
*/
|
694
|
+
char *errmsg;
|
695
|
+
/* errmsg_init is the expected error message from mongocrypt_init */
|
696
|
+
char *errmsg_init;
|
697
|
+
bool use_need_kms_credentials_state;
|
808
698
|
} setopt_kms_providers_testcase_t;
|
809
699
|
|
810
|
-
#define EXAMPLE_LOCAL_MATERIAL
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
static void
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
crypt);
|
899
|
-
if (!test->errmsg_init) {
|
900
|
-
ASSERT_OK (mongocrypt_init (crypt), crypt);
|
901
|
-
} else {
|
902
|
-
ASSERT_FAILS (mongocrypt_init (crypt), crypt, test->errmsg_init);
|
903
|
-
}
|
904
|
-
} else {
|
905
|
-
ASSERT_FAILS (
|
906
|
-
mongocrypt_setopt_kms_providers (crypt, TEST_BSON (test->value)),
|
907
|
-
crypt,
|
908
|
-
test->errmsg);
|
909
|
-
}
|
910
|
-
mongocrypt_destroy (crypt);
|
911
|
-
}
|
700
|
+
#define EXAMPLE_LOCAL_MATERIAL \
|
701
|
+
"TlPm8M/Uxs0eK13ReFeOUyxVC2rarCf5+LbKuY/dnFxS/" \
|
702
|
+
"LoYc1CZqnfSXujqqWrrt3fOTQ2TdtNhO4bBfamOyJPx4uJSstehc7It4pLp3LHes70z64AYqJ" \
|
703
|
+
"Uemk4G+2He"
|
704
|
+
|
705
|
+
static void _test_setopt_kms_providers(_mongocrypt_tester_t *tester) {
|
706
|
+
setopt_kms_providers_testcase_t *test;
|
707
|
+
size_t i;
|
708
|
+
setopt_kms_providers_testcase_t tests[] = {
|
709
|
+
{"{'azure': {'tenantId': '', 'clientId': '', 'clientSecret': '', "
|
710
|
+
"'identityPlatformEndpoint': 'example.com' }}",
|
711
|
+
NULL},
|
712
|
+
{"{'azure': {'tenantId': '', 'clientId': '', 'clientSecret': '' }}", NULL},
|
713
|
+
{"{'azure': {'tenantId': '', 'clientId': '', 'clientSecret': '', "
|
714
|
+
"'identityPlatformEndpoint': 'example' }}",
|
715
|
+
"Invalid endpoint"},
|
716
|
+
{"{'azure': {'tenantId': '', 'clientSecret': '' }}", "clientId"},
|
717
|
+
{"{'aws': {'accessKeyId': 'abc', 'secretAccessKey': 'def'}}", NULL},
|
718
|
+
{"{'local': {'key': {'$binary': {'base64': '" EXAMPLE_LOCAL_MATERIAL "', 'subType': '00'}} }}", NULL},
|
719
|
+
{"{'local': {'key': '" EXAMPLE_LOCAL_MATERIAL "' }}", NULL},
|
720
|
+
{"{'local': {'key': 'invalid base64' }}", "unable to parse base64"},
|
721
|
+
/* either base64 string or binary is acceptable for privateKey */
|
722
|
+
{"{'gcp': {'endpoint': 'oauth2.googleapis.com', 'email': 'test', "
|
723
|
+
"'privateKey': 'AAAA' }}"},
|
724
|
+
{"{'gcp': {'endpoint': 'oauth2.googleapis.com', 'email': 'test', "
|
725
|
+
"'privateKey': {'$binary': {'base64': 'AAAA', 'subType': '00'}} }}"},
|
726
|
+
/* endpoint is not required. */
|
727
|
+
{"{'gcp': {'email': 'test', 'privateKey': 'AAAA' }}"},
|
728
|
+
{"{'gcp': {'privateKey': 'AAAA'}}", "expected UTF-8 gcp.email"},
|
729
|
+
{"{'gcp': {'email': 'test', 'privateKey': 'invalid base64' }}", "unable to parse base64"},
|
730
|
+
{"{'gcp': {'endpoint': 'example', 'email': 'test', 'privateKey': "
|
731
|
+
"'AAAA'}}",
|
732
|
+
"Invalid endpoint"},
|
733
|
+
{"{'azure': {'tenantId': '', 'clientId': '', 'clientSecret': '', "
|
734
|
+
"'identityPlatformEndpoint': 'example.com', 'extra': 'invalid' }}",
|
735
|
+
"Unexpected field: 'extra'"},
|
736
|
+
{"{'aws': {'accessKeyId': 'abc', 'secretAccessKey': 'def', 'extra': "
|
737
|
+
"'invalid'}}",
|
738
|
+
"Unexpected field: 'extra'"},
|
739
|
+
{"{'gcp': {'endpoint': 'oauth2.googleapis.com', 'email': 'test', "
|
740
|
+
"'privateKey': 'AAAA', 'extra': 'invalid' }}",
|
741
|
+
"Unexpected field: 'extra'"},
|
742
|
+
{"{'local': {'key': '" EXAMPLE_LOCAL_MATERIAL "', 'extra': 'invalid' }}", "Unexpected field: 'extra'"},
|
743
|
+
{"{'local': {'key': 'AAAA'}}", "local key must be 96 bytes"},
|
744
|
+
/* KMIP test cases. */
|
745
|
+
{"{'kmip': {'endpoint': '127.0.0.1:5696' }}", NULL},
|
746
|
+
/* localhost is a valid endpoint for KMIP.
|
747
|
+
* Unlike Azure, GCP, and AWS, applications run their own KMIP servers. */
|
748
|
+
{"{'kmip': {'endpoint': 'localhost' }}", NULL},
|
749
|
+
{"{'kmip': {'endpoint': '127.0.0.1:5696', 'extra': 'invalid' }}", "Unexpected field: 'extra'"},
|
750
|
+
/* Empty documents are OK if on-demand KMS credentials are opted-in with
|
751
|
+
* a call to mongocrypt_setopt_use_need_kms_credentials_state. */
|
752
|
+
{"{'aws': {}}", NULL, NULL, true},
|
753
|
+
{"{'azure': {}}", NULL, NULL, true},
|
754
|
+
{"{'local': {}}", NULL, NULL, true},
|
755
|
+
{"{'gcp': {}}", NULL, NULL, true},
|
756
|
+
{"{'kmip': {}}", NULL, NULL, true},
|
757
|
+
/* Empty documents are not OK if on-demand KMS credentials are not
|
758
|
+
opted-in. */
|
759
|
+
{"{'aws': {}}", NULL, "on-demand credentials not enabled", false},
|
760
|
+
{"{'azure': {}}", NULL, "on-demand credentials not enabled", false},
|
761
|
+
{"{'local': {}}", NULL, "on-demand credentials not enabled", false},
|
762
|
+
{"{'gcp': {}}", NULL, "on-demand credentials not enabled", false},
|
763
|
+
{"{'kmip': {}}", NULL, "on-demand credentials not enabled", false},
|
764
|
+
{"{'gcp': {'accessToken': 'foobar', 'email': 'foo@bar.com' }}", "Unexpected field: 'email'"},
|
765
|
+
{.value = "{ 'azure': { 'accessToken': 'secret' } }"},
|
766
|
+
};
|
767
|
+
|
768
|
+
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
|
769
|
+
mongocrypt_t *crypt;
|
770
|
+
|
771
|
+
test = tests + i;
|
772
|
+
crypt = mongocrypt_new();
|
773
|
+
if (test->use_need_kms_credentials_state) {
|
774
|
+
mongocrypt_setopt_use_need_kms_credentials_state(crypt);
|
775
|
+
}
|
776
|
+
if (!test->errmsg) {
|
777
|
+
ASSERT_OK(mongocrypt_setopt_kms_providers(crypt, TEST_BSON(test->value)), crypt);
|
778
|
+
if (!test->errmsg_init) {
|
779
|
+
ASSERT_OK(mongocrypt_init(crypt), crypt);
|
780
|
+
} else {
|
781
|
+
ASSERT_FAILS(mongocrypt_init(crypt), crypt, test->errmsg_init);
|
782
|
+
}
|
783
|
+
} else {
|
784
|
+
ASSERT_FAILS(mongocrypt_setopt_kms_providers(crypt, TEST_BSON(test->value)), crypt, test->errmsg);
|
785
|
+
}
|
786
|
+
mongocrypt_destroy(crypt);
|
787
|
+
}
|
912
788
|
}
|
913
789
|
|
914
790
|
bool _aes_ctr_is_supported_by_os = true;
|
915
791
|
|
916
|
-
int
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
_mongocrypt_tester_install_key (&tester);
|
943
|
-
_mongocrypt_tester_install_marking (&tester);
|
944
|
-
_mongocrypt_tester_install_traverse_util (&tester);
|
945
|
-
_mongocrypt_tester_install (
|
946
|
-
&tester, "_test_setopt_schema", _test_setopt_schema, CRYPTO_REQUIRED);
|
947
|
-
_mongocrypt_tester_install (&tester,
|
792
|
+
int main(int argc, char **argv) {
|
793
|
+
_mongocrypt_tester_t tester = {0};
|
794
|
+
int i;
|
795
|
+
|
796
|
+
printf("Pass a list of test names to run only specific tests. E.g.:\n");
|
797
|
+
printf("test-mongocrypt _mongocrypt_test_mcgrew\n\n");
|
798
|
+
|
799
|
+
/* Install all tests. */
|
800
|
+
_mongocrypt_tester_install_crypto(&tester);
|
801
|
+
_mongocrypt_tester_install_log(&tester);
|
802
|
+
_mongocrypt_tester_install_data_key(&tester);
|
803
|
+
_mongocrypt_tester_install_ctx_encrypt(&tester);
|
804
|
+
_mongocrypt_tester_install_ctx_decrypt(&tester);
|
805
|
+
_mongocrypt_tester_install_ctx_rewrap_many_datakey(&tester);
|
806
|
+
_mongocrypt_tester_install_ciphertext(&tester);
|
807
|
+
_mongocrypt_tester_install_key_broker(&tester);
|
808
|
+
_mongocrypt_tester_install(&tester, "_test_mongocrypt_bad_init", _test_mongocrypt_bad_init, CRYPTO_REQUIRED);
|
809
|
+
_mongocrypt_tester_install_local_kms(&tester);
|
810
|
+
_mongocrypt_tester_install_cache(&tester);
|
811
|
+
_mongocrypt_tester_install_buffer(&tester);
|
812
|
+
_mongocrypt_tester_install_ctx_setopt(&tester);
|
813
|
+
_mongocrypt_tester_install_key(&tester);
|
814
|
+
_mongocrypt_tester_install_marking(&tester);
|
815
|
+
_mongocrypt_tester_install_traverse_util(&tester);
|
816
|
+
_mongocrypt_tester_install(&tester, "_test_setopt_schema", _test_setopt_schema, CRYPTO_REQUIRED);
|
817
|
+
_mongocrypt_tester_install(&tester,
|
948
818
|
"_test_setopt_encrypted_field_config_map",
|
949
819
|
_test_setopt_encrypted_field_config_map,
|
950
820
|
CRYPTO_REQUIRED);
|
951
|
-
|
821
|
+
_mongocrypt_tester_install(&tester,
|
952
822
|
"_test_setopt_invalid_kms_providers",
|
953
823
|
_test_setopt_invalid_kms_providers,
|
954
824
|
CRYPTO_REQUIRED);
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
825
|
+
_mongocrypt_tester_install_crypto_hooks(&tester);
|
826
|
+
_mongocrypt_tester_install_key_cache(&tester);
|
827
|
+
_mongocrypt_tester_install_kms_responses(&tester);
|
828
|
+
_mongocrypt_tester_install_status(&tester);
|
829
|
+
_mongocrypt_tester_install_endpoint(&tester);
|
830
|
+
_mongocrypt_tester_install(&tester, "_test_setopt_kms_providers", _test_setopt_kms_providers, CRYPTO_OPTIONAL);
|
831
|
+
_mongocrypt_tester_install_kek(&tester);
|
832
|
+
_mongocrypt_tester_install_cache_oauth(&tester);
|
833
|
+
_mongocrypt_tester_install_kms_ctx(&tester);
|
834
|
+
_mongocrypt_tester_install_csfle_lib(&tester);
|
835
|
+
_mongocrypt_tester_install_dll(&tester);
|
836
|
+
_mongocrypt_tester_install_mc_tokens(&tester);
|
837
|
+
_mongocrypt_tester_install_fle2_payloads(&tester);
|
838
|
+
_mongocrypt_tester_install_fle2_iev_v2_payloads(&tester);
|
839
|
+
_mongocrypt_tester_install_efc(&tester);
|
840
|
+
_mongocrypt_tester_install_compact(&tester);
|
841
|
+
_mongocrypt_tester_install_fle2_payload_uev(&tester);
|
842
|
+
_mongocrypt_tester_install_fle2_payload_uev_v2(&tester);
|
843
|
+
_mongocrypt_tester_install_fle2_payload_iup(&tester);
|
844
|
+
_mongocrypt_tester_install_fle2_payload_iup_v2(&tester);
|
845
|
+
_mongocrypt_tester_install_fle2_payload_find_equality_v2(&tester);
|
846
|
+
_mongocrypt_tester_install_fle2_payload_find_range_v2(&tester);
|
847
|
+
_mongocrypt_tester_install_range_encoding(&tester);
|
848
|
+
_mongocrypt_tester_install_range_edge_generation(&tester);
|
849
|
+
_mongocrypt_tester_install_range_mincover(&tester);
|
850
|
+
_mongocrypt_tester_install_mc_RangeOpts(&tester);
|
851
|
+
_mongocrypt_tester_install_mc_FLE2RangeFindDriverSpec(&tester);
|
852
|
+
_mongocrypt_tester_install_gcp_auth(&tester);
|
853
|
+
_mongocrypt_tester_install_mc_reader(&tester);
|
854
|
+
_mongocrypt_tester_install_mc_writer(&tester);
|
982
855
|
|
983
856
|
#ifdef MONGOCRYPT_ENABLE_CRYPTO_COMMON_CRYPTO
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
857
|
+
char osversion[32];
|
858
|
+
size_t osversion_len = sizeof(osversion) - 1;
|
859
|
+
int osversion_name[] = {CTL_KERN, KERN_OSRELEASE};
|
860
|
+
|
861
|
+
_aes_ctr_is_supported_by_os = false;
|
862
|
+
|
863
|
+
if (sysctl(osversion_name, 2, osversion, &osversion_len, NULL, 0) == -1) {
|
864
|
+
goto get_os_version_failed;
|
865
|
+
}
|
866
|
+
|
867
|
+
uint32_t major, minor;
|
868
|
+
if (sscanf(osversion, "%u.%u", &major, &minor) != 2) {
|
869
|
+
goto get_os_version_failed;
|
870
|
+
}
|
871
|
+
|
872
|
+
if (major >= 20) {
|
873
|
+
// macOS 11 and newer
|
874
|
+
_aes_ctr_is_supported_by_os = true;
|
875
|
+
} else {
|
876
|
+
major -= 4;
|
877
|
+
// macOS 10.1.1 and newer. CTR unsupported in 10.14 and earlier
|
878
|
+
_aes_ctr_is_supported_by_os = major > 14;
|
879
|
+
}
|
1007
880
|
get_os_version_failed:
|
1008
881
|
#endif
|
1009
882
|
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
883
|
+
printf("Running tests...\n");
|
884
|
+
for (i = 0; tester.test_names[i]; i++) {
|
885
|
+
int j;
|
886
|
+
bool found = false;
|
887
|
+
|
888
|
+
if (argc > 1) {
|
889
|
+
for (j = 1; j < argc; j++) {
|
890
|
+
found = (0 == strcmp(argv[j], tester.test_names[i]));
|
891
|
+
if (found) {
|
892
|
+
break;
|
893
|
+
}
|
894
|
+
}
|
895
|
+
if (!found) {
|
896
|
+
continue;
|
897
|
+
}
|
898
|
+
}
|
899
|
+
printf(" begin %s\n", tester.test_names[i]);
|
900
|
+
tester.test_fns[i](&tester);
|
901
|
+
/* Clear state. */
|
902
|
+
memset(&tester.paths, 0, sizeof(tester.paths));
|
903
|
+
printf(" end %s\n", tester.test_names[i]);
|
904
|
+
}
|
905
|
+
printf("... done running tests\n");
|
906
|
+
|
907
|
+
if (i == 0) {
|
908
|
+
printf("WARNING - no tests run.\n");
|
909
|
+
}
|
910
|
+
|
911
|
+
/* Clean up tester. */
|
912
|
+
for (i = 0; i < tester.test_count; i++) {
|
913
|
+
bson_free(tester.test_names[i]);
|
914
|
+
}
|
915
|
+
|
916
|
+
for (i = 0; i < tester.file_count; i++) {
|
917
|
+
_mongocrypt_buffer_cleanup(&tester.file_bufs[i]);
|
918
|
+
bson_free(tester.file_paths[i]);
|
919
|
+
}
|
920
|
+
|
921
|
+
for (i = 0; i < tester.bin_count; i++) {
|
922
|
+
mongocrypt_binary_destroy(tester.test_bin[i]);
|
923
|
+
}
|
924
|
+
|
925
|
+
for (i = 0; i < tester.bson_count; i++) {
|
926
|
+
bson_destroy(&tester.test_bson[i]);
|
927
|
+
}
|
928
|
+
|
929
|
+
for (i = 0; i < tester.blob_count; i++) {
|
930
|
+
bson_free(tester.test_blob[i]);
|
931
|
+
}
|
932
|
+
|
933
|
+
_mongocrypt_buffer_cleanup(&tester.encrypted_doc);
|
934
|
+
}
|
935
|
+
|
936
|
+
void _test_ctx_wrap_and_feed_key(mongocrypt_ctx_t *ctx,
|
937
|
+
const _mongocrypt_buffer_t *id,
|
938
|
+
_mongocrypt_buffer_t *key,
|
939
|
+
mongocrypt_status_t *status) {
|
940
|
+
// Wrap key using local provider.
|
941
|
+
_mongocrypt_buffer_t kek = _mongocrypt_ctx_kms_providers(ctx)->local.key;
|
942
|
+
_mongocrypt_buffer_t encrypted_key;
|
943
|
+
_mongocrypt_buffer_init(&encrypted_key);
|
944
|
+
ASSERT_OK_STATUS(_mongocrypt_wrap_key(ctx->crypt->crypto, &kek, key, &encrypted_key, status), status);
|
945
|
+
|
946
|
+
bson_t doc;
|
947
|
+
bson_init(&doc);
|
948
|
+
ASSERT(bson_append_binary(&doc, "_id", (int)strlen("_id"), BSON_SUBTYPE_UUID, id->data, id->len));
|
949
|
+
ASSERT(bson_append_binary(&doc,
|
950
|
+
"keyMaterial",
|
951
|
+
(int)strlen("keyMaterial"),
|
952
|
+
BSON_SUBTYPE_BINARY,
|
953
|
+
encrypted_key.data,
|
954
|
+
encrypted_key.len));
|
955
|
+
ASSERT(bson_append_now_utc(&doc, "creationDate", (int)strlen("creationDate")));
|
956
|
+
ASSERT(bson_append_now_utc(&doc, "updateDate", (int)strlen("updateDate")));
|
957
|
+
ASSERT(bson_append_int32(&doc, "status", (int)strlen("status"), 0));
|
958
|
+
bson_t masterKey;
|
959
|
+
bson_init(&masterKey);
|
960
|
+
ASSERT(bson_append_document_begin(&doc, "masterKey", (int)strlen("masterKey"), &masterKey));
|
961
|
+
ASSERT(bson_append_utf8(&masterKey, "provider", (int)strlen("provider"), "local", (int)strlen("local")));
|
962
|
+
ASSERT(bson_append_document_end(&doc, &masterKey));
|
963
|
+
mongocrypt_binary_t *bin = mongocrypt_binary_new_from_data((uint8_t *)bson_get_data(&doc), doc.len);
|
964
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx, bin), ctx);
|
965
|
+
mongocrypt_binary_destroy(bin);
|
966
|
+
bson_destroy(&doc);
|
967
|
+
|
968
|
+
_mongocrypt_buffer_cleanup(&encrypted_key);
|
1060
969
|
}
|