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
@@ -17,8 +17,15 @@
17
17
  /* For each field, check a valid value, invalid value, missing value */
18
18
 
19
19
  #include "bson/bson.h"
20
+ #include "mc-fle-blob-subtype-private.h"
21
+ #include "mc-tokens-private.h"
22
+ #include "mongocrypt-buffer-private.h"
23
+ #include "mongocrypt-ciphertext-private.h"
20
24
  #include "mongocrypt-marking-private.h"
25
+ #include "mongocrypt.h"
26
+ #include "test-mongocrypt-assert.h"
21
27
  #include "test-mongocrypt.h"
28
+ #include <stdbool.h>
22
29
 
23
30
  /* Create a basis marking buffer with valid values for the given fields. */
24
31
  static void _make_marking(bson_t *bson, _mongocrypt_buffer_t *buf) {
@@ -187,10 +194,24 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
187
194
  const char *expectedMinCover;
188
195
  mc_optional_int64_t sparsity;
189
196
  const char *expectedError;
197
+ const char *expectedErrorAtParseTime;
198
+ bool disableRangeV2;
190
199
  } testcase_t;
191
200
 
192
201
  testcase_t tests[] = {
193
- {.description = "Int32 Bounds included",
202
+ {.description = "Range V2 disabled w/ trim factor fails",
203
+ .findSpecJSON = RAW_STRING({
204
+ "lowerBound" : {"$numberInt" : "7"},
205
+ "lbIncluded" : true,
206
+ "upperBound" : {"$numberInt" : "32"},
207
+ "ubIncluded" : true,
208
+ "indexMin" : {"$numberInt" : "0"},
209
+ "indexMax" : {"$numberInt" : "32"},
210
+ "trimFactor" : 0
211
+ }),
212
+ .disableRangeV2 = true,
213
+ .expectedErrorAtParseTime = "'trimFactor' is not supported for QE range v1"},
214
+ {.description = "Range V2 disabled w/ no trim factor succeeds",
194
215
  .findSpecJSON = RAW_STRING({
195
216
  "lowerBound" : {"$numberInt" : "7"},
196
217
  "lbIncluded" : true,
@@ -199,6 +220,21 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
199
220
  "indexMin" : {"$numberInt" : "0"},
200
221
  "indexMax" : {"$numberInt" : "32"}
201
222
  }),
223
+ .disableRangeV2 = true,
224
+ .expectedMinCover = "000111\n"
225
+ "001\n"
226
+ "01\n"
227
+ "100000\n"},
228
+ {.description = "Int32 Bounds included",
229
+ .findSpecJSON = RAW_STRING({
230
+ "lowerBound" : {"$numberInt" : "7"},
231
+ "lbIncluded" : true,
232
+ "upperBound" : {"$numberInt" : "32"},
233
+ "ubIncluded" : true,
234
+ "indexMin" : {"$numberInt" : "0"},
235
+ "indexMax" : {"$numberInt" : "32"},
236
+ "trimFactor" : 0
237
+ }),
202
238
  .expectedMinCover = "000111\n"
203
239
  "001\n"
204
240
  "01\n"
@@ -211,7 +247,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
211
247
  "upperBound" : {"$numberInt" : "32"},
212
248
  "ubIncluded" : false,
213
249
  "indexMin" : {"$numberInt" : "0"},
214
- "indexMax" : {"$numberInt" : "32"}
250
+ "indexMax" : {"$numberInt" : "32"},
251
+ "trimFactor" : 0
215
252
  }),
216
253
  .expectedMinCover = "001\n"
217
254
  "01\n"},
@@ -222,7 +259,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
222
259
  "upperBound" : {"$numberInt" : "32"},
223
260
  "ubIncluded" : false,
224
261
  "indexMin" : {"$numberInt" : "0"},
225
- "indexMax" : {"$numberInt" : "32"}
262
+ "indexMax" : {"$numberInt" : "32"},
263
+ "trimFactor" : 0
226
264
  }),
227
265
  .expectedMinCover = "000111\n"
228
266
  "001\n"
@@ -234,7 +272,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
234
272
  "upperBound" : {"$numberInt" : "32"},
235
273
  "ubIncluded" : true,
236
274
  "indexMin" : {"$numberInt" : "0"},
237
- "indexMax" : {"$numberInt" : "32"}
275
+ "indexMax" : {"$numberInt" : "32"},
276
+ "trimFactor" : 0
238
277
  }),
239
278
  .expectedMinCover = "001\n"
240
279
  "01\n"
@@ -246,7 +285,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
246
285
  "upperBound" : {"$numberDouble" : "Infinity"},
247
286
  "ubIncluded" : true,
248
287
  "indexMin" : {"$numberInt" : "0"},
