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
@@ -4,10 +4,10 @@
|
|
4
4
|
#include "./macros.h"
|
5
5
|
#include "./str.h"
|
6
6
|
|
7
|
-
#include <stdbool.h>
|
8
7
|
#include <inttypes.h>
|
9
|
-
#include <
|
8
|
+
#include <stdbool.h>
|
10
9
|
#include <stdlib.h>
|
10
|
+
#include <string.h>
|
11
11
|
|
12
12
|
MLIB_C_LINKAGE_BEGIN
|
13
13
|
|
@@ -15,33 +15,31 @@ MLIB_C_LINKAGE_BEGIN
|
|
15
15
|
* @brief A 128-bit binary integer
|
16
16
|
*/
|
17
17
|
typedef union {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
struct {
|
19
|
+
uint64_t lo;
|
20
|
+
uint64_t hi;
|
21
|
+
} r;
|
22
22
|
#if defined(__SIZEOF_INT128__)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
// These union members are only for the purpose of debugging visualization
|
24
|
+
// and testing, and will only appear correctly on little-endian platforms.
|
25
|
+
__int128_t signed_;
|
26
|
+
__uint128_t unsigned_;
|
27
27
|
#endif
|
28
28
|
} mlib_int128;
|
29
29
|
|
30
30
|
/// Define an int128 from a literal within [INT64_MIN, INT64_MAX]
|
31
|
-
#define MLIB_INT128(N) MLIB_INIT
|
31
|
+
#define MLIB_INT128(N) MLIB_INIT(mlib_int128) MLIB_INT128_C(N)
|
32
32
|
/// Define an int128 from a literal within [INT64_MIN, INT64_MAX] (usable as a
|
33
33
|
/// constant init)
|
34
|
-
#define MLIB_INT128_C(N)
|
35
|
-
MLIB_INT128_FROM_PARTS ((uint64_t) INT64_C (N), \
|
36
|
-
(INT64_C (N) < 0 ? UINT64_MAX : 0))
|
34
|
+
#define MLIB_INT128_C(N) MLIB_INT128_FROM_PARTS((uint64_t)INT64_C(N), (INT64_C(N) < 0 ? UINT64_MAX : 0))
|
37
35
|
/**
|
38
36
|
* @brief Cast an integral value to an mlib_int128
|
39
37
|
*
|
40
38
|
* If the argument is signed and less-than zero, it will be sign-extended
|
41
39
|
*/
|
42
|
-
#define MLIB_INT128_CAST(N)
|
43
|
-
|
44
|
-
|
40
|
+
#define MLIB_INT128_CAST(N) \
|
41
|
+
MLIB_INIT(mlib_int128) \
|
42
|
+
MLIB_INT128_FROM_PARTS((uint64_t)(N), ((N) < 0 ? UINT64_MAX : 0))
|
45
43
|
|
46
44
|
/**
|
47
45
|
* @brief Create an mlib_int128 from the low and high parts of the integer
|
@@ -49,20 +47,17 @@ typedef union {
|
|
49
47
|
* @param LowWord_u64 The low-value 64 bits of the number
|
50
48
|
* @param HighWord_u64 The high-value 64 bits of the number
|
51
49
|
*/
|
52
|
-
#define MLIB_INT128_FROM_PARTS(LowWord_u64, HighWord_u64)
|
53
|
-
|
54
|
-
{LowWord_u64, HighWord_u64}, \
|
55
|
-
}
|
50
|
+
#define MLIB_INT128_FROM_PARTS(LowWord_u64, HighWord_u64) \
|
51
|
+
{ {LowWord_u64, HighWord_u64}, }
|
56
52
|
|
57
53
|
/// Maximum value of int128 when treated as a signed integer
|
58
|
-
#define MLIB_INT128_SMAX
|
59
|
-
MLIB_INT128_FROM_PARTS (UINT64_MAX, UINT64_MAX & ~(UINT64_C (1) << 63))
|
54
|
+
#define MLIB_INT128_SMAX MLIB_INT128_FROM_PARTS(UINT64_MAX, UINT64_MAX & ~(UINT64_C(1) << 63))
|
60
55
|
|
61
56
|
/// Minimum value of int128, when treated as a signed integer
|
62
|
-
#define MLIB_INT128_SMIN MLIB_INT128_FROM_PARTS
|
57
|
+
#define MLIB_INT128_SMIN MLIB_INT128_FROM_PARTS(0, UINT64_C(1) << 63)
|
63
58
|
|
64
59
|
/// Maximum value of int128, when treated as an unsigned integer
|
65
|
-
#define MLIB_INT128_UMAX MLIB_INT128_FROM_PARTS
|
60
|
+
#define MLIB_INT128_UMAX MLIB_INT128_FROM_PARTS(UINT64_MAX, UINT64_MAX)
|
66
61
|
|
67
62
|
/**
|
68
63
|
* @brief Compare two 128-bit integers as unsigned integers
|
@@ -71,20 +66,18 @@ typedef union {
|
|
71
66
|
* @return (R > 0) if (left > right)
|
72
67
|
* @return (R = 0) if (left == right)
|
73
68
|
*/
|
74
|
-
static mlib_constexpr_fn int
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
return 0;
|
87
|
-
}
|
69
|
+
static mlib_constexpr_fn int mlib_int128_ucmp(mlib_int128 left, mlib_int128 right) {
|
70
|
+
if (left.r.hi > right.r.hi) {
|
71
|
+
return 1;
|
72
|
+
} else if (left.r.hi < right.r.hi) {
|
73
|
+
return -1;
|
74
|
+
} else if (left.r.lo > right.r.lo) {
|
75
|
+
return 1;
|
76
|
+
} else if (left.r.lo < right.r.lo) {
|
77
|
+
return -1;
|
78
|
+
} else {
|
79
|
+
return 0;
|
80
|
+
}
|
88
81
|
}
|
89
82
|
|
90
83
|
/**
|
@@ -94,19 +87,17 @@ mlib_int128_ucmp (mlib_int128 left, mlib_int128 right)
|
|
94
87
|
* @return (R > 0) if (left > right)
|
95
88
|
* @return (R = 0) if (left == right)
|
96
89
|
*/
|
97
|
-
static mlib_constexpr_fn int
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
return 1;
|
109
|
-
}
|
90
|
+
static mlib_constexpr_fn int mlib_int128_scmp(mlib_int128 left, mlib_int128 right) {
|
91
|
+
if ((left.r.hi & (1ull << 63)) == (right.r.hi & (1ull << 63))) {
|
92
|
+
// Same signed-ness, so they are as comparable as unsigned
|
93
|
+
return mlib_int128_ucmp(left, right);
|
94
|
+
} else if (left.r.hi & (1ull << 63)) {
|
95
|
+
// The left is negative
|
96
|
+
return -1;
|
97
|
+
} else {
|
98
|
+
// The right is negative
|
99
|
+
return 1;
|
100
|
+
}
|
110
101
|
}
|
111
102
|
|
112
103
|
/**
|
@@ -115,10 +106,8 @@ mlib_int128_scmp (mlib_int128 left, mlib_int128 right)
|
|
115
106
|
* @retval true If left == right
|
116
107
|
* @retval false Otherwise
|
117
108
|
*/
|
118
|
-
static mlib_constexpr_fn bool
|
119
|
-
|
120
|
-
{
|
121
|
-
return mlib_int128_ucmp (left, right) == 0;
|
109
|
+
static mlib_constexpr_fn bool mlib_int128_eq(mlib_int128 left, mlib_int128 right) {
|
110
|
+
return mlib_int128_ucmp(left, right) == 0;
|
122
111
|
}
|
123
112
|
|
124
113
|
/**
|
@@ -126,26 +115,22 @@ mlib_int128_eq (mlib_int128 left, mlib_int128 right)
|
|
126
115
|
*
|
127
116
|
* @return mlib_int128 The sum of the two addends. Overflow will wrap.
|
128
117
|
*/
|
129
|
-
static mlib_constexpr_fn mlib_int128
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
uint64_t hisum = left.r.hi + right.r.hi + carry;
|
136
|
-
return MLIB_INIT (mlib_int128) MLIB_INT128_FROM_PARTS (losum, hisum);
|
118
|
+
static mlib_constexpr_fn mlib_int128 mlib_int128_add(mlib_int128 left, mlib_int128 right) {
|
119
|
+
uint64_t losum = left.r.lo + right.r.lo;
|
120
|
+
// Overflow check
|
121
|
+
unsigned carry = (losum < left.r.lo || losum < right.r.lo);
|
122
|
+
uint64_t hisum = left.r.hi + right.r.hi + carry;
|
123
|
+
return MLIB_INIT(mlib_int128) MLIB_INT128_FROM_PARTS(losum, hisum);
|
137
124
|
}
|
138
125
|
|
139
126
|
/**
|
140
127
|
* @brief Treat the given 128-bit integer as signed, and return its
|
141
128
|
* negated value
|
142
129
|
*/
|
143
|
-
static mlib_constexpr_fn mlib_int128
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
r = mlib_int128_add (r, MLIB_INT128 (1));
|
148
|
-
return r;
|
130
|
+
static mlib_constexpr_fn mlib_int128 mlib_int128_negate(mlib_int128 v) {
|
131
|
+
mlib_int128 r = MLIB_INT128_FROM_PARTS(~v.r.lo, ~v.r.hi);
|
132
|
+
r = mlib_int128_add(r, MLIB_INT128(1));
|
133
|
+
return r;
|
149
134
|
}
|
150
135
|
|
151
136
|
/**
|
@@ -153,14 +138,12 @@ mlib_int128_negate (mlib_int128 v)
|
|
153
138
|
*
|
154
139
|
* @return mlib_int128 The difference between `from` and `less`
|
155
140
|
*/
|
156
|
-
static mlib_constexpr_fn mlib_int128
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
high -= borrow;
|
163
|
-
return MLIB_INIT (mlib_int128) MLIB_INT128_FROM_PARTS (low, high);
|
141
|
+
static mlib_constexpr_fn mlib_int128 mlib_int128_sub(mlib_int128 from, mlib_int128 less) {
|
142
|
+
unsigned borrow = from.r.lo < less.r.lo;
|
143
|
+
uint64_t low = from.r.lo - less.r.lo;
|
144
|
+
uint64_t high = from.r.hi - less.r.hi;
|
145
|
+
high -= borrow;
|
146
|
+
return MLIB_INIT(mlib_int128) MLIB_INT128_FROM_PARTS(low, high);
|
164
147
|
}
|
165
148
|
|
166
149
|
/**
|
@@ -170,35 +153,33 @@ mlib_int128_sub (mlib_int128 from, mlib_int128 less)
|
|
170
153
|
* @param off The offset to shift left. If negative, shifts right
|
171
154
|
* @return The result of the shift operation
|
172
155
|
*/
|
173
|
-
static mlib_constexpr_fn mlib_int128
|
174
|
-
|
175
|
-
{
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
return val;
|
201
|
-
}
|
156
|
+
static mlib_constexpr_fn mlib_int128 mlib_int128_lshift(mlib_int128 val, int off) {
|
157
|
+
if (off > 0) {
|
158
|
+
if (off >= 64) {
|
159
|
+
off -= 64;
|
160
|
+
uint64_t high = val.r.lo << off;
|
161
|
+
return MLIB_INIT(mlib_int128) MLIB_INT128_FROM_PARTS(0, high);
|
162
|
+
} else {
|
163
|
+
uint64_t low = val.r.lo << off;
|
164
|
+
uint64_t high = val.r.hi << off;
|
165
|
+
high |= val.r.lo >> (64 - off);
|
166
|
+
return MLIB_INIT(mlib_int128) MLIB_INT128_FROM_PARTS(low, high);
|
167
|
+
}
|
168
|
+
} else if (off < 0) {
|
169
|
+
off = -off;
|
170
|
+
if (off >= 64) {
|
171
|
+
off -= 64;
|
172
|
+
uint64_t low = val.r.hi >> off;
|
173
|
+
return MLIB_INIT(mlib_int128) MLIB_INT128_FROM_PARTS(low, 0);
|
174
|
+
} else {
|
175
|
+
uint64_t high = val.r.hi >> off;
|
176
|
+
uint64_t low = val.r.lo >> off;
|
177
|
+
low |= val.r.hi << (64 - off);
|
178
|
+
return MLIB_INIT(mlib_int128) MLIB_INT128_FROM_PARTS(low, high);
|
179
|
+
}
|
180
|
+
} else {
|
181
|
+
return val;
|
182
|
+
}
|
202
183
|
}
|
203
184
|
|
204
185
|
/**
|
@@ -208,241 +189,240 @@ mlib_int128_lshift (mlib_int128 val, int off)
|
|
208
189
|
* @param off The offset to shift right. If negative, shifts left
|
209
190
|
* @return The result of the shift operation
|
210
191
|
*/
|
211
|
-
static mlib_constexpr_fn mlib_int128
|
212
|
-
|
213
|
-
{
|
214
|
-
return mlib_int128_lshift (val, -off);
|
192
|
+
static mlib_constexpr_fn mlib_int128 mlib_int128_rshift(mlib_int128 val, int off) {
|
193
|
+
return mlib_int128_lshift(val, -off);
|
215
194
|
}
|
216
195
|
|
217
196
|
/**
|
218
197
|
* @brief Bitwise-or two 128-bit integers
|
219
198
|
*/
|
220
|
-
static mlib_constexpr_fn mlib_int128
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
199
|
+
static mlib_constexpr_fn mlib_int128 mlib_int128_bitor(mlib_int128 l, mlib_int128 r) {
|
200
|
+
return MLIB_INIT(mlib_int128) MLIB_INT128_FROM_PARTS(l.r.lo | r.r.lo, l.r.hi | r.r.hi);
|
201
|
+
}
|
202
|
+
|
203
|
+
/**
|
204
|
+
* @brief Bitwise-and two 128-bit integers
|
205
|
+
*/
|
206
|
+
static mlib_constexpr_fn mlib_int128 mlib_int128_bitand(mlib_int128 l, mlib_int128 r) {
|
207
|
+
return MLIB_INIT(mlib_int128) MLIB_INT128_FROM_PARTS(l.r.lo & r.r.lo, l.r.hi & r.r.hi);
|
225
208
|
}
|
226
209
|
|
227
210
|
// Multiply two 64bit integers to get a 128-bit result without overflow
|
228
|
-
static mlib_constexpr_fn mlib_int128
|
229
|
-
|
230
|
-
{
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
return MLIB_INIT (mlib_int128) MLIB_INT128_FROM_PARTS (
|
247
|
-
((uint64_t) w[1] << 32) | w[0], ((uint64_t) w[3] << 32) | w[2]);
|
211
|
+
static mlib_constexpr_fn mlib_int128 _mlibUnsignedMult128(uint64_t left, uint64_t right) {
|
212
|
+
// Perform a Knuth 4.3.1M multiplication
|
213
|
+
uint32_t u[2] = {(uint32_t)left, (uint32_t)(left >> 32)};
|
214
|
+
uint32_t v[2] = {(uint32_t)right, (uint32_t)(right >> 32)};
|
215
|
+
uint32_t w[4] = {0};
|
216
|
+
|
217
|
+
for (int j = 0; j < 2; ++j) {
|
218
|
+
uint64_t t = 0;
|
219
|
+
for (int i = 0; i < 2; ++i) {
|
220
|
+
t += (uint64_t)(u[i]) * v[j] + w[i + j];
|
221
|
+
w[i + j] = (uint32_t)t;
|
222
|
+
t >>= 32;
|
223
|
+
}
|
224
|
+
w[j + 2] = (uint32_t)t;
|
225
|
+
}
|
226
|
+
|
227
|
+
return MLIB_INIT(mlib_int128) MLIB_INT128_FROM_PARTS(((uint64_t)w[1] << 32) | w[0], ((uint64_t)w[3] << 32) | w[2]);
|
248
228
|
}
|
249
229
|
|
250
230
|
/**
|
251
231
|
* @brief Multiply two mlib_int128s together. Overflow will wrap.
|
252
232
|
*/
|
253
|
-
static mlib_constexpr_fn mlib_int128
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
ret.r.hi += l.r.hi * r.r.lo;
|
261
|
-
return ret;
|
233
|
+
static mlib_constexpr_fn mlib_int128 mlib_int128_mul(mlib_int128 l, mlib_int128 r) {
|
234
|
+
// Multiply the low-order word
|
235
|
+
mlib_int128 ret = _mlibUnsignedMult128(l.r.lo, r.r.lo);
|
236
|
+
// Accumulate the high-order parts:
|
237
|
+
ret.r.hi += l.r.lo * r.r.hi;
|
238
|
+
ret.r.hi += l.r.hi * r.r.lo;
|
239
|
+
return ret;
|
262
240
|
}
|
263
241
|
|
264
242
|
/// Get the number of leading zeros in a 64bit number.
|
265
|
-
static mlib_constexpr_fn int
|
266
|
-
|
267
|
-
{
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
243
|
+
static mlib_constexpr_fn int _mlibCountLeadingZeros_u64(uint64_t bits) {
|
244
|
+
int n = 0;
|
245
|
+
if (bits == 0) {
|
246
|
+
return 64;
|
247
|
+
}
|
248
|
+
while (!(1ull << 63 & bits)) {
|
249
|
+
++n;
|
250
|
+
bits <<= 1;
|
251
|
+
}
|
252
|
+
return n;
|
253
|
+
}
|
254
|
+
|
255
|
+
static mlib_constexpr_fn int _mlibCountLeadingZeros_u128(mlib_int128 r) {
|
256
|
+
int clz_l = _mlibCountLeadingZeros_u64(r.r.hi);
|
257
|
+
if (clz_l != 64) {
|
258
|
+
return clz_l;
|
259
|
+
}
|
260
|
+
|
261
|
+
int clz_r = _mlibCountLeadingZeros_u64(r.r.lo);
|
262
|
+
return clz_l + clz_r;
|
277
263
|
}
|
278
264
|
|
279
265
|
/// Implementation of Knuth's algorithm 4.3.1 D for unsigned integer division
|
280
266
|
static mlib_constexpr_fn void
|
281
|
-
_mlibKnuth431D
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
267
|
+
_mlibKnuth431D(uint32_t *const u, const int ulen, const uint32_t *const v, const int vlen, uint32_t *quotient) {
|
268
|
+
// Part D1 (normalization) is done by caller,
|
269
|
+
// normalized in u and v (radix b is 2^32)
|
270
|
+
typedef uint64_t u64;
|
271
|
+
typedef int64_t i64;
|
272
|
+
typedef uint32_t u32;
|
273
|
+
const int m = ulen - vlen - 1;
|
274
|
+
const int n = vlen;
|
275
|
+
|
276
|
+
// 'd' is 2^32. Shifting left and right is equivalent to mult and division by
|
277
|
+
// d, respectively.
|
278
|
+
|
279
|
+
// D2
|
280
|
+
int j = m;
|
281
|
+
for (;;) {
|
282
|
+
// D3: Select two u32 as a u64:
|
283
|
+
u64 two = ((u64)(u[j + n]) << 32) | u[j + n - 1];
|
284
|
+
// D3: Partial quotient: q̂
|
285
|
+
u64 q = two / v[n - 1];
|
286
|
+
// D3: Partial remainder: r̂
|
287
|
+
u64 r = two % v[n - 1];
|
288
|
+
|
289
|
+
// D3: Compute q̂ and r̂
|
290
|
+
while (q >> 32 || q * (u64)v[n - 2] > (r << 32 | u[j + n - 2])) {
|
291
|
+
q--;
|
292
|
+
r += v[n - 1];
|
293
|
+
if (r >> 32) {
|
294
|
+
break;
|
295
|
+
}
|
296
|
+
}
|
297
|
+
|
298
|
+
// D4: Multiply and subtract
|
299
|
+
i64 k = 0;
|
300
|
+
i64 t = 0;
|
301
|
+
for (int i = 0; i < n; ++i) {
|
302
|
+
u64 prod = (u32)q * (u64)(v[i]);
|
303
|
+
t = u[i + j] - k - (u32)prod;
|
304
|
+
u[i + j] = (u32)t;
|
305
|
+
k = (i64)(prod >> 32) - (t >> 32);
|
306
|
+
}
|
307
|
+
t = u[j + n] - k;
|
308
|
+
u[j + n] = (u32)t;
|
309
|
+
|
310
|
+
quotient[j] = (u32)q;
|
311
|
+
|
312
|
+
// D5: Test remainder
|
313
|
+
if (t < 0) {
|
314
|
+
// D6: Add back
|
315
|
+
--quotient[j];
|
316
|
+
k = 0;
|
317
|
+
for (int i = 0; i < n; ++i) {
|
318
|
+
t = u[i + j] + k + v[i];
|
319
|
+
u[i + j] = (u32)(t);
|
320
|
+
k = t >> 32;
|
321
|
+
}
|
322
|
+
u[j + n] += (u32)k;
|
323
|
+
}
|
324
|
+
|
325
|
+
// D7:
|
326
|
+
--j;
|
327
|
+
if (j < 0) {
|
313
328
|
break;
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
i64 k = 0;
|
319
|
-
i64 t = 0;
|
320
|
-
for (int i = 0; i < n; ++i) {
|
321
|
-
u64 prod = (u32) q * (u64) (v[i]);
|
322
|
-
t = u[i + j] - k - (u32) prod;
|
323
|
-
u[i + j] = (u32) t;
|
324
|
-
k = (i64) (prod >> 32) - (t >> 32);
|
325
|
-
}
|
326
|
-
t = u[j + n] - k;
|
327
|
-
u[j + n] = (u32) t;
|
328
|
-
|
329
|
-
quotient[j] = (u32) q;
|
330
|
-
|
331
|
-
// D5: Test remainder
|
332
|
-
if (t < 0) {
|
333
|
-
// D6: Add back
|
334
|
-
--quotient[j];
|
335
|
-
k = 0;
|
336
|
-
for (int i = 0; i < n; ++i) {
|
337
|
-
t = u[i + j] + k + v[i];
|
338
|
-
u[i + j] = (u32) (t);
|
339
|
-
k = t >> 32;
|
340
|
-
}
|
341
|
-
u[j + n] += (u32) k;
|
342
|
-
}
|
343
|
-
|
344
|
-
// D7:
|
345
|
-
--j;
|
346
|
-
if (j < 0) {
|
347
|
-
break;
|
348
|
-
}
|
349
|
-
}
|
350
|
-
|
351
|
-
// Denormalization (D8) is done by caller.
|
329
|
+
}
|
330
|
+
}
|
331
|
+
|
332
|
+
// Denormalization (D8) is done by caller.
|
352
333
|
}
|
353
334
|
|
354
335
|
/// The result of 128-bit division
|
355
336
|
typedef struct mlib_int128_divmod_result {
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
337
|
+
/// The quotient of the division operation (rounds to zero)
|
338
|
+
mlib_int128 quotient;
|
339
|
+
/// The remainder of the division operation
|
340
|
+
mlib_int128 remainder;
|
360
341
|
} mlib_int128_divmod_result;
|
361
342
|
|
362
343
|
/// Divide a 128-bit number by a 64bit number.
|
363
|
-
static mlib_constexpr_fn struct mlib_int128_divmod_result
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
};
|
344
|
+
static mlib_constexpr_fn struct mlib_int128_divmod_result _mlibDivide_u128_by_u64(const mlib_int128 numer,
|
345
|
+
const uint64_t denom) {
|
346
|
+
mlib_int128 adjusted = numer;
|
347
|
+
adjusted.r.hi %= denom;
|
348
|
+
int d = _mlibCountLeadingZeros_u64(denom);
|
349
|
+
|
350
|
+
typedef uint32_t u32;
|
351
|
+
typedef uint64_t u64;
|
352
|
+
|
353
|
+
if (d >= 32) {
|
354
|
+
// jk: We're dividing by less than UINT32_MAX: We can do a simple short
|
355
|
+
// division of two base32 numbers.
|
356
|
+
// Treat the denominator as a single base32 digit:
|
357
|
+
const u32 d0 = (u32)denom;
|
358
|
+
|
359
|
+
// And the numerator as four base32 digits:
|
360
|
+
const u64 n0 = (u32)(numer.r.lo);
|
361
|
+
const u64 n1 = (u32)(numer.r.lo >> 32);
|
362
|
+
|
363
|
+
// We don't need to split n2 and n3. (n3,n2) will be the first partial
|
364
|
+
// dividend
|
365
|
+
const u64 n3_n2 = numer.r.hi;
|
366
|
+
|
367
|
+
// First partial remainder: (n3,n2) % d0
|
368
|
+
const u64 r1 = n3_n2 % d0;
|
369
|
+
// Second partial dividend: (r1,n1)
|
370
|
+
const u64 r1_n1 = (r1 << 32) + n1;
|
371
|
+
// Second partial remainder: (r1,n1) % d0
|
372
|
+
const u64 r0 = r1_n1 % d0;
|
373
|
+
// Final partial dividend: (r0,n0)
|
374
|
+
const u64 r0_n0 = (r0 << 32) + n0;
|
375
|
+
// Final remainder: (r0,n0) % d0
|
376
|
+
const u64 rem = r0_n0 % d0;
|
377
|
+
|
378
|
+
// Form the quotient as four base32 digits:
|
379
|
+
// Least quotient digit: (r0,n0) / d0
|
380
|
+
const u64 q0 = r0_n0 / d0;
|
381
|
+
// Second quotient digit: (r1,n1) / d0
|
382
|
+
const u64 q1 = r1_n1 / d0;
|
383
|
+
// Third and fourth quotient digit: (n3,n2) / d0
|
384
|
+
const u64 q3_q2 = n3_n2 / d0;
|
385
|
+
|
386
|
+
// Low word of the quotient: (q1,q0)
|
387
|
+
const u64 q1_q0 = (q1 << 32) + q0;
|
388
|
+
|
389
|
+
return MLIB_INIT(mlib_int128_divmod_result){
|
390
|
+
MLIB_INIT(mlib_int128) MLIB_INT128_FROM_PARTS(q1_q0, q3_q2),
|
391
|
+
MLIB_INIT(mlib_int128) MLIB_INT128_FROM_PARTS(rem, 0),
|
392
|
+
};
|
393
|
+
}
|
394
|
+
|
395
|
+
// Normalize for a Knuth 4.3.1D division. Convert the integers into two
|
396
|
+
// base-32 numbers, with u and v being arrays of digits:
|
397
|
+
u32 u[5] = {
|
398
|
+
(u32)(adjusted.r.lo << d),
|
399
|
+
(u32)(adjusted.r.lo >> (32 - d)),
|
400
|
+
(u32)(adjusted.r.hi << d),
|
401
|
+
(u32)(adjusted.r.hi >> (32 - d)),
|
402
|
+
0,
|
403
|
+
};
|
404
|
+
|
405
|
+
if (d != 0) {
|
406
|
+
// Extra bits from overlap:
|
407
|
+
u[2] |= (u32)(adjusted.r.lo >> (64 - d));
|
408
|
+
u[4] |= (u32)(adjusted.r.hi >> (64 - d));
|
409
|
+
}
|
410
|
+
|
411
|
+
u32 v[2] = {
|
412
|
+
(u32)(denom << d),
|
413
|
+
(u32)(denom >> (32 - d)),
|
414
|
+
};
|
415
|
+
|
416
|
+
u32 qparts[3] = {0};
|
417
|
+
|
418
|
+
_mlibKnuth431D(u, 5, v, 2, qparts);
|
419
|
+
|
420
|
+
u64 rem = ((u64)u[1] << (32 - d)) | (u[0] >> d);
|
421
|
+
u64 quo = ((u64)qparts[1] << 32) | qparts[0];
|
422
|
+
return MLIB_INIT(mlib_int128_divmod_result){
|
423
|
+
MLIB_INIT(mlib_int128) MLIB_INT128_FROM_PARTS(quo, numer.r.hi / denom),
|
424
|
+
MLIB_INIT(mlib_int128) MLIB_INT128_FROM_PARTS(rem, 0),
|
425
|
+
};
|
446
426
|
}
|
447
427
|
|
448
428
|
/**
|
@@ -452,200 +432,184 @@ _mlibDivide_u128_by_u64 (const mlib_int128 numer, const uint64_t denom)
|
|
452
432
|
* @param denom The divisor
|
453
433
|
* @return A struct with .quotient and .remainder results
|
454
434
|
*/
|
455
|
-
static mlib_constexpr_fn mlib_int128_divmod_result
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
MLIB_INT128_CAST (q[0] | (uint64_t) q[1] << 32),
|
537
|
-
remainder,
|
538
|
-
};
|
539
|
-
}
|
435
|
+
static mlib_constexpr_fn mlib_int128_divmod_result mlib_int128_divmod(mlib_int128 numer, mlib_int128 denom) {
|
436
|
+
const uint64_t nhi = numer.r.hi;
|
437
|
+
const uint64_t nlo = numer.r.lo;
|
438
|
+
const uint64_t dhi = denom.r.hi;
|
439
|
+
const uint64_t dlo = denom.r.lo;
|
440
|
+
if (dhi > nhi) {
|
441
|
+
// Denominator is definitely larger than numerator. Quotient is zero,
|
442
|
+
// remainder is full numerator.
|
443
|
+
return MLIB_INIT(mlib_int128_divmod_result){MLIB_INT128(0), numer};
|
444
|
+
} else if (dhi == nhi) {
|
445
|
+
// High words are equal
|
446
|
+
if (nhi == 0) {
|
447
|
+
// Both high words are zero, so this is just a division of two 64bit
|
448
|
+
// numbers
|
449
|
+
return MLIB_INIT(mlib_int128_divmod_result){
|
450
|
+
MLIB_INT128_CAST(nlo / dlo),
|
451
|
+
MLIB_INT128_CAST(nlo % dlo),
|
452
|
+
};
|
453
|
+
} else if (nlo > dlo) {
|
454
|
+
// The numerator is larger than the denom and the high word on the
|
455
|
+
// denom is non-zero, so this cannot divide to anything greater than 1.
|
456
|
+
return MLIB_INIT(mlib_int128_divmod_result){
|
457
|
+
MLIB_INT128(1),
|
458
|
+
mlib_int128_sub(numer, denom),
|
459
|
+
};
|
460
|
+
} else if (nlo < dlo) {
|
461
|
+
// numer.r.lo < denom.r.lo and denom.r.hi > denom.r.lo, so the
|
462
|
+
// integer division becomes zero
|
463
|
+
return MLIB_INIT(mlib_int128_divmod_result){
|
464
|
+
MLIB_INT128(0),
|
465
|
+
numer,
|
466
|
+
};
|
467
|
+
} else {
|
468
|
+
// N / N is one
|
469
|
+
return MLIB_INIT(mlib_int128_divmod_result){MLIB_INT128(1), MLIB_INT128(0)};
|
470
|
+
}
|
471
|
+
} else if (dhi == 0) {
|
472
|
+
// No high in denominator. We can use a u128/u64
|
473
|
+
return _mlibDivide_u128_by_u64(numer, denom.r.lo);
|
474
|
+
} else {
|
475
|
+
// We'll need to do a full u128/u128 division
|
476
|
+
// Normalize for Knuth 4.3.1D
|
477
|
+
int d = _mlibCountLeadingZeros_u64(denom.r.hi);
|
478
|
+
// Does the denom have only three base32 digits?
|
479
|
+
const bool has_three = d >= 32;
|
480
|
+
d &= 31;
|
481
|
+
|
482
|
+
uint32_t u[5] = {
|
483
|
+
(uint32_t)(numer.r.lo << d),
|
484
|
+
(uint32_t)(numer.r.lo >> (32 - d)),
|
485
|
+
(uint32_t)(numer.r.hi << d),
|
486
|
+
(uint32_t)(numer.r.hi >> (32 - d)),
|
487
|
+
0,
|
488
|
+
};
|
489
|
+
uint32_t v[4] = {
|
490
|
+
(uint32_t)(denom.r.lo << d),
|
491
|
+
(uint32_t)(denom.r.lo >> (32 - d)),
|
492
|
+
(uint32_t)(denom.r.hi << d),
|
493
|
+
(uint32_t)(denom.r.hi >> (32 - d)),
|
494
|
+
};
|
495
|
+
if (d != 0) {
|
496
|
+
u[2] |= (uint32_t)(numer.r.lo >> (64 - d));
|
497
|
+
u[4] |= (uint32_t)(numer.r.hi >> (64 - d));
|
498
|
+
v[2] |= (uint32_t)(denom.r.lo >> (64 - d));
|
499
|
+
};
|
500
|
+
|
501
|
+
uint32_t q[2] = {0};
|
502
|
+
if (has_three) {
|
503
|
+
_mlibKnuth431D(u, 5, v, 3, q);
|
504
|
+
} else {
|
505
|
+
_mlibKnuth431D(u, 5, v, 4, q);
|
506
|
+
}
|
507
|
+
|
508
|
+
mlib_int128 remainder = MLIB_INT128_FROM_PARTS(((uint64_t)u[1] << 32) | u[0], ((uint64_t)u[3] << 32) | u[2]);
|
509
|
+
remainder = mlib_int128_rshift(remainder, d);
|
510
|
+
|
511
|
+
return MLIB_INIT(mlib_int128_divmod_result){
|
512
|
+
MLIB_INT128_CAST(q[0] | (uint64_t)q[1] << 32),
|
513
|
+
remainder,
|
514
|
+
};
|
515
|
+
}
|
540
516
|
}
|
541
517
|
|
542
518
|
/**
|
543
519
|
* @brief Perform a division of two 128-bit numbers
|
544
520
|
*/
|
545
|
-
static mlib_constexpr_fn mlib_int128
|
546
|
-
|
547
|
-
{
|
548
|
-
return mlib_int128_divmod (numer, denom).quotient;
|
521
|
+
static mlib_constexpr_fn mlib_int128 mlib_int128_div(mlib_int128 numer, mlib_int128 denom) {
|
522
|
+
return mlib_int128_divmod(numer, denom).quotient;
|
549
523
|
}
|
550
524
|
|
551
525
|
/**
|
552
526
|
* @brief Perform a modulus of two 128-bit numbers
|
553
527
|
*/
|
554
|
-
static mlib_constexpr_fn mlib_int128
|
555
|
-
|
556
|
-
{
|
557
|
-
return mlib_int128_divmod (numer, denom).remainder;
|
528
|
+
static mlib_constexpr_fn mlib_int128 mlib_int128_mod(mlib_int128 numer, mlib_int128 denom) {
|
529
|
+
return mlib_int128_divmod(numer, denom).remainder;
|
558
530
|
}
|
559
531
|
|
560
532
|
/**
|
561
533
|
* @brief Get the nth power of ten as a 128-bit number
|
562
534
|
*/
|
563
|
-
static mlib_constexpr_fn mlib_int128
|
564
|
-
|
565
|
-
{
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
}
|
570
|
-
return r;
|
535
|
+
static mlib_constexpr_fn mlib_int128 mlib_int128_pow10(uint8_t nth) {
|
536
|
+
mlib_int128 r = MLIB_INT128(1);
|
537
|
+
while (nth-- > 0) {
|
538
|
+
r = mlib_int128_mul(r, MLIB_INT128(10));
|
539
|
+
}
|
540
|
+
return r;
|
571
541
|
}
|
572
542
|
|
573
543
|
/**
|
574
544
|
* @brief Get the Nth power of two as a 128-bit number
|
575
545
|
*/
|
576
|
-
static mlib_constexpr_fn mlib_int128
|
577
|
-
|
578
|
-
{
|
579
|
-
return mlib_int128_lshift (MLIB_INT128 (1), (int) nth);
|
546
|
+
static mlib_constexpr_fn mlib_int128 mlib_int128_pow2(uint8_t nth) {
|
547
|
+
return mlib_int128_lshift(MLIB_INT128(1), (int)nth);
|
580
548
|
}
|
581
549
|
|
582
550
|
/**
|
583
551
|
* @brief Read a 128-bit unsigned integer from a base-10 string
|
584
552
|
*/
|
585
|
-
static mlib_constexpr_fn mlib_int128
|
586
|
-
|
587
|
-
{
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
}
|
633
|
-
return ret;
|
553
|
+
static mlib_constexpr_fn mlib_int128 mlib_int128_from_string(const char *s, const char **end) {
|
554
|
+
int radix = 10;
|
555
|
+
if (mlib_strlen(s) > 2 && s[0] == '0') {
|
556
|
+
// Check for a different radix
|
557
|
+
char b = s[1];
|
558
|
+
if (b == 'b' || b == 'B') {
|
559
|
+
radix = 2;
|
560
|
+
s += 2;
|
561
|
+
} else if (b == 'c' || b == 'C') {
|
562
|
+
radix = 8;
|
563
|
+
s += 2;
|
564
|
+
} else if (b == 'x' || b == 'X') {
|
565
|
+
radix = 16;
|
566
|
+
s += 2;
|
567
|
+
} else {
|
568
|
+
radix = 8;
|
569
|
+
s += 1;
|
570
|
+
}
|
571
|
+
}
|
572
|
+
|
573
|
+
mlib_int128 ret = MLIB_INT128(0);
|
574
|
+
for (; *s; ++s) {
|
575
|
+
char c = *s;
|
576
|
+
if (c == '\'') {
|
577
|
+
// Digit separator. Skip it;
|
578
|
+
continue;
|
579
|
+
}
|
580
|
+
if (c >= 'a') {
|
581
|
+
// Uppercase (if a letter, otherwise some other punct):
|
582
|
+
c = (char)(c - ('a' - 'A'));
|
583
|
+
}
|
584
|
+
int digit = c - '0';
|
585
|
+
if (c >= 'A') {
|
586
|
+
// It's actually a letter (or garbage, which we'll catch later)
|
587
|
+
digit = (c - 'A') + 10;
|
588
|
+
}
|
589
|
+
if (digit > radix || digit < 0) {
|
590
|
+
// The digit is outside of our radix, or garbage
|
591
|
+
break;
|
592
|
+
}
|
593
|
+
ret = mlib_int128_mul(ret, MLIB_INT128_CAST(radix));
|
594
|
+
ret = mlib_int128_add(ret, MLIB_INT128_CAST(digit));
|
595
|
+
}
|
596
|
+
if (end) {
|
597
|
+
*end = s;
|
598
|
+
}
|
599
|
+
return ret;
|
634
600
|
}
|
635
601
|
|
636
602
|
/**
|
637
603
|
* @brief Truncate a 128-bit number to a 64-bit number
|
638
604
|
*/
|
639
|
-
static mlib_constexpr_fn uint64_t
|
640
|
-
|
641
|
-
{
|
642
|
-
return v.r.lo;
|
605
|
+
static mlib_constexpr_fn uint64_t mlib_int128_to_u64(mlib_int128 v) {
|
606
|
+
return v.r.lo;
|
643
607
|
}
|
644
608
|
|
645
609
|
/// The result type of formatting a 128-bit number
|
646
610
|
typedef struct {
|
647
|
-
|
648
|
-
|
611
|
+
/// The character array of the number as a base10 string. Null-terminated.
|
612
|
+
char str[40];
|
649
613
|
} mlib_int128_charbuf;
|
650
614
|
|
651
615
|
/**
|
@@ -653,31 +617,29 @@ typedef struct {
|
|
653
617
|
*
|
654
618
|
* @return mlib_int128_charbuf a struct containing a .str character array
|
655
619
|
*/
|
656
|
-
static mlib_constexpr_fn mlib_int128_charbuf
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
into.str[len] = 0;
|
680
|
-
return into;
|
620
|
+
static mlib_constexpr_fn mlib_int128_charbuf mlib_int128_format(mlib_int128 i) {
|
621
|
+
mlib_int128_charbuf into = {{0}};
|
622
|
+
char *out = into.str + (sizeof into) - 1;
|
623
|
+
int len = 0;
|
624
|
+
if (mlib_int128_eq(i, MLIB_INT128(0))) {
|
625
|
+
*out-- = '0';
|
626
|
+
len = 1;
|
627
|
+
}
|
628
|
+
while (!mlib_int128_eq(i, MLIB_INT128(0))) {
|
629
|
+
mlib_int128_divmod_result dm = mlib_int128_divmod(i, MLIB_INT128(10));
|
630
|
+
uint64_t v = mlib_int128_to_u64(dm.remainder);
|
631
|
+
char digits[] = "0123456789";
|
632
|
+
char d = digits[v];
|
633
|
+
*out = d;
|
634
|
+
--out;
|
635
|
+
i = dm.quotient;
|
636
|
+
++len;
|
637
|
+
}
|
638
|
+
for (int j = 0; j < len; ++j) {
|
639
|
+
into.str[j] = out[j + 1];
|
640
|
+
}
|
641
|
+
into.str[len] = 0;
|
642
|
+
return into;
|
681
643
|
}
|
682
644
|
|
683
645
|
MLIB_C_LINKAGE_END
|