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.
Files changed (385) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +33 -0
  3. data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +12 -1
  4. data/ext/libmongocrypt/libmongocrypt/CODEOWNERS +1 -4
  5. data/ext/libmongocrypt/libmongocrypt/Earthfile +151 -3
  6. data/ext/libmongocrypt/libmongocrypt/README.md +36 -40
  7. data/ext/libmongocrypt/libmongocrypt/bindings/cs/CMakeLists.txt +1 -0
  8. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Driver.snk +0 -0
  9. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/AssemblyInfo.cs +2 -2
  10. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Binary.cs +16 -2
  11. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClientFactory.cs +8 -4
  12. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Library.cs +10 -0
  13. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/LibraryLoader.cs +81 -44
  14. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/MongoDB.Libmongocrypt.csproj +2 -1
  15. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/MongoDB.Libmongocrypt.Test.csproj +2 -0
  16. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test32/MongoDB.Libmongocrypt.Test32.csproj +2 -0
  17. data/ext/libmongocrypt/libmongocrypt/bindings/cs/README.md +3 -0
  18. data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.cake +21 -26
  19. data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.config +3 -0
  20. data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.sh +0 -0
  21. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/benchmarks/build.gradle.kts +28 -0
  22. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/benchmarks/src/main/java/com/mongodb/crypt/benchmark/BenchmarkRunner.java +217 -0
  23. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/benchmarks/src/main/resources/keyDocument.json +24 -0
  24. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/build.gradle.kts +21 -6
  25. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradle/wrapper/gradle-wrapper.jar +0 -0
  26. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradle/wrapper/gradle-wrapper.properties +1 -1
  27. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradlew +154 -108
  28. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradlew.bat +7 -18
  29. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/settings.gradle.kts +1 -0
  30. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CAPI.java +41 -6
  31. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CAPIHelper.java +5 -5
  32. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CipherCallback.java +27 -1
  33. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptImpl.java +34 -19
  34. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoExplicitEncryptOptions.java +6 -4
  35. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/resources/META-INF/native-image/jni-config.json +180 -0
  36. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/resources/META-INF/native-image/reflect-config.json +134 -0
  37. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java +44 -2
  38. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/encrypted-payload.json +1 -1
  39. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/rangeopts.json +3 -0
  40. data/ext/libmongocrypt/libmongocrypt/bindings/node/README.md +4 -900
  41. data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +60 -0
  42. data/ext/libmongocrypt/libmongocrypt/bindings/python/README.rst +41 -20
  43. data/ext/libmongocrypt/libmongocrypt/bindings/python/RELEASE.rst +6 -24
  44. data/ext/libmongocrypt/libmongocrypt/bindings/python/build-manylinux-wheel.sh +4 -13
  45. data/ext/libmongocrypt/libmongocrypt/bindings/python/hatch_build.py +36 -0
  46. data/ext/libmongocrypt/libmongocrypt/bindings/python/libmongocrypt-version.txt +1 -0
  47. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/__init__.py +2 -2
  48. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/auto_encrypter.py +61 -0
  49. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/credentials.py +156 -0
  50. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/explicit_encrypter.py +156 -0
  51. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/state_machine.py +149 -0
  52. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/auto_encrypter.py +2 -46
  53. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binary.py +14 -17
  54. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +107 -61
  55. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/compat.py +6 -4
  56. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/credentials.py +2 -121
  57. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/crypto.py +31 -20
  58. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/errors.py +2 -2
  59. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/explicit_encrypter.py +2 -233
  60. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +168 -238
  61. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/options.py +265 -0
  62. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/state_machine.py +2 -141
  63. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/auto_encrypter.py +61 -0
  64. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/credentials.py +156 -0
  65. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/explicit_encrypter.py +156 -0
  66. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/state_machine.py +149 -0
  67. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +2 -2
  68. data/ext/libmongocrypt/libmongocrypt/bindings/python/pyproject.toml +118 -0
  69. data/ext/libmongocrypt/libmongocrypt/bindings/python/release.sh +97 -61
  70. data/ext/libmongocrypt/libmongocrypt/bindings/python/{test-requirements.txt → requirements-test.txt} +4 -1
  71. data/ext/libmongocrypt/libmongocrypt/bindings/python/requirements.txt +4 -0
  72. data/ext/libmongocrypt/libmongocrypt/bindings/python/sbom.json +76 -0
  73. data/ext/libmongocrypt/libmongocrypt/bindings/python/strip_header.py +6 -7
  74. data/ext/libmongocrypt/libmongocrypt/bindings/python/synchro.py +64 -0
  75. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/__init__.py +1 -0
  76. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/collection-info.json +1 -1
  77. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/command.json +1 -1
  78. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/compact/success/encrypted-payload.json +21 -21
  79. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-command-reply.json +1 -1
  80. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-field-config-map.json +1 -1
  81. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit-v2/int32/encrypted-payload.json +1 -1
  82. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit-v2/int32/rangeopts.json +3 -0
  83. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-rangePreview-explicit/int32/rangeopts.json +11 -0
  84. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-rangePreview-explicit/int32/value-to-encrypt.json +20 -0
  85. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document-azure.json +1 -1
  86. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document-gcp.json +1 -1
  87. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document.json +1 -1
  88. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-filter.json +1 -1
  89. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/list-collections-filter.json +1 -1
  90. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/mongocryptd-command.json +1 -1
  91. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/mongocryptd-reply.json +1 -1
  92. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/schema-map.json +1 -1
  93. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/performance/keyDocument.json +24 -0
  94. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/performance/perf_test.py +165 -0
  95. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_binding.py +8 -12
  96. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_crypto.py +9 -11
  97. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_mongocrypt.py +988 -340
  98. data/ext/libmongocrypt/libmongocrypt/bindings/python/update-sbom.sh +14 -0
  99. data/ext/libmongocrypt/libmongocrypt/cmake/FetchMongoC.cmake +19 -1
  100. data/ext/libmongocrypt/libmongocrypt/cmake/ImportBSON.cmake +23 -0
  101. data/ext/libmongocrypt/libmongocrypt/cmake/IntelDFP.cmake +19 -227
  102. data/ext/libmongocrypt/libmongocrypt/cmake/Patch.cmake +54 -0
  103. data/ext/libmongocrypt/libmongocrypt/doc/img/cli-icon.png +0 -0
  104. data/ext/libmongocrypt/libmongocrypt/doc/img/reference-targets.png +0 -0
  105. data/ext/libmongocrypt/libmongocrypt/doc/releasing.md +153 -0
  106. data/ext/libmongocrypt/libmongocrypt/etc/calc_release_version.py +61 -28
  107. data/ext/libmongocrypt/libmongocrypt/etc/calc_release_version_selftest.sh +73 -0
  108. data/ext/libmongocrypt/libmongocrypt/etc/cyclonedx.sbom.json +108 -0
  109. data/ext/libmongocrypt/libmongocrypt/etc/format.sh +1 -1
  110. data/ext/libmongocrypt/libmongocrypt/etc/libbson-remove-GCC-diagnostic-pragma.patch +27 -0
  111. data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-alpine-arm-fix.patch +17 -0
  112. data/ext/libmongocrypt/libmongocrypt/etc/packager.py +120 -91
  113. data/ext/libmongocrypt/libmongocrypt/etc/purls.txt +14 -0
  114. data/ext/libmongocrypt/libmongocrypt/etc/repo_config.yaml +56 -0
  115. data/ext/libmongocrypt/libmongocrypt/etc/silk-create-asset-group.sh +70 -0
  116. data/ext/libmongocrypt/libmongocrypt/etc/ssdlc_compliance_report.md +37 -0
  117. data/ext/libmongocrypt/libmongocrypt/etc/third_party_vulnerabilities.md +42 -0
  118. data/ext/libmongocrypt/libmongocrypt/integrating.md +18 -1
  119. data/ext/libmongocrypt/libmongocrypt/kms-message/CMakeLists.txt +11 -3
  120. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_gcp_request.c +1 -1
  121. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_reader_writer.c +17 -0
  122. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_reader_writer_private.h +6 -0
  123. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_request.c +211 -1
  124. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_response.c +163 -0
  125. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_tag_type_private.h +2 -1
  126. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_kmip_request.h +17 -0
  127. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_kmip_response.h +6 -0
  128. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_port.c +3 -2
  129. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request.c +4 -2
  130. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_str.c +2 -2
  131. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kmip_reader_writer.c +23 -2
  132. data/ext/libmongocrypt/libmongocrypt/src/crypto/libcrypto.c +13 -10
  133. data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.h +1 -1
  134. data/ext/libmongocrypt/libmongocrypt/src/mc-efc-private.h +16 -2
  135. data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +94 -6
  136. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +15 -5
  137. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +114 -53
  138. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private-v2.h +1 -1
  139. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private.h +1 -1
  140. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-v2.c +2 -2
  141. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload.c +2 -2
  142. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private-v2.h +21 -6
  143. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private.h +5 -5
  144. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-v2.c +38 -2
  145. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload.c +1 -1
  146. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private-v2.h +20 -7
  147. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private.h +8 -8
  148. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-v2.c +89 -1
  149. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-v2.c +3 -3
  150. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev.c +1 -23
  151. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds-private.h +4 -3
  152. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +15 -12
  153. data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +11 -0
  154. data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +16 -6
  155. data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +64 -22
  156. data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +23 -4
  157. data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +359 -65
  158. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +26 -14
  159. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +17 -6
  160. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +31 -13
  161. data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +16 -3
  162. data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +259 -63
  163. data/ext/libmongocrypt/libmongocrypt/src/mc-tokens-private.h +40 -24
  164. data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +57 -13
  165. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.h +17 -0
  166. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +5 -0
  167. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary-private.h +0 -5
  168. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer.c +5 -7
  169. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key.c +1 -0
  170. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth-private.h +16 -18
  171. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth.c +105 -76
  172. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto.c +9 -3
  173. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +170 -89
  174. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +5 -5
  175. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +505 -124
  176. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-private.h +31 -6
  177. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +81 -13
  178. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +7 -0
  179. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek-private.h +5 -1
  180. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek.c +161 -103
  181. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker-private.h +2 -7
  182. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +191 -69
  183. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key.c +1 -1
  184. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx-private.h +50 -15
  185. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx.c +365 -69
  186. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking-private.h +2 -1
  187. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +200 -107
  188. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +50 -5
  189. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +591 -15
  190. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +6 -13
  191. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util.c +3 -2
  192. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +47 -234
  193. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +75 -24
  194. data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +18 -2
  195. data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +4 -0
  196. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/bypassQueryAnalysis/payload.json +53 -0
  197. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/jsonSchema/cmd-to-mongocryptd.json +23 -0
  198. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/jsonSchema/cmd.json +20 -0
  199. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/cmd-to-mongocryptd.json +50 -0
  200. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/cmd.json +20 -0
  201. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/collinfo.json +44 -0
  202. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/encrypted-field-map.json +24 -0
  203. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/encrypted-payload-pattern.json +53 -0
  204. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/mongocryptd-reply.json +62 -0
  205. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/cmd-to-mongocryptd.json +30 -0
  206. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/cmd.json +17 -0
  207. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/mongocryptd-reply.json +39 -0
  208. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/payload.json +21 -0
  209. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/missing-key-id/collinfo.json +20 -0
  210. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/no-fields/collinfo.json +9 -0
  211. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/no-fields/encrypted-payload.json +4 -0
  212. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/cmd.json +1 -0
  213. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/collinfo.json +63 -0
  214. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/encrypted-field-config-map.json +61 -0
  215. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/encrypted-payload-range-v2.json +37 -0
  216. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/encrypted-payload.json +29 -0
  217. data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/cmd.json +1 -0
  218. data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/collinfo.json +64 -0
  219. data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/encrypted-payload-range-v2.json +105 -0
  220. data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/encrypted-payload.json +30 -0
  221. data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/cmd.json +1 -0
  222. data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/collinfo.json +49 -0
  223. data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/encrypted-field-config-map.json +47 -0
  224. data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/encrypted-payload.json +23 -0
  225. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/collinfo.json +15 -0
  226. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-field-config-map.json +10 -0
  227. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-payload-range-v2.json +104 -0
  228. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-payload.json +6 -0
  229. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/collinfo.json +4 -4
  230. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/encrypted-payload.json +3 -3
  231. data/ext/libmongocrypt/libmongocrypt/test/data/kms-azure/decrypt-response.txt +16 -0
  232. data/ext/libmongocrypt/libmongocrypt/test/data/kms-azure/encrypt-response.txt +16 -0
  233. data/ext/libmongocrypt/libmongocrypt/test/data/kms-azure/oauth-response.txt +19 -0
  234. data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/cmd.json +9 -0
  235. data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/encrypted-field-map.json +19 -0
  236. data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/encrypted-payload.json +62 -0
  237. data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/mongocryptd-reply.json +69 -0
  238. data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/cmd.json +11 -0
  239. data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/encrypted-field-map.json +19 -0
  240. data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/encrypted-payload.json +40 -0
  241. data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/mongocryptd-reply.json +47 -0
  242. data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_decimal128.cstruct +1 -1
  243. data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_double.cstruct +8637 -7958
  244. data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_int32.cstruct +5522 -1382
  245. data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_int64.cstruct +5042 -1262
  246. data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_decimal128.cstruct +1 -1
  247. data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_decimal128_precision.cstruct +1 -1
  248. data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_double.cstruct +1 -1
  249. data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_double_precision.cstruct +2 -2
  250. data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_int32.cstruct +1 -1
  251. data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_int64.cstruct +1 -1
  252. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/cmd.json +8 -0
  253. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/encrypted-field-map.json +19 -0
  254. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/encrypted-payload.json +53 -0
  255. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/mongocryptd-reply.json +58 -0
  256. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/cmd.json +11 -0
  257. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/encrypted-field-map.json +19 -0
  258. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/encrypted-payload.json +40 -0
  259. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/mongocryptd-reply.json +45 -0
  260. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32/expected.json +26 -0
  261. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32/to-encrypt.json +20 -0
  262. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32-defaults/expected.json +26 -0
  263. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32-defaults/to-encrypt.json +20 -0
  264. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-insert-double/expected.json +8 -0
  265. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-insert-int32/expected.json +8 -0
  266. data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-insert-int32-defaults/expected.json +8 -0
  267. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/README.md +7 -4
  268. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/mc.json +9 -5
  269. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/server.json +9 -5
  270. data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +1 -0
  271. data/ext/libmongocrypt/libmongocrypt/test/test-gcp-auth.c +8 -8
  272. data/ext/libmongocrypt/libmongocrypt/test/test-mc-efc.c +6 -4
  273. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-range-payload-v2.c +43 -3
  274. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup-v2.c +76 -0
  275. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-rfds.c +5 -5
  276. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-edge-generation.c +89 -14
  277. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +342 -76
  278. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +94 -12
  279. data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +205 -7
  280. data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +49 -23
  281. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +16 -19
  282. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.h +22 -1
  283. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache-oauth.c +94 -11
  284. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cleanup.c +374 -0
  285. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-compact.c +121 -42
  286. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +134 -4
  287. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +40 -0
  288. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.h +16 -0
  289. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-csfle-lib.c +11 -11
  290. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-decrypt.c +8 -5
  291. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +922 -92
  292. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +2 -2
  293. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +114 -12
  294. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +14 -9
  295. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-ctx.c +424 -3
  296. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-log.c +1 -1
  297. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-marking.c +447 -28
  298. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-opts.c +42 -0
  299. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-traverse-util.c +30 -26
  300. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.c +7 -0
  301. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.h +3 -0
  302. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +66 -14
  303. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +11 -0
  304. data/ext/libmongocrypt/libmongocrypt/test/test-named-kms-providers.c +2381 -0
  305. data/ext/libmongocrypt/libmongocrypt/test/util/HELP.autogen +3 -1
  306. data/ext/libmongocrypt/libmongocrypt/test/util/README.md +1 -0
  307. data/ext/libmongocrypt/libmongocrypt/test/util/csfle.c +4 -0
  308. data/ext/libmongocrypt/libmongocrypt/test/util/make_includes.py +1 -1
  309. data/ext/libmongocrypt/libmongocrypt/test/util/util.c +38 -3
  310. data/lib/libmongocrypt_helper/version.rb +2 -2
  311. metadata +112 -106
  312. checksums.yaml.gz.sig +0 -0
  313. data/ext/libmongocrypt/libmongocrypt/VERSION_CURRENT +0 -1
  314. data/ext/libmongocrypt/libmongocrypt/bindings/cs/cs.sln +0 -79
  315. data/ext/libmongocrypt/libmongocrypt/bindings/node/CHANGELOG.md +0 -105
  316. data/ext/libmongocrypt/libmongocrypt/bindings/node/LICENSE +0 -201
  317. data/ext/libmongocrypt/libmongocrypt/bindings/node/binding.gyp +0 -79
  318. data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/README.hbs +0 -44
  319. data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/build-static.sh +0 -36
  320. data/ext/libmongocrypt/libmongocrypt/bindings/node/index.d.ts +0 -641
  321. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/autoEncrypter.js +0 -420
  322. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/buffer_pool.js +0 -123
  323. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/clientEncryption.js +0 -821
  324. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/common.js +0 -98
  325. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/cryptoCallbacks.js +0 -87
  326. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/errors.js +0 -75
  327. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/index.js +0 -73
  328. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/mongocryptdManager.js +0 -66
  329. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/aws.js +0 -26
  330. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/azure.js +0 -178
  331. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/gcp.js +0 -24
  332. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/index.js +0 -54
  333. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/utils.js +0 -39
  334. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/stateMachine.js +0 -492
  335. data/ext/libmongocrypt/libmongocrypt/bindings/node/package-lock.json +0 -15302
  336. data/ext/libmongocrypt/libmongocrypt/bindings/node/package.json +0 -100
  337. data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.cc +0 -956
  338. data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.h +0 -114
  339. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/autoEncrypter.test.js +0 -950
  340. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/buffer_pool.test.js +0 -91
  341. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/clientEncryption.test.js +0 -1093
  342. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/common.test.js +0 -94
  343. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/cryptoCallbacks.test.js +0 -240
  344. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/README.md +0 -5
  345. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/cmd.json +0 -6
  346. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/collection-info.json +0 -37
  347. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encrypted-document-nested.json +0 -8
  348. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encrypted-document.json +0 -11
  349. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encryptedFields.json +0 -30
  350. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/key-document.json +0 -32
  351. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/key1-document.json +0 -30
  352. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/mongocryptd-reply.json +0 -18
  353. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/index.test.js +0 -45
  354. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/mongocryptdManager.test.js +0 -48
  355. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/providers/credentialsProvider.test.js +0 -551
  356. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/release.test.js +0 -66
  357. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/requirements.helper.js +0 -51
  358. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/stateMachine.test.js +0 -331
  359. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/chai-addons.js +0 -8
  360. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/mongodb_reporter.js +0 -325
  361. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/types/index.test-d.ts +0 -63
  362. data/ext/libmongocrypt/libmongocrypt/bindings/python/setup.py +0 -89
  363. data/ext/libmongocrypt/libmongocrypt/debian/build_snapshot.sh +0 -79
  364. data/ext/libmongocrypt/libmongocrypt/debian/changelog +0 -105
  365. data/ext/libmongocrypt/libmongocrypt/debian/compat +0 -1
  366. data/ext/libmongocrypt/libmongocrypt/debian/control +0 -41
  367. data/ext/libmongocrypt/libmongocrypt/debian/copyright +0 -129
  368. data/ext/libmongocrypt/libmongocrypt/debian/gbp.conf +0 -23
  369. data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt-dev.dirs +0 -2
  370. data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt-dev.install +0 -5
  371. data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt0.dirs +0 -1
  372. data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt0.install +0 -1
  373. data/ext/libmongocrypt/libmongocrypt/debian/rules +0 -46
  374. data/ext/libmongocrypt/libmongocrypt/debian/source/format +0 -1
  375. data/ext/libmongocrypt/libmongocrypt/debian/source/lintian-overrides +0 -3
  376. data/ext/libmongocrypt/libmongocrypt/debian/source/options +0 -1
  377. data/ext/libmongocrypt/libmongocrypt/debian/watch +0 -3
  378. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/mongocryptd-reply.json +0 -72
  379. data.tar.gz.sig +0 -1
  380. metadata.gz.sig +0 -0
  381. /data/ext/libmongocrypt/libmongocrypt/{bindings/node/test/data/kms-decrypt-reply.txt → test/data/kms-aws/decrypt-response.txt} +0 -0
  382. /data/ext/libmongocrypt/libmongocrypt/{bindings/node/test/data/kms-encrypt-reply.txt → test/data/kms-aws/encrypt-response.txt} +0 -0
  383. /data/ext/libmongocrypt/libmongocrypt/test/data/{gcp-auth → kms-gcp}/decrypt-response.txt +0 -0
  384. /data/ext/libmongocrypt/libmongocrypt/test/data/{gcp-auth → kms-gcp}/encrypt-response.txt +0 -0
  385. /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 copy
