libmongocrypt-helper 1.7.4.0.1002 → 1.8.0.0.1001

Sign up to get free protection for your applications and to get access to all the features.
Files changed (396) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +9 -7
  4. data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +17 -23
  5. data/ext/libmongocrypt/libmongocrypt/Earthfile +374 -0
  6. data/ext/libmongocrypt/libmongocrypt/README.md +7 -7
  7. data/ext/libmongocrypt/libmongocrypt/VERSION_CURRENT +1 -1
  8. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClient.cs +25 -6
  9. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Library.cs +25 -3
  10. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Example/MongoDB.Libmongocrypt.Example.csproj +1 -1
  11. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/BasicTests.cs +1 -1
  12. data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.cake +3 -2
  13. data/ext/libmongocrypt/libmongocrypt/bindings/cs/cs.sln +79 -0
  14. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/build.gradle.kts +2 -2
  15. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java +6 -4
  16. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
  17. data/ext/libmongocrypt/libmongocrypt/bindings/node/CHANGELOG.md +24 -0
  18. data/ext/libmongocrypt/libmongocrypt/bindings/node/README.md +134 -5
  19. data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/build-static.sh +3 -6
  20. data/ext/libmongocrypt/libmongocrypt/bindings/node/index.d.ts +203 -77
  21. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/autoEncrypter.js +1 -1
  22. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/clientEncryption.js +165 -43
  23. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/common.js +12 -14
  24. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/errors.js +75 -0
  25. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/index.js +34 -3
  26. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/aws.js +26 -0
  27. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/azure.js +178 -0
  28. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/gcp.js +24 -0
  29. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/index.js +54 -0
  30. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/utils.js +39 -0
  31. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/stateMachine.js +9 -4
  32. data/ext/libmongocrypt/libmongocrypt/bindings/node/package-lock.json +4440 -5189
  33. data/ext/libmongocrypt/libmongocrypt/bindings/node/package.json +27 -8
  34. data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.cc +65 -38
  35. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/autoEncrypter.test.js +4 -7
  36. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/clientEncryption.test.js +434 -42
  37. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/common.test.js +94 -0
  38. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/cryptoCallbacks.test.js +1 -45
  39. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/index.test.js +45 -0
  40. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/mongocryptdManager.test.js +1 -1
  41. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/providers/credentialsProvider.test.js +551 -0
  42. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/release.test.js +10 -3
  43. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/requirements.helper.js +23 -1
  44. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/stateMachine.test.js +1 -1
  45. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/chai-addons.js +8 -0
  46. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/types/index.test-d.ts +63 -0
  47. data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +26 -0
  48. data/ext/libmongocrypt/libmongocrypt/bindings/python/README.rst +2 -2
  49. data/ext/libmongocrypt/libmongocrypt/bindings/python/build-manylinux-wheel.sh +1 -1
  50. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +128 -238
  51. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/compat.py +0 -27
  52. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/explicit_encrypter.py +1 -1
  53. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +5 -21
  54. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +2 -2
  55. data/ext/libmongocrypt/libmongocrypt/bindings/python/release.sh +5 -5
  56. data/ext/libmongocrypt/libmongocrypt/bindings/python/setup.py +14 -9
  57. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/__init__.py +1 -10
  58. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
  59. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_mongocrypt.py +5 -5
  60. data/ext/libmongocrypt/libmongocrypt/bindings/python/test-requirements.txt +4 -12
  61. data/ext/libmongocrypt/libmongocrypt/cmake/ImportBSON.cmake +8 -6
  62. data/ext/libmongocrypt/libmongocrypt/cmake/IntelDFP.cmake +2 -1
  63. data/ext/libmongocrypt/libmongocrypt/cmake/Platform.cmake +50 -0
  64. data/ext/libmongocrypt/libmongocrypt/cmake/mongocrypt-config.cmake +21 -0
  65. data/ext/libmongocrypt/libmongocrypt/debian/gbp.conf +2 -2
  66. data/ext/libmongocrypt/libmongocrypt/etc/c6-vault.repo +39 -0
  67. data/ext/libmongocrypt/libmongocrypt/etc/fle2_aead_generate_tests.py +15 -24
  68. data/ext/libmongocrypt/libmongocrypt/etc/fle2_crypto.py +66 -54
  69. data/ext/libmongocrypt/libmongocrypt/etc/fle2_generate_tests.py +14 -23
  70. data/ext/libmongocrypt/libmongocrypt/etc/fle2v2_aead_generate_tests.py +32 -0
  71. data/ext/libmongocrypt/libmongocrypt/etc/format-all.sh +12 -0
  72. data/ext/libmongocrypt/libmongocrypt/etc/format.sh +16 -0
  73. data/ext/libmongocrypt/libmongocrypt/etc/install-package.sh +48 -0
  74. data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-libmongocrypt-pr-625.patch +13 -0
  75. data/ext/libmongocrypt/libmongocrypt/src/crypto/cng.c +381 -436
  76. data/ext/libmongocrypt/libmongocrypt/src/crypto/commoncrypto.c +162 -227
  77. data/ext/libmongocrypt/libmongocrypt/src/crypto/libcrypto.c +180 -248
  78. data/ext/libmongocrypt/libmongocrypt/src/crypto/none.c +33 -55
  79. data/ext/libmongocrypt/libmongocrypt/src/csfle-markup.cpp +175 -205
  80. data/ext/libmongocrypt/libmongocrypt/src/mc-array-private.h +10 -21
  81. data/ext/libmongocrypt/libmongocrypt/src/mc-array.c +44 -56
  82. data/ext/libmongocrypt/libmongocrypt/src/mc-check-conversions-private.h +4 -8
  83. data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.h +351 -463
  84. data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.test.cpp +59 -66
  85. data/ext/libmongocrypt/libmongocrypt/src/mc-efc-private.h +7 -11
  86. data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +80 -92
  87. data/ext/libmongocrypt/libmongocrypt/src/mc-fle-blob-subtype-private.h +18 -10
  88. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +59 -70
  89. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +384 -439
  90. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private-v2.h +41 -0
  91. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private.h +11 -18
  92. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-v2.c +135 -0
  93. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload.c +109 -126
  94. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private-v2.h +88 -0
  95. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private.h +24 -27
  96. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-v2.c +137 -0
  97. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload.c +106 -125
  98. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private-v2.h +117 -0
  99. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private.h +28 -36
  100. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-v2.c +294 -0
  101. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload.c +237 -278
  102. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private-v2.h +133 -0
  103. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private.h +67 -56
  104. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-v2.c +437 -0
  105. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev.c +476 -325
  106. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common-private.h +69 -0
  107. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common.c +182 -0
  108. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-private.h +23 -31
  109. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2-private.h +85 -0
  110. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2.c +142 -0
  111. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev.c +104 -231
  112. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-range-operator-private.h +8 -7
  113. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds-private.h +55 -56
  114. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +517 -580
  115. data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +36 -66
  116. data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +57 -76
  117. data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +158 -189
  118. data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +36 -42
  119. data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +515 -558
  120. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +155 -191
  121. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +43 -53
  122. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +170 -240
  123. data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +29 -34
  124. data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +289 -338
  125. data/ext/libmongocrypt/libmongocrypt/src/mc-reader-private.h +36 -71
  126. data/ext/libmongocrypt/libmongocrypt/src/mc-reader.c +111 -164
  127. data/ext/libmongocrypt/libmongocrypt/src/mc-tokens-private.h +55 -49
  128. data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +109 -125
  129. data/ext/libmongocrypt/libmongocrypt/src/mc-writer-private.h +66 -0
  130. data/ext/libmongocrypt/libmongocrypt/src/mc-writer.c +141 -0
  131. data/ext/libmongocrypt/libmongocrypt/src/mlib/check.hpp +37 -55
  132. data/ext/libmongocrypt/libmongocrypt/src/mlib/endian.h +11 -11
  133. data/ext/libmongocrypt/libmongocrypt/src/mlib/error.h +27 -32
  134. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.h +444 -499
  135. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +251 -334
  136. data/ext/libmongocrypt/libmongocrypt/src/mlib/macros.h +4 -5
  137. data/ext/libmongocrypt/libmongocrypt/src/mlib/path.h +196 -231
  138. data/ext/libmongocrypt/libmongocrypt/src/mlib/path.test.c +56 -79
  139. data/ext/libmongocrypt/libmongocrypt/src/mlib/str.h +411 -530
  140. data/ext/libmongocrypt/libmongocrypt/src/mlib/str.test.c +116 -131
  141. data/ext/libmongocrypt/libmongocrypt/src/mlib/thread.h +17 -26
  142. data/ext/libmongocrypt/libmongocrypt/src/mlib/user-check.h +2 -2
  143. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary-private.h +3 -6
  144. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary.c +31 -48
  145. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer-private.h +55 -131
  146. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer.c +444 -565
  147. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo-private.h +1 -2
  148. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo.c +28 -45
  149. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key-private.h +11 -17
  150. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key.c +103 -132
  151. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth-private.h +8 -14
  152. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth.c +78 -90
  153. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-private.h +26 -45
  154. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache.c +220 -273
  155. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext-private.h +13 -25
  156. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext.c +147 -166
  157. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-compat.h +2 -2
  158. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto-private.h +110 -204
  159. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto.c +1137 -1565
  160. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +425 -472
  161. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +817 -694
  162. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +2394 -2697
  163. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-private.h +166 -186
  164. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-rewrap-many-datakey.c +308 -351
  165. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +921 -1138
  166. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +16 -24
  167. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endian-private.h +44 -58
  168. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint-private.h +21 -25
  169. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint.c +167 -181
  170. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek-private.h +37 -43
  171. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek.c +215 -253
  172. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker-private.h +73 -108
  173. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +889 -1034
  174. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-private.h +27 -44
  175. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key.c +349 -402
  176. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx-private.h +92 -120
  177. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx.c +1397 -1612
  178. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log-private.h +35 -67
  179. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log.c +49 -83
  180. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking-private.h +30 -36
  181. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +1821 -1470
  182. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-mutex-private.h +7 -12
  183. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +80 -108
  184. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +354 -424
  185. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +101 -117
  186. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status-private.h +3 -8
  187. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status.c +92 -119
  188. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util-private.h +19 -29
  189. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util.c +136 -176
  190. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util-private.h +11 -21
  191. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util.c +96 -135
  192. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +1092 -1320
  193. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +130 -295
  194. data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +66 -78
  195. data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_mutex.c +20 -28
  196. data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +60 -73
  197. data/ext/libmongocrypt/libmongocrypt/src/os_win/os_mutex.c +8 -16
  198. data/ext/libmongocrypt/libmongocrypt/test/crypt_shared-stub.cpp +57 -87
  199. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/encrypted-payload-v2.json +60 -0
  200. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/encrypted-payload-v2.json +67 -0
  201. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/encrypted-payload.json +2 -2
  202. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-contentionFactor1-v2.json +8 -0
  203. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-v2.json +8 -0
  204. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-contentionFactor1-v2.json +8 -0
  205. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-same-user-and-index-key-v2.json +8 -0
  206. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-v2.json +8 -0
  207. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/cmd.json +6 -0
  208. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-field-map.json +22 -0
  209. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-payload.json +40 -0
  210. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/mongocryptd-reply.json +19 -0
  211. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/cmd.json +10 -0
  212. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-field-map.json +27 -0
  213. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-payload.json +41 -0
  214. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/mongocryptd-reply.json +49 -0
  215. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/cmd.json +6 -0
  216. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
  217. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-payload.json +50 -0
  218. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/mongocryptd-reply.json +58 -0
  219. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/cmd.json +6 -0
  220. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-field-map.json +27 -0
  221. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-payload.json +41 -0
  222. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/mongocryptd-reply.json +49 -0
  223. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/cmd.json +8 -0
  224. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-field-map.json +30 -0
  225. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-payload.json +44 -0
  226. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/mongocryptd-reply.json +52 -0
  227. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/cmd.json +8 -0
  228. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-field-map.json +27 -0
  229. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-payload.json +41 -0
  230. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/mongocryptd-reply.json +49 -0
  231. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/cmd.json +8 -0
  232. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-field-map.json +27 -0
  233. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-payload.json +41 -0
  234. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/mongocryptd-reply.json +49 -0
  235. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/cmd.json +8 -0
  236. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-field-map.json +27 -0
  237. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-payload.json +41 -0
  238. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/mongocryptd-reply.json +49 -0
  239. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/encrypted-payload-v2.json +26 -0
  240. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/encrypted-payload-v2.json +26 -0
  241. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/encrypted-payload-v2.json +26 -0
  242. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload-v2.json +26 -0
  243. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/encrypted-payload-v2.json +16 -0
  244. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert/cmd.json +1 -1
  245. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/RNG_DATA.h +65 -65
  246. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/cmd.json +13 -0
  247. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-field-map.json +27 -0
  248. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-payload.json +44 -0
  249. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/mongocryptd-reply.json +52 -0
  250. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/RNG_DATA.h +132 -132
  251. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/RNG_DATA.h +71 -71
  252. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/cmd.json +9 -0
  253. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
  254. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-payload.json +53 -0
  255. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/mongocryptd-reply.json +61 -0
  256. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/cmd.json +9 -0
  257. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-field-map.json +27 -0
  258. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-payload.json +44 -0
  259. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/mongocryptd-reply.json +52 -0
  260. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/RNG_DATA.h +68 -68
  261. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/RNG_DATA.h +19 -19
  262. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/cmd.json +11 -0
  263. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-field-map.json +30 -0
  264. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-payload.json +47 -0
  265. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/mongocryptd-reply.json +55 -0
  266. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/cmd.json +11 -0
  267. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-field-map.json +27 -0
  268. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-payload.json +44 -0
  269. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/mongocryptd-reply.json +52 -0
  270. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/RNG_DATA.h +25 -25
  271. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/cmd.json +11 -0
  272. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-field-map.json +27 -0
  273. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-payload.json +44 -0
  274. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/mongocryptd-reply.json +52 -0
  275. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/RNG_DATA.h +65 -65
  276. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/cmd.json +11 -0
  277. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-field-map.json +27 -0
  278. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-payload.json +44 -0
  279. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/mongocryptd-reply.json +52 -0
  280. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/RNG_DATA.h +68 -68
  281. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/encrypted-payload-v2.json +8 -0
  282. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/RNG_DATA.h +19 -19
  283. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/encrypted-payload-v2.json +8 -0
  284. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/RNG_DATA.h +25 -25
  285. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/encrypted-payload-v2.json +8 -0
  286. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload-v2.json +8 -0
  287. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/RNG_DATA.h +15 -15
  288. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/encrypted-payload-v2.json +8 -0
  289. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/cmd.json +9 -0
  290. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-field-map.json +18 -0
  291. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-payload.json +14 -0
  292. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/mongocryptd-reply.json +41 -0
  293. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/cmd.json +9 -0
  294. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-field-map.json +22 -0
  295. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-payload.json +39 -0
  296. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/mongocryptd-reply.json +49 -0
  297. data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneRangeV2.json +10 -0
  298. data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneV2.json +10 -0
  299. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/README.md +17 -0
  300. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/aes-ctr.json +29 -0
  301. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-fixed.json +10 -0
  302. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-generated.json +38 -0
  303. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-decrypt.json +35 -0
  304. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-fixed.json +29 -0
  305. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-generated.json +122 -0
  306. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-fixed.json +29 -0
  307. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-generated.json +122 -0
  308. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/mcgrew.json +12 -0
  309. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/nist.json +20 -0
  310. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/README.md +27 -0
  311. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/mc.json +21 -0
  312. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/server.json +21 -0
  313. data/ext/libmongocrypt/libmongocrypt/test/example-no-bson.c +4 -4
  314. data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +278 -323
  315. data/ext/libmongocrypt/libmongocrypt/test/fuzz_kms.c +8 -7
  316. data/ext/libmongocrypt/libmongocrypt/test/test-dll.cpp +6 -7
  317. data/ext/libmongocrypt/libmongocrypt/test/test-gcp-auth.c +221 -283
  318. data/ext/libmongocrypt/libmongocrypt/test/test-mc-efc.c +58 -73
  319. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-equality-payload-v2.c +78 -0
  320. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-range-payload-v2.c +89 -0
  321. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev-v2.c +248 -0
  322. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev.c +467 -414
  323. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup-v2.c +172 -0
  324. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup.c +141 -159
  325. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev-v2.c +338 -0
  326. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev.c +238 -176
  327. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-rfds.c +373 -474
  328. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-edge-generation.c +346 -388
  329. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +708 -825
  330. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +417 -481
  331. data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +110 -144
  332. data/ext/libmongocrypt/libmongocrypt/test/test-mc-reader.c +124 -207
  333. data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +223 -213
  334. data/ext/libmongocrypt/libmongocrypt/test/test-mc-writer.c +176 -0
  335. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +634 -807
  336. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.h +1 -2
  337. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert.h +168 -189
  338. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-buffer.c +187 -211
  339. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache-oauth.c +34 -36
  340. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache.c +210 -233
  341. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ciphertext.c +185 -220
  342. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-compact.c +331 -445
  343. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +670 -814
  344. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +102 -135
  345. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.h +54 -71
  346. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto.c +394 -846
  347. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-csfle-lib.c +159 -183
  348. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-decrypt.c +867 -1045
  349. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +4349 -4713
  350. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +750 -964
  351. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +991 -1178
  352. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +342 -419
  353. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-dll.c +23 -30
  354. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-endpoint.c +98 -111
  355. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kek.c +49 -52
  356. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-broker.c +770 -920
  357. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-cache.c +354 -407
  358. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key.c +197 -245
  359. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-ctx.c +286 -370
  360. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-responses.c +147 -166
  361. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-local-kms.c +50 -61
  362. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-log.c +85 -100
  363. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-marking.c +656 -692
  364. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-status.c +46 -58
  365. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-traverse-util.c +377 -451
  366. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.c +48 -67
  367. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.h +4 -10
  368. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +827 -918
  369. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +111 -172
  370. data/ext/libmongocrypt/libmongocrypt/test/util/csfle.c +508 -559
  371. data/ext/libmongocrypt/libmongocrypt/test/util/util.c +735 -881
  372. data/ext/libmongocrypt/libmongocrypt/test/util/util.h +33 -55
  373. data/lib/libmongocrypt_helper/version.rb +2 -2
  374. data.tar.gz.sig +0 -0
  375. metadata +154 -26
  376. metadata.gz.sig +0 -0
  377. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
  378. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/key-document.json +0 -0
  379. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/credentialsProvider.js +0 -33
  380. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/credentialsProvider.test.js +0 -163
  381. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
  382. data/ext/libmongocrypt/libmongocrypt/test/data/aes-ctr.cstructs +0 -359
  383. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-aead.cstructs +0 -109
  384. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload.json +0 -26
  385. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/rangeopts.json +0 -5
  386. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/value-to-encrypt.json +0 -20
  387. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/RNG_DATA.h +0 -70
  388. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload.json +0 -8
  389. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/rangeopts.json +0 -5
  390. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/value-to-encrypt.json +0 -5
  391. data/ext/libmongocrypt/libmongocrypt/test/data/fle2.cstructs +0 -33
  392. /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/key-filter.json +0 -0
  393. /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/rangeopts.json +0 -0
  394. /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/value-to-encrypt.json +0 -0
  395. /data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/rangeopts.json +0 -0
  396. /data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/value-to-encrypt.json +0 -0
