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
@@ -1,701 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
const fs = require('fs');
|
3
|
-
const expect = require('chai').expect;
|
4
|
-
const sinon = require('sinon');
|
5
|
-
const mongodb = require('mongodb');
|
6
|
-
const BSON = mongodb.BSON;
|
7
|
-
const MongoClient = mongodb.MongoClient;
|
8
|
-
const cryptoCallbacks = require('../lib/cryptoCallbacks');
|
9
|
-
const stateMachine = require('../lib/stateMachine')({ mongodb });
|
10
|
-
const StateMachine = stateMachine.StateMachine;
|
11
|
-
const { Binary, EJSON, deserialize } = BSON;
|
12
|
-
|
13
|
-
function readHttpResponse(path) {
|
14
|
-
let data = fs.readFileSync(path, 'utf8').toString();
|
15
|
-
data = data.split('\n').join('\r\n');
|
16
|
-
return Buffer.from(data, 'utf8');
|
17
|
-
}
|
18
|
-
|
19
|
-
const ClientEncryption = require('../lib/clientEncryption')({
|
20
|
-
mongodb,
|
21
|
-
stateMachine
|
22
|
-
}).ClientEncryption;
|
23
|
-
|
24
|
-
class MockClient {
|
25
|
-
constructor() {
|
26
|
-
this.topology = {
|
27
|
-
bson: BSON
|
28
|
-
};
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
const requirements = require('./requirements.helper');
|
33
|
-
|
34
|
-
describe('ClientEncryption', function () {
|
35
|
-
this.timeout(12000);
|
36
|
-
let client;
|
37
|
-
|
38
|
-
function throwIfNotNsNotFoundError(err) {
|
39
|
-
if (!err.message.match(/ns not found/)) {
|
40
|
-
throw err;
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
async function setup() {
|
45
|
-
client = new MongoClient('mongodb://localhost:27017/test', {
|
46
|
-
useNewUrlParser: true,
|
47
|
-
useUnifiedTopology: true
|
48
|
-
});
|
49
|
-
await client.connect();
|
50
|
-
try {
|
51
|
-
await client.db('client').collection('encryption').drop();
|
52
|
-
} catch (err) {
|
53
|
-
throwIfNotNsNotFoundError(err);
|
54
|
-
}
|
55
|
-
}
|
56
|
-
|
57
|
-
function teardown() {
|
58
|
-
if (requirements.SKIP_LIVE_TESTS) {
|
59
|
-
return Promise.resolve();
|
60
|
-
}
|
61
|
-
|
62
|
-
return client.close();
|
63
|
-
}
|
64
|
-
|
65
|
-
describe('#constructor', function () {
|
66
|
-
context('when mongodb exports BSON (driver >= 4.9.0)', function () {
|
67
|
-
context('when a bson option is provided', function () {
|
68
|
-
const bson = Object.assign({}, BSON);
|
69
|
-
const encrypter = new ClientEncryption(
|
70
|
-
{},
|
71
|
-
{
|
72
|
-
bson: bson,
|
73
|
-
keyVaultNamespace: 'client.encryption',
|
74
|
-
kmsProviders: {
|
75
|
-
local: { key: Buffer.alloc(96) }
|
76
|
-
}
|
77
|
-
}
|
78
|
-
);
|
79
|
-
|
80
|
-
it('uses the bson option', function () {
|
81
|
-
expect(encrypter._bson).to.equal(bson);
|
82
|
-
});
|
83
|
-
});
|
84
|
-
|
85
|
-
context('when a bson option is not provided', function () {
|
86
|
-
const encrypter = new ClientEncryption(
|
87
|
-
{},
|
88
|
-
{
|
89
|
-
keyVaultNamespace: 'client.encryption',
|
90
|
-
kmsProviders: {
|
91
|
-
local: { key: Buffer.alloc(96) }
|
92
|
-
}
|
93
|
-
}
|
94
|
-
);
|
95
|
-
|
96
|
-
it('uses the mongodb exported BSON', function () {
|
97
|
-
expect(encrypter._bson).to.equal(BSON);
|
98
|
-
});
|
99
|
-
});
|
100
|
-
|
101
|
-
it('never uses bson from the topology', function () {
|
102
|
-
expect(() => {
|
103
|
-
new ClientEncryption(
|
104
|
-
{},
|
105
|
-
{
|
106
|
-
keyVaultNamespace: 'client.encryption',
|
107
|
-
kmsProviders: {
|
108
|
-
local: { key: Buffer.alloc(96) }
|
109
|
-
}
|
110
|
-
}
|
111
|
-
);
|
112
|
-
}).not.to.throw();
|
113
|
-
});
|
114
|
-
});
|
115
|
-
|
116
|
-
context('when mongodb does not export BSON (driver < 4.9.0)', function () {
|
117
|
-
context('when a bson option is provided', function () {
|
118
|
-
const bson = Object.assign({}, BSON);
|
119
|
-
const encrypter = new ClientEncryption(
|
120
|
-
{},
|
121
|
-
{
|
122
|
-
bson: bson,
|
123
|
-
keyVaultNamespace: 'client.encryption',
|
124
|
-
kmsProviders: {
|
125
|
-
local: { key: Buffer.alloc(96) }
|
126
|
-
}
|
127
|
-
}
|
128
|
-
);
|
129
|
-
|
130
|
-
it('uses the bson option', function () {
|
131
|
-
expect(encrypter._bson).to.equal(bson);
|
132
|
-
});
|
133
|
-
});
|
134
|
-
|
135
|
-
context('when a bson option is not provided', function () {
|
136
|
-
const mongoNoBson = { ...mongodb, BSON: undefined };
|
137
|
-
const ClientEncryptionNoBson = require('../lib/clientEncryption')({
|
138
|
-
mongodb: mongoNoBson,
|
139
|
-
stateMachine
|
140
|
-
}).ClientEncryption;
|
141
|
-
|
142
|
-
context('when the client has a topology', function () {
|
143
|
-
const client = new MockClient();
|
144
|
-
const encrypter = new ClientEncryptionNoBson(client, {
|
145
|
-
keyVaultNamespace: 'client.encryption',
|
146
|
-
kmsProviders: {
|
147
|
-
local: { key: Buffer.alloc(96) }
|
148
|
-
}
|
149
|
-
});
|
150
|
-
|
151
|
-
it('uses the bson on the topology', function () {
|
152
|
-
expect(encrypter._bson).to.equal(client.topology.bson);
|
153
|
-
});
|
154
|
-
});
|
155
|
-
|
156
|
-
context('when the client does not have a topology', function () {
|
157
|
-
it('raises an error', function () {
|
158
|
-
expect(() => {
|
159
|
-
new ClientEncryptionNoBson({}, {});
|
160
|
-
}).to.throw(/bson/);
|
161
|
-
});
|
162
|
-
});
|
163
|
-
});
|
164
|
-
});
|
165
|
-
});
|
166
|
-
|
167
|
-
describe('stubbed stateMachine', function () {
|
168
|
-
let sandbox = sinon.createSandbox();
|
169
|
-
|
170
|
-
after(() => sandbox.restore());
|
171
|
-
before(() => {
|
172
|
-
// stubbed out for AWS unit testing below
|
173
|
-
const MOCK_KMS_ENCRYPT_REPLY = readHttpResponse(`${__dirname}/data/kms-encrypt-reply.txt`);
|
174
|
-
sandbox.stub(StateMachine.prototype, 'kmsRequest').callsFake(request => {
|
175
|
-
request.addResponse(MOCK_KMS_ENCRYPT_REPLY);
|
176
|
-
return Promise.resolve();
|
177
|
-
});
|
178
|
-
});
|
179
|
-
|
180
|
-
beforeEach(function () {
|
181
|
-
if (requirements.SKIP_LIVE_TESTS) {
|
182
|
-
this.currentTest.skipReason = `requirements.SKIP_LIVE_TESTS=${requirements.SKIP_LIVE_TESTS}`;
|
183
|
-
this.test.skip();
|
184
|
-
return;
|
185
|
-
}
|
186
|
-
|
187
|
-
return setup();
|
188
|
-
});
|
189
|
-
|
190
|
-
afterEach(function () {
|
191
|
-
return teardown();
|
192
|
-
});
|
193
|
-
|
194
|
-
[
|
195
|
-
{
|
196
|
-
name: 'local',
|
197
|
-
kmsProviders: { local: { key: Buffer.alloc(96) } }
|
198
|
-
},
|
199
|
-
{
|
200
|
-
name: 'aws',
|
201
|
-
kmsProviders: { aws: { accessKeyId: 'example', secretAccessKey: 'example' } },
|
202
|
-
options: { masterKey: { region: 'region', key: 'cmk' } }
|
203
|
-
}
|
204
|
-
].forEach(providerTest => {
|
205
|
-
it(`should create a data key with the "${providerTest.name}" KMS provider`, function (done) {
|
206
|
-
const providerName = providerTest.name;
|
207
|
-
const encryption = new ClientEncryption(client, {
|
208
|
-
keyVaultNamespace: 'client.encryption',
|
209
|
-
kmsProviders: providerTest.kmsProviders
|
210
|
-
});
|
211
|
-
|
212
|
-
const dataKeyOptions = providerTest.options || {};
|
213
|
-
encryption.createDataKey(providerName, dataKeyOptions, (err, dataKey) => {
|
214
|
-
expect(err).to.not.exist;
|
215
|
-
expect(dataKey._bsontype).to.equal('Binary');
|
216
|
-
|
217
|
-
client
|
218
|
-
.db('client')
|
219
|
-
.collection('encryption')
|
220
|
-
.findOne({ _id: dataKey }, (err, doc) => {
|
221
|
-
expect(err).to.not.exist;
|
222
|
-
expect(doc).to.have.property('masterKey');
|
223
|
-
expect(doc.masterKey).to.have.property('provider');
|
224
|
-
expect(doc.masterKey.provider).to.eql(providerName);
|
225
|
-
done();
|
226
|
-
});
|
227
|
-
});
|
228
|
-
});
|
229
|
-
|
230
|
-
it(`should create a data key with the "${providerTest.name}" KMS provider (fixed key material)`, function (done) {
|
231
|
-
const providerName = providerTest.name;
|
232
|
-
const encryption = new ClientEncryption(client, {
|
233
|
-
keyVaultNamespace: 'client.encryption',
|
234
|
-
kmsProviders: providerTest.kmsProviders
|
235
|
-
});
|
236
|
-
|
237
|
-
const dataKeyOptions = {
|
238
|
-
...providerTest.options,
|
239
|
-
keyMaterial: new BSON.Binary(Buffer.alloc(96))
|
240
|
-
};
|
241
|
-
encryption.createDataKey(providerName, dataKeyOptions, (err, dataKey) => {
|
242
|
-
expect(err).to.not.exist;
|
243
|
-
expect(dataKey._bsontype).to.equal('Binary');
|
244
|
-
|
245
|
-
client
|
246
|
-
.db('client')
|
247
|
-
.collection('encryption')
|
248
|
-
.findOne({ _id: dataKey }, (err, doc) => {
|
249
|
-
expect(err).to.not.exist;
|
250
|
-
expect(doc).to.have.property('masterKey');
|
251
|
-
expect(doc.masterKey).to.have.property('provider');
|
252
|
-
expect(doc.masterKey.provider).to.eql(providerName);
|
253
|
-
done();
|
254
|
-
});
|
255
|
-
});
|
256
|
-
});
|
257
|
-
});
|
258
|
-
|
259
|
-
it(`should create a data key with the local KMS provider (fixed key material, fixed key UUID)`, async function () {
|
260
|
-
// 'Custom Key Material Test' prose spec test:
|
261
|
-
const keyVaultColl = client.db('client').collection('encryption');
|
262
|
-
const encryption = new ClientEncryption(client, {
|
263
|
-
keyVaultNamespace: 'client.encryption',
|
264
|
-
kmsProviders: {
|
265
|
-
local: {
|
266
|
-
key: 'A'.repeat(128) // the value here is not actually relevant
|
267
|
-
}
|
268
|
-
}
|
269
|
-
});
|
270
|
-
|
271
|
-
const dataKeyOptions = {
|
272
|
-
keyMaterial: new BSON.Binary(
|
273
|
-
Buffer.from(
|
274
|
-
'xPTAjBRG5JiPm+d3fj6XLi2q5DMXUS/f1f+SMAlhhwkhDRL0kr8r9GDLIGTAGlvC+HVjSIgdL+RKwZCvpXSyxTICWSXTUYsWYPyu3IoHbuBZdmw2faM3WhcRIgbMReU5',
|
275
|
-
'base64'
|
276
|
-
)
|
277
|
-
)
|
278
|
-
};
|
279
|
-
const dataKey = await encryption.createDataKey('local', dataKeyOptions);
|
280
|
-
expect(dataKey._bsontype).to.equal('Binary');
|
281
|
-
|
282
|
-
// Remove and re-insert with a fixed UUID to guarantee consistent output
|
283
|
-
const doc = (
|
284
|
-
await keyVaultColl.findOneAndDelete({ _id: dataKey }, { writeConcern: { w: 'majority' } })
|
285
|
-
).value;
|
286
|
-
doc._id = new BSON.Binary(Buffer.alloc(16), 4);
|
287
|
-
await keyVaultColl.insertOne(doc, { writeConcern: { w: 'majority' } });
|
288
|
-
|
289
|
-
const encrypted = await encryption.encrypt('test', {
|
290
|
-
keyId: doc._id,
|
291
|
-
algorithm: 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic'
|
292
|
-
});
|
293
|
-
expect(encrypted._bsontype).to.equal('Binary');
|
294
|
-
expect(encrypted.toString('base64')).to.equal(
|
295
|
-
'AQAAAAAAAAAAAAAAAAAAAAACz0ZOLuuhEYi807ZXTdhbqhLaS2/t9wLifJnnNYwiw79d75QYIZ6M/aYC1h9nCzCjZ7pGUpAuNnkUhnIXM3PjrA=='
|
296
|
-
);
|
297
|
-
});
|
298
|
-
|
299
|
-
it('should fail to create a data key if keyMaterial is wrong', function (done) {
|
300
|
-
const encryption = new ClientEncryption(client, {
|
301
|
-
keyVaultNamespace: 'client.encryption',
|
302
|
-
kmsProviders: { local: { key: 'A'.repeat(128) } }
|
303
|
-
});
|
304
|
-
|
305
|
-
const dataKeyOptions = {
|
306
|
-
keyMaterial: new BSON.Binary(Buffer.alloc(97))
|
307
|
-
};
|
308
|
-
try {
|
309
|
-
encryption.createDataKey('local', dataKeyOptions);
|
310
|
-
expect.fail('missed exception');
|
311
|
-
} catch (err) {
|
312
|
-
expect(err.message).to.equal('keyMaterial should have length 96, but has length 97');
|
313
|
-
done();
|
314
|
-
}
|
315
|
-
});
|
316
|
-
|
317
|
-
it('should explicitly encrypt and decrypt with the "local" KMS provider', function (done) {
|
318
|
-
const encryption = new ClientEncryption(client, {
|
319
|
-
keyVaultNamespace: 'client.encryption',
|
320
|
-
kmsProviders: { local: { key: Buffer.alloc(96) } }
|
321
|
-
});
|
322
|
-
|
323
|
-
encryption.createDataKey('local', (err, dataKey) => {
|
324
|
-
expect(err).to.not.exist;
|
325
|
-
|
326
|
-
const encryptOptions = {
|
327
|
-
keyId: dataKey,
|
328
|
-
algorithm: 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic'
|
329
|
-
};
|
330
|
-
|
331
|
-
encryption.encrypt('hello', encryptOptions, (err, encrypted) => {
|
332
|
-
expect(err).to.not.exist;
|
333
|
-
expect(encrypted._bsontype).to.equal('Binary');
|
334
|
-
expect(encrypted.sub_type).to.equal(6);
|
335
|
-
|
336
|
-
encryption.decrypt(encrypted, (err, decrypted) => {
|
337
|
-
expect(err).to.not.exist;
|
338
|
-
expect(decrypted).to.equal('hello');
|
339
|
-
done();
|
340
|
-
});
|
341
|
-
});
|
342
|
-
});
|
343
|
-
});
|
344
|
-
|
345
|
-
it('should explicitly encrypt and decrypt with the "local" KMS provider (promise)', function () {
|
346
|
-
const encryption = new ClientEncryption(client, {
|
347
|
-
keyVaultNamespace: 'client.encryption',
|
348
|
-
kmsProviders: { local: { key: Buffer.alloc(96) } }
|
349
|
-
});
|
350
|
-
|
351
|
-
return encryption
|
352
|
-
.createDataKey('local')
|
353
|
-
.then(dataKey => {
|
354
|
-
const encryptOptions = {
|
355
|
-
keyId: dataKey,
|
356
|
-
algorithm: 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic'
|
357
|
-
};
|
358
|
-
|
359
|
-
return encryption.encrypt('hello', encryptOptions);
|
360
|
-
})
|
361
|
-
.then(encrypted => {
|
362
|
-
expect(encrypted._bsontype).to.equal('Binary');
|
363
|
-
expect(encrypted.sub_type).to.equal(6);
|
364
|
-
|
365
|
-
return encryption.decrypt(encrypted);
|
366
|
-
})
|
367
|
-
.then(decrypted => {
|
368
|
-
expect(decrypted).to.equal('hello');
|
369
|
-
});
|
370
|
-
});
|
371
|
-
|
372
|
-
it('should explicitly encrypt and decrypt with a re-wrapped local key', function () {
|
373
|
-
// Create new ClientEncryption instances to make sure
|
374
|
-
// that we are actually using the rewrapped keys and not
|
375
|
-
// something that has been cached.
|
376
|
-
const newClientEncryption = () =>
|
377
|
-
new ClientEncryption(client, {
|
378
|
-
keyVaultNamespace: 'client.encryption',
|
379
|
-
kmsProviders: { local: { key: 'A'.repeat(128) } }
|
380
|
-
});
|
381
|
-
let encrypted;
|
382
|
-
|
383
|
-
return newClientEncryption()
|
384
|
-
.createDataKey('local')
|
385
|
-
.then(dataKey => {
|
386
|
-
const encryptOptions = {
|
387
|
-
keyId: dataKey,
|
388
|
-
algorithm: 'Indexed',
|
389
|
-
contentionFactor: 0
|
390
|
-
};
|
391
|
-
|
392
|
-
return newClientEncryption().encrypt('hello', encryptOptions);
|
393
|
-
})
|
394
|
-
.then(_encrypted => {
|
395
|
-
encrypted = _encrypted;
|
396
|
-
expect(encrypted._bsontype).to.equal('Binary');
|
397
|
-
expect(encrypted.sub_type).to.equal(6);
|
398
|
-
})
|
399
|
-
.then(() => {
|
400
|
-
return newClientEncryption().rewrapManyDataKey({});
|
401
|
-
})
|
402
|
-
.then(rewrapManyDataKeyResult => {
|
403
|
-
expect(rewrapManyDataKeyResult.bulkWriteResult.result.nModified).to.equal(1);
|
404
|
-
return newClientEncryption().decrypt(encrypted);
|
405
|
-
})
|
406
|
-
.then(decrypted => {
|
407
|
-
expect(decrypted).to.equal('hello');
|
408
|
-
});
|
409
|
-
});
|
410
|
-
|
411
|
-
it('should not perform updates if no keys match', function () {
|
412
|
-
const clientEncryption = new ClientEncryption(client, {
|
413
|
-
keyVaultNamespace: 'client.encryption',
|
414
|
-
kmsProviders: { local: { key: 'A'.repeat(128) } }
|
415
|
-
});
|
416
|
-
|
417
|
-
return clientEncryption.rewrapManyDataKey({ _id: 12345 }).then(rewrapManyDataKeyResult => {
|
418
|
-
expect(rewrapManyDataKeyResult.bulkWriteResult).to.equal(undefined);
|
419
|
-
});
|
420
|
-
});
|
421
|
-
|
422
|
-
it.skip('should explicitly encrypt and decrypt with a re-wrapped local key (explicit session/transaction)', function () {
|
423
|
-
const encryption = new ClientEncryption(client, {
|
424
|
-
keyVaultNamespace: 'client.encryption',
|
425
|
-
kmsProviders: { local: { key: 'A'.repeat(128) } }
|
426
|
-
});
|
427
|
-
let encrypted;
|
428
|
-
let rewrapManyDataKeyResult;
|
429
|
-
|
430
|
-
return encryption
|
431
|
-
.createDataKey('local')
|
432
|
-
.then(dataKey => {
|
433
|
-
const encryptOptions = {
|
434
|
-
keyId: dataKey,
|
435
|
-
algorithm: 'Indexed',
|
436
|
-
contentionFactor: 0
|
437
|
-
};
|
438
|
-
|
439
|
-
return encryption.encrypt('hello', encryptOptions);
|
440
|
-
})
|
441
|
-
.then(_encrypted => {
|
442
|
-
encrypted = _encrypted;
|
443
|
-
})
|
444
|
-
.then(() => {
|
445
|
-
// withSession does not forward the callback's return value, hence
|
446
|
-
// the slightly awkward 'rewrapManyDataKeyResult' passing here
|
447
|
-
return client.withSession(session => {
|
448
|
-
return session.withTransaction(() => {
|
449
|
-
expect(session.transaction.isStarting).to.equal(true);
|
450
|
-
expect(session.transaction.isActive).to.equal(true);
|
451
|
-
rewrapManyDataKeyResult = encryption.rewrapManyDataKey(
|
452
|
-
{},
|
453
|
-
{ provider: 'local', session }
|
454
|
-
);
|
455
|
-
return rewrapManyDataKeyResult.then(() => {
|
456
|
-
// Verify that the 'session' argument was actually used
|
457
|
-
expect(session.transaction.isStarting).to.equal(false);
|
458
|
-
expect(session.transaction.isActive).to.equal(true);
|
459
|
-
});
|
460
|
-
});
|
461
|
-
});
|
462
|
-
})
|
463
|
-
.then(() => {
|
464
|
-
return rewrapManyDataKeyResult;
|
465
|
-
})
|
466
|
-
.then(rewrapManyDataKeyResult => {
|
467
|
-
expect(rewrapManyDataKeyResult.bulkWriteResult.result.nModified).to.equal(1);
|
468
|
-
return encryption.decrypt(encrypted);
|
469
|
-
})
|
470
|
-
.then(decrypted => {
|
471
|
-
expect(decrypted).to.equal('hello');
|
472
|
-
});
|
473
|
-
}).skipReason = 'TODO(DRIVERS-2389): add explicit session support to key management API';
|
474
|
-
|
475
|
-
// TODO(NODE-3371): resolve KMS JSON response does not include string 'Plaintext'. HTTP status=200 error
|
476
|
-
it.skip('should explicitly encrypt and decrypt with the "aws" KMS provider', function (done) {
|
477
|
-
const encryption = new ClientEncryption(client, {
|
478
|
-
keyVaultNamespace: 'client.encryption',
|
479
|
-
kmsProviders: { aws: { accessKeyId: 'example', secretAccessKey: 'example' } }
|
480
|
-
});
|
481
|
-
|
482
|
-
const dataKeyOptions = {
|
483
|
-
masterKey: { region: 'region', key: 'cmk' }
|
484
|
-
};
|
485
|
-
|
486
|
-
encryption.createDataKey('aws', dataKeyOptions, (err, dataKey) => {
|
487
|
-
expect(err).to.not.exist;
|
488
|
-
|
489
|
-
const encryptOptions = {
|
490
|
-
keyId: dataKey,
|
491
|
-
algorithm: 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic'
|
492
|
-
};
|
493
|
-
|
494
|
-
encryption.encrypt('hello', encryptOptions, (err, encrypted) => {
|
495
|
-
expect(err).to.not.exist;
|
496
|
-
expect(encrypted).to.have.property('v');
|
497
|
-
expect(encrypted.v._bsontype).to.equal('Binary');
|
498
|
-
expect(encrypted.v.sub_type).to.equal(6);
|
499
|
-
|
500
|
-
encryption.decrypt(encrypted, (err, decrypted) => {
|
501
|
-
expect(err).to.not.exist;
|
502
|
-
expect(decrypted).to.equal('hello');
|
503
|
-
done();
|
504
|
-
});
|
505
|
-
});
|
506
|
-
});
|
507
|
-
}).skipReason =
|
508
|
-
"TODO(NODE-3371): resolve KMS JSON response does not include string 'Plaintext'. HTTP status=200 error";
|
509
|
-
});
|
510
|
-
|
511
|
-
describe('ClientEncryptionKeyAltNames', function () {
|
512
|
-
const kmsProviders = requirements.awsKmsProviders;
|
513
|
-
const dataKeyOptions = requirements.awsDataKeyOptions;
|
514
|
-
beforeEach(function () {
|
515
|
-
if (requirements.SKIP_AWS_TESTS) {
|
516
|
-
this.currentTest.skipReason = `requirements.SKIP_AWS_TESTS=${requirements.SKIP_AWS_TESTS}`;
|
517
|
-
this.skip();
|
518
|
-
return;
|
519
|
-
}
|
520
|
-
|
521
|
-
return setup().then(() => {
|
522
|
-
this.client = client;
|
523
|
-
this.collection = client.db('client').collection('encryption');
|
524
|
-
this.encryption = new ClientEncryption(this.client, {
|
525
|
-
keyVaultNamespace: 'client.encryption',
|
526
|
-
kmsProviders
|
527
|
-
});
|
528
|
-
});
|
529
|
-
});
|
530
|
-
|
531
|
-
afterEach(function () {
|
532
|
-
return teardown().then(() => {
|
533
|
-
this.encryption = undefined;
|
534
|
-
this.collection = undefined;
|
535
|
-
this.client = undefined;
|
536
|
-
});
|
537
|
-
});
|
538
|
-
|
539
|
-
function makeOptions(keyAltNames) {
|
540
|
-
expect(dataKeyOptions.masterKey).to.be.an('object');
|
541
|
-
expect(dataKeyOptions.masterKey.key).to.be.a('string');
|
542
|
-
expect(dataKeyOptions.masterKey.region).to.be.a('string');
|
543
|
-
|
544
|
-
return {
|
545
|
-
masterKey: {
|
546
|
-
key: dataKeyOptions.masterKey.key,
|
547
|
-
region: dataKeyOptions.masterKey.region
|
548
|
-
},
|
549
|
-
keyAltNames
|
550
|
-
};
|
551
|
-
}
|
552
|
-
|
553
|
-
describe('errors', function () {
|
554
|
-
[42, 'hello', { keyAltNames: 'foobar' }, /foobar/].forEach(val => {
|
555
|
-
it(`should fail if typeof keyAltNames = ${typeof val}`, function () {
|
556
|
-
const options = makeOptions(val);
|
557
|
-
expect(() => this.encryption.createDataKey('aws', options, () => undefined)).to.throw(
|
558
|
-
TypeError
|
559
|
-
);
|
560
|
-
});
|
561
|
-
});
|
562
|
-
|
563
|
-
[undefined, null, 42, { keyAltNames: 'foobar' }, ['foobar'], /foobar/].forEach(val => {
|
564
|
-
it(`should fail if typeof keyAltNames[x] = ${typeof val}`, function () {
|
565
|
-
const options = makeOptions([val]);
|
566
|
-
expect(() => this.encryption.createDataKey('aws', options, () => undefined)).to.throw(
|
567
|
-
TypeError
|
568
|
-
);
|
569
|
-
});
|
570
|
-
});
|
571
|
-
});
|
572
|
-
|
573
|
-
it('should create a key with keyAltNames', function () {
|
574
|
-
let dataKey;
|
575
|
-
const options = makeOptions(['foobar']);
|
576
|
-
return this.encryption
|
577
|
-
.createDataKey('aws', options)
|
578
|
-
.then(_dataKey => (dataKey = _dataKey))
|
579
|
-
.then(() => this.collection.findOne({ keyAltNames: 'foobar' }))
|
580
|
-
.then(document => {
|
581
|
-
expect(document).to.be.an('object');
|
582
|
-
expect(document).to.have.property('keyAltNames').that.includes.members(['foobar']);
|
583
|
-
expect(document).to.have.property('_id').that.deep.equals(dataKey);
|
584
|
-
});
|
585
|
-
});
|
586
|
-
|
587
|
-
it('should create a key with multiple keyAltNames', function () {
|
588
|
-
let dataKey;
|
589
|
-
return this.encryption
|
590
|
-
.createDataKey('aws', makeOptions(['foobar', 'fizzbuzz']))
|
591
|
-
.then(_dataKey => (dataKey = _dataKey))
|
592
|
-
.then(() =>
|
593
|
-
Promise.all([
|
594
|
-
this.collection.findOne({ keyAltNames: 'foobar' }),
|
595
|
-
this.collection.findOne({ keyAltNames: 'fizzbuzz' })
|
596
|
-
])
|
597
|
-
)
|
598
|
-
.then(docs => {
|
599
|
-
expect(docs).to.have.lengthOf(2);
|
600
|
-
const doc1 = docs[0];
|
601
|
-
const doc2 = docs[1];
|
602
|
-
expect(doc1).to.be.an('object');
|
603
|
-
expect(doc2).to.be.an('object');
|
604
|
-
expect(doc1)
|
605
|
-
.to.have.property('keyAltNames')
|
606
|
-
.that.includes.members(['foobar', 'fizzbuzz']);
|
607
|
-
expect(doc1).to.have.property('_id').that.deep.equals(dataKey);
|
608
|
-
expect(doc2)
|
609
|
-
.to.have.property('keyAltNames')
|
610
|
-
.that.includes.members(['foobar', 'fizzbuzz']);
|
611
|
-
expect(doc2).to.have.property('_id').that.deep.equals(dataKey);
|
612
|
-
});
|
613
|
-
});
|
614
|
-
|
615
|
-
it('should be able to reference a key with `keyAltName` during encryption', function () {
|
616
|
-
let keyId;
|
617
|
-
const keyAltName = 'mySpecialKey';
|
618
|
-
const algorithm = 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic';
|
619
|
-
|
620
|
-
const valueToEncrypt = 'foobar';
|
621
|
-
|
622
|
-
return this.encryption
|
623
|
-
.createDataKey('aws', makeOptions([keyAltName]))
|
624
|
-
.then(_dataKey => (keyId = _dataKey))
|
625
|
-
.then(() => this.encryption.encrypt(valueToEncrypt, { keyId, algorithm }))
|
626
|
-
.then(encryptedValue => {
|
627
|
-
return this.encryption
|
628
|
-
.encrypt(valueToEncrypt, { keyAltName, algorithm })
|
629
|
-
.then(encryptedValue2 => {
|
630
|
-
expect(encryptedValue).to.deep.equal(encryptedValue2);
|
631
|
-
});
|
632
|
-
});
|
633
|
-
});
|
634
|
-
});
|
635
|
-
|
636
|
-
context('with stubbed key material and fixed random source', function () {
|
637
|
-
let sandbox = sinon.createSandbox();
|
638
|
-
|
639
|
-
afterEach(() => {
|
640
|
-
sandbox.restore();
|
641
|
-
});
|
642
|
-
beforeEach(() => {
|
643
|
-
const rndData = Buffer.from(
|
644
|
-
'\x4d\x06\x95\x64\xf5\xa0\x5e\x9e\x35\x23\xb9\x8f\x57\x5a\xcb\x15',
|
645
|
-
'latin1'
|
646
|
-
);
|
647
|
-
let rndPos = 0;
|
648
|
-
sandbox.stub(cryptoCallbacks, 'randomHook').callsFake((buffer, count) => {
|
649
|
-
if (rndPos + count > rndData) {
|
650
|
-
return new Error('Out of fake random data');
|
651
|
-
}
|
652
|
-
buffer.set(rndData.subarray(rndPos, rndPos + count));
|
653
|
-
rndPos += count;
|
654
|
-
return count;
|
655
|
-
});
|
656
|
-
|
657
|
-
// stubbed out for AWS unit testing below
|
658
|
-
sandbox.stub(StateMachine.prototype, 'fetchKeys').callsFake((client, ns, filter, cb) => {
|
659
|
-
filter = deserialize(filter);
|
660
|
-
const keyIds = filter.$or[0]._id.$in.map(key => key.toString('hex'));
|
661
|
-
const fileNames = keyIds.map(
|
662
|
-
keyId => `${__dirname}/../../../test/data/keys/${keyId.toUpperCase()}-local-document.json`
|
663
|
-
);
|
664
|
-
const contents = fileNames.map(filename => EJSON.parse(fs.readFileSync(filename)));
|
665
|
-
cb(null, contents);
|
666
|
-
});
|
667
|
-
});
|
668
|
-
|
669
|
-
// This exactly matches _test_encrypt_fle2_explicit from the C tests
|
670
|
-
it('should explicitly encrypt and decrypt with the "local" KMS provider (FLE2, exact result)', function () {
|
671
|
-
const encryption = new ClientEncryption(new MockClient(), {
|
672
|
-
keyVaultNamespace: 'client.encryption',
|
673
|
-
kmsProviders: { local: { key: Buffer.alloc(96) } }
|
674
|
-
});
|
675
|
-
|
676
|
-
const encryptOptions = {
|
677
|
-
keyId: new Binary(Buffer.from('ABCDEFAB123498761234123456789012', 'hex'), 4),
|
678
|
-
algorithm: 'Unindexed'
|
679
|
-
};
|
680
|
-
|
681
|
-
return encryption
|
682
|
-
.encrypt('value123', encryptOptions)
|
683
|
-
.then(encrypted => {
|
684
|
-
expect(encrypted._bsontype).to.equal('Binary');
|
685
|
-
expect(encrypted.sub_type).to.equal(6);
|
686
|
-
expect(encrypted.toString('base64')).to.equal(
|
687
|
-
'BqvN76sSNJh2EjQSNFZ4kBICTQaVZPWgXp41I7mPV1rLFTtw1tXzjcdSEyxpKKqujlko5TeizkB9hHQ009dVY1+fgIiDcefh+eQrm3CkhQ=='
|
688
|
-
);
|
689
|
-
|
690
|
-
return encryption.decrypt(encrypted);
|
691
|
-
})
|
692
|
-
.then(decrypted => {
|
693
|
-
expect(decrypted).to.equal('value123');
|
694
|
-
});
|
695
|
-
});
|
696
|
-
});
|
697
|
-
|
698
|
-
it('should provide the libmongocrypt version', function () {
|
699
|
-
expect(ClientEncryption.libmongocryptVersion).to.be.a('string');
|
700
|
-
});
|
701
|
-
});
|