libmongocrypt-helper 1.7.4.0.1002 → 1.11.0.0.1001
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +40 -5
- data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +29 -24
- data/ext/libmongocrypt/libmongocrypt/CODEOWNERS +1 -4
- data/ext/libmongocrypt/libmongocrypt/Earthfile +522 -0
- data/ext/libmongocrypt/libmongocrypt/README.md +36 -40
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/CMakeLists.txt +1 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Driver.snk +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/AssemblyInfo.cs +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Binary.cs +16 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClient.cs +25 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClientFactory.cs +8 -4
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Library.cs +35 -3
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/LibraryLoader.cs +81 -44
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/MongoDB.Libmongocrypt.csproj +2 -1
- 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/MongoDB.Libmongocrypt.Test/MongoDB.Libmongocrypt.Test.csproj +2 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test32/MongoDB.Libmongocrypt.Test32.csproj +2 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/README.md +3 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.cake +22 -26
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.config +3 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.sh +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/benchmarks/build.gradle.kts +28 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/benchmarks/src/main/java/com/mongodb/crypt/benchmark/BenchmarkRunner.java +217 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/benchmarks/src/main/resources/keyDocument.json +24 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/build.gradle.kts +22 -7
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradle/wrapper/gradle-wrapper.properties +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradlew +154 -108
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradlew.bat +7 -18
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/settings.gradle.kts +1 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CAPI.java +41 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CAPIHelper.java +5 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CipherCallback.java +27 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptImpl.java +34 -19
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoExplicitEncryptOptions.java +6 -4
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/resources/META-INF/native-image/jni-config.json +180 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/resources/META-INF/native-image/reflect-config.json +134 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java +50 -6
- 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/{python/test/data/fle2-find-range-explicit → java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2}/int32/rangeopts.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/README.md +4 -771
- data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +86 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/README.rst +41 -20
- data/ext/libmongocrypt/libmongocrypt/bindings/python/RELEASE.rst +6 -24
- data/ext/libmongocrypt/libmongocrypt/bindings/python/build-manylinux-wheel.sh +4 -13
- data/ext/libmongocrypt/libmongocrypt/bindings/python/hatch_build.py +36 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/libmongocrypt-version.txt +1 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/__init__.py +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/auto_encrypter.py +61 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/credentials.py +156 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/explicit_encrypter.py +156 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/state_machine.py +149 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/auto_encrypter.py +2 -46
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binary.py +14 -17
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +232 -296
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/compat.py +6 -31
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/credentials.py +2 -121
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/crypto.py +31 -20
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/errors.py +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/explicit_encrypter.py +2 -233
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +168 -254
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/options.py +265 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/state_machine.py +2 -141
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/auto_encrypter.py +61 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/credentials.py +156 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/explicit_encrypter.py +156 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/state_machine.py +149 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pyproject.toml +118 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/release.sh +97 -61
- data/ext/libmongocrypt/libmongocrypt/bindings/python/requirements-test.txt +7 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/requirements.txt +4 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/sbom.json +76 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/strip_header.py +6 -7
- data/ext/libmongocrypt/libmongocrypt/bindings/python/synchro.py +64 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/__init__.py +2 -10
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/collection-info.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/command.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/compact/success/encrypted-payload.json +21 -21
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-command-reply.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-field-config-map.json +1 -1
- 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/data/fle2-find-range-explicit-v2/int32/rangeopts.json +14 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document-azure.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document-gcp.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-filter.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/list-collections-filter.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/mongocryptd-command.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/mongocryptd-reply.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/schema-map.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/performance/keyDocument.json +24 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/performance/perf_test.py +165 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_binding.py +8 -12
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_crypto.py +9 -11
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_mongocrypt.py +991 -343
- data/ext/libmongocrypt/libmongocrypt/bindings/python/update-sbom.sh +14 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/FetchMongoC.cmake +19 -1
- data/ext/libmongocrypt/libmongocrypt/cmake/ImportBSON.cmake +31 -6
- data/ext/libmongocrypt/libmongocrypt/cmake/IntelDFP.cmake +20 -227
- data/ext/libmongocrypt/libmongocrypt/cmake/Patch.cmake +54 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/Platform.cmake +50 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/mongocrypt-config.cmake +21 -0
- data/ext/libmongocrypt/libmongocrypt/doc/img/cli-icon.png +0 -0
- data/ext/libmongocrypt/libmongocrypt/doc/img/reference-targets.png +0 -0
- data/ext/libmongocrypt/libmongocrypt/doc/releasing.md +153 -0
- data/ext/libmongocrypt/libmongocrypt/etc/c6-vault.repo +39 -0
- data/ext/libmongocrypt/libmongocrypt/etc/calc_release_version.py +61 -28
- data/ext/libmongocrypt/libmongocrypt/etc/calc_release_version_selftest.sh +73 -0
- data/ext/libmongocrypt/libmongocrypt/etc/cyclonedx.sbom.json +108 -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/libbson-remove-GCC-diagnostic-pragma.patch +27 -0
- data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-alpine-arm-fix.patch +17 -0
- data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-libmongocrypt-pr-625.patch +13 -0
- data/ext/libmongocrypt/libmongocrypt/etc/packager.py +120 -91
- data/ext/libmongocrypt/libmongocrypt/etc/purls.txt +14 -0
- data/ext/libmongocrypt/libmongocrypt/etc/repo_config.yaml +56 -0
- data/ext/libmongocrypt/libmongocrypt/etc/silk-create-asset-group.sh +70 -0
- data/ext/libmongocrypt/libmongocrypt/etc/ssdlc_compliance_report.md +37 -0
- data/ext/libmongocrypt/libmongocrypt/etc/third_party_vulnerabilities.md +42 -0
- data/ext/libmongocrypt/libmongocrypt/integrating.md +18 -1
- data/ext/libmongocrypt/libmongocrypt/kms-message/CMakeLists.txt +11 -3
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_gcp_request.c +1 -1
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_reader_writer.c +17 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_reader_writer_private.h +6 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_request.c +211 -1
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_response.c +163 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_tag_type_private.h +2 -1
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_kmip_request.h +17 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_kmip_response.h +6 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_port.c +3 -2
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request.c +4 -2
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_str.c +2 -2
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kmip_reader_writer.c +23 -2
- 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 +183 -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 +21 -11
- data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +175 -99
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle-blob-subtype-private.h +18 -10
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +69 -70
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +445 -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 +103 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private.h +28 -31
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-v2.c +173 -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 +130 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private.h +36 -44
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-v2.c +382 -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 +454 -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 +56 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +520 -580
- data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +47 -66
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +67 -76
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +201 -190
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +55 -42
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +809 -558
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +177 -201
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +54 -53
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +188 -240
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +43 -35
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +484 -337
- 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 +87 -65
- data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +153 -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 +461 -499
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +256 -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 +1 -9
- 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 +442 -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 +104 -132
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth-private.h +16 -24
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth.c +110 -93
- 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 +1145 -1567
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +510 -476
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +817 -694
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +2775 -2697
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-private.h +189 -184
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-rewrap-many-datakey.c +308 -351
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +990 -1139
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +23 -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 +42 -44
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek.c +292 -272
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker-private.h +70 -110
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +1010 -1033
- 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 +127 -120
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx.c +1692 -1611
- 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 +31 -36
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +1923 -1479
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-mutex-private.h +7 -12
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +124 -107
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +925 -419
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +99 -122
- 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 +98 -136
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +924 -1339
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +199 -313
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +83 -79
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_mutex.c +20 -28
- data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +64 -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/bulkWrite/bypassQueryAnalysis/payload.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/jsonSchema/cmd-to-mongocryptd.json +23 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/jsonSchema/cmd.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/cmd-to-mongocryptd.json +50 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/cmd.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/collinfo.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/encrypted-field-map.json +24 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/encrypted-payload-pattern.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/mongocryptd-reply.json +62 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/cmd-to-mongocryptd.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/cmd.json +17 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/mongocryptd-reply.json +39 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/payload.json +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/missing-key-id/collinfo.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/no-fields/collinfo.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/no-fields/encrypted-payload.json +4 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/cmd.json +1 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/collinfo.json +63 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/encrypted-field-config-map.json +61 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/encrypted-payload-range-v2.json +37 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/encrypted-payload.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/cmd.json +1 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/collinfo.json +64 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/encrypted-payload-range-v2.json +105 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/encrypted-payload.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/cmd.json +1 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/collinfo.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/encrypted-field-config-map.json +47 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/encrypted-payload.json +23 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/collinfo.json +15 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-field-config-map.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-payload-range-v2.json +104 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-payload.json +6 -0
- 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/collinfo.json +4 -4
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/encrypted-payload.json +5 -5
- 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/kms-azure/decrypt-response.txt +16 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/kms-azure/encrypt-response.txt +16 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/kms-azure/oauth-response.txt +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/encrypted-field-map.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/encrypted-payload.json +62 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/mongocryptd-reply.json +69 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/encrypted-field-map.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/encrypted-payload.json +40 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/mongocryptd-reply.json +47 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_decimal128.cstruct +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_double.cstruct +8637 -7958
- data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_int32.cstruct +5522 -1382
- data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_int64.cstruct +5042 -1262
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_decimal128.cstruct +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_decimal128_precision.cstruct +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_double.cstruct +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_double_precision.cstruct +2 -2
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_int32.cstruct +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_int64.cstruct +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/encrypted-field-map.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/encrypted-payload.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/mongocryptd-reply.json +58 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/encrypted-field-map.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/encrypted-payload.json +40 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/mongocryptd-reply.json +45 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32/expected.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32/to-encrypt.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32-defaults/expected.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32-defaults/to-encrypt.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-insert-double/expected.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-insert-int32/expected.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-insert-int32-defaults/expected.json +8 -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 +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/mc.json +25 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/server.json +25 -0
- data/ext/libmongocrypt/libmongocrypt/test/example-no-bson.c +4 -4
- data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +279 -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 +60 -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 +129 -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 +248 -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 +421 -388
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +974 -825
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +499 -481
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +312 -148
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-reader.c +124 -207
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +249 -213
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-writer.c +176 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +632 -808
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.h +22 -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 +118 -37
- 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-cleanup.c +374 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-compact.c +410 -445
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +798 -812
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +142 -135
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.h +70 -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 +870 -1045
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +5183 -4717
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +750 -964
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +1093 -1178
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +348 -420
- 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 +705 -368
- 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 +1073 -690
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-opts.c +42 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-status.c +46 -58
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-traverse-util.c +381 -451
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.c +55 -67
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.h +7 -10
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +879 -918
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +119 -169
- data/ext/libmongocrypt/libmongocrypt/test/test-named-kms-providers.c +2381 -0
- data/ext/libmongocrypt/libmongocrypt/test/util/HELP.autogen +3 -1
- data/ext/libmongocrypt/libmongocrypt/test/util/README.md +1 -0
- data/ext/libmongocrypt/libmongocrypt/test/util/csfle.c +512 -559
- data/ext/libmongocrypt/libmongocrypt/test/util/make_includes.py +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/util/util.c +771 -882
- data/ext/libmongocrypt/libmongocrypt/test/util/util.h +33 -55
- data/lib/libmongocrypt_helper/version.rb +2 -2
- metadata +245 -111
- checksums.yaml.gz.sig +0 -0
- data/ext/libmongocrypt/libmongocrypt/VERSION_CURRENT +0 -1
- 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/CHANGELOG.md +0 -81
- data/ext/libmongocrypt/libmongocrypt/bindings/node/LICENSE +0 -201
- data/ext/libmongocrypt/libmongocrypt/bindings/node/binding.gyp +0 -79
- data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/README.hbs +0 -44
- data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/build-static.sh +0 -39
- data/ext/libmongocrypt/libmongocrypt/bindings/node/index.d.ts +0 -515
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/autoEncrypter.js +0 -420
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/buffer_pool.js +0 -123
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/clientEncryption.js +0 -699
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/common.js +0 -100
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/credentialsProvider.js +0 -33
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/cryptoCallbacks.js +0 -87
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/index.js +0 -42
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/mongocryptdManager.js +0 -66
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/stateMachine.js +0 -487
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package-lock.json +0 -16051
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package.json +0 -81
- data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.cc +0 -929
- data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.h +0 -114
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/autoEncrypter.test.js +0 -953
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/buffer_pool.test.js +0 -91
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/clientEncryption.test.js +0 -701
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/credentialsProvider.test.js +0 -163
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/cryptoCallbacks.test.js +0 -284
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/README.md +0 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/cmd.json +0 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/collection-info.json +0 -37
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encrypted-document-nested.json +0 -8
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encrypted-document.json +0 -11
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encryptedFields.json +0 -30
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/key-document.json +0 -32
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/key1-document.json +0 -30
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/mongocryptd-reply.json +0 -18
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/mongocryptdManager.test.js +0 -48
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/release.test.js +0 -59
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/requirements.helper.js +0 -29
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/stateMachine.test.js +0 -331
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/mongodb_reporter.js +0 -325
- data/ext/libmongocrypt/libmongocrypt/bindings/python/setup.py +0 -84
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test-requirements.txt +0 -12
- data/ext/libmongocrypt/libmongocrypt/debian/build_snapshot.sh +0 -79
- data/ext/libmongocrypt/libmongocrypt/debian/changelog +0 -105
- data/ext/libmongocrypt/libmongocrypt/debian/compat +0 -1
- data/ext/libmongocrypt/libmongocrypt/debian/control +0 -41
- data/ext/libmongocrypt/libmongocrypt/debian/copyright +0 -129
- data/ext/libmongocrypt/libmongocrypt/debian/gbp.conf +0 -23
- data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt-dev.dirs +0 -2
- data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt-dev.install +0 -5
- data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt0.dirs +0 -1
- data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt0.install +0 -1
- data/ext/libmongocrypt/libmongocrypt/debian/rules +0 -46
- data/ext/libmongocrypt/libmongocrypt/debian/source/format +0 -1
- data/ext/libmongocrypt/libmongocrypt/debian/source/lintian-overrides +0 -3
- data/ext/libmongocrypt/libmongocrypt/debian/source/options +0 -1
- data/ext/libmongocrypt/libmongocrypt/debian/watch +0 -3
- data/ext/libmongocrypt/libmongocrypt/test/data/aes-ctr.cstructs +0 -359
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/mongocryptd-reply.json +0 -72
- 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-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.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
- /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/value-to-encrypt.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
- /data/ext/libmongocrypt/libmongocrypt/bindings/{java/mongocrypt/src/test/resources/fle2-find-range-explicit → python/test/data/fle2-find-rangePreview-explicit}/int32/rangeopts.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/{test/data/fle2-find-range-explicit/int32-nominmax → bindings/python/test/data/fle2-find-rangePreview-explicit/int32}/value-to-encrypt.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/{bindings/node/test/data/kms-decrypt-reply.txt → test/data/kms-aws/decrypt-response.txt} +0 -0
- /data/ext/libmongocrypt/libmongocrypt/{bindings/node/test/data/kms-encrypt-reply.txt → test/data/kms-aws/encrypt-response.txt} +0 -0
- /data/ext/libmongocrypt/libmongocrypt/test/data/{gcp-auth → kms-gcp}/decrypt-response.txt +0 -0
- /data/ext/libmongocrypt/libmongocrypt/test/data/{gcp-auth → kms-gcp}/encrypt-response.txt +0 -0
- /data/ext/libmongocrypt/libmongocrypt/test/data/{gcp-auth → kms-gcp}/oauth-response.txt +0 -0
@@ -15,903 +15,889 @@
|
|
15
15
|
*/
|
16
16
|
|
17
17
|
#include "mongocrypt-config.h"
|
18
|
-
#include "mongocrypt-private.h"
|
19
18
|
#include "mongocrypt-crypto-private.h"
|
19
|
+
#include "mongocrypt-private.h"
|
20
|
+
#include "test-mongocrypt-crypto-std-hooks.h"
|
20
21
|
|
21
22
|
#include "test-mongocrypt.h"
|
22
23
|
|
23
24
|
#define IV_HEX "1F572A1B84EC8F99B7915AA2A2AEA2F4"
|
24
|
-
#define HMAC_HEX
|
25
|
-
|
26
|
-
|
25
|
+
#define HMAC_HEX \
|
26
|
+
"60676DE9FD305FD2C0815763C422687270DA2416D94A917B276E9DCBB13F412F" \
|
27
|
+
"92FA403AA8AE172BD2E4729ED352793795EE588A2977C9C1F218D2AAD779C997"
|
27
28
|
/* only the first 32 bytes are appended. */
|
28
|
-
#define HMAC_HEX_TAG
|
29
|
-
|
30
|
-
|
31
|
-
#define
|
32
|
-
|
33
|
-
#define ENCRYPTION_KEY_HEX \
|
34
|
-
"E1D1727BAF970E01181C0868CB9D3E574B47AC09771FF30FE2D093B0950C7DAF"
|
35
|
-
#define IV_KEY_HEX \
|
36
|
-
"0A9328FCB6405ABDF5B4BFEC243FE9CF503CD4F24360872B75F08A2A3961802B"
|
29
|
+
#define HMAC_HEX_TAG "60676DE9FD305FD2C0815763C422687270DA2416D94A917B276E9DCBB13F412F"
|
30
|
+
|
31
|
+
#define HMAC_KEY_HEX "CCD3836C8F24AC5FAAFAAA630C5C6C5D210FD03934EA1440CD67E0DCDE3F8EA6"
|
32
|
+
#define ENCRYPTION_KEY_HEX "E1D1727BAF970E01181C0868CB9D3E574B47AC09771FF30FE2D093B0950C7DAF"
|
33
|
+
#define IV_KEY_HEX "0A9328FCB6405ABDF5B4BFEC243FE9CF503CD4F24360872B75F08A2A3961802B"
|
37
34
|
/* full 96 byte key consists of three "sub" keys */
|
38
35
|
#define KEY_HEX HMAC_KEY_HEX ENCRYPTION_KEY_HEX IV_KEY_HEX
|
39
|
-
#define HASH_HEX
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
"CC0B95D217493205A038C50F537F452C59EFF6541D0026"
|
36
|
+
#define HASH_HEX "489EC3238378DC624C74B8CC4598ACED2B7EA5DE5C5F7602D8761BAE92FD8ABE"
|
37
|
+
#define RANDOM_HEX \
|
38
|
+
"670ACBB44D4E04A279CC0B95D217493205A038C50F537F452C59EFF6541D0026670ACBB44" \
|
39
|
+
"D4E04A279CC0B95D217493205A038C50F537F452C59EFF6541D0026670ACBB44D4E04A279" \
|
40
|
+
"CC0B95D217493205A038C50F537F452C59EFF6541D0026"
|
45
41
|
|
46
42
|
/* a document containing the history of calls */
|
47
43
|
static bson_string_t *call_history;
|
48
44
|
|
49
|
-
static void
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
{
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
}
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
bool
|
225
|
-
_sign_rsaes_pkcs1_v1_5 (void *ctx,
|
226
|
-
mongocrypt_binary_t *key,
|
227
|
-
mongocrypt_binary_t *in,
|
228
|
-
mongocrypt_binary_t *out,
|
229
|
-
mongocrypt_status_t *status)
|
230
|
-
{
|
231
|
-
_mongocrypt_buffer_t tmp;
|
232
|
-
|
233
|
-
BSON_ASSERT (0 == strncmp ("error_on:", (char *) ctx, strlen ("error_on:")));
|
234
|
-
bson_string_append_printf (call_history, "call:%s\n", BSON_FUNC);
|
235
|
-
_append_bin ("key", key);
|
236
|
-
_append_bin ("in", in);
|
237
|
-
|
238
|
-
bson_string_append_printf (call_history, "ret:%s\n", BSON_FUNC);
|
239
|
-
memset (out->data, 0, out->len);
|
240
|
-
|
241
|
-
_mongocrypt_buffer_copy_from_hex (&tmp, HASH_HEX);
|
242
|
-
memcpy (out->data, tmp.data, tmp.len);
|
243
|
-
_mongocrypt_buffer_cleanup (&tmp);
|
244
|
-
if (0 == strcmp ((char *) ctx, "error_on:sign_rsaes_pkcs1_v1_5")) {
|
245
|
-
mongocrypt_status_set (
|
246
|
-
status, MONGOCRYPT_STATUS_ERROR_CLIENT, 1, (char *) ctx, -1);
|
247
|
-
return false;
|
248
|
-
}
|
249
|
-
return true;
|
45
|
+
static void _append_bin(const char *name, mongocrypt_binary_t *bin) {
|
46
|
+
_mongocrypt_buffer_t tmp;
|
47
|
+
char *hex;
|
48
|
+
|
49
|
+
_mongocrypt_buffer_from_binary(&tmp, bin);
|
50
|
+
hex = _mongocrypt_buffer_to_hex(&tmp);
|
51
|
+
bson_string_append_printf(call_history, "%s:%s\n", name, hex);
|
52
|
+
bson_free(hex);
|
53
|
+
_mongocrypt_buffer_cleanup(&tmp);
|
54
|
+
}
|
55
|
+
|
56
|
+
static bool _mock_aes_256_xxx_encrypt(void *ctx,
|
57
|
+
mongocrypt_binary_t *key,
|
58
|
+
mongocrypt_binary_t *iv,
|
59
|
+
mongocrypt_binary_t *in,
|
60
|
+
mongocrypt_binary_t *out,
|
61
|
+
uint32_t *bytes_written,
|
62
|
+
mongocrypt_status_t *status) {
|
63
|
+
BSON_ASSERT(0 == strncmp("error_on:", (char *)ctx, strlen("error_on:")));
|
64
|
+
bson_string_append_printf(call_history, "call:%s\n", BSON_FUNC);
|
65
|
+
_append_bin("key", key);
|
66
|
+
if (NULL != iv) {
|
67
|
+
_append_bin("iv", iv);
|
68
|
+
}
|
69
|
+
_append_bin("in", in);
|
70
|
+
/* append it directly, don't encrypt. */
|
71
|
+
uint8_t *out_u8 = out->data;
|
72
|
+
memcpy(out_u8 + *bytes_written, in->data, in->len);
|
73
|
+
*bytes_written += in->len;
|
74
|
+
bson_string_append_printf(call_history, "ret:%s\n", BSON_FUNC);
|
75
|
+
if (0 == strcmp((char *)ctx, "error_on:aes_256_cbc_encrypt")
|
76
|
+
|| 0 == strcmp((char *)ctx, "error_on:aes_256_ctr_encrypt")
|
77
|
+
|| 0 == strcmp((char *)ctx, "error_on:aes_256_ecb_encrypt")) {
|
78
|
+
mongocrypt_status_set(status, MONGOCRYPT_STATUS_ERROR_CLIENT, 1, (char *)ctx, -1);
|
79
|
+
return false;
|
80
|
+
}
|
81
|
+
return true;
|
82
|
+
}
|
83
|
+
|
84
|
+
static bool _mock_aes_256_xxx_decrypt(void *ctx,
|
85
|
+
mongocrypt_binary_t *key,
|
86
|
+
mongocrypt_binary_t *iv,
|
87
|
+
mongocrypt_binary_t *in,
|
88
|
+
mongocrypt_binary_t *out,
|
89
|
+
uint32_t *bytes_written,
|
90
|
+
mongocrypt_status_t *status) {
|
91
|
+
BSON_ASSERT(0 == strncmp("error_on:", (char *)ctx, strlen("error_on:")));
|
92
|
+
bson_string_append_printf(call_history, "call:%s\n", BSON_FUNC);
|
93
|
+
_append_bin("key", key);
|
94
|
+
_append_bin("iv", iv);
|
95
|
+
_append_bin("in", in);
|
96
|
+
/* append it directly, don't decrypt. */
|
97
|
+
uint8_t *out_u8 = out->data;
|
98
|
+
memcpy(out_u8 + *bytes_written, in->data, in->len);
|
99
|
+
*bytes_written += in->len;
|
100
|
+
bson_string_append_printf(call_history, "ret:%s\n", BSON_FUNC);
|
101
|
+
if (0 == strcmp((char *)ctx, "error_on:aes_256_cbc_decrypt")
|
102
|
+
|| 0 == strcmp((char *)ctx, "error_on:aes_256_ctr_decrypt")) {
|
103
|
+
mongocrypt_status_set(status, MONGOCRYPT_STATUS_ERROR_CLIENT, 1, (char *)ctx, -1);
|
104
|
+
return false;
|
105
|
+
}
|
106
|
+
return true;
|
107
|
+
}
|
108
|
+
|
109
|
+
bool _hmac_sha_512(void *ctx,
|
110
|
+
mongocrypt_binary_t *key,
|
111
|
+
mongocrypt_binary_t *in,
|
112
|
+
mongocrypt_binary_t *out,
|
113
|
+
mongocrypt_status_t *status) {
|
114
|
+
_mongocrypt_buffer_t tmp;
|
115
|
+
|
116
|
+
BSON_ASSERT(0 == strncmp("error_on:", (char *)ctx, strlen("error_on:")));
|
117
|
+
bson_string_append_printf(call_history, "call:%s\n", BSON_FUNC);
|
118
|
+
_append_bin("key", key);
|
119
|
+
_append_bin("in", in);
|
120
|
+
|
121
|
+
bson_string_append_printf(call_history, "ret:%s\n", BSON_FUNC);
|
122
|
+
|
123
|
+
_mongocrypt_buffer_copy_from_hex(&tmp, HMAC_HEX);
|
124
|
+
memcpy(out->data, tmp.data, tmp.len);
|
125
|
+
_mongocrypt_buffer_cleanup(&tmp);
|
126
|
+
if (0 == strcmp((char *)ctx, "error_on:hmac_sha512")) {
|
127
|
+
mongocrypt_status_set(status, MONGOCRYPT_STATUS_ERROR_CLIENT, 1, (char *)ctx, -1);
|
128
|
+
return false;
|
129
|
+
}
|
130
|
+
return true;
|
131
|
+
}
|
132
|
+
|
133
|
+
bool _hmac_sha_256(void *ctx,
|
134
|
+
mongocrypt_binary_t *key,
|
135
|
+
mongocrypt_binary_t *in,
|
136
|
+
mongocrypt_binary_t *out,
|
137
|
+
mongocrypt_status_t *status) {
|
138
|
+
_mongocrypt_buffer_t tmp;
|
139
|
+
|
140
|
+
BSON_ASSERT(0 == strncmp("error_on:", (char *)ctx, strlen("error_on:")));
|
141
|
+
bson_string_append_printf(call_history, "call:%s\n", BSON_FUNC);
|
142
|
+
_append_bin("key", key);
|
143
|
+
_append_bin("in", in);
|
144
|
+
|
145
|
+
bson_string_append_printf(call_history, "ret:%s\n", BSON_FUNC);
|
146
|
+
|
147
|
+
_mongocrypt_buffer_copy_from_hex(&tmp, HASH_HEX);
|
148
|
+
memcpy(out->data, tmp.data, tmp.len);
|
149
|
+
_mongocrypt_buffer_cleanup(&tmp);
|
150
|
+
if (0 == strcmp((char *)ctx, "error_on:hmac_sha256")) {
|
151
|
+
mongocrypt_status_set(status, MONGOCRYPT_STATUS_ERROR_CLIENT, 1, (char *)ctx, -1);
|
152
|
+
return false;
|
153
|
+
}
|
154
|
+
return true;
|
155
|
+
}
|
156
|
+
|
157
|
+
bool _sha_256(void *ctx, mongocrypt_binary_t *in, mongocrypt_binary_t *out, mongocrypt_status_t *status) {
|
158
|
+
_mongocrypt_buffer_t tmp;
|
159
|
+
|
160
|
+
BSON_ASSERT(0 == strncmp("error_on:", (char *)ctx, strlen("error_on:")));
|
161
|
+
bson_string_append_printf(call_history, "call:%s\n", BSON_FUNC);
|
162
|
+
_append_bin("in", in);
|
163
|
+
|
164
|
+
bson_string_append_printf(call_history, "ret:%s\n", BSON_FUNC);
|
165
|
+
|
166
|
+
_mongocrypt_buffer_copy_from_hex(&tmp, HASH_HEX);
|
167
|
+
memcpy(out->data, tmp.data, tmp.len);
|
168
|
+
_mongocrypt_buffer_cleanup(&tmp);
|
169
|
+
if (0 == strcmp((char *)ctx, "error_on:sha256")) {
|
170
|
+
mongocrypt_status_set(status, MONGOCRYPT_STATUS_ERROR_CLIENT, 1, (char *)ctx, -1);
|
171
|
+
return false;
|
172
|
+
}
|
173
|
+
return true;
|
174
|
+
}
|
175
|
+
|
176
|
+
bool _random(void *ctx, mongocrypt_binary_t *out, uint32_t count, mongocrypt_status_t *status) {
|
177
|
+
/* only have 32 bytes of random test data. */
|
178
|
+
BSON_ASSERT(count <= 96);
|
179
|
+
|
180
|
+
BSON_ASSERT(0 == strncmp("error_on:", (char *)ctx, strlen("error_on:")));
|
181
|
+
bson_string_append_printf(call_history, "call:%s\n", BSON_FUNC);
|
182
|
+
bson_string_append_printf(call_history, "count:%d\n", (int)count);
|
183
|
+
bson_string_append_printf(call_history, "ret:%s\n", BSON_FUNC);
|
184
|
+
|
185
|
+
_mongocrypt_buffer_t tmp;
|
186
|
+
_mongocrypt_buffer_copy_from_hex(&tmp, RANDOM_HEX);
|
187
|
+
memcpy(out->data, tmp.data, count);
|
188
|
+
_mongocrypt_buffer_cleanup(&tmp);
|
189
|
+
if (0 == strcmp((char *)ctx, "error_on:random")) {
|
190
|
+
mongocrypt_status_set(status, MONGOCRYPT_STATUS_ERROR_CLIENT, 1, (char *)ctx, -1);
|
191
|
+
return false;
|
192
|
+
}
|
193
|
+
return true;
|
194
|
+
}
|
195
|
+
|
196
|
+
bool _sign_rsaes_pkcs1_v1_5(void *ctx,
|
197
|
+
mongocrypt_binary_t *key,
|
198
|
+
mongocrypt_binary_t *in,
|
199
|
+
mongocrypt_binary_t *out,
|
200
|
+
mongocrypt_status_t *status) {
|
201
|
+
_mongocrypt_buffer_t tmp;
|
202
|
+
|
203
|
+
BSON_ASSERT(0 == strncmp("error_on:", (char *)ctx, strlen("error_on:")));
|
204
|
+
bson_string_append_printf(call_history, "call:%s\n", BSON_FUNC);
|
205
|
+
_append_bin("key", key);
|
206
|
+
_append_bin("in", in);
|
207
|
+
|
208
|
+
bson_string_append_printf(call_history, "ret:%s\n", BSON_FUNC);
|
209
|
+
memset(out->data, 0, out->len);
|
210
|
+
|
211
|
+
_mongocrypt_buffer_copy_from_hex(&tmp, HASH_HEX);
|
212
|
+
memcpy(out->data, tmp.data, tmp.len);
|
213
|
+
_mongocrypt_buffer_cleanup(&tmp);
|
214
|
+
if (0 == strcmp((char *)ctx, "error_on:sign_rsaes_pkcs1_v1_5")) {
|
215
|
+
mongocrypt_status_set(status, MONGOCRYPT_STATUS_ERROR_CLIENT, 1, (char *)ctx, -1);
|
216
|
+
return false;
|
217
|
+
}
|
218
|
+
return true;
|
250
219
|
}
|
251
220
|
|
252
221
|
static mongocrypt_t *
|
253
|
-
_create_mongocrypt_and_hooks
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
ASSERT_OK (
|
262
|
-
mongocrypt_setopt_kms_provider_aws (crypt, "example", -1, "example", -1),
|
263
|
-
crypt);
|
264
|
-
ASSERT_OK (
|
265
|
-
mongocrypt_setopt_kms_providers (
|
266
|
-
crypt,
|
267
|
-
TEST_BSON ("{'gcp': { 'email': 'test', 'privateKey': 'AAAA'}}")),
|
268
|
-
crypt);
|
269
|
-
ret = mongocrypt_setopt_crypto_hooks (crypt,
|
222
|
+
_create_mongocrypt_and_hooks(_mongocrypt_tester_t *tester, const char *error_on, bool ctr_hook, bool ecb_hook) {
|
223
|
+
bool ret;
|
224
|
+
|
225
|
+
mongocrypt_t *crypt = mongocrypt_new();
|
226
|
+
ASSERT_OK(mongocrypt_setopt_kms_provider_aws(crypt, "example", -1, "example", -1), crypt);
|
227
|
+
ASSERT_OK(mongocrypt_setopt_kms_providers(crypt, TEST_BSON("{'gcp': { 'email': 'test', 'privateKey': 'AAAA'}}")),
|
228
|
+
crypt);
|
229
|
+
ret = mongocrypt_setopt_crypto_hooks(crypt,
|
270
230
|
_mock_aes_256_xxx_encrypt,
|
271
231
|
_mock_aes_256_xxx_decrypt,
|
272
232
|
_random,
|
273
233
|
_hmac_sha_512,
|
274
234
|
_hmac_sha_256,
|
275
235
|
_sha_256,
|
276
|
-
(void *)
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
ASSERT_OK (mongocrypt_init (crypt), crypt);
|
294
|
-
return crypt;
|
236
|
+
(void *)error_on);
|
237
|
+
ASSERT_OK(ret, crypt);
|
238
|
+
ret = mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs1_v1_5(crypt, _sign_rsaes_pkcs1_v1_5, (void *)error_on);
|
239
|
+
ASSERT_OK(ret, crypt);
|
240
|
+
if (ctr_hook) {
|
241
|
+
ret = mongocrypt_setopt_aes_256_ctr(crypt,
|
242
|
+
_mock_aes_256_xxx_encrypt,
|
243
|
+
_mock_aes_256_xxx_decrypt,
|
244
|
+
(void *)error_on);
|
245
|
+
ASSERT_OK(ret, crypt);
|
246
|
+
}
|
247
|
+
if (ecb_hook) {
|
248
|
+
ret = mongocrypt_setopt_aes_256_ecb(crypt, _mock_aes_256_xxx_encrypt, (void *)error_on);
|
249
|
+
ASSERT_OK(ret, crypt);
|
250
|
+
}
|
251
|
+
ASSERT_OK(_mongocrypt_init_for_test(crypt), crypt);
|
252
|
+
return crypt;
|
295
253
|
}
|
296
254
|
|
297
|
-
static mongocrypt_t *
|
298
|
-
|
299
|
-
{
|
300
|
-
return _create_mongocrypt_and_hooks (tester, error_on, false, false);
|
255
|
+
static mongocrypt_t *_create_mongocrypt(_mongocrypt_tester_t *tester, const char *error_on) {
|
256
|
+
return _create_mongocrypt_and_hooks(tester, error_on, false, false);
|
301
257
|
}
|
302
258
|
|
303
259
|
static void
|
304
|
-
_test_crypto_hooks_encryption_helper
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
} else {
|
380
|
-
ASSERT_FAILS_STATUS (ret, status, error_on);
|
381
|
-
}
|
382
|
-
|
383
|
-
|
384
|
-
_mongocrypt_buffer_cleanup (&key);
|
385
|
-
_mongocrypt_buffer_cleanup (&iv);
|
386
|
-
_mongocrypt_buffer_cleanup (&associated_data);
|
387
|
-
_mongocrypt_buffer_cleanup (&plaintext);
|
388
|
-
_mongocrypt_buffer_cleanup (&ciphertext);
|
389
|
-
mongocrypt_status_destroy (status);
|
390
|
-
mongocrypt_destroy (crypt);
|
391
|
-
bson_string_free (call_history, true);
|
260
|
+
_test_crypto_hooks_encryption_helper(_mongocrypt_tester_t *tester, const char *error_on, bool ctr_hook, bool ecb_hook) {
|
261
|
+
mongocrypt_t *crypt;
|
262
|
+
bool ret;
|
263
|
+
uint32_t bytes_written;
|
264
|
+
mongocrypt_status_t *status;
|
265
|
+
_mongocrypt_buffer_t iv, associated_data, key, plaintext, ciphertext;
|
266
|
+
const char *expected_call_history = "call:_mock_aes_256_xxx_encrypt\n"
|
267
|
+
"key:" ENCRYPTION_KEY_HEX "\n"
|
268
|
+
"iv:" IV_HEX "\n"
|
269
|
+
"in:BBBB0E0E0E0E0E0E0E0E0E0E0E0E0E0E\n"
|
270
|
+
"ret:_mock_aes_256_xxx_encrypt\n"
|
271
|
+
"call:_hmac_sha_512\n"
|
272
|
+
"key:CCD3836C8F24AC5FAAFAAA630C5C6C5D210FD03934EA1440CD67E0DCDE3F8EA6\n"
|
273
|
+
"in:AAAA" IV_HEX "BBBB0E0E0E0E0E0E0E0E0E0E0E0E0E0E0000000000000010\n"
|
274
|
+
"ret:_hmac_sha_512\n";
|
275
|
+
|
276
|
+
status = mongocrypt_status_new();
|
277
|
+
crypt = _create_mongocrypt_and_hooks(tester, error_on, ctr_hook, ecb_hook);
|
278
|
+
|
279
|
+
_mongocrypt_buffer_copy_from_hex(&iv, IV_HEX);
|
280
|
+
_mongocrypt_buffer_copy_from_hex(&associated_data, "AAAA");
|
281
|
+
_mongocrypt_buffer_copy_from_hex(&plaintext, "BBBB");
|
282
|
+
|
283
|
+
call_history = bson_string_new(NULL);
|
284
|
+
|
285
|
+
if (ctr_hook || ecb_hook) {
|
286
|
+
const _mongocrypt_value_encryption_algorithm_t *fle2alg = _mcFLE2Algorithm();
|
287
|
+
_mongocrypt_buffer_copy_from_hex(&key, ENCRYPTION_KEY_HEX);
|
288
|
+
_mongocrypt_buffer_init(&ciphertext);
|
289
|
+
_mongocrypt_buffer_resize(&ciphertext, fle2alg->get_ciphertext_len(plaintext.len, status));
|
290
|
+
ret =
|
291
|
+
fle2alg
|
292
|
+
->do_encrypt(crypt->crypto, &iv, NULL /* aad */, &key, &plaintext, &ciphertext, &bytes_written, status);
|
293
|
+
} else {
|
294
|
+
const _mongocrypt_value_encryption_algorithm_t *fle1alg = _mcFLE1Algorithm();
|
295
|
+
_mongocrypt_buffer_copy_from_hex(&key, KEY_HEX);
|
296
|
+
_mongocrypt_buffer_init(&ciphertext);
|
297
|
+
_mongocrypt_buffer_resize(&ciphertext, fle1alg->get_ciphertext_len(plaintext.len, status));
|
298
|
+
ret = fle1alg->do_encrypt(crypt->crypto,
|
299
|
+
&iv,
|
300
|
+
&associated_data,
|
301
|
+
&key,
|
302
|
+
&plaintext,
|
303
|
+
&ciphertext,
|
304
|
+
&bytes_written,
|
305
|
+
status);
|
306
|
+
}
|
307
|
+
|
308
|
+
if (0 == strcmp(error_on, "error_on:none")) {
|
309
|
+
ASSERT_OK_STATUS(ret, status);
|
310
|
+
ciphertext.len = bytes_written;
|
311
|
+
|
312
|
+
/* Check the full trace. */
|
313
|
+
ASSERT_STREQUAL(call_history->str, expected_call_history);
|
314
|
+
|
315
|
+
/* Check the structure of the ciphertext */
|
316
|
+
BSON_ASSERT(0
|
317
|
+
== _mongocrypt_buffer_cmp_hex(&ciphertext,
|
318
|
+
IV_HEX "BBBB0E0E0E0E0E0E0E0E0E0E0E0E0E0E" /* the "encrypted"
|
319
|
+
block which is
|
320
|
+
really plaintext.
|
321
|
+
BBBB + padding. */
|
322
|
+
HMAC_HEX_TAG));
|
323
|
+
} else {
|
324
|
+
ASSERT_FAILS_STATUS(ret, status, error_on);
|
325
|
+
}
|
326
|
+
|
327
|
+
_mongocrypt_buffer_cleanup(&key);
|
328
|
+
_mongocrypt_buffer_cleanup(&iv);
|
329
|
+
_mongocrypt_buffer_cleanup(&associated_data);
|
330
|
+
_mongocrypt_buffer_cleanup(&plaintext);
|
331
|
+
_mongocrypt_buffer_cleanup(&ciphertext);
|
332
|
+
mongocrypt_status_destroy(status);
|
333
|
+
mongocrypt_destroy(crypt);
|
334
|
+
bson_string_free(call_history, true);
|
392
335
|
}
|
393
336
|
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
tester, "error_on:aes_256_cbc_encrypt", false, false);
|
401
|
-
_test_crypto_hooks_encryption_helper (
|
402
|
-
tester, "error_on:aes_256_ctr_encrypt", true, false);
|
403
|
-
_test_crypto_hooks_encryption_helper (
|
404
|
-
tester, "error_on:aes_256_ecb_encrypt", false, true);
|
405
|
-
_test_crypto_hooks_encryption_helper (
|
406
|
-
tester, "error_on:hmac_sha512", false, false);
|
337
|
+
static void _test_crypto_hooks_encryption(_mongocrypt_tester_t *tester) {
|
338
|
+
_test_crypto_hooks_encryption_helper(tester, "error_on:none", false, false);
|
339
|
+
_test_crypto_hooks_encryption_helper(tester, "error_on:aes_256_cbc_encrypt", false, false);
|
340
|
+
_test_crypto_hooks_encryption_helper(tester, "error_on:aes_256_ctr_encrypt", true, false);
|
341
|
+
_test_crypto_hooks_encryption_helper(tester, "error_on:aes_256_ecb_encrypt", false, true);
|
342
|
+
_test_crypto_hooks_encryption_helper(tester, "error_on:hmac_sha512", false, false);
|
407
343
|
}
|
408
344
|
|
409
|
-
|
410
345
|
static void
|
411
|
-
_test_crypto_hooks_decryption_helper
|
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
|
-
/* Check the resulting plaintext */
|
474
|
-
BSON_ASSERT (0 == _mongocrypt_buffer_cmp_hex (&plaintext, "BBBB"));
|
475
|
-
} else {
|
476
|
-
ASSERT_FAILS_STATUS (ret, status, error_on);
|
477
|
-
}
|
478
|
-
|
479
|
-
_mongocrypt_buffer_cleanup (&key);
|
480
|
-
_mongocrypt_buffer_cleanup (&associated_data);
|
481
|
-
_mongocrypt_buffer_cleanup (&plaintext);
|
482
|
-
_mongocrypt_buffer_cleanup (&ciphertext);
|
483
|
-
mongocrypt_status_destroy (status);
|
484
|
-
mongocrypt_destroy (crypt);
|
485
|
-
bson_string_free (call_history, true);
|
346
|
+
_test_crypto_hooks_decryption_helper(_mongocrypt_tester_t *tester, const char *error_on, bool ctr_hook, bool ecb_hook) {
|
347
|
+
mongocrypt_t *crypt;
|
348
|
+
bool ret;
|
349
|
+
uint32_t bytes_written;
|
350
|
+
mongocrypt_status_t *status;
|
351
|
+
_mongocrypt_buffer_t associated_data, key, plaintext, ciphertext;
|
352
|
+
const char *expected_call_history = "call:_hmac_sha_512\n"
|
353
|
+
"key:" HMAC_KEY_HEX "\n"
|
354
|
+
"in:AAAA" IV_HEX "BBBB0E0E0E0E0E0E0E0E0E0E0E0E0E0E0000000000000010\n"
|
355
|
+
"ret:_hmac_sha_512\n"
|
356
|
+
"call:_mock_aes_256_xxx_decrypt\n"
|
357
|
+
"key:" ENCRYPTION_KEY_HEX "\n"
|
358
|
+
"iv:" IV_HEX "\n"
|
359
|
+
"in:BBBB0E0E0E0E0E0E0E0E0E0E0E0E0E0E\n"
|
360
|
+
"ret:_mock_aes_256_xxx_decrypt\n";
|
361
|
+
|
362
|
+
status = mongocrypt_status_new();
|
363
|
+
crypt = _create_mongocrypt_and_hooks(tester, error_on, ctr_hook, ecb_hook);
|
364
|
+
|
365
|
+
_mongocrypt_buffer_copy_from_hex(&associated_data, "AAAA");
|
366
|
+
_mongocrypt_buffer_copy_from_hex(&ciphertext, IV_HEX "BBBB0E0E0E0E0E0E0E0E0E0E0E0E0E0E" HMAC_HEX_TAG);
|
367
|
+
|
368
|
+
call_history = bson_string_new(NULL);
|
369
|
+
|
370
|
+
if (ctr_hook || ecb_hook) {
|
371
|
+
const _mongocrypt_value_encryption_algorithm_t *fle2alg = _mcFLE2Algorithm();
|
372
|
+
_mongocrypt_buffer_copy_from_hex(&key, ENCRYPTION_KEY_HEX);
|
373
|
+
_mongocrypt_buffer_init(&plaintext);
|
374
|
+
_mongocrypt_buffer_resize(&plaintext, fle2alg->get_plaintext_len(ciphertext.len, status));
|
375
|
+
|
376
|
+
ret = fle2alg->do_decrypt(crypt->crypto, NULL /* aad */, &key, &ciphertext, &plaintext, &bytes_written, status);
|
377
|
+
} else {
|
378
|
+
const _mongocrypt_value_encryption_algorithm_t *fle1alg = _mcFLE1Algorithm();
|
379
|
+
_mongocrypt_buffer_copy_from_hex(&key, KEY_HEX);
|
380
|
+
_mongocrypt_buffer_init(&plaintext);
|
381
|
+
_mongocrypt_buffer_resize(&plaintext, fle1alg->get_plaintext_len(ciphertext.len, status));
|
382
|
+
|
383
|
+
ret =
|
384
|
+
fle1alg->do_decrypt(crypt->crypto, &associated_data, &key, &ciphertext, &plaintext, &bytes_written, status);
|
385
|
+
}
|
386
|
+
|
387
|
+
if (0 == strcmp(error_on, "error_on:none")) {
|
388
|
+
ASSERT_OK_STATUS(ret, status);
|
389
|
+
plaintext.len = bytes_written;
|
390
|
+
|
391
|
+
/* Check the full trace. */
|
392
|
+
ASSERT_STREQUAL(call_history->str, expected_call_history);
|
393
|
+
|
394
|
+
/* Check the resulting plaintext */
|
395
|
+
BSON_ASSERT(0 == _mongocrypt_buffer_cmp_hex(&plaintext, "BBBB"));
|
396
|
+
} else {
|
397
|
+
ASSERT_FAILS_STATUS(ret, status, error_on);
|
398
|
+
}
|
399
|
+
|
400
|
+
_mongocrypt_buffer_cleanup(&key);
|
401
|
+
_mongocrypt_buffer_cleanup(&associated_data);
|
402
|
+
_mongocrypt_buffer_cleanup(&plaintext);
|
403
|
+
_mongocrypt_buffer_cleanup(&ciphertext);
|
404
|
+
mongocrypt_status_destroy(status);
|
405
|
+
mongocrypt_destroy(crypt);
|
406
|
+
bson_string_free(call_history, true);
|
486
407
|
}
|
487
408
|
|
488
|
-
static void
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
_test_crypto_hooks_decryption_helper (
|
495
|
-
tester, "error_on:aes_256_ctr_decrypt", true, false);
|
496
|
-
_test_crypto_hooks_decryption_helper (
|
497
|
-
tester, "error_on:aes_256_ecb_encrypt", false, true);
|
498
|
-
_test_crypto_hooks_decryption_helper (
|
499
|
-
tester, "error_on:hmac_sha512", false, false);
|
409
|
+
static void _test_crypto_hooks_decryption(_mongocrypt_tester_t *tester) {
|
410
|
+
_test_crypto_hooks_decryption_helper(tester, "error_on:none", false, false);
|
411
|
+
_test_crypto_hooks_decryption_helper(tester, "error_on:aes_256_cbc_decrypt", false, false);
|
412
|
+
_test_crypto_hooks_decryption_helper(tester, "error_on:aes_256_ctr_decrypt", true, false);
|
413
|
+
_test_crypto_hooks_decryption_helper(tester, "error_on:aes_256_ecb_encrypt", false, true);
|
414
|
+
_test_crypto_hooks_decryption_helper(tester, "error_on:hmac_sha512", false, false);
|
500
415
|
}
|
501
416
|
|
502
|
-
static void
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
_mongocrypt_buffer_cleanup (&iv);
|
548
|
-
mongocrypt_status_destroy (status);
|
549
|
-
mongocrypt_destroy (crypt);
|
550
|
-
bson_string_free (call_history, true);
|
417
|
+
static void _test_crypto_hooks_iv_gen_helper(_mongocrypt_tester_t *tester, char *error_on) {
|
418
|
+
mongocrypt_t *crypt;
|
419
|
+
bool ret;
|
420
|
+
mongocrypt_status_t *status;
|
421
|
+
_mongocrypt_buffer_t associated_data, key, plaintext, iv;
|
422
|
+
char *expected_iv = bson_strndup(HMAC_HEX_TAG, 16 * 2); /* only the first 16 bytes are used for IV. */
|
423
|
+
const char *expected_call_history = "call:_hmac_sha_512\n"
|
424
|
+
"key:" IV_KEY_HEX "\n"
|
425
|
+
"in:AAAA0000000000000010BBBB\n"
|
426
|
+
"ret:_hmac_sha_512\n";
|
427
|
+
|
428
|
+
status = mongocrypt_status_new();
|
429
|
+
crypt = _create_mongocrypt(tester, error_on);
|
430
|
+
|
431
|
+
_mongocrypt_buffer_copy_from_hex(&associated_data, "AAAA");
|
432
|
+
_mongocrypt_buffer_copy_from_hex(&key, KEY_HEX);
|
433
|
+
_mongocrypt_buffer_copy_from_hex(&plaintext, "BBBB");
|
434
|
+
|
435
|
+
_mongocrypt_buffer_init(&iv);
|
436
|
+
_mongocrypt_buffer_resize(&iv, MONGOCRYPT_IV_LEN);
|
437
|
+
|
438
|
+
call_history = bson_string_new(NULL);
|
439
|
+
|
440
|
+
ret = _mongocrypt_calculate_deterministic_iv(crypt->crypto, &key, &plaintext, &associated_data, &iv, status);
|
441
|
+
|
442
|
+
if (0 == strcmp(error_on, "error_on:none")) {
|
443
|
+
ASSERT_OK_STATUS(ret, status);
|
444
|
+
|
445
|
+
/* Check the full trace. */
|
446
|
+
ASSERT_STREQUAL(call_history->str, expected_call_history);
|
447
|
+
|
448
|
+
/* Check the resulting iv */
|
449
|
+
BSON_ASSERT(0 == _mongocrypt_buffer_cmp_hex(&iv, expected_iv));
|
450
|
+
} else {
|
451
|
+
ASSERT_FAILS_STATUS(ret, status, error_on);
|
452
|
+
}
|
453
|
+
|
454
|
+
bson_free(expected_iv);
|
455
|
+
_mongocrypt_buffer_cleanup(&key);
|
456
|
+
_mongocrypt_buffer_cleanup(&associated_data);
|
457
|
+
_mongocrypt_buffer_cleanup(&plaintext);
|
458
|
+
_mongocrypt_buffer_cleanup(&iv);
|
459
|
+
mongocrypt_status_destroy(status);
|
460
|
+
mongocrypt_destroy(crypt);
|
461
|
+
bson_string_free(call_history, true);
|
551
462
|
}
|
552
463
|
|
553
|
-
static void
|
554
|
-
|
555
|
-
|
556
|
-
_test_crypto_hooks_iv_gen_helper (tester, "error_on:none");
|
557
|
-
_test_crypto_hooks_iv_gen_helper (tester, "error_on:hmac_sha512");
|
464
|
+
static void _test_crypto_hooks_iv_gen(_mongocrypt_tester_t *tester) {
|
465
|
+
_test_crypto_hooks_iv_gen_helper(tester, "error_on:none");
|
466
|
+
_test_crypto_hooks_iv_gen_helper(tester, "error_on:hmac_sha512");
|
558
467
|
}
|
559
468
|
|
469
|
+
static void _test_crypto_hooks_random_helper(_mongocrypt_tester_t *tester, const char *error_on) {
|
470
|
+
mongocrypt_t *crypt;
|
471
|
+
bool ret;
|
472
|
+
mongocrypt_status_t *status;
|
473
|
+
_mongocrypt_buffer_t random;
|
474
|
+
const char *expected_call_history = "call:_random\n"
|
475
|
+
"count:96\n"
|
476
|
+
"ret:_random\n";
|
560
477
|
|
561
|
-
|
562
|
-
|
563
|
-
const char *error_on)
|
564
|
-
{
|
565
|
-
mongocrypt_t *crypt;
|
566
|
-
bool ret;
|
567
|
-
mongocrypt_status_t *status;
|
568
|
-
_mongocrypt_buffer_t random;
|
569
|
-
const char *expected_call_history = "call:_random\n"
|
570
|
-
"count:96\n"
|
571
|
-
"ret:_random\n";
|
572
|
-
|
573
|
-
status = mongocrypt_status_new ();
|
574
|
-
crypt = _create_mongocrypt (tester, error_on);
|
478
|
+
status = mongocrypt_status_new();
|
479
|
+
crypt = _create_mongocrypt(tester, error_on);
|
575
480
|
|
576
|
-
|
577
|
-
|
481
|
+
_mongocrypt_buffer_init(&random);
|
482
|
+
_mongocrypt_buffer_resize(&random, 96);
|
578
483
|
|
579
|
-
|
484
|
+
call_history = bson_string_new(NULL);
|
580
485
|
|
581
|
-
|
486
|
+
ret = _mongocrypt_random(crypt->crypto, &random, random.len, status);
|
582
487
|
|
583
|
-
|
584
|
-
|
488
|
+
if (0 == strcmp(error_on, "error_on:none")) {
|
489
|
+
ASSERT_OK_STATUS(ret, status);
|
585
490
|
|
586
|
-
|
587
|
-
|
491
|
+
/* Check the full trace. */
|
492
|
+
ASSERT_STREQUAL(call_history->str, expected_call_history);
|
588
493
|
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
494
|
+
/* Check the resulting iv */
|
495
|
+
BSON_ASSERT(0 == _mongocrypt_buffer_cmp_hex(&random, RANDOM_HEX));
|
496
|
+
} else {
|
497
|
+
ASSERT_FAILS_STATUS(ret, status, error_on);
|
498
|
+
}
|
594
499
|
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
500
|
+
_mongocrypt_buffer_cleanup(&random);
|
501
|
+
mongocrypt_status_destroy(status);
|
502
|
+
mongocrypt_destroy(crypt);
|
503
|
+
bson_string_free(call_history, true);
|
599
504
|
}
|
600
505
|
|
601
|
-
static void
|
602
|
-
|
603
|
-
|
604
|
-
_test_crypto_hooks_random_helper (tester, "error_on:none");
|
605
|
-
_test_crypto_hooks_random_helper (tester, "error_on:random");
|
506
|
+
static void _test_crypto_hooks_random(_mongocrypt_tester_t *tester) {
|
507
|
+
_test_crypto_hooks_random_helper(tester, "error_on:none");
|
508
|
+
_test_crypto_hooks_random_helper(tester, "error_on:random");
|
606
509
|
}
|
607
510
|
|
608
|
-
static void
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
mongocrypt_ctx_t *ctx;
|
614
|
-
bool ret;
|
511
|
+
static void _test_kms_request_helper(_mongocrypt_tester_t *tester, const char *error_on) {
|
512
|
+
mongocrypt_t *crypt;
|
513
|
+
mongocrypt_status_t *status;
|
514
|
+
mongocrypt_ctx_t *ctx;
|
515
|
+
bool ret;
|
615
516
|
|
616
|
-
|
617
|
-
|
618
|
-
|
517
|
+
status = mongocrypt_status_new();
|
518
|
+
crypt = _create_mongocrypt(tester, error_on);
|
519
|
+
ctx = mongocrypt_ctx_new(crypt);
|
619
520
|
|
620
|
-
|
521
|
+
call_history = bson_string_new(NULL);
|
621
522
|
|
622
|
-
|
623
|
-
mongocrypt_ctx_setopt_masterkey_aws (ctx, "us-east-1", -1, "cmk", -1),
|
624
|
-
ctx);
|
523
|
+
ASSERT_OK(mongocrypt_ctx_setopt_masterkey_aws(ctx, "us-east-1", -1, "cmk", -1), ctx);
|
625
524
|
|
626
|
-
|
627
|
-
|
525
|
+
mongocrypt_ctx_datakey_init(ctx);
|
526
|
+
ret = mongocrypt_ctx_status(ctx, status);
|
628
527
|
|
629
|
-
|
630
|
-
|
528
|
+
if (0 == strcmp(error_on, "error_on:none")) {
|
529
|
+
ASSERT_OK_STATUS(ret, status);
|
631
530
|
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
531
|
+
/* The call history includes some random data, just assert we've called
|
532
|
+
* our hooks. */
|
533
|
+
BSON_ASSERT(strstr(call_history->str, "call:_hmac_sha_256"));
|
534
|
+
BSON_ASSERT(strstr(call_history->str, "call:_sha_256"));
|
535
|
+
} else {
|
536
|
+
ASSERT_FAILS_STATUS(ret, status, error_on);
|
537
|
+
}
|
639
538
|
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
539
|
+
mongocrypt_ctx_destroy(ctx);
|
540
|
+
mongocrypt_status_destroy(status);
|
541
|
+
mongocrypt_destroy(crypt);
|
542
|
+
bson_string_free(call_history, true);
|
644
543
|
}
|
645
544
|
|
646
|
-
static void
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
_test_kms_request_helper (tester, "error_on:hmac_sha256");
|
651
|
-
_test_kms_request_helper (tester, "error_on:sha256");
|
545
|
+
static void _test_kms_request(_mongocrypt_tester_t *tester) {
|
546
|
+
_test_kms_request_helper(tester, "error_on:none");
|
547
|
+
_test_kms_request_helper(tester, "error_on:hmac_sha256");
|
548
|
+
_test_kms_request_helper(tester, "error_on:sha256");
|
652
549
|
}
|
653
550
|
|
551
|
+
static void _test_crypto_hooks_unset(_mongocrypt_tester_t *tester) {
|
552
|
+
mongocrypt_t *crypt;
|
654
553
|
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
crypt = mongocrypt_new ();
|
661
|
-
mongocrypt_setopt_kms_provider_aws (crypt, "example", -1, "example", -1);
|
662
|
-
ASSERT_OK (mongocrypt_init (crypt), crypt);
|
663
|
-
mongocrypt_destroy (crypt);
|
554
|
+
crypt = mongocrypt_new();
|
555
|
+
mongocrypt_setopt_kms_provider_aws(crypt, "example", -1, "example", -1);
|
556
|
+
ASSERT_OK(_mongocrypt_init_for_test(crypt), crypt);
|
557
|
+
mongocrypt_destroy(crypt);
|
664
558
|
}
|
665
559
|
|
666
|
-
|
667
560
|
/* test a bug fix, that an error on explicit encryption in the crypto hooks sets
|
668
561
|
* the context state */
|
669
|
-
static void
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
BSON_ASSERT (MONGOCRYPT_CTX_ERROR == mongocrypt_ctx_state (ctx));
|
697
|
-
mongocrypt_binary_destroy (bin);
|
698
|
-
mongocrypt_binary_destroy (key_id);
|
699
|
-
mongocrypt_ctx_destroy (ctx);
|
700
|
-
mongocrypt_destroy (crypt);
|
701
|
-
bson_string_free (call_history, true);
|
562
|
+
static void _test_crypto_hooks_explicit_err(_mongocrypt_tester_t *tester) {
|
563
|
+
mongocrypt_t *crypt;
|
564
|
+
mongocrypt_ctx_t *ctx;
|
565
|
+
mongocrypt_binary_t *bin, *key_id;
|
566
|
+
const char *deterministic = MONGOCRYPT_ALGORITHM_DETERMINISTIC_STR;
|
567
|
+
|
568
|
+
call_history = bson_string_new(NULL);
|
569
|
+
|
570
|
+
/* error on something during encryption. */
|
571
|
+
crypt = _create_mongocrypt(tester, "error_on:hmac_sha512");
|
572
|
+
|
573
|
+
ctx = mongocrypt_ctx_new(crypt);
|
574
|
+
key_id = mongocrypt_binary_new_from_data(MONGOCRYPT_DATA_AND_LEN("aaaaaaaaaaaaaaaa"));
|
575
|
+
|
576
|
+
ASSERT_OK(mongocrypt_ctx_setopt_algorithm(ctx, deterministic, -1), ctx);
|
577
|
+
ASSERT_OK(mongocrypt_ctx_setopt_key_id(ctx, key_id), ctx);
|
578
|
+
ASSERT_OK(mongocrypt_ctx_explicit_encrypt_init(ctx, TEST_BSON("{'v': 123}")), ctx);
|
579
|
+
|
580
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_READY);
|
581
|
+
bin = mongocrypt_binary_new();
|
582
|
+
ASSERT_FAILS(mongocrypt_ctx_finalize(ctx, bin), ctx, "error_on:hmac_sha512");
|
583
|
+
BSON_ASSERT(MONGOCRYPT_CTX_ERROR == mongocrypt_ctx_state(ctx));
|
584
|
+
mongocrypt_binary_destroy(bin);
|
585
|
+
mongocrypt_binary_destroy(key_id);
|
586
|
+
mongocrypt_ctx_destroy(ctx);
|
587
|
+
mongocrypt_destroy(crypt);
|
588
|
+
bson_string_free(call_history, true);
|
702
589
|
}
|
703
590
|
|
704
591
|
/* validate that sha256 errors are handled correctly */
|
705
|
-
static void
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
mongocrypt_status_t *status;
|
710
|
-
mongocrypt_ctx_t *ctx;
|
592
|
+
static void _test_crypto_hooks_explicit_sha256_err(_mongocrypt_tester_t *tester) {
|
593
|
+
mongocrypt_t *crypt;
|
594
|
+
mongocrypt_status_t *status;
|
595
|
+
mongocrypt_ctx_t *ctx;
|
711
596
|
|
712
|
-
|
713
|
-
|
714
|
-
|
597
|
+
status = mongocrypt_status_new();
|
598
|
+
crypt = _create_mongocrypt(tester, "error_on:sha256");
|
599
|
+
ctx = mongocrypt_ctx_new(crypt);
|
715
600
|
|
716
|
-
|
601
|
+
call_history = bson_string_new(NULL);
|
717
602
|
|
718
|
-
|
719
|
-
|
720
|
-
ctx);
|
721
|
-
ASSERT_FAILS (
|
722
|
-
mongocrypt_ctx_datakey_init (ctx), ctx, "failed to create KMS message");
|
603
|
+
ASSERT_OK(mongocrypt_ctx_setopt_masterkey_aws(ctx, "us-east-1", -1, "cmk", -1), ctx);
|
604
|
+
ASSERT_FAILS(mongocrypt_ctx_datakey_init(ctx), ctx, "failed to create KMS message");
|
723
605
|
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
606
|
+
mongocrypt_ctx_destroy(ctx);
|
607
|
+
mongocrypt_status_destroy(status);
|
608
|
+
mongocrypt_destroy(crypt);
|
609
|
+
bson_string_free(call_history, true);
|
728
610
|
}
|
729
611
|
|
730
|
-
static void
|
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
|
-
call_history = bson_string_new (NULL);
|
773
|
-
|
774
|
-
ASSERT_OK (mongocrypt_ctx_encrypt_init (
|
775
|
-
ctx, "test", -1, TEST_FILE ("./test/example/cmd.json")),
|
776
|
-
ctx);
|
777
|
-
_mongocrypt_tester_run_ctx_to (tester, ctx, MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
778
|
-
ASSERT_FAILS (mongocrypt_ctx_mongo_feed (
|
779
|
-
ctx, TEST_FILE ("./test/data/key-document-gcp.json")),
|
612
|
+
static void _test_crypto_hook_sign_rsaes_pkcs1_v1_5(_mongocrypt_tester_t *tester) {
|
613
|
+
mongocrypt_t *crypt;
|
614
|
+
mongocrypt_ctx_t *ctx;
|
615
|
+
|
616
|
+
crypt = _create_mongocrypt(tester, "error_on:none");
|
617
|
+
call_history = bson_string_new(NULL);
|
618
|
+
|
619
|
+
ctx = mongocrypt_ctx_new(crypt);
|
620
|
+
mongocrypt_ctx_setopt_key_encryption_key(ctx,
|
621
|
+
TEST_BSON("{'provider': 'gcp', 'projectId': 'test', 'location': "
|
622
|
+
"'global', 'keyRing': 'ring', 'keyName': 'key'}"));
|
623
|
+
ASSERT_OK(mongocrypt_ctx_datakey_init(ctx), ctx);
|
624
|
+
|
625
|
+
BSON_ASSERT(strstr(call_history->str, "call:_sign_rsaes_pkcs1_v1_5"));
|
626
|
+
BSON_ASSERT(strstr(call_history->str, "key:000000"));
|
627
|
+
|
628
|
+
mongocrypt_ctx_destroy(ctx);
|
629
|
+
mongocrypt_destroy(crypt);
|
630
|
+
bson_string_free(call_history, true);
|
631
|
+
|
632
|
+
/* Test error when creating a data key. */
|
633
|
+
crypt = _create_mongocrypt(tester, "error_on:sign_rsaes_pkcs1_v1_5");
|
634
|
+
ctx = mongocrypt_ctx_new(crypt);
|
635
|
+
call_history = bson_string_new(NULL);
|
636
|
+
|
637
|
+
mongocrypt_ctx_setopt_key_encryption_key(ctx,
|
638
|
+
TEST_BSON("{'provider': 'gcp', 'projectId': 'test', 'location': "
|
639
|
+
"'global', 'keyRing': 'ring', 'keyName': 'key'}"));
|
640
|
+
ASSERT_FAILS(mongocrypt_ctx_datakey_init(ctx), ctx, "error_on:sign_rsaes_pkcs1_v1_5");
|
641
|
+
|
642
|
+
mongocrypt_ctx_destroy(ctx);
|
643
|
+
mongocrypt_destroy(crypt);
|
644
|
+
bson_string_free(call_history, true);
|
645
|
+
|
646
|
+
/* Test error when encrypting. */
|
647
|
+
crypt = _create_mongocrypt(tester, "error_on:sign_rsaes_pkcs1_v1_5");
|
648
|
+
ctx = mongocrypt_ctx_new(crypt);
|
649
|
+
call_history = bson_string_new(NULL);
|
650
|
+
|
651
|
+
ASSERT_OK(mongocrypt_ctx_encrypt_init(ctx, "test", -1, TEST_FILE("./test/example/cmd.json")), ctx);
|
652
|
+
_mongocrypt_tester_run_ctx_to(tester, ctx, MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
653
|
+
ASSERT_FAILS(mongocrypt_ctx_mongo_feed(ctx, TEST_FILE("./test/data/key-document-gcp.json")),
|
780
654
|
ctx,
|
781
655
|
"error_on:sign_rsaes_pkcs1_v1_5");
|
782
656
|
|
783
|
-
|
784
|
-
|
785
|
-
|
657
|
+
mongocrypt_ctx_destroy(ctx);
|
658
|
+
mongocrypt_destroy(crypt);
|
659
|
+
bson_string_free(call_history, true);
|
786
660
|
}
|
787
661
|
|
788
662
|
#ifdef MONGOCRYPT_ENABLE_CRYPTO_LIBCRYPTO
|
789
|
-
bool
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
{
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
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
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
ASSERT (0 == _mongocrypt_buffer_cmp (&plaintext, &plaintext_ecb));
|
887
|
-
|
888
|
-
_mongocrypt_buffer_cleanup (&key);
|
889
|
-
_mongocrypt_buffer_cleanup (&iv);
|
890
|
-
_mongocrypt_buffer_cleanup (&plaintext);
|
891
|
-
_mongocrypt_buffer_cleanup (&ciphertext_reg);
|
892
|
-
_mongocrypt_buffer_cleanup (&ciphertext_ecb);
|
893
|
-
_mongocrypt_buffer_cleanup (&plaintext_ecb);
|
894
|
-
mongocrypt_destroy (crypt_reg);
|
895
|
-
mongocrypt_destroy (crypt_ecb);
|
896
|
-
mongocrypt_status_destroy (status);
|
663
|
+
bool _native_crypto_aes_256_ecb_encrypt(aes_256_args_t args);
|
664
|
+
|
665
|
+
static bool _aes_256_ecb_encrypt(void *ctx,
|
666
|
+
mongocrypt_binary_t *key,
|
667
|
+
mongocrypt_binary_t *iv,
|
668
|
+
mongocrypt_binary_t *in,
|
669
|
+
mongocrypt_binary_t *out,
|
670
|
+
uint32_t *bytes_written,
|
671
|
+
mongocrypt_status_t *status) {
|
672
|
+
_mongocrypt_buffer_t key_buf;
|
673
|
+
_mongocrypt_buffer_from_binary(&key_buf, key);
|
674
|
+
if (iv) {
|
675
|
+
CLIENT_ERR("IV expected to be NULL in this mode");
|
676
|
+
return false;
|
677
|
+
}
|
678
|
+
_mongocrypt_buffer_t in_buf;
|
679
|
+
_mongocrypt_buffer_from_binary(&in_buf, in);
|
680
|
+
_mongocrypt_buffer_t out_buf;
|
681
|
+
_mongocrypt_buffer_from_binary(&out_buf, out);
|
682
|
+
|
683
|
+
aes_256_args_t args = {&key_buf, NULL, &in_buf, &out_buf, bytes_written, status};
|
684
|
+
|
685
|
+
return _native_crypto_aes_256_ecb_encrypt(args);
|
686
|
+
}
|
687
|
+
|
688
|
+
void _test_fle2_crypto_via_ecb_hook(_mongocrypt_tester_t *tester) {
|
689
|
+
const _mongocrypt_value_encryption_algorithm_t *fle2alg = _mcFLE2Algorithm();
|
690
|
+
bool ret;
|
691
|
+
_mongocrypt_buffer_t key;
|
692
|
+
_mongocrypt_buffer_t iv;
|
693
|
+
_mongocrypt_buffer_t plaintext;
|
694
|
+
_mongocrypt_buffer_t ciphertext_reg;
|
695
|
+
_mongocrypt_buffer_t ciphertext_ecb;
|
696
|
+
_mongocrypt_buffer_t plaintext_ecb;
|
697
|
+
uint32_t bytes_written;
|
698
|
+
mongocrypt_status_t *status = mongocrypt_status_new();
|
699
|
+
|
700
|
+
_mongocrypt_buffer_copy_from_hex(&iv, IV_HEX);
|
701
|
+
_mongocrypt_buffer_copy_from_hex(&plaintext, "4f6c64204d63446f6e616c64206861642061206661726d2e20456965696f0a");
|
702
|
+
_mongocrypt_buffer_copy_from_hex(&key, ENCRYPTION_KEY_HEX);
|
703
|
+
|
704
|
+
/* Encrypt data using native CTR and ECB-hook and compare */
|
705
|
+
|
706
|
+
mongocrypt_t *crypt_reg = mongocrypt_new();
|
707
|
+
_mongocrypt_buffer_init(&ciphertext_reg);
|
708
|
+
_mongocrypt_buffer_resize(&ciphertext_reg, fle2alg->get_ciphertext_len(plaintext.len, status));
|
709
|
+
ret = fle2alg->do_encrypt(crypt_reg->crypto,
|
710
|
+
&iv,
|
711
|
+
NULL /* aad */,
|
712
|
+
&key,
|
713
|
+
&plaintext,
|
714
|
+
&ciphertext_reg,
|
715
|
+
&bytes_written,
|
716
|
+
status);
|
717
|
+
ASSERT_OK(ret, crypt_reg);
|
718
|
+
|
719
|
+
mongocrypt_t *crypt_ecb = mongocrypt_new();
|
720
|
+
ret = mongocrypt_setopt_aes_256_ecb(crypt_ecb, _aes_256_ecb_encrypt, NULL);
|
721
|
+
ASSERT_OK(ret, crypt_ecb);
|
722
|
+
_mongocrypt_buffer_init(&ciphertext_ecb);
|
723
|
+
_mongocrypt_buffer_resize(&ciphertext_ecb, fle2alg->get_ciphertext_len(plaintext.len, status));
|
724
|
+
ret = fle2alg->do_encrypt(crypt_ecb->crypto,
|
725
|
+
&iv,
|
726
|
+
NULL /* aad */,
|
727
|
+
&key,
|
728
|
+
&plaintext,
|
729
|
+
&ciphertext_ecb,
|
730
|
+
&bytes_written,
|
731
|
+
status);
|
732
|
+
ASSERT_OK(ret, crypt_ecb);
|
733
|
+
|
734
|
+
ASSERT(0 == _mongocrypt_buffer_cmp(&ciphertext_reg, &ciphertext_ecb));
|
735
|
+
|
736
|
+
/* Decrypt data using ECB-hook and compare to original */
|
737
|
+
|
738
|
+
_mongocrypt_buffer_init(&plaintext_ecb);
|
739
|
+
_mongocrypt_buffer_resize(&plaintext_ecb, fle2alg->get_plaintext_len(ciphertext_ecb.len, status));
|
740
|
+
ret = fle2alg->do_decrypt(crypt_ecb->crypto,
|
741
|
+
NULL /* aad */,
|
742
|
+
&key,
|
743
|
+
&ciphertext_ecb,
|
744
|
+
&plaintext_ecb,
|
745
|
+
&bytes_written,
|
746
|
+
status);
|
747
|
+
ASSERT_OK(ret, crypt_ecb);
|
748
|
+
|
749
|
+
ASSERT(0 == _mongocrypt_buffer_cmp(&plaintext, &plaintext_ecb));
|
750
|
+
|
751
|
+
_mongocrypt_buffer_cleanup(&key);
|
752
|
+
_mongocrypt_buffer_cleanup(&iv);
|
753
|
+
_mongocrypt_buffer_cleanup(&plaintext);
|
754
|
+
_mongocrypt_buffer_cleanup(&ciphertext_reg);
|
755
|
+
_mongocrypt_buffer_cleanup(&ciphertext_ecb);
|
756
|
+
_mongocrypt_buffer_cleanup(&plaintext_ecb);
|
757
|
+
mongocrypt_destroy(crypt_reg);
|
758
|
+
mongocrypt_destroy(crypt_ecb);
|
759
|
+
mongocrypt_status_destroy(status);
|
897
760
|
}
|
898
761
|
#endif
|
899
762
|
|
900
|
-
void
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
763
|
+
static void test_is_crypto_available_with_crypto_required(_mongocrypt_tester_t *tester) {
|
764
|
+
// libmongocrypt is built with native crypto.
|
765
|
+
ASSERT(mongocrypt_is_crypto_available());
|
766
|
+
}
|
767
|
+
|
768
|
+
static void test_is_crypto_available_with_crypto_prohibited(_mongocrypt_tester_t *tester) {
|
769
|
+
// libmongocrypt is not built with native crypto.
|
770
|
+
ASSERT(!mongocrypt_is_crypto_available());
|
771
|
+
}
|
772
|
+
|
773
|
+
static int ctr_encrypt_count;
|
774
|
+
|
775
|
+
static bool _aes_256_ctr_encrypt_and_count(void *ctx,
|
776
|
+
mongocrypt_binary_t *key,
|
777
|
+
mongocrypt_binary_t *iv,
|
778
|
+
mongocrypt_binary_t *in,
|
779
|
+
mongocrypt_binary_t *out,
|
780
|
+
uint32_t *bytes_written,
|
781
|
+
mongocrypt_status_t *status) {
|
782
|
+
ctr_encrypt_count++;
|
783
|
+
return _std_hook_native_crypto_aes_256_ctr_encrypt(ctx, key, iv, in, out, bytes_written, status);
|
784
|
+
}
|
785
|
+
|
786
|
+
static int ctr_decrypt_count;
|
787
|
+
|
788
|
+
static bool _aes_256_ctr_decrypt_and_count(void *ctx,
|
789
|
+
mongocrypt_binary_t *key,
|
790
|
+
mongocrypt_binary_t *iv,
|
791
|
+
mongocrypt_binary_t *in,
|
792
|
+
mongocrypt_binary_t *out,
|
793
|
+
uint32_t *bytes_written,
|
794
|
+
mongocrypt_status_t *status) {
|
795
|
+
ctr_decrypt_count++;
|
796
|
+
return _std_hook_native_crypto_aes_256_ctr_decrypt(ctx, key, iv, in, out, bytes_written, status);
|
797
|
+
}
|
798
|
+
|
799
|
+
static void test_setting_only_ctr_hook(_mongocrypt_tester_t *tester) {
|
800
|
+
// Test that the CTR hook can be set without setting other crypto hooks.
|
801
|
+
// This enables supporting macOS <= 10.14 in bindings using libmongocrypt with native crypto.
|
802
|
+
// macOS <= 10.14 does not support native CTR encryption.
|
803
|
+
|
804
|
+
if (!_aes_ctr_is_supported_by_os) {
|
805
|
+
printf("Common Crypto with no CTR support detected. Skipping.");
|
806
|
+
return;
|
807
|
+
}
|
808
|
+
|
809
|
+
// Configure KMS providers with local KEK used to encrypt key documents.
|
810
|
+
mongocrypt_binary_t *kms_providers =
|
811
|
+
TEST_BSON("{'local' : { 'key': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
812
|
+
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'}}");
|
813
|
+
_mongocrypt_buffer_t key_id1, key_id2;
|
814
|
+
_mongocrypt_buffer_copy_from_hex(&key_id1, "12345678123498761234123456789012");
|
815
|
+
_mongocrypt_buffer_copy_from_hex(&key_id2, "ABCDEFAB123498761234123456789012");
|
816
|
+
|
817
|
+
mongocrypt_t *crypt = mongocrypt_new();
|
818
|
+
ASSERT_OK(
|
819
|
+
mongocrypt_setopt_aes_256_ctr(crypt, _aes_256_ctr_encrypt_and_count, _aes_256_ctr_decrypt_and_count, NULL),
|
820
|
+
crypt);
|
821
|
+
ASSERT_OK(mongocrypt_setopt_kms_providers(crypt, kms_providers), crypt);
|
822
|
+
ASSERT_OK(_mongocrypt_init_for_test(crypt), crypt);
|
823
|
+
|
824
|
+
// Encrypt with an algorithm using the CTR hook.
|
825
|
+
ctr_encrypt_count = 0;
|
826
|
+
{
|
827
|
+
mongocrypt_ctx_t *ctx = mongocrypt_ctx_new(crypt);
|
828
|
+
ASSERT_OK(mongocrypt_ctx_setopt_key_id(ctx, _mongocrypt_buffer_as_binary(&key_id1)), ctx);
|
829
|
+
ASSERT_OK(mongocrypt_ctx_setopt_contention_factor(ctx, 1), ctx);
|
830
|
+
ASSERT_OK(mongocrypt_ctx_setopt_algorithm(ctx, MONGOCRYPT_ALGORITHM_INDEXED_STR, -1), ctx);
|
831
|
+
ASSERT_OK(mongocrypt_ctx_explicit_encrypt_init(ctx, TEST_BSON("{'v' : 123}")), ctx);
|
832
|
+
|
833
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
834
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
835
|
+
TEST_FILE("./test/data/keys/"
|
836
|
+
"12345678123498761234123456789012-local-"
|
837
|
+
"document.json")),
|
838
|
+
ctx);
|
839
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
840
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_READY);
|
841
|
+
mongocrypt_binary_t *ciphertext = mongocrypt_binary_new();
|
842
|
+
ASSERT_OK(mongocrypt_ctx_finalize(ctx, ciphertext), ctx);
|
843
|
+
mongocrypt_binary_destroy(ciphertext);
|
844
|
+
mongocrypt_ctx_destroy(ctx);
|
845
|
+
}
|
846
|
+
// CTR encrypt hook is called.
|
847
|
+
ASSERT_CMPINT(ctr_encrypt_count, ==, 1);
|
848
|
+
|
849
|
+
// Decrypt with an algorithm using the CTR hook.
|
850
|
+
ctr_decrypt_count = 0;
|
851
|
+
{
|
852
|
+
// `ieev_payload_base64` is an IEEV payload, which uses the CTR hook to decrypt.
|
853
|
+
const char *ieev_payload_base64 = "BxI0VngSNJh2EjQSNFZ4kBICQ7uhTd9C2oI8M1afRon0ZaYG0s6oTmt0aBZ9kO4S4mm5vId01"
|
854
|
+
"BsW7tBHytA8pDJ2IiWBCmah3OGH2M4ET7PSqekQD4gkUCo4JeEttx4yj05Ou4D6yZUmYfVKmE"
|
855
|
+
"ljge16NCxKm7Ir9gvmQsp8x1wqGBzpndA6gkqFxsxfvQ/"
|
856
|
+
"cIqOwMW9dGTTWsfKge+jYkCUIFMfms+XyC/8evQhjjA+qR6eEmV+N/"
|
857
|
+
"kwpR7Q7TJe0lwU5kw2kSe3/KiPKRZZTbn8znadvycfJ0cCWGad9SQ==";
|
858
|
+
|
859
|
+
mongocrypt_ctx_t *ctx = mongocrypt_ctx_new(crypt);
|
860
|
+
ASSERT_OK(mongocrypt_ctx_explicit_decrypt_init(
|
861
|
+
ctx,
|
862
|
+
TEST_BSON("{'v':{'$binary':{'base64': '%s','subType':'6'}}}", ieev_payload_base64)),
|
863
|
+
ctx);
|
864
|
+
|
865
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_MONGO_KEYS);
|
866
|
+
ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx,
|
867
|
+
TEST_FILE("./test/data/keys/"
|
868
|
+
"ABCDEFAB123498761234123456789012-local-"
|
869
|
+
"document.json")),
|
870
|
+
ctx);
|
871
|
+
ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx);
|
872
|
+
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_READY);
|
873
|
+
mongocrypt_binary_t *decrypted = mongocrypt_binary_new();
|
874
|
+
ASSERT_OK(mongocrypt_ctx_finalize(ctx, decrypted), ctx);
|
875
|
+
ASSERT_MONGOCRYPT_BINARY_EQUAL_BSON(decrypted, TEST_BSON("{'v': 'value123'}"));
|
876
|
+
mongocrypt_binary_destroy(decrypted);
|
877
|
+
mongocrypt_ctx_destroy(ctx);
|
878
|
+
}
|
879
|
+
// CTR decrypt hook is called repeatedly.
|
880
|
+
ASSERT_CMPINT(ctr_decrypt_count, ==, 4);
|
881
|
+
|
882
|
+
_mongocrypt_buffer_cleanup(&key_id2);
|
883
|
+
_mongocrypt_buffer_cleanup(&key_id1);
|
884
|
+
mongocrypt_destroy(crypt);
|
885
|
+
}
|
886
|
+
|
887
|
+
void _mongocrypt_tester_install_crypto_hooks(_mongocrypt_tester_t *tester) {
|
888
|
+
INSTALL_TEST_CRYPTO(_test_crypto_hooks_encryption, CRYPTO_OPTIONAL);
|
889
|
+
INSTALL_TEST_CRYPTO(_test_crypto_hooks_decryption, CRYPTO_OPTIONAL);
|
890
|
+
INSTALL_TEST_CRYPTO(_test_crypto_hooks_iv_gen, CRYPTO_OPTIONAL);
|
891
|
+
INSTALL_TEST_CRYPTO(_test_crypto_hooks_random, CRYPTO_OPTIONAL);
|
892
|
+
INSTALL_TEST_CRYPTO(_test_kms_request, CRYPTO_OPTIONAL);
|
893
|
+
INSTALL_TEST_CRYPTO(_test_crypto_hooks_unset, CRYPTO_PROHIBITED);
|
894
|
+
INSTALL_TEST_CRYPTO(_test_crypto_hooks_explicit_err, CRYPTO_OPTIONAL);
|
895
|
+
INSTALL_TEST_CRYPTO(_test_crypto_hooks_explicit_sha256_err, CRYPTO_OPTIONAL);
|
896
|
+
INSTALL_TEST_CRYPTO(_test_crypto_hook_sign_rsaes_pkcs1_v1_5, CRYPTO_OPTIONAL);
|
897
|
+
INSTALL_TEST_CRYPTO(test_is_crypto_available_with_crypto_required, CRYPTO_REQUIRED);
|
898
|
+
INSTALL_TEST_CRYPTO(test_is_crypto_available_with_crypto_prohibited, CRYPTO_PROHIBITED);
|
899
|
+
INSTALL_TEST_CRYPTO(test_setting_only_ctr_hook, CRYPTO_REQUIRED);
|
914
900
|
#ifdef MONGOCRYPT_ENABLE_CRYPTO_LIBCRYPTO
|
915
|
-
|
901
|
+
INSTALL_TEST(_test_fle2_crypto_via_ecb_hook);
|
916
902
|
#endif
|
917
903
|
}
|