libmongocrypt-helper 1.7.4.0.1002 → 1.8.0.0.1001
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +9 -7
- data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +17 -23
- data/ext/libmongocrypt/libmongocrypt/Earthfile +374 -0
- data/ext/libmongocrypt/libmongocrypt/README.md +7 -7
- data/ext/libmongocrypt/libmongocrypt/VERSION_CURRENT +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClient.cs +25 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Library.cs +25 -3
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Example/MongoDB.Libmongocrypt.Example.csproj +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/BasicTests.cs +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.cake +3 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/cs.sln +79 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/build.gradle.kts +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java +6 -4
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/CHANGELOG.md +24 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/README.md +134 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/build-static.sh +3 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/node/index.d.ts +203 -77
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/autoEncrypter.js +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/clientEncryption.js +165 -43
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/common.js +12 -14
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/errors.js +75 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/index.js +34 -3
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/aws.js +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/azure.js +178 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/gcp.js +24 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/index.js +54 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/utils.js +39 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/stateMachine.js +9 -4
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package-lock.json +4440 -5189
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package.json +27 -8
- data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.cc +65 -38
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/autoEncrypter.test.js +4 -7
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/clientEncryption.test.js +434 -42
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/common.test.js +94 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/cryptoCallbacks.test.js +1 -45
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/index.test.js +45 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/mongocryptdManager.test.js +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/providers/credentialsProvider.test.js +551 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/release.test.js +10 -3
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/requirements.helper.js +23 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/stateMachine.test.js +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/chai-addons.js +8 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/types/index.test-d.ts +63 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/README.rst +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/build-manylinux-wheel.sh +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +128 -238
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/compat.py +0 -27
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/explicit_encrypter.py +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +5 -21
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/release.sh +5 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/python/setup.py +14 -9
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/__init__.py +1 -10
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_mongocrypt.py +5 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test-requirements.txt +4 -12
- data/ext/libmongocrypt/libmongocrypt/cmake/ImportBSON.cmake +8 -6
- data/ext/libmongocrypt/libmongocrypt/cmake/IntelDFP.cmake +2 -1
- data/ext/libmongocrypt/libmongocrypt/cmake/Platform.cmake +50 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/mongocrypt-config.cmake +21 -0
- data/ext/libmongocrypt/libmongocrypt/debian/gbp.conf +2 -2
- data/ext/libmongocrypt/libmongocrypt/etc/c6-vault.repo +39 -0
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_aead_generate_tests.py +15 -24
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_crypto.py +66 -54
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_generate_tests.py +14 -23
- data/ext/libmongocrypt/libmongocrypt/etc/fle2v2_aead_generate_tests.py +32 -0
- data/ext/libmongocrypt/libmongocrypt/etc/format-all.sh +12 -0
- data/ext/libmongocrypt/libmongocrypt/etc/format.sh +16 -0
- data/ext/libmongocrypt/libmongocrypt/etc/install-package.sh +48 -0
- data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-libmongocrypt-pr-625.patch +13 -0
- data/ext/libmongocrypt/libmongocrypt/src/crypto/cng.c +381 -436
- data/ext/libmongocrypt/libmongocrypt/src/crypto/commoncrypto.c +162 -227
- data/ext/libmongocrypt/libmongocrypt/src/crypto/libcrypto.c +180 -248
- data/ext/libmongocrypt/libmongocrypt/src/crypto/none.c +33 -55
- data/ext/libmongocrypt/libmongocrypt/src/csfle-markup.cpp +175 -205
- data/ext/libmongocrypt/libmongocrypt/src/mc-array-private.h +10 -21
- data/ext/libmongocrypt/libmongocrypt/src/mc-array.c +44 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-check-conversions-private.h +4 -8
- data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.h +351 -463
- data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.test.cpp +59 -66
- data/ext/libmongocrypt/libmongocrypt/src/mc-efc-private.h +7 -11
- data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +80 -92
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle-blob-subtype-private.h +18 -10
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +59 -70
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +384 -439
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private-v2.h +41 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private.h +11 -18
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-v2.c +135 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload.c +109 -126
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private-v2.h +88 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private.h +24 -27
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-v2.c +137 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload.c +106 -125
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private-v2.h +117 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private.h +28 -36
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-v2.c +294 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload.c +237 -278
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private-v2.h +133 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private.h +67 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-v2.c +437 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev.c +476 -325
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common-private.h +69 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common.c +182 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-private.h +23 -31
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2-private.h +85 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2.c +142 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev.c +104 -231
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-range-operator-private.h +8 -7
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds-private.h +55 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +517 -580
- data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +36 -66
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +57 -76
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +158 -189
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +36 -42
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +515 -558
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +155 -191
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +43 -53
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +170 -240
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +29 -34
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +289 -338
- data/ext/libmongocrypt/libmongocrypt/src/mc-reader-private.h +36 -71
- data/ext/libmongocrypt/libmongocrypt/src/mc-reader.c +111 -164
- data/ext/libmongocrypt/libmongocrypt/src/mc-tokens-private.h +55 -49
- data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +109 -125
- data/ext/libmongocrypt/libmongocrypt/src/mc-writer-private.h +66 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-writer.c +141 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/check.hpp +37 -55
- data/ext/libmongocrypt/libmongocrypt/src/mlib/endian.h +11 -11
- data/ext/libmongocrypt/libmongocrypt/src/mlib/error.h +27 -32
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.h +444 -499
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +251 -334
- data/ext/libmongocrypt/libmongocrypt/src/mlib/macros.h +4 -5
- data/ext/libmongocrypt/libmongocrypt/src/mlib/path.h +196 -231
- data/ext/libmongocrypt/libmongocrypt/src/mlib/path.test.c +56 -79
- data/ext/libmongocrypt/libmongocrypt/src/mlib/str.h +411 -530
- data/ext/libmongocrypt/libmongocrypt/src/mlib/str.test.c +116 -131
- data/ext/libmongocrypt/libmongocrypt/src/mlib/thread.h +17 -26
- data/ext/libmongocrypt/libmongocrypt/src/mlib/user-check.h +2 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary-private.h +3 -6
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary.c +31 -48
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer-private.h +55 -131
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer.c +444 -565
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo-private.h +1 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo.c +28 -45
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key-private.h +11 -17
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key.c +103 -132
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth-private.h +8 -14
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth.c +78 -90
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-private.h +26 -45
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache.c +220 -273
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext-private.h +13 -25
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext.c +147 -166
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-compat.h +2 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto-private.h +110 -204
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto.c +1137 -1565
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +425 -472
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +817 -694
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +2394 -2697
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-private.h +166 -186
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-rewrap-many-datakey.c +308 -351
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +921 -1138
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +16 -24
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endian-private.h +44 -58
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint-private.h +21 -25
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint.c +167 -181
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek-private.h +37 -43
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek.c +215 -253
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker-private.h +73 -108
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +889 -1034
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-private.h +27 -44
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key.c +349 -402
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx-private.h +92 -120
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx.c +1397 -1612
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log-private.h +35 -67
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log.c +49 -83
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking-private.h +30 -36
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +1821 -1470
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-mutex-private.h +7 -12
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +80 -108
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +354 -424
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +101 -117
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status-private.h +3 -8
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status.c +92 -119
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util-private.h +19 -29
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util.c +136 -176
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util-private.h +11 -21
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util.c +96 -135
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +1092 -1320
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +130 -295
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +66 -78
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_mutex.c +20 -28
- data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +60 -73
- data/ext/libmongocrypt/libmongocrypt/src/os_win/os_mutex.c +8 -16
- data/ext/libmongocrypt/libmongocrypt/test/crypt_shared-stub.cpp +57 -87
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/encrypted-payload-v2.json +60 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/encrypted-payload-v2.json +67 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/encrypted-payload.json +2 -2
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-contentionFactor1-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-contentionFactor1-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-same-user-and-index-key-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-field-map.json +22 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-payload.json +40 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/mongocryptd-reply.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/cmd.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-payload.json +50 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/mongocryptd-reply.json +58 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/encrypted-payload-v2.json +16 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert/cmd.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/RNG_DATA.h +65 -65
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/cmd.json +13 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/RNG_DATA.h +132 -132
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/RNG_DATA.h +71 -71
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-payload.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/mongocryptd-reply.json +61 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/RNG_DATA.h +68 -68
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/RNG_DATA.h +19 -19
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-payload.json +47 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/mongocryptd-reply.json +55 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/RNG_DATA.h +25 -25
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/RNG_DATA.h +65 -65
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/RNG_DATA.h +68 -68
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/RNG_DATA.h +19 -19
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/RNG_DATA.h +25 -25
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/RNG_DATA.h +15 -15
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-field-map.json +18 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-payload.json +14 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/mongocryptd-reply.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-field-map.json +22 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-payload.json +39 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneRangeV2.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneV2.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/README.md +17 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/aes-ctr.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-fixed.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-generated.json +38 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-decrypt.json +35 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-fixed.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-generated.json +122 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-fixed.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-generated.json +122 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/mcgrew.json +12 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/nist.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/README.md +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/mc.json +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/server.json +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/example-no-bson.c +4 -4
- data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +278 -323
- data/ext/libmongocrypt/libmongocrypt/test/fuzz_kms.c +8 -7
- data/ext/libmongocrypt/libmongocrypt/test/test-dll.cpp +6 -7
- data/ext/libmongocrypt/libmongocrypt/test/test-gcp-auth.c +221 -283
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-efc.c +58 -73
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-equality-payload-v2.c +78 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-range-payload-v2.c +89 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev-v2.c +248 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev.c +467 -414
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup-v2.c +172 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup.c +141 -159
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev-v2.c +338 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev.c +238 -176
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-rfds.c +373 -474
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-edge-generation.c +346 -388
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +708 -825
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +417 -481
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +110 -144
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-reader.c +124 -207
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +223 -213
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-writer.c +176 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +634 -807
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.h +1 -2
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert.h +168 -189
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-buffer.c +187 -211
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache-oauth.c +34 -36
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache.c +210 -233
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ciphertext.c +185 -220
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-compact.c +331 -445
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +670 -814
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +102 -135
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.h +54 -71
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto.c +394 -846
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-csfle-lib.c +159 -183
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-decrypt.c +867 -1045
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +4349 -4713
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +750 -964
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +991 -1178
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +342 -419
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-dll.c +23 -30
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-endpoint.c +98 -111
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kek.c +49 -52
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-broker.c +770 -920
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-cache.c +354 -407
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key.c +197 -245
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-ctx.c +286 -370
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-responses.c +147 -166
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-local-kms.c +50 -61
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-log.c +85 -100
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-marking.c +656 -692
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-status.c +46 -58
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-traverse-util.c +377 -451
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.c +48 -67
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.h +4 -10
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +827 -918
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +111 -172
- data/ext/libmongocrypt/libmongocrypt/test/util/csfle.c +508 -559
- data/ext/libmongocrypt/libmongocrypt/test/util/util.c +735 -881
- data/ext/libmongocrypt/libmongocrypt/test/util/util.h +33 -55
- data/lib/libmongocrypt_helper/version.rb +2 -2
- data.tar.gz.sig +0 -0
- metadata +154 -26
- metadata.gz.sig +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/key-document.json +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/credentialsProvider.js +0 -33
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/credentialsProvider.test.js +0 -163
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/test/data/aes-ctr.cstructs +0 -359
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-aead.cstructs +0 -109
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/rangeopts.json +0 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/value-to-encrypt.json +0 -20
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/RNG_DATA.h +0 -70
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload.json +0 -8
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/rangeopts.json +0 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/value-to-encrypt.json +0 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2.cstructs +0 -33
- /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/key-filter.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/rangeopts.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/value-to-encrypt.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/rangeopts.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/value-to-encrypt.json +0 -0
@@ -16,1119 +16,941 @@
|
|
16
16
|
|
17
17
|
#include "mongocrypt-ctx-private.h"
|
18
18
|
#include "mongocrypt.h"
|
19
|
-
#include "test-mongocrypt.h"
|
20
19
|
#include "test-mongocrypt-assert-match-bson.h"
|
20
|
+
#include "test-mongocrypt.h"
|
21
21
|
|
22
|
-
static void
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
mongocrypt_binary_t *msg;
|
28
|
-
crypt = _mongocrypt_tester_mongocrypt (TESTER_MONGOCRYPT_DEFAULT);
|
22
|
+
static void _test_explicit_decrypt_init(_mongocrypt_tester_t *tester) {
|
23
|
+
mongocrypt_t *crypt;
|
24
|
+
mongocrypt_ctx_t *ctx;
|
25
|
+
mongocrypt_binary_t *msg;
|
26
|
+
crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
29
27
|
|
30
|
-
|
28
|
+
msg = TEST_BSON("{ 'v': { '$binary': { 'subType': '06', 'base64': "
|
31
29
|
"'AWFhYWFhYWFhYWFhYWFhYWECRTOW9yZzNDn5dGwuqsrJQNLtgMEKaujhs"
|
32
30
|
"9aRWRp+7Yo3JK8N8jC8P0Xjll6C1CwLsE/"
|
33
31
|
"iP5wjOMhVv1KMMyOCSCrHorXRsb2IKPtzl2lKTqQ=' } } }");
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
mongocrypt_ctx_destroy (ctx);
|
33
|
+
/* NULL document. */
|
34
|
+
ctx = mongocrypt_ctx_new(crypt);
|
35
|
+
ASSERT_FAILS(mongocrypt_ctx_explicit_decrypt_init(ctx, NULL), ctx, "invalid msg");
|
36
|
+
BSON_ASSERT(mongocrypt_ctx_state(ctx) == MONGOCRYPT_CTX_ERROR);
|
37
|
+
mongocrypt_ctx_destroy(ctx);
|
41
38
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
39
|
+
/* Success. */
|
40
|
+
ctx = mongocrypt_ctx_new(crypt);
|
41
|
+
ASSERT_OK(mongocrypt_ctx_explicit_decrypt_init(ctx, msg), ctx);
|
42
|
+
BSON_ASSERT(mongocrypt_ctx_state(ctx) == MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
43
|
+
mongocrypt_ctx_destroy(ctx);
|
47
44
|
|
48
|
-
|
45
|
+
mongocrypt_destroy(crypt);
|
49
46
|
}
|
50
47
|
|
51
|
-
|
52
48
|
/* Test individual ctx states. */
|
53
|
-
static void
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
mongocrypt_ctx_t *ctx;
|
58
|
-
mongocrypt_binary_t *encrypted;
|
59
|
-
|
60
|
-
crypt = _mongocrypt_tester_mongocrypt (TESTER_MONGOCRYPT_DEFAULT);
|
61
|
-
|
62
|
-
encrypted = _mongocrypt_tester_encrypted_doc (tester);
|
63
|
-
|
64
|
-
/* Success. */
|
65
|
-
ctx = mongocrypt_ctx_new (crypt);
|
66
|
-
ASSERT_OK (mongocrypt_ctx_decrypt_init (ctx, encrypted), ctx);
|
67
|
-
BSON_ASSERT (mongocrypt_ctx_state (ctx) == MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
68
|
-
mongocrypt_ctx_destroy (ctx);
|
69
|
-
|
70
|
-
/* NULL document. */
|
71
|
-
ctx = mongocrypt_ctx_new (crypt);
|
72
|
-
ASSERT_FAILS (mongocrypt_ctx_decrypt_init (ctx, NULL), ctx, "invalid doc");
|
73
|
-
BSON_ASSERT (mongocrypt_ctx_state (ctx) == MONGOCRYPT_CTX_ERROR);
|
74
|
-
mongocrypt_ctx_destroy (ctx);
|
75
|
-
|
76
|
-
mongocrypt_binary_destroy (encrypted);
|
77
|
-
mongocrypt_destroy (crypt);
|
78
|
-
}
|
79
|
-
|
49
|
+
static void _test_decrypt_init(_mongocrypt_tester_t *tester) {
|
50
|
+
mongocrypt_t *crypt;
|
51
|
+
mongocrypt_ctx_t *ctx;
|
52
|
+
mongocrypt_binary_t *encrypted;
|
80
53
|
|
81
|
-
|
82
|
-
_test_decrypt_need_keys (_mongocrypt_tester_t *tester)
|
83
|
-
{
|
84
|
-
mongocrypt_t *crypt;
|
85
|
-
mongocrypt_ctx_t *ctx;
|
86
|
-
mongocrypt_binary_t *encrypted;
|
54
|
+
crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
87
55
|
|
88
|
-
|
56
|
+
encrypted = _mongocrypt_tester_encrypted_doc(tester);
|
89
57
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
ctx, TEST_FILE ("./test/example/key-document.json")),
|
96
|
-
ctx);
|
97
|
-
ASSERT_OK (mongocrypt_ctx_mongo_done (ctx), ctx);
|
98
|
-
BSON_ASSERT (mongocrypt_ctx_state (ctx) == MONGOCRYPT_CTX_NEED_KMS);
|
99
|
-
mongocrypt_ctx_destroy (ctx);
|
100
|
-
mongocrypt_destroy (crypt); /* recreate crypt because of caching. */
|
58
|
+
/* Success. */
|
59
|
+
ctx = mongocrypt_ctx_new(crypt);
|
60
|
+
ASSERT_OK(mongocrypt_ctx_decrypt_init(ctx, encrypted), ctx);
|
61
|
+
BSON_ASSERT(mongocrypt_ctx_state(ctx) == MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
62
|
+
mongocrypt_ctx_destroy(ctx);
|
101
63
|
|
102
|
-
|
103
|
-
|
64
|
+
/* NULL document. */
|
65
|
+
ctx = mongocrypt_ctx_new(crypt);
|
66
|
+
ASSERT_FAILS(mongocrypt_ctx_decrypt_init(ctx, NULL), ctx, "invalid doc");
|
67
|
+
BSON_ASSERT(mongocrypt_ctx_state(ctx) == MONGOCRYPT_CTX_ERROR);
|
68
|
+
mongocrypt_ctx_destroy(ctx);
|
104
69
|
|
105
|
-
|
70
|
+
mongocrypt_binary_destroy(encrypted);
|
71
|
+
mongocrypt_destroy(crypt);
|
106
72
|
}
|
107
73
|
|
74
|
+
static void _test_decrypt_need_keys(_mongocrypt_tester_t *tester) {
|
75
|
+
mongocrypt_t *crypt;
|
76
|
+
mongocrypt_ctx_t *ctx;
|
77
|
+
mongocrypt_binary_t *encrypted;
|
78
|
+
|
79
|
+
encrypted = _mongocrypt_tester_encrypted_doc(tester);
|
80
|
+
|
81
|
+
/* Success. */
|
82
|
+
crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
83
|
+
ctx = mongocrypt_ctx_new(crypt);
|
84
|
+
ASSERT_OK(mongocrypt_ctx_decrypt_init(ctx, encrypted), ctx);
|
85
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx, TEST_FILE("./test/example/key-document.json")), ctx);
|
86
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
87
|
+
BSON_ASSERT(mongocrypt_ctx_state(ctx) == MONGOCRYPT_CTX_NEED_KMS);
|
88
|
+
mongocrypt_ctx_destroy(ctx);
|
89
|
+
mongocrypt_destroy(crypt); /* recreate crypt because of caching. */
|
108
90
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
mongocrypt_ctx_t *ctx;
|
114
|
-
mongocrypt_binary_t *encrypted, *decrypted;
|
115
|
-
bson_t as_bson;
|
116
|
-
bson_iter_t iter;
|
117
|
-
|
118
|
-
encrypted = _mongocrypt_tester_encrypted_doc (tester);
|
119
|
-
decrypted = mongocrypt_binary_new ();
|
120
|
-
crypt = _mongocrypt_tester_mongocrypt (TESTER_MONGOCRYPT_DEFAULT);
|
121
|
-
|
122
|
-
/* Success. */
|
123
|
-
ctx = mongocrypt_ctx_new (crypt);
|
124
|
-
ASSERT_OK (mongocrypt_ctx_decrypt_init (ctx, encrypted), ctx);
|
125
|
-
_mongocrypt_tester_run_ctx_to (tester, ctx, MONGOCRYPT_CTX_READY);
|
126
|
-
ASSERT_OK (mongocrypt_ctx_finalize (ctx, decrypted), ctx);
|
127
|
-
BSON_ASSERT (_mongocrypt_binary_to_bson (decrypted, &as_bson));
|
128
|
-
bson_iter_init (&iter, &as_bson);
|
129
|
-
bson_iter_find_descendant (&iter, "filter.ssn", &iter);
|
130
|
-
BSON_ASSERT (BSON_ITER_HOLDS_UTF8 (&iter));
|
131
|
-
BSON_ASSERT (0 == strcmp (bson_iter_utf8 (&iter, NULL),
|
132
|
-
_mongocrypt_tester_plaintext (tester)));
|
133
|
-
mongocrypt_binary_destroy (decrypted);
|
134
|
-
mongocrypt_ctx_destroy (ctx);
|
135
|
-
mongocrypt_destroy (crypt);
|
136
|
-
mongocrypt_binary_destroy (encrypted);
|
91
|
+
/* TODO: CDRIVER-3044 test that decryption warns when keys are not
|
92
|
+
* found/inactive. */
|
93
|
+
|
94
|
+
mongocrypt_binary_destroy(encrypted);
|
137
95
|
}
|
138
96
|
|
97
|
+
static void _test_decrypt_ready(_mongocrypt_tester_t *tester) {
|
98
|
+
mongocrypt_t *crypt;
|
99
|
+
mongocrypt_ctx_t *ctx;
|
100
|
+
mongocrypt_binary_t *encrypted, *decrypted;
|
101
|
+
bson_t as_bson;
|
102
|
+
bson_iter_t iter;
|
103
|
+
|
104
|
+
encrypted = _mongocrypt_tester_encrypted_doc(tester);
|
105
|
+
decrypted = mongocrypt_binary_new();
|
106
|
+
crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
107
|
+
|
108
|
+
/* Success. */
|
109
|
+
ctx = mongocrypt_ctx_new(crypt);
|
110
|
+
ASSERT_OK(mongocrypt_ctx_decrypt_init(ctx, encrypted), ctx);
|
111
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_READY);
|
112
|
+
ASSERT_OK(mongocrypt_ctx_finalize(ctx, decrypted), ctx);
|
113
|
+
BSON_ASSERT(_mongocrypt_binary_to_bson(decrypted, &as_bson));
|
114
|
+
bson_iter_init(&iter, &as_bson);
|
115
|
+
bson_iter_find_descendant(&iter, "filter.ssn", &iter);
|
116
|
+
BSON_ASSERT(BSON_ITER_HOLDS_UTF8(&iter));
|
117
|
+
BSON_ASSERT(0 == strcmp(bson_iter_utf8(&iter, NULL), _mongocrypt_tester_plaintext(tester)));
|
118
|
+
mongocrypt_binary_destroy(decrypted);
|
119
|
+
mongocrypt_ctx_destroy(ctx);
|
120
|
+
mongocrypt_destroy(crypt);
|
121
|
+
mongocrypt_binary_destroy(encrypted);
|
122
|
+
}
|
139
123
|
|
140
124
|
/* Test with empty AWS credentials. */
|
141
|
-
void
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
ASSERT_OK (mongocrypt_ctx_decrypt_init (
|
154
|
-
ctx, TEST_FILE ("./test/data/encrypted-cmd.json")),
|
155
|
-
ctx);
|
156
|
-
_mongocrypt_tester_run_ctx_to (tester, ctx, MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
157
|
-
ASSERT_FAILS (mongocrypt_ctx_mongo_feed (
|
158
|
-
ctx, TEST_FILE ("./test/example/key-document.json")),
|
125
|
+
void _test_decrypt_empty_aws(_mongocrypt_tester_t *tester) {
|
126
|
+
mongocrypt_t *crypt;
|
127
|
+
mongocrypt_ctx_t *ctx;
|
128
|
+
|
129
|
+
crypt = mongocrypt_new();
|
130
|
+
ASSERT_OK(mongocrypt_setopt_kms_provider_aws(crypt, "", -1, "", -1), crypt);
|
131
|
+
ASSERT_OK(mongocrypt_init(crypt), crypt);
|
132
|
+
|
133
|
+
ctx = mongocrypt_ctx_new(crypt);
|
134
|
+
ASSERT_OK(mongocrypt_ctx_decrypt_init(ctx, TEST_FILE("./test/data/encrypted-cmd.json")), ctx);
|
135
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
136
|
+
ASSERT_FAILS(mongocrypt_ctx_mongo_feed(ctx, TEST_FILE("./test/example/key-document.json")),
|
159
137
|
ctx,
|
160
138
|
"failed to create KMS message");
|
161
139
|
|
162
|
-
|
163
|
-
|
140
|
+
mongocrypt_ctx_destroy(ctx);
|
141
|
+
mongocrypt_destroy(crypt);
|
164
142
|
}
|
165
143
|
|
166
|
-
static void
|
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
|
-
_mongocrypt_tester_run_ctx_to (tester, ctx, MONGOCRYPT_CTX_READY);
|
197
|
-
mongocrypt_ctx_finalize (ctx, bin);
|
198
|
-
|
199
|
-
mongocrypt_binary_destroy (bin);
|
200
|
-
mongocrypt_ctx_destroy (ctx);
|
201
|
-
_mongocrypt_buffer_cleanup (&encrypted);
|
202
|
-
mongocrypt_destroy (crypt);
|
144
|
+
static void _test_decrypt_empty_binary(_mongocrypt_tester_t *tester) {
|
145
|
+
mongocrypt_t *crypt;
|
146
|
+
mongocrypt_ctx_t *ctx;
|
147
|
+
mongocrypt_binary_t *bin;
|
148
|
+
_mongocrypt_buffer_t encrypted;
|
149
|
+
|
150
|
+
bin = mongocrypt_binary_new();
|
151
|
+
crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
152
|
+
ctx = mongocrypt_ctx_new(crypt);
|
153
|
+
|
154
|
+
/* Encrypt an empty binary value. */
|
155
|
+
mongocrypt_ctx_setopt_key_alt_name(ctx, TEST_BSON("{'keyAltName': 'keyDocumentName'}"));
|
156
|
+
mongocrypt_ctx_setopt_algorithm(ctx, MONGOCRYPT_ALGORITHM_DETERMINISTIC_STR, -1);
|
157
|
+
mongocrypt_ctx_explicit_encrypt_init(ctx, TEST_BSON("{'v': { '$binary': { 'base64': '', 'subType': '00' } } }"));
|
158
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_READY);
|
159
|
+
mongocrypt_ctx_finalize(ctx, bin);
|
160
|
+
/* Copy the encrypted ciphertext since it is tied to the lifetime of ctx. */
|
161
|
+
_mongocrypt_buffer_copy_from_binary(&encrypted, bin);
|
162
|
+
mongocrypt_ctx_destroy(ctx);
|
163
|
+
|
164
|
+
/* Decrypt it back. */
|
165
|
+
ctx = mongocrypt_ctx_new(crypt);
|
166
|
+
mongocrypt_ctx_explicit_decrypt_init(ctx, _mongocrypt_buffer_as_binary(&encrypted));
|
167
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_READY);
|
168
|
+
mongocrypt_ctx_finalize(ctx, bin);
|
169
|
+
|
170
|
+
mongocrypt_binary_destroy(bin);
|
171
|
+
mongocrypt_ctx_destroy(ctx);
|
172
|
+
_mongocrypt_buffer_cleanup(&encrypted);
|
173
|
+
mongocrypt_destroy(crypt);
|
203
174
|
}
|
204
175
|
|
205
|
-
static void
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
ctx,
|
227
|
-
TEST_BSON ("{'v': { '$binary': { 'base64': '', 'subType': '00' } } }"));
|
228
|
-
_mongocrypt_tester_run_ctx_to (
|
229
|
-
tester, ctx, MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS);
|
230
|
-
ASSERT_OK (mongocrypt_ctx_provide_kms_providers (
|
231
|
-
ctx,
|
232
|
-
TEST_BSON ("{'aws':{'accessKeyId': 'example',"
|
233
|
-
"'secretAccessKey': 'example'}}")),
|
176
|
+
static void _test_decrypt_per_ctx_credentials(_mongocrypt_tester_t *tester) {
|
177
|
+
mongocrypt_t *crypt;
|
178
|
+
mongocrypt_ctx_t *ctx;
|
179
|
+
mongocrypt_binary_t *bin;
|
180
|
+
_mongocrypt_buffer_t encrypted;
|
181
|
+
|
182
|
+
bin = mongocrypt_binary_new();
|
183
|
+
crypt = mongocrypt_new();
|
184
|
+
mongocrypt_setopt_use_need_kms_credentials_state(crypt);
|
185
|
+
mongocrypt_setopt_kms_providers(crypt, TEST_BSON("{'aws': {}}"));
|
186
|
+
ASSERT_OK(mongocrypt_init(crypt), crypt);
|
187
|
+
ctx = mongocrypt_ctx_new(crypt);
|
188
|
+
|
189
|
+
/* Encrypt an empty binary value. */
|
190
|
+
mongocrypt_ctx_setopt_key_alt_name(ctx, TEST_BSON("{'keyAltName': 'keyDocumentName'}"));
|
191
|
+
mongocrypt_ctx_setopt_algorithm(ctx, MONGOCRYPT_ALGORITHM_DETERMINISTIC_STR, -1);
|
192
|
+
mongocrypt_ctx_explicit_encrypt_init(ctx, TEST_BSON("{'v': { '$binary': { 'base64': '', 'subType': '00' } } }"));
|
193
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS);
|
194
|
+
ASSERT_OK(mongocrypt_ctx_provide_kms_providers(ctx,
|
195
|
+
TEST_BSON("{'aws':{'accessKeyId': 'example',"
|
196
|
+
"'secretAccessKey': 'example'}}")),
|
234
197
|
ctx);
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
mongocrypt_destroy (crypt);
|
198
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_READY);
|
199
|
+
mongocrypt_ctx_finalize(ctx, bin);
|
200
|
+
/* Copy the encrypted ciphertext since it is tied to the lifetime of ctx. */
|
201
|
+
_mongocrypt_buffer_copy_from_binary(&encrypted, bin);
|
202
|
+
mongocrypt_ctx_destroy(ctx);
|
203
|
+
|
204
|
+
/* Decrypt it back. */
|
205
|
+
ctx = mongocrypt_ctx_new(crypt);
|
206
|
+
mongocrypt_ctx_explicit_decrypt_init(ctx, _mongocrypt_buffer_as_binary(&encrypted));
|
207
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_READY);
|
208
|
+
mongocrypt_ctx_finalize(ctx, bin);
|
209
|
+
|
210
|
+
mongocrypt_binary_destroy(bin);
|
211
|
+
mongocrypt_ctx_destroy(ctx);
|
212
|
+
_mongocrypt_buffer_cleanup(&encrypted);
|
213
|
+
mongocrypt_destroy(crypt);
|
252
214
|
}
|
253
215
|
|
254
|
-
static void
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
ctx,
|
286
|
-
TEST_BSON ("{'v': { '$binary': { 'base64': '', 'subType': '00' } } }"));
|
287
|
-
_mongocrypt_tester_run_ctx_to (
|
288
|
-
tester, ctx, MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS);
|
289
|
-
ASSERT_OK (mongocrypt_ctx_provide_kms_providers (
|
290
|
-
ctx,
|
291
|
-
TEST_BSON ("{'local':{'key': { '$binary': {'base64': '%s', "
|
292
|
-
"'subType': '00'}}}}",
|
293
|
-
local_kek)),
|
216
|
+
static void _test_decrypt_per_ctx_credentials_local(_mongocrypt_tester_t *tester) {
|
217
|
+
mongocrypt_t *crypt;
|
218
|
+
mongocrypt_ctx_t *ctx;
|
219
|
+
mongocrypt_binary_t *bin;
|
220
|
+
_mongocrypt_buffer_t encrypted;
|
221
|
+
/* local_kek is the KEK used to encrypt the keyMaterial in
|
222
|
+
* ./test/data/key-document-local.json */
|
223
|
+
const char *local_kek = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
224
|
+
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
|
225
|
+
/* local_uuid is the hex of the UUID of the key in
|
226
|
+
* ./test/data/key-document-local.json */
|
227
|
+
const char *local_uuid = "61616161616161616161616161616161";
|
228
|
+
_mongocrypt_buffer_t local_uuid_buf;
|
229
|
+
|
230
|
+
bin = mongocrypt_binary_new();
|
231
|
+
crypt = mongocrypt_new();
|
232
|
+
mongocrypt_setopt_use_need_kms_credentials_state(crypt);
|
233
|
+
mongocrypt_setopt_kms_providers(crypt, TEST_BSON("{'local': {}}"));
|
234
|
+
ASSERT_OK(mongocrypt_init(crypt), crypt);
|
235
|
+
ctx = mongocrypt_ctx_new(crypt);
|
236
|
+
|
237
|
+
/* Encrypt an empty binary value. */
|
238
|
+
_mongocrypt_buffer_copy_from_hex(&local_uuid_buf, local_uuid);
|
239
|
+
mongocrypt_ctx_setopt_key_id(ctx, _mongocrypt_buffer_as_binary(&local_uuid_buf));
|
240
|
+
mongocrypt_ctx_setopt_algorithm(ctx, MONGOCRYPT_ALGORITHM_DETERMINISTIC_STR, -1);
|
241
|
+
mongocrypt_ctx_explicit_encrypt_init(ctx, TEST_BSON("{'v': { '$binary': { 'base64': '', 'subType': '00' } } }"));
|
242
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS);
|
243
|
+
ASSERT_OK(mongocrypt_ctx_provide_kms_providers(ctx,
|
244
|
+
TEST_BSON("{'local':{'key': { '$binary': {'base64': '%s', "
|
245
|
+
"'subType': '00'}}}}",
|
246
|
+
local_kek)),
|
294
247
|
ctx);
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
mongocrypt_ctx_destroy (ctx);
|
316
|
-
_mongocrypt_buffer_cleanup (&encrypted);
|
317
|
-
mongocrypt_destroy (crypt);
|
248
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
249
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx, TEST_FILE("./test/data/key-document-local.json")), ctx);
|
250
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
251
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_READY);
|
252
|
+
mongocrypt_ctx_finalize(ctx, bin);
|
253
|
+
/* Copy the encrypted ciphertext since it is tied to the lifetime of ctx. */
|
254
|
+
_mongocrypt_buffer_copy_from_binary(&encrypted, bin);
|
255
|
+
mongocrypt_ctx_destroy(ctx);
|
256
|
+
|
257
|
+
/* Decrypt it back. */
|
258
|
+
ctx = mongocrypt_ctx_new(crypt);
|
259
|
+
mongocrypt_ctx_explicit_decrypt_init(ctx, _mongocrypt_buffer_as_binary(&encrypted));
|
260
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_READY);
|
261
|
+
mongocrypt_ctx_finalize(ctx, bin);
|
262
|
+
|
263
|
+
_mongocrypt_buffer_cleanup(&local_uuid_buf);
|
264
|
+
mongocrypt_binary_destroy(bin);
|
265
|
+
mongocrypt_ctx_destroy(ctx);
|
266
|
+
_mongocrypt_buffer_cleanup(&encrypted);
|
267
|
+
mongocrypt_destroy(crypt);
|
318
268
|
}
|
319
269
|
|
320
|
-
static void
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
mongocrypt_ctx_decrypt_init (
|
494
|
-
ctx,
|
495
|
-
TEST_BSON ("{'plainText':'sample','encrypted1':{'$binary':{'base64'"
|
496
|
-
":'" TEST_IEEV_BASE64 "','subType':'6'}}, "
|
497
|
-
"'encrypted2':{'$binary':{'base64':'" TEST_IEEV_BASE64
|
498
|
-
"','subType':'6'}}}")),
|
499
|
-
ctx);
|
500
|
-
/* The first transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests S_Key.
|
501
|
-
*/
|
502
|
-
ASSERT_STATE_EQUAL (mongocrypt_ctx_state (ctx),
|
503
|
-
MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
504
|
-
ASSERT_OK (mongocrypt_ctx_mongo_feed (
|
505
|
-
ctx,
|
506
|
-
TEST_FILE ("./test/data/keys/"
|
507
|
-
"12345678123498761234123456789012-local-"
|
508
|
-
"document.json")),
|
509
|
-
ctx);
|
510
|
-
ASSERT_OK (mongocrypt_ctx_mongo_done (ctx), ctx);
|
511
|
-
/* The second transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests K_Key.
|
512
|
-
*/
|
513
|
-
ASSERT_STATE_EQUAL (mongocrypt_ctx_state (ctx),
|
514
|
-
MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
515
|
-
ASSERT_OK (mongocrypt_ctx_mongo_feed (
|
516
|
-
ctx,
|
517
|
-
TEST_FILE ("./test/data/keys/"
|
518
|
-
"ABCDEFAB123498761234123456789012-local-"
|
519
|
-
"document.json")),
|
520
|
-
ctx);
|
521
|
-
ASSERT_OK (mongocrypt_ctx_mongo_done (ctx), ctx);
|
522
|
-
ASSERT_STATE_EQUAL (mongocrypt_ctx_state (ctx), MONGOCRYPT_CTX_READY);
|
523
|
-
out = mongocrypt_binary_new ();
|
524
|
-
ASSERT_OK (mongocrypt_ctx_finalize (ctx, out), ctx);
|
525
|
-
ASSERT (_mongocrypt_binary_to_bson (out, &out_bson));
|
526
|
-
_assert_match_bson (&out_bson,
|
527
|
-
TMP_BSON ("{'plainText': 'sample', 'encrypted1': "
|
270
|
+
static void _test_decrypt_fle2(_mongocrypt_tester_t *tester) {
|
271
|
+
_mongocrypt_buffer_t S_KeyId;
|
272
|
+
_mongocrypt_buffer_t K_KeyId;
|
273
|
+
|
274
|
+
if (!_aes_ctr_is_supported_by_os) {
|
275
|
+
printf("Common Crypto with no CTR support detected. Skipping.");
|
276
|
+
return;
|
277
|
+
}
|
278
|
+
|
279
|
+
#define TEST_IEEV_BASE64 \
|
280
|
+
"BxI0VngSNJh2EjQSNFZ4kBICQ7uhTd9C2oI8M1afRon0ZaYG0s6oTmt0aBZ9kO4S4mm5vId01" \
|
281
|
+
"BsW7tBHytA8pDJ2IiWBCmah3OGH2M4ET7PSqekQD4gkUCo4JeEttx4yj05Ou4D6yZUmYfVKmE" \
|
282
|
+
"ljge16NCxKm7Ir9gvmQsp8x1wqGBzpndA6gkqFxsxfvQ/" \
|
283
|
+
"cIqOwMW9dGTTWsfKge+jYkCUIFMfms+XyC/8evQhjjA+qR6eEmV+N/" \
|
284
|
+
"kwpR7Q7TJe0lwU5kw2kSe3/KiPKRZZTbn8znadvycfJ0cCWGad9SQ=="
|
285
|
+
|
286
|
+
_mongocrypt_buffer_copy_from_hex(&S_KeyId, "12345678123498761234123456789012");
|
287
|
+
_mongocrypt_buffer_copy_from_hex(&K_KeyId, "ABCDEFAB123498761234123456789012");
|
288
|
+
|
289
|
+
/* Test success with an FLE2IndexedEqualityEncryptedValue payload. */
|
290
|
+
{
|
291
|
+
mongocrypt_t *crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
292
|
+
mongocrypt_ctx_t *ctx;
|
293
|
+
mongocrypt_binary_t *out;
|
294
|
+
bson_t out_bson;
|
295
|
+
|
296
|
+
ctx = mongocrypt_ctx_new(crypt);
|
297
|
+
ASSERT_OK(mongocrypt_ctx_decrypt_init(ctx,
|
298
|
+
TEST_BSON("{'plainText':'sample','encrypted':{'$binary':{'base64':"
|
299
|
+
"'" TEST_IEEV_BASE64 "','subType':'6'}}}")),
|
300
|
+
ctx);
|
301
|
+
/* The first transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests S_Key.
|
302
|
+
*/
|
303
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
304
|
+
{
|
305
|
+
mongocrypt_binary_t *filter = mongocrypt_binary_new();
|
306
|
+
ASSERT_OK(mongocrypt_ctx_mongo_op(ctx, filter), ctx);
|
307
|
+
ASSERT_MONGOCRYPT_BINARY_EQUAL_BSON(TEST_FILE("./test/data/fle2-decrypt-ieev/first-filter.json"), filter);
|
308
|
+
mongocrypt_binary_destroy(filter);
|
309
|
+
}
|
310
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
311
|
+
TEST_FILE("./test/data/keys/"
|
312
|
+
"12345678123498761234123456789012-local-"
|
313
|
+
"document.json")),
|
314
|
+
ctx);
|
315
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
316
|
+
/* The second transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests K_Key.
|
317
|
+
*/
|
318
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
319
|
+
{
|
320
|
+
mongocrypt_binary_t *filter = mongocrypt_binary_new();
|
321
|
+
ASSERT_OK(mongocrypt_ctx_mongo_op(ctx, filter), ctx);
|
322
|
+
ASSERT_MONGOCRYPT_BINARY_EQUAL_BSON(TEST_FILE("./test/data/fle2-decrypt-ieev/second-filter.json"), filter);
|
323
|
+
mongocrypt_binary_destroy(filter);
|
324
|
+
}
|
325
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
326
|
+
TEST_FILE("./test/data/keys/"
|
327
|
+
"ABCDEFAB123498761234123456789012-local-"
|
328
|
+
"document.json")),
|
329
|
+
ctx);
|
330
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
331
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_READY);
|
332
|
+
out = mongocrypt_binary_new();
|
333
|
+
ASSERT_OK(mongocrypt_ctx_finalize(ctx, out), ctx);
|
334
|
+
ASSERT(_mongocrypt_binary_to_bson(out, &out_bson));
|
335
|
+
_assert_match_bson(&out_bson, TMP_BSON("{'plainText': 'sample', 'encrypted': 'value123'}"));
|
336
|
+
mongocrypt_binary_destroy(out);
|
337
|
+
mongocrypt_ctx_destroy(ctx);
|
338
|
+
mongocrypt_destroy(crypt);
|
339
|
+
}
|
340
|
+
|
341
|
+
/* Test success with a non-local KMS provider. */
|
342
|
+
{
|
343
|
+
mongocrypt_t *crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
344
|
+
mongocrypt_ctx_t *ctx;
|
345
|
+
mongocrypt_binary_t *out;
|
346
|
+
bson_t out_bson;
|
347
|
+
|
348
|
+
ctx = mongocrypt_ctx_new(crypt);
|
349
|
+
ASSERT_OK(mongocrypt_ctx_decrypt_init(ctx,
|
350
|
+
TEST_BSON("{'plainText':'sample','encrypted':{'$binary':{'base64':"
|
351
|
+
"'" TEST_IEEV_BASE64 "','subType':'6'}}}")),
|
352
|
+
ctx);
|
353
|
+
/* The first transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests S_Key.
|
354
|
+
*/
|
355
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
356
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
357
|
+
TEST_FILE("./test/data/keys/"
|
358
|
+
"12345678123498761234123456789012-aws-"
|
359
|
+
"document.json")),
|
360
|
+
ctx);
|
361
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
362
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_KMS);
|
363
|
+
{
|
364
|
+
mongocrypt_kms_ctx_t *kms_ctx = mongocrypt_ctx_next_kms_ctx(ctx);
|
365
|
+
ASSERT(kms_ctx);
|
366
|
+
ASSERT_OK(mongocrypt_kms_ctx_feed(kms_ctx,
|
367
|
+
TEST_FILE("./test/data/keys/"
|
368
|
+
"12345678123498761234123456789012-"
|
369
|
+
"aws-decrypt-reply.txt")),
|
370
|
+
kms_ctx);
|
371
|
+
ASSERT(!mongocrypt_ctx_next_kms_ctx(ctx));
|
372
|
+
ASSERT_OK(mongocrypt_ctx_kms_done(ctx), ctx);
|
373
|
+
}
|
374
|
+
/* The second transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests K_Key.
|
375
|
+
*/
|
376
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
377
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
378
|
+
TEST_FILE("./test/data/keys/"
|
379
|
+
"ABCDEFAB123498761234123456789012-aws-"
|
380
|
+
"document.json")),
|
381
|
+
ctx);
|
382
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
383
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_KMS);
|
384
|
+
{
|
385
|
+
mongocrypt_kms_ctx_t *kms_ctx = mongocrypt_ctx_next_kms_ctx(ctx);
|
386
|
+
ASSERT(kms_ctx);
|
387
|
+
ASSERT_OK(mongocrypt_kms_ctx_feed(kms_ctx,
|
388
|
+
TEST_FILE("./test/data/keys/"
|
389
|
+
"ABCDEFAB123498761234123456789012-"
|
390
|
+
"aws-decrypt-reply.txt")),
|
391
|
+
kms_ctx);
|
392
|
+
ASSERT(!mongocrypt_ctx_next_kms_ctx(ctx));
|
393
|
+
ASSERT_OK(mongocrypt_ctx_kms_done(ctx), ctx);
|
394
|
+
}
|
395
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_READY);
|
396
|
+
out = mongocrypt_binary_new();
|
397
|
+
ASSERT_OK(mongocrypt_ctx_finalize(ctx, out), ctx);
|
398
|
+
ASSERT(_mongocrypt_binary_to_bson(out, &out_bson));
|
399
|
+
_assert_match_bson(&out_bson, TMP_BSON("{'plainText': 'sample', 'encrypted': 'value123'}"));
|
400
|
+
mongocrypt_binary_destroy(out);
|
401
|
+
mongocrypt_ctx_destroy(ctx);
|
402
|
+
mongocrypt_destroy(crypt);
|
403
|
+
}
|
404
|
+
|
405
|
+
/* Test success with two FLE2IndexedEqualityEncryptedValue payloads. */
|
406
|
+
{
|
407
|
+
mongocrypt_t *crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
408
|
+
mongocrypt_ctx_t *ctx;
|
409
|
+
mongocrypt_binary_t *out;
|
410
|
+
bson_t out_bson;
|
411
|
+
|
412
|
+
ctx = mongocrypt_ctx_new(crypt);
|
413
|
+
ASSERT_OK(mongocrypt_ctx_decrypt_init(ctx,
|
414
|
+
TEST_BSON("{'plainText':'sample','encrypted1':{'$binary':{'base64'"
|
415
|
+
":'" TEST_IEEV_BASE64 "','subType':'6'}}, "
|
416
|
+
"'encrypted2':{'$binary':{'base64':'" TEST_IEEV_BASE64
|
417
|
+
"','subType':'6'}}}")),
|
418
|
+
ctx);
|
419
|
+
/* The first transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests S_Key.
|
420
|
+
*/
|
421
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
422
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
423
|
+
TEST_FILE("./test/data/keys/"
|
424
|
+
"12345678123498761234123456789012-local-"
|
425
|
+
"document.json")),
|
426
|
+
ctx);
|
427
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
428
|
+
/* The second transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests K_Key.
|
429
|
+
*/
|
430
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
431
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
432
|
+
TEST_FILE("./test/data/keys/"
|
433
|
+
"ABCDEFAB123498761234123456789012-local-"
|
434
|
+
"document.json")),
|
435
|
+
ctx);
|
436
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
437
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_READY);
|
438
|
+
out = mongocrypt_binary_new();
|
439
|
+
ASSERT_OK(mongocrypt_ctx_finalize(ctx, out), ctx);
|
440
|
+
ASSERT(_mongocrypt_binary_to_bson(out, &out_bson));
|
441
|
+
_assert_match_bson(&out_bson,
|
442
|
+
TMP_BSON("{'plainText': 'sample', 'encrypted1': "
|
528
443
|
"'value123', 'encrypted2': 'value123'}"));
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
{
|
679
|
-
mongocrypt_t *crypt =
|
680
|
-
_mongocrypt_tester_mongocrypt (TESTER_MONGOCRYPT_DEFAULT);
|
681
|
-
mongocrypt_ctx_t *ctx;
|
682
|
-
|
683
|
-
ctx = mongocrypt_ctx_new (crypt);
|
684
|
-
ASSERT_OK (
|
685
|
-
mongocrypt_ctx_decrypt_init (
|
686
|
-
ctx,
|
687
|
-
TEST_BSON ("{'plainText':'sample','encrypted':{'$binary':{'base64':"
|
688
|
-
"'" TEST_IEEV_BASE64 "','subType':'6'}}}")),
|
689
|
-
ctx);
|
690
|
-
/* The first transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests S_Key.
|
691
|
-
*/
|
692
|
-
ASSERT_STATE_EQUAL (mongocrypt_ctx_state (ctx),
|
693
|
-
MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
694
|
-
ASSERT_OK (mongocrypt_ctx_mongo_feed (
|
695
|
-
ctx,
|
696
|
-
TEST_FILE ("./test/data/keys/"
|
697
|
-
"12345678123498761234123456789012-local-"
|
698
|
-
"document.json")),
|
699
|
-
ctx);
|
700
|
-
ASSERT_OK (mongocrypt_ctx_mongo_done (ctx), ctx);
|
701
|
-
/* The second transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests K_Key.
|
702
|
-
*/
|
703
|
-
ASSERT_STATE_EQUAL (mongocrypt_ctx_state (ctx),
|
704
|
-
MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
705
|
-
ASSERT_FAILS (mongocrypt_ctx_mongo_done (ctx),
|
706
|
-
ctx,
|
707
|
-
"not all keys requested were satisfied");
|
708
|
-
mongocrypt_ctx_destroy (ctx);
|
709
|
-
mongocrypt_destroy (crypt);
|
710
|
-
}
|
711
|
-
|
712
|
-
_mongocrypt_buffer_cleanup (&K_KeyId);
|
713
|
-
_mongocrypt_buffer_cleanup (&S_KeyId);
|
444
|
+
mongocrypt_binary_destroy(out);
|
445
|
+
mongocrypt_ctx_destroy(ctx);
|
446
|
+
mongocrypt_destroy(crypt);
|
447
|
+
}
|
448
|
+
|
449
|
+
/* Test success when S_Key is cached, K_Key is not cached. */
|
450
|
+
{
|
451
|
+
mongocrypt_t *crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
452
|
+
mongocrypt_ctx_t *ctx;
|
453
|
+
mongocrypt_binary_t *out;
|
454
|
+
bson_t out_bson;
|
455
|
+
|
456
|
+
ctx = mongocrypt_ctx_new(crypt);
|
457
|
+
ASSERT_OK(mongocrypt_ctx_decrypt_init(ctx,
|
458
|
+
TEST_BSON("{'plainText':'sample','encrypted':{'$binary':{'base64':"
|
459
|
+
"' " TEST_IEEV_BASE64 "','subType':'6'}}}")),
|
460
|
+
ctx);
|
461
|
+
/* The first transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests S_Key.
|
462
|
+
*/
|
463
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
464
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
465
|
+
TEST_FILE("./test/data/keys/"
|
466
|
+
"12345678123498761234123456789012-local-"
|
467
|
+
"document.json")),
|
468
|
+
ctx);
|
469
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
470
|
+
mongocrypt_ctx_destroy(ctx);
|
471
|
+
|
472
|
+
/* Create a new context. S_Key is cached in crypt. */
|
473
|
+
ctx = mongocrypt_ctx_new(crypt);
|
474
|
+
ASSERT_OK(mongocrypt_ctx_decrypt_init(ctx,
|
475
|
+
TEST_BSON("{'plainText':'sample','encrypted':{'$binary':{'base64':"
|
476
|
+
"'" TEST_IEEV_BASE64 "','subType':'6'}}}")),
|
477
|
+
ctx);
|
478
|
+
/* The first transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests K_Key.
|
479
|
+
*/
|
480
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
481
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
482
|
+
TEST_FILE("./test/data/keys/"
|
483
|
+
"ABCDEFAB123498761234123456789012-local-"
|
484
|
+
"document.json")),
|
485
|
+
ctx);
|
486
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
487
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_READY);
|
488
|
+
out = mongocrypt_binary_new();
|
489
|
+
ASSERT_OK(mongocrypt_ctx_finalize(ctx, out), ctx);
|
490
|
+
ASSERT(_mongocrypt_binary_to_bson(out, &out_bson));
|
491
|
+
_assert_match_bson(&out_bson, TMP_BSON("{'plainText': 'sample', 'encrypted': 'value123' }"));
|
492
|
+
mongocrypt_binary_destroy(out);
|
493
|
+
mongocrypt_ctx_destroy(ctx);
|
494
|
+
mongocrypt_destroy(crypt);
|
495
|
+
}
|
496
|
+
|
497
|
+
/* Test success when S_Key is cached, K_Key is cached. */
|
498
|
+
{
|
499
|
+
mongocrypt_t *crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
500
|
+
mongocrypt_ctx_t *ctx;
|
501
|
+
mongocrypt_binary_t *out;
|
502
|
+
bson_t out_bson;
|
503
|
+
|
504
|
+
ctx = mongocrypt_ctx_new(crypt);
|
505
|
+
ASSERT_OK(mongocrypt_ctx_decrypt_init(ctx,
|
506
|
+
TEST_BSON("{'plainText':'sample','encrypted':{'$binary':{'base64':"
|
507
|
+
"'" TEST_IEEV_BASE64 "','subType':'6'}}}")),
|
508
|
+
ctx);
|
509
|
+
/* The first transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests S_Key.
|
510
|
+
*/
|
511
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
512
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
513
|
+
TEST_FILE("./test/data/keys/"
|
514
|
+
"12345678123498761234123456789012-local-"
|
515
|
+
"document.json")),
|
516
|
+
ctx);
|
517
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
518
|
+
/* The second transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests K_Key.
|
519
|
+
*/
|
520
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
521
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
522
|
+
TEST_FILE("./test/data/keys/"
|
523
|
+
"ABCDEFAB123498761234123456789012-local-"
|
524
|
+
"document.json")),
|
525
|
+
ctx);
|
526
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
527
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_READY);
|
528
|
+
mongocrypt_ctx_destroy(ctx);
|
529
|
+
|
530
|
+
/* Create a new ctx. S_Key and K_Key are cached in crypt. */
|
531
|
+
ctx = mongocrypt_ctx_new(crypt);
|
532
|
+
ASSERT_OK(mongocrypt_ctx_decrypt_init(ctx,
|
533
|
+
TEST_BSON("{'plainText':'sample','encrypted':{'$binary':{'base64':"
|
534
|
+
"'" TEST_IEEV_BASE64 "','subType':'6'}}}")),
|
535
|
+
ctx);
|
536
|
+
out = mongocrypt_binary_new();
|
537
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_READY);
|
538
|
+
ASSERT_OK(mongocrypt_ctx_finalize(ctx, out), ctx);
|
539
|
+
ASSERT(_mongocrypt_binary_to_bson(out, &out_bson));
|
540
|
+
_assert_match_bson(&out_bson, TMP_BSON("{'plainText': 'sample', 'encrypted': 'value123'}"));
|
541
|
+
mongocrypt_binary_destroy(out);
|
542
|
+
mongocrypt_ctx_destroy(ctx);
|
543
|
+
mongocrypt_destroy(crypt);
|
544
|
+
}
|
545
|
+
|
546
|
+
/* Test error when S_Key is not provided. */
|
547
|
+
{
|
548
|
+
mongocrypt_t *crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
549
|
+
mongocrypt_ctx_t *ctx;
|
550
|
+
|
551
|
+
ctx = mongocrypt_ctx_new(crypt);
|
552
|
+
ASSERT_OK(mongocrypt_ctx_decrypt_init(ctx,
|
553
|
+
TEST_BSON("{'plainText':'sample','encrypted':{'$binary':{'base64':"
|
554
|
+
"'" TEST_IEEV_BASE64 "','subType':'6'}}}")),
|
555
|
+
ctx);
|
556
|
+
/* The first transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests S_Key.
|
557
|
+
*/
|
558
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
559
|
+
ASSERT_FAILS(mongocrypt_ctx_mongo_done(ctx), ctx, "not all keys requested were satisfied");
|
560
|
+
mongocrypt_ctx_destroy(ctx);
|
561
|
+
mongocrypt_destroy(crypt);
|
562
|
+
}
|
563
|
+
|
564
|
+
/* Test error when K_Key is not provided. */
|
565
|
+
{
|
566
|
+
mongocrypt_t *crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
567
|
+
mongocrypt_ctx_t *ctx;
|
568
|
+
|
569
|
+
ctx = mongocrypt_ctx_new(crypt);
|
570
|
+
ASSERT_OK(mongocrypt_ctx_decrypt_init(ctx,
|
571
|
+
TEST_BSON("{'plainText':'sample','encrypted':{'$binary':{'base64':"
|
572
|
+
"'" TEST_IEEV_BASE64 "','subType':'6'}}}")),
|
573
|
+
ctx);
|
574
|
+
/* The first transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests S_Key.
|
575
|
+
*/
|
576
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
577
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
578
|
+
TEST_FILE("./test/data/keys/"
|
579
|
+
"12345678123498761234123456789012-local-"
|
580
|
+
"document.json")),
|
581
|
+
ctx);
|
582
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
583
|
+
/* The second transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests K_Key.
|
584
|
+
*/
|
585
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
586
|
+
ASSERT_FAILS(mongocrypt_ctx_mongo_done(ctx), ctx, "not all keys requested were satisfied");
|
587
|
+
mongocrypt_ctx_destroy(ctx);
|
588
|
+
mongocrypt_destroy(crypt);
|
589
|
+
}
|
590
|
+
|
591
|
+
_mongocrypt_buffer_cleanup(&K_KeyId);
|
592
|
+
_mongocrypt_buffer_cleanup(&S_KeyId);
|
714
593
|
|
715
594
|
#undef TEST_IEEV_BASE64
|
716
595
|
}
|
717
596
|
|
718
|
-
static void
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
out = mongocrypt_binary_new ();
|
779
|
-
ASSERT_OK (mongocrypt_ctx_finalize (ctx, out), ctx);
|
780
|
-
ASSERT (_mongocrypt_binary_to_bson (out, &out_bson));
|
781
|
-
_assert_match_bson (&out_bson, TMP_BSON ("{'v': 'value123'}"));
|
782
|
-
mongocrypt_binary_destroy (out);
|
783
|
-
mongocrypt_ctx_destroy (ctx);
|
784
|
-
mongocrypt_destroy (crypt);
|
785
|
-
}
|
786
|
-
_mongocrypt_buffer_cleanup (&K_KeyId);
|
787
|
-
_mongocrypt_buffer_cleanup (&S_KeyId);
|
597
|
+
static void _test_explicit_decrypt_fle2_ieev(_mongocrypt_tester_t *tester) {
|
598
|
+
_mongocrypt_buffer_t S_KeyId;
|
599
|
+
_mongocrypt_buffer_t K_KeyId;
|
600
|
+
|
601
|
+
if (!_aes_ctr_is_supported_by_os) {
|
602
|
+
printf("Common Crypto with no CTR support detected. Skipping.");
|
603
|
+
return;
|
604
|
+
}
|
605
|
+
|
606
|
+
#define TEST_IEEV_BASE64 \
|
607
|
+
"BxI0VngSNJh2EjQSNFZ4kBICQ7uhTd9C2oI8M1afRon0ZaYG0s6oTmt0aBZ9kO4S4mm5vId01" \
|
608
|
+
"BsW7tBHytA8pDJ2IiWBCmah3OGH2M4ET7PSqekQD4gkUCo4JeEttx4yj05Ou4D6yZUmYfVKmE" \
|
609
|
+
"ljge16NCxKm7Ir9gvmQsp8x1wqGBzpndA6gkqFxsxfvQ/" \
|
610
|
+
"cIqOwMW9dGTTWsfKge+jYkCUIFMfms+XyC/8evQhjjA+qR6eEmV+N/" \
|
611
|
+
"kwpR7Q7TJe0lwU5kw2kSe3/KiPKRZZTbn8znadvycfJ0cCWGad9SQ=="
|
612
|
+
|
613
|
+
_mongocrypt_buffer_copy_from_hex(&S_KeyId, "12345678123498761234123456789012");
|
614
|
+
_mongocrypt_buffer_copy_from_hex(&K_KeyId, "ABCDEFAB123498761234123456789012");
|
615
|
+
|
616
|
+
/* Test success with an FLE2IndexedEqualityEncryptedValue payload. */
|
617
|
+
{
|
618
|
+
mongocrypt_t *crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
619
|
+
mongocrypt_ctx_t *ctx;
|
620
|
+
mongocrypt_binary_t *out;
|
621
|
+
bson_t out_bson;
|
622
|
+
|
623
|
+
ctx = mongocrypt_ctx_new(crypt);
|
624
|
+
ASSERT_OK(mongocrypt_ctx_explicit_decrypt_init(
|
625
|
+
ctx,
|
626
|
+
TEST_BSON("{'v':{'$binary':{'base64': '" TEST_IEEV_BASE64 "','subType':'6'}}}")),
|
627
|
+
ctx);
|
628
|
+
/* The first transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests S_Key.
|
629
|
+
*/
|
630
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
631
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
632
|
+
TEST_FILE("./test/data/keys/"
|
633
|
+
"12345678123498761234123456789012-local-"
|
634
|
+
"document.json")),
|
635
|
+
ctx);
|
636
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
637
|
+
/* The second transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests K_Key.
|
638
|
+
*/
|
639
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
640
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
641
|
+
TEST_FILE("./test/data/keys/"
|
642
|
+
"ABCDEFAB123498761234123456789012-local-"
|
643
|
+
"document.json")),
|
644
|
+
ctx);
|
645
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
646
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_READY);
|
647
|
+
out = mongocrypt_binary_new();
|
648
|
+
ASSERT_OK(mongocrypt_ctx_finalize(ctx, out), ctx);
|
649
|
+
ASSERT(_mongocrypt_binary_to_bson(out, &out_bson));
|
650
|
+
_assert_match_bson(&out_bson, TMP_BSON("{'v': 'value123'}"));
|
651
|
+
mongocrypt_binary_destroy(out);
|
652
|
+
mongocrypt_ctx_destroy(ctx);
|
653
|
+
mongocrypt_destroy(crypt);
|
654
|
+
}
|
655
|
+
_mongocrypt_buffer_cleanup(&K_KeyId);
|
656
|
+
_mongocrypt_buffer_cleanup(&S_KeyId);
|
788
657
|
|
789
658
|
#undef TEST_IEEV_BASE64
|
790
659
|
}
|
791
660
|
|
792
|
-
#define TEST_IUP_BASE64
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
static void
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
out = mongocrypt_binary_new ();
|
839
|
-
ASSERT_OK (mongocrypt_ctx_finalize (ctx, out), ctx);
|
840
|
-
ASSERT (_mongocrypt_binary_to_bson (out, &out_bson));
|
841
|
-
_assert_match_bson (
|
842
|
-
&out_bson,
|
843
|
-
TMP_BSON ("{'plainText': 'sample', 'encrypted': 'value123'}"));
|
844
|
-
mongocrypt_binary_destroy (out);
|
845
|
-
mongocrypt_ctx_destroy (ctx);
|
846
|
-
mongocrypt_destroy (crypt);
|
847
|
-
}
|
661
|
+
#define TEST_IUP_BASE64 \
|
662
|
+
"BHEBAAAFZAAgAAAAAHb62aV7+mqmaGcotPLdG3KP7S8diFwWMLM/" \
|
663
|
+
"5rYtqLrEBXMAIAAAAAAVJ6OWHRv3OtCozHpt3ZzfBhaxZirLv3B+" \
|
664
|
+
"G8PuaaO4EgVjACAAAAAAsZXWOWA+UiCBbrJNB6bHflB/" \
|
665
|
+
"cn7pWSvwWN2jw4FPeIUFcABQAAAAAMdD1nV2nqeI1eXEQNskDflCy8I7/" \
|
666
|
+
"HvvqDKJ6XxjhrPQWdLqjz+8GosGUsB7A8ee/uG9/" \
|
667
|
+
"guENuL25XD+" \
|
668
|
+
"Fxxkv1LLXtavHOlLF7iW0u9yabqqBXUAEAAAAAQSNFZ4EjSYdhI0EjRWeJASEHQAAgAAAAV2A" \
|
669
|
+
"E0AAAAAq83vqxI0mHYSNBI0VniQEkzZZBBDgeZh+h+gXEmOrSFtVvkUcnHWj/" \
|
670
|
+
"rfPW7iJ0G3UJ8zpuBmUM/VjOMJCY4+eDqdTiPIwX+/vNXegc8FZQAgAAAAAOuac/" \
|
671
|
+
"eRLYakKX6B0vZ1r3QodOQFfjqJD+xlGiPu4/PsAA=="
|
672
|
+
|
673
|
+
static void _test_decrypt_fle2_iup(_mongocrypt_tester_t *tester) {
|
674
|
+
if (!_aes_ctr_is_supported_by_os) {
|
675
|
+
printf("Common Crypto with no CTR support detected. Skipping.");
|
676
|
+
return;
|
677
|
+
}
|
678
|
+
|
679
|
+
/* Test success with an FLE2InsertUpdatePayload. */
|
680
|
+
{
|
681
|
+
mongocrypt_t *crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
682
|
+
mongocrypt_ctx_t *ctx;
|
683
|
+
mongocrypt_binary_t *out;
|
684
|
+
bson_t out_bson;
|
685
|
+
|
686
|
+
ctx = mongocrypt_ctx_new(crypt);
|
687
|
+
ASSERT_OK(mongocrypt_ctx_decrypt_init(ctx,
|
688
|
+
TEST_BSON("{'plainText':'sample','encrypted':{'$binary':{'base64':"
|
689
|
+
"'" TEST_IUP_BASE64 "','subType':'6'}}}")),
|
690
|
+
ctx);
|
691
|
+
|
692
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
693
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
694
|
+
TEST_FILE("./test/data/keys/"
|
695
|
+
"ABCDEFAB123498761234123456789012-local-document.json")),
|
696
|
+
ctx);
|
697
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
698
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_READY);
|
699
|
+
out = mongocrypt_binary_new();
|
700
|
+
ASSERT_OK(mongocrypt_ctx_finalize(ctx, out), ctx);
|
701
|
+
ASSERT(_mongocrypt_binary_to_bson(out, &out_bson));
|
702
|
+
_assert_match_bson(&out_bson, TMP_BSON("{'plainText': 'sample', 'encrypted': 'value123'}"));
|
703
|
+
mongocrypt_binary_destroy(out);
|
704
|
+
mongocrypt_ctx_destroy(ctx);
|
705
|
+
mongocrypt_destroy(crypt);
|
706
|
+
}
|
848
707
|
}
|
708
|
+
|
849
709
|
#undef TEST_IUP_BASE64
|
850
710
|
|
851
711
|
/* Test decrypting a BSON binary non-subtype 6 is an error. */
|
852
|
-
static void
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
"{'v': { '$binary': { 'base64': 'AAAA', 'subType': '00' }}}")),
|
864
|
-
ctx,
|
865
|
-
"decryption expected BSON binary subtype 6, got 0");
|
866
|
-
mongocrypt_ctx_destroy (ctx);
|
867
|
-
mongocrypt_destroy (crypt);
|
712
|
+
static void _test_decrypt_wrong_binary_subtype(_mongocrypt_tester_t *tester) {
|
713
|
+
mongocrypt_t *crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
714
|
+
mongocrypt_ctx_t *ctx = mongocrypt_ctx_new(crypt);
|
715
|
+
/* Use subtype 0. */
|
716
|
+
ASSERT_FAILS(
|
717
|
+
mongocrypt_ctx_explicit_decrypt_init(ctx,
|
718
|
+
TEST_BSON("{'v': { '$binary': { 'base64': 'AAAA', 'subType': '00' }}}")),
|
719
|
+
ctx,
|
720
|
+
"decryption expected BSON binary subtype 6, got 0");
|
721
|
+
mongocrypt_ctx_destroy(ctx);
|
722
|
+
mongocrypt_destroy(crypt);
|
868
723
|
}
|
869
724
|
|
870
|
-
#define TEST_IREV_BASE64
|
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
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
725
|
+
#define TEST_IREV_BASE64 \
|
726
|
+
"CRI0VngSNJh2EjQSNFZ4kBIQsPF0Ii0Hfv7ZMhnNt/yt+mviydF8EUw0YlO+amC3IF8dX2J/" \
|
727
|
+
"GmRZRnihW3VqJYoLMk0BIit0x9YQiQEEQPxPcTXnCx4t1fquOY7cRGqIAWTDHuQ9AdUw94EY1" \
|
728
|
+
"J55mq9UhwD7flh0ySR/SbkTwjIU32U1iM6Bv4AriE4smI87Yd0V7Z7kDoDx7afx9vM/" \
|
729
|
+
"+h9NWZvpfYcZ+P32sfILb3BdXT5zLrkyc5Xb3myDxE9abTrR8ePG0YuEmeqwGE4bZ6QHKzd/" \
|
730
|
+
"RLmHciWstKOtER5uRpo3p570wGO8QE9QtQoJp/7N7Su30dK/" \
|
731
|
+
"bk59hVvlNO6i3nUPwqMd13DePobNGn84q3Fag5O4Kw8P4EGfomFWzxydlVQ0SppGVfan9tIj1" \
|
732
|
+
"CFu5doYYT4adzX7L9HinKsTWE5ctD9Qxhhzb2cVs5JO96j4mpwOaloF/" \
|
733
|
+
"4qJhyqlzTEpoCXGQ0X9aeEplibFxQ7FJkaFfYzIDIxA2d6lzwVel3j+VwQ7zOP/" \
|
734
|
+
"bCnaFu6EP1OQw3ZarsaWGENf45DFuK5RsKX198vZTlqtH24YhAL1+noQTMtpTOp/" \
|
735
|
+
"6vrczOXkr7dJGQ6RAfliq1maD18PN5yjdyNhr7BXsrK6f01DX2Xr4s51AARxQ/" \
|
736
|
+
"0U5hmb4HjKg8Sbno4Th+Wza3I0RMgM0YzhRUJz+BXzx2l9NPdeyuECdQ1Q2wP1MNOCBy/" \
|
737
|
+
"QBJmc+" \
|
738
|
+
"RWYK57oWCuv5vmkpN8IlriyRv0PGRhYr4ZcLkDdzmuyfK6SGAvIPD4veDJRj3cXEazyMh6g+" \
|
739
|
+
"rvwt70laxo2IOhvUXDc89WvarthTOzlFt5FNrA8uXhUYyL1q1XSWYCiCu5vRv77BvRUJjf2B6" \
|
740
|
+
"5kaIKUAGDhYuhch2yU6O9VsHLik3xOGSwIUZJbdMyHY+eA8ZlWZeKJbpjz7a/" \
|
741
|
+
"TyBQU6VNG4+Z5SXJjURogkODNkx21QS0Z1+b7ZnCSXf1OQceomkDrREB7vyD2HX5rN2/" \
|
742
|
+
"KIBMgH3J7DnG2VpNhYJ9Ve1hMDGcrQggjkCpdP7lloc6QiH837tD/81gYmr95IbuIHe/" \
|
743
|
+
"x20oHh9heGHUELnCQ6hXYWOBvSFlGcqZs/" \
|
744
|
+
"f0qxn5Fe2OfQPRzEstxoW99IdPvgotDnL2vaz2JNFvFqiofc2pIP7XvpFKIoQO7q8LX9z7ah1" \
|
745
|
+
"Yh8cbi6us8g5y9WzOfh882jU7vQT+31a1ZaeDMbFV1Cemc+/" \
|
746
|
+
"d0HNksi1qMJtcjrH2MQgXJ3BTyAuJH9OFK8iGqSzHhop9hp5z8mvx834PPjgBfZGt4w/" \
|
747
|
+
"7qeie+T4sooGVVqA6F3jl8YfFdIUAwkxe5GBQVVvaRLYm/" \
|
748
|
+
"4SLGBf54Dexi7e0+rL2sG5DeKygNdFzMc6lRO+" \
|
749
|
+
"gvmAMmDucRm4bxmu7ycNZCQUcuSKoMUWWu6A6eUiyBCQUxrrlX/" \
|
750
|
+
"3CkRXkQQ6JCwZZMvTgBokYx3WQR6LpW70xWLXyQhav4ZnHKzgITSOe7mUkMJ35NDMD+" \
|
751
|
+
"qsxXY7sWbGz+b60DWF7yaMVzDPzIGjWLpckMRMxgN3bQ5SE/mFxdjoZD5yYb84q/" \
|
752
|
+
"O7EjwGA9MSTp9MFEZt7VV3f5TDWiNUZKmjUgOdjBoTSAkVzAO2nqqQNg23x6Z6FQDBeefRkfc" \
|
753
|
+
"9FoUiBqHuN4fU/zc4Hkthp1McwIkYwRdlgPceD/" \
|
754
|
+
"BSNbkNRNAnzghBhCquIqpXd8AptBX2qO67rfT7COhpn/" \
|
755
|
+
"fzVo3ueCRTaM2DtjD3uuH4rMNb3LDjyJFX1DZ5eEWkGq9UE/" \
|
756
|
+
"AFivfeia4cA0a8Z1LzZcW7WvE5Y1WIZN4gy9SZcNgHEQq8Ad8Q4fAbxe8XJ6/" \
|
757
|
+
"tNvG+AvAuLEvNJtbhC/4Ei/" \
|
758
|
+
"JoXplvutDlW5d6g4KEWj4GICqggM5ZSv0TCkbfFkLdaJrOHrn+oI++" \
|
759
|
+
"krv1U4yQk6P18Mg2bE18ibe+LdWNsqn01V7yDmS+" \
|
760
|
+
"VAvqQF8f2p4rOOyWsGc7CoyXSrq9LCuGq9eMPR6auo+" \
|
761
|
+
"tyS1Nek2t6SgpOpzBBDdQnC5sHC1OWTW3ui7w4H0NKCuZOiMncbSDOlegn8C0zZa6Z5iYAce8" \
|
762
|
+
"a8Ow3jryBEnKBaguhjjOMG8iX/eka8XP+UTxvso4fKVVOXQwobZMdYbf/" \
|
763
|
+
"sXNJbMbWrFc1S9rdlXL/" \
|
764
|
+
"nnYvYrRMnOBJ27Mz5vvtOpd4fyQ+wi1q+" \
|
765
|
+
"5VvuLDM8u51B4oaYqpGUZZ3qVS5BBYm9cDxgMtcdoXjOSopHasdAhron+" \
|
766
|
+
"NdbGFBxyrUGKnnVXYocEuvsvwhBEA3HUUVV94m3C0agh2eVpmCIyWrs+" \
|
767
|
+
"grkpAaNLZwXVuzegttJ0GoTxzQnDIWkvlvkS3ZGo25spfPp+/Nda4SZAYRNmtnGfB2TRl0Wx/" \
|
768
|
+
"o/" \
|
769
|
+
"V2vx+9qnGyDq52CSkMftpfnsMXAnAv6ps7U+" \
|
770
|
+
"mgbgNPUFjv1Y0xKaeJdshu1HyEmq5aYqHJSfF2EzvPfH4d0Ijz1lsxMxL4IsqB7kufcOR4FFn" \
|
771
|
+
"aYXKIXLjRwM5VZNAK/3dvCb3l9H7QMOiJPbdoxAd123aymjz9N/" \
|
772
|
+
"2O33wMaG6OE8pXp0iYEaW7DOr0FfT913JeUnPNPcqqsA9YXod2UuNWZElTW/" \
|
773
|
+
"saL32v9akNwA4Jd7Y5VgI4y+XyDH3kAU0Uc8g6YCx/hqcn4pd2+ryH+/" \
|
774
|
+
"5nVQhnCE0KNOjjrFS92RNLD71GUhWR+VXMw2tKXBUSKnt9Ai4LLJrdvFbwrdqK+" \
|
775
|
+
"AjBUVqI3MgylNxRw2395ppAbheE1pAcoqLoDOGyOs66Y8kJGpaqs0AmdmZHw2OA26btw+" \
|
776
|
+
"ceBN+UgScsB5P5wNIup1AvU5J7h1vlFBNygg3WO/MJGCz48xgJ/" \
|
777
|
+
"klg9wCLQ+vXtrhYJz15RgguADFLBrTcV/Miel20KulnprI+/" \
|
778
|
+
"lXtRvEAoGJSc0UZ8J7UVTf8kvYzT3hF7XzZzlhKxPYebjdnp2la4o2PkyZXcc/" \
|
779
|
+
"gFLa7ickR28ZPUigwpW0lK5sJIwWbnZmP5wbQNhiGO8QL9gVpFOnu0xHpu8MqBvfZGf2HiE+" \
|
780
|
+
"qBUSR89v88gz6u/TVP9zVH1dnk9PE54Uw3yPdxL/" \
|
781
|
+
"feukvF71sEI6WWd2fdupgRlDGzASrKSAsFbaZobwUViEIFbWo7zPYVZyMglCrD1Xoxdd6EBeU" \
|
782
|
+
"SJDkS1nhiHOR/7FpIhae8fggAD+StXR7725vzcwIOX21ozRcE2iWw6OP99vDoqLQ8VYzYS0/" \
|
783
|
+
"f3WMME6b5ndYz25uC0AiULXYI="
|
929
784
|
|
930
785
|
/* Test decrypting FLE2IndexedRangeEncryptedValue */
|
931
|
-
static void
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
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
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
"ABCDEFAB123498761234123456789012-local-"
|
989
|
-
"document.json")),
|
990
|
-
ctx);
|
991
|
-
ASSERT_OK (mongocrypt_ctx_mongo_done (ctx), ctx);
|
992
|
-
ASSERT_STATE_EQUAL (mongocrypt_ctx_state (ctx), MONGOCRYPT_CTX_READY);
|
993
|
-
out = mongocrypt_binary_new ();
|
994
|
-
ASSERT_OK (mongocrypt_ctx_finalize (ctx, out), ctx);
|
995
|
-
ASSERT (_mongocrypt_binary_to_bson (out, &out_bson));
|
996
|
-
_assert_match_bson (
|
997
|
-
&out_bson, TMP_BSON ("{'plainText': 'sample', 'encrypted': 123456}"));
|
998
|
-
mongocrypt_binary_destroy (out);
|
999
|
-
mongocrypt_ctx_destroy (ctx);
|
1000
|
-
mongocrypt_destroy (crypt);
|
1001
|
-
}
|
786
|
+
static void _test_decrypt_fle2_irev(_mongocrypt_tester_t *tester) {
|
787
|
+
if (!_aes_ctr_is_supported_by_os) {
|
788
|
+
printf("Common Crypto with no CTR support detected. Skipping.");
|
789
|
+
return;
|
790
|
+
}
|
791
|
+
|
792
|
+
/* Test success with an FLE2IndexedEqualityEncryptedValue payload. */
|
793
|
+
{
|
794
|
+
mongocrypt_t *crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
795
|
+
mongocrypt_ctx_t *ctx;
|
796
|
+
mongocrypt_binary_t *out;
|
797
|
+
bson_t out_bson;
|
798
|
+
|
799
|
+
ctx = mongocrypt_ctx_new(crypt);
|
800
|
+
ASSERT_OK(mongocrypt_ctx_decrypt_init(ctx,
|
801
|
+
TEST_BSON("{'plainText':'sample','encrypted':{'$binary':{'base64':"
|
802
|
+
"'" TEST_IREV_BASE64 "','subType':'6'}}}")),
|
803
|
+
ctx);
|
804
|
+
/* The first transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests S_Key.
|
805
|
+
*/
|
806
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
807
|
+
{
|
808
|
+
mongocrypt_binary_t *filter = mongocrypt_binary_new();
|
809
|
+
ASSERT_OK(mongocrypt_ctx_mongo_op(ctx, filter), ctx);
|
810
|
+
ASSERT_MONGOCRYPT_BINARY_EQUAL_BSON(TEST_FILE("./test/data/fle2-decrypt-ieev/first-filter.json"), filter);
|
811
|
+
mongocrypt_binary_destroy(filter);
|
812
|
+
}
|
813
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
814
|
+
TEST_FILE("./test/data/keys/"
|
815
|
+
"12345678123498761234123456789012-local-"
|
816
|
+
"document.json")),
|
817
|
+
ctx);
|
818
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
819
|
+
/* The second transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests K_Key.
|
820
|
+
*/
|
821
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
822
|
+
{
|
823
|
+
mongocrypt_binary_t *filter = mongocrypt_binary_new();
|
824
|
+
ASSERT_OK(mongocrypt_ctx_mongo_op(ctx, filter), ctx);
|
825
|
+
ASSERT_MONGOCRYPT_BINARY_EQUAL_BSON(TEST_FILE("./test/data/fle2-decrypt-ieev/second-filter.json"), filter);
|
826
|
+
mongocrypt_binary_destroy(filter);
|
827
|
+
}
|
828
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
829
|
+
TEST_FILE("./test/data/keys/"
|
830
|
+
"ABCDEFAB123498761234123456789012-local-"
|
831
|
+
"document.json")),
|
832
|
+
ctx);
|
833
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
834
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_READY);
|
835
|
+
out = mongocrypt_binary_new();
|
836
|
+
ASSERT_OK(mongocrypt_ctx_finalize(ctx, out), ctx);
|
837
|
+
ASSERT(_mongocrypt_binary_to_bson(out, &out_bson));
|
838
|
+
_assert_match_bson(&out_bson, TMP_BSON("{'plainText': 'sample', 'encrypted': 123456}"));
|
839
|
+
mongocrypt_binary_destroy(out);
|
840
|
+
mongocrypt_ctx_destroy(ctx);
|
841
|
+
mongocrypt_destroy(crypt);
|
842
|
+
}
|
1002
843
|
}
|
1003
844
|
|
1004
845
|
// Test explicitly decrypting an FLE2IndexedRangeEncryptedValue.
|
1005
|
-
static void
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
ASSERT_OK (mongocrypt_ctx_explicit_decrypt_init (
|
1021
|
-
ctx,
|
1022
|
-
TEST_BSON ("{'v': {'$binary':{'base64':'" TEST_IREV_BASE64
|
1023
|
-
"','subType':'6'}}}")),
|
846
|
+
static void _test_explicit_decrypt_fle2_irev(_mongocrypt_tester_t *tester) {
|
847
|
+
if (!_aes_ctr_is_supported_by_os) {
|
848
|
+
printf("Common Crypto with no CTR support detected. Skipping.");
|
849
|
+
return;
|
850
|
+
}
|
851
|
+
|
852
|
+
mongocrypt_t *crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
853
|
+
mongocrypt_ctx_t *ctx;
|
854
|
+
mongocrypt_binary_t *out;
|
855
|
+
bson_t out_bson;
|
856
|
+
|
857
|
+
ctx = mongocrypt_ctx_new(crypt);
|
858
|
+
ASSERT_OK(mongocrypt_ctx_explicit_decrypt_init(
|
859
|
+
ctx,
|
860
|
+
TEST_BSON("{'v': {'$binary':{'base64':'" TEST_IREV_BASE64 "','subType':'6'}}}")),
|
1024
861
|
ctx);
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
TEST_FILE ("./test/data/keys/"
|
1039
|
-
"12345678123498761234123456789012-local-"
|
1040
|
-
"document.json")),
|
862
|
+
/* The first transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests S_Key.
|
863
|
+
*/
|
864
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
865
|
+
{
|
866
|
+
mongocrypt_binary_t *filter = mongocrypt_binary_new();
|
867
|
+
ASSERT_OK(mongocrypt_ctx_mongo_op(ctx, filter), ctx);
|
868
|
+
ASSERT_MONGOCRYPT_BINARY_EQUAL_BSON(TEST_FILE("./test/data/fle2-decrypt-ieev/first-filter.json"), filter);
|
869
|
+
mongocrypt_binary_destroy(filter);
|
870
|
+
}
|
871
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
872
|
+
TEST_FILE("./test/data/keys/"
|
873
|
+
"12345678123498761234123456789012-local-"
|
874
|
+
"document.json")),
|
1041
875
|
ctx);
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
ctx,
|
1057
|
-
TEST_FILE ("./test/data/keys/"
|
1058
|
-
"ABCDEFAB123498761234123456789012-local-"
|
1059
|
-
"document.json")),
|
876
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
877
|
+
/* The second transition to MONGOCRYPT_CTX_NEED_MONGO_KEYS requests K_Key.
|
878
|
+
*/
|
879
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
880
|
+
{
|
881
|
+
mongocrypt_binary_t *filter = mongocrypt_binary_new();
|
882
|
+
ASSERT_OK(mongocrypt_ctx_mongo_op(ctx, filter), ctx);
|
883
|
+
ASSERT_MONGOCRYPT_BINARY_EQUAL_BSON(TEST_FILE("./test/data/fle2-decrypt-ieev/second-filter.json"), filter);
|
884
|
+
mongocrypt_binary_destroy(filter);
|
885
|
+
}
|
886
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
887
|
+
TEST_FILE("./test/data/keys/"
|
888
|
+
"ABCDEFAB123498761234123456789012-local-"
|
889
|
+
"document.json")),
|
1060
890
|
ctx);
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
891
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
892
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_READY);
|
893
|
+
out = mongocrypt_binary_new();
|
894
|
+
ASSERT_OK(mongocrypt_ctx_finalize(ctx, out), ctx);
|
895
|
+
ASSERT(_mongocrypt_binary_to_bson(out, &out_bson));
|
896
|
+
_assert_match_bson(&out_bson, TMP_BSON("{'v': 123456}"));
|
897
|
+
mongocrypt_binary_destroy(out);
|
898
|
+
mongocrypt_ctx_destroy(ctx);
|
899
|
+
mongocrypt_destroy(crypt);
|
1070
900
|
}
|
1071
901
|
|
1072
902
|
#undef TEST_IREV_BASE64
|
1073
903
|
|
1074
904
|
// Test explicitly decrypting an FLE2InsertUpdatePayload with edges.
|
1075
|
-
static void
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
ASSERT_OK (mongocrypt_ctx_explicit_decrypt_init (
|
1092
|
-
ctx,
|
1093
|
-
TEST_FILE ("./test/data/fle2-insert-range-explicit/int32/"
|
1094
|
-
"encrypted-payload.json")),
|
905
|
+
static void _test_explicit_decrypt_fle2_iup_with_edges(_mongocrypt_tester_t *tester) {
|
906
|
+
if (!_aes_ctr_is_supported_by_os) {
|
907
|
+
printf("Common Crypto with no CTR support detected. Skipping.");
|
908
|
+
return;
|
909
|
+
}
|
910
|
+
|
911
|
+
/* Test success with an FLE2IndexedEqualityEncryptedValue payload. */
|
912
|
+
mongocrypt_t *crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
|
913
|
+
mongocrypt_ctx_t *ctx;
|
914
|
+
mongocrypt_binary_t *out;
|
915
|
+
bson_t out_bson;
|
916
|
+
|
917
|
+
ctx = mongocrypt_ctx_new(crypt);
|
918
|
+
ASSERT_OK(mongocrypt_ctx_explicit_decrypt_init(ctx,
|
919
|
+
TEST_FILE("./test/data/fle2-insert-range-explicit/int32/"
|
920
|
+
"encrypted-payload.json")),
|
1095
921
|
ctx);
|
1096
922
|
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
"ABCDEFAB123498761234123456789012-local-"
|
1103
|
-
"document.json")),
|
923
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
924
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
925
|
+
TEST_FILE("./test/data/keys/"
|
926
|
+
"ABCDEFAB123498761234123456789012-local-"
|
927
|
+
"document.json")),
|
1104
928
|
ctx);
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
929
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
930
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_READY);
|
931
|
+
out = mongocrypt_binary_new();
|
932
|
+
ASSERT_OK(mongocrypt_ctx_finalize(ctx, out), ctx);
|
933
|
+
ASSERT(_mongocrypt_binary_to_bson(out, &out_bson));
|
934
|
+
_assert_match_bson(&out_bson, TMP_BSON("{'v': 123456}"));
|
935
|
+
mongocrypt_binary_destroy(out);
|
936
|
+
mongocrypt_ctx_destroy(ctx);
|
937
|
+
mongocrypt_destroy(crypt);
|
1114
938
|
}
|
1115
939
|
|
1116
|
-
void
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
INSTALL_TEST (_test_explicit_decrypt_fle2_irev);
|
1133
|
-
INSTALL_TEST (_test_explicit_decrypt_fle2_iup_with_edges);
|
940
|
+
void _mongocrypt_tester_install_ctx_decrypt(_mongocrypt_tester_t *tester) {
|
941
|
+
INSTALL_TEST(_test_explicit_decrypt_init);
|
942
|
+
INSTALL_TEST(_test_decrypt_init);
|
943
|
+
INSTALL_TEST(_test_decrypt_need_keys);
|
944
|
+
INSTALL_TEST(_test_decrypt_ready);
|
945
|
+
INSTALL_TEST(_test_decrypt_empty_aws);
|
946
|
+
INSTALL_TEST(_test_decrypt_empty_binary);
|
947
|
+
INSTALL_TEST(_test_decrypt_per_ctx_credentials);
|
948
|
+
INSTALL_TEST(_test_decrypt_per_ctx_credentials_local);
|
949
|
+
INSTALL_TEST(_test_decrypt_fle2);
|
950
|
+
INSTALL_TEST(_test_explicit_decrypt_fle2_ieev);
|
951
|
+
INSTALL_TEST(_test_decrypt_fle2_iup);
|
952
|
+
INSTALL_TEST(_test_decrypt_wrong_binary_subtype);
|
953
|
+
INSTALL_TEST(_test_decrypt_fle2_irev);
|
954
|
+
INSTALL_TEST(_test_explicit_decrypt_fle2_irev);
|
955
|
+
INSTALL_TEST(_test_explicit_decrypt_fle2_iup_with_edges);
|
1134
956
|
}
|