libmongocrypt-helper 1.13.2.0.1001 → 1.14.0.0.1001

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +8 -0
  3. data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +5 -1
  4. data/ext/libmongocrypt/libmongocrypt/CODEOWNERS +4 -1
  5. data/ext/libmongocrypt/libmongocrypt/Earthfile +18 -17
  6. data/ext/libmongocrypt/libmongocrypt/README.md +8 -8
  7. data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +7 -0
  8. data/ext/libmongocrypt/libmongocrypt/bindings/python/CONTRIBUTING.md +34 -0
  9. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/state_machine.py +6 -2
  10. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +18 -2
  11. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +9 -1
  12. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/options.py +14 -0
  13. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/state_machine.py +6 -2
  14. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +1 -1
  15. data/ext/libmongocrypt/libmongocrypt/bindings/python/sbom.json +8 -8
  16. data/ext/libmongocrypt/libmongocrypt/bindings/python/scripts/libmongocrypt-version.txt +1 -0
  17. data/ext/libmongocrypt/libmongocrypt/bindings/python/{release.sh → scripts/release.sh} +9 -3
  18. data/ext/libmongocrypt/libmongocrypt/bindings/python/{synchro.py → scripts/synchro.py} +16 -9
  19. data/ext/libmongocrypt/libmongocrypt/bindings/python/scripts/synchro.sh +8 -0
  20. data/ext/libmongocrypt/libmongocrypt/bindings/python/scripts/update-version.sh +27 -0
  21. data/ext/libmongocrypt/libmongocrypt/bindings/python/scripts/update_binding.py +78 -0
  22. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_mongocrypt.py +15 -0
  23. data/ext/libmongocrypt/libmongocrypt/doc/releasing.md +25 -18
  24. data/ext/libmongocrypt/libmongocrypt/etc/calc_release_version.py +39 -13
  25. data/ext/libmongocrypt/libmongocrypt/etc/calc_release_version_selftest.sh +1 -1
  26. data/ext/libmongocrypt/libmongocrypt/etc/cyclonedx.sbom.json +2 -2
  27. data/ext/libmongocrypt/libmongocrypt/kms-message/CMakeLists.txt +1 -1
  28. data/ext/libmongocrypt/libmongocrypt/kms-message/src/hexlify.c +5 -0
  29. data/ext/libmongocrypt/libmongocrypt/kms-message/src/hexlify.h +1 -1
  30. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_azure_request.c +1 -1
  31. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_gcp_request.c +1 -1
  32. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_reader_writer.c +4 -2
  33. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_request.c +1 -2
  34. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message_private.h +5 -1
  35. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request.c +1 -1
  36. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_opt.c +1 -1
  37. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_str.c +2 -8
  38. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_str.h +9 -0
  39. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_response_parser.c +0 -1
  40. data/ext/libmongocrypt/libmongocrypt/kms-message/src/sort.c +7 -3
  41. data/ext/libmongocrypt/libmongocrypt/kms-message/src/sort.h +2 -0
  42. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kmip_reader_writer.c +8 -1
  43. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_assert.h +5 -4
  44. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_azure_online.c +1 -1
  45. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_gcp_online.c +1 -1
  46. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_kmip_request.c +4 -0
  47. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_kmip_response.c +3 -0
  48. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_kmip_response_parser.c +4 -0
  49. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_online_util.c +1 -1
  50. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_online_util.h +1 -1
  51. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_request.c +39 -39
  52. data/ext/libmongocrypt/libmongocrypt/src/crypto/libcrypto.c +235 -65
  53. data/ext/libmongocrypt/libmongocrypt/src/crypto/none.c +1 -1
  54. data/ext/libmongocrypt/libmongocrypt/src/csfle-markup.cpp +4 -2
  55. data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.h +2 -2
  56. data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.test.cpp +2 -2
  57. data/ext/libmongocrypt/libmongocrypt/src/mc-efc-private.h +1 -4
  58. data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +9 -11
  59. data/ext/libmongocrypt/libmongocrypt/src/mc-fle-blob-subtype-private.h +1 -0
  60. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +10 -8
  61. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +167 -176
  62. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-v2.c +6 -17
  63. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload.c +6 -17
  64. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private-v2.h +1 -1
  65. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-v2.c +25 -26
  66. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload.c +2 -1
  67. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-text-payload-private.h +122 -0
  68. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-text-payload.c +477 -0
  69. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private-v2.h +1 -3
  70. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-v2.c +28 -43
  71. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload.c +6 -17
  72. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-v2.c +6 -5
  73. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev.c +13 -10
  74. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common.c +3 -2
  75. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +7 -6
  76. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-tag-and-encrypted-metadata-block.c +4 -3
  77. data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +1 -1
  78. data/ext/libmongocrypt/libmongocrypt/src/mc-parse-utils-private.h +27 -0
  79. data/ext/libmongocrypt/libmongocrypt/src/mc-parse-utils.c +48 -0
  80. data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +5 -5
  81. data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +15 -20
  82. data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +4 -6
  83. data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +9 -18
  84. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +4 -5
  85. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +5 -9
  86. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +14 -19
  87. data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +2 -4
  88. data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +109 -119
  89. data/ext/libmongocrypt/libmongocrypt/src/mc-reader-private.h +2 -2
  90. data/ext/libmongocrypt/libmongocrypt/src/mc-reader.c +4 -2
  91. data/ext/libmongocrypt/libmongocrypt/src/mc-schema-broker-private.h +0 -3
  92. data/ext/libmongocrypt/libmongocrypt/src/mc-schema-broker.c +4 -14
  93. data/ext/libmongocrypt/libmongocrypt/src/mc-str-encode-string-sets-private.h +1 -1
  94. data/ext/libmongocrypt/libmongocrypt/src/mc-str-encode-string-sets.c +3 -3
  95. data/ext/libmongocrypt/libmongocrypt/src/mc-text-search-str-encode-private.h +8 -1
  96. data/ext/libmongocrypt/libmongocrypt/src/mc-text-search-str-encode.c +78 -2
  97. data/ext/libmongocrypt/libmongocrypt/src/mc-tokens-private.h +34 -16
  98. data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +66 -74
  99. data/ext/libmongocrypt/libmongocrypt/src/mc-writer-private.h +1 -1
  100. data/ext/libmongocrypt/libmongocrypt/src/mc-writer.c +4 -2
  101. data/ext/libmongocrypt/libmongocrypt/src/mlib/error.h +1 -1
  102. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.h +12 -1
  103. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +5 -0
  104. data/ext/libmongocrypt/libmongocrypt/src/mlib/path.h +5 -5
  105. data/ext/libmongocrypt/libmongocrypt/src/mlib/path.test.c +2 -5
  106. data/ext/libmongocrypt/libmongocrypt/src/mlib/str.h +65 -58
  107. data/ext/libmongocrypt/libmongocrypt/src/mlib/str.test.c +3 -3
  108. data/ext/libmongocrypt/libmongocrypt/src/mlib/thread.h +1 -1
  109. data/ext/libmongocrypt/libmongocrypt/src/mlib/user-check.h +1 -1
  110. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo-private.h +1 -1
  111. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo.c +4 -0
  112. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext-private.h +1 -1
  113. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto-private.h +4 -4
  114. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto.c +29 -25
  115. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +3 -2
  116. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +6 -3
  117. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +48 -58
  118. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-rewrap-many-datakey.c +12 -0
  119. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +5 -13
  120. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +19 -2
  121. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +9 -9
  122. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking-private.h +3 -4
  123. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +285 -89
  124. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +0 -2
  125. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +0 -1
  126. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +1 -1
  127. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util.c +4 -1
  128. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +47 -31
  129. data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +2 -0
  130. data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_mutex.c +1 -1
  131. data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +3 -1
  132. data/ext/libmongocrypt/libmongocrypt/src/os_win/os_mutex.c +1 -1
  133. data/ext/libmongocrypt/libmongocrypt/src/unicode/case-fold-map.c +1 -1
  134. data/ext/libmongocrypt/libmongocrypt/src/unicode/diacritic-fold-map.c +1 -1
  135. data/ext/libmongocrypt/libmongocrypt/src/unicode/fold.c +1 -1
  136. data/ext/libmongocrypt/libmongocrypt/test/crypt_shared-stub.cpp +0 -14
  137. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-field-config-map.json +6 -1
  138. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/FLE2InsertUpdatePayloadV2-RangeV2.json +8 -0
  139. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-field-map.json +1 -1
  140. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-payload.json +6 -4
  141. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/mongocryptd-reply.json +1 -1
  142. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-field-map.json +1 -1
  143. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-payload.json +6 -4
  144. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/mongocryptd-reply.json +2 -2
  145. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-field-map.json +1 -1
  146. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-payload.json +6 -4
  147. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/mongocryptd-reply.json +1 -1
  148. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-payload.json +14 -6
  149. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-field-map.json +1 -1
  150. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-payload.json +6 -4
  151. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/mongocryptd-reply.json +1 -1
  152. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-field-map.json +1 -1
  153. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-payload.json +6 -4
  154. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/mongocryptd-reply.json +1 -1
  155. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-field-map.json +1 -1
  156. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-payload.json +6 -4
  157. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/mongocryptd-reply.json +1 -1
  158. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/encrypted-payload-v2.json +1 -1
  159. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/encrypted-payload-v2.json +1 -1
  160. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/encrypted-payload-v2.json +1 -1
  161. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/encrypted-payload-v2.json +1 -1
  162. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-field-map.json +1 -1
  163. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-payload.json +6 -4
  164. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/mongocryptd-reply.json +1 -1
  165. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-field-map.json +1 -1
  166. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-payload.json +6 -4
  167. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/mongocryptd-reply.json +1 -1
  168. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-field-map.json +1 -1
  169. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-payload.json +6 -4
  170. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/mongocryptd-reply.json +1 -1
  171. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-payload.json +14 -6
  172. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-field-map.json +1 -1
  173. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-payload.json +6 -4
  174. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/mongocryptd-reply.json +1 -1
  175. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-field-map.json +1 -1
  176. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-payload.json +3 -3
  177. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/mongocryptd-reply.json +1 -1
  178. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-field-map.json +1 -1
  179. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-payload.json +6 -4
  180. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/mongocryptd-reply.json +1 -1
  181. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/encrypted-payload-v2.json +1 -1
  182. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/encrypted-payload-v2.json +1 -1
  183. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/encrypted-payload-v2.json +1 -1
  184. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/encrypted-payload-v2.json +1 -1
  185. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/mc.json +8 -0
  186. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/server.json +8 -0
  187. data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +5 -5
  188. data/ext/libmongocrypt/libmongocrypt/test/test-dll.cpp +11 -5
  189. data/ext/libmongocrypt/libmongocrypt/test/test-gcp-auth.c +2 -2
  190. data/ext/libmongocrypt/libmongocrypt/test/test-mc-efc.c +9 -11
  191. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-encryption-placeholder.c +18 -29
  192. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-equality-payload-v2.c +1 -1
  193. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-range-payload-v2.c +2 -18
  194. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-text-payload.c +320 -0
  195. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup-v2.c +2 -17
  196. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup.c +1 -1
  197. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-rfds.c +8 -5
  198. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-edge-generation.c +6 -10
  199. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +29 -33
  200. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +12 -20
  201. data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +5 -20
  202. data/ext/libmongocrypt/libmongocrypt/test/test-mc-reader.c +5 -5
  203. data/ext/libmongocrypt/libmongocrypt/test/test-mc-text-search-str-encode.c +147 -18
  204. data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +35 -14
  205. data/ext/libmongocrypt/libmongocrypt/test/test-mc-writer.c +10 -10
  206. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +3 -7
  207. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert.h +36 -24
  208. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-buffer.c +4 -4
  209. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache.c +2 -2
  210. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ciphertext.c +13 -13
  211. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cleanup.c +49 -55
  212. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-compact.c +64 -67
  213. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +18 -18
  214. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +4 -0
  215. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto.c +4 -3
  216. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-csfle-lib.c +13 -3
  217. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-decrypt.c +31 -13
  218. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +35 -52
  219. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +28 -1
  220. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +50 -91
  221. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +1 -1
  222. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-dll.c +7 -4
  223. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-endpoint.c +1 -1
  224. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kek.c +1 -1
  225. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-cache.c +3 -5
  226. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-ctx.c +2 -2
  227. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-local-kms.c +1 -1
  228. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-log.c +2 -2
  229. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-marking.c +527 -225
  230. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-status.c +1 -1
  231. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +45 -56
  232. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +12 -3
  233. data/ext/libmongocrypt/libmongocrypt/test/test-named-kms-providers.c +11 -11
  234. data/ext/libmongocrypt/libmongocrypt/test/test-unicode-fold.c +6 -2
  235. data/ext/libmongocrypt/libmongocrypt/test/util/HELP.autogen +1 -1
  236. data/ext/libmongocrypt/libmongocrypt/test/util/csfle.c +1 -1
  237. data/ext/libmongocrypt/libmongocrypt/test/util/util.c +5 -5
  238. data/ext/libmongocrypt/libmongocrypt/test/util/util.h +7 -6
  239. data/lib/libmongocrypt_helper/version.rb +2 -2
  240. metadata +17 -13
  241. data/ext/libmongocrypt/libmongocrypt/bindings/python/libmongocrypt-version.txt +0 -1
  242. data/ext/libmongocrypt/libmongocrypt/bindings/python/strip_header.py +0 -50
  243. data/ext/libmongocrypt/libmongocrypt/bindings/python/update-sbom.sh +0 -14
  244. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/encrypted-payload.json +0 -29
  245. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-payload.json +0 -29
  246. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/FLE2EqualityIndexedValueV2.json +0 -8
  247. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/FLE2RangeIndexedValueV2.json +0 -8
  248. /data/ext/libmongocrypt/libmongocrypt/bindings/python/{build-manylinux-wheel.sh → scripts/build-manylinux-wheel.sh} +0 -0
  249. /data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/{FLE2InsertUpdatePayload-with-edges.json → FLE2InsertUpdatePayload-RangeV1.json} +0 -0
  250. /data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/{FLE2InsertUpdatePayload-with-edges-V2.json → FLE2InsertUpdatePayloadV2-RangeV1.json} +0 -0