249
- "indexMax" : {"$numberInt" : "32"}
288
+ "indexMax" : {"$numberInt" : "32"},
289
+ "trimFactor" : 0
250
290
  }),
251
291
  .expectedMinCover = "000111\n"
252
292
  "001\n"
@@ -259,7 +299,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
259
299
  "upperBound" : {"$numberInt" : "8"},
260
300
  "ubIncluded" : true,
261
301
  "indexMin" : {"$numberInt" : "0"},
262
- "indexMax" : {"$numberInt" : "32"}
302
+ "indexMax" : {"$numberInt" : "32"},
303
+ "trimFactor" : 0
263
304
  }),
264
305
  .expectedMinCover = "000\n"
265
306
  "001000\n"},
@@ -270,10 +311,150 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
270
311
  "upperBound" : {"$numberDouble" : "Infinity"},
271
312
  "ubIncluded" : true,
272
313
  "indexMin" : {"$numberInt" : "0"},
273
- "indexMax" : {"$numberInt" : "32"}
314
+ "indexMax" : {"$numberInt" : "32"},
315
+ "trimFactor" : 0
316
+ }),
317
+ .expectedMinCover = "0\n"
318
+ "100000\n"},
319
+ {.description = "Int32 mincover=root no trimming",
320
+ .findSpecJSON = RAW_STRING({
321
+ "lowerBound" : {"$numberDouble" : "-Infinity"},
322
+ "lbIncluded" : true,
323
+ "upperBound" : {"$numberDouble" : "Infinity"},
324
+ "ubIncluded" : true,
325
+ "indexMin" : {"$numberInt" : "0"},
326
+ "indexMax" : {"$numberInt" : "31"},
327
+ "trimFactor" : 0
328
+ }),
329
+ .expectedMinCover = "root\n"},
330
+ {.description = "Int32 mincover=root TF=1",
331
+ .findSpecJSON = RAW_STRING({
332
+ "lowerBound" : {"$numberDouble" : "-Infinity"},
333
+ "lbIncluded" : true,
334
+ "upperBound" : {"$numberDouble" : "Infinity"},
335
+ "ubIncluded" : true,
336
+ "indexMin" : {"$numberInt" : "0"},
337
+ "indexMax" : {"$numberInt" : "31"},
338
+ "trimFactor" : 1
274
339
  }),
275
340
  .expectedMinCover = "0\n"
341
+ "1\n"},
342
+ {.description = "Int32 mincover=root TF=3",
343
+ .findSpecJSON = RAW_STRING({
344
+ "lowerBound" : {"$numberDouble" : "-Infinity"},
345
+ "lbIncluded" : true,
346
+ "upperBound" : {"$numberDouble" : "Infinity"},
347
+ "ubIncluded" : true,
348
+ "indexMin" : {"$numberInt" : "0"},
349
+ "indexMax" : {"$numberInt" : "31"},
350
+ "trimFactor" : 3
351
+ }),
352
+ .expectedMinCover = "000\n"
353
+ "001\n"
354
+ "010\n"
355
+ "011\n"
356
+ "100\n"
357
+ "101\n"
358
+ "110\n"
359
+ "111\n"},
360
+ {.description = "Int32 infinite both bounds SP=2",
361
+ .findSpecJSON = RAW_STRING({
362
+ "lowerBound" : {"$numberDouble" : "-Infinity"},
363
+ "lbIncluded" : true,
364
+ "upperBound" : {"$numberDouble" : "Infinity"},
365
+ "ubIncluded" : true,
366
+ "indexMin" : {"$numberInt" : "0"},
367
+ "indexMax" : {"$numberInt" : "32"},
368
+ "trimFactor" : 0
369
+ }),
370
+ .sparsity = OPT_I64(2),
371
+ .expectedMinCover = "00\n"
372
+ "01\n"
276
373
  "100000\n"},
