libmongocrypt-helper 1.8.0.0.1001 → 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 +33 -0
- data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +12 -1
- data/ext/libmongocrypt/libmongocrypt/CODEOWNERS +1 -4
- data/ext/libmongocrypt/libmongocrypt/Earthfile +151 -3
- 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/CryptClientFactory.cs +8 -4
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Library.cs +10 -0
- 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.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 +21 -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 +21 -6
- 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 +44 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/encrypted-payload.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/rangeopts.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/README.md +4 -900
- data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +60 -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 +107 -61
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/compat.py +6 -4
- 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 -238
- 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/{test-requirements.txt → requirements-test.txt} +4 -1
- 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 +1 -0
- 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 +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit-v2/int32/rangeopts.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-rangePreview-explicit/int32/rangeopts.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-rangePreview-explicit/int32/value-to-encrypt.json +20 -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 +988 -340
- 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 +23 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/IntelDFP.cmake +19 -227
- data/ext/libmongocrypt/libmongocrypt/cmake/Patch.cmake +54 -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/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/format.sh +1 -1
- 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/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/libcrypto.c +13 -10
- data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.h +1 -1
- data/ext/libmongocrypt/libmongocrypt/src/mc-efc-private.h +16 -2
- data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +94 -6
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +15 -5
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +114 -53
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private-v2.h +1 -1
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private.h +1 -1
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-v2.c +2 -2
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload.c +2 -2
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private-v2.h +21 -6
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private.h +5 -5
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-v2.c +38 -2
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload.c +1 -1
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private-v2.h +20 -7
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private.h +8 -8
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-v2.c +89 -1
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-v2.c +3 -3
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev.c +1 -23
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds-private.h +4 -3
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +15 -12
- data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +11 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +16 -6
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +64 -22
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +23 -4
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +359 -65
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +26 -14
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +17 -6
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +31 -13
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +16 -3
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +259 -63
- data/ext/libmongocrypt/libmongocrypt/src/mc-tokens-private.h +40 -24
- data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +57 -13
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.h +17 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +5 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary-private.h +0 -5
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer.c +5 -7
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key.c +1 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth-private.h +16 -18
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth.c +105 -76
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto.c +9 -3
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +170 -89
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +5 -5
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +505 -124
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-private.h +31 -6
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +81 -13
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +7 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek-private.h +5 -1
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek.c +161 -103
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker-private.h +2 -7
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +191 -69
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key.c +1 -1
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx-private.h +50 -15
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx.c +365 -69
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking-private.h +2 -1
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +200 -107
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +50 -5
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +591 -15
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +6 -13
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util.c +3 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +47 -234
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +75 -24
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +18 -2
- data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +4 -0
- 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-explain/with-csfle/collinfo.json +4 -4
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/encrypted-payload.json +3 -3
- 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/tokens/README.md +7 -4
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/mc.json +9 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/server.json +9 -5
- data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +1 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-gcp-auth.c +8 -8
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-efc.c +6 -4
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-range-payload-v2.c +43 -3
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup-v2.c +76 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-rfds.c +5 -5
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-edge-generation.c +89 -14
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +342 -76
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +94 -12
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +205 -7
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +49 -23
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +16 -19
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.h +22 -1
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache-oauth.c +94 -11
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cleanup.c +374 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-compact.c +121 -42
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +134 -4
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +40 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.h +16 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-csfle-lib.c +11 -11
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-decrypt.c +8 -5
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +922 -92
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +2 -2
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +114 -12
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +14 -9
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-ctx.c +424 -3
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-log.c +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-marking.c +447 -28
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-opts.c +42 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-traverse-util.c +30 -26
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.c +7 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.h +3 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +66 -14
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +11 -0
- 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 +4 -0
- data/ext/libmongocrypt/libmongocrypt/test/util/make_includes.py +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/util/util.c +38 -3
- data/lib/libmongocrypt_helper/version.rb +2 -2
- metadata +112 -106
- checksums.yaml.gz.sig +0 -0
- data/ext/libmongocrypt/libmongocrypt/VERSION_CURRENT +0 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/cs.sln +0 -79
- data/ext/libmongocrypt/libmongocrypt/bindings/node/CHANGELOG.md +0 -105
- 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 -36
- data/ext/libmongocrypt/libmongocrypt/bindings/node/index.d.ts +0 -641
- 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 -821
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/common.js +0 -98
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/cryptoCallbacks.js +0 -87
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/errors.js +0 -75
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/index.js +0 -73
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/mongocryptdManager.js +0 -66
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/aws.js +0 -26
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/azure.js +0 -178
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/gcp.js +0 -24
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/index.js +0 -54
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/utils.js +0 -39
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/stateMachine.js +0 -492
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package-lock.json +0 -15302
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package.json +0 -100
- data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.cc +0 -956
- data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.h +0 -114
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/autoEncrypter.test.js +0 -950
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/buffer_pool.test.js +0 -91
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/clientEncryption.test.js +0 -1093
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/common.test.js +0 -94
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/cryptoCallbacks.test.js +0 -240
- 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/index.test.js +0 -45
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/mongocryptdManager.test.js +0 -48
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/providers/credentialsProvider.test.js +0 -551
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/release.test.js +0 -66
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/requirements.helper.js +0 -51
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/stateMachine.test.js +0 -331
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/chai-addons.js +0 -8
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/mongodb_reporter.js +0 -325
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/types/index.test-d.ts +0 -63
- data/ext/libmongocrypt/libmongocrypt/bindings/python/setup.py +0 -89
- 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/compact/success/mongocryptd-reply.json +0 -72
- data.tar.gz.sig +0 -1
- metadata.gz.sig +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
@@ -162,8 +162,131 @@ bool mc_getTypeInfo64(mc_getTypeInfo64_args_t args, mc_OSTType_Int64 *out, mongo
|
|
162
162
|
}
|
163
163
|
|
164
164
|
#define exp10Double(x) pow(10, x)
|
165
|
+
#define SCALED_DOUBLE_BOUNDS 9007199254740992.0 // 2^53
|
166
|
+
|
167
|
+
uint64_t subtract_int64_t(int64_t max, int64_t min) {
|
168
|
+
BSON_ASSERT(max > min);
|
169
|
+
// If the values have the same sign, then simple subtraction
|
170
|
+
// will work because we know max > min.
|
171
|
+
if ((max > 0 && min > 0) || (max < 0 && min < 0)) {
|
172
|
+
return (uint64_t)(max - min);
|
173
|
+
}
|
174
|
+
|
175
|
+
// If they are opposite signs, then we can just invert
|
176
|
+
// min to be positive and return the sum.
|
177
|
+
uint64_t u_return = (uint64_t)max;
|
178
|
+
u_return += (uint64_t)(~min + 1);
|
179
|
+
return u_return;
|
180
|
+
}
|
181
|
+
|
182
|
+
bool ceil_log2_double(uint64_t i, uint32_t *maxBitsOut, mongocrypt_status_t *status) {
|
183
|
+
if (i == 0) {
|
184
|
+
CLIENT_ERR("Invalid input to ceil_log2_double function. Input cannot be 0.");
|
185
|
+
return false;
|
186
|
+
}
|
187
|
+
|
188
|
+
uint32_t clz = (uint32_t)_mlibCountLeadingZeros_u64(i);
|
189
|
+
uint32_t bits;
|
190
|
+
if ((i & (i - 1)) == 0) {
|
191
|
+
bits = 64 - clz - 1;
|
192
|
+
} else {
|
193
|
+
bits = 64 - clz;
|
194
|
+
}
|
195
|
+
*maxBitsOut = bits;
|
196
|
+
return true;
|
197
|
+
}
|
198
|
+
|
199
|
+
bool mc_canUsePrecisionModeDouble(double min,
|
200
|
+
double max,
|
201
|
+
int32_t precision,
|
202
|
+
uint32_t *maxBitsOut,
|
203
|
+
mongocrypt_status_t *status) {
|
204
|
+
BSON_ASSERT_PARAM(maxBitsOut);
|
205
|
+
BSON_ASSERT(precision >= 0);
|
206
|
+
|
207
|
+
if (min >= max) {
|
208
|
+
CLIENT_ERR("Invalid bounds for double range precision, min must be less than max. min: %g, max: %g", min, max);
|
209
|
+
return false;
|
210
|
+
}
|
211
|
+
|
212
|
+
const double scaled_prc = exp10Double(precision);
|
213
|
+
|
214
|
+
const double scaled_max = max * scaled_prc;
|
215
|
+
const double scaled_min = min * scaled_prc;
|
216
|
+
|
217
|
+
if (scaled_max != trunc(scaled_max)) {
|
218
|
+
CLIENT_ERR("Invalid upper bound for double precision. Fractional digits must be less than the specified "
|
219
|
+
"precision value. max: %g",
|
220
|
+
max);
|
221
|
+
return false;
|
222
|
+
}
|
223
|
+
|
224
|
+
if (scaled_min != trunc(scaled_min)) {
|
225
|
+
CLIENT_ERR("Invalid lower bound for double precision. Fractional digits must be less than the specified "
|
226
|
+
"precision value. min: %g",
|
227
|
+
min);
|
228
|
+
return false;
|
229
|
+
}
|
230
|
+
|
231
|
+
if (fabs(scaled_max) >= SCALED_DOUBLE_BOUNDS) {
|
232
|
+
CLIENT_ERR(
|
233
|
+
"Invalid upper bound for double precision. Absolute scaled value of max must be less than %g. max: %g",
|
234
|
+
SCALED_DOUBLE_BOUNDS,
|
235
|
+
max);
|
236
|
+
return false;
|
237
|
+
}
|
238
|
+
|
239
|
+
if (fabs(scaled_min) >= SCALED_DOUBLE_BOUNDS) {
|
240
|
+
CLIENT_ERR(
|
241
|
+
"Invalid lower bound for double precision. Absolute scaled value of min must be less than %g. min: %g",
|
242
|
+
SCALED_DOUBLE_BOUNDS,
|
243
|
+
min);
|
244
|
+
return false;
|
245
|
+
}
|
246
|
+
|
247
|
+
const double t_1 = scaled_max - scaled_min;
|
248
|
+
const double t_4 = (double)UINT64_MAX - t_1;
|
249
|
+
const double t_5 = floor(log10(t_4)) - 1;
|
250
|
+
|
251
|
+
if ((double)precision > t_5) {
|
252
|
+
CLIENT_ERR("Invalid value for precision. precision: %" PRId32, precision);
|
253
|
+
return false;
|
254
|
+
}
|
255
|
+
|
256
|
+
const int64_t i_1 = (int64_t)(scaled_max);
|
257
|
+
const int64_t i_2 = (int64_t)(scaled_min);
|
258
|
+
|
259
|
+
const uint64_t range = subtract_int64_t(i_1, i_2);
|
260
|
+
|
261
|
+
if (((uint64_t)scaled_prc) > UINT64_MAX - range) {
|
262
|
+
CLIENT_ERR("Invalid value for min, max, and precision. The calculated domain size is too large. min: %g, max: "
|
263
|
+
"%g, precision: %" PRId32,
|
264
|
+
min,
|
265
|
+
max,
|
266
|
+
precision);
|
267
|
+
return false;
|
268
|
+
}
|
269
|
+
|
270
|
+
const uint64_t i_3 = range + (uint64_t)(scaled_prc);
|
165
271
|
|
166
|
-
|
272
|
+
if (!ceil_log2_double(i_3, maxBitsOut, status)) {
|
273
|
+
return false;
|
274
|
+
}
|
275
|
+
|
276
|
+
// Integers between -2^53 and 2^53 can be exactly represented. Outside this range, doubles lose precision by a
|
277
|
+
// multiple of 2^(n-52) where n = #bits. We disallow users from using precision mode when the bounds exceed 2^53 to
|
278
|
+
// prevent the users from being surprised by how floating point math works.
|
279
|
+
if (*maxBitsOut >= 53) {
|
280
|
+
return false;
|
281
|
+
}
|
282
|
+
|
283
|
+
return true;
|
284
|
+
}
|
285
|
+
|
286
|
+
bool mc_getTypeInfoDouble(mc_getTypeInfoDouble_args_t args,
|
287
|
+
mc_OSTType_Double *out,
|
288
|
+
mongocrypt_status_t *status,
|
289
|
+
bool use_range_v2) {
|
167
290
|
if (args.min.set != args.max.set || args.min.set != args.precision.set) {
|
168
291
|
CLIENT_ERR("min, max, and precision must all be set or must all be unset");
|
169
292
|
return false;
|
@@ -194,6 +317,19 @@ bool mc_getTypeInfoDouble(mc_getTypeInfoDouble_args_t args, mc_OSTType_Double *o
|
|
194
317
|
}
|
195
318
|
}
|
196
319
|
|
320
|
+
if (args.precision.set) {
|
321
|
+
if (args.precision.value < 0) {
|
322
|
+
CLIENT_ERR("Precision must be non-negative, but got %" PRId32, args.precision.value);
|
323
|
+
return false;
|
324
|
+
}
|
325
|
+
|
326
|
+
double scaled = exp10Double(args.precision.value);
|
327
|
+
if (!mc_isfinite(scaled)) {
|
328
|
+
CLIENT_ERR("Precision is too large and cannot be used to calculate the scaled range bounds");
|
329
|
+
return false;
|
330
|
+
}
|
331
|
+
}
|
332
|
+
|
197
333
|
const bool is_neg = args.value < 0.0;
|
198
334
|
|
199
335
|
// Map negative 0 to zero so sign bit is 0.
|
@@ -210,39 +346,33 @@ bool mc_getTypeInfoDouble(mc_getTypeInfoDouble_args_t args, mc_OSTType_Double *o
|
|
210
346
|
bool use_precision_mode = false;
|
211
347
|
uint32_t bits_range;
|
212
348
|
if (args.precision.set) {
|
213
|
-
|
214
|
-
|
215
|
-
CLIENT_ERR("Precision must be between 0 and 324 inclusive, got: %" PRIu32, args.precision.value);
|
216
|
-
return false;
|
217
|
-
}
|
218
|
-
|
219
|
-
double range = args.max.value - args.min.value;
|
349
|
+
use_precision_mode =
|
350
|
+
mc_canUsePrecisionModeDouble(args.min.value, args.max.value, args.precision.value, &bits_range, status);
|
220
351
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
if (mc_isfinite(range)) {
|
225
|
-
// This creates a range which is wider then we permit by our min/max
|
226
|
-
// bounds check with the +1 but it is as the algorithm is written in
|
227
|
-
// WRITING-11907.
|
228
|
-
double rangeAndPrecision = (range + 1) * exp10Double(args.precision.value);
|
229
|
-
|
230
|
-
if (mc_isfinite(rangeAndPrecision)) {
|
231
|
-
double bits_range_double = log2(rangeAndPrecision);
|
232
|
-
bits_range = (uint32_t)ceil(bits_range_double);
|
233
|
-
|
234
|
-
if (bits_range < 64) {
|
235
|
-
use_precision_mode = true;
|
236
|
-
}
|
352
|
+
if (!use_precision_mode && use_range_v2) {
|
353
|
+
if (!mongocrypt_status_ok(status)) {
|
354
|
+
return false;
|
237
355
|
}
|
356
|
+
|
357
|
+
CLIENT_ERR("The domain of double values specified by the min, max, and precision cannot be represented in "
|
358
|
+
"fewer than 53 bits. min: %g, max: %g, precision: %" PRId32,
|
359
|
+
args.min.value,
|
360
|
+
args.max.value,
|
361
|
+
args.precision.value);
|
362
|
+
return false;
|
238
363
|
}
|
364
|
+
|
365
|
+
// If we are not in range_v2, then we don't care about the error returned
|
366
|
+
// from canUsePrecisionMode so we can reset the status.
|
367
|
+
_mongocrypt_status_reset(status);
|
239
368
|
}
|
240
369
|
|
241
370
|
if (use_precision_mode) {
|
242
371
|
// Take a number of xxxx.ppppp and truncate it xxxx.ppp if precision = 3.
|
243
372
|
// We do not change the digits before the decimal place.
|
244
|
-
|
245
|
-
int64_t
|
373
|
+
int64_t v_prime = (int64_t)(trunc(args.value * exp10Double(args.precision.value)));
|
374
|
+
int64_t scaled_min = (int64_t)(args.min.value * exp10Double(args.precision.value));
|
375
|
+
int64_t v_prime2 = v_prime - scaled_min;
|
246
376
|
|
247
377
|
BSON_ASSERT(v_prime2 < INT64_MAX && v_prime2 >= 0);
|
248
378
|
|
@@ -298,7 +428,7 @@ bool mc_getTypeInfoDouble(mc_getTypeInfoDouble_args_t args, mc_OSTType_Double *o
|
|
298
428
|
* @param dec
|
299
429
|
* @return mlib_int128
|
300
430
|
*/
|
301
|
-
static mlib_int128
|
431
|
+
static mlib_int128 dec128_to_uint128(mc_dec128 dec) {
|
302
432
|
// Only normal numbers
|
303
433
|
BSON_ASSERT(mc_dec128_is_finite(dec));
|
304
434
|
BSON_ASSERT(!mc_dec128_is_nan(dec));
|
@@ -313,6 +443,7 @@ static mlib_int128 dec128_to_int128(mc_dec128 dec) {
|
|
313
443
|
// Decimal128:
|
314
444
|
int32_t exp = ((int32_t)mc_dec128_get_biased_exp(dec)) - MC_DEC128_EXPONENT_BIAS;
|
315
445
|
// We will scale up/down based on whether it is negative:
|
446
|
+
BSON_ASSERT(abs(exp) <= UINT8_MAX);
|
316
447
|
mlib_int128 e1 = mlib_int128_pow10((uint8_t)abs(exp));
|
317
448
|
if (exp < 0) {
|
318
449
|
ret = mlib_int128_div(ret, e1);
|
@@ -323,15 +454,176 @@ static mlib_int128 dec128_to_int128(mc_dec128 dec) {
|
|
323
454
|
return ret;
|
324
455
|
}
|
325
456
|
|
457
|
+
// (2^127 - 1) = the maximum signed 128-bit integer value, as a decimal128
|
458
|
+
#define INT_128_MAX_AS_DECIMAL mc_dec128_from_string("170141183460469231731687303715884105727")
|
459
|
+
// (2^128 - 1) = the max unsigned 128-bit integer value, as a decimal128
|
460
|
+
#define UINT_128_MAX_AS_DECIMAL mc_dec128_from_string("340282366920938463463374607431768211455")
|
461
|
+
|
462
|
+
static mlib_int128 dec128_to_int128(mc_dec128 dec) {
|
463
|
+
BSON_ASSERT(mc_dec128_less(dec, INT_128_MAX_AS_DECIMAL));
|
464
|
+
|
465
|
+
bool negative = false;
|
466
|
+
|
467
|
+
if (mc_dec128_is_negative(dec)) {
|
468
|
+
negative = true;
|
469
|
+
dec = mc_dec128_mul(MC_DEC128(-1), dec);
|
470
|
+
}
|
471
|
+
|
472
|
+
mlib_int128 ret_val = dec128_to_uint128(dec);
|
473
|
+
|
474
|
+
if (negative) {
|
475
|
+
ret_val = mlib_int128_mul(MLIB_INT128(-1), ret_val);
|
476
|
+
}
|
477
|
+
|
478
|
+
return ret_val;
|
479
|
+
}
|
480
|
+
|
481
|
+
bool ceil_log2_int128(mlib_int128 i, uint32_t *maxBitsOut, mongocrypt_status_t *status) {
|
482
|
+
if (mlib_int128_eq(i, MLIB_INT128(0))) {
|
483
|
+
CLIENT_ERR("Invalid input to ceil_log2_int128 function. Input cannot be 0.");
|
484
|
+
return false;
|
485
|
+
}
|
486
|
+
|
487
|
+
uint32_t clz = (uint32_t)_mlibCountLeadingZeros_u128(i);
|
488
|
+
uint32_t bits;
|
489
|
+
|
490
|
+
// if i & (i - 1) == 0
|
491
|
+
if (mlib_int128_eq((mlib_int128_bitand(i, (mlib_int128_sub(i, MLIB_INT128(1))))), MLIB_INT128(0))) {
|
492
|
+
bits = 128 - clz - 1;
|
493
|
+
} else {
|
494
|
+
bits = 128 - clz;
|
495
|
+
}
|
496
|
+
*maxBitsOut = bits;
|
497
|
+
return true;
|
498
|
+
}
|
499
|
+
|
500
|
+
bool mc_canUsePrecisionModeDecimal(mc_dec128 min,
|
501
|
+
mc_dec128 max,
|
502
|
+
int32_t precision,
|
503
|
+
uint32_t *maxBitsOut,
|
504
|
+
mongocrypt_status_t *status) {
|
505
|
+
BSON_ASSERT_PARAM(maxBitsOut);
|
506
|
+
BSON_ASSERT(precision >= 0);
|
507
|
+
|
508
|
+
if (!mc_dec128_is_finite(max)) {
|
509
|
+
CLIENT_ERR("Invalid upper bound for Decimal128 precision. Max is infinite.");
|
510
|
+
return false;
|
511
|
+
}
|
512
|
+
|
513
|
+
if (!mc_dec128_is_finite(min)) {
|
514
|
+
CLIENT_ERR("Invalid lower bound for Decimal128 precision. Min is infinite.");
|
515
|
+
return false;
|
516
|
+
}
|
517
|
+
|
518
|
+
if (mc_dec128_greater_equal(min, max)) {
|
519
|
+
CLIENT_ERR("Invalid upper and lower bounds for Decimal128 precision. Min must be strictly less than max. min: "
|
520
|
+
"%s, max: %s",
|
521
|
+
mc_dec128_to_string(min).str,
|
522
|
+
mc_dec128_to_string(max).str);
|
523
|
+
return false;
|
524
|
+
}
|
525
|
+
|
526
|
+
mc_dec128 scaled_max = mc_dec128_scale(max, precision);
|
527
|
+
mc_dec128 scaled_min = mc_dec128_scale(min, precision);
|
528
|
+
|
529
|
+
mc_dec128 scaled_max_trunc = mc_dec128_round_integral_ex(scaled_max, MC_DEC128_ROUND_TOWARD_ZERO, NULL);
|
530
|
+
mc_dec128 scaled_min_trunc = mc_dec128_round_integral_ex(scaled_min, MC_DEC128_ROUND_TOWARD_ZERO, NULL);
|
531
|
+
|
532
|
+
if (mc_dec128_not_equal(scaled_max, scaled_max_trunc)) {
|
533
|
+
CLIENT_ERR("Invalid upper bound for Decimal128 precision. Fractional digits must be less than "
|
534
|
+
"the specified precision value. max: %s, precision: %" PRId32,
|
535
|
+
mc_dec128_to_string(max).str,
|
536
|
+
precision);
|
537
|
+
return false;
|
538
|
+
}
|
539
|
+
|
540
|
+
if (mc_dec128_not_equal(scaled_min, scaled_min_trunc)) {
|
541
|
+
CLIENT_ERR("Invalid lower bound for Decimal128 precision. Fractional digits must be less than "
|
542
|
+
"the specified precision value. min: %s, precision: %" PRId32,
|
543
|
+
mc_dec128_to_string(min).str,
|
544
|
+
precision);
|
545
|
+
return false;
|
546
|
+
}
|
547
|
+
|
548
|
+
if (mc_dec128_greater(mc_dec128_abs(scaled_max), INT_128_MAX_AS_DECIMAL)) {
|
549
|
+
CLIENT_ERR("Invalid upper bound for Decimal128 precision. Absolute scaled value must be less than "
|
550
|
+
"or equal to %s. max: %s",
|
551
|
+
mc_dec128_to_string(INT_128_MAX_AS_DECIMAL).str,
|
552
|
+
mc_dec128_to_string(max).str);
|
553
|
+
return false;
|
554
|
+
}
|
555
|
+
|
556
|
+
if (mc_dec128_greater(mc_dec128_abs(scaled_min), INT_128_MAX_AS_DECIMAL)) {
|
557
|
+
CLIENT_ERR("Invalid lower bound for Decimal128 precision. Absolute scaled value must be less than "
|
558
|
+
"or equal to %s. min: %s",
|
559
|
+
mc_dec128_to_string(INT_128_MAX_AS_DECIMAL).str,
|
560
|
+
mc_dec128_to_string(min).str);
|
561
|
+
return false;
|
562
|
+
}
|
563
|
+
|
564
|
+
mc_dec128 t_1 = mc_dec128_sub(scaled_max, scaled_min);
|
565
|
+
mc_dec128 t_4 = mc_dec128_sub(UINT_128_MAX_AS_DECIMAL, t_1);
|
566
|
+
|
567
|
+
// t_5 = floor(log10(t_4)) - 1;
|
568
|
+
mc_dec128 t_5 = mc_dec128_sub(mc_dec128_round_integral_ex(mc_dec128_log10(t_4), MC_DEC128_ROUND_TOWARD_ZERO, NULL),
|
569
|
+
MC_DEC128(1));
|
570
|
+
|
571
|
+
// We convert precision to a double so we can avoid warning C4146 on Windows.
|
572
|
+
mc_dec128 prc_dec = mc_dec128_from_double((double)precision);
|
573
|
+
|
574
|
+
if (mc_dec128_less(t_5, prc_dec)) {
|
575
|
+
CLIENT_ERR("Invalid value for precision. precision: %" PRId32, precision);
|
576
|
+
return false;
|
577
|
+
}
|
578
|
+
|
579
|
+
mlib_int128 i_1 = dec128_to_int128(scaled_max);
|
580
|
+
mlib_int128 i_2 = dec128_to_int128(scaled_min);
|
581
|
+
|
582
|
+
// Because we have guaranteed earlier that max is greater than min, we can
|
583
|
+
// subtract these values and guarantee that taking their unsigned
|
584
|
+
// representation will yield the actual range result.
|
585
|
+
mlib_int128 range128 = mlib_int128_sub(i_1, i_2);
|
586
|
+
|
587
|
+
if (precision > UINT8_MAX) {
|
588
|
+
CLIENT_ERR("Invalid value for precision. Must be less than 255. precision: %" PRId32, precision);
|
589
|
+
return false;
|
590
|
+
}
|
591
|
+
|
592
|
+
mlib_int128 i_3 = mlib_int128_add(range128, mlib_int128_pow10((uint8_t)precision));
|
593
|
+
if (!ceil_log2_int128(i_3, maxBitsOut, status)) {
|
594
|
+
return false;
|
595
|
+
}
|
596
|
+
|
597
|
+
if (*maxBitsOut >= 128) {
|
598
|
+
return false;
|
599
|
+
}
|
600
|
+
|
601
|
+
return true;
|
602
|
+
}
|
603
|
+
|
326
604
|
bool mc_getTypeInfoDecimal128(mc_getTypeInfoDecimal128_args_t args,
|
327
605
|
mc_OSTType_Decimal128 *out,
|
328
|
-
mongocrypt_status_t *status
|
606
|
+
mongocrypt_status_t *status,
|
607
|
+
bool use_range_v2) {
|
329
608
|
/// Basic param checks
|
330
609
|
if (args.min.set != args.max.set || args.min.set != args.precision.set) {
|
331
610
|
CLIENT_ERR("min, max, and precision must all be set or must all be unset");
|
332
611
|
return false;
|
333
612
|
}
|
334
613
|
|
614
|
+
if (args.precision.set) {
|
615
|
+
if (args.precision.value < 0) {
|
616
|
+
CLIENT_ERR("Precision must be non-negative, but got %" PRId32, args.precision.value);
|
617
|
+
return false;
|
618
|
+
}
|
619
|
+
|
620
|
+
mc_dec128 scaled = mc_dec128_scale(MC_DEC128(1), args.precision.value);
|
621
|
+
if (!mc_dec128_is_finite(scaled)) {
|
622
|
+
CLIENT_ERR("Precision is too large and cannot be used to calculate the scaled range bounds");
|
623
|
+
return false;
|
624
|
+
}
|
625
|
+
}
|
626
|
+
|
335
627
|
// We only accept normal numbers
|
336
628
|
if (mc_dec128_is_inf(args.value) || mc_dec128_is_nan(args.value)) {
|
337
629
|
CLIENT_ERR("Infinity and Nan Decimal128 values are not supported.");
|
@@ -375,45 +667,27 @@ bool mc_getTypeInfoDecimal128(mc_getTypeInfoDecimal128_args_t args,
|
|
375
667
|
// full range.
|
376
668
|
bool use_precision_mode = false;
|
377
669
|
// The number of bits required to hold the result (used for precision mode)
|
378
|
-
|
670
|
+
uint32_t bits_range = 0;
|
379
671
|
if (args.precision.set) {
|
380
|
-
|
381
|
-
|
382
|
-
CLIENT_ERR("Precision must be between 0 and 6182 inclusive, got: %" PRIu32, args.precision.value);
|
383
|
-
return false;
|
384
|
-
}
|
672
|
+
use_precision_mode =
|
673
|
+
mc_canUsePrecisionModeDecimal(args.min.value, args.max.value, args.precision.value, &bits_range, status);
|
385
674
|
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
mc_dec128 bounds = mc_dec128_add(bounds_n1, MC_DEC128_ONE);
|
390
|
-
|
391
|
-
// We can overflow if max = max_dec128 and min = min_dec128 so make sure
|
392
|
-
// we have finite number after we do subtraction
|
393
|
-
if (mc_dec128_is_finite(bounds)) {
|
394
|
-
// This creates a range which is wider then we permit by our min/max
|
395
|
-
// bounds check with the +1 but it is as the algorithm is written in
|
396
|
-
// WRITING-11907.
|
397
|
-
mc_dec128 precision_scaled_bounds = mc_dec128_scale(bounds, args.precision.value);
|
398
|
-
/// The number of bits required to hold the result for the given
|
399
|
-
/// precision (as decimal)
|
400
|
-
mc_dec128 bits_range_dec = mc_dec128_log2(precision_scaled_bounds);
|
401
|
-
|
402
|
-
if (mc_dec128_is_finite(bits_range_dec) && mc_dec128_less(bits_range_dec, MC_DEC128(128))) {
|
403
|
-
// We need fewer than 128 bits to hold the result. But round up,
|
404
|
-
// just to be sure:
|
405
|
-
int64_t r =
|
406
|
-
mc_dec128_to_int64(mc_dec128_round_integral_ex(bits_range_dec, MC_DEC128_ROUND_UPWARD, NULL));
|
407
|
-
BSON_ASSERT(r >= 0);
|
408
|
-
BSON_ASSERT(r <= UINT8_MAX);
|
409
|
-
// We've computed the proper 'bits_range'
|
410
|
-
bits_range = (uint8_t)r;
|
411
|
-
|
412
|
-
if (bits_range < 128) {
|
413
|
-
use_precision_mode = true;
|
414
|
-
}
|
675
|
+
if (use_range_v2 && !use_precision_mode) {
|
676
|
+
if (!mongocrypt_status_ok(status)) {
|
677
|
+
return false;
|
415
678
|
}
|
679
|
+
|
680
|
+
CLIENT_ERR("The domain of decimal values specified by the min, max, and precision cannot be represented in "
|
681
|
+
"fewer than 128 bits. min: %s, max: %s, precision: %" PRIu32,
|
682
|
+
mc_dec128_to_string(args.min.value).str,
|
683
|
+
mc_dec128_to_string(args.max.value).str,
|
684
|
+
args.precision.value);
|
685
|
+
return false;
|
416
686
|
}
|
687
|
+
|
688
|
+
// If we are not in range_v2, then we don't care about the error returned
|
689
|
+
// from canUsePrecisionMode so we can reset the status.
|
690
|
+
_mongocrypt_status_reset(status);
|
417
691
|
}
|
418
692
|
|
419
693
|
// Constant zero
|
@@ -456,9 +730,9 @@ bool mc_getTypeInfoDecimal128(mc_getTypeInfoDecimal128_args_t args,
|
|
456
730
|
v_prime2 = mc_dec128_round_integral_ex(v_prime2, MC_DEC128_ROUND_TOWARD_ZERO, NULL);
|
457
731
|
|
458
732
|
BSON_ASSERT(mc_dec128_less(mc_dec128_log2(v_prime2), MC_DEC128(128)));
|
459
|
-
|
733
|
+
BSON_ASSERT(bits_range < 128);
|
460
734
|
// Resulting OST maximum
|
461
|
-
mlib_int128 ost_max = mlib_int128_sub(mlib_int128_pow2(bits_range), i128_one);
|
735
|
+
mlib_int128 ost_max = mlib_int128_sub(mlib_int128_pow2((uint8_t)bits_range), i128_one);
|
462
736
|
|
463
737
|
// Now we need to get the Decimal128 out as a 128-bit integer
|
464
738
|
// But Decimal128 does not support conversion to Int128.
|
@@ -575,3 +849,23 @@ bool mc_getTypeInfoDecimal128(mc_getTypeInfoDecimal128_args_t args,
|
|
575
849
|
}
|
576
850
|
|
577
851
|
#endif // defined MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
|
852
|
+
|
853
|
+
const int64_t mc_FLERangeSparsityDefault = 2;
|
854
|
+
const int32_t mc_FLERangeTrimFactorDefault = 6;
|
855
|
+
|
856
|
+
int32_t trimFactorDefault(size_t maxlen, mc_optional_int32_t trimFactor, bool use_range_v2) {
|
857
|
+
if (trimFactor.set) {
|
858
|
+
return trimFactor.value;
|
859
|
+
}
|
860
|
+
|
861
|
+
if (!use_range_v2) {
|
862
|
+
// Preserve old default.
|
863
|
+
return 0;
|
864
|
+
}
|
865
|
+
|
866
|
+
if (bson_cmp_greater_su(mc_FLERangeTrimFactorDefault, maxlen - 1)) {
|
867
|
+
return (int32_t)(maxlen - 1);
|
868
|
+
} else {
|
869
|
+
return mc_FLERangeTrimFactorDefault;
|
870
|
+
}
|
871
|
+
}
|
@@ -17,18 +17,6 @@
|
|
17
17
|
// mc-range-mincover-generator.template.h is meant to be included in another
|
18
18
|
// source file.
|
19
19
|
|
20
|
-
// TODO: replace `CONCAT` with `BSON_CONCAT` after libbson dependency is
|
21
|
-
// upgraded to 1.20.0 or higher.
|
22
|
-
#ifndef CONCAT
|
23
|
-
#define CONCAT_1(a, b) a##b
|
24
|
-
#define CONCAT(a, b) CONCAT_1(a, b)
|
25
|
-
#endif
|
26
|
-
// TODO: replace `CONCAT3` with `BSON_CONCAT3` after libbson dependency is
|
27
|
-
// upgraded to 1.20.0 or higher.
|
28
|
-
#ifndef CONCAT3
|
29
|
-
#define CONCAT3(a, b, c) CONCAT(a, CONCAT(b, c))
|
30
|
-
#endif
|
31
|
-
|
32
20
|
#if !(defined(UINT_T) && defined(UINT_C) && defined(UINT_FMT_S) && defined(DECORATE_NAME))
|
33
21
|
#ifdef __INTELLISENSE__
|
34
22
|
#define UINT_T uint32_t
|
@@ -101,6 +89,7 @@ typedef struct {
|
|
101
89
|
UINT_T _rangeMin;
|
102
90
|
UINT_T _rangeMax;
|
103
91
|
size_t _sparsity;
|
92
|
+
int32_t _trimFactor;
|
104
93
|
// _maxlen is the maximum bit length of edges in the mincover.
|
105
94
|
size_t _maxlen;
|
106
95
|
} DECORATE_NAME(MinCoverGenerator);
|
@@ -110,7 +99,9 @@ static inline DECORATE_NAME(MinCoverGenerator)
|
|
110
99
|
UINT_T rangeMax,
|
111
100
|
UINT_T max,
|
112
101
|
size_t sparsity,
|
113
|
-
|
102
|
+
mc_optional_int32_t opt_trimFactor,
|
103
|
+
mongocrypt_status_t *status,
|
104
|
+
bool use_range_v2) {
|
114
105
|
BSON_ASSERT_PARAM(status);
|
115
106
|
|
116
107
|
if (UINT_COMPARE(rangeMin, rangeMax) > 0) {
|
@@ -131,11 +122,25 @@ static inline DECORATE_NAME(MinCoverGenerator)
|
|
131
122
|
CLIENT_ERR("Sparsity must be > 0");
|
132
123
|
return NULL;
|
133
124
|
}
|
125
|
+
size_t maxlen = (size_t)BITS - DECORATE_NAME(mc_count_leading_zeros)(max);
|
126
|
+
int32_t trimFactor = trimFactorDefault(maxlen, opt_trimFactor, use_range_v2);
|
127
|
+
if (trimFactor != 0 && bson_cmp_greater_equal_su(trimFactor, maxlen)) {
|
128
|
+
CLIENT_ERR("Trim factor must be less than the number of bits (%ld) used to represent an element of the domain, "
|
129
|
+
"but got %" PRId32,
|
130
|
+
maxlen,
|
131
|
+
trimFactor);
|
132
|
+
return NULL;
|
133
|
+
}
|
134
|
+
if (trimFactor < 0) {
|
135
|
+
CLIENT_ERR("Trim factor must be >= 0, but got (%" PRId32 ")", trimFactor);
|
136
|
+
return NULL;
|
137
|
+
}
|
134
138
|
DECORATE_NAME(MinCoverGenerator) *mcg = bson_malloc0(sizeof(DECORATE_NAME(MinCoverGenerator)));
|
135
139
|
mcg->_rangeMin = rangeMin;
|
136
140
|
mcg->_rangeMax = rangeMax;
|
137
141
|
mcg->_maxlen = (size_t)BITS - DECORATE_NAME(mc_count_leading_zeros)(max);
|
138
142
|
mcg->_sparsity = sparsity;
|
143
|
+
mcg->_trimFactor = trimFactor;
|
139
144
|
return mcg;
|
140
145
|
}
|
141
146
|
|
@@ -164,7 +169,9 @@ static inline bool DECORATE_NAME(MinCoverGenerator_isLevelStored)(DECORATE_NAME(
|
|
164
169
|
size_t maskedBits) {
|
165
170
|
BSON_ASSERT_PARAM(mcg);
|
166
171
|
size_t level = mcg->_maxlen - maskedBits;
|
167
|
-
|
172
|
+
BSON_ASSERT(bson_in_range_size_t_signed(mcg->_trimFactor));
|
173
|
+
size_t trimFactor_sz = (size_t)mcg->_trimFactor;
|
174
|
+
return 0 == maskedBits || (level >= trimFactor_sz && 0 == (level % mcg->_sparsity));
|
168
175
|
}
|
169
176
|
|
170
177
|
char *
|
@@ -219,6 +226,11 @@ static inline mc_mincover_t *DECORATE_NAME(MinCoverGenerator_minCover)(DECORATE_
|
|
219
226
|
return mc;
|
220
227
|
}
|
221
228
|
|
229
|
+
static inline int32_t DECORATE_NAME(MinCoverGenerator_usedTrimFactor)(DECORATE_NAME(MinCoverGenerator) * mcg) {
|
230
|
+
BSON_ASSERT_PARAM(mcg);
|
231
|
+
return mcg->_trimFactor;
|
232
|
+
}
|
233
|
+
|
222
234
|
// adjustBounds increments *lowerBound if includeLowerBound is false and
|
223
235
|
// decrements *upperBound if includeUpperBound is false.
|
224
236
|
// lowerBound, min, upperBound, and max are expected to come from the result
|
@@ -33,6 +33,9 @@ const char *mc_mincover_get(mc_mincover_t *mincover, size_t index);
|
|
33
33
|
// mc_mincover_len returns the number of represented mincover.
|
34
34
|
size_t mc_mincover_len(mc_mincover_t *mincover);
|
35
35
|
|
36
|
+
// Return the trimFactor that was used to generate this mincover.
|
37
|
+
int32_t mc_mincover_get_used_trimFactor(const mc_mincover_t *mincover);
|
38
|
+
|
36
39
|
// mc_mincover_destroys frees `mincover`.
|
37
40
|
void mc_mincover_destroy(mc_mincover_t *mincover);
|
38
41
|
|
@@ -44,12 +47,14 @@ typedef struct {
|
|
44
47
|
mc_optional_int32_t min;
|
45
48
|
mc_optional_int32_t max;
|
46
49
|
size_t sparsity;
|
50
|
+
mc_optional_int32_t trimFactor;
|
47
51
|
} mc_getMincoverInt32_args_t;
|
48
52
|
|
49
53
|
// mc_getMincoverInt32 implements the Mincover Generation algorithm described in
|
50
54
|
// SERVER-68600 for int32_t.
|
51
55
|
mc_mincover_t *mc_getMincoverInt32(mc_getMincoverInt32_args_t args,
|
52
|
-
mongocrypt_status_t *status
|
56
|
+
mongocrypt_status_t *status,
|
57
|
+
bool use_range_v2) MONGOCRYPT_WARN_UNUSED_RESULT;
|
53
58
|
|
54
59
|
typedef struct {
|
55
60
|
int64_t lowerBound;
|
@@ -59,12 +64,14 @@ typedef struct {
|
|
59
64
|
mc_optional_int64_t min;
|
60
65
|
mc_optional_int64_t max;
|
61
66
|
size_t sparsity;
|
67
|
+
mc_optional_int32_t trimFactor;
|
62
68
|
} mc_getMincoverInt64_args_t;
|
63
69
|
|
64
70
|
// mc_getMincoverInt64 implements the Mincover Generation algorithm described in
|
65
71
|
// SERVER-68600 for int64_t.
|
66
72
|
mc_mincover_t *mc_getMincoverInt64(mc_getMincoverInt64_args_t args,
|
67
|
-
mongocrypt_status_t *status
|
73
|
+
mongocrypt_status_t *status,
|
74
|
+
bool use_range_v2) MONGOCRYPT_WARN_UNUSED_RESULT;
|
68
75
|
|
69
76
|
typedef struct {
|
70
77
|
double lowerBound;
|
@@ -74,13 +81,15 @@ typedef struct {
|
|
74
81
|
size_t sparsity;
|
75
82
|
mc_optional_double_t min;
|
76
83
|
mc_optional_double_t max;
|
77
|
-
|
84
|
+
mc_optional_int32_t precision;
|
85
|
+
mc_optional_int32_t trimFactor;
|
78
86
|
} mc_getMincoverDouble_args_t;
|
79
87
|
|
80
88
|
// mc_getMincoverDouble implements the Mincover Generation algorithm described
|
81
89
|
// in SERVER-68600 for double.
|
82
90
|
mc_mincover_t *mc_getMincoverDouble(mc_getMincoverDouble_args_t args,
|
83
|
-
mongocrypt_status_t *status
|
91
|
+
mongocrypt_status_t *status,
|
92
|
+
bool use_range_v2) MONGOCRYPT_WARN_UNUSED_RESULT;
|
84
93
|
|
85
94
|
#if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
|
86
95
|
typedef struct {
|
@@ -90,13 +99,15 @@ typedef struct {
|
|
90
99
|
bool includeUpperBound;
|
91
100
|
size_t sparsity;
|
92
101
|
mc_optional_dec128_t min, max;
|
93
|
-
|
102
|
+
mc_optional_int32_t precision;
|
103
|
+
mc_optional_int32_t trimFactor;
|
94
104
|
} mc_getMincoverDecimal128_args_t;
|
95
105
|
|
96
106
|
// mc_getMincoverDecimal128 implements the Mincover Generation algorithm
|
97
107
|
// described in SERVER-68600 for Decimal128 (as mc_dec128).
|
98
108
|
mc_mincover_t *mc_getMincoverDecimal128(mc_getMincoverDecimal128_args_t args,
|
99
|
-
mongocrypt_status_t *status
|
109
|
+
mongocrypt_status_t *status,
|
110
|
+
bool use_range_v2) MONGOCRYPT_WARN_UNUSED_RESULT;
|
100
111
|
#endif // MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
|
101
112
|
|
102
113
|
#endif /* MC_RANGE_MINCOVER_PRIVATE_H */
|