@@ -198,59 +198,67 @@ static void _test_RangeTest_Encode_Int64(_mongocrypt_tester_t *tester) {
198
198
 
199
199
  static void _test_canUsePrecisionModeDouble(_mongocrypt_tester_t *tester) {
200
200
  #define CAN_USE_PRECISION_MODE(lb, ub, prc, expected, expected_bits_out) \
201
- { \
201
+ if (1) { \
202
202
  uint32_t bits_out = 0; \
203
203
  mongocrypt_status_t *const status = mongocrypt_status_new(); \
204
- TEST_PRINTF("_test_canUsePrecisionModeDecimal, min: %f, max: %f, prc: %" PRIu32, lb, ub, prc); \
204
+ TEST_PRINTF("_test_canUsePrecisionModeDecimal, min: %f, max: %f, prc: %" PRId32, lb, ub, prc); \
205
205
  bool result = mc_canUsePrecisionModeDouble(lb, ub, prc, &bits_out, status); \
206
206
  ASSERT_OK_STATUS(mongocrypt_status_ok(status), status); \
207
207
  ASSERT(result == expected); \
208
208
  ASSERT_CMPINT32(expected_bits_out, ==, bits_out); \
209
209
  mongocrypt_status_destroy(status); \
210
- }
210
+ } else \
211
+ ((void)0)
211
212
 
212
213
  #define CAN_USE_PRECISION_MODE_ERRORS(lb, ub, prc, error) \
213
- { \
214
+ if (1) { \
214
215
  mongocrypt_status_t *const status = mongocrypt_status_new(); \
215
- TEST_PRINTF("_test_canUsePrecisionModeDecimal errors, min: %f, max: %f, prc: %" PRIu32, lb, ub, prc); \
216
+ TEST_PRINTF("_test_canUsePrecisionModeDecimal errors, min: %f, max: %f, prc: %" PRId32, lb, ub, prc); \
216
217
  uint32_t bits_out = 0; \
217
218
  bool result = mc_canUsePrecisionModeDouble(lb, ub, prc, &bits_out, status); \
218
219
  ASSERT_OR_PRINT_MSG(!result, "expected error, but got none"); \
219
220
  ASSERT_STATUS_CONTAINS(status, error); \
220
221
  mongocrypt_status_destroy(status); \
221
- }
222
+ } else \
223
+ ((void)0)
222
224
 
223
- CAN_USE_PRECISION_MODE(1.0, 16.0, 0, true, 4);
224
- CAN_USE_PRECISION_MODE(0.0, 16.0, 0, true, 5);
225
+ CAN_USE_PRECISION_MODE(1.0, 16.0, INT32_C(0), true, 4);
226
+ CAN_USE_PRECISION_MODE(0.0, 16.0, INT32_C(0), true, 5);
225
227
  // 2^53 + 1 is where double starts to lose precision, so we need to ensure that we get the
226
228
  // correct value for max_bits out.
227
- CAN_USE_PRECISION_MODE_ERRORS(1.0, 9007199254740992.0, 0, "Invalid upper bound for double precision. Absolute");
228
- CAN_USE_PRECISION_MODE_ERRORS(0.0, 9007199254740992.0, 0, "Invalid upper bound for double precision. Absolute");
229
+ CAN_USE_PRECISION_MODE_ERRORS(1.0,
230
+ 9007199254740992.0,
231
+ INT32_C(0),
232
+ "Invalid upper bound for double precision. Absolute");
233
+ CAN_USE_PRECISION_MODE_ERRORS(0.0,
234
+ 9007199254740992.0,
235
+ INT32_C(0),
236
+ "Invalid upper bound for double precision. Absolute");
229
237
 
230
238
  CAN_USE_PRECISION_MODE(2.718281, 314.159265, 6, true, 29);
231
239
 
232
240
  CAN_USE_PRECISION_MODE_ERRORS(-1000000000.0,
233
241
  9223372036844775424.0,
234
- 0,
242
+ INT32_C(0),
235
243
  "Invalid upper bound for double precision. Absolute");
236
244
 
237
245
  CAN_USE_PRECISION_MODE_ERRORS(2.710000,
238
246
  314.150000,
239
- 2,
247
+ INT32_C(2),
240
248
  "Invalid upper bound for double precision. Fractional digits");
241
249
  CAN_USE_PRECISION_MODE_ERRORS(314.150000, 350.0, 2, "Invalid lower bound for double precision. Fractional digits");
242
250
 
243
251
  CAN_USE_PRECISION_MODE_ERRORS((double)9007199254740992,
244
252
  INT_64_MAX_DOUBLE,
245
- 0,
253
+ INT32_C(0),
246
254
  "Invalid upper bound for double precision. Absolute scaled value");
247
255
  CAN_USE_PRECISION_MODE_ERRORS(-1 * INT_64_MAX_DOUBLE,
248
256
  1.0,
249
- 0,
257
+ INT32_C(0),
250
258
  "Invalid lower bound for double precision. Absolute scaled value");
251
259
  CAN_USE_PRECISION_MODE_ERRORS(-92233720368547.0,
252
260
  92233720368547.0,
253
- 5,
261
+ INT32_C(5),
254
262
  "Invalid upper bound for double precision. Absolute");
255
263
 
256
264
  #undef CAN_USE_PRECISION_MODE
@@ -552,7 +560,7 @@ static void _test_RangeTest_Encode_Double(_mongocrypt_tester_t *tester) {
552
560
 
553
561
  if (test->min.set && test->max.set && test->precision.set) {
554
562
  TEST_PRINTF("_test_RangeTest_Encode_Double: value=%f, min=%f, max=%f, "
555
- "precision=%" PRIu32 "\n",
563
+ "precision=%" PRId32 "\n",
556
564
  test->value,
557
565
  test->min.value,
558
566
  test->max.value,
@@ -561,15 +569,13 @@ static void _test_RangeTest_Encode_Double(_mongocrypt_tester_t *tester) {
561
569
  TEST_PRINTF("_test_RangeTest_Encode_Double: value=%f\n", test->value);
562
570
  }
563
571
 
564
- const bool use_range_v2 = !test->use_range_v1;
565
572
  mc_OSTType_Double got;
566
573
  const bool ok = mc_getTypeInfoDouble((mc_getTypeInfoDouble_args_t){.value = test->value,
567
574
  .min = test->min,
568
575
  .max = test->max,
569
576
  .precision = test->precision},
570
577
  &got,
571
- status,
572
- use_range_v2);
578
+ status);
573
579
  if (test->expectError) {
574
580
  ASSERT_OR_PRINT_MSG(!ok, "expected error, but got none");
575
581
  ASSERT_STATUS_CONTAINS(status, test->expectError);
@@ -583,7 +589,7 @@ static void _test_RangeTest_Encode_Double(_mongocrypt_tester_t *tester) {
583
589
  }
584
590
  }
585
591
 
586
- #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
592
+ #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT()
587
593
  typedef struct {
588
594
  mc_dec128 value;
589
595
  mc_optional_dec128_t min;
@@ -903,15 +909,7 @@ static void _test_RangeTest_Encode_Decimal128(_mongocrypt_tester_t *tester) {
903
909
  }
904
910
 
905
911
  #define ASSERT_EIBB_ERROR(Val, Max, Min, Precision, Expect, Error) \
906
- (Decimal128Test){ \
907
- .value = mc_dec128_from_string(#Val), \
908
- .min = OPT_MC_DEC128(mc_dec128_from_string(#Min)), \
909
- .max = OPT_MC_DEC128(mc_dec128_from_string(#Max)), \
910
- .precision = OPT_I32(Precision), \
911
- .expect = Expect, \
912
- .use_range_v1 = true, \
913
- }, \
914
- (Decimal128Test) { \
912
+ (Decimal128Test) { \
915
913
  .value = mc_dec128_from_string(#Val), .min = OPT_MC_DEC128(mc_dec128_from_string(#Min)), \
916
914
  .max = OPT_MC_DEC128(mc_dec128_from_string(#Max)), .precision = OPT_I32(Precision), .expectError = Error \
917
915
  }
@@ -996,7 +994,6 @@ static void _test_RangeTest_Encode_Decimal128(_mongocrypt_tester_t *tester) {
996
994
  TEST_PRINTF("_test_RangeTest_Encode_Decimal128: value=%s\n", mc_dec128_to_string(test->value).str);
997
995
  }
998
996
  mc_OSTType_Decimal128 got;
999
- const bool use_range_v2 = !test->use_range_v1;
1000
997
  const bool ok = mc_getTypeInfoDecimal128(
1001
998
  (mc_getTypeInfoDecimal128_args_t){
1002
999
  .value = test->value,
@@ -1005,8 +1002,7 @@ static void _test_RangeTest_Encode_Decimal128(_mongocrypt_tester_t *tester) {
1005
1002
  .precision = test->precision,
1006
1003
  },
1007
1004
  &got,
1008
- status,
1009
- use_range_v2);
1005
+ status);
1010
1006
  if (test->expectError) {
1011
1007
  ASSERT_OR_PRINT_MSG(!ok, "expected error, but got none");
1012
1008
  ASSERT_STATUS_CONTAINS(status, test->expectError);
@@ -1027,7 +1023,7 @@ void _mongocrypt_tester_install_range_encoding(_mongocrypt_tester_t *tester) {
1027
1023
  INSTALL_TEST(_test_RangeTest_Encode_Int64);
1028
1024
  INSTALL_TEST(_test_canUsePrecisionModeDouble);
1029
1025
  INSTALL_TEST(_test_RangeTest_Encode_Double);
1030
- #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
1026
+ #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT()
1031
1027
  INSTALL_TEST(_test_canUsePrecisionModeDecimal);
1032
1028
  INSTALL_TEST(_test_RangeTest_Encode_Decimal128);
1033
1029
  #endif
@@ -68,7 +68,7 @@ typedef struct {
68
68
  const char *expectError;
69
69
  } DoubleTest;
70
70
 
71
- #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
71
+ #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT()
72
72
  typedef struct {
73
73
  mc_dec128 lowerBound;
74
74
  bool includeLowerBound;
@@ -95,7 +95,6 @@ static mc_mincover_t *_test_getMincover32(void *tests, size_t idx, mongocrypt_st
95
95
 
96
96
  Int32Test *test = (Int32Test *)tests + idx;
97
97
 
98
- const bool use_range_v2 = true;
99
98
  return mc_getMincoverInt32((mc_getMincoverInt32_args_t){.lowerBound = test->lowerBound,
100
99
  .includeLowerBound = test->includeLowerBound,
101
100
  .upperBound = test->upperBound,
@@ -104,14 +103,12 @@ static mc_mincover_t *_test_getMincover32(void *tests, size_t idx, mongocrypt_st
104
103
  .max = test->max,
105
104
  .sparsity = test->sparsity,
106
105
  .trimFactor = OPT_I32(test->trimFactor)},
107
- status,
108
- use_range_v2);
106
+ status);
109
107
  }
110
108
 
111
109
  static mc_mincover_t *_test_getMincover64(void *tests, size_t idx, mongocrypt_status_t *status) {
112
110
  BSON_ASSERT_PARAM(tests);
113
111
 
114
- const bool use_range_v2 = true;
115
112
  const uint32_t trimFactor = 0; // At present, all test cases expect trimFactor=0.
116
113
  Int64Test *const test = (Int64Test *)tests + idx;
117
114
 
@@ -123,14 +120,12 @@ static mc_mincover_t *_test_getMincover64(void *tests, size_t idx, mongocrypt_st
123
120
  .max = test->max,
124
121
  .sparsity = test->sparsity,
125
122
  .trimFactor = OPT_I32(trimFactor)},
126
- status,
127
- use_range_v2);
123
+ status);
128
124
  }
129
125
 
130
126
  static mc_mincover_t *_test_getMincoverDouble_helper(void *tests, size_t idx, mongocrypt_status_t *status) {
131
127
  BSON_ASSERT_PARAM(tests);
132
128
 
133
- const bool use_range_v2 = true;
134
129
  const uint32_t trimFactor = 0; // At present, all test cases expect trimFactor=0.
135
130
  DoubleTest *const test = (DoubleTest *)tests + idx;
136
131
 
@@ -144,17 +139,15 @@ static mc_mincover_t *_test_getMincoverDouble_helper(void *tests, size_t idx, mo
144
139
  .max = test->precision.set ? test->max : (mc_optional_double_t){0},
145
140
  .precision = test->precision,
146
141
  .trimFactor = OPT_I32(trimFactor)},
147
- status,
148
- use_range_v2);
142
+ status);
149
143
  }
150
144
 
151
- #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
145
+ #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT()
152
146
  static mc_mincover_t *_test_getMincoverDecimal128_helper(void *tests, size_t idx, mongocrypt_status_t *status) {
153
147
  BSON_ASSERT_PARAM(tests);
154
148
 
155
149
  Decimal128Test *const test = (Decimal128Test *)tests + idx;
156
150
 
157
- const bool use_range_v2 = true;
158
151
  const uint32_t trimFactor = 0; // At present, all test cases expect trimFactor=0.
159
152
  return mc_getMincoverDecimal128(
160
153
  (mc_getMincoverDecimal128_args_t){.lowerBound = test->lowerBound,
@@ -166,8 +159,7 @@ static mc_mincover_t *_test_getMincoverDecimal128_helper(void *tests, size_t idx
166
159
  .max = test->precision.set ? test->max : (mc_optional_dec128_t){0},
167
160
  .precision = test->precision,
168
161
  .trimFactor = OPT_I32(trimFactor)},
169
- status,
170
- use_range_v2);
162
+ status);
171
163
  }
172
164
  #endif // MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
173
165
 
@@ -202,7 +194,7 @@ static const char *_test_expectErrorDouble(void *tests, size_t idx, mongocrypt_s
202
194
  return test->expectError;
203
195
  }
204
196
 
205
- #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
197
+ #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT()
206
198
  static const char *_test_expectErrorDecimal128(void *tests, size_t idx, mongocrypt_status_t *status) {
207
199
  BSON_ASSERT_PARAM(tests);
208
200
  BSON_ASSERT_PARAM(status);
@@ -238,7 +230,7 @@ static const char *const *_test_expectMincoverDouble(void *tests, size_t idx) {
238
230
  return ((DoubleTest *)tests + idx)->expectMincoverStrings;
239
231
  }
240
232
 
241
- #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
233
+ #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT()
242
234
  static const char *const *_test_expectMincoverDecimal128(void *tests, size_t idx) {
243
235
  BSON_ASSERT_PARAM(tests);
244
236
  return ((Decimal128Test *)tests + idx)->expectMincoverStrings;
@@ -314,7 +306,7 @@ static void _test_dump_Double(void *tests, size_t idx, mc_mincover_t *got) {
314
306
  TEST_STDERR_PRINTF(" max=%f", test->max.value);
315
307
  }
316
308
  if (test->precision.set) {
317
- TEST_STDERR_PRINTF(" precision=%" PRIu32, test->precision.value);
309
+ TEST_STDERR_PRINTF(" precision=%" PRId32, test->precision.value);
318
310
  }
319
311
  TEST_STDERR_PRINTF(" sparsity=%zu\n", test->sparsity);
320
312
  TEST_STDERR_PRINTF("mincover expected ... begin\n");
@@ -329,7 +321,7 @@ static void _test_dump_Double(void *tests, size_t idx, mc_mincover_t *got) {
329
321
  TEST_STDERR_PRINTF("mincover got ... end\n");
330
322
  }
331
323
 
332
- #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
324
+ #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT()
333
325
  static void _test_dump_Decimal128(void *tests, size_t idx, mc_mincover_t *got) {
334
326
  BSON_ASSERT_PARAM(tests);
335
327
  Decimal128Test *const test = (Decimal128Test *)tests + idx;
@@ -594,7 +586,7 @@ static void _test_getMincoverDouble(_mongocrypt_tester_t *tester) {
594
586
  .dump = _test_dump_Double});
595
587
  }
596
588
 
597
- #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
589
+ #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT()
598
590
  static void _test_getMincoverDecimal128(_mongocrypt_tester_t *tester) {
599
591
  Decimal128Test tests[] = {
600
592
  #include "./data/range-min-cover/mincover_decimal128.cstruct"
@@ -614,7 +606,7 @@ void _mongocrypt_tester_install_range_mincover(_mongocrypt_tester_t *tester) {
614
606
  INSTALL_TEST(_test_getMincoverInt32);
615
607
  INSTALL_TEST(_test_getMincoverInt64);
616
608
  INSTALL_TEST(_test_getMincoverDouble);
617
- #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
609
+ #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT()
618
610
  INSTALL_TEST(_test_getMincoverDecimal128);
619
611
  #endif
620
612
  }
@@ -30,7 +30,6 @@ static void test_mc_RangeOpts_parse(_mongocrypt_tester_t *tester) {
30
30
  int64_t expectSparsity;
31
31
  mc_optional_uint32_t expectPrecision;
32
32
  mc_optional_int32_t expectTrimFactor;
33
- bool useRangeV2;
34
33
  } testcase;
35
34
 
36
35
  testcase tests[] = {
@@ -62,24 +61,17 @@ static void test_mc_RangeOpts_parse(_mongocrypt_tester_t *tester) {
62
61
  {.desc = "Requires precision for double when only min is set",
63
62
  .in = RAW_STRING({"min" : 0.0, "sparsity" : {"$numberLong" : "1"}}),
64
63
  .expectError = "expected 'precision'"},
65
- // Once `use_range_v2` is default true, this test may be removed.
66
- {.desc = "Fails when trim factor is set but Range V2 is disabled",
67
- .in = RAW_STRING({"trimFactor" : 1, "sparsity" : {"$numberLong" : "1"}}),
68
- .expectError = "'trimFactor' is not supported for QE range v1"},
69
64
  {.desc = "Works when trim factor is set and Range V2 is enabled",
70
65
  .in = RAW_STRING({"trimFactor" : 1, "sparsity" : {"$numberLong" : "1"}}),
71
- .useRangeV2 = true,
72
66
  .expectSparsity = 1,
73
67
  .expectTrimFactor = OPT_I32(1)},
74
68
  {.desc = "Does not require sparsity",
75
69
  .in = RAW_STRING({"min" : 123, "max" : 456}),
76
- .useRangeV2 = true,
77
70
  .expectSparsity = mc_FLERangeSparsityDefault,
78
71
  .expectMin = OPT_I32_C(123),
79
72
  .expectMax = OPT_I32_C(456)},
80
73
  {.desc = "Errors on negative trim factor",
81
74
  .in = RAW_STRING({"trimFactor" : -1, "sparsity" : {"$numberLong" : "1"}}),
82
- .useRangeV2 = true,
83
75
  .expectError = "'trimFactor' must be non-negative"},
84
76
  };
85
77
 
@@ -88,7 +80,7 @@ static void test_mc_RangeOpts_parse(_mongocrypt_tester_t *tester) {
88
80
  mongocrypt_status_t *status = mongocrypt_status_new();
89
81
  mc_RangeOpts_t ro;
90
82
  TEST_PRINTF("running test_mc_RangeOpts_parse subtest: %s\n", test->desc);
91
- bool ret = mc_RangeOpts_parse(&ro, TMP_BSON(test->in), test->useRangeV2, status);
83
+ bool ret = mc_RangeOpts_parse(&ro, TMP_BSON_STR(test->in), status);
92
84
  if (!test->expectError) {
93
85
  ASSERT_OK_STATUS(ret, status);
94
86
  ASSERT_CMPINT(test->expectMin.set, ==, ro.min.set);
@@ -119,8 +111,6 @@ static void test_mc_RangeOpts_to_FLE2RangeInsertSpec(_mongocrypt_tester_t *teste
119
111
  const char *v;
120
112
  const char *expectError;
121
113
  const char *expect;
122
- // Most of the tests are for trim factor, so range V2 is default enabled.
123
- bool disableRangeV2;
124
114
  } testcase;
125
115
 
126
116
  testcase tests[] = {
@@ -128,11 +118,6 @@ static void test_mc_RangeOpts_to_FLE2RangeInsertSpec(_mongocrypt_tester_t *teste
128
118
  .in = RAW_STRING({"min" : 123, "max" : 456, "sparsity" : {"$numberLong" : "1"}}),
129
119
  .v = RAW_STRING({"v" : 789}),
130
120
  .expect = RAW_STRING({"v" : {"v" : 789, "min" : 123, "max" : 456}})},
131
- {.desc = "Trim factor not appended if range V2 disabled",
132
- .in = RAW_STRING({"min" : 123, "max" : 456, "sparsity" : {"$numberLong" : "1"}}),
133
- .v = RAW_STRING({"v" : 789}),
134
- .disableRangeV2 = true,
135
- .expect = RAW_STRING({"v" : {"v" : 789, "min" : 123, "max" : 456}})},
136
121
  {.desc = "Works with precision",
137
122
  .in = RAW_STRING({"min" : 123.0, "max" : 456.0, "precision" : 2, "sparsity" : {"$numberLong" : "1"}}),
138
123
  .v = RAW_STRING({"v" : 789.0}),
@@ -260,7 +245,7 @@ static void test_mc_RangeOpts_to_FLE2RangeInsertSpec(_mongocrypt_tester_t *teste
260
245
  .expectError = "Trim factor (64) must be less than the total number of bits (64) used to represent any "
261
246
  "element in the domain."},
262
247
 
263
- #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
248
+ #if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT()
264
249
  {.desc = "tf bound check passes correctly for decimal with min, max, precision set (tf = 9, 2^9 < domain size "
265
250
  "< 2^10)",
266
251
  .in = RAW_STRING({
@@ -317,12 +302,12 @@ static void test_mc_RangeOpts_to_FLE2RangeInsertSpec(_mongocrypt_tester_t *teste
317
302
  mongocrypt_status_t *status = mongocrypt_status_new();
318
303
  mc_RangeOpts_t ro;
319
304
  TEST_PRINTF("running test_mc_RangeOpts_to_FLE2RangeInsertSpec subtest: %s\n", test->desc);
320
- ASSERT_OK_STATUS(mc_RangeOpts_parse(&ro, TMP_BSON(test->in), !test->disableRangeV2, status), status);
305
+ ASSERT_OK_STATUS(mc_RangeOpts_parse(&ro, TMP_BSON_STR(test->in), status), status);
321
306
  bson_t out = BSON_INITIALIZER;
322
- bool ret = mc_RangeOpts_to_FLE2RangeInsertSpec(&ro, TMP_BSON(test->v), &out, !test->disableRangeV2, status);
307
+ bool ret = mc_RangeOpts_to_FLE2RangeInsertSpec(&ro, TMP_BSON_STR(test->v), &out, status);
323
308
  if (!test->expectError) {
324
309
  ASSERT_OK_STATUS(ret, status);
325
- ASSERT_EQUAL_BSON(TMP_BSON(test->expect), &out);
310
+ ASSERT_EQUAL_BSON(TMP_BSON_STR(test->expect), &out);
326
311
  } else {
327
312
  ASSERT_FAILS_STATUS(ret, status, test->expectError);
328
313
  }
@@ -26,7 +26,7 @@ static void _test_mc_reader(_mongocrypt_tester_t *tester) {
26
26
  status = mongocrypt_status_new();
27
27
 
28
28
  mc_reader_t reader;
29
- mc_reader_init_from_buffer(&reader, &input_buf, __FUNCTION__);
29
+ mc_reader_init_from_buffer(&reader, &input_buf, __func__);
30
30
 
31
31
  uint8_t value;
32
32
  ASSERT_OK_STATUS(mc_reader_read_u8(&reader, &value, status), status);
@@ -57,7 +57,7 @@ static void _test_mc_reader_uuid(_mongocrypt_tester_t *tester) {
57
57
  status = mongocrypt_status_new();
58
58
 
59
59
  mc_reader_t reader;
60
- mc_reader_init_from_buffer(&reader, &input_buf, __FUNCTION__);
60
+ mc_reader_init_from_buffer(&reader, &input_buf, __func__);
61
61
 
62
62
  _mongocrypt_buffer_t value;
63
63
  ASSERT_OK_STATUS(mc_reader_read_uuid_buffer(&reader, &value, status), status);
@@ -93,7 +93,7 @@ static void _test_mc_reader_prfblock(_mongocrypt_tester_t *tester) {
93
93
  status = mongocrypt_status_new();
94
94
 
95
95
  mc_reader_t reader;
96
- mc_reader_init_from_buffer(&reader, &input_buf, __FUNCTION__);
96
+ mc_reader_init_from_buffer(&reader, &input_buf, __func__);
97
97
 
98
98
  _mongocrypt_buffer_t value;
99
99
  ASSERT_OK_STATUS(mc_reader_read_prfblock_buffer(&reader, &value, status), status);
@@ -117,7 +117,7 @@ static void _test_mc_reader_ints(_mongocrypt_tester_t *tester) {
117
117
  status = mongocrypt_status_new();
118
118
 
119
119
  mc_reader_t reader;
120
- mc_reader_init_from_buffer(&reader, &input_buf, __FUNCTION__);
120
+ mc_reader_init_from_buffer(&reader, &input_buf, __func__);
121
121
 
122
122
  uint32_t u32;
123
123
  ASSERT_OK_STATUS(mc_reader_read_u32(&reader, &u32, status), status);
@@ -143,7 +143,7 @@ static void _test_mc_reader_bytes(_mongocrypt_tester_t *tester) {
143
143
  status = mongocrypt_status_new();
144
144
 
145
145
  mc_reader_t reader;
146
- mc_reader_init_from_buffer(&reader, &input_buf, __FUNCTION__);
146
+ mc_reader_init_from_buffer(&reader, &input_buf, __func__);
147
147
 
148
148
  const uint8_t *ptr;
149
149
  const uint64_t len = 4;
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
+ #include "mongocrypt.h"
17
18
  #include "test-mongocrypt-assert.h"
18
19
  #include "test-mongocrypt.h"
19
20
 
@@ -138,7 +139,7 @@ static void test_nofold_suffix_prefix_case(_mongocrypt_tester_t *tester,
138
139
  ASSERT_CMPPTR((uint8_t *)affix, ==, sets->base_string->buf.data + start_offset);
139
140
  ASSERT_CMPUINT32(affix_len,
140
141
  ==,
141
- sets->base_string->codepoint_offsets[folded_codepoint_len] - start_offset)
142
+ sets->base_string->codepoint_offsets[folded_codepoint_len] - start_offset);
142
143
  } else {
143
144
  uint32_t end_offset = sets->base_string->codepoint_offsets[lb + idx];
144
145
  ASSERT_CMPPTR((uint8_t *)affix, ==, sets->base_string->buf.data);
@@ -360,21 +361,21 @@ static void test_nofold_substring_case_multiple_mlen(_mongocrypt_tester_t *teste
360
361
  test_nofold_substring_case(tester, str, lb, ub, byte_len + 64, casef, diacf, foldable_codepoints);
361
362
  }
362
363
 
363
- const char *normal_ascii_strings[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f",
364
- "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
365
- "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L",
366
- "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
367
- const char *ascii_diacritics[] = {"^", "`"};
368
- const char *normal_unicode_strings[] = {"ぁ", "あ", "ぃ", "い", "ぅ", "う", "ぇ", "え", "ぉ", "お", "か", "が",
369
- "き", "ぎ", "く", "け", "Ѐ", "Ё", "Ђ", "Ѓ", "Є", "Ѕ", "І", "Ї",
370
- "Ј", "Љ", "Њ", "Ћ", "Ќ", "Ѝ", "Ў", "Џ", "𓀀", "𓀁", "𓀂", "𓀃",
371
- "𓀄", "𓀅", "𓀆", "𓀇", "𓀈", "𓀉", "𓀊", "𓀋", "𓀌", "𓀍", "𓀎", "𓀏"};
372
- const char *unicode_diacritics[] = {"̀", "́", "̂", "̃", "̄", "̅", "̆", "̇", "̈", "̉", "̊", "̋", "̌", "̍", "̎",
373
- "̏", "᷄", "᷅", "᷆", "᷇", "᷈", "᷉", "᷊", "᷋", "᷌", "᷍", "᷎", "᷏", "︠", "︡",
374
- "︢", "︣", "︤", "︥", "︦", "︧", "︨", "︩", "︪", "︫", "︬", "︭", "︮", "︯"};
364
+ static const char *normal_ascii_strings[] = {
365
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
366
+ "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F",
367
+ "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
368
+ static const char *ascii_diacritics[] = {"^", "`"};
369
+ static const char *normal_unicode_strings[] = {"ぁ", "あ", "ぃ", "い", "ぅ", "う", "ぇ", "え", "ぉ", "お", "か", "が",
370
+ "き", "ぎ", "く", "け", "Ѐ", "Ё", "Ђ", "Ѓ", "Є", "Ѕ", "І", "Ї",
371
+ "Ј", "Љ", "Њ", "Ћ", "Ќ", "Ѝ", "Ў", "Џ", "𓀀", "𓀁", "𓀂", "𓀃",
372
+ "𓀄", "𓀅", "𓀆", "𓀇", "𓀈", "𓀉", "𓀊", "𓀋", "𓀌", "𓀍", "𓀎", "𓀏"};
373
+ static const char *unicode_diacritics[] = {"̀", "́", "̂", "̃", "̄", "̅", "̆", "̇", "̈", "̉", "̊", "̋", "̌", "̍", "̎",
374
+ "̏", "᷄", "᷅", "᷆", "᷇", "᷈", "᷉", "᷊", "᷋", "᷌", "᷍", "᷎", "᷏", "︠", "︡",
375
+ "︢", "︣", "︤", "︥", "︦", "︧", "︨", "︩", "︪", "︫", "︬", "︭", "︮", "︯"};
375
376
 
376
377
  // Build a random string which has unfolded_len codepoints, but folds to folded_len codepoints after diacritic folding.
377
- char *build_random_string_to_fold(uint32_t folded_len, uint32_t unfolded_len) {
378
+ static char *build_random_string_to_fold(uint32_t folded_len, uint32_t unfolded_len) {
378
379
  // 1/3 to generate all unicode, 1/3 to be half and half, 1/3 to be all ascii.
379
380
  int ascii_ratio = rand() % 3;
380
381
  ASSERT_CMPUINT32(unfolded_len, >=, folded_len);
@@ -526,11 +527,11 @@ static void suffix_prefix_run_folding_case(_mongocrypt_tester_t *tester,
526
527
  test_nofold_suffix_prefix_case(tester, long_s, 32, 49, casef, diacf, foldable_codepoints);
527
528
  }
528
529
 
529
- const uint32_t UNFOLDED_CASES[] = {0, 1, 3, 16};
530
+ static const uint32_t UNFOLDED_CASES[] = {0, 1, 3, 16};
530
531
  // Predefined lengths to test a variety of cases
531
- const uint32_t SHORT_LEN = 9;
532
- const uint32_t MEDIUM_LEN = 16;
533
- const uint32_t LONG_LEN = 27;
532
+ static const uint32_t SHORT_LEN = 9;
533
+ static const uint32_t MEDIUM_LEN = 16;
534
+ static const uint32_t LONG_LEN = 27;
534
535
 
535
536
  static void _test_text_search_str_encode_suffix_prefix(_mongocrypt_tester_t *tester) {
536
537
  unsigned int seed = (unsigned int)time(0);
@@ -1198,10 +1199,138 @@ static void _test_text_search_str_encode_empty_string(_mongocrypt_tester_t *test
1198
1199
  }
1199
1200
  }
1200
1201
 
1202
+ // Tests mc_text_search_str_query() fails on invalid utf-8.
1203
+ static void _test_text_search_str_query_bad_string(_mongocrypt_tester_t *tester) {
1204
+ mongocrypt_status_t *status = mongocrypt_status_new();
1205
+ _mongocrypt_buffer_t out;
1206
+ mc_FLE2TextSearchInsertSpec_t spec = {.v = "\xff\xff\xff\xff\xff\xff\xff\xff\xff", .len = 9};
1207
+
1208
+ bool res = mc_text_search_str_query(&spec, &out, status);
1209
+ ASSERT_FAILS_STATUS(res, status, "not valid UTF-8");
1210
+ mongocrypt_status_destroy(status);
1211
+ }
1212
+
1213
+ // Tests mc_text_search_str_query() checks the input string codepoint length against lb and ub
1214
+ // for substring, suffix, and prefix queries, and not for exact queres.
1215
+ static void _test_text_search_str_query_bounds_checking(_mongocrypt_tester_t *tester) {
1216
+ mc_FLE2TextSearchInsertSpec_t substrSpec = {.substr = {{.mlen = 20, .lb = 4, .ub = 7}, .set = true}};
1217
+ mc_FLE2TextSearchInsertSpec_t suffixSpec = {.suffix = {{.lb = 4, .ub = 7}, .set = true}};
1218
+ mc_FLE2TextSearchInsertSpec_t prefixSpec = {.prefix = {{.lb = 4, .ub = 7}, .set = true}};
1219
+ mc_FLE2TextSearchInsertSpec_t *specs[3] = {&substrSpec, &suffixSpec, &prefixSpec};
1220
+
1221
+ char *short_str = build_random_string_to_fold(3, 5);
1222
+ char *long_str = build_random_string_to_fold(8, 10);
1223
+
1224
+ mongocrypt_status_t *status = mongocrypt_status_new();
1225
+ _mongocrypt_buffer_t out;
1226
+
1227
+ for (int i = 0; i < 3; i++) {
1228
+ // long_str always fails regardless of folding
1229
+ for (int d = 0; d < 2; d++) {
1230
+ specs[i]->v = long_str;
1231
+ specs[i]->len = (uint32_t)strlen(specs[i]->v);
1232
+ specs[i]->diacf = d;
1233
+ ASSERT_FAILS_STATUS(mc_text_search_str_query(specs[i], &out, status),
1234
+ status,
1235
+ "longer than the maximum query length");
1236
+ _mongocrypt_buffer_cleanup(&out);
1237
+ _mongocrypt_status_reset(status);
1238
+ }
1239
+ // short_str only fails if diacritic folding is on
1240
+ specs[i]->v = short_str;
1241
+ specs[i]->len = (uint32_t)strlen(specs[i]->v);
1242
+ specs[i]->diacf = true;
1243
+ ASSERT_FAILS_STATUS(mc_text_search_str_query(specs[i], &out, status),
1244
+ status,
1245
+ "shorter than the minimum query length");
1246
+ _mongocrypt_buffer_cleanup(&out);
1247
+ _mongocrypt_status_reset(status);
1248
+
1249
+ specs[i]->diacf = false;
1250
+ ASSERT_OK_STATUS(mc_text_search_str_query(specs[i], &out, status), status);
1251
+ _mongocrypt_buffer_cleanup(&out);
1252
+ _mongocrypt_status_reset(status);
1253
+ }
1254
+
1255
+ // test no bounds checking performed if no substr/suffix/prefix specs
1256
+ mc_FLE2TextSearchInsertSpec_t exactSpecShort = {.diacf = true, .v = short_str, .len = (uint32_t)strlen(short_str)};
1257
+ mc_FLE2TextSearchInsertSpec_t exactSpecLong = {.diacf = true, .v = long_str, .len = (uint32_t)strlen(long_str)};
1258
+ ASSERT_OK_STATUS(mc_text_search_str_query(&exactSpecShort, &out, status), status);
1259
+ _mongocrypt_buffer_cleanup(&out);
1260
+ _mongocrypt_status_reset(status);
1261
+ ASSERT_OK_STATUS(mc_text_search_str_query(&exactSpecLong, &out, status), status);
1262
+
1263
+ _mongocrypt_buffer_cleanup(&out);
1264
+ mongocrypt_status_destroy(status);
1265
+ bson_free(short_str);
1266
+ bson_free(long_str);
1267
+ }
1268
+
1269
+ // Tests mc_text_search_str_query() rejects empty string input for substr/suffix/prefix queries,
1270
+ // but not for exact match queries.
1271
+ static void _test_text_search_str_query_empty_string(_mongocrypt_tester_t *tester) {
1272
+ mc_FLE2TextSearchInsertSpec_t substrSpec = {.substr = {{20, 4, 7}, true}, .v = "", .len = 0};
1273
+ mc_FLE2TextSearchInsertSpec_t suffixSpec = {.suffix = {{4, 7}, true}, .v = "", .len = 0};
1274
+ mc_FLE2TextSearchInsertSpec_t prefixSpec = {.prefix = {{4, 7}, true}, .v = "", .len = 0};
1275
+ mc_FLE2TextSearchInsertSpec_t exactSpec = {.v = "", .len = 0};
1276
+ mc_FLE2TextSearchInsertSpec_t *specs[3] = {&substrSpec, &suffixSpec, &prefixSpec};
1277
+ mongocrypt_status_t *status = mongocrypt_status_new();
1278
+ _mongocrypt_buffer_t out;
1279
+ for (int i = 0; i < 3; i++) {
1280
+ ASSERT_FAILS_STATUS(mc_text_search_str_query(specs[i], &out, status), status, "string value cannot be empty");
1281
+ _mongocrypt_buffer_cleanup(&out);
1282
+ _mongocrypt_status_reset(status);
1283
+ }
1284
+
1285
+ ASSERT_OK_STATUS(mc_text_search_str_query(&exactSpec, &out, status), status);
1286
+ _mongocrypt_buffer_cleanup(&out);
1287
+ mongocrypt_status_destroy(status);
1288
+ }
1289
+
1290
+ // Tests mc_text_search_str_query() performs folding per the diacf and casef parameters.
1291
+ static void _test_text_search_str_query_folding(_mongocrypt_tester_t *tester) {
1292
+ const char *testStr = "Düsseldorf";
1293
+ const char *diacFoldStr = "Dusseldorf";
1294
+ const char *caseFoldStr = "düsseldorf";
1295
+ const char *bothFoldStr = "dusseldorf";
1296
+ mc_FLE2TextSearchInsertSpec_t spec = {.v = testStr, .len = (uint32_t)strlen(testStr)};
1297
+ mongocrypt_status_t *status = mongocrypt_status_new();
1298
+ _mongocrypt_buffer_t out;
1299
+
1300
+ spec.diacf = true;
1301
+ ASSERT_OK_STATUS(mc_text_search_str_query(&spec, &out, status), status);
1302
+ ASSERT_CMPUINT32((uint32_t)strlen(diacFoldStr) + 5, ==, out.len); // +5 for BSON overhead
1303
+ ASSERT_STREQUAL(diacFoldStr, (const char *)(out.data + 4)); // +4 skips past 32-bit size field
1304
+
1305
+ _mongocrypt_buffer_cleanup(&out);
1306
+ _mongocrypt_status_reset(status);
1307
+
1308
+ spec.casef = true;
1309
+ spec.diacf = false;
1310
+ ASSERT_OK_STATUS(mc_text_search_str_query(&spec, &out, status), status);
1311
+ ASSERT_CMPUINT32((uint32_t)strlen(caseFoldStr) + 5, ==, out.len);
1312
+ ASSERT_STREQUAL(caseFoldStr, (const char *)(out.data + 4));
1313
+
1314
+ _mongocrypt_buffer_cleanup(&out);
1315
+ _mongocrypt_status_reset(status);
1316
+
1317
+ spec.diacf = true;
1318
+ ASSERT_OK_STATUS(mc_text_search_str_query(&spec, &out, status), status);
1319
+ ASSERT_CMPUINT32((uint32_t)strlen(bothFoldStr) + 5, ==, out.len);
1320
+ ASSERT_STREQUAL(bothFoldStr, (const char *)(out.data + 4));
1321
+
1322
+ _mongocrypt_buffer_cleanup(&out);
1323
+ mongocrypt_status_destroy(status);
1324
+ }
1325
+
1201
1326
  void _mongocrypt_tester_install_text_search_str_encode(_mongocrypt_tester_t *tester) {
1202
1327
  INSTALL_TEST(_test_text_search_str_encode_suffix_prefix);
1203
1328
  INSTALL_TEST(_test_text_search_str_encode_substring);
1204
1329
  INSTALL_TEST(_test_text_search_str_encode_multiple);
1205
1330
  INSTALL_TEST(_test_text_search_str_encode_bad_string);
1206
1331
  INSTALL_TEST(_test_text_search_str_encode_empty_string);
1332
+ INSTALL_TEST(_test_text_search_str_query_bad_string);
1333
+ INSTALL_TEST(_test_text_search_str_query_bounds_checking);
1334
+ INSTALL_TEST(_test_text_search_str_query_empty_string);
1335
+ INSTALL_TEST(_test_text_search_str_query_folding);
1207
1336
  }