374
+ {.description = "Int32 infinite both bounds TF=1",
375
+ .findSpecJSON = RAW_STRING({
376
+ "lowerBound" : {"$numberDouble" : "-Infinity"},
377
+ "lbIncluded" : true,
378
+ "upperBound" : {"$numberDouble" : "Infinity"},
379
+ "ubIncluded" : true,
380
+ "indexMin" : {"$numberInt" : "0"},
381
+ "indexMax" : {"$numberInt" : "32"},
382
+ "trimFactor" : 1
383
+ }),
384
+ .expectedMinCover = "0\n"
385
+ "100000\n"},
386
+ {.description = "Int32 infinite both bounds TF=2",
387
+ .findSpecJSON = RAW_STRING({
388
+ "lowerBound" : {"$numberDouble" : "-Infinity"},
389
+ "lbIncluded" : true,
390
+ "upperBound" : {"$numberDouble" : "Infinity"},
391
+ "ubIncluded" : true,
392
+ "indexMin" : {"$numberInt" : "0"},
393
+ "indexMax" : {"$numberInt" : "32"},
394
+ "trimFactor" : 2
395
+ }),
396
+ .expectedMinCover = "00\n"
397
+ "01\n"
398
+ "100000\n"},
399
+
400
+ {.description = "Int32 infinite both bounds TF=3",
401
+ .findSpecJSON = RAW_STRING({
402
+ "lowerBound" : {"$numberDouble" : "-Infinity"},
403
+ "lbIncluded" : true,
404
+ "upperBound" : {"$numberDouble" : "Infinity"},
405
+ "ubIncluded" : true,
406
+ "indexMin" : {"$numberInt" : "0"},
407
+ "indexMax" : {"$numberInt" : "32"},
408
+ "trimFactor" : 3
409
+ }),
410
+ .expectedMinCover = "000\n"
411
+ "001\n"
412
+ "010\n"
413
+ "011\n"
414
+ "100000\n"},
415
+ {.description = "Int32 infinite both bounds SP=2 TF=3",
416
+ .findSpecJSON = RAW_STRING({
417
+ "lowerBound" : {"$numberDouble" : "-Infinity"},
418
+ "lbIncluded" : true,
419
+ "upperBound" : {"$numberDouble" : "Infinity"},
420
+ "ubIncluded" : true,
421
+ "indexMin" : {"$numberInt" : "0"},
422
+ "indexMax" : {"$numberInt" : "32"},
423
+ "trimFactor" : 3
424
+ }),
425
+ .sparsity = OPT_I64(2),
426
+ .expectedMinCover = "0000\n"
427
+ "0001\n"
428
+ "0010\n"
429
+ "0011\n"
430
+ "0100\n"
431
+ "0101\n"
432
+ "0110\n"
433
+ "0111\n"
434
+ "100000\n"},
435
+ {.description = "Too large trim factor fails",
436
+ .findSpecJSON = RAW_STRING({
437
+ "lowerBound" : {"$numberDouble" : "-Infinity"},
438
+ "lbIncluded" : true,
439
+ "upperBound" : {"$numberDouble" : "Infinity"},
440
+ "ubIncluded" : true,
441
+ "indexMin" : {"$numberInt" : "0"},
442
+ "indexMax" : {"$numberInt" : "32"},
443
+ "trimFactor" : 6
444
+ }),
445
+ .expectedError =
446
+ "Trim factor must be less than the number of bits (6) used to represent an element of the domain"},
447
+ {.description = "Negative trim factor fails",
448
+ .findSpecJSON = RAW_STRING({
449
+ "lowerBound" : {"$numberDouble" : "-Infinity"},
450
+ "lbIncluded" : true,
451
+ "upperBound" : {"$numberDouble" : "Infinity"},
452
+ "ubIncluded" : true,
453
+ "indexMin" : {"$numberInt" : "0"},
454
+ "indexMax" : {"$numberInt" : "32"},
455
+ "trimFactor" : -1
456
+ }),
457
+ .expectedErrorAtParseTime = "'trimFactor' must be non-negative"},
277
458
  {.description = "Int64 Bounds included",
278
459
  .findSpecJSON = RAW_STRING({
279
460
  "lowerBound" : {"$numberLong" : "0"},
@@ -281,7 +462,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
281
462
  "upperBound" : {"$numberLong" : "823"},
282
463
  "ubIncluded" : true,
283
464
  "indexMin" : {"$numberLong" : "-1000000000000000"},
284
- "indexMax" : {"$numberLong" : "8070450532247928832"}
465
+ "indexMax" : {"$numberLong" : "8070450532247928832"},
466
+ "trimFactor" : 0
285
467
  }),
286
468
  .expectedMinCover = "000000000000011100011010111111010100100110001101000000\n"
287
469
  "00000000000001110001101011111101010010011000110100000100\n"
@@ -299,7 +481,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
299
481
  "upperBound" : {"$numberLong" : "823"},
300
482
  "ubIncluded" : false,
301
483
  "indexMin" : {"$numberLong" : "-1000000000000000"},
302
- "indexMax" : {"$numberLong" : "8070450532247928832"}
484
+ "indexMax" : {"$numberLong" : "8070450532247928832"},
485
+ "trimFactor" : 0
303
486
  }),
304
487
  .expectedMinCover = "000000000000011100011010111111010100100110001101000000000000001\n"
305
488
  "00000000000001110001101011111101010010011000110100000000000001\n"
@@ -332,7 +515,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
332
515
  "upperBound" : {"$numberLong" : "823"},
333
516
  "ubIncluded" : false,
334
517
  "indexMin" : {"$numberLong" : "-1000000000000000"},