@@ -16,152 +16,126 @@
16
16
 
17
17
  #include <bson/bson.h>
18
18
 
19
- #include "mongocrypt-opts-private.h"
20
19
  #include "mongocrypt-log-private.h"
20
+ #include "mongocrypt-opts-private.h"
21
21
  #include "mongocrypt-private.h"
22
22
 
23
23
  #include <kms_message/kms_b64.h>
24
24
 
25
- void
26
- _mongocrypt_opts_init (_mongocrypt_opts_t *opts)
27
- {
28
- BSON_ASSERT_PARAM (opts);
29
- memset (opts, 0, sizeof (*opts));
25
+ void _mongocrypt_opts_init(_mongocrypt_opts_t *opts) {
26
+ BSON_ASSERT_PARAM(opts);
27
+ memset(opts, 0, sizeof(*opts));
30
28
  }
31
29
 
32
- static void
33
- _mongocrypt_opts_kms_provider_azure_cleanup (
34
- _mongocrypt_opts_kms_provider_azure_t *kms_provider_azure)
35
- {
36
- if (!kms_provider_azure) {
37
- return;
38
- }
39
- bson_free (kms_provider_azure->client_id);
40
- bson_free (kms_provider_azure->client_secret);
41
- bson_free (kms_provider_azure->tenant_id);
42
- bson_free (kms_provider_azure->access_token);
43
- _mongocrypt_endpoint_destroy (
44
- kms_provider_azure->identity_platform_endpoint);
30
+ static void _mongocrypt_opts_kms_provider_azure_cleanup(_mongocrypt_opts_kms_provider_azure_t *kms_provider_azure) {
31
+ if (!kms_provider_azure) {
32
+ return;
33
+ }
34
+ bson_free(kms_provider_azure->client_id);
35
+ bson_free(kms_provider_azure->client_secret);
36
+ bson_free(kms_provider_azure->tenant_id);
37
+ bson_free(kms_provider_azure->access_token);
38
+ _mongocrypt_endpoint_destroy(kms_provider_azure->identity_platform_endpoint);
45
39
  }
46
40
 
47
- static void
48
- _mongocrypt_opts_kms_provider_gcp_cleanup (
49
- _mongocrypt_opts_kms_provider_gcp_t *kms_provider_gcp)
50
- {
51
- if (!kms_provider_gcp) {
52
- return;
53
- }
54
- bson_free (kms_provider_gcp->email);
55
- _mongocrypt_endpoint_destroy (kms_provider_gcp->endpoint);
56
- _mongocrypt_buffer_cleanup (&kms_provider_gcp->private_key);
57
- bson_free (kms_provider_gcp->access_token);
41
+ static void _mongocrypt_opts_kms_provider_gcp_cleanup(_mongocrypt_opts_kms_provider_gcp_t *kms_provider_gcp) {
42
+ if (!kms_provider_gcp) {
43
+ return;
44
+ }
45
+ bson_free(kms_provider_gcp->email);
46
+ _mongocrypt_endpoint_destroy(kms_provider_gcp->endpoint);
47
+ _mongocrypt_buffer_cleanup(&kms_provider_gcp->private_key);
48
+ bson_free(kms_provider_gcp->access_token);
58
49
  }
59
50
 
60
- void
61
- _mongocrypt_opts_kms_providers_cleanup (
62
- _mongocrypt_opts_kms_providers_t *kms_providers)
63
- {
64
- if (!kms_providers) {
65
- return;
66
- }
67
- bson_free (kms_providers->aws.secret_access_key);
68
- bson_free (kms_providers->aws.access_key_id);
69
- bson_free (kms_providers->aws.session_token);
70
- _mongocrypt_buffer_cleanup (&kms_providers->local.key);
71
- _mongocrypt_opts_kms_provider_azure_cleanup (&kms_providers->azure);
72
- _mongocrypt_opts_kms_provider_gcp_cleanup (&kms_providers->gcp);
73
- _mongocrypt_endpoint_destroy (kms_providers->kmip.endpoint);
51
+ void _mongocrypt_opts_kms_providers_cleanup(_mongocrypt_opts_kms_providers_t *kms_providers) {
52
+ if (!kms_providers) {
53
+ return;
54
+ }
55
+ bson_free(kms_providers->aws.secret_access_key);
56
+ bson_free(kms_providers->aws.access_key_id);
57
+ bson_free(kms_providers->aws.session_token);
58
+ _mongocrypt_buffer_cleanup(&kms_providers->local.key);
59
+ _mongocrypt_opts_kms_provider_azure_cleanup(&kms_providers->azure);
60
+ _mongocrypt_opts_kms_provider_gcp_cleanup(&kms_providers->gcp);
61
+ _mongocrypt_endpoint_destroy(kms_providers->kmip.endpoint);
74
62
  }
75
63
 
76
-
77
- void
78
- _mongocrypt_opts_merge_kms_providers (
79
- _mongocrypt_opts_kms_providers_t *dest,
80
- const _mongocrypt_opts_kms_providers_t *source)
81
- {
82
- BSON_ASSERT_PARAM (dest);
83
- BSON_ASSERT_PARAM (source);
84
-
85
- if (source->configured_providers & MONGOCRYPT_KMS_PROVIDER_AWS) {
86
- memcpy (&dest->aws, &source->aws, sizeof (source->aws));
87
- dest->configured_providers |= MONGOCRYPT_KMS_PROVIDER_AWS;
88
- }
89
- if (source->configured_providers & MONGOCRYPT_KMS_PROVIDER_LOCAL) {
90
- memcpy (&dest->local, &source->local, sizeof (source->local));
91
- dest->configured_providers |= MONGOCRYPT_KMS_PROVIDER_LOCAL;
92
- }
93
- if (source->configured_providers & MONGOCRYPT_KMS_PROVIDER_AZURE) {
94
- memcpy (&dest->azure, &source->azure, sizeof (source->azure));
95
- dest->configured_providers |= MONGOCRYPT_KMS_PROVIDER_AZURE;
96
- }
97
- if (source->configured_providers & MONGOCRYPT_KMS_PROVIDER_GCP) {
98
- memcpy (&dest->gcp, &source->gcp, sizeof (source->gcp));
99
- dest->configured_providers |= MONGOCRYPT_KMS_PROVIDER_GCP;
100
- }
101
- if (source->configured_providers & MONGOCRYPT_KMS_PROVIDER_KMIP) {
102
- memcpy (&dest->kmip, &source->kmip, sizeof (source->kmip));
103
- dest->configured_providers |= MONGOCRYPT_KMS_PROVIDER_KMIP;
104
- }
105
- /* ensure all providers were copied */
106
- BSON_ASSERT (!(source->configured_providers & ~dest->configured_providers));
64
+ void _mongocrypt_opts_merge_kms_providers(_mongocrypt_opts_kms_providers_t *dest,
65
+ const _mongocrypt_opts_kms_providers_t *source) {
66
+ BSON_ASSERT_PARAM(dest);
67
+ BSON_ASSERT_PARAM(source);
68
+
69
+ if (source->configured_providers & MONGOCRYPT_KMS_PROVIDER_AWS) {
70
+ memcpy(&dest->aws, &source->aws, sizeof(source->aws));
71
+ dest->configured_providers |= MONGOCRYPT_KMS_PROVIDER_AWS;
72
+ }
73
+ if (source->configured_providers & MONGOCRYPT_KMS_PROVIDER_LOCAL) {
74
+ memcpy(&dest->local, &source->local, sizeof(source->local));
75
+ dest->configured_providers |= MONGOCRYPT_KMS_PROVIDER_LOCAL;
76
+ }
77
+ if (source->configured_providers & MONGOCRYPT_KMS_PROVIDER_AZURE) {
78
+ memcpy(&dest->azure, &source->azure, sizeof(source->azure));
79
+ dest->configured_providers |= MONGOCRYPT_KMS_PROVIDER_AZURE;
80
+ }
81
+ if (source->configured_providers & MONGOCRYPT_KMS_PROVIDER_GCP) {
82
+ memcpy(&dest->gcp, &source->gcp, sizeof(source->gcp));
83
+ dest->configured_providers |= MONGOCRYPT_KMS_PROVIDER_GCP;
84
+ }
85
+ if (source->configured_providers & MONGOCRYPT_KMS_PROVIDER_KMIP) {
86
+ memcpy(&dest->kmip, &source->kmip, sizeof(source->kmip));
87
+ dest->configured_providers |= MONGOCRYPT_KMS_PROVIDER_KMIP;
88
+ }
89
+ /* ensure all providers were copied */
90
+ BSON_ASSERT(!(source->configured_providers & ~dest->configured_providers));
107
91
  }
108
92
 
109
-
110
- void
111
- _mongocrypt_opts_cleanup (_mongocrypt_opts_t *opts)
112
- {
113
- if (!opts) {
114
- return;
115
- }
116
- _mongocrypt_opts_kms_providers_cleanup (&opts->kms_providers);
117
- _mongocrypt_buffer_cleanup (&opts->schema_map);
118
- _mongocrypt_buffer_cleanup (&opts->encrypted_field_config_map);
119
- // Free any lib search paths added by the caller
120
- for (int i = 0; i < opts->n_crypt_shared_lib_search_paths; ++i) {
121
- mstr_free (opts->crypt_shared_lib_search_paths[i]);
122
- }
123
- bson_free (opts->crypt_shared_lib_search_paths);
124
- mstr_free (opts->crypt_shared_lib_override_path);
93
+ void _mongocrypt_opts_cleanup(_mongocrypt_opts_t *opts) {
94
+ if (!opts) {
95
+ return;
96
+ }
97
+ _mongocrypt_opts_kms_providers_cleanup(&opts->kms_providers);
98
+ _mongocrypt_buffer_cleanup(&opts->schema_map);
99
+ _mongocrypt_buffer_cleanup(&opts->encrypted_field_config_map);
100
+ // Free any lib search paths added by the caller
101
+ for (int i = 0; i < opts->n_crypt_shared_lib_search_paths; ++i) {
102
+ mstr_free(opts->crypt_shared_lib_search_paths[i]);
103
+ }
104
+ bson_free(opts->crypt_shared_lib_search_paths);
105
+ mstr_free(opts->crypt_shared_lib_override_path);
125
106
  }
126
107
 
127
-
128
- bool
129
- _mongocrypt_opts_kms_providers_validate (
130
- _mongocrypt_opts_t *opts,
131
- _mongocrypt_opts_kms_providers_t *kms_providers,
132
- mongocrypt_status_t *status)
133
- {
134
- BSON_ASSERT_PARAM (opts);
135
- BSON_ASSERT_PARAM (kms_providers);
136
-
137
- if (!kms_providers->configured_providers &&
138
- !kms_providers->need_credentials) {
139
- CLIENT_ERR ("no kms provider set");
140
- return false;
141
- }
142
-
143
- if (kms_providers->configured_providers & MONGOCRYPT_KMS_PROVIDER_AWS) {
144
- if (!kms_providers->aws.access_key_id ||
145
- !kms_providers->aws.secret_access_key) {
146
- CLIENT_ERR ("aws credentials unset");
147
- return false;
148
- }
149
- }
150
-
151
- if (kms_providers->configured_providers & MONGOCRYPT_KMS_PROVIDER_LOCAL) {
152
- if (_mongocrypt_buffer_empty (&kms_providers->local.key)) {
153
- CLIENT_ERR ("local data key unset");
154
- return false;
155
- }
156
- }
157
-
158
- if (kms_providers->need_credentials &&
159
- !opts->use_need_kms_credentials_state) {
160
- CLIENT_ERR ("on-demand credentials not enabled");
161
- return false;
162
- }
163
-
164
- return true;
108
+ bool _mongocrypt_opts_kms_providers_validate(_mongocrypt_opts_t *opts,
109
+ _mongocrypt_opts_kms_providers_t *kms_providers,
110
+ mongocrypt_status_t *status) {
111
+ BSON_ASSERT_PARAM(opts);
112
+ BSON_ASSERT_PARAM(kms_providers);
113
+
114
+ if (!kms_providers->configured_providers && !kms_providers->need_credentials) {
115
+ CLIENT_ERR("no kms provider set");
116
+ return false;
117
+ }
118
+
119
+ if (kms_providers->configured_providers & MONGOCRYPT_KMS_PROVIDER_AWS) {
120
+ if (!kms_providers->aws.access_key_id || !kms_providers->aws.secret_access_key) {
121
+ CLIENT_ERR("aws credentials unset");
122
+ return false;
123
+ }
124
+ }
125
+
126
+ if (kms_providers->configured_providers & MONGOCRYPT_KMS_PROVIDER_LOCAL) {
127
+ if (_mongocrypt_buffer_empty(&kms_providers->local.key)) {
128
+ CLIENT_ERR("local data key unset");
129
+ return false;
130
+ }
131
+ }
132
+
133
+ if (kms_providers->need_credentials && !opts->use_need_kms_credentials_state) {
134
+ CLIENT_ERR("on-demand credentials not enabled");
135
+ return false;
136
+ }
137
+
138
+ return true;
165
139
  }
166
140
 
167
141
  /* _shares_bson_fields checks if @one or @two share any top-level field names.
@@ -169,325 +143,281 @@ _mongocrypt_opts_kms_providers_validate (
169
143
  * occurred. Sets @found to the first shared field name found.
170
144
  * If no shared field names are found, @found is set to NULL.
171
145
  */
172
- static bool
173
- _shares_bson_fields (bson_t *one,
174
- bson_t *two,
175
- const char **found,
176
- mongocrypt_status_t *status)
177
- {
178
- bson_iter_t iter1;
179
- bson_iter_t iter2;
180
-
181
- BSON_ASSERT_PARAM (one);
182
- BSON_ASSERT_PARAM (two);
183
- BSON_ASSERT_PARAM (found);
184
- *found = NULL;
185
- if (!bson_iter_init (&iter1, one)) {
186
- CLIENT_ERR ("error iterating one BSON in _shares_bson_fields");
187
- return false;
188
- }
189
- while (bson_iter_next (&iter1)) {
190
- const char *key1 = bson_iter_key (&iter1);
191
-
192
- if (!bson_iter_init (&iter2, two)) {
193
- CLIENT_ERR ("error iterating two BSON in _shares_bson_fields");
194
- return false;
195
- }
196
- while (bson_iter_next (&iter2)) {
197
- const char *key2 = bson_iter_key (&iter2);
198
- if (0 == strcmp (key1, key2)) {
199
- *found = key1;
200
- return true;
201
- }
202
- }
203
- }
204
- return true;
146
+ static bool _shares_bson_fields(bson_t *one, bson_t *two, const char **found, mongocrypt_status_t *status) {
147
+ bson_iter_t iter1;
148
+ bson_iter_t iter2;
149
+
150
+ BSON_ASSERT_PARAM(one);
151
+ BSON_ASSERT_PARAM(two);
152
+ BSON_ASSERT_PARAM(found);
153
+ *found = NULL;
154
+ if (!bson_iter_init(&iter1, one)) {
155
+ CLIENT_ERR("error iterating one BSON in _shares_bson_fields");
156
+ return false;
157
+ }
158
+ while (bson_iter_next(&iter1)) {
159
+ const char *key1 = bson_iter_key(&iter1);
160
+
161
+ if (!bson_iter_init(&iter2, two)) {
162
+ CLIENT_ERR("error iterating two BSON in _shares_bson_fields");
163
+ return false;
164
+ }
165
+ while (bson_iter_next(&iter2)) {
166
+ const char *key2 = bson_iter_key(&iter2);
167
+ if (0 == strcmp(key1, key2)) {
168
+ *found = key1;
169
+ return true;
170
+ }
171
+ }
172
+ }
173
+ return true;
205
174
  }
206
175
 
207
176
  /* _validate_encrypted_field_config_map_and_schema_map validates that the same
208
177
  * namespace is not both in encrypted_field_config_map and schema_map. */
209
- static bool
210
- _validate_encrypted_field_config_map_and_schema_map (
211
- _mongocrypt_buffer_t *encrypted_field_config_map,
212
- _mongocrypt_buffer_t *schema_map,
213
- mongocrypt_status_t *status)
214
- {
215
- BSON_ASSERT_PARAM (encrypted_field_config_map);
216
- BSON_ASSERT_PARAM (schema_map);
217
-
218
- const char *found;
219
- bson_t schema_map_bson;
220
- bson_t encrypted_field_config_map_bson;
221
-
222
- /* If either map is unset, there is nothing to validate. Return true to
223
- * signal no error. */
224
- if (_mongocrypt_buffer_empty (encrypted_field_config_map)) {
225
- return true;
226
- }
227
- if (_mongocrypt_buffer_empty (schema_map)) {
228
- return true;
229
- }
230
-
231
- if (!_mongocrypt_buffer_to_bson (schema_map, &schema_map_bson)) {
232
- CLIENT_ERR ("error converting schema_map to BSON");
233
- return false;
234
- }
235
- if (!_mongocrypt_buffer_to_bson (encrypted_field_config_map,
236
- &encrypted_field_config_map_bson)) {
237
- CLIENT_ERR ("error converting encrypted_field_config_map to BSON");
238
- return false;
239
- }
240
- if (!_shares_bson_fields (
241
- &schema_map_bson, &encrypted_field_config_map_bson, &found, status)) {
242
- return false;
243
- }
244
- if (found != NULL) {
245
- CLIENT_ERR (
246
- "%s is present in both schema_map and encrypted_field_config_map",
247
- found);
248
- return false;
249
- }
250
- return true;
178
+ static bool _validate_encrypted_field_config_map_and_schema_map(_mongocrypt_buffer_t *encrypted_field_config_map,
179
+ _mongocrypt_buffer_t *schema_map,
180
+ mongocrypt_status_t *status) {
181
+ BSON_ASSERT_PARAM(encrypted_field_config_map);
182
+ BSON_ASSERT_PARAM(schema_map);
183
+
184
+ const char *found;
185
+ bson_t schema_map_bson;
186
+ bson_t encrypted_field_config_map_bson;
187
+
188
+ /* If either map is unset, there is nothing to validate. Return true to
189
+ * signal no error. */
190
+ if (_mongocrypt_buffer_empty(encrypted_field_config_map)) {
191
+ return true;
192
+ }
193
+ if (_mongocrypt_buffer_empty(schema_map)) {
194
+ return true;
195
+ }
196
+
197
+ if (!_mongocrypt_buffer_to_bson(schema_map, &schema_map_bson)) {
198
+ CLIENT_ERR("error converting schema_map to BSON");
199
+ return false;
200
+ }
201
+ if (!_mongocrypt_buffer_to_bson(encrypted_field_config_map, &encrypted_field_config_map_bson)) {
202
+ CLIENT_ERR("error converting encrypted_field_config_map to BSON");
203
+ return false;
204
+ }
205
+ if (!_shares_bson_fields(&schema_map_bson, &encrypted_field_config_map_bson, &found, status)) {
206
+ return false;
207
+ }
208
+ if (found != NULL) {
209
+ CLIENT_ERR("%s is present in both schema_map and encrypted_field_config_map", found);
210
+ return false;
211
+ }
212
+ return true;
251
213
  }
252
214
 
215
+ bool _mongocrypt_opts_validate(_mongocrypt_opts_t *opts, mongocrypt_status_t *status) {
216
+ BSON_ASSERT_PARAM(opts);
253
217
 
254
- bool
255
- _mongocrypt_opts_validate (_mongocrypt_opts_t *opts,
256
- mongocrypt_status_t *status)
257
- {
258
- BSON_ASSERT_PARAM (opts);
218
+ if (!_validate_encrypted_field_config_map_and_schema_map(&opts->encrypted_field_config_map,
219
+ &opts->schema_map,
220
+ status)) {
221
+ return false;
222
+ }
223
+ return _mongocrypt_opts_kms_providers_validate(opts, &opts->kms_providers, status);
224
+ }
259
225
 
260
- if (!_validate_encrypted_field_config_map_and_schema_map (
261
- &opts->encrypted_field_config_map, &opts->schema_map, status)) {
262
- return false;
263
- }
264
- return _mongocrypt_opts_kms_providers_validate (
265
- opts, &opts->kms_providers, status);
226
+ bool _mongocrypt_parse_optional_utf8(const bson_t *bson, const char *dotkey, char **out, mongocrypt_status_t *status) {
227
+ bson_iter_t iter;
228
+ bson_iter_t child;
229
+
230
+ BSON_ASSERT_PARAM(bson);
231
+ BSON_ASSERT_PARAM(dotkey);
232
+ BSON_ASSERT_PARAM(out);
233
+
234
+ *out = NULL;
235
+
236
+ if (!bson_iter_init(&iter, bson)) {
237
+ CLIENT_ERR("invalid BSON");
238
+ return false;
239
+ }
240
+ if (!bson_iter_find_descendant(&iter, dotkey, &child)) {
241
+ /* Not found. Not an error. */
242
+ return true;
243
+ }
244
+ if (!BSON_ITER_HOLDS_UTF8(&child)) {
245
+ CLIENT_ERR("expected UTF-8 %s", dotkey);
246
+ return false;
247
+ }
248
+
249
+ *out = bson_strdup(bson_iter_utf8(&child, NULL));
250
+ return true;
266
251
  }
267
252
 
268
- bool
269
- _mongocrypt_parse_optional_utf8 (const bson_t *bson,
270
- const char *dotkey,
271
- char **out,
272
- mongocrypt_status_t *status)
273
- {
274
- bson_iter_t iter;
275
- bson_iter_t child;
276
-
277
- BSON_ASSERT_PARAM (bson);
278
- BSON_ASSERT_PARAM (dotkey);
279
- BSON_ASSERT_PARAM (out);
280
-
281
- *out = NULL;
282
-
283
- if (!bson_iter_init (&iter, bson)) {
284
- CLIENT_ERR ("invalid BSON");
285
- return false;
286
- }
287
- if (!bson_iter_find_descendant (&iter, dotkey, &child)) {
288
- /* Not found. Not an error. */
289
- return true;
290
- }
291
- if (!BSON_ITER_HOLDS_UTF8 (&child)) {
292
- CLIENT_ERR ("expected UTF-8 %s", dotkey);
293
- return false;
294
- }
295
-
296
- *out = bson_strdup (bson_iter_utf8 (&child, NULL));
297
- return true;
253
+ bool _mongocrypt_parse_required_utf8(const bson_t *bson, const char *dotkey, char **out, mongocrypt_status_t *status) {
254
+ BSON_ASSERT_PARAM(bson);
255
+ BSON_ASSERT_PARAM(dotkey);
256
+ BSON_ASSERT_PARAM(out);
257
+
258
+ if (!_mongocrypt_parse_optional_utf8(bson, dotkey, out, status)) {
259
+ return false;
260
+ }
261
+
262
+ if (!*out) {
263
+ CLIENT_ERR("expected UTF-8 %s", dotkey);
264
+ return false;
265
+ }
266
+
267
+ return true;
298
268
  }
299
269
 
270
+ bool _mongocrypt_parse_optional_endpoint(const bson_t *bson,
271
+ const char *dotkey,
272
+ _mongocrypt_endpoint_t **out,
273
+ _mongocrypt_endpoint_parse_opts_t *opts,
274
+ mongocrypt_status_t *status) {
275
+ char *endpoint_raw;
300
276
 
301
- bool
302
- _mongocrypt_parse_required_utf8 (const bson_t *bson,
303
- const char *dotkey,
304
- char **out,
305
- mongocrypt_status_t *status)
306
- {
307
- BSON_ASSERT_PARAM (bson);
308
- BSON_ASSERT_PARAM (dotkey);
309
- BSON_ASSERT_PARAM (out);
277
+ BSON_ASSERT_PARAM(bson);
278
+ BSON_ASSERT_PARAM(dotkey);
279
+ BSON_ASSERT_PARAM(out);
310
280
 
311
- if (!_mongocrypt_parse_optional_utf8 (bson, dotkey, out, status)) {
312
- return false;
313
- }
281
+ *out = NULL;
314
282
 
315
- if (!*out) {
316
- CLIENT_ERR ("expected UTF-8 %s", dotkey);
317
- return false;
318
- }
283
+ if (!_mongocrypt_parse_optional_utf8(bson, dotkey, &endpoint_raw, status)) {
284
+ return false;
285
+ }
319
286
 
320
- return true;
287
+ /* Not found. Not an error. */
288
+ if (!endpoint_raw) {
289
+ return true;
290
+ }
291
+
292
+ *out = _mongocrypt_endpoint_new(endpoint_raw, -1, opts, status);
293
+ bson_free(endpoint_raw);
294
+ return (*out) != NULL;
321
295
  }
322
296
 
323
- bool
324
- _mongocrypt_parse_optional_endpoint (const bson_t *bson,
325
- const char *dotkey,
326
- _mongocrypt_endpoint_t **out,
327
- _mongocrypt_endpoint_parse_opts_t *opts,
328
- mongocrypt_status_t *status)
329
- {
330
- char *endpoint_raw;
331
-
332
- BSON_ASSERT_PARAM (bson);
333
- BSON_ASSERT_PARAM (dotkey);
334
- BSON_ASSERT_PARAM (out);
335
-
336
- *out = NULL;
337
-
338
- if (!_mongocrypt_parse_optional_utf8 (bson, dotkey, &endpoint_raw, status)) {
339
- return false;
340
- }
341
-
342
- /* Not found. Not an error. */
343
- if (!endpoint_raw) {
344
- return true;
345
- }
346
-
347
- *out = _mongocrypt_endpoint_new (endpoint_raw, -1, opts, status);
348
- bson_free (endpoint_raw);
349
- return (*out) != NULL;
297
+ bool _mongocrypt_parse_required_endpoint(const bson_t *bson,
298
+ const char *dotkey,
299
+ _mongocrypt_endpoint_t **out,
300
+ _mongocrypt_endpoint_parse_opts_t *opts,
301
+ mongocrypt_status_t *status) {
302
+ BSON_ASSERT_PARAM(bson);
303
+ BSON_ASSERT_PARAM(dotkey);
304
+ BSON_ASSERT_PARAM(out);
305
+
306
+ if (!_mongocrypt_parse_optional_endpoint(bson, dotkey, out, opts, status)) {
307
+ return false;
308
+ }
309
+
310
+ if (!*out) {
311
+ CLIENT_ERR("expected endpoint %s", dotkey);
312
+ return false;
313
+ }
314
+
315
+ return true;
350
316
  }
351
317
 
352
- bool
353
- _mongocrypt_parse_required_endpoint (const bson_t *bson,
354
- const char *dotkey,
355
- _mongocrypt_endpoint_t **out,
356
- _mongocrypt_endpoint_parse_opts_t *opts,
357
- mongocrypt_status_t *status)
358
- {
359
- BSON_ASSERT_PARAM (bson);
360
- BSON_ASSERT_PARAM (dotkey);
361
- BSON_ASSERT_PARAM (out);
362
-
363
- if (!_mongocrypt_parse_optional_endpoint (bson, dotkey, out, opts, status)) {
364
- return false;
365
- }
366
-
367
- if (!*out) {
368
- CLIENT_ERR ("expected endpoint %s", dotkey);
369
- return false;
370
- }
371
-
372
- return true;
318
+ bool _mongocrypt_parse_optional_binary(const bson_t *bson,
319
+ const char *dotkey,
320
+ _mongocrypt_buffer_t *out,
321
+ mongocrypt_status_t *status) {
322
+ bson_iter_t iter;
323
+ bson_iter_t child;
324
+
325
+ BSON_ASSERT_PARAM(bson);
326
+ BSON_ASSERT_PARAM(dotkey);
327
+ BSON_ASSERT_PARAM(out);
328
+
329
+ _mongocrypt_buffer_init(out);
330
+
331
+ if (!bson_iter_init(&iter, bson)) {
332
+ CLIENT_ERR("invalid BSON");
333
+ return false;
334
+ }
335
+ if (!bson_iter_find_descendant(&iter, dotkey, &child)) {
336
+ /* Not found. Not an error. */
337
+ return true;
338
+ }
339
+ if (BSON_ITER_HOLDS_UTF8(&child)) {
340
+ size_t out_len;
341
+ /* Attempt to base64 decode. */
342
+ out->data = kms_message_b64_to_raw(bson_iter_utf8(&child, NULL), &out_len);
343
+ if (!out->data) {
344
+ CLIENT_ERR("unable to parse base64 from UTF-8 field %s", dotkey);
345
+ return false;
346
+ }
347
+ BSON_ASSERT(out_len <= UINT32_MAX);
348
+ out->len = (uint32_t)out_len;
349
+ out->owned = true;
350
+ } else if (BSON_ITER_HOLDS_BINARY(&child)) {
351
+ if (!_mongocrypt_buffer_copy_from_binary_iter(out, &child)) {
352
+ CLIENT_ERR("unable to parse binary from field %s", dotkey);
353
+ return false;
354
+ }
355
+ } else {
356
+ CLIENT_ERR("expected UTF-8 or binary %s", dotkey);
357
+ return false;
358
+ }
359
+
360
+ return true;
373
361
  }
374
362
 
363
+ bool _mongocrypt_parse_required_binary(const bson_t *bson,
364
+ const char *dotkey,
365
+ _mongocrypt_buffer_t *out,
366
+ mongocrypt_status_t *status) {
367
+ BSON_ASSERT_PARAM(bson);
368
+ BSON_ASSERT_PARAM(dotkey);
369
+ BSON_ASSERT_PARAM(out);
375
370
 
376
- bool
377
- _mongocrypt_parse_optional_binary (const bson_t *bson,
378
- const char *dotkey,
379
- _mongocrypt_buffer_t *out,
380
- mongocrypt_status_t *status)
381
- {
382
- bson_iter_t iter;
383
- bson_iter_t child;
384
-
385
- BSON_ASSERT_PARAM (bson);
386
- BSON_ASSERT_PARAM (dotkey);
387
- BSON_ASSERT_PARAM (out);
388
-
389
- _mongocrypt_buffer_init (out);
390
-
391
- if (!bson_iter_init (&iter, bson)) {
392
- CLIENT_ERR ("invalid BSON");
393
- return false;
394
- }
395
- if (!bson_iter_find_descendant (&iter, dotkey, &child)) {
396
- /* Not found. Not an error. */
397
- return true;
398
- }
399
- if (BSON_ITER_HOLDS_UTF8 (&child)) {
400
- size_t out_len;
401
- /* Attempt to base64 decode. */
402
- out->data =
403
- kms_message_b64_to_raw (bson_iter_utf8 (&child, NULL), &out_len);
404
- if (!out->data) {
405
- CLIENT_ERR ("unable to parse base64 from UTF-8 field %s", dotkey);
406
- return false;
407
- }
408
- BSON_ASSERT (out_len <= UINT32_MAX);
409
- out->len = (uint32_t) out_len;
410
- out->owned = true;
411
- } else if (BSON_ITER_HOLDS_BINARY (&child)) {
412
- if (!_mongocrypt_buffer_copy_from_binary_iter (out, &child)) {
413
- CLIENT_ERR ("unable to parse binary from field %s", dotkey);
414
- return false;
415
- }
416
- } else {
417
- CLIENT_ERR ("expected UTF-8 or binary %s", dotkey);
418
- return false;
419
- }
420
-
421
-
422
- return true;
423
- }
371
+ if (!_mongocrypt_parse_optional_binary(bson, dotkey, out, status)) {
372
+ return false;
373
+ }
374
+
375
+ if (out->len == 0) {
376
+ CLIENT_ERR("expected UTF-8 or binary %s", dotkey);
377
+ return false;
378
+ }
424
379
 
425
- bool
426
- _mongocrypt_parse_required_binary (const bson_t *bson,
427
- const char *dotkey,
428
- _mongocrypt_buffer_t *out,
429
- mongocrypt_status_t *status)
430
- {
431
- BSON_ASSERT_PARAM (bson);
432
- BSON_ASSERT_PARAM (dotkey);
433
- BSON_ASSERT_PARAM (out);
434
-
435
- if (!_mongocrypt_parse_optional_binary (bson, dotkey, out, status)) {
436
- return false;
437
- }
438
-
439
- if (out->len == 0) {
440
- CLIENT_ERR ("expected UTF-8 or binary %s", dotkey);
441
- return false;
442
- }
443
-
444
- return true;
380
+ return true;
445
381
  }
446
382
 
447
- bool
448
- _mongocrypt_check_allowed_fields_va (const bson_t *bson,
449
- const char *dotkey,
450
- mongocrypt_status_t *status,
451
- ...)
452
- {
453
- va_list args;
454
- const char *field;
455
- bson_iter_t iter;
456
-
457
- BSON_ASSERT_PARAM (bson);
458
-
459
- if (dotkey) {
460
- bson_iter_t parent;
461
-
462
- bson_iter_init (&parent, bson);
463
- if (!bson_iter_find_descendant (&parent, dotkey, &iter) ||
464
- !BSON_ITER_HOLDS_DOCUMENT (&iter)) {
465
- CLIENT_ERR ("invalid BSON, expected %s", dotkey);
466
- return false;
467
- }
468
- bson_iter_recurse (&iter, &iter);
469
- } else {
470
- bson_iter_init (&iter, bson);
471
- }
472
-
473
- while (bson_iter_next (&iter)) {
474
- bool found = false;
475
-
476
- va_start (args, status);
477
- field = va_arg (args, const char *);
478
- while (field) {
479
- if (0 == strcmp (field, bson_iter_key (&iter))) {
480
- found = true;
481
- break;
482
- }
483
- field = va_arg (args, const char *);
484
- }
485
- va_end (args);
486
-
487
- if (!found) {
488
- CLIENT_ERR ("Unexpected field: '%s'", bson_iter_key (&iter));
489
- return false;
490
- }
491
- }
492
- return true;
383
+ bool _mongocrypt_check_allowed_fields_va(const bson_t *bson, const char *dotkey, mongocrypt_status_t *status, ...) {
384
+ va_list args;
385
+ const char *field;
386
+ bson_iter_t iter;
387
+
388
+ BSON_ASSERT_PARAM(bson);
389
+
390
+ if (dotkey) {
391
+ bson_iter_t parent;
392
+
393
+ bson_iter_init(&parent, bson);
394
+ if (!bson_iter_find_descendant(&parent, dotkey, &iter) || !BSON_ITER_HOLDS_DOCUMENT(&iter)) {
395
+ CLIENT_ERR("invalid BSON, expected %s", dotkey);
396
+ return false;
397
+ }
398
+ bson_iter_recurse(&iter, &iter);
399
+ } else {
400
+ bson_iter_init(&iter, bson);
401
+ }
402
+
403
+ while (bson_iter_next(&iter)) {
404
+ bool found = false;
405
+
406
+ va_start(args, status);
407
+ field = va_arg(args, const char *);
408
+ while (field) {
409
+ if (0 == strcmp(field, bson_iter_key(&iter))) {
410
+ found = true;
411
+ break;
412
+ }
413
+ field = va_arg(args, const char *);
414
+ }
415
+ va_end(args);
416
+
417
+ if (!found) {
418
+ CLIENT_ERR("Unexpected field: '%s'", bson_iter_key(&iter));
419
+ return false;
420
+ }
421
+ }
422
+ return true;
493
423
  }