16
-
17
-
18
- from pymongocrypt.binary import (MongoCryptBinaryIn,
19
- MongoCryptBinaryOut)
20
- from pymongocrypt.binding import ffi, lib, _to_string
21
- from pymongocrypt.compat import str_to_bytes, unicode_type
22
- from pymongocrypt.credentials import _ask_for_kms_credentials
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.state_machine import MongoCryptCallback
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("callback must be a MongoCryptCallback")
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
- self.__callback.bson_encode(kms_providers)) as kmsopt:
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
- self.__crypt, binary_schema_map.bin):
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(encrypted_fields_map) as binary_encrypted_fields_map:
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
- self.__crypt, binary_encrypted_fields_map.bin):
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
- if not lib.mongocrypt_setopt_crypto_hooks(
222
- self.__crypt, aes_256_cbc_encrypt, aes_256_cbc_decrypt,
223
- secure_random, hmac_sha_512, hmac_sha_256, sha_256, ffi.NULL):
224
- self.__raise_from_status()
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
- if not lib.mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs1_v1_5(
227
- self.__crypt, sign_rsaes_pkcs1_v1_5, ffi.NULL):
228
- self.__raise_from_status()
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
- if not lib.mongocrypt_setopt_aes_256_ctr(
231
- self.__crypt, aes_256_ctr_encrypt, aes_256_ctr_decrypt, ffi.NULL):
232
- self.__raise_from_status()
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(self.__crypt, b"$SYSTEM")
240
- on_demand_aws = 'aws' in kms_providers and not len(kms_providers['aws'])
241
- on_demand_gcp = 'gcp' in kms_providers and not len(kms_providers['gcp'])
242
- on_demand_azure = 'azure' in kms_providers and not len(kms_providers['azure'])
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 self.__opts.crypt_shared_lib_required and self.crypt_shared_lib_version is None:
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={}".format(
253
- self.__opts.crypt_shared_lib_path) +
254
- " or the operating system's dynamic library search path")
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(self._create_context(), self.__opts.kms_providers, database, command)
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(self._create_context(), self.__opts.kms_providers, command)
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(self._create_context(),
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(self._create_context(), self.__opts.kms_providers, kms_provider, opts,
354
- self.__callback)
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(self._create_context(), self.__opts.kms_providers, filter, provider, master_key, self.__callback)
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(object):
374
- __slots__ = ("__ctx", "__kms_providers")
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.__kms_providers = kms_providers
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(EncryptionContext, self).__init__(ctx, kms_providers)
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
- ctx, database, len(database), binary.bin):
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(DecryptionContext, self).__init__(ctx, kms_providers)
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(ExplicitEncryptionContext, self).__init__(ctx, kms_providers)
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(ctx, opts.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(ctx, range_opts.bin):
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(ctx, binary.bin):
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(ExplicitDecryptionContext, self).__init__(ctx, kms_providers)
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(DataKeyContext, self).__init__(ctx, kms_providers)
541
+ super().__init__(ctx, kms_providers)
613
542
  try:
614
- if kms_provider not in ['aws', 'gcp', 'azure', 'kmip', 'local']:
615
- raise ValueError('unknown kms_provider: %s' % (kms_provider,))
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 kms_provider in ['kmip', 'local']:
549
+ if provider_type in ["kmip", "local"]:
619
550
  master_key = {}
620
551
  else:
621
552
  raise ValueError(
622
- 'master_key is required for kms_provider: "%s"' % (
623
- kms_provider,))
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 kms_provider == 'aws':
628
- if ('region' not in master_key or
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
- 'kms_provider: "aws"')
633
- elif kms_provider == 'azure':
634
- if ('keyName' not in master_key or
635
- 'keyVaultEndpoint' not in master_key):
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: "azure"')
639
- elif kms_provider == 'gcp':
640
- if ('projectId' not in master_key or
641
- 'location' not in master_key or
642
- 'keyRing' not in master_key or
643
- 'keyName' not in master_key):
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: "gcp"')
579
+ f'"keyRing", and "keyName" for kms_provider: {kms_provider!r}'
580
+ )
647
581
 
648
- master_key['provider'] = kms_provider
649
- with MongoCryptBinaryIn(
650
- callback.bson_encode(master_key)) as mkey:
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(object):
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(RewrapManyDataKeyContext, self).__init__(ctx, kms_providers)
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(ctx, binary.bin):
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)