335
- "indexMax" : {"$numberLong" : "8070450532247928832"}
518
+ "indexMax" : {"$numberLong" : "8070450532247928832"},
519
+ "trimFactor" : 0
336
520
  }),
337
521
  .expectedMinCover = "000000000000011100011010111111010100100110001101000000\n"
338
522
  "00000000000001110001101011111101010010011000110100000100\n"
@@ -353,7 +537,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
353
537
  "upperBound" : {"$numberLong" : "823"},
354
538
  "ubIncluded" : true,
355
539
  "indexMin" : {"$numberLong" : "-1000000000000000"},
356
- "indexMax" : {"$numberLong" : "8070450532247928832"}
540
+ "indexMax" : {"$numberLong" : "8070450532247928832"},
541
+ "trimFactor" : 0
357
542
  }),
358
543
  .expectedMinCover = "000000000000011100011010111111010100100110001101000000000000001\n"
359
544
  "00000000000001110001101011111101010010011000110100000000000001\n"
@@ -382,7 +567,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
382
567
  "upperBound" : {"$numberDouble" : "Infinity"},
383
568
  "ubIncluded" : true,
384
569
  "indexMin" : {"$numberLong" : "0"},
385
- "indexMax" : {"$numberLong" : "7"}
570
+ "indexMax" : {"$numberLong" : "7"},
571
+ "trimFactor" : 0
386
572
  }),
387
573
  .expectedMinCover = "001\n"
388
574
  "01\n"
@@ -394,7 +580,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
394
580
  "upperBound" : {"$numberLong" : "5"},
395
581
  "ubIncluded" : true,
396
582
  "indexMin" : {"$numberLong" : "0"},
397
- "indexMax" : {"$numberLong" : "7"}
583
+ "indexMax" : {"$numberLong" : "7"},
584
+ "trimFactor" : 0
398
585
  }),
399
586
  .expectedMinCover = "0\n"
400
587
  "10\n"},
@@ -405,7 +592,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
405
592
  "upperBound" : {"$numberDouble" : "Infinity"},
406
593
  "ubIncluded" : true,
407
594
  "indexMin" : {"$numberLong" : "0"},
408
- "indexMax" : {"$numberLong" : "7"}
595
+ "indexMax" : {"$numberLong" : "7"},
596
+ "trimFactor" : 0
409
597
  }),
410
598
  .expectedMinCover = "root\n"},
411
599
  {.description = "Mismatched types",
@@ -415,7 +603,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
415
603
  "upperBound" : {"$numberLong" : "2"},
416
604
  "ubIncluded" : true,
417
605
  "indexMin" : {"$numberLong" : "0"},
418
- "indexMax" : {"$numberLong" : "7"}
606
+ "indexMax" : {"$numberLong" : "7"},
607
+ "trimFactor" : 0
419
608
  }),
420
609
  .expectedError = "expected lowerBound to match index type"},
421
610
  {.description = "Int32 exclusive lower bound > upper bound",
@@ -425,7 +614,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
425
614
  "upperBound" : {"$numberInt" : "7"},
426
615
  "ubIncluded" : true,
427
616
  "indexMin" : {"$numberInt" : "0"},
428
- "indexMax" : {"$numberInt" : "32"}
617
+ "indexMax" : {"$numberInt" : "32"},
618
+ "trimFactor" : 0
429
619
  }),
430
620
  .expectedError = "must be less than or equal to range max"},
431
621
  {.description = "Int64 exclusive lower bound > upper bound",
@@ -435,7 +625,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
435
625
  "upperBound" : {"$numberLong" : "7"},
436
626
  "ubIncluded" : true,
437
627
  "indexMin" : {"$numberLong" : "0"},
438
- "indexMax" : {"$numberLong" : "32"}
628
+ "indexMax" : {"$numberLong" : "32"},
629
+ "trimFactor" : 0
439
630
  }),
440
631
  .expectedError = "must be less than or equal to range max"},
441
632
  {.description = "Int32 exclusive upper bound < lower bound",
@@ -445,7 +636,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
445
636
  "upperBound" : {"$numberInt" : "7"},
446
637
  "ubIncluded" : false,
447
638
  "indexMin" : {"$numberInt" : "0"},
448
- "indexMax" : {"$numberInt" : "32"}
639
+ "indexMax" : {"$numberInt" : "32"},
640
+ "trimFactor" : 0
449
641
  }),
450
642
  .expectedError = "must be less than or equal to range max"},
451
643
  {.description = "Int64 exclusive upper bound < lower bound",
@@ -455,7 +647,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
455
647
  "upperBound" : {"$numberLong" : "7"},
456
648
  "ubIncluded" : false,
457
649
  "indexMin" : {"$numberLong" : "0"},
458
- "indexMax" : {"$numberLong" : "32"}
650
+ "indexMax" : {"$numberLong" : "32"},
651
+ "trimFactor" : 0
459
652
  }),
