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
@@ -12,158 +12,32 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
import
|
16
|
-
|
17
|
-
|
18
|
-
from
|
19
|
-
|
20
|
-
from pymongocrypt.
|
21
|
-
from pymongocrypt.
|
22
|
-
from pymongocrypt.
|
15
|
+
import platform
|
16
|
+
import sys
|
17
|
+
|
18
|
+
from packaging.version import Version
|
19
|
+
|
20
|
+
from pymongocrypt.asynchronous.state_machine import AsyncMongoCryptCallback
|
21
|
+
from pymongocrypt.binary import MongoCryptBinaryIn, MongoCryptBinaryOut
|
22
|
+
from pymongocrypt.binding import _to_string, ffi, lib
|
23
|
+
from pymongocrypt.compat import str_to_bytes
|
24
|
+
from pymongocrypt.crypto import (
|
25
|
+
aes_256_cbc_decrypt,
|
26
|
+
aes_256_cbc_encrypt,
|
27
|
+
aes_256_ctr_decrypt,
|
28
|
+
aes_256_ctr_encrypt,
|
29
|
+
hmac_sha_256,
|
30
|
+
hmac_sha_512,
|
31
|
+
secure_random,
|
32
|
+
sha_256,
|
33
|
+
sign_rsaes_pkcs1_v1_5,
|
34
|
+
)
|
23
35
|
from pymongocrypt.errors import MongoCryptError
|
24
|
-
from pymongocrypt.
|
25
|
-
|
26
|
-
from pymongocrypt.crypto import (aes_256_cbc_encrypt,
|
27
|
-
aes_256_cbc_decrypt,
|
28
|
-
aes_256_ctr_decrypt,
|
29
|
-
aes_256_ctr_encrypt,
|
30
|
-
hmac_sha_256,
|
31
|
-
hmac_sha_512,
|
32
|
-
sha_256,
|
33
|
-
secure_random,
|
34
|
-
sign_rsaes_pkcs1_v1_5)
|
35
|
-
|
36
|
-
|
37
|
-
class MongoCryptOptions(object):
|
38
|
-
def __init__(self, kms_providers, schema_map=None, encrypted_fields_map=None,
|
39
|
-
bypass_query_analysis=False, crypt_shared_lib_path=None,
|
40
|
-
crypt_shared_lib_required=False, bypass_encryption=False):
|
41
|
-
"""Options for :class:`MongoCrypt`.
|
42
|
-
|
43
|
-
:Parameters:
|
44
|
-
- `kms_providers`: Map of KMS provider options. The kms_providers
|
45
|
-
map values differ by provider:
|
46
|
-
- `aws`: Map with "accessKeyId" and "secretAccessKey" as strings,
|
47
|
-
and optionally a "sessionToken" for temporary credentials.
|
48
|
-
- `azure`: Map with "clientId" and "clientSecret" as strings.
|
49
|
-
- `gcp`: Map with "email" as a string and "privateKey" as
|
50
|
-
a byte array or a base64-encoded string.
|
51
|
-
- `kmip`: Map with "endpoint" as a string.
|
52
|
-
- `local`: Map with "key" as a 96-byte array or the equivalent
|
53
|
-
base64-encoded string.
|
54
|
-
- `schema_map`: Optional map of collection namespace ("db.coll") to
|
55
|
-
JSON Schema. By default, a collection's JSONSchema is periodically
|
56
|
-
polled with the listCollections command. But a JSONSchema may be
|
57
|
-
specified locally with the schemaMap option.
|
58
|
-
|
59
|
-
Supplying a `schema_map` provides more security than relying on
|
60
|
-
JSON Schemas obtained from the server. It protects against a
|
61
|
-
malicious server advertising a false JSON Schema, which could trick
|
62
|
-
the client into sending unencrypted data that should be encrypted.
|
63
|
-
|
64
|
-
Schemas supplied in the schemaMap only apply to configuring
|
65
|
-
automatic encryption for client side encryption. Other validation
|
66
|
-
rules in the JSON schema will not be enforced by the driver and
|
67
|
-
will result in an error.
|
68
|
-
- `encrypted_fields_map`: Optional map encoded to BSON `bytes`.
|
69
|
-
- `bypass_query_analysis`: If ``True``, disable automatic analysis of
|
70
|
-
outgoing commands. Set `bypass_query_analysis` to use explicit
|
71
|
-
encryption on indexed fields without the MongoDB Enterprise Advanced
|
72
|
-
licensed crypt_shared library.
|
73
|
-
- `crypt_shared_lib_path`: Optional string path to the crypt_shared
|
74
|
-
library.
|
75
|
-
- `crypt_shared_lib_required`: Whether to require a crypt_shared
|
76
|
-
library.
|
77
|
-
- `bypass_encryption`: Whether to bypass encryption.
|
78
|
-
|
79
|
-
.. versionadded:: 1.3
|
80
|
-
``crypt_shared_lib_path``, ``crypt_shared_lib_path``,
|
81
|
-
``bypass_encryption`` parameters.
|
82
|
-
|
83
|
-
.. versionadded:: 1.1
|
84
|
-
Support for "azure" and "gcp" kms_providers.
|
85
|
-
Support for temporary AWS credentials via "sessionToken".
|
86
|
-
|
87
|
-
.. versionchanged:: 1.1
|
88
|
-
For kmsProvider "local", the "key" field can now be specified
|
89
|
-
as either a 96-byte array or the equivalent base64-encoded string.
|
90
|
-
"""
|
91
|
-
if not isinstance(kms_providers, dict):
|
92
|
-
raise ValueError('kms_providers must be a dict')
|
93
|
-
if not kms_providers:
|
94
|
-
raise ValueError('at least one KMS provider must be configured')
|
95
|
-
|
96
|
-
if 'aws' in kms_providers:
|
97
|
-
aws = kms_providers["aws"]
|
98
|
-
if not isinstance(aws, dict):
|
99
|
-
raise ValueError("kms_providers['aws'] must be a dict")
|
100
|
-
if len(aws):
|
101
|
-
if "accessKeyId" not in aws or "secretAccessKey" not in aws:
|
102
|
-
raise ValueError("kms_providers['aws'] must contain "
|
103
|
-
"'accessKeyId' and 'secretAccessKey'")
|
104
|
-
|
105
|
-
if 'azure' in kms_providers:
|
106
|
-
azure = kms_providers["azure"]
|
107
|
-
if not isinstance(azure, dict):
|
108
|
-
raise ValueError("kms_providers['azure'] must be a dict")
|
109
|
-
if len(azure):
|
110
|
-
if 'clientId' not in azure or 'clientSecret' not in azure:
|
111
|
-
raise ValueError("kms_providers['azure'] must contain "
|
112
|
-
"'clientId' and 'clientSecret'")
|
113
|
-
|
114
|
-
if 'gcp' in kms_providers:
|
115
|
-
gcp = kms_providers['gcp']
|
116
|
-
if not isinstance(gcp, dict):
|
117
|
-
raise ValueError("kms_providers['gcp'] must be a dict")
|
118
|
-
if len(gcp):
|
119
|
-
if 'email' not in gcp or 'privateKey' not in gcp:
|
120
|
-
raise ValueError("kms_providers['gcp'] must contain "
|
121
|
-
"'email' and 'privateKey'")
|
122
|
-
if not isinstance(kms_providers['gcp']['privateKey'],
|
123
|
-
(bytes, unicode_type)):
|
124
|
-
raise TypeError("kms_providers['gcp']['privateKey'] must "
|
125
|
-
"be an instance of bytes or str")
|
126
|
-
|
127
|
-
if 'kmip' in kms_providers:
|
128
|
-
kmip = kms_providers['kmip']
|
129
|
-
if not isinstance(kmip, dict):
|
130
|
-
raise ValueError("kms_providers['kmip'] must be a dict")
|
131
|
-
if 'endpoint' not in kmip:
|
132
|
-
raise ValueError("kms_providers['kmip'] must contain "
|
133
|
-
"'endpoint'")
|
134
|
-
if not isinstance(kms_providers['kmip']['endpoint'],
|
135
|
-
(str, unicode_type)):
|
136
|
-
raise TypeError("kms_providers['kmip']['endpoint'] must "
|
137
|
-
"be an instance of str")
|
138
|
-
|
139
|
-
if 'local' in kms_providers:
|
140
|
-
local = kms_providers['local']
|
141
|
-
if not isinstance(local, dict):
|
142
|
-
raise ValueError("kms_providers['local'] must be a dict")
|
143
|
-
if 'key' not in local:
|
144
|
-
raise ValueError("kms_providers['local'] must contain 'key'")
|
145
|
-
if not isinstance(kms_providers['local']['key'],
|
146
|
-
(bytes, unicode_type)):
|
147
|
-
raise TypeError("kms_providers['local']['key'] must be an "
|
148
|
-
"instance of bytes or str")
|
149
|
-
|
150
|
-
if schema_map is not None and not isinstance(schema_map, bytes):
|
151
|
-
raise TypeError("schema_map must be bytes or None")
|
152
|
-
|
153
|
-
if encrypted_fields_map is not None and not isinstance(encrypted_fields_map, bytes):
|
154
|
-
raise TypeError("encrypted_fields_map must be bytes or None")
|
155
|
-
|
156
|
-
self.kms_providers = kms_providers
|
157
|
-
self.schema_map = schema_map
|
158
|
-
self.encrypted_fields_map = encrypted_fields_map
|
159
|
-
self.bypass_query_analysis = bypass_query_analysis
|
160
|
-
self.crypt_shared_lib_path = crypt_shared_lib_path
|
161
|
-
self.crypt_shared_lib_required = crypt_shared_lib_required
|
162
|
-
self.bypass_encryption = bypass_encryption
|
163
|
-
|
36
|
+
from pymongocrypt.options import MongoCryptOptions
|
37
|
+
from pymongocrypt.synchronous.state_machine import MongoCryptCallback
|
164
38
|
|
165
|
-
class MongoCrypt(object):
|
166
39
|
|
40
|
+
class MongoCrypt:
|
167
41
|
def __init__(self, options, callback):
|
168
42
|
"""Abstracts libmongocrypt's mongocrypt_t type.
|
169
43
|
|
@@ -178,8 +52,10 @@ class MongoCrypt(object):
|
|
178
52
|
if not isinstance(options, MongoCryptOptions):
|
179
53
|
raise TypeError("options must be a MongoCryptOptions")
|
180
54
|
|
181
|
-
if not isinstance(callback, MongoCryptCallback):
|
182
|
-
raise TypeError(
|
55
|
+
if not isinstance(callback, (AsyncMongoCryptCallback, MongoCryptCallback)):
|
56
|
+
raise TypeError(
|
57
|
+
"callback must be a MongoCryptCallback or AsyncMongoCryptCallback"
|
58
|
+
)
|
183
59
|
|
184
60
|
self.__crypt = lib.mongocrypt_new()
|
185
61
|
if self.__crypt == ffi.NULL:
|
@@ -195,63 +71,96 @@ class MongoCrypt(object):
|
|
195
71
|
def __init(self):
|
196
72
|
"""Internal init helper."""
|
197
73
|
kms_providers = self.__opts.kms_providers
|
198
|
-
with MongoCryptBinaryIn(
|
199
|
-
|
200
|
-
if not lib.mongocrypt_setopt_kms_providers(
|
201
|
-
self.__crypt, kmsopt.bin):
|
74
|
+
with MongoCryptBinaryIn(self.__callback.bson_encode(kms_providers)) as kmsopt:
|
75
|
+
if not lib.mongocrypt_setopt_kms_providers(self.__crypt, kmsopt.bin):
|
202
76
|
self.__raise_from_status()
|
203
77
|
|
204
78
|
schema_map = self.__opts.schema_map
|
205
79
|
if schema_map is not None:
|
206
80
|
with MongoCryptBinaryIn(schema_map) as binary_schema_map:
|
207
81
|
if not lib.mongocrypt_setopt_schema_map(
|
208
|
-
|
82
|
+
self.__crypt, binary_schema_map.bin
|
83
|
+
):
|
209
84
|
self.__raise_from_status()
|
210
85
|
|
211
86
|
encrypted_fields_map = self.__opts.encrypted_fields_map
|
212
87
|
if encrypted_fields_map is not None:
|
213
|
-
with MongoCryptBinaryIn(
|
88
|
+
with MongoCryptBinaryIn(
|
89
|
+
encrypted_fields_map
|
90
|
+
) as binary_encrypted_fields_map:
|
214
91
|
if not lib.mongocrypt_setopt_encrypted_field_config_map(
|
215
|
-
|
92
|
+
self.__crypt, binary_encrypted_fields_map.bin
|
93
|
+
):
|
216
94
|
self.__raise_from_status()
|
217
95
|
|
218
96
|
if self.__opts.bypass_query_analysis:
|
219
97
|
lib.mongocrypt_setopt_bypass_query_analysis(self.__crypt)
|
220
98
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
99
|
+
# Prefer using the native crypto binding when we know it's available.
|
100
|
+
try:
|
101
|
+
crypto_available = lib.mongocrypt_is_crypto_available()
|
102
|
+
except AttributeError:
|
103
|
+
# libmongocrypt < 1.9
|
104
|
+
crypto_available = False
|
105
|
+
|
106
|
+
if not crypto_available:
|
107
|
+
if not lib.mongocrypt_setopt_crypto_hooks(
|
108
|
+
self.__crypt,
|
109
|
+
aes_256_cbc_encrypt,
|
110
|
+
aes_256_cbc_decrypt,
|
111
|
+
secure_random,
|
112
|
+
hmac_sha_512,
|
113
|
+
hmac_sha_256,
|
114
|
+
sha_256,
|
115
|
+
ffi.NULL,
|
116
|
+
):
|
117
|
+
self.__raise_from_status()
|
225
118
|
|
226
|
-
|
227
|
-
self.__crypt, sign_rsaes_pkcs1_v1_5, ffi.NULL
|
228
|
-
|
119
|
+
if not lib.mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs1_v1_5(
|
120
|
+
self.__crypt, sign_rsaes_pkcs1_v1_5, ffi.NULL
|
121
|
+
):
|
122
|
+
self.__raise_from_status()
|
229
123
|
|
230
|
-
|
231
|
-
self.__crypt, aes_256_ctr_encrypt, aes_256_ctr_decrypt, ffi.NULL
|
232
|
-
|
124
|
+
if not lib.mongocrypt_setopt_aes_256_ctr(
|
125
|
+
self.__crypt, aes_256_ctr_encrypt, aes_256_ctr_decrypt, ffi.NULL
|
126
|
+
):
|
127
|
+
self.__raise_from_status()
|
128
|
+
elif sys.platform == "darwin" and Version(platform.mac_ver()[0]) < Version(
|
129
|
+
"10.15"
|
130
|
+
):
|
131
|
+
# MONGOCRYPT-440 libmongocrypt does not support AES-CTR on macOS < 10.15.
|
132
|
+
if not lib.mongocrypt_setopt_aes_256_ctr(
|
133
|
+
self.__crypt, aes_256_ctr_encrypt, aes_256_ctr_decrypt, ffi.NULL
|
134
|
+
):
|
135
|
+
self.__raise_from_status()
|
233
136
|
|
234
137
|
if self.__opts.crypt_shared_lib_path is not None:
|
235
138
|
lib.mongocrypt_setopt_set_crypt_shared_lib_path_override(
|
236
|
-
self.__crypt, self.__opts.crypt_shared_lib_path.encode("utf-8")
|
139
|
+
self.__crypt, self.__opts.crypt_shared_lib_path.encode("utf-8")
|
140
|
+
)
|
237
141
|
|
238
142
|
if not self.__opts.bypass_encryption:
|
239
|
-
lib.mongocrypt_setopt_append_crypt_shared_lib_search_path(
|
240
|
-
|
241
|
-
|
242
|
-
|
143
|
+
lib.mongocrypt_setopt_append_crypt_shared_lib_search_path(
|
144
|
+
self.__crypt, b"$SYSTEM"
|
145
|
+
)
|
146
|
+
on_demand_aws = "aws" in kms_providers and not len(kms_providers["aws"])
|
147
|
+
on_demand_gcp = "gcp" in kms_providers and not len(kms_providers["gcp"])
|
148
|
+
on_demand_azure = "azure" in kms_providers and not len(kms_providers["azure"])
|
243
149
|
if any([on_demand_aws, on_demand_gcp, on_demand_azure]):
|
244
150
|
lib.mongocrypt_setopt_use_need_kms_credentials_state(self.__crypt)
|
245
151
|
|
246
152
|
if not lib.mongocrypt_init(self.__crypt):
|
247
153
|
self.__raise_from_status()
|
248
154
|
|
249
|
-
if
|
155
|
+
if (
|
156
|
+
self.__opts.crypt_shared_lib_required
|
157
|
+
and self.crypt_shared_lib_version is None
|
158
|
+
):
|
250
159
|
raise MongoCryptError(
|
251
160
|
"crypt_shared_lib_required=True but the crypt_shared library could not be loaded "
|
252
|
-
"from crypt_shared_lib_path={}"
|
253
|
-
|
254
|
-
|
161
|
+
f"from crypt_shared_lib_path={self.__opts.crypt_shared_lib_path}"
|
162
|
+
+ " or the operating system's dynamic library search path"
|
163
|
+
)
|
255
164
|
|
256
165
|
def __raise_from_status(self):
|
257
166
|
status = lib.mongocrypt_status_new()
|
@@ -300,7 +209,9 @@ class MongoCrypt(object):
|
|
300
209
|
:Returns:
|
301
210
|
A :class:`EncryptionContext`.
|
302
211
|
"""
|
303
|
-
return EncryptionContext(
|
212
|
+
return EncryptionContext(
|
213
|
+
self._create_context(), self.__opts.kms_providers, database, command
|
214
|
+
)
|
304
215
|
|
305
216
|
def decryption_context(self, command):
|
306
217
|
"""Creates a context to use for decryption.
|
@@ -311,7 +222,9 @@ class MongoCrypt(object):
|
|
311
222
|
:Returns:
|
312
223
|
A :class:`DecryptionContext`.
|
313
224
|
"""
|
314
|
-
return DecryptionContext(
|
225
|
+
return DecryptionContext(
|
226
|
+
self._create_context(), self.__opts.kms_providers, command
|
227
|
+
)
|
315
228
|
|
316
229
|
def explicit_encryption_context(self, value, opts):
|
317
230
|
"""Creates a context to use for explicit encryption.
|
@@ -325,7 +238,8 @@ class MongoCrypt(object):
|
|
325
238
|
A :class:`ExplicitEncryptionContext`.
|
326
239
|
"""
|
327
240
|
return ExplicitEncryptionContext(
|
328
|
-
self._create_context(), self.__opts.kms_providers, value, opts
|
241
|
+
self._create_context(), self.__opts.kms_providers, value, opts
|
242
|
+
)
|
329
243
|
|
330
244
|
def explicit_decryption_context(self, value):
|
331
245
|
"""Creates a context to use for explicit decryption.
|
@@ -337,8 +251,9 @@ class MongoCrypt(object):
|
|
337
251
|
:Returns:
|
338
252
|
A :class:`ExplicitDecryptionContext`.
|
339
253
|
"""
|
340
|
-
return ExplicitDecryptionContext(
|
341
|
-
self.__opts.kms_providers, value
|
254
|
+
return ExplicitDecryptionContext(
|
255
|
+
self._create_context(), self.__opts.kms_providers, value
|
256
|
+
)
|
342
257
|
|
343
258
|
def data_key_context(self, kms_provider, opts=None):
|
344
259
|
"""Creates a context to use for key generation.
|
@@ -350,8 +265,13 @@ class MongoCrypt(object):
|
|
350
265
|
:Returns:
|
351
266
|
A :class:`DataKeyContext`.
|
352
267
|
"""
|
353
|
-
return DataKeyContext(
|
354
|
-
|
268
|
+
return DataKeyContext(
|
269
|
+
self._create_context(),
|
270
|
+
self.__opts.kms_providers,
|
271
|
+
kms_provider,
|
272
|
+
opts,
|
273
|
+
self.__callback,
|
274
|
+
)
|
355
275
|
|
356
276
|
def rewrap_many_data_key_context(self, filter, provider, master_key):
|
357
277
|
"""Creates a context to use for rewrapping many data keys.
|
@@ -367,11 +287,18 @@ class MongoCrypt(object):
|
|
367
287
|
:Returns:
|
368
288
|
A :class:`RewrapManyDataKeyContext`.
|
369
289
|
"""
|
370
|
-
return RewrapManyDataKeyContext(
|
290
|
+
return RewrapManyDataKeyContext(
|
291
|
+
self._create_context(),
|
292
|
+
self.__opts.kms_providers,
|
293
|
+
filter,
|
294
|
+
provider,
|
295
|
+
master_key,
|
296
|
+
self.__callback,
|
297
|
+
)
|
371
298
|
|
372
299
|
|
373
|
-
class MongoCryptContext
|
374
|
-
__slots__ = ("__ctx", "
|
300
|
+
class MongoCryptContext:
|
301
|
+
__slots__ = ("__ctx", "kms_providers")
|
375
302
|
|
376
303
|
def __init__(self, ctx, kms_providers):
|
377
304
|
"""Abstracts libmongocrypt's mongocrypt_ctx_t type.
|
@@ -382,7 +309,7 @@ class MongoCryptContext(object):
|
|
382
309
|
- `kms_providers`: The KMS provider map.
|
383
310
|
"""
|
384
311
|
self.__ctx = ctx
|
385
|
-
self.
|
312
|
+
self.kms_providers = kms_providers
|
386
313
|
|
387
314
|
def _close(self):
|
388
315
|
"""Cleanup resources."""
|
@@ -433,10 +360,6 @@ class MongoCryptContext(object):
|
|
433
360
|
if not lib.mongocrypt_ctx_mongo_done(self.__ctx):
|
434
361
|
self._raise_from_status()
|
435
362
|
|
436
|
-
def ask_for_kms_credentials(self):
|
437
|
-
"""Get on-demand kms credentials"""
|
438
|
-
return _ask_for_kms_credentials(self.__kms_providers)
|
439
|
-
|
440
363
|
def provide_kms_providers(self, providers):
|
441
364
|
"""Provide a map of KMS providers."""
|
442
365
|
with MongoCryptBinaryIn(providers) as binary:
|
@@ -476,13 +399,14 @@ class EncryptionContext(MongoCryptContext):
|
|
476
399
|
- `database`: Optional, the name of the database.
|
477
400
|
- `command`: The BSON command to encrypt.
|
478
401
|
"""
|
479
|
-
super(
|
402
|
+
super().__init__(ctx, kms_providers)
|
480
403
|
self.database = database
|
481
404
|
try:
|
482
405
|
with MongoCryptBinaryIn(command) as binary:
|
483
406
|
database = str_to_bytes(database)
|
484
407
|
if not lib.mongocrypt_ctx_encrypt_init(
|
485
|
-
|
408
|
+
ctx, database, len(database), binary.bin
|
409
|
+
):
|
486
410
|
self._raise_from_status()
|
487
411
|
except Exception:
|
488
412
|
# Destroy the context on error.
|
@@ -502,7 +426,7 @@ class DecryptionContext(MongoCryptContext):
|
|
502
426
|
- `kms_providers`: The KMS provider map.
|
503
427
|
- `command`: The encoded BSON command to decrypt.
|
504
428
|
"""
|
505
|
-
super(
|
429
|
+
super().__init__(ctx, kms_providers)
|
506
430
|
try:
|
507
431
|
with MongoCryptBinaryIn(command) as binary:
|
508
432
|
if not lib.mongocrypt_ctx_decrypt_init(ctx, binary.bin):
|
@@ -527,7 +451,7 @@ class ExplicitEncryptionContext(MongoCryptContext):
|
|
527
451
|
form { "v" : BSON value to encrypt }}.
|
528
452
|
- `opts`: A :class:`ExplicitEncryptOpts`.
|
529
453
|
"""
|
530
|
-
super(
|
454
|
+
super().__init__(ctx, kms_providers)
|
531
455
|
try:
|
532
456
|
algorithm = str_to_bytes(opts.algorithm)
|
533
457
|
if not lib.mongocrypt_ctx_setopt_algorithm(ctx, algorithm, -1):
|
@@ -549,17 +473,23 @@ class ExplicitEncryptionContext(MongoCryptContext):
|
|
549
473
|
self._raise_from_status()
|
550
474
|
|
551
475
|
if opts.contention_factor is not None:
|
552
|
-
if not lib.mongocrypt_ctx_setopt_contention_factor(
|
476
|
+
if not lib.mongocrypt_ctx_setopt_contention_factor(
|
477
|
+
ctx, opts.contention_factor
|
478
|
+
):
|
553
479
|
self._raise_from_status()
|
554
480
|
|
555
481
|
if opts.range_opts is not None:
|
556
482
|
with MongoCryptBinaryIn(opts.range_opts) as range_opts:
|
557
|
-
if not lib.mongocrypt_ctx_setopt_algorithm_range(
|
483
|
+
if not lib.mongocrypt_ctx_setopt_algorithm_range(
|
484
|
+
ctx, range_opts.bin
|
485
|
+
):
|
558
486
|
self._raise_from_status()
|
559
487
|
|
560
488
|
with MongoCryptBinaryIn(value) as binary:
|
561
489
|
if opts.is_expression:
|
562
|
-
if not lib.mongocrypt_ctx_explicit_encrypt_expression_init(
|
490
|
+
if not lib.mongocrypt_ctx_explicit_encrypt_expression_init(
|
491
|
+
ctx, binary.bin
|
492
|
+
):
|
563
493
|
self._raise_from_status()
|
564
494
|
else:
|
565
495
|
if not lib.mongocrypt_ctx_explicit_encrypt_init(ctx, binary.bin):
|
@@ -582,12 +512,11 @@ class ExplicitDecryptionContext(MongoCryptContext):
|
|
582
512
|
- `kms_providers`: The KMS provider map.
|
583
513
|
- `value`: The encoded BSON value to decrypt.
|
584
514
|
"""
|
585
|
-
super(
|
515
|
+
super().__init__(ctx, kms_providers)
|
586
516
|
|
587
517
|
try:
|
588
518
|
with MongoCryptBinaryIn(value) as binary:
|
589
|
-
if not lib.mongocrypt_ctx_explicit_decrypt_init(ctx,
|
590
|
-
binary.bin):
|
519
|
+
if not lib.mongocrypt_ctx_explicit_decrypt_init(ctx, binary.bin):
|
591
520
|
self._raise_from_status()
|
592
521
|
except Exception:
|
593
522
|
# Destroy the context on error.
|
@@ -609,60 +538,61 @@ class DataKeyContext(MongoCryptContext):
|
|
609
538
|
- `opts`: An optional class:`DataKeyOpts`.
|
610
539
|
- `callback`: A :class:`MongoCryptCallback`.
|
611
540
|
"""
|
612
|
-
super(
|
541
|
+
super().__init__(ctx, kms_providers)
|
613
542
|
try:
|
614
|
-
if kms_provider not in
|
615
|
-
raise ValueError(
|
543
|
+
if kms_provider not in kms_providers:
|
544
|
+
raise ValueError(f"unknown kms_provider: {kms_provider}")
|
616
545
|
|
546
|
+
# Account for provider names like "local:myname".
|
547
|
+
provider_type = kms_provider.split(":")[0]
|
617
548
|
if opts is None or opts.master_key is None:
|
618
|
-
if
|
549
|
+
if provider_type in ["kmip", "local"]:
|
619
550
|
master_key = {}
|
620
551
|
else:
|
621
552
|
raise ValueError(
|
622
|
-
|
623
|
-
|
553
|
+
f"master_key is required for kms_provider: {kms_provider!r}"
|
554
|
+
)
|
624
555
|
else:
|
625
556
|
master_key = opts.master_key.copy()
|
626
557
|
|
627
|
-
if
|
628
|
-
if
|
629
|
-
'key' not in master_key):
|
558
|
+
if provider_type == "aws":
|
559
|
+
if "region" not in master_key or "key" not in master_key:
|
630
560
|
raise ValueError(
|
631
561
|
'master_key must include "region" and "key" for '
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
562
|
+
f"kms_provider: {kms_provider!r}"
|
563
|
+
)
|
564
|
+
elif provider_type == "azure":
|
565
|
+
if "keyName" not in master_key or "keyVaultEndpoint" not in master_key:
|
636
566
|
raise ValueError(
|
637
567
|
'master key must include "keyName" and '
|
638
|
-
'"keyVaultEndpoint" for kms_provider:
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
568
|
+
f'"keyVaultEndpoint" for kms_provider: {kms_provider!r}'
|
569
|
+
)
|
570
|
+
elif provider_type == "gcp":
|
571
|
+
if (
|
572
|
+
"projectId" not in master_key
|
573
|
+
or "location" not in master_key
|
574
|
+
or "keyRing" not in master_key
|
575
|
+
or "keyName" not in master_key
|
576
|
+
):
|
644
577
|
raise ValueError(
|
645
578
|
'master key must include "projectId", "location",'
|
646
|
-
'"keyRing", and "keyName" for kms_provider:
|
579
|
+
f'"keyRing", and "keyName" for kms_provider: {kms_provider!r}'
|
580
|
+
)
|
647
581
|
|
648
|
-
master_key[
|
649
|
-
with MongoCryptBinaryIn(
|
650
|
-
|
651
|
-
if not lib.mongocrypt_ctx_setopt_key_encryption_key(
|
652
|
-
ctx, mkey.bin):
|
582
|
+
master_key["provider"] = kms_provider
|
583
|
+
with MongoCryptBinaryIn(callback.bson_encode(master_key)) as mkey:
|
584
|
+
if not lib.mongocrypt_ctx_setopt_key_encryption_key(ctx, mkey.bin):
|
653
585
|
self._raise_from_status()
|
654
586
|
|
655
587
|
if opts.key_alt_names:
|
656
588
|
for key_alt_name in opts.key_alt_names:
|
657
589
|
with MongoCryptBinaryIn(key_alt_name) as binary:
|
658
|
-
if not lib.mongocrypt_ctx_setopt_key_alt_name(
|
659
|
-
ctx, binary.bin):
|
590
|
+
if not lib.mongocrypt_ctx_setopt_key_alt_name(ctx, binary.bin):
|
660
591
|
self._raise_from_status()
|
661
592
|
|
662
593
|
if opts.key_material:
|
663
594
|
with MongoCryptBinaryIn(opts.key_material) as binary:
|
664
|
-
if not lib.mongocrypt_ctx_setopt_key_material(
|
665
|
-
ctx, binary.bin):
|
595
|
+
if not lib.mongocrypt_ctx_setopt_key_material(ctx, binary.bin):
|
666
596
|
self._raise_from_status()
|
667
597
|
|
668
598
|
if not lib.mongocrypt_ctx_datakey_init(ctx):
|
@@ -673,7 +603,7 @@ class DataKeyContext(MongoCryptContext):
|
|
673
603
|
raise
|
674
604
|
|
675
605
|
|
676
|
-
class MongoCryptKmsContext
|
606
|
+
class MongoCryptKmsContext:
|
677
607
|
__slots__ = ("__ctx",)
|
678
608
|
|
679
609
|
def __init__(self, ctx):
|
@@ -727,8 +657,7 @@ class MongoCryptKmsContext(object):
|
|
727
657
|
|
728
658
|
.. versionadded:: 1.2
|
729
659
|
"""
|
730
|
-
return _to_string(
|
731
|
-
lib.mongocrypt_kms_ctx_get_kms_provider(self.__ctx, ffi.NULL))
|
660
|
+
return _to_string(lib.mongocrypt_kms_ctx_get_kms_provider(self.__ctx, ffi.NULL))
|
732
661
|
|
733
662
|
def feed(self, data):
|
734
663
|
"""Feed bytes from the HTTP response.
|
@@ -754,8 +683,7 @@ class MongoCryptKmsContext(object):
|
|
754
683
|
class RewrapManyDataKeyContext(MongoCryptContext):
|
755
684
|
__slots__ = ()
|
756
685
|
|
757
|
-
def __init__(self, ctx, kms_providers, filter, provider, master_key,
|
758
|
-
callback):
|
686
|
+
def __init__(self, ctx, kms_providers, filter, provider, master_key, callback):
|
759
687
|
"""Abstracts libmongocrypt's mongocrypt_ctx_t type.
|
760
688
|
|
761
689
|
:Parameters:
|
@@ -767,7 +695,7 @@ class RewrapManyDataKeyContext(MongoCryptContext):
|
|
767
695
|
- `master_key`: Optional document for the given provider.
|
768
696
|
- `callback`: A :class:`MongoCryptCallback`.
|
769
697
|
"""
|
770
|
-
super(
|
698
|
+
super().__init__(ctx, kms_providers)
|
771
699
|
key_encryption_key_bson = None
|
772
700
|
if provider is not None:
|
773
701
|
data = dict(provider=provider)
|
@@ -778,7 +706,9 @@ class RewrapManyDataKeyContext(MongoCryptContext):
|
|
778
706
|
try:
|
779
707
|
if key_encryption_key_bson:
|
780
708
|
with MongoCryptBinaryIn(key_encryption_key_bson) as binary:
|
781
|
-
if not lib.mongocrypt_ctx_setopt_key_encryption_key(
|
709
|
+
if not lib.mongocrypt_ctx_setopt_key_encryption_key(
|
710
|
+
ctx, binary.bin
|
711
|
+
):
|
782
712
|
self._raise_from_status()
|
783
713
|
|
784
714
|
filter_bson = callback.bson_encode(filter)
|