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
@@ -14,678 +14,555 @@
|
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
16
|
|
17
|
-
#include <bson/bson.h>
|
18
17
|
#include "mongocrypt-buffer-private.h"
|
19
18
|
#include "mongocrypt-endian-private.h"
|
20
19
|
#include "mongocrypt-util-private.h"
|
20
|
+
#include <bson/bson.h>
|
21
|
+
|
22
|
+
// Require libbson 1.16.0 or newer. Fix for CDRIVER-3360 is needed.
|
23
|
+
#if !BSON_CHECK_VERSION(1, 16, 0)
|
24
|
+
#error "libbson 1.16.0 or newer is required."
|
25
|
+
#endif
|
21
26
|
|
22
27
|
#define INT32_LEN 4
|
23
28
|
#define TYPE_LEN 1
|
24
29
|
#define NULL_BYTE_LEN 1
|
25
30
|
#define NULL_BYTE_VAL 0x00
|
26
31
|
|
27
|
-
|
28
32
|
/* if a buffer is not owned, copy the data and make it owned. */
|
29
|
-
static void
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
buf->owned = true;
|
33
|
+
static void _make_owned(_mongocrypt_buffer_t *buf) {
|
34
|
+
uint8_t *tmp;
|
35
|
+
|
36
|
+
BSON_ASSERT_PARAM(buf);
|
37
|
+
if (buf->owned) {
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
tmp = buf->data;
|
41
|
+
if (buf->len > 0) {
|
42
|
+
buf->data = bson_malloc(buf->len);
|
43
|
+
BSON_ASSERT(buf->data);
|
44
|
+
memcpy(buf->data, tmp, buf->len);
|
45
|
+
} else {
|
46
|
+
buf->data = NULL;
|
47
|
+
}
|
48
|
+
|
49
|
+
buf->owned = true;
|
48
50
|
}
|
49
51
|
|
50
52
|
/* TODO CDRIVER-2990 have buffer operations require initialized buffer to
|
51
53
|
* prevent leaky code. */
|
52
|
-
void
|
53
|
-
|
54
|
-
{
|
55
|
-
BSON_ASSERT_PARAM (buf);
|
54
|
+
void _mongocrypt_buffer_init(_mongocrypt_buffer_t *buf) {
|
55
|
+
BSON_ASSERT_PARAM(buf);
|
56
56
|
|
57
|
-
|
57
|
+
memset(buf, 0, sizeof(*buf));
|
58
58
|
}
|
59
59
|
|
60
|
+
void _mongocrypt_buffer_resize(_mongocrypt_buffer_t *buf, uint32_t len) {
|
61
|
+
BSON_ASSERT_PARAM(buf);
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
63
|
+
/* Currently this just wipes whatever was in data before,
|
64
|
+
but a fancier implementation could copy over up to 'len'
|
65
|
+
bytes from the old buffer to the new one. */
|
66
|
+
if (buf->owned) {
|
67
|
+
buf->data = bson_realloc(buf->data, len);
|
68
|
+
buf->len = len;
|
69
|
+
return;
|
70
|
+
}
|
65
71
|
|
66
|
-
|
67
|
-
|
68
|
-
bytes from the old buffer to the new one. */
|
69
|
-
if (buf->owned) {
|
70
|
-
buf->data = bson_realloc (buf->data, len);
|
71
|
-
buf->len = len;
|
72
|
-
return;
|
73
|
-
}
|
72
|
+
buf->data = bson_malloc(len);
|
73
|
+
BSON_ASSERT(buf->data);
|
74
74
|
|
75
|
-
|
76
|
-
|
75
|
+
buf->len = len;
|
76
|
+
buf->owned = true;
|
77
|
+
}
|
78
|
+
|
79
|
+
void _mongocrypt_buffer_init_size(_mongocrypt_buffer_t *buf, uint32_t len) {
|
80
|
+
BSON_ASSERT_PARAM(buf);
|
77
81
|
|
78
|
-
|
79
|
-
|
82
|
+
_mongocrypt_buffer_init(buf);
|
83
|
+
_mongocrypt_buffer_resize(buf, len);
|
80
84
|
}
|
81
85
|
|
86
|
+
void _mongocrypt_buffer_steal(_mongocrypt_buffer_t *buf, _mongocrypt_buffer_t *src) {
|
87
|
+
BSON_ASSERT_PARAM(buf);
|
88
|
+
BSON_ASSERT_PARAM(src);
|
82
89
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
90
|
+
if (!src->owned) {
|
91
|
+
_mongocrypt_buffer_copy_to(src, buf);
|
92
|
+
_mongocrypt_buffer_init(src);
|
93
|
+
return;
|
94
|
+
}
|
87
95
|
|
88
|
-
|
89
|
-
|
96
|
+
buf->data = src->data;
|
97
|
+
buf->len = src->len;
|
98
|
+
buf->owned = true;
|
99
|
+
_mongocrypt_buffer_init(src);
|
90
100
|
}
|
91
101
|
|
102
|
+
bool _mongocrypt_buffer_from_binary_iter(_mongocrypt_buffer_t *buf, bson_iter_t *iter) {
|
103
|
+
BSON_ASSERT_PARAM(buf);
|
104
|
+
BSON_ASSERT_PARAM(iter);
|
105
|
+
|
106
|
+
if (!BSON_ITER_HOLDS_BINARY(iter)) {
|
107
|
+
return false;
|
108
|
+
}
|
109
|
+
_mongocrypt_buffer_init(buf);
|
110
|
+
bson_iter_binary(iter, &buf->subtype, &buf->len, (const uint8_t **)&buf->data);
|
111
|
+
buf->owned = false;
|
112
|
+
return true;
|
113
|
+
}
|
92
114
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
BSON_ASSERT_PARAM (buf);
|
97
|
-
BSON_ASSERT_PARAM (src);
|
115
|
+
bool _mongocrypt_buffer_copy_from_binary_iter(_mongocrypt_buffer_t *buf, bson_iter_t *iter) {
|
116
|
+
BSON_ASSERT_PARAM(buf);
|
117
|
+
BSON_ASSERT_PARAM(iter);
|
98
118
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
return;
|
103
|
-
}
|
119
|
+
if (!_mongocrypt_buffer_from_binary_iter(buf, iter)) {
|
120
|
+
return false;
|
121
|
+
}
|
104
122
|
|
105
|
-
|
106
|
-
|
107
|
-
buf->owned = true;
|
108
|
-
_mongocrypt_buffer_init (src);
|
123
|
+
_make_owned(buf);
|
124
|
+
return true;
|
109
125
|
}
|
110
126
|
|
111
|
-
bool
|
112
|
-
|
113
|
-
|
114
|
-
{
|
115
|
-
BSON_ASSERT_PARAM (buf);
|
116
|
-
BSON_ASSERT_PARAM (iter);
|
127
|
+
bool _mongocrypt_buffer_from_document_iter(_mongocrypt_buffer_t *buf, bson_iter_t *iter) {
|
128
|
+
BSON_ASSERT_PARAM(buf);
|
129
|
+
BSON_ASSERT_PARAM(iter);
|
117
130
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
return true;
|
131
|
+
if (!BSON_ITER_HOLDS_DOCUMENT(iter)) {
|
132
|
+
return false;
|
133
|
+
}
|
134
|
+
_mongocrypt_buffer_init(buf);
|
135
|
+
bson_iter_document(iter, &buf->len, (const uint8_t **)&buf->data);
|
136
|
+
buf->owned = false;
|
137
|
+
return true;
|
126
138
|
}
|
127
139
|
|
140
|
+
bool _mongocrypt_buffer_copy_from_document_iter(_mongocrypt_buffer_t *buf, bson_iter_t *iter) {
|
141
|
+
BSON_ASSERT_PARAM(buf);
|
142
|
+
BSON_ASSERT_PARAM(iter);
|
128
143
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
144
|
+
if (!_mongocrypt_buffer_from_document_iter(buf, iter)) {
|
145
|
+
return false;
|
146
|
+
}
|
147
|
+
_make_owned(buf);
|
148
|
+
return true;
|
149
|
+
}
|
135
150
|
|
136
|
-
|
137
|
-
|
138
|
-
|
151
|
+
void _mongocrypt_buffer_steal_from_bson(_mongocrypt_buffer_t *buf, bson_t *bson) {
|
152
|
+
BSON_ASSERT_PARAM(buf);
|
153
|
+
BSON_ASSERT_PARAM(bson);
|
139
154
|
|
140
|
-
|
141
|
-
|
155
|
+
_mongocrypt_buffer_init(buf);
|
156
|
+
buf->data = bson_destroy_with_steal(bson, true, &buf->len);
|
157
|
+
buf->owned = true;
|
142
158
|
}
|
143
159
|
|
160
|
+
void _mongocrypt_buffer_from_bson(_mongocrypt_buffer_t *buf, const bson_t *bson) {
|
161
|
+
BSON_ASSERT_PARAM(buf);
|
162
|
+
BSON_ASSERT_PARAM(bson);
|
144
163
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
BSON_ASSERT_PARAM (iter);
|
164
|
+
_mongocrypt_buffer_init(buf);
|
165
|
+
buf->data = (uint8_t *)bson_get_data(bson);
|
166
|
+
buf->len = bson->len;
|
167
|
+
buf->owned = false;
|
168
|
+
}
|
151
169
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
buf->owned = false;
|
158
|
-
return true;
|
170
|
+
bool _mongocrypt_buffer_to_bson(const _mongocrypt_buffer_t *buf, bson_t *bson) {
|
171
|
+
BSON_ASSERT_PARAM(buf);
|
172
|
+
BSON_ASSERT_PARAM(bson);
|
173
|
+
|
174
|
+
return bson_init_static(bson, buf->data, buf->len);
|
159
175
|
}
|
160
176
|
|
177
|
+
bool _mongocrypt_buffer_append(const _mongocrypt_buffer_t *buf, bson_t *bson, const char *key, int key_len) {
|
178
|
+
BSON_ASSERT_PARAM(buf);
|
179
|
+
BSON_ASSERT_PARAM(bson);
|
180
|
+
BSON_ASSERT_PARAM(key);
|
181
|
+
|
182
|
+
return bson_append_binary(bson, key, key_len, buf->subtype, buf->data, buf->len);
|
183
|
+
}
|
161
184
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
{
|
166
|
-
BSON_ASSERT_PARAM (buf);
|
167
|
-
BSON_ASSERT_PARAM (iter);
|
185
|
+
void _mongocrypt_buffer_from_binary(_mongocrypt_buffer_t *buf, const mongocrypt_binary_t *binary) {
|
186
|
+
BSON_ASSERT_PARAM(buf);
|
187
|
+
BSON_ASSERT_PARAM(binary);
|
168
188
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
return true;
|
189
|
+
_mongocrypt_buffer_init(buf);
|
190
|
+
buf->data = binary->data;
|
191
|
+
buf->len = binary->len;
|
192
|
+
buf->owned = false;
|
174
193
|
}
|
175
194
|
|
195
|
+
void _mongocrypt_buffer_copy_from_binary(_mongocrypt_buffer_t *buf, const struct _mongocrypt_binary_t *binary) {
|
196
|
+
BSON_ASSERT_PARAM(buf);
|
197
|
+
BSON_ASSERT_PARAM(binary);
|
176
198
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
199
|
+
_mongocrypt_buffer_from_binary(buf, binary);
|
200
|
+
_make_owned(buf);
|
201
|
+
}
|
202
|
+
|
203
|
+
void _mongocrypt_buffer_to_binary(const _mongocrypt_buffer_t *buf, mongocrypt_binary_t *binary) {
|
204
|
+
BSON_ASSERT_PARAM(buf);
|
205
|
+
BSON_ASSERT_PARAM(binary);
|
182
206
|
|
183
|
-
|
184
|
-
|
185
|
-
buf->owned = true;
|
207
|
+
binary->data = buf->data;
|
208
|
+
binary->len = buf->len;
|
186
209
|
}
|
187
210
|
|
211
|
+
void _mongocrypt_buffer_copy_to(const _mongocrypt_buffer_t *src, _mongocrypt_buffer_t *dst) {
|
212
|
+
if (src == dst) {
|
213
|
+
return;
|
214
|
+
}
|
215
|
+
|
216
|
+
BSON_ASSERT_PARAM(src);
|
217
|
+
BSON_ASSERT_PARAM(dst);
|
188
218
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
BSON_ASSERT_PARAM (bson);
|
219
|
+
_mongocrypt_buffer_cleanup(dst);
|
220
|
+
if (src->len == 0) {
|
221
|
+
return;
|
222
|
+
}
|
194
223
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
224
|
+
dst->data = bson_malloc((size_t)src->len);
|
225
|
+
BSON_ASSERT(dst->data);
|
226
|
+
|
227
|
+
memcpy(dst->data, src->data, src->len);
|
228
|
+
dst->len = src->len;
|
229
|
+
dst->subtype = src->subtype;
|
230
|
+
dst->owned = true;
|
199
231
|
}
|
200
232
|
|
233
|
+
void _mongocrypt_buffer_set_to(const _mongocrypt_buffer_t *src, _mongocrypt_buffer_t *dst) {
|
234
|
+
if (src == dst) {
|
235
|
+
return;
|
236
|
+
}
|
201
237
|
|
202
|
-
|
203
|
-
|
204
|
-
{
|
205
|
-
BSON_ASSERT_PARAM (buf);
|
206
|
-
BSON_ASSERT_PARAM (bson);
|
238
|
+
BSON_ASSERT_PARAM(src);
|
239
|
+
BSON_ASSERT_PARAM(dst);
|
207
240
|
|
208
|
-
|
241
|
+
dst->data = src->data;
|
242
|
+
dst->len = src->len;
|
243
|
+
dst->subtype = src->subtype;
|
244
|
+
dst->owned = false;
|
209
245
|
}
|
210
246
|
|
247
|
+
int _mongocrypt_buffer_cmp(const _mongocrypt_buffer_t *a, const _mongocrypt_buffer_t *b) {
|
248
|
+
BSON_ASSERT_PARAM(a);
|
249
|
+
BSON_ASSERT_PARAM(b);
|
211
250
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
BSON_ASSERT_PARAM (bson);
|
220
|
-
BSON_ASSERT_PARAM (key);
|
221
|
-
|
222
|
-
return bson_append_binary (
|
223
|
-
bson, key, key_len, buf->subtype, buf->data, buf->len);
|
251
|
+
if (a->len != b->len) {
|
252
|
+
return a->len > b->len ? 1 : -1;
|
253
|
+
}
|
254
|
+
if (0 == a->len) {
|
255
|
+
return 0;
|
256
|
+
}
|
257
|
+
return memcmp(a->data, b->data, a->len);
|
224
258
|
}
|
225
259
|
|
260
|
+
void _mongocrypt_buffer_cleanup(_mongocrypt_buffer_t *buf) {
|
261
|
+
if (buf && buf->owned) {
|
262
|
+
bson_free(buf->data);
|
263
|
+
}
|
264
|
+
}
|
226
265
|
|
227
|
-
|
228
|
-
|
229
|
-
const mongocrypt_binary_t *binary)
|
230
|
-
{
|
231
|
-
BSON_ASSERT_PARAM (buf);
|
232
|
-
BSON_ASSERT_PARAM (binary);
|
266
|
+
bool _mongocrypt_buffer_empty(const _mongocrypt_buffer_t *buf) {
|
267
|
+
BSON_ASSERT_PARAM(buf);
|
233
268
|
|
234
|
-
|
235
|
-
buf->data = binary->data;
|
236
|
-
buf->len = binary->len;
|
237
|
-
buf->owned = false;
|
269
|
+
return buf->data == NULL;
|
238
270
|
}
|
239
271
|
|
272
|
+
bool _mongocrypt_buffer_to_bson_value(_mongocrypt_buffer_t *plaintext, uint8_t type, bson_value_t *out) {
|
273
|
+
bool ret = false;
|
274
|
+
bson_iter_t iter;
|
275
|
+
bson_t wrapper;
|
276
|
+
uint32_t data_len;
|
277
|
+
uint32_t le_data_len;
|
278
|
+
uint8_t *data;
|
279
|
+
uint8_t data_prefix;
|
280
|
+
|
281
|
+
BSON_ASSERT_PARAM(plaintext);
|
282
|
+
BSON_ASSERT_PARAM(out);
|
283
|
+
|
284
|
+
data_prefix = INT32_LEN /* adds document size */
|
285
|
+
+ TYPE_LEN /* element type */
|
286
|
+
+ NULL_BYTE_LEN; /* and doc's null byte terminator */
|
240
287
|
|
241
|
-
|
242
|
-
_mongocrypt_buffer_copy_from_binary (_mongocrypt_buffer_t *buf,
|
243
|
-
const struct _mongocrypt_binary_t *binary)
|
244
|
-
{
|
245
|
-
BSON_ASSERT_PARAM (buf);
|
246
|
-
BSON_ASSERT_PARAM (binary);
|
288
|
+
BSON_ASSERT(plaintext->len <= UINT32_MAX - data_prefix - NULL_BYTE_LEN);
|
247
289
|
|
248
|
-
|
249
|
-
|
290
|
+
data_len = (plaintext->len + data_prefix + NULL_BYTE_LEN);
|
291
|
+
le_data_len = BSON_UINT32_TO_LE(data_len);
|
292
|
+
|
293
|
+
data = bson_malloc0(data_len);
|
294
|
+
BSON_ASSERT(data);
|
295
|
+
|
296
|
+
memcpy(data + data_prefix, plaintext->data, plaintext->len);
|
297
|
+
memcpy(data, &le_data_len, INT32_LEN);
|
298
|
+
memcpy(data + INT32_LEN, &type, TYPE_LEN);
|
299
|
+
data[data_len - 1] = NULL_BYTE_VAL;
|
300
|
+
|
301
|
+
if (!bson_init_static(&wrapper, data, data_len)) {
|
302
|
+
goto fail;
|
303
|
+
}
|
304
|
+
|
305
|
+
if (!bson_validate(&wrapper, BSON_VALIDATE_NONE, NULL)) {
|
306
|
+
goto fail;
|
307
|
+
}
|
308
|
+
|
309
|
+
if (!bson_iter_init_find(&iter, &wrapper, "")) {
|
310
|
+
goto fail;
|
311
|
+
}
|
312
|
+
bson_value_copy(bson_iter_value(&iter), out);
|
313
|
+
|
314
|
+
ret = true;
|
315
|
+
fail:
|
316
|
+
bson_free(data);
|
317
|
+
return ret;
|
250
318
|
}
|
251
319
|
|
320
|
+
void _mongocrypt_buffer_from_iter(_mongocrypt_buffer_t *plaintext, bson_iter_t *iter) {
|
321
|
+
bson_t wrapper = BSON_INITIALIZER;
|
322
|
+
int32_t offset = INT32_LEN /* skips document size */
|
323
|
+
+ TYPE_LEN /* element type */
|
324
|
+
+ NULL_BYTE_LEN; /* and the key's null byte terminator */
|
325
|
+
|
326
|
+
uint8_t *wrapper_data;
|
327
|
+
|
328
|
+
BSON_ASSERT_PARAM(plaintext);
|
329
|
+
BSON_ASSERT_PARAM(iter);
|
330
|
+
|
331
|
+
/* It is not straightforward to transform a bson_value_t to a string of
|
332
|
+
* bytes. As a workaround, we wrap the value in a bson document with an empty
|
333
|
+
* key, then use the raw buffer from inside the new bson_t, skipping the
|
334
|
+
* length and type header information and the key name. */
|
335
|
+
bson_append_iter(&wrapper, "", 0, iter);
|
336
|
+
wrapper_data = ((uint8_t *)bson_get_data(&wrapper));
|
337
|
+
BSON_ASSERT(wrapper.len >= (uint32_t)offset + NULL_BYTE_LEN);
|
338
|
+
plaintext->len = wrapper.len - (uint32_t)offset - NULL_BYTE_LEN; /* the final null byte */
|
339
|
+
plaintext->data = bson_malloc(plaintext->len);
|
340
|
+
BSON_ASSERT(plaintext->data);
|
252
341
|
|
253
|
-
|
254
|
-
|
255
|
-
mongocrypt_binary_t *binary)
|
256
|
-
{
|
257
|
-
BSON_ASSERT_PARAM (buf);
|
258
|
-
BSON_ASSERT_PARAM (binary);
|
342
|
+
plaintext->owned = true;
|
343
|
+
memcpy(plaintext->data, wrapper_data + offset, plaintext->len);
|
259
344
|
|
260
|
-
|
261
|
-
binary->len = buf->len;
|
345
|
+
bson_destroy(&wrapper);
|
262
346
|
}
|
263
347
|
|
348
|
+
bool _mongocrypt_buffer_from_uuid_iter(_mongocrypt_buffer_t *buf, bson_iter_t *iter) {
|
349
|
+
const uint8_t *data;
|
350
|
+
bson_subtype_t subtype;
|
351
|
+
uint32_t len;
|
264
352
|
|
265
|
-
|
266
|
-
|
267
|
-
_mongocrypt_buffer_t *dst)
|
268
|
-
{
|
269
|
-
if (src == dst) {
|
270
|
-
return;
|
271
|
-
}
|
353
|
+
BSON_ASSERT_PARAM(buf);
|
354
|
+
BSON_ASSERT_PARAM(iter);
|
272
355
|
|
273
|
-
|
274
|
-
|
356
|
+
if (!BSON_ITER_HOLDS_BINARY(iter)) {
|
357
|
+
return false;
|
358
|
+
}
|
359
|
+
bson_iter_binary(iter, &subtype, &len, &data);
|
360
|
+
if (subtype != BSON_SUBTYPE_UUID) {
|
361
|
+
return false;
|
362
|
+
}
|
363
|
+
if (len != UUID_LEN) {
|
364
|
+
return false;
|
365
|
+
}
|
366
|
+
_mongocrypt_buffer_init(buf);
|
367
|
+
buf->data = (uint8_t *)data;
|
368
|
+
buf->len = len;
|
369
|
+
buf->subtype = subtype;
|
370
|
+
buf->owned = false;
|
371
|
+
return true;
|
372
|
+
}
|
373
|
+
|
374
|
+
bool _mongocrypt_buffer_copy_from_uuid_iter(_mongocrypt_buffer_t *buf, bson_iter_t *iter) {
|
375
|
+
BSON_ASSERT_PARAM(buf);
|
376
|
+
BSON_ASSERT_PARAM(iter);
|
275
377
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
378
|
+
if (!_mongocrypt_buffer_from_uuid_iter(buf, iter)) {
|
379
|
+
return false;
|
380
|
+
}
|
381
|
+
_make_owned(buf);
|
382
|
+
return true;
|
383
|
+
}
|
280
384
|
|
281
|
-
|
282
|
-
|
385
|
+
bool _mongocrypt_buffer_is_uuid(_mongocrypt_buffer_t *buf) {
|
386
|
+
BSON_ASSERT_PARAM(buf);
|
283
387
|
|
284
|
-
|
285
|
-
dst->len = src->len;
|
286
|
-
dst->subtype = src->subtype;
|
287
|
-
dst->owned = true;
|
388
|
+
return buf->len == UUID_LEN && buf->subtype == BSON_SUBTYPE_UUID;
|
288
389
|
}
|
289
390
|
|
391
|
+
void _mongocrypt_buffer_copy_from_hex(_mongocrypt_buffer_t *buf, const char *hex) {
|
392
|
+
uint32_t i;
|
393
|
+
size_t hex_len;
|
394
|
+
|
395
|
+
BSON_ASSERT_PARAM(buf);
|
396
|
+
BSON_ASSERT_PARAM(hex);
|
290
397
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
return;
|
297
|
-
}
|
398
|
+
hex_len = strlen(hex);
|
399
|
+
if (hex_len == 0) {
|
400
|
+
_mongocrypt_buffer_init(buf);
|
401
|
+
return;
|
402
|
+
}
|
298
403
|
|
299
|
-
|
300
|
-
|
404
|
+
BSON_ASSERT(hex_len / 2u <= UINT32_MAX);
|
405
|
+
buf->len = (uint32_t)(hex_len / 2u);
|
406
|
+
buf->data = bson_malloc(buf->len);
|
407
|
+
BSON_ASSERT(buf->data);
|
301
408
|
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
409
|
+
buf->owned = true;
|
410
|
+
for (i = 0; i < buf->len; i++) {
|
411
|
+
uint32_t tmp;
|
412
|
+
BSON_ASSERT(i <= UINT32_MAX / 2);
|
413
|
+
BSON_ASSERT(sscanf(hex + (2 * i), "%02x", &tmp));
|
414
|
+
*(buf->data + i) = (uint8_t)tmp;
|
415
|
+
}
|
306
416
|
}
|
307
417
|
|
418
|
+
int _mongocrypt_buffer_cmp_hex(_mongocrypt_buffer_t *buf, const char *hex) {
|
419
|
+
_mongocrypt_buffer_t tmp;
|
420
|
+
int res;
|
308
421
|
|
309
|
-
|
310
|
-
|
311
|
-
const _mongocrypt_buffer_t *b)
|
312
|
-
{
|
313
|
-
BSON_ASSERT_PARAM (a);
|
314
|
-
BSON_ASSERT_PARAM (b);
|
422
|
+
BSON_ASSERT_PARAM(buf);
|
423
|
+
BSON_ASSERT_PARAM(hex);
|
315
424
|
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
return 0;
|
321
|
-
}
|
322
|
-
return memcmp (a->data, b->data, a->len);
|
425
|
+
_mongocrypt_buffer_copy_from_hex(&tmp, hex);
|
426
|
+
res = _mongocrypt_buffer_cmp(buf, &tmp);
|
427
|
+
_mongocrypt_buffer_cleanup(&tmp);
|
428
|
+
return res;
|
323
429
|
}
|
324
430
|
|
431
|
+
char *_mongocrypt_buffer_to_hex(_mongocrypt_buffer_t *buf) {
|
432
|
+
BSON_ASSERT_PARAM(buf);
|
433
|
+
/* since buf->len is a uint32_t, even doubling it won't bring it anywhere
|
434
|
+
* near to SIZE_MAX */
|
325
435
|
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
436
|
+
char *hex = bson_malloc0(buf->len * 2 + 1);
|
437
|
+
BSON_ASSERT(hex);
|
438
|
+
|
439
|
+
char *out = hex;
|
440
|
+
|
441
|
+
for (uint32_t i = 0; i < buf->len; i++, out += 2) {
|
442
|
+
sprintf(out, "%02X", buf->data[i]);
|
443
|
+
}
|
444
|
+
return hex;
|
332
445
|
}
|
333
446
|
|
447
|
+
bool _mongocrypt_buffer_concat(_mongocrypt_buffer_t *dst, const _mongocrypt_buffer_t *srcs, uint32_t num_srcs) {
|
448
|
+
uint32_t total = 0;
|
449
|
+
uint32_t offset;
|
450
|
+
uint32_t i;
|
451
|
+
|
452
|
+
BSON_ASSERT_PARAM(dst);
|
453
|
+
BSON_ASSERT_PARAM(srcs);
|
334
454
|
|
335
|
-
|
336
|
-
|
337
|
-
{
|
338
|
-
BSON_ASSERT_PARAM (buf);
|
455
|
+
for (i = 0; i < num_srcs; i++) {
|
456
|
+
uint32_t old_total = total;
|
339
457
|
|
340
|
-
|
458
|
+
total += srcs[i].len;
|
459
|
+
/* If the previous operation overflowed, then total will have a smaller
|
460
|
+
* value than previously. */
|
461
|
+
if (total < old_total) {
|
462
|
+
return false;
|
463
|
+
}
|
464
|
+
}
|
465
|
+
|
466
|
+
_mongocrypt_buffer_init(dst);
|
467
|
+
_mongocrypt_buffer_resize(dst, total);
|
468
|
+
offset = 0;
|
469
|
+
for (i = 0; i < num_srcs; i++) {
|
470
|
+
if (srcs[i].len) {
|
471
|
+
memcpy(dst->data + offset, srcs[i].data, srcs[i].len);
|
472
|
+
}
|
473
|
+
offset += srcs[i].len;
|
474
|
+
}
|
475
|
+
return true;
|
341
476
|
}
|
342
477
|
|
343
|
-
|
344
|
-
|
345
|
-
uint8_t type,
|
346
|
-
bson_value_t *out)
|
347
|
-
{
|
348
|
-
bool ret = false;
|
349
|
-
bson_iter_t iter;
|
350
|
-
bson_t wrapper;
|
351
|
-
uint32_t data_len;
|
352
|
-
uint32_t le_data_len;
|
353
|
-
uint8_t *data;
|
354
|
-
uint8_t data_prefix;
|
478
|
+
struct _mongocrypt_binary_t *_mongocrypt_buffer_as_binary(_mongocrypt_buffer_t *buf) {
|
479
|
+
BSON_ASSERT_PARAM(buf);
|
355
480
|
|
356
|
-
|
357
|
-
|
481
|
+
buf->bin.data = buf->data;
|
482
|
+
buf->bin.len = buf->len;
|
483
|
+
return &buf->bin;
|
484
|
+
}
|
358
485
|
|
359
|
-
|
360
|
-
|
361
|
-
|
486
|
+
bool _mongocrypt_buffer_copy_from_data_and_size(_mongocrypt_buffer_t *buf, const uint8_t *data, size_t len) {
|
487
|
+
BSON_ASSERT_PARAM(buf);
|
488
|
+
BSON_ASSERT_PARAM(data);
|
362
489
|
|
363
|
-
|
490
|
+
_mongocrypt_buffer_init(buf);
|
364
491
|
|
365
|
-
|
366
|
-
|
492
|
+
if (!size_to_uint32(len, &buf->len)) {
|
493
|
+
return false;
|
494
|
+
}
|
367
495
|
|
368
|
-
|
369
|
-
|
496
|
+
if ((buf->data = bson_malloc(len))) {
|
497
|
+
memcpy(buf->data, data, len);
|
498
|
+
buf->owned = true;
|
499
|
+
}
|
370
500
|
|
371
|
-
|
372
|
-
|
373
|
-
memcpy (data + INT32_LEN, &type, TYPE_LEN);
|
374
|
-
data[data_len - 1] = NULL_BYTE_VAL;
|
501
|
+
return true;
|
502
|
+
}
|
375
503
|
|
376
|
-
|
377
|
-
|
378
|
-
|
504
|
+
bool _mongocrypt_buffer_steal_from_data_and_size(_mongocrypt_buffer_t *buf, uint8_t *data, size_t len) {
|
505
|
+
BSON_ASSERT_PARAM(buf);
|
506
|
+
BSON_ASSERT_PARAM(data);
|
379
507
|
|
380
|
-
|
381
|
-
|
382
|
-
|
508
|
+
_mongocrypt_buffer_init(buf);
|
509
|
+
if (!size_to_uint32(len, &buf->len)) {
|
510
|
+
return false;
|
511
|
+
}
|
512
|
+
buf->data = data;
|
513
|
+
buf->owned = true;
|
514
|
+
return true;
|
515
|
+
}
|
383
516
|
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
bson_value_copy (bson_iter_value (&iter), out);
|
517
|
+
bool _mongocrypt_buffer_steal_from_string(_mongocrypt_buffer_t *buf, char *str) {
|
518
|
+
BSON_ASSERT_PARAM(buf);
|
519
|
+
BSON_ASSERT_PARAM(str);
|
388
520
|
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
521
|
+
_mongocrypt_buffer_init(buf);
|
522
|
+
if (!size_to_uint32(strlen(str), &buf->len)) {
|
523
|
+
return false;
|
524
|
+
}
|
525
|
+
buf->data = (uint8_t *)str;
|
526
|
+
buf->owned = true;
|
527
|
+
return true;
|
528
|
+
}
|
397
529
|
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
bool
|
438
|
-
_mongocrypt_buffer_from_uuid_iter (_mongocrypt_buffer_t *buf, bson_iter_t *iter)
|
439
|
-
{
|
440
|
-
const uint8_t *data;
|
441
|
-
bson_subtype_t subtype;
|
442
|
-
uint32_t len;
|
443
|
-
|
444
|
-
BSON_ASSERT_PARAM (buf);
|
445
|
-
BSON_ASSERT_PARAM (iter);
|
446
|
-
|
447
|
-
if (!BSON_ITER_HOLDS_BINARY (iter)) {
|
448
|
-
return false;
|
449
|
-
}
|
450
|
-
bson_iter_binary (iter, &subtype, &len, &data);
|
451
|
-
if (subtype != BSON_SUBTYPE_UUID) {
|
452
|
-
return false;
|
453
|
-
}
|
454
|
-
if (len != UUID_LEN) {
|
455
|
-
return false;
|
456
|
-
}
|
457
|
-
_mongocrypt_buffer_init (buf);
|
458
|
-
buf->data = (uint8_t *) data;
|
459
|
-
buf->len = len;
|
460
|
-
buf->subtype = subtype;
|
461
|
-
buf->owned = false;
|
462
|
-
return true;
|
463
|
-
}
|
464
|
-
|
465
|
-
|
466
|
-
bool
|
467
|
-
_mongocrypt_buffer_copy_from_uuid_iter (_mongocrypt_buffer_t *buf,
|
468
|
-
bson_iter_t *iter)
|
469
|
-
{
|
470
|
-
BSON_ASSERT_PARAM (buf);
|
471
|
-
BSON_ASSERT_PARAM (iter);
|
472
|
-
|
473
|
-
if (!_mongocrypt_buffer_from_uuid_iter (buf, iter)) {
|
474
|
-
return false;
|
475
|
-
}
|
476
|
-
_make_owned (buf);
|
477
|
-
return true;
|
478
|
-
}
|
479
|
-
|
480
|
-
bool
|
481
|
-
_mongocrypt_buffer_is_uuid (_mongocrypt_buffer_t *buf)
|
482
|
-
{
|
483
|
-
BSON_ASSERT_PARAM (buf);
|
484
|
-
|
485
|
-
return buf->len == UUID_LEN && buf->subtype == BSON_SUBTYPE_UUID;
|
486
|
-
}
|
487
|
-
|
488
|
-
void
|
489
|
-
_mongocrypt_buffer_copy_from_hex (_mongocrypt_buffer_t *buf, const char *hex)
|
490
|
-
{
|
491
|
-
uint32_t i;
|
492
|
-
size_t hex_len;
|
493
|
-
|
494
|
-
BSON_ASSERT_PARAM (buf);
|
495
|
-
BSON_ASSERT_PARAM (hex);
|
496
|
-
|
497
|
-
hex_len = strlen (hex);
|
498
|
-
if (hex_len == 0) {
|
499
|
-
_mongocrypt_buffer_init (buf);
|
500
|
-
return;
|
501
|
-
}
|
502
|
-
|
503
|
-
BSON_ASSERT (hex_len / 2u <= UINT32_MAX);
|
504
|
-
buf->len = (uint32_t) (hex_len / 2u);
|
505
|
-
buf->data = bson_malloc (buf->len);
|
506
|
-
BSON_ASSERT (buf->data);
|
507
|
-
|
508
|
-
buf->owned = true;
|
509
|
-
for (i = 0; i < buf->len; i++) {
|
510
|
-
uint32_t tmp;
|
511
|
-
BSON_ASSERT (i <= UINT32_MAX / 2);
|
512
|
-
BSON_ASSERT (sscanf (hex + (2 * i), "%02x", &tmp));
|
513
|
-
*(buf->data + i) = (uint8_t) tmp;
|
514
|
-
}
|
515
|
-
}
|
516
|
-
|
517
|
-
int
|
518
|
-
_mongocrypt_buffer_cmp_hex (_mongocrypt_buffer_t *buf, const char *hex)
|
519
|
-
{
|
520
|
-
_mongocrypt_buffer_t tmp;
|
521
|
-
int res;
|
522
|
-
|
523
|
-
BSON_ASSERT_PARAM (buf);
|
524
|
-
BSON_ASSERT_PARAM (hex);
|
525
|
-
|
526
|
-
_mongocrypt_buffer_copy_from_hex (&tmp, hex);
|
527
|
-
res = _mongocrypt_buffer_cmp (buf, &tmp);
|
528
|
-
_mongocrypt_buffer_cleanup (&tmp);
|
529
|
-
return res;
|
530
|
-
}
|
531
|
-
|
532
|
-
char *
|
533
|
-
_mongocrypt_buffer_to_hex (_mongocrypt_buffer_t *buf)
|
534
|
-
{
|
535
|
-
BSON_ASSERT_PARAM (buf);
|
536
|
-
/* since buf->len is a uint32_t, even doubling it won't bring it anywhere
|
537
|
-
* near to SIZE_MAX */
|
538
|
-
|
539
|
-
char *hex = bson_malloc0 (buf->len * 2 + 1);
|
540
|
-
BSON_ASSERT (hex);
|
541
|
-
|
542
|
-
char *out = hex;
|
543
|
-
|
544
|
-
for (uint32_t i = 0; i < buf->len; i++, out += 2) {
|
545
|
-
sprintf (out, "%02X", buf->data[i]);
|
546
|
-
}
|
547
|
-
return hex;
|
548
|
-
}
|
549
|
-
|
550
|
-
bool
|
551
|
-
_mongocrypt_buffer_concat (_mongocrypt_buffer_t *dst,
|
552
|
-
const _mongocrypt_buffer_t *srcs,
|
553
|
-
uint32_t num_srcs)
|
554
|
-
{
|
555
|
-
uint32_t total = 0;
|
556
|
-
uint32_t offset;
|
557
|
-
uint32_t i;
|
558
|
-
|
559
|
-
BSON_ASSERT_PARAM (dst);
|
560
|
-
BSON_ASSERT_PARAM (srcs);
|
561
|
-
|
562
|
-
for (i = 0; i < num_srcs; i++) {
|
563
|
-
uint32_t old_total = total;
|
564
|
-
|
565
|
-
total += srcs[i].len;
|
566
|
-
/* If the previous operation overflowed, then total will have a smaller
|
567
|
-
* value than previously. */
|
568
|
-
if (total < old_total) {
|
569
|
-
return false;
|
570
|
-
}
|
571
|
-
}
|
572
|
-
|
573
|
-
_mongocrypt_buffer_init (dst);
|
574
|
-
_mongocrypt_buffer_resize (dst, total);
|
575
|
-
offset = 0;
|
576
|
-
for (i = 0; i < num_srcs; i++) {
|
577
|
-
if (srcs[i].len) {
|
578
|
-
memcpy (dst->data + offset, srcs[i].data, srcs[i].len);
|
579
|
-
}
|
580
|
-
offset += srcs[i].len;
|
581
|
-
}
|
582
|
-
return true;
|
583
|
-
}
|
584
|
-
|
585
|
-
struct _mongocrypt_binary_t *
|
586
|
-
_mongocrypt_buffer_as_binary (_mongocrypt_buffer_t *buf)
|
587
|
-
{
|
588
|
-
BSON_ASSERT_PARAM (buf);
|
589
|
-
|
590
|
-
buf->bin.data = buf->data;
|
591
|
-
buf->bin.len = buf->len;
|
592
|
-
return &buf->bin;
|
593
|
-
}
|
594
|
-
|
595
|
-
bool
|
596
|
-
_mongocrypt_buffer_copy_from_data_and_size (_mongocrypt_buffer_t *buf,
|
597
|
-
const uint8_t *data,
|
598
|
-
size_t len)
|
599
|
-
{
|
600
|
-
BSON_ASSERT_PARAM (buf);
|
601
|
-
BSON_ASSERT_PARAM (data);
|
602
|
-
|
603
|
-
_mongocrypt_buffer_init (buf);
|
604
|
-
|
605
|
-
if (!size_to_uint32 (len, &buf->len)) {
|
606
|
-
return false;
|
607
|
-
}
|
608
|
-
buf->data = bson_malloc (len);
|
609
|
-
memcpy (buf->data, data, len);
|
610
|
-
buf->owned = true;
|
611
|
-
return true;
|
612
|
-
}
|
613
|
-
|
614
|
-
bool
|
615
|
-
_mongocrypt_buffer_steal_from_data_and_size (_mongocrypt_buffer_t *buf,
|
616
|
-
uint8_t *data,
|
617
|
-
size_t len)
|
618
|
-
{
|
619
|
-
BSON_ASSERT_PARAM (buf);
|
620
|
-
BSON_ASSERT_PARAM (data);
|
621
|
-
|
622
|
-
_mongocrypt_buffer_init (buf);
|
623
|
-
if (!size_to_uint32 (len, &buf->len)) {
|
624
|
-
return false;
|
625
|
-
}
|
626
|
-
buf->data = data;
|
627
|
-
buf->owned = true;
|
628
|
-
return true;
|
629
|
-
}
|
630
|
-
|
631
|
-
bool
|
632
|
-
_mongocrypt_buffer_steal_from_string (_mongocrypt_buffer_t *buf, char *str)
|
633
|
-
{
|
634
|
-
BSON_ASSERT_PARAM (buf);
|
635
|
-
BSON_ASSERT_PARAM (str);
|
636
|
-
|
637
|
-
_mongocrypt_buffer_init (buf);
|
638
|
-
if (!size_to_uint32 (strlen (str), &buf->len)) {
|
639
|
-
return false;
|
640
|
-
}
|
641
|
-
buf->data = (uint8_t *) str;
|
642
|
-
buf->owned = true;
|
643
|
-
return true;
|
644
|
-
}
|
645
|
-
|
646
|
-
bool
|
647
|
-
_mongocrypt_buffer_from_string (_mongocrypt_buffer_t *buf, const char *str)
|
648
|
-
{
|
649
|
-
BSON_ASSERT_PARAM (buf);
|
650
|
-
BSON_ASSERT_PARAM (str);
|
651
|
-
|
652
|
-
_mongocrypt_buffer_init (buf);
|
653
|
-
if (!size_to_uint32 (strlen (str), &buf->len)) {
|
654
|
-
return false;
|
655
|
-
}
|
656
|
-
buf->data = (uint8_t *) str;
|
657
|
-
buf->owned = false;
|
658
|
-
return true;
|
659
|
-
}
|
660
|
-
|
661
|
-
void
|
662
|
-
_mongocrypt_buffer_copy_from_uint64_le (_mongocrypt_buffer_t *buf,
|
663
|
-
uint64_t value)
|
664
|
-
{
|
665
|
-
uint64_t value_le = MONGOCRYPT_UINT64_TO_LE (value);
|
666
|
-
|
667
|
-
BSON_ASSERT_PARAM (buf);
|
668
|
-
|
669
|
-
_mongocrypt_buffer_init (buf);
|
670
|
-
_mongocrypt_buffer_resize (buf, sizeof (value));
|
671
|
-
memcpy (buf->data, &value_le, buf->len);
|
672
|
-
}
|
673
|
-
|
674
|
-
bool
|
675
|
-
_mongocrypt_buffer_from_subrange (_mongocrypt_buffer_t *out,
|
676
|
-
const _mongocrypt_buffer_t *in,
|
677
|
-
uint32_t offset,
|
678
|
-
uint32_t len)
|
679
|
-
{
|
680
|
-
BSON_ASSERT_PARAM (out);
|
681
|
-
BSON_ASSERT_PARAM (in);
|
682
|
-
|
683
|
-
_mongocrypt_buffer_init (out);
|
684
|
-
BSON_ASSERT (offset <= UINT32_MAX - len);
|
685
|
-
if (offset + len > in->len) {
|
686
|
-
return false;
|
687
|
-
}
|
688
|
-
out->data = in->data + offset;
|
689
|
-
out->len = len;
|
690
|
-
return true;
|
530
|
+
bool _mongocrypt_buffer_from_string(_mongocrypt_buffer_t *buf, const char *str) {
|
531
|
+
BSON_ASSERT_PARAM(buf);
|
532
|
+
BSON_ASSERT_PARAM(str);
|
533
|
+
|
534
|
+
_mongocrypt_buffer_init(buf);
|
535
|
+
if (!size_to_uint32(strlen(str), &buf->len)) {
|
536
|
+
return false;
|
537
|
+
}
|
538
|
+
buf->data = (uint8_t *)str;
|
539
|
+
buf->owned = false;
|
540
|
+
return true;
|
541
|
+
}
|
542
|
+
|
543
|
+
void _mongocrypt_buffer_copy_from_uint64_le(_mongocrypt_buffer_t *buf, uint64_t value) {
|
544
|
+
uint64_t value_le = MONGOCRYPT_UINT64_TO_LE(value);
|
545
|
+
|
546
|
+
BSON_ASSERT_PARAM(buf);
|
547
|
+
|
548
|
+
_mongocrypt_buffer_init(buf);
|
549
|
+
_mongocrypt_buffer_resize(buf, sizeof(value));
|
550
|
+
memcpy(buf->data, &value_le, buf->len);
|
551
|
+
}
|
552
|
+
|
553
|
+
bool _mongocrypt_buffer_from_subrange(_mongocrypt_buffer_t *out,
|
554
|
+
const _mongocrypt_buffer_t *in,
|
555
|
+
uint32_t offset,
|
556
|
+
uint32_t len) {
|
557
|
+
BSON_ASSERT_PARAM(out);
|
558
|
+
BSON_ASSERT_PARAM(in);
|
559
|
+
|
560
|
+
_mongocrypt_buffer_init(out);
|
561
|
+
BSON_ASSERT(offset <= UINT32_MAX - len);
|
562
|
+
if (offset + len > in->len) {
|
563
|
+
return false;
|
564
|
+
}
|
565
|
+
out->data = in->data + offset;
|
566
|
+
out->len = len;
|
567
|
+
return true;
|
691
568
|
}
|