460
653
  .expectedError = "must be less than or equal to range max"},
461
654
  {.description = "Int32 exclusive bounds cross",
@@ -465,7 +658,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
465
658
  "upperBound" : {"$numberInt" : "7"},
466
659
  "ubIncluded" : false,
467
660
  "indexMin" : {"$numberInt" : "0"},
468
- "indexMax" : {"$numberInt" : "32"}
661
+ "indexMax" : {"$numberInt" : "32"},
662
+ "trimFactor" : 0
469
663
  }),
470
664
  .expectedError = "must be less than or equal to range max"},
471
665
  {.description = "Int64 exclusive bounds cross",
@@ -475,7 +669,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
475
669
  "upperBound" : {"$numberLong" : "7"},
476
670
  "ubIncluded" : false,
477
671
  "indexMin" : {"$numberLong" : "0"},
478
- "indexMax" : {"$numberLong" : "32"}
672
+ "indexMax" : {"$numberLong" : "32"},
673
+ "trimFactor" : 0
479
674
  }),
480
675
  .expectedError = "must be less than or equal to range max"},
481
676
  {.description = "Int32 exclusive upper bound is 0",
@@ -485,7 +680,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
485
680
  "upperBound" : {"$numberInt" : "0"},
486
681
  "ubIncluded" : false,
487
682
  "indexMin" : {"$numberInt" : "0"},
488
- "indexMax" : {"$numberInt" : "32"}
683
+ "indexMax" : {"$numberInt" : "32"},
684
+ "trimFactor" : 0
489
685
  }),
490
686
  .expectedError = "must be greater than the range minimum"},
491
687
  {.description = "Double inclusive bounds",
@@ -495,7 +691,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
495
691
  "upperBound" : {"$numberDouble" : "35.25"},
496
692
  "ubIncluded" : true,
497
693
  "indexMin" : {"$numberDouble" : "0"},
498
- "indexMax" : {"$numberDouble" : "1000"}
694
+ "indexMax" : {"$numberDouble" : "1000"},
695
+ "trimFactor" : 0
499
696
  }),
500
697
  .expectedMinCover = "11000000001101111\n"
501
698
  "1100000000111\n"
@@ -511,7 +708,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
511
708
  "upperBound" : {"$numberDouble" : "35.25"},
512
709
  "ubIncluded" : false,
513
710
  "indexMin" : {"$numberDouble" : "0"},
514
- "indexMax" : {"$numberDouble" : "1000"}
711
+ "indexMax" : {"$numberDouble" : "1000"},
712
+ "trimFactor" : 0
515
713
  }),
516
714
  .expectedMinCover = "1100000000110111100000000000000000000000000000000000000000000001\n"
517
715
  "110000000011011110000000000000000000000000000000000000000000001\n"
@@ -571,7 +769,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
571
769
  "upperBound" : {"$numberDouble" : "35.25"},
572
770
  "ubIncluded" : false,
573
771
  "indexMin" : {"$numberDouble" : "0"},
574
- "indexMax" : {"$numberDouble" : "1000"}
772
+ "indexMax" : {"$numberDouble" : "1000"},
773
+ "trimFactor" : 0
575
774
  }),
576
775
  .expectedMinCover = "11000000001101111\n"
577
776
  "1100000000111\n"
@@ -585,7 +784,8 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
585
784
  "upperBound" : {"$numberDouble" : "35.25"},
586
785
  "ubIncluded" : true,
587
786
  "indexMin" : {"$numberDouble" : "0"},
588
- "indexMax" : {"$numberDouble" : "1000"}
787
+ "indexMax" : {"$numberDouble" : "1000"},
788
+ "trimFactor" : 0
589
789
  }),
590
790
  .expectedMinCover = "1100000000110111100000000000000000000000000000000000000000000001\n"
591
791
  "110000000011011110000000000000000000000000000000000000000000001\n"
@@ -672,14 +872,22 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
672
872
  ASSERT(bson_iter_init_find(&findSpecIter, findSpecDoc, "findSpec"));
673
873
 
674
874
  mc_FLE2RangeFindSpec_t findSpec;
675
- ASSERT_OK_STATUS(mc_FLE2RangeFindSpec_parse(&findSpec, &findSpecIter, status), status);
875
+ bool res = mc_FLE2RangeFindSpec_parse(&findSpec, &findSpecIter, !test->disableRangeV2, status);
876
+ if (test->expectedErrorAtParseTime) {
877
+ ASSERT(!res);
878
+ ASSERT_STATUS_CONTAINS(status, test->expectedErrorAtParseTime);
879
+ goto cleanup;
880
+ } else {
881
+ ASSERT_OK_STATUS(res, status);
882
+ }
676
883
 
677
884
  size_t sparsity = 1;
678
885
  if (test->sparsity.set) {
679
886
  sparsity = (size_t)test->sparsity.value;
680
887
  }
681
888
 
682
- mc_mincover_t *mc = mc_get_mincover_from_FLE2RangeFindSpec(&findSpec, sparsity, status);
889
+ const bool use_range_v2 = !test->disableRangeV2;
890
+ mc_mincover_t *mc = mc_get_mincover_from_FLE2RangeFindSpec(&findSpec, sparsity, status, use_range_v2);
683
891
 
684
892
  if (test->expectedError) {
685
893
  ASSERT(NULL == mc);
@@ -690,13 +898,224 @@ static void test_mc_get_mincover_from_FLE2RangeFindSpec(_mongocrypt_tester_t *te
690
898
  }
691
899
  mc_mincover_destroy(mc);
692
900
 
901
+ cleanup:
693
902
  bson_destroy(findSpecDoc);
694
903
  bson_destroy(findSpecVal);
695
904
  mongocrypt_status_destroy(status);
696
905
  }
697
906
  }
698
907
 
908
+ // Runs _mongocrypt_marking_to_ciphertext to compute the ciphertext for the given marking.
909
+ static void get_ciphertext_from_marking_json(_mongocrypt_tester_t *tester,
910
+ mongocrypt_t *crypt,
911
+ const char *markingJSON,
912
+ _mongocrypt_ciphertext_t *out) {
913
+ mongocrypt_status_t *status = mongocrypt_status_new();
914
+ mongocrypt_ctx_t *ctx = mongocrypt_ctx_new(crypt);
915
+ // Set up encryption environment
916
+ ASSERT_OK(mongocrypt_ctx_encrypt_init(ctx, "test", -1, TEST_FILE("./test/example/cmd.json")), ctx);
917
+ // Add a test key
918
+ _mongocrypt_buffer_t keyId;
919
+ _mongocrypt_buffer_from_binary(&keyId, TEST_BIN(16));
920
+ keyId.subtype = BSON_SUBTYPE_UUID;
921
+ _mongocrypt_key_broker_add_test_key(&ctx->kb, &keyId);
922
+
923
+ _mongocrypt_buffer_t marking_buf;
924
+ _mongocrypt_marking_t marking;
925
+ bson_t *marking_bson = TMP_BSON(markingJSON);
926
+ // Add key identifier info to the marking
927
+ BSON_APPEND_BINARY(marking_bson, "ki", BSON_SUBTYPE_UUID, (TEST_BIN(16))->data, 16);
928
+ BSON_APPEND_BINARY(marking_bson, "ku", BSON_SUBTYPE_UUID, (TEST_BIN(16))->data, 16);
929
+ _make_marking(marking_bson, &marking_buf);
930
+ // Use FLE2 as the subtype (default is FLE1)
931
+ marking_buf.data[0] = MC_SUBTYPE_FLE2EncryptionPlaceholder;
932
+ _parse_ok(&marking_buf, &marking);
933
+
934
+ ASSERT_OK_STATUS(_mongocrypt_marking_to_ciphertext((void *)&ctx->kb, &marking, out, status), status);
935
+
936
+ mongocrypt_status_destroy(status);
937
+ _mongocrypt_buffer_cleanup(&marking_buf);
938
+ _mongocrypt_marking_cleanup(&marking);
939
+ mongocrypt_ctx_destroy(ctx);
940
+ }
941
+
942
+ // Assert that the encryptedTokens fields in V2 insert/update ciphertext matches our expectations. Specifically, checks
943
+ // that the length of these fields are what we expect, and that the "isLeaf" token is appended when using range V2.
944
+ static void assert_correctness_of_ciphertext(_mongocrypt_ciphertext_t *ciphertext,
945
+ mongocrypt_t *crypt,
946
+ mc_ECOCToken_t *ecocToken,
947
+ bool useRangeV2,
948
+ uint32_t expectedEdges) {
949
+ uint32_t expectedPLength = useRangeV2 ? 33 : 32;
950
+ const _mongocrypt_value_encryption_algorithm_t *fle2alg = _mcFLE2Algorithm();
951
+ mongocrypt_status_t *status = mongocrypt_status_new();
952
+
953
+ bson_t ciphertextBSON;
954
+ bson_iter_t iter;
955
+ ASSERT(_mongocrypt_buffer_to_bson(&ciphertext->data, &ciphertextBSON));
956
+
957
+ // 'p' field should be available, length should be 16 bytes of IV + expected bytes
958
+ bson_iter_init_find(&iter, &ciphertextBSON, "p");
959
+ ASSERT(BSON_ITER_HOLDS_BINARY(&iter));
960
+ uint32_t p_len;
961
+ const uint8_t *p_data;
962
+ bson_iter_binary(&iter, NULL, &p_len, &p_data);
963
+ ASSERT_CMPUINT32(p_len, ==, 16 + expectedPLength);
964
+
965
+ if (useRangeV2) {
966
+ _mongocrypt_buffer_t p_buf, decrypted_buf;
967
+ ASSERT(_mongocrypt_buffer_copy_from_data_and_size(&p_buf, p_data, p_len));
968
+ _mongocrypt_buffer_init_size(&decrypted_buf, expectedPLength);
969
+ uint32_t decryptedBytes;
970
+ // Decrypt p. When using range V2, last byte should be 0.
971
+ ASSERT_OK_STATUS(fle2alg->do_decrypt(crypt->crypto,
972
+ NULL,
973
+ mc_ECOCToken_get(ecocToken),
974
+ &p_buf,
975
+ &decrypted_buf,
976
+ &decryptedBytes,
977
+ status),
978
+ status);
979
+ ASSERT_CMPUINT32(decryptedBytes, ==, expectedPLength);
980
+ ASSERT_CMPUINT8(decrypted_buf.data[decrypted_buf.len - 1], ==, 0);
981
+ _mongocrypt_buffer_cleanup(&decrypted_buf);
982
+ _mongocrypt_buffer_cleanup(&p_buf);
983
+ }
984
+
985
+ // 'g' field should be available
986
+ bson_iter_init_find(&iter, &ciphertextBSON, "g");
987
+ ASSERT(BSON_ITER_HOLDS_ARRAY(&iter));
988
+ uint32_t g_buf_len;
989
+ const uint8_t *g_buf;
990
+ bson_t g_arr;
991
+ bson_iter_array(&iter, &g_buf_len, &g_buf);
992
+ ASSERT(bson_init_static(&g_arr, g_buf, g_buf_len));
993
+
994
+ bson_iter_t g_iter;
995
+ bson_iter_init(&g_iter, &g_arr);
996
+ size_t g_count = 0, leaf_count = 0;
997
+ // Iterate through each edge token set and check p for each
998
+ while (bson_iter_next(&g_iter)) {
999
+ g_count++;
1000
+ ASSERT(BSON_ITER_HOLDS_DOCUMENT(&g_iter));
1001
+ uint32_t subdoc_len;
1002
+ const uint8_t *subdoc_buf;
1003
+ bson_t subdoc;
1004
+ bson_iter_document(&g_iter, &subdoc_len, &subdoc_buf);
1005
+ ASSERT(bson_init_static(&subdoc, subdoc_buf, subdoc_len));
1006
+
1007
+ bson_iter_t sub_iter;
1008
+ bson_iter_init_find(&sub_iter, &subdoc, "p");
1009
+ ASSERT(BSON_ITER_HOLDS_BINARY(&sub_iter));
1010
+ bson_iter_binary(&sub_iter, NULL, &p_len, &p_data);
1011
+ ASSERT_CMPUINT32(p_len, ==, 16 + expectedPLength);
1012
+
1013
+ if (useRangeV2) {
1014
+ _mongocrypt_buffer_t p_buf, decrypted_buf;
1015
+ ASSERT(_mongocrypt_buffer_copy_from_data_and_size(&p_buf, p_data, p_len));
1016
+ _mongocrypt_buffer_init_size(&decrypted_buf, expectedPLength);
1017
+
1018
+ // Decrypt p. If useRangeV2, the last byte should be 0 or 1, depending on whether isLeaf.
1019
+ uint32_t decrypted_bytes;
1020
+ ASSERT_OK_STATUS(fle2alg->do_decrypt(crypt->crypto,
1021
+ NULL,
1022
+ mc_ECOCToken_get(ecocToken),
1023
+ &p_buf,
1024
+ &decrypted_buf,
1025
+ &decrypted_bytes,
1026
+ status),
1027
+ status);
1028
+ ASSERT_CMPUINT32(decrypted_bytes, ==, expectedPLength);
1029
+ if (decrypted_buf.data[decrypted_buf.len - 1] == 1) {
1030
+ leaf_count++;
1031
+ } else {
1032
+ ASSERT_CMPUINT8(decrypted_buf.data[decrypted_buf.len - 1], ==, 0)
1033
+ }
1034
+
1035
+ _mongocrypt_buffer_cleanup(&decrypted_buf);
1036
+ _mongocrypt_buffer_cleanup(&p_buf);
1037
+ }
1038
+ }
1039
+ ASSERT_CMPSIZE_T(g_count, ==, expectedEdges);
1040
+ if (useRangeV2) {
1041
+ // There should be exactly one leaf in any insert call.
1042
+ ASSERT_CMPSIZE_T(leaf_count, ==, 1);
1043
+ }
1044
+ bson_destroy(&ciphertextBSON);
1045
+ mongocrypt_status_destroy(status);
1046
+ }
1047
+
1048
+ // Get the ECOC token to use in decryption.
1049
+ static mc_ECOCToken_t *getECOCToken(mongocrypt_t *crypt) {
1050
+ mongocrypt_status_t *status = mongocrypt_status_new();
1051
+ // Test token key that we added earlier is all zeros.
1052
+ _mongocrypt_buffer_t tokenKey;
1053
+ _mongocrypt_buffer_init_size(&tokenKey, MONGOCRYPT_TOKEN_KEY_LEN);
1054
+ memset(tokenKey.data, 0, MONGOCRYPT_TOKEN_KEY_LEN);
1055
+
1056
+ mc_CollectionsLevel1Token_t *collectionsLevel1Token =
1057
+ mc_CollectionsLevel1Token_new(crypt->crypto, &tokenKey, status);
1058
+ mc_ECOCToken_t *ecocToken = mc_ECOCToken_new(crypt->crypto, collectionsLevel1Token, status);
1059
+ ASSERT(mongocrypt_status_ok(status));
1060
+
1061
+ mc_CollectionsLevel1Token_destroy(collectionsLevel1Token);
1062
+ _mongocrypt_buffer_cleanup(&tokenKey);
1063
+ mongocrypt_status_destroy(status);
1064
+ return ecocToken;
1065
+ }
1066
+
1067
+ static void test_mc_marking_to_ciphertext(_mongocrypt_tester_t *tester) {
1068
+ if (!_aes_ctr_is_supported_by_os) {
1069
+ printf("Common Crypto with no CTR support detected. Skipping.");
1070
+ return;
1071
+ }
1072
+
1073
+ // Test that whether range V2 is enabled or disabled, the ciphertext matches our expectations.
1074
+ {
1075
+ const char markingJSON[] = RAW_STRING({
1076
+ 't' : 1,
1077
+ 'a' : 3,
1078
+ 'v' : {'min' : 0, 'max' : 7, 'v' : 5},
1079
+ 's' : {'$numberLong' : '1'},
1080
+ 'cm' : {'$numberLong' : '1'}
1081
+ });
1082
+ _mongocrypt_ciphertext_t ciphertext;
1083
+ _mongocrypt_ciphertext_init(&ciphertext);
1084
+ mongocrypt_t *crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT);
1085
+
1086
+ get_ciphertext_from_marking_json(tester, crypt, markingJSON, &ciphertext);
1087
+
1088
+ mc_ECOCToken_t *ecocToken = getECOCToken(crypt);
1089
+ assert_correctness_of_ciphertext(&ciphertext, crypt, ecocToken, false, 4);
1090
+ _mongocrypt_ciphertext_cleanup(&ciphertext);
1091
+ mc_ECOCToken_destroy(ecocToken);
1092
+ mongocrypt_destroy(crypt);
1093
+ }
1094
+ {
1095
+ const char markingJSON[] = RAW_STRING({
1096
+ 't' : 1,
1097
+ 'a' : 3,
1098
+ 'v' : {'min' : 0, 'max' : 7, 'v' : 5, 'trimFactor' : 0},
1099
+ 's' : {'$numberLong' : '1'},
1100
+ 'cm' : {'$numberLong' : '1'}
1101
+ });
1102
+ _mongocrypt_ciphertext_t ciphertext;
1103
+ _mongocrypt_ciphertext_init(&ciphertext);
1104
+ mongocrypt_t *crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_WITH_RANGE_V2);
1105
+
1106
+ get_ciphertext_from_marking_json(tester, crypt, markingJSON, &ciphertext);
1107
+
1108
+ mc_ECOCToken_t *ecocToken = getECOCToken(crypt);
1109
+ assert_correctness_of_ciphertext(&ciphertext, crypt, ecocToken, true, 4);
1110
+ _mongocrypt_ciphertext_cleanup(&ciphertext);
1111
+ mc_ECOCToken_destroy(ecocToken);
1112
+
1113
+ mongocrypt_destroy(crypt);
1114
+ }
1115
+ }
1116
+
699
1117
  void _mongocrypt_tester_install_marking(_mongocrypt_tester_t *tester) {
700
1118
  INSTALL_TEST(test_mongocrypt_marking_parse);
701
1119
  INSTALL_TEST(test_mc_get_mincover_from_FLE2RangeFindSpec);
1120
+ INSTALL_TEST(test_mc_marking_to_ciphertext);
702
1121
  }