libmongocrypt-helper 1.7.0.0.1001 → 1.7.4.0.1000

Sign up to get free protection for your applications and to get access to all the features.
Files changed (991) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/ext/libmongocrypt/extconf.rb +70 -0
  4. data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +164 -0
  5. data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +699 -0
  6. data/ext/libmongocrypt/libmongocrypt/CODEOWNERS +13 -0
  7. data/ext/libmongocrypt/libmongocrypt/LICENSE +201 -0
  8. data/ext/libmongocrypt/libmongocrypt/README.md +250 -0
  9. data/ext/libmongocrypt/libmongocrypt/VERSION_CURRENT +1 -0
  10. data/ext/libmongocrypt/libmongocrypt/bindings/cs/CMakeLists.txt +16 -0
  11. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/AssemblyInfo.cs +4 -0
  12. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Binary.cs +131 -0
  13. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/BinarySafeHandle.cs +60 -0
  14. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CheckableSafeHandle.cs +46 -0
  15. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CipherCallbacks.cs +168 -0
  16. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/ContextSafeHandle.cs +48 -0
  17. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClient.cs +238 -0
  18. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClientFactory.cs +134 -0
  19. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptContext.cs +214 -0
  20. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptException.cs +37 -0
  21. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptOptions.cs +67 -0
  22. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/HashCallback.cs +59 -0
  23. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/HmacShaCallbacks.cs +96 -0
  24. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/IStatus.cs +26 -0
  25. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/KmsCredentials.cs +53 -0
  26. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/KmsKeyId.cs +91 -0
  27. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/KmsRequest.cs +125 -0
  28. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/KmsRequestCollection.cs +60 -0
  29. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Library.cs +652 -0
  30. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/LibraryLoader.cs +252 -0
  31. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/LibraryLoadingException.cs +34 -0
  32. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/License.txt +14 -0
  33. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/LogLevel.cs +26 -0
  34. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/MongoCryptSafeHandle.cs +48 -0
  35. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/MongoDB.Libmongocrypt.csproj +106 -0
  36. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/MongoDB.Libmongocrypt.ruleset +85 -0
  37. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/MongoDB.Libmongocrypt.targets +21 -0
  38. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/OperatingSystemHelper.cs +59 -0
  39. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Package.include.template.csproj +38 -0
  40. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/PinnedBinary.cs +49 -0
  41. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/SecureRandomCallback.cs +51 -0
  42. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/SigningRSAESPKCSCallback.cs +74 -0
  43. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Status.cs +94 -0
  44. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/StatusSafeHandle.cs +60 -0
  45. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/StyleCop.ruleset +11 -0
  46. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/stylecop.json +8 -0
  47. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Example/MongoDB.Libmongocrypt.Example.csproj +23 -0
  48. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Example/Package.include.template.csproj +11 -0
  49. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Example/Program.cs +442 -0
  50. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/BasicTests.cs +748 -0
  51. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/BsonUtil.cs +82 -0
  52. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/CallbackUtils.cs +37 -0
  53. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/CipherCallbacksTests.cs +46 -0
  54. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/HashCallbackTests.cs +37 -0
  55. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/HmacShaCallbacksTests.cs +37 -0
  56. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/MongoDB.Libmongocrypt.Test.csproj +35 -0
  57. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/Package.include.template.csproj +23 -0
  58. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/SigningRSAESPKCSCallbackTests.cs +64 -0
  59. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/test/example/collection-info.json +37 -0
  60. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/test/example/command-reply.json +13 -0
  61. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/test/example/encrypted-command-reply.json +16 -0
  62. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/test/example/encrypted-command.json +11 -0
  63. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/test/example/encrypted-value.json +6 -0
  64. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/test/example/key-document.json +36 -0
  65. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/test/example/key-filter.json +19 -0
  66. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/test/example/list-collections-filter.json +3 -0
  67. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/test/example/mongocryptd-command.json +22 -0
  68. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/xunit.runner.json +6 -0
  69. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test32/BasicTests.cs +54 -0
  70. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test32/MongoDB.Libmongocrypt.Test32.csproj +42 -0
  71. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test32/Package.include.template.csproj +23 -0
  72. data/ext/libmongocrypt/libmongocrypt/bindings/cs/README.md +66 -0
  73. data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.cake +219 -0
  74. data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.ps1 +275 -0
  75. data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.sh +77 -0
  76. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/README.md +36 -0
  77. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/build.gradle.kts +339 -0
  78. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradle/wrapper/gradle-wrapper.jar +0 -0
  79. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradle/wrapper/gradle-wrapper.properties +5 -0
  80. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradlew +188 -0
  81. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradlew.bat +100 -0
  82. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/BinaryHolder.java +45 -0
  83. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CAPI.java +1130 -0
  84. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CAPIHelper.java +96 -0
  85. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CipherCallback.java +66 -0
  86. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/DisposableMemory.java +31 -0
  87. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/JULLogger.java +130 -0
  88. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/Logger.java +144 -0
  89. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/Loggers.java +50 -0
  90. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MacCallback.java +60 -0
  91. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MessageDigestCallback.java +55 -0
  92. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoAwsKmsProviderOptions.java +104 -0
  93. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCrypt.java +100 -0
  94. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptContext.java +137 -0
  95. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptContextImpl.java +164 -0
  96. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptException.java +67 -0
  97. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptImpl.java +408 -0
  98. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptOptions.java +284 -0
  99. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCrypts.java +38 -0
  100. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoDataKeyOptions.java +125 -0
  101. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoExplicitEncryptOptions.java +225 -0
  102. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoKeyDecryptor.java +76 -0
  103. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoKeyDecryptorImpl.java +105 -0
  104. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoLocalKmsProviderOptions.java +83 -0
  105. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoRewrapManyDataKeyOptions.java +104 -0
  106. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/SLF4JLogger.java +110 -0
  107. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/SecureRandomCallback.java +51 -0
  108. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/SigningRSAESPKCSCallback.java +76 -0
  109. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/package-info.java +18 -0
  110. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java +345 -0
  111. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/collection-info.json +37 -0
  112. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/command-reply.json +13 -0
  113. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/command.json +6 -0
  114. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/encrypted-command-reply.json +16 -0
  115. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/encrypted-command.json +11 -0
  116. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/encrypted-value.json +6 -0
  117. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/encrypted-payload.json +26 -0
  118. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/key-document.json +0 -0
  119. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/key-filter.json +19 -0
  120. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/rangeopts.json +11 -0
  121. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/value-to-encrypt.json +20 -0
  122. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/json-schema.json +15 -0
  123. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/key-document.json +36 -0
  124. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/key-filter-keyAltName.json +14 -0
  125. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/key-filter.json +19 -0
  126. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/keys/ABCDEFAB123498761234123456789012-local-document.json +30 -0
  127. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/kms-reply.txt +6 -0
  128. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/list-collections-filter.json +3 -0
  129. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/mongocryptd-command.json +22 -0
  130. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/mongocryptd-reply.json +18 -0
  131. data/ext/libmongocrypt/libmongocrypt/bindings/node/CHANGELOG.md +81 -0
  132. data/ext/libmongocrypt/libmongocrypt/bindings/node/LICENSE +201 -0
  133. data/ext/libmongocrypt/libmongocrypt/bindings/node/README.md +773 -0
  134. data/ext/libmongocrypt/libmongocrypt/bindings/node/binding.gyp +79 -0
  135. data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/README.hbs +44 -0
  136. data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/build-static.sh +39 -0
  137. data/ext/libmongocrypt/libmongocrypt/bindings/node/index.d.ts +515 -0
  138. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/autoEncrypter.js +420 -0
  139. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/buffer_pool.js +123 -0
  140. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/clientEncryption.js +699 -0
  141. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/common.js +100 -0
  142. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/credentialsProvider.js +33 -0
  143. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/cryptoCallbacks.js +87 -0
  144. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/index.js +42 -0
  145. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/mongocryptdManager.js +66 -0
  146. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/stateMachine.js +487 -0
  147. data/ext/libmongocrypt/libmongocrypt/bindings/node/package-lock.json +16051 -0
  148. data/ext/libmongocrypt/libmongocrypt/bindings/node/package.json +81 -0
  149. data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.cc +929 -0
  150. data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.h +114 -0
  151. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/autoEncrypter.test.js +953 -0
  152. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/buffer_pool.test.js +91 -0
  153. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/clientEncryption.test.js +701 -0
  154. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/credentialsProvider.test.js +163 -0
  155. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/cryptoCallbacks.test.js +284 -0
  156. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/README.md +5 -0
  157. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/cmd.json +6 -0
  158. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/collection-info.json +37 -0
  159. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encrypted-document-nested.json +8 -0
  160. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encrypted-document.json +11 -0
  161. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encryptedFields.json +30 -0
  162. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/key-document.json +32 -0
  163. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/key1-document.json +30 -0
  164. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/kms-decrypt-reply.txt +6 -0
  165. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/kms-encrypt-reply.txt +7 -0
  166. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/mongocryptd-reply.json +18 -0
  167. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/mongocryptdManager.test.js +48 -0
  168. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/release.test.js +59 -0
  169. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/requirements.helper.js +29 -0
  170. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/stateMachine.test.js +331 -0
  171. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/mongodb_reporter.js +325 -0
  172. data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +121 -0
  173. data/ext/libmongocrypt/libmongocrypt/bindings/python/LICENSE +201 -0
  174. data/ext/libmongocrypt/libmongocrypt/bindings/python/README.rst +187 -0
  175. data/ext/libmongocrypt/libmongocrypt/bindings/python/RELEASE.rst +107 -0
  176. data/ext/libmongocrypt/libmongocrypt/bindings/python/build-manylinux-wheel.sh +16 -0
  177. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/__init__.py +16 -0
  178. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/auto_encrypter.py +61 -0
  179. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binary.py +94 -0
  180. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +1561 -0
  181. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/compat.py +61 -0
  182. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/credentials.py +136 -0
  183. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/crypto.py +162 -0
  184. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/errors.py +39 -0
  185. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/explicit_encrypter.py +248 -0
  186. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +808 -0
  187. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/state_machine.py +156 -0
  188. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +17 -0
  189. data/ext/libmongocrypt/libmongocrypt/bindings/python/release.sh +92 -0
  190. data/ext/libmongocrypt/libmongocrypt/bindings/python/setup.py +84 -0
  191. data/ext/libmongocrypt/libmongocrypt/bindings/python/strip_header.py +51 -0
  192. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/__init__.py +37 -0
  193. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/collection-info.json +39 -0
  194. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/command-reply.json +13 -0
  195. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/command.json +6 -0
  196. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/compact/success/cmd.json +1 -0
  197. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/compact/success/encrypted-field-config-map.json +47 -0
  198. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/compact/success/encrypted-payload.json +23 -0
  199. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-command-reply.json +16 -0
  200. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-command.json +13 -0
  201. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-field-config-map.json +48 -0
  202. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-value.json +6 -0
  203. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit/int32/encrypted-payload.json +26 -0
  204. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit/int32/rangeopts.json +11 -0
  205. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit/int32/value-to-encrypt.json +20 -0
  206. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document-azure.json +33 -0
  207. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document-gcp.json +35 -0
  208. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document.json +33 -0
  209. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-filter.json +19 -0
  210. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/keys/12345678123498761234123456789012-local-document.json +30 -0
  211. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/keys/12345678123498761234123456789013-local-document.json +30 -0
  212. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/keys/ABCDEFAB123498761234123456789012-local-document.json +30 -0
  213. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/kms-encrypt-reply.txt +7 -0
  214. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/kms-reply-azure.txt +6 -0
  215. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/kms-reply-gcp.txt +6 -0
  216. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/kms-reply.txt +6 -0
  217. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/list-collections-filter.json +3 -0
  218. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/mongocryptd-command.json +26 -0
  219. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/mongocryptd-reply.json +20 -0
  220. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/schema-map.json +40 -0
  221. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_binding.py +71 -0
  222. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_crypto.py +49 -0
  223. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_mongocrypt.py +825 -0
  224. data/ext/libmongocrypt/libmongocrypt/bindings/python/test-requirements.txt +12 -0
  225. data/ext/libmongocrypt/libmongocrypt/cmake/FetchMongoC.cmake +20 -0
  226. data/ext/libmongocrypt/libmongocrypt/cmake/ImportBSON.cmake +209 -0
  227. data/ext/libmongocrypt/libmongocrypt/cmake/ImportDFP.cmake +70 -0
  228. data/ext/libmongocrypt/libmongocrypt/cmake/IntelDFP.cmake +409 -0
  229. data/ext/libmongocrypt/libmongocrypt/cmake/LTO.cmake +57 -0
  230. data/ext/libmongocrypt/libmongocrypt/cmake/MongoC-Warnings.cmake +74 -0
  231. data/ext/libmongocrypt/libmongocrypt/cmake/libmongocrypt-hidden-symbols.map +8 -0
  232. data/ext/libmongocrypt/libmongocrypt/cmake/libmongocrypt-hidden-symbols.txt +5 -0
  233. data/ext/libmongocrypt/libmongocrypt/cmake/libmongocrypt-static.pc.in +9 -0
  234. data/ext/libmongocrypt/libmongocrypt/cmake/libmongocrypt.pc.in +10 -0
  235. data/ext/libmongocrypt/libmongocrypt/cmake/ltocheck-lib.c +6 -0
  236. data/ext/libmongocrypt/libmongocrypt/cmake/ltocheck-main.c +9 -0
  237. data/ext/libmongocrypt/libmongocrypt/cmake/mongocrypt-config.cmake +42 -0
  238. data/ext/libmongocrypt/libmongocrypt/debian/build_snapshot.sh +79 -0
  239. data/ext/libmongocrypt/libmongocrypt/debian/changelog +105 -0
  240. data/ext/libmongocrypt/libmongocrypt/debian/compat +1 -0
  241. data/ext/libmongocrypt/libmongocrypt/debian/control +41 -0
  242. data/ext/libmongocrypt/libmongocrypt/debian/copyright +129 -0
  243. data/ext/libmongocrypt/libmongocrypt/debian/gbp.conf +23 -0
  244. data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt-dev.dirs +2 -0
  245. data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt-dev.install +5 -0
  246. data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt0.dirs +1 -0
  247. data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt0.install +1 -0
  248. data/ext/libmongocrypt/libmongocrypt/debian/rules +46 -0
  249. data/ext/libmongocrypt/libmongocrypt/debian/source/format +1 -0
  250. data/ext/libmongocrypt/libmongocrypt/debian/source/lintian-overrides +3 -0
  251. data/ext/libmongocrypt/libmongocrypt/debian/source/options +1 -0
  252. data/ext/libmongocrypt/libmongocrypt/debian/watch +3 -0
  253. data/ext/libmongocrypt/libmongocrypt/doc/Doxygen +2474 -0
  254. data/ext/libmongocrypt/libmongocrypt/etc/calc_release_version.py +265 -0
  255. data/ext/libmongocrypt/libmongocrypt/etc/debian/control +33 -0
  256. data/ext/libmongocrypt/libmongocrypt/etc/debian/rules +41 -0
  257. data/ext/libmongocrypt/libmongocrypt/etc/debian/source/format +1 -0
  258. data/ext/libmongocrypt/libmongocrypt/etc/fle2_aead_generate_tests.py +41 -0
  259. data/ext/libmongocrypt/libmongocrypt/etc/fle2_crypto.py +105 -0
  260. data/ext/libmongocrypt/libmongocrypt/etc/fle2_crypto_selftest.py +52 -0
  261. data/ext/libmongocrypt/libmongocrypt/etc/fle2_generate_tests.py +34 -0
  262. data/ext/libmongocrypt/libmongocrypt/etc/generate-kek-tests.py +69 -0
  263. data/ext/libmongocrypt/libmongocrypt/etc/generate-test-data.py +141 -0
  264. data/ext/libmongocrypt/libmongocrypt/etc/list-compile-files.py +20 -0
  265. data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-MONGOCRYPT-571.patch +25 -0
  266. data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-s390x.patch +134 -0
  267. data/ext/libmongocrypt/libmongocrypt/etc/packager.py +854 -0
  268. data/ext/libmongocrypt/libmongocrypt/etc/print-marking.py +36 -0
  269. data/ext/libmongocrypt/libmongocrypt/etc/repo_config.yaml +257 -0
  270. data/ext/libmongocrypt/libmongocrypt/etc/requirements.txt +2 -0
  271. data/ext/libmongocrypt/libmongocrypt/etc/rewrite.py +16 -0
  272. data/ext/libmongocrypt/libmongocrypt/etc/rpm/libmongocrypt.spec +67 -0
  273. data/ext/libmongocrypt/libmongocrypt/etc/rpm/tweak.awk +19 -0
  274. data/ext/libmongocrypt/libmongocrypt/integrating.md +251 -0
  275. data/ext/libmongocrypt/libmongocrypt/kms-message/CMakeLists.txt +305 -0
  276. data/ext/libmongocrypt/libmongocrypt/kms-message/COPYING +177 -0
  277. data/ext/libmongocrypt/libmongocrypt/kms-message/README.md +41 -0
  278. data/ext/libmongocrypt/libmongocrypt/kms-message/THIRD_PARTY_NOTICES +42 -0
  279. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/LICENSE +202 -0
  280. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/NOTICE +2 -0
  281. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-key-duplicate/get-header-key-duplicate.authz +1 -0
  282. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-key-duplicate/get-header-key-duplicate.creq +9 -0
  283. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-key-duplicate/get-header-key-duplicate.req +6 -0
  284. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-key-duplicate/get-header-key-duplicate.sreq +7 -0
  285. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-key-duplicate/get-header-key-duplicate.sts +4 -0
  286. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-multiline/get-header-value-multiline.authz +1 -0
  287. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-multiline/get-header-value-multiline.creq +9 -0
  288. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-multiline/get-header-value-multiline.req +6 -0
  289. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-multiline/get-header-value-multiline.sreq +7 -0
  290. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-multiline/get-header-value-multiline.sts +4 -0
  291. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-order/get-header-value-order.authz +1 -0
  292. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-order/get-header-value-order.creq +9 -0
  293. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-order/get-header-value-order.req +7 -0
  294. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-order/get-header-value-order.sreq +8 -0
  295. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-order/get-header-value-order.sts +4 -0
  296. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-trim/get-header-value-trim.authz +1 -0
  297. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-trim/get-header-value-trim.creq +10 -0
  298. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-trim/get-header-value-trim.req +5 -0
  299. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-trim/get-header-value-trim.sreq +6 -0
  300. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-trim/get-header-value-trim.sts +4 -0
  301. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-unreserved/get-unreserved.authz +1 -0
  302. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-unreserved/get-unreserved.creq +8 -0
  303. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-unreserved/get-unreserved.req +3 -0
  304. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-unreserved/get-unreserved.sreq +4 -0
  305. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-unreserved/get-unreserved.sts +4 -0
  306. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-utf8/get-utf8.authz +1 -0
  307. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-utf8/get-utf8.creq +8 -0
  308. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-utf8/get-utf8.req +3 -0
  309. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-utf8/get-utf8.sreq +4 -0
  310. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-utf8/get-utf8.sts +4 -0
  311. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla/get-vanilla.authz +1 -0
  312. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla/get-vanilla.creq +8 -0
  313. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla/get-vanilla.req +3 -0
  314. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla/get-vanilla.sreq +4 -0
  315. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla/get-vanilla.sts +4 -0
  316. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-empty-query-key/get-vanilla-empty-query-key.authz +1 -0
  317. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-empty-query-key/get-vanilla-empty-query-key.creq +8 -0
  318. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-empty-query-key/get-vanilla-empty-query-key.req +3 -0
  319. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-empty-query-key/get-vanilla-empty-query-key.sreq +4 -0
  320. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-empty-query-key/get-vanilla-empty-query-key.sts +4 -0
  321. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query/get-vanilla-query.authz +1 -0
  322. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query/get-vanilla-query.creq +8 -0
  323. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query/get-vanilla-query.req +3 -0
  324. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query/get-vanilla-query.sreq +4 -0
  325. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query/get-vanilla-query.sts +4 -0
  326. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-key/get-vanilla-query-order-key.authz +1 -0
  327. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-key/get-vanilla-query-order-key.creq +8 -0
  328. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-key/get-vanilla-query-order-key.req +3 -0
  329. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-key/get-vanilla-query-order-key.sreq +4 -0
  330. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-key/get-vanilla-query-order-key.sts +4 -0
  331. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-key-case/get-vanilla-query-order-key-case.authz +1 -0
  332. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-key-case/get-vanilla-query-order-key-case.creq +8 -0
  333. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-key-case/get-vanilla-query-order-key-case.req +3 -0
  334. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-key-case/get-vanilla-query-order-key-case.sreq +4 -0
  335. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-key-case/get-vanilla-query-order-key-case.sts +4 -0
  336. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-value/get-vanilla-query-order-value.authz +1 -0
  337. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-value/get-vanilla-query-order-value.creq +8 -0
  338. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-value/get-vanilla-query-order-value.req +3 -0
  339. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-value/get-vanilla-query-order-value.sreq +4 -0
  340. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-value/get-vanilla-query-order-value.sts +4 -0
  341. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-unreserved/get-vanilla-query-unreserved.authz +1 -0
  342. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-unreserved/get-vanilla-query-unreserved.creq +8 -0
  343. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-unreserved/get-vanilla-query-unreserved.req +3 -0
  344. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-unreserved/get-vanilla-query-unreserved.sreq +4 -0
  345. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-unreserved/get-vanilla-query-unreserved.sts +4 -0
  346. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-utf8-query/get-vanilla-utf8-query.authz +1 -0
  347. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-utf8-query/get-vanilla-utf8-query.creq +8 -0
  348. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-utf8-query/get-vanilla-utf8-query.req +3 -0
  349. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-utf8-query/get-vanilla-utf8-query.sreq +4 -0
  350. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-utf8-query/get-vanilla-utf8-query.sts +4 -0
  351. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative/get-relative.authz +1 -0
  352. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative/get-relative.creq +8 -0
  353. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative/get-relative.req +3 -0
  354. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative/get-relative.sreq +4 -0
  355. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative/get-relative.sts +4 -0
  356. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative-relative/get-relative-relative.authz +1 -0
  357. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative-relative/get-relative-relative.creq +8 -0
  358. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative-relative/get-relative-relative.req +3 -0
  359. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative-relative/get-relative-relative.sreq +4 -0
  360. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative-relative/get-relative-relative.sts +4 -0
  361. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash/get-slash.authz +1 -0
  362. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash/get-slash.creq +8 -0
  363. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash/get-slash.req +3 -0
  364. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash/get-slash.sreq +4 -0
  365. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash/get-slash.sts +4 -0
  366. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-dot-slash/get-slash-dot-slash.authz +1 -0
  367. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-dot-slash/get-slash-dot-slash.creq +8 -0
  368. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-dot-slash/get-slash-dot-slash.req +3 -0
  369. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-dot-slash/get-slash-dot-slash.sreq +4 -0
  370. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-dot-slash/get-slash-dot-slash.sts +4 -0
  371. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-pointless-dot/get-slash-pointless-dot.authz +1 -0
  372. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-pointless-dot/get-slash-pointless-dot.creq +8 -0
  373. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-pointless-dot/get-slash-pointless-dot.req +3 -0
  374. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-pointless-dot/get-slash-pointless-dot.sreq +4 -0
  375. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-pointless-dot/get-slash-pointless-dot.sts +4 -0
  376. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slashes/get-slashes.authz +1 -0
  377. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slashes/get-slashes.creq +8 -0
  378. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slashes/get-slashes.req +3 -0
  379. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slashes/get-slashes.sreq +4 -0
  380. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slashes/get-slashes.sts +4 -0
  381. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-space/get-space.authz +1 -0
  382. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-space/get-space.creq +8 -0
  383. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-space/get-space.req +3 -0
  384. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-space/get-space.sreq +4 -0
  385. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-space/get-space.sts +4 -0
  386. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/normalize-path.txt +3 -0
  387. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-case/post-header-key-case.authz +1 -0
  388. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-case/post-header-key-case.creq +8 -0
  389. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-case/post-header-key-case.req +3 -0
  390. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-case/post-header-key-case.sreq +4 -0
  391. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-case/post-header-key-case.sts +4 -0
  392. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-sort/post-header-key-sort.authz +1 -0
  393. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-sort/post-header-key-sort.creq +9 -0
  394. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-sort/post-header-key-sort.req +4 -0
  395. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-sort/post-header-key-sort.sreq +5 -0
  396. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-sort/post-header-key-sort.sts +4 -0
  397. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-value-case/post-header-value-case.authz +1 -0
  398. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-value-case/post-header-value-case.creq +9 -0
  399. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-value-case/post-header-value-case.req +4 -0
  400. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-value-case/post-header-value-case.sreq +5 -0
  401. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-value-case/post-header-value-case.sts +4 -0
  402. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-sts-token/post-sts-header-after/post-sts-header-after.authz +1 -0
  403. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-sts-token/post-sts-header-after/post-sts-header-after.creq +8 -0
  404. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-sts-token/post-sts-header-after/post-sts-header-after.req +3 -0
  405. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-sts-token/post-sts-header-after/post-sts-header-after.sreq +5 -0
  406. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-sts-token/post-sts-header-after/post-sts-header-after.sts +4 -0
  407. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-sts-token/post-sts-header-before/post-sts-header-before.authz +1 -0
  408. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-sts-token/post-sts-header-before/post-sts-header-before.creq +9 -0
  409. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-sts-token/post-sts-header-before/post-sts-header-before.req +4 -0
  410. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-sts-token/post-sts-header-before/post-sts-header-before.sreq +5 -0
  411. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-sts-token/post-sts-header-before/post-sts-header-before.sts +4 -0
  412. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-sts-token/readme.txt +15 -0
  413. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla/post-vanilla.authz +1 -0
  414. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla/post-vanilla.creq +8 -0
  415. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla/post-vanilla.req +3 -0
  416. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla/post-vanilla.sreq +4 -0
  417. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla/post-vanilla.sts +4 -0
  418. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-empty-query-value/post-vanilla-empty-query-value.authz +1 -0
  419. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-empty-query-value/post-vanilla-empty-query-value.creq +8 -0
  420. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-empty-query-value/post-vanilla-empty-query-value.req +3 -0
  421. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-empty-query-value/post-vanilla-empty-query-value.sreq +4 -0
  422. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-empty-query-value/post-vanilla-empty-query-value.sts +4 -0
  423. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-query/post-vanilla-query.authz +1 -0
  424. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-query/post-vanilla-query.creq +8 -0
  425. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-query/post-vanilla-query.req +3 -0
  426. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-query/post-vanilla-query.sreq +4 -0
  427. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-query/post-vanilla-query.sts +4 -0
  428. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-x-www-form-urlencoded/post-x-www-form-urlencoded.authz +1 -0
  429. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-x-www-form-urlencoded/post-x-www-form-urlencoded.creq +9 -0
  430. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-x-www-form-urlencoded/post-x-www-form-urlencoded.req +6 -0
  431. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-x-www-form-urlencoded/post-x-www-form-urlencoded.sreq +7 -0
  432. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-x-www-form-urlencoded/post-x-www-form-urlencoded.sts +4 -0
  433. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-x-www-form-urlencoded-parameters/post-x-www-form-urlencoded-parameters.authz +1 -0
  434. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-x-www-form-urlencoded-parameters/post-x-www-form-urlencoded-parameters.creq +9 -0
  435. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-x-www-form-urlencoded-parameters/post-x-www-form-urlencoded-parameters.req +6 -0
  436. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-x-www-form-urlencoded-parameters/post-x-www-form-urlencoded-parameters.sreq +7 -0
  437. data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-x-www-form-urlencoded-parameters/post-x-www-form-urlencoded-parameters.sts +4 -0
  438. data/ext/libmongocrypt/libmongocrypt/kms-message/cmake/kms_message-config.cmake +1 -0
  439. data/ext/libmongocrypt/libmongocrypt/kms-message/cmake/libkms_message.pc.in +9 -0
  440. data/ext/libmongocrypt/libmongocrypt/kms-message/src/hexlify.c +67 -0
  441. data/ext/libmongocrypt/libmongocrypt/kms-message/src/hexlify.h +24 -0
  442. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_azure_request.c +219 -0
  443. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_b64.c +654 -0
  444. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_caller_identity_request.c +52 -0
  445. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_crypto.h +70 -0
  446. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_crypto_apple.c +159 -0
  447. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_crypto_libcrypto.c +142 -0
  448. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_crypto_none.c +65 -0
  449. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_crypto_windows.c +268 -0
  450. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_decrypt_request.c +72 -0
  451. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_encrypt_request.c +73 -0
  452. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_endian_private.h +165 -0
  453. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_gcp_request.c +286 -0
  454. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_item_type_private.h +59 -0
  455. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_reader_writer.c +502 -0
  456. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_reader_writer_private.h +150 -0
  457. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_request.c +256 -0
  458. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_response.c +323 -0
  459. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_response_parser.c +148 -0
  460. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_response_parser_private.h +55 -0
  461. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_result_reason_private.h +77 -0
  462. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_result_status_private.h +54 -0
  463. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_tag_type_private.h +343 -0
  464. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kv_list.c +149 -0
  465. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kv_list.h +56 -0
  466. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_azure_request.h +110 -0
  467. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_b64.h +70 -0
  468. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_caller_identity_request.h +36 -0
  469. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_decrypt_request.h +37 -0
  470. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_encrypt_request.h +39 -0
  471. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_gcp_request.h +124 -0
  472. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_kmip_request.h +58 -0
  473. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_kmip_response.h +40 -0
  474. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_kmip_response_parser.h +26 -0
  475. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_message.h +34 -0
  476. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_message_defines.h +72 -0
  477. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_request.h +103 -0
  478. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_request_opt.h +80 -0
  479. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_response.h +43 -0
  480. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_response_parser.h +64 -0
  481. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message.c +47 -0
  482. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message_private.h +142 -0
  483. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_port.c +33 -0
  484. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_port.h +34 -0
  485. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request.c +925 -0
  486. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_opt.c +88 -0
  487. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_opt_private.h +32 -0
  488. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_str.c +520 -0
  489. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_str.h +89 -0
  490. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_response.c +54 -0
  491. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_response_parser.c +408 -0
  492. data/ext/libmongocrypt/libmongocrypt/kms-message/src/sort.c +74 -0
  493. data/ext/libmongocrypt/libmongocrypt/kms-message/src/sort.h +21 -0
  494. data/ext/libmongocrypt/libmongocrypt/kms-message/test/connection_close/connection_close.sreq +5 -0
  495. data/ext/libmongocrypt/libmongocrypt/kms-message/test/content_length/content_length.sreq +7 -0
  496. data/ext/libmongocrypt/libmongocrypt/kms-message/test/decrypt/decrypt.creq +11 -0
  497. data/ext/libmongocrypt/libmongocrypt/kms-message/test/decrypt/decrypt.sreq +9 -0
  498. data/ext/libmongocrypt/libmongocrypt/kms-message/test/encrypt/encrypt.creq +11 -0
  499. data/ext/libmongocrypt/libmongocrypt/kms-message/test/encrypt/encrypt.sreq +9 -0
  500. data/ext/libmongocrypt/libmongocrypt/kms-message/test/example-chunked-response.bin +20 -0
  501. data/ext/libmongocrypt/libmongocrypt/kms-message/test/example-multi-chunked-response.bin +22 -0
  502. data/ext/libmongocrypt/libmongocrypt/kms-message/test/example-response.bin +6 -0
  503. data/ext/libmongocrypt/libmongocrypt/kms-message/test/host/host.sreq +4 -0
  504. data/ext/libmongocrypt/libmongocrypt/kms-message/test/multibyte/multibyte.creq +10 -0
  505. data/ext/libmongocrypt/libmongocrypt/kms-message/test/multibyte/multibyte.sreq +8 -0
  506. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kmip_reader_writer.c +485 -0
  507. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_assert.h +147 -0
  508. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_azure_online.c +260 -0
  509. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_gcp_online.c +250 -0
  510. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_kmip_request.c +223 -0
  511. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_kmip_response.c +214 -0
  512. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_kmip_response_parser.c +197 -0
  513. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_online_util.c +120 -0
  514. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_online_util.h +35 -0
  515. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_request.c +1302 -0
  516. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_util.c +92 -0
  517. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_util.h +45 -0
  518. data/ext/libmongocrypt/libmongocrypt/kms-message/test/windows/dirent.h +1224 -0
  519. data/ext/libmongocrypt/libmongocrypt/src/crypto/cng.c +640 -0
  520. data/ext/libmongocrypt/libmongocrypt/src/crypto/commoncrypto.c +326 -0
  521. data/ext/libmongocrypt/libmongocrypt/src/crypto/libcrypto.c +341 -0
  522. data/ext/libmongocrypt/libmongocrypt/src/crypto/none.c +97 -0
  523. data/ext/libmongocrypt/libmongocrypt/src/csfle-markup.cpp +237 -0
  524. data/ext/libmongocrypt/libmongocrypt/src/mc-array-private.h +54 -0
  525. data/ext/libmongocrypt/libmongocrypt/src/mc-array.c +102 -0
  526. data/ext/libmongocrypt/libmongocrypt/src/mc-check-conversions-private.h +36 -0
  527. data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.h +743 -0
  528. data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.test.cpp +86 -0
  529. data/ext/libmongocrypt/libmongocrypt/src/mc-efc-private.h +48 -0
  530. data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +127 -0
  531. data/ext/libmongocrypt/libmongocrypt/src/mc-fle-blob-subtype-private.h +40 -0
  532. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +152 -0
  533. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +487 -0
  534. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private.h +47 -0
  535. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload.c +156 -0
  536. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private.h +95 -0
  537. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload.c +158 -0
  538. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private.h +124 -0
  539. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload.c +316 -0
  540. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private.h +179 -0
  541. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev.c +385 -0
  542. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-private.h +93 -0
  543. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev.c +269 -0
  544. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-range-operator-private.h +29 -0
  545. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds-private.h +91 -0
  546. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +658 -0
  547. data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +124 -0
  548. data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +161 -0
  549. data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +242 -0
  550. data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +128 -0
  551. data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +620 -0
  552. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +308 -0
  553. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +112 -0
  554. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +341 -0
  555. data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +99 -0
  556. data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +382 -0
  557. data/ext/libmongocrypt/libmongocrypt/src/mc-reader-private.h +130 -0
  558. data/ext/libmongocrypt/libmongocrypt/src/mc-reader.c +235 -0
  559. data/ext/libmongocrypt/libmongocrypt/src/mc-tokens-private.h +118 -0
  560. data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +151 -0
  561. data/ext/libmongocrypt/libmongocrypt/src/mlib/check.hpp +89 -0
  562. data/ext/libmongocrypt/libmongocrypt/src/mlib/endian.h +42 -0
  563. data/ext/libmongocrypt/libmongocrypt/src/mlib/error.h +59 -0
  564. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.h +685 -0
  565. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.c +3 -0
  566. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +407 -0
  567. data/ext/libmongocrypt/libmongocrypt/src/mlib/macros.h +53 -0
  568. data/ext/libmongocrypt/libmongocrypt/src/mlib/path.h +381 -0
  569. data/ext/libmongocrypt/libmongocrypt/src/mlib/path.test.c +93 -0
  570. data/ext/libmongocrypt/libmongocrypt/src/mlib/str.h +1028 -0
  571. data/ext/libmongocrypt/libmongocrypt/src/mlib/str.test.c +137 -0
  572. data/ext/libmongocrypt/libmongocrypt/src/mlib/thread.h +88 -0
  573. data/ext/libmongocrypt/libmongocrypt/src/mlib/user-check.h +4 -0
  574. data/ext/libmongocrypt/libmongocrypt/src/mlib/windows-lean.h +19 -0
  575. data/ext/libmongocrypt/libmongocrypt/src/mongo_crypt-v1.h +320 -0
  576. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary-private.h +34 -0
  577. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary.c +87 -0
  578. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer-private.h +236 -0
  579. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer.c +691 -0
  580. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo-private.h +24 -0
  581. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo.c +82 -0
  582. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key-private.h +55 -0
  583. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key.c +190 -0
  584. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth-private.h +46 -0
  585. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth.c +126 -0
  586. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-private.h +96 -0
  587. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache.c +341 -0
  588. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext-private.h +64 -0
  589. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext.c +212 -0
  590. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-compat.h +44 -0
  591. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-config.h.in +87 -0
  592. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto-private.h +303 -0
  593. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto.c +1850 -0
  594. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +534 -0
  595. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +773 -0
  596. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +3005 -0
  597. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-private.h +269 -0
  598. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-rewrap-many-datakey.c +415 -0
  599. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +1283 -0
  600. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +97 -0
  601. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endian-private.h +168 -0
  602. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint-private.h +64 -0
  603. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint.c +212 -0
  604. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek-private.h +109 -0
  605. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek.c +325 -0
  606. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker-private.h +209 -0
  607. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +1189 -0
  608. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-private.h +87 -0
  609. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key.c +473 -0
  610. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx-private.h +154 -0
  611. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx.c +1785 -0
  612. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log-private.h +111 -0
  613. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log.c +123 -0
  614. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking-private.h +74 -0
  615. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +1624 -0
  616. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-mutex-private.h +46 -0
  617. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +231 -0
  618. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +493 -0
  619. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +197 -0
  620. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status-private.h +39 -0
  621. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status.c +169 -0
  622. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util-private.h +59 -0
  623. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util.c +234 -0
  624. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util-private.h +84 -0
  625. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util.c +203 -0
  626. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +1605 -0
  627. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +1610 -0
  628. data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +132 -0
  629. data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_mutex.c +57 -0
  630. data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +92 -0
  631. data/ext/libmongocrypt/libmongocrypt/src/os_win/os_mutex.c +45 -0
  632. data/ext/libmongocrypt/libmongocrypt/test/crypt_shared-stub.cpp +155 -0
  633. data/ext/libmongocrypt/libmongocrypt/test/data/NIST-CAVP.cstructs +1350 -0
  634. data/ext/libmongocrypt/libmongocrypt/test/data/aes-ctr.cstructs +359 -0
  635. data/ext/libmongocrypt/libmongocrypt/test/data/cache-tests.json +197 -0
  636. data/ext/libmongocrypt/libmongocrypt/test/data/collection-info-no-schema.json +19 -0
  637. data/ext/libmongocrypt/libmongocrypt/test/data/collection-info-no-validator.json +13 -0
  638. data/ext/libmongocrypt/libmongocrypt/test/data/collection-info-view.json +11 -0
  639. data/ext/libmongocrypt/libmongocrypt/test/data/collinfo-siblings.json +40 -0
  640. data/ext/libmongocrypt/libmongocrypt/test/data/compact/missing-key-id/collinfo.json +21 -0
  641. data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-fields/collinfo.json +10 -0
  642. data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-fields/encrypted-payload.json +4 -0
  643. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/cmd.json +1 -0
  644. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/collinfo.json +49 -0
  645. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-field-config-map.json +47 -0
  646. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-payload.json +23 -0
  647. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/mongocryptd-reply.json +72 -0
  648. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/omitted/cmd-to-mongocryptd.json +34 -0
  649. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/omitted/cmd.json +6 -0
  650. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/omitted/collinfo.json +27 -0
  651. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/omitted/encrypted-payload.json +39 -0
  652. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/omitted/mongocryptd-reply.json +45 -0
  653. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved/cmd-to-mongocryptd.json +34 -0
  654. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved/cmd.json +7 -0
  655. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved/collinfo.json +27 -0
  656. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved/encrypted-payload.json +40 -0
  657. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved/mongocryptd-reply.json +45 -0
  658. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_empty/cmd-to-mongocryptd.json +17 -0
  659. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_empty/cmd.json +7 -0
  660. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_empty/collinfo.json +10 -0
  661. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_empty/encrypted-payload.json +7 -0
  662. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_empty/mongocryptd-reply.json +23 -0
  663. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_fle1/cmd-to-mongocryptd.json +26 -0
  664. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_fle1/cmd.json +7 -0
  665. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_fle1/collinfo.json +25 -0
  666. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_fle1/encrypted-payload.json +14 -0
  667. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_fle1/mongocryptd-reply.json +15 -0
  668. data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-extraField.json +24 -0
  669. data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-missingKeyId.json +17 -0
  670. data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-oneField.json +23 -0
  671. data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-twoFields.json +39 -0
  672. data/ext/libmongocrypt/libmongocrypt/test/data/encrypted-cmd.json +11 -0
  673. data/ext/libmongocrypt/libmongocrypt/test/data/encrypted-field-config-map.json +48 -0
  674. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decryption-input.json +8 -0
  675. data/ext/libmongocrypt/libmongocrypt/test/data/find-with-encryptionInformation.json +16 -0
  676. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-collMod/cmd-to-mongocryptd.json +12 -0
  677. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-collMod/cmd.json +8 -0
  678. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-collMod/insert/cmd.json +8 -0
  679. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-collMod/insert/collinfo.json +9 -0
  680. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-collMod/mongocryptd-reply.json +14 -0
  681. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/old-mongocryptd/cmd.json +3 -0
  682. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/old-mongocryptd/encrypted-payload.json +3 -0
  683. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/old-mongocryptd/ismaster-to-mongocryptd.json +3 -0
  684. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/old-mongocryptd/mongocryptd-ismaster.json +12 -0
  685. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-cmd-schema/cmd-to-mongocryptd.json +20 -0
  686. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-cmd-schema/cmd.json +12 -0
  687. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-cmd-schema/encrypted-payload.json +12 -0
  688. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-cmd-schema/ismaster-to-mongocryptd.json +3 -0
  689. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-cmd-schema/mongocryptd-ismaster.json +12 -0
  690. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-cmd-schema/mongocryptd-reply.json +9 -0
  691. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-schema/cmd-to-mongocryptd.json +7 -0
  692. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-schema/cmd.json +3 -0
  693. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-schema/encrypted-payload.json +3 -0
  694. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-schema/ismaster-to-mongocryptd.json +3 -0
  695. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-schema/mongocryptd-ismaster.json +12 -0
  696. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-schema/mongocryptd-reply.json +9 -0
  697. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-schema/schema-map.json +5 -0
  698. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/without-schema/cmd-to-mongocryptd.json +5 -0
  699. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/without-schema/cmd.json +3 -0
  700. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/without-schema/encrypted-payload.json +3 -0
  701. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/without-schema/ismaster-to-mongocryptd.json +3 -0
  702. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/without-schema/mongocryptd-ismaster.json +12 -0
  703. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/without-schema/mongocryptd-reply.json +9 -0
  704. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-explain/with-csfle/cmd.json +8 -0
  705. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-explain/with-csfle/collinfo.json +7 -0
  706. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-explain/with-csfle/encrypted-payload.json +8 -0
  707. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-explain/with-mongocryptd/cmd-to-mongocryptd.json +10 -0
  708. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-explain/with-mongocryptd/cmd.json +8 -0
  709. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-explain/with-mongocryptd/collinfo.json +7 -0
  710. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-explain/with-mongocryptd/encrypted-payload.json +8 -0
  711. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-explain/with-mongocryptd/mongocryptd-reply.json +14 -0
  712. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-aead.cstructs +109 -0
  713. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create/cmd-to-mongocryptd.json +14 -0
  714. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create/cmd.json +3 -0
  715. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create/encrypted-field-config-map.json +8 -0
  716. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create/encrypted-payload.json +3 -0
  717. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create/ismaster-to-mongocryptd.json +3 -0
  718. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create/mongocryptd-ismaster.json +12 -0
  719. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create/mongocryptd-reply.json +9 -0
  720. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-decrypt-ieev/first-filter.json +21 -0
  721. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-decrypt-ieev/second-filter.json +21 -0
  722. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/cmd.json +6 -0
  723. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/collinfo.json +49 -0
  724. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/encrypted-field-config-map.json +47 -0
  725. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/encrypted-payload.json +91 -0
  726. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/mongocryptd-reply.json +66 -0
  727. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/cmd.json +6 -0
  728. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/collinfo.json +49 -0
  729. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/encrypted-field-config-map.json +47 -0
  730. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/encrypted-payload.json +98 -0
  731. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/mongocryptd-reply.json +72 -0
  732. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/cmd.json +8 -0
  733. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/collinfo.json +27 -0
  734. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/encrypted-payload.json +46 -0
  735. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-mongocryptd/cmd-to-mongocryptd.json +36 -0
  736. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-mongocryptd/cmd.json +8 -0
  737. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-mongocryptd/collinfo.json +27 -0
  738. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-mongocryptd/encrypted-payload.json +41 -0
  739. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-mongocryptd/mongocryptd-reply.json +47 -0
  740. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-contentionFactor1.json +8 -0
  741. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed.json +8 -0
  742. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-contentionFactor1.json +8 -0
  743. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-same-user-and-index-key.json +8 -0
  744. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed.json +8 -0
  745. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality/cmd.json +6 -0
  746. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality/encrypted-field-map.json +23 -0
  747. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality/encrypted-payload.json +41 -0
  748. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality/mongocryptd-reply.json +19 -0
  749. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-explicit/cmd-to-mongocryptd.json +24 -0
  750. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-explicit/cmd-to-mongod.json +24 -0
  751. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-explicit/cmd.json +11 -0
  752. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-explicit/reply-from-mongocryptd.json +27 -0
  753. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/README.md +2 -0
  754. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date/cmd.json +10 -0
  755. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date/encrypted-field-map.json +28 -0
  756. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date/encrypted-payload.json +42 -0
  757. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date/mongocryptd-reply.json +50 -0
  758. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128/cmd.json +6 -0
  759. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128/encrypted-field-map.json +28 -0
  760. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128/encrypted-payload.json +42 -0
  761. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128/mongocryptd-reply.json +50 -0
  762. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision/cmd.json +6 -0
  763. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision/encrypted-field-map.json +31 -0
  764. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision/encrypted-payload.json +51 -0
  765. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision/mongocryptd-reply.json +59 -0
  766. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double/cmd.json +8 -0
  767. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double/encrypted-field-map.json +28 -0
  768. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double/encrypted-payload.json +42 -0
  769. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double/mongocryptd-reply.json +50 -0
  770. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision/cmd.json +8 -0
  771. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision/encrypted-field-map.json +31 -0
  772. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision/encrypted-payload.json +45 -0
  773. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision/mongocryptd-reply.json +53 -0
  774. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32/cmd.json +8 -0
  775. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32/encrypted-field-map.json +28 -0
  776. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32/encrypted-payload.json +42 -0
  777. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32/mongocryptd-reply.json +50 -0
  778. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64/cmd.json +8 -0
  779. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64/encrypted-field-map.json +28 -0
  780. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64/encrypted-payload.json +42 -0
  781. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64/mongocryptd-reply.json +50 -0
  782. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/encrypted-payload.json +26 -0
  783. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/rangeopts.json +5 -0
  784. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/value-to-encrypt.json +20 -0
  785. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/encrypted-payload.json +26 -0
  786. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/rangeopts.json +14 -0
  787. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/value-to-encrypt.json +20 -0
  788. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/encrypted-payload.json +26 -0
  789. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/rangeopts.json +11 -0
  790. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/value-to-encrypt.json +20 -0
  791. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload.json +26 -0
  792. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/rangeopts.json +5 -0
  793. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/value-to-encrypt.json +20 -0
  794. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/encrypted-payload.json +16 -0
  795. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/rangeopts.json +11 -0
  796. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/value-to-encrypt.json +13 -0
  797. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert/cmd.json +9 -0
  798. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert/encrypted-field-map.json +23 -0
  799. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert/encrypted-payload.json +40 -0
  800. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert/mongocryptd-reply.json +50 -0
  801. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/README.md +2 -0
  802. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/RNG_DATA.h +67 -0
  803. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/cmd.json +13 -0
  804. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/encrypted-field-map.json +28 -0
  805. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/encrypted-payload.json +45 -0
  806. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/mongocryptd-reply.json +53 -0
  807. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/RNG_DATA.h +134 -0
  808. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/cmd.json +9 -0
  809. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/encrypted-field-map.json +28 -0
  810. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/encrypted-payload.json +45 -0
  811. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/mongocryptd-reply.json +53 -0
  812. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/RNG_DATA.h +73 -0
  813. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/cmd.json +9 -0
  814. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/encrypted-field-map.json +31 -0
  815. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/encrypted-payload.json +54 -0
  816. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/mongocryptd-reply.json +62 -0
  817. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/RNG_DATA.h +70 -0
  818. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/cmd.json +11 -0
  819. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/encrypted-field-map.json +28 -0
  820. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/encrypted-payload.json +45 -0
  821. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/mongocryptd-reply.json +53 -0
  822. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/RNG_DATA.h +21 -0
  823. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/cmd.json +11 -0
  824. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/encrypted-field-map.json +31 -0
  825. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/encrypted-payload.json +48 -0
  826. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/mongocryptd-reply.json +56 -0
  827. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/RNG_DATA.h +27 -0
  828. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/cmd.json +11 -0
  829. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/encrypted-field-map.json +28 -0
  830. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/encrypted-payload.json +45 -0
  831. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/mongocryptd-reply.json +53 -0
  832. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/RNG_DATA.h +67 -0
  833. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/cmd.json +11 -0
  834. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/encrypted-field-map.json +28 -0
  835. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/encrypted-payload.json +45 -0
  836. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/mongocryptd-reply.json +53 -0
  837. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/RNG_DATA.h +70 -0
  838. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/encrypted-payload.json +8 -0
  839. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/rangeopts.json +5 -0
  840. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/value-to-encrypt.json +5 -0
  841. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/RNG_DATA.h +21 -0
  842. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/encrypted-payload.json +8 -0
  843. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/rangeopts.json +14 -0
  844. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/value-to-encrypt.json +5 -0
  845. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/RNG_DATA.h +27 -0
  846. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/encrypted-payload.json +8 -0
  847. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/rangeopts.json +11 -0
  848. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/value-to-encrypt.json +5 -0
  849. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/RNG_DATA.h +70 -0
  850. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload.json +8 -0
  851. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/rangeopts.json +5 -0
  852. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/value-to-encrypt.json +5 -0
  853. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/RNG_DATA.h +17 -0
  854. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/encrypted-payload.json +8 -0
  855. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/rangeopts.json +11 -0
  856. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/value-to-encrypt.json +5 -0
  857. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed/cmd.json +9 -0
  858. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed/encrypted-field-map.json +23 -0
  859. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed/encrypted-payload.json +14 -0
  860. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed/mongocryptd-reply.json +46 -0
  861. data/ext/libmongocrypt/libmongocrypt/test/data/fle2.cstructs +33 -0
  862. data/ext/libmongocrypt/libmongocrypt/test/data/gcp-auth/decrypt-response.txt +5 -0
  863. data/ext/libmongocrypt/libmongocrypt/test/data/gcp-auth/encrypt-response.txt +5 -0
  864. data/ext/libmongocrypt/libmongocrypt/test/data/gcp-auth/oauth-response.txt +5 -0
  865. data/ext/libmongocrypt/libmongocrypt/test/data/kek-tests.json +169 -0
  866. data/ext/libmongocrypt/libmongocrypt/test/data/key-document-azure.json +33 -0
  867. data/ext/libmongocrypt/libmongocrypt/test/data/key-document-full.json +36 -0
  868. data/ext/libmongocrypt/libmongocrypt/test/data/key-document-gcp.json +35 -0
  869. data/ext/libmongocrypt/libmongocrypt/test/data/key-document-kmip.json +34 -0
  870. data/ext/libmongocrypt/libmongocrypt/test/data/key-document-local.json +18 -0
  871. data/ext/libmongocrypt/libmongocrypt/test/data/key-document-no-region.json +31 -0
  872. data/ext/libmongocrypt/libmongocrypt/test/data/key-document-with-alt-name-duplicate-id.json +36 -0
  873. data/ext/libmongocrypt/libmongocrypt/test/data/key-document-with-alt-name.json +33 -0
  874. data/ext/libmongocrypt/libmongocrypt/test/data/key-document-with-alt-name2.json +33 -0
  875. data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789012-aws-decrypt-reply.txt +11 -0
  876. data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789012-aws-document.json +32 -0
  877. data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789012-key-material.txt +1 -0
  878. data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789012-local-document.json +30 -0
  879. data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789013-aws-decrypt-reply.txt +11 -0
  880. data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789013-aws-document.json +32 -0
  881. data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789013-key-material.txt +1 -0
  882. data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789013-local-document.json +30 -0
  883. data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789014-key-material.txt +1 -0
  884. data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789014-local-document.json +30 -0
  885. data/ext/libmongocrypt/libmongocrypt/test/data/keys/ABCDEFAB123498761234123456789012-aws-decrypt-reply.txt +11 -0
  886. data/ext/libmongocrypt/libmongocrypt/test/data/keys/ABCDEFAB123498761234123456789012-aws-document.json +32 -0
  887. data/ext/libmongocrypt/libmongocrypt/test/data/keys/ABCDEFAB123498761234123456789012-key-material.txt +1 -0
  888. data/ext/libmongocrypt/libmongocrypt/test/data/keys/ABCDEFAB123498761234123456789012-local-document.json +30 -0
  889. data/ext/libmongocrypt/libmongocrypt/test/data/keys/README.md +21 -0
  890. data/ext/libmongocrypt/libmongocrypt/test/data/kms-encrypt-reply.txt +7 -0
  891. data/ext/libmongocrypt/libmongocrypt/test/data/kms-tests.json +297 -0
  892. data/ext/libmongocrypt/libmongocrypt/test/data/mongocryptd-cmd.json +26 -0
  893. data/ext/libmongocrypt/libmongocrypt/test/data/mongocryptd-reply-existing-ciphertext.json +24 -0
  894. data/ext/libmongocrypt/libmongocrypt/test/data/mongocryptd-reply-invalid.json +18 -0
  895. data/ext/libmongocrypt/libmongocrypt/test/data/mongocryptd-reply-key-alt-name.json +18 -0
  896. data/ext/libmongocrypt/libmongocrypt/test/data/mongocryptd-reply-key-alt-name2.json +18 -0
  897. data/ext/libmongocrypt/libmongocrypt/test/data/mongocryptd-reply-no-encryption-needed.json +7 -0
  898. data/ext/libmongocrypt/libmongocrypt/test/data/mongocryptd-reply-no-markings.json +7 -0
  899. data/ext/libmongocrypt/libmongocrypt/test/data/mongocryptd-reply-random.json +18 -0
  900. data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_decimal128.cstruct +14527 -0
  901. data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_double.cstruct +7959 -0
  902. data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_int32.cstruct +6906 -0
  903. data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_int64.cstruct +9429 -0
  904. data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_decimal128.cstruct +4565 -0
  905. data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_decimal128_precision.cstruct +312 -0
  906. data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_double.cstruct +3277 -0
  907. data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_double_precision.cstruct +369 -0
  908. data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_int32.cstruct +4612 -0
  909. data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_int64.cstruct +3398 -0
  910. data/ext/libmongocrypt/libmongocrypt/test/data/rmd/key-document-a.json +35 -0
  911. data/ext/libmongocrypt/libmongocrypt/test/data/rmd/key-document-b.json +37 -0
  912. data/ext/libmongocrypt/libmongocrypt/test/data/rmd/key-document-local.json +30 -0
  913. data/ext/libmongocrypt/libmongocrypt/test/data/rmd/kms-decrypt-reply-a.txt +6 -0
  914. data/ext/libmongocrypt/libmongocrypt/test/data/rmd/kms-decrypt-reply-b.txt +6 -0
  915. data/ext/libmongocrypt/libmongocrypt/test/data/rmd/kms-encrypt-reply-a.txt +7 -0
  916. data/ext/libmongocrypt/libmongocrypt/test/data/rmd/kms-encrypt-reply-b.txt +7 -0
  917. data/ext/libmongocrypt/libmongocrypt/test/data/schema-map.json +40 -0
  918. data/ext/libmongocrypt/libmongocrypt/test/data/schema.json +19 -0
  919. data/ext/libmongocrypt/libmongocrypt/test/example/README.md +5 -0
  920. data/ext/libmongocrypt/libmongocrypt/test/example/cmd.json +6 -0
  921. data/ext/libmongocrypt/libmongocrypt/test/example/collection-info.json +39 -0
  922. data/ext/libmongocrypt/libmongocrypt/test/example/encrypted-command.json +9 -0
  923. data/ext/libmongocrypt/libmongocrypt/test/example/key-document-custom-endpoint.json +34 -0
  924. data/ext/libmongocrypt/libmongocrypt/test/example/key-document.json +33 -0
  925. data/ext/libmongocrypt/libmongocrypt/test/example/kms-decrypt-reply.txt +6 -0
  926. data/ext/libmongocrypt/libmongocrypt/test/example/mongocryptd-reply.json +18 -0
  927. data/ext/libmongocrypt/libmongocrypt/test/example-no-bson.c +23 -0
  928. data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +368 -0
  929. data/ext/libmongocrypt/libmongocrypt/test/fuzz_kms.c +42 -0
  930. data/ext/libmongocrypt/libmongocrypt/test/test-dll.cpp +22 -0
  931. data/ext/libmongocrypt/libmongocrypt/test/test-gcp-auth.c +312 -0
  932. data/ext/libmongocrypt/libmongocrypt/test/test-mc-efc.c +104 -0
  933. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev.c +443 -0
  934. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup.c +184 -0
  935. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev.c +200 -0
  936. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-rfds.c +518 -0
  937. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-edge-generation.c +468 -0
  938. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +886 -0
  939. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +609 -0
  940. data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +174 -0
  941. data/ext/libmongocrypt/libmongocrypt/test/test-mc-reader.c +251 -0
  942. data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +245 -0
  943. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +1079 -0
  944. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.h +26 -0
  945. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert.h +218 -0
  946. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-buffer.c +266 -0
  947. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache-oauth.c +57 -0
  948. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache.c +264 -0
  949. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ciphertext.c +259 -0
  950. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-compact.c +478 -0
  951. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +917 -0
  952. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +177 -0
  953. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.h +110 -0
  954. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto.c +892 -0
  955. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-csfle-lib.c +208 -0
  956. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-decrypt.c +1134 -0
  957. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +5096 -0
  958. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +1061 -0
  959. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +1301 -0
  960. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +489 -0
  961. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-dll.c +48 -0
  962. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-endpoint.c +138 -0
  963. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kek.c +104 -0
  964. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-broker.c +1174 -0
  965. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-cache.c +475 -0
  966. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key.c +282 -0
  967. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-ctx.c +561 -0
  968. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-responses.c +206 -0
  969. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-local-kms.c +89 -0
  970. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-log.c +137 -0
  971. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-marking.c +738 -0
  972. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-status.c +88 -0
  973. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-traverse-util.c +548 -0
  974. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.c +105 -0
  975. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.h +42 -0
  976. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +1060 -0
  977. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +290 -0
  978. data/ext/libmongocrypt/libmongocrypt/test/util/HELP.autogen +102 -0
  979. data/ext/libmongocrypt/libmongocrypt/test/util/README.md +103 -0
  980. data/ext/libmongocrypt/libmongocrypt/test/util/csfle.c +612 -0
  981. data/ext/libmongocrypt/libmongocrypt/test/util/helpgen.py +7 -0
  982. data/ext/libmongocrypt/libmongocrypt/test/util/make_includes.py +845 -0
  983. data/ext/libmongocrypt/libmongocrypt/test/util/util.c +969 -0
  984. data/ext/libmongocrypt/libmongocrypt/test/util/util.h +96 -0
  985. data/ext/libmongocrypt/libmongocrypt/third-party/IntelRDFPMathLib20U2.tar.xz +0 -0
  986. data/lib/libmongocrypt_helper/version.rb +2 -2
  987. data/lib/libmongocrypt_helper.rb +13 -1
  988. data.tar.gz.sig +0 -0
  989. metadata +988 -6
  990. metadata.gz.sig +0 -0
  991. data/so/libmongocrypt.so +0 -0
@@ -0,0 +1,1850 @@
1
+ /*
2
+ * Copyright 2019-present MongoDB, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ /*
18
+ * Comments in this implementation refer to:
19
+ * [MCGREW] https://tools.ietf.org/html/draft-mcgrew-aead-aes-cbc-hmac-sha2-05
20
+ */
21
+
22
+ #include <bson/bson.h>
23
+
24
+ #include "mongocrypt-binary-private.h"
25
+ #include "mongocrypt-buffer-private.h"
26
+ #include "mongocrypt-crypto-private.h"
27
+ #include "mongocrypt-log-private.h"
28
+ #include "mongocrypt-private.h"
29
+ #include "mongocrypt-status-private.h"
30
+
31
+ #include <inttypes.h>
32
+
33
+ /* This function uses ECB callback to simulate CTR encrypt and decrypt
34
+ *
35
+ * Note: the same function performs both encrypt and decrypt using same ECB
36
+ * encryption function
37
+ */
38
+
39
+ static bool
40
+ _crypto_aes_256_ctr_encrypt_decrypt_via_ecb (
41
+ void *ctx,
42
+ mongocrypt_crypto_fn aes_256_ecb_encrypt,
43
+ aes_256_args_t args,
44
+ mongocrypt_status_t *status)
45
+ {
46
+ BSON_ASSERT (args.iv && args.iv->len);
47
+ BSON_ASSERT (args.in);
48
+ BSON_ASSERT (args.out);
49
+
50
+ if (args.out->len < args.in->len) {
51
+ CLIENT_ERR ("output buffer too small");
52
+ return false;
53
+ }
54
+
55
+ _mongocrypt_buffer_t ctr, tmp;
56
+ mongocrypt_binary_t key_bin, out_bin, in_bin, ctr_bin, tmp_bin;
57
+ bool ret;
58
+
59
+ _mongocrypt_buffer_to_binary (args.key, &key_bin);
60
+ _mongocrypt_buffer_init (&ctr);
61
+ _mongocrypt_buffer_copy_to (args.iv, &ctr);
62
+ _mongocrypt_buffer_to_binary (&ctr, &ctr_bin);
63
+ _mongocrypt_buffer_to_binary (args.out, &out_bin);
64
+ _mongocrypt_buffer_to_binary (args.in, &in_bin);
65
+ _mongocrypt_buffer_init_size (&tmp, args.iv->len);
66
+ _mongocrypt_buffer_to_binary (&tmp, &tmp_bin);
67
+
68
+ for (uint32_t ptr = 0; ptr < args.in->len;) {
69
+ /* Encrypt value in CTR buffer */
70
+ uint32_t bytes_written = 0;
71
+ if (!aes_256_ecb_encrypt (
72
+ ctx, &key_bin, NULL, &ctr_bin, &tmp_bin, &bytes_written, status)) {
73
+ ret = false;
74
+ goto cleanup;
75
+ }
76
+
77
+ if (bytes_written != tmp_bin.len) {
78
+ CLIENT_ERR ("encryption hook returned unexpected length");
79
+ ret = false;
80
+ goto cleanup;
81
+ }
82
+
83
+ /* XOR resulting stream with original data */
84
+ for (uint32_t i = 0; i < bytes_written && ptr < args.in->len;
85
+ i++, ptr++) {
86
+ out_bin.data[ptr] = in_bin.data[ptr] ^ tmp_bin.data[i];
87
+ }
88
+
89
+ /* Increment value in CTR buffer */
90
+ uint32_t carry = 1;
91
+ /* assert rather than return since this should never happen */
92
+ BSON_ASSERT (ctr_bin.len == 0u || ctr_bin.len - 1u <= INT_MAX);
93
+ for (int i = (int) ctr_bin.len - 1; i >= 0 && carry != 0; --i) {
94
+ uint32_t bpp = carry + ctr_bin.data[i];
95
+ carry = bpp >> 8;
96
+ ctr_bin.data[i] = bpp & 0xFF;
97
+ }
98
+ }
99
+
100
+ if (args.bytes_written) {
101
+ *args.bytes_written = args.in->len;
102
+ }
103
+
104
+ ret = true;
105
+
106
+ cleanup:
107
+ _mongocrypt_buffer_cleanup (&ctr);
108
+ _mongocrypt_buffer_cleanup (&tmp);
109
+ return ret;
110
+ }
111
+
112
+ /* Crypto primitives. These either call the native built in crypto primitives or
113
+ * user supplied hooks. */
114
+ static bool
115
+ _crypto_aes_256_cbc_encrypt (_mongocrypt_crypto_t *crypto, aes_256_args_t args)
116
+ {
117
+ mongocrypt_status_t *status = args.status;
118
+
119
+ BSON_ASSERT_PARAM (crypto);
120
+
121
+ BSON_ASSERT (args.key);
122
+ if (args.key->len != MONGOCRYPT_ENC_KEY_LEN) {
123
+ CLIENT_ERR ("invalid encryption key length");
124
+ return false;
125
+ }
126
+
127
+ BSON_ASSERT (args.iv);
128
+ if (args.iv->len != MONGOCRYPT_IV_LEN) {
129
+ CLIENT_ERR ("invalid iv length");
130
+ return false;
131
+ }
132
+
133
+ if (crypto->hooks_enabled) {
134
+ mongocrypt_binary_t enc_key_bin, iv_bin, out_bin, in_bin;
135
+ bool ret;
136
+
137
+ _mongocrypt_buffer_to_binary (args.key, &enc_key_bin);
138
+ _mongocrypt_buffer_to_binary (args.iv, &iv_bin);
139
+ _mongocrypt_buffer_to_binary (args.out, &out_bin);
140
+ _mongocrypt_buffer_to_binary (args.in, &in_bin);
141
+
142
+ ret = crypto->aes_256_cbc_encrypt (crypto->ctx,
143
+ &enc_key_bin,
144
+ &iv_bin,
145
+ &in_bin,
146
+ &out_bin,
147
+ args.bytes_written,
148
+ status);
149
+ return ret;
150
+ }
151
+ return _native_crypto_aes_256_cbc_encrypt (args);
152
+ }
153
+
154
+ static bool
155
+ _crypto_aes_256_ctr_encrypt (_mongocrypt_crypto_t *crypto, aes_256_args_t args)
156
+ {
157
+ mongocrypt_status_t *status = args.status;
158
+
159
+ BSON_ASSERT_PARAM (crypto);
160
+
161
+ BSON_ASSERT (args.key);
162
+ if (args.key->len != MONGOCRYPT_ENC_KEY_LEN) {
163
+ CLIENT_ERR ("invalid encryption key length");
164
+ return false;
165
+ }
166
+
167
+ BSON_ASSERT (args.iv);
168
+ if (args.iv->len != MONGOCRYPT_IV_LEN) {
169
+ CLIENT_ERR ("invalid iv length");
170
+ return false;
171
+ }
172
+
173
+ if (crypto->aes_256_ctr_encrypt) {
174
+ mongocrypt_binary_t enc_key_bin, iv_bin, out_bin, in_bin;
175
+ bool ret;
176
+
177
+ _mongocrypt_buffer_to_binary (args.key, &enc_key_bin);
178
+ _mongocrypt_buffer_to_binary (args.iv, &iv_bin);
179
+ _mongocrypt_buffer_to_binary (args.out, &out_bin);
180
+ _mongocrypt_buffer_to_binary (args.in, &in_bin);
181
+
182
+ ret = crypto->aes_256_ctr_encrypt (crypto->ctx,
183
+ &enc_key_bin,
184
+ &iv_bin,
185
+ &in_bin,
186
+ &out_bin,
187
+ args.bytes_written,
188
+ status);
189
+ return ret;
190
+ }
191
+
192
+ if (crypto->aes_256_ecb_encrypt) {
193
+ return _crypto_aes_256_ctr_encrypt_decrypt_via_ecb (
194
+ crypto->ctx, crypto->aes_256_ecb_encrypt, args, status);
195
+ }
196
+
197
+ return _native_crypto_aes_256_ctr_encrypt (args);
198
+ }
199
+
200
+ static bool
201
+ _crypto_aes_256_cbc_decrypt (_mongocrypt_crypto_t *crypto, aes_256_args_t args)
202
+ {
203
+ mongocrypt_status_t *status = args.status;
204
+
205
+ BSON_ASSERT_PARAM (crypto);
206
+
207
+ BSON_ASSERT (args.key);
208
+ if (args.key->len != MONGOCRYPT_ENC_KEY_LEN) {
209
+ CLIENT_ERR ("invalid encryption key length");
210
+ return false;
211
+ }
212
+
213
+ if (crypto->hooks_enabled) {
214
+ mongocrypt_binary_t enc_key_bin, iv_bin, out_bin, in_bin;
215
+ bool ret;
216
+
217
+ _mongocrypt_buffer_to_binary (args.key, &enc_key_bin);
218
+ _mongocrypt_buffer_to_binary (args.iv, &iv_bin);
219
+ _mongocrypt_buffer_to_binary (args.out, &out_bin);
220
+ _mongocrypt_buffer_to_binary (args.in, &in_bin);
221
+
222
+ ret = crypto->aes_256_cbc_decrypt (crypto->ctx,
223
+ &enc_key_bin,
224
+ &iv_bin,
225
+ &in_bin,
226
+ &out_bin,
227
+ args.bytes_written,
228
+ status);
229
+ return ret;
230
+ }
231
+ return _native_crypto_aes_256_cbc_decrypt (args);
232
+ }
233
+
234
+ static bool
235
+ _crypto_aes_256_ctr_decrypt (_mongocrypt_crypto_t *crypto, aes_256_args_t args)
236
+ {
237
+ mongocrypt_status_t *status = args.status;
238
+
239
+ BSON_ASSERT_PARAM (crypto);
240
+
241
+ BSON_ASSERT (args.key);
242
+ if (args.key->len != MONGOCRYPT_ENC_KEY_LEN) {
243
+ CLIENT_ERR ("invalid encryption key length");
244
+ return false;
245
+ }
246
+
247
+ if (crypto->aes_256_ctr_decrypt) {
248
+ mongocrypt_binary_t enc_key_bin, iv_bin, out_bin, in_bin;
249
+ bool ret;
250
+
251
+ _mongocrypt_buffer_to_binary (args.key, &enc_key_bin);
252
+ _mongocrypt_buffer_to_binary (args.iv, &iv_bin);
253
+ _mongocrypt_buffer_to_binary (args.out, &out_bin);
254
+ _mongocrypt_buffer_to_binary (args.in, &in_bin);
255
+
256
+ ret = crypto->aes_256_ctr_decrypt (crypto->ctx,
257
+ &enc_key_bin,
258
+ &iv_bin,
259
+ &in_bin,
260
+ &out_bin,
261
+ args.bytes_written,
262
+ status);
263
+ return ret;
264
+ }
265
+
266
+ if (crypto->aes_256_ecb_encrypt) {
267
+ return _crypto_aes_256_ctr_encrypt_decrypt_via_ecb (
268
+ crypto->ctx, crypto->aes_256_ecb_encrypt, args, status);
269
+ }
270
+
271
+ return _native_crypto_aes_256_ctr_decrypt (args);
272
+ }
273
+
274
+ static bool
275
+ _crypto_hmac_sha_512 (_mongocrypt_crypto_t *crypto,
276
+ const _mongocrypt_buffer_t *hmac_key,
277
+ const _mongocrypt_buffer_t *in,
278
+ _mongocrypt_buffer_t *out,
279
+ mongocrypt_status_t *status)
280
+ {
281
+ BSON_ASSERT_PARAM (crypto);
282
+ BSON_ASSERT_PARAM (hmac_key);
283
+ BSON_ASSERT_PARAM (in);
284
+ BSON_ASSERT_PARAM (out);
285
+
286
+ if (hmac_key->len != MONGOCRYPT_MAC_KEY_LEN) {
287
+ CLIENT_ERR ("invalid hmac key length");
288
+ return false;
289
+ }
290
+
291
+ if (out->len != MONGOCRYPT_HMAC_SHA512_LEN) {
292
+ CLIENT_ERR ("out does not contain %d bytes", MONGOCRYPT_HMAC_SHA512_LEN);
293
+ return false;
294
+ }
295
+
296
+ if (crypto->hooks_enabled) {
297
+ mongocrypt_binary_t hmac_key_bin, out_bin, in_bin;
298
+ bool ret;
299
+
300
+ _mongocrypt_buffer_to_binary (hmac_key, &hmac_key_bin);
301
+ _mongocrypt_buffer_to_binary (out, &out_bin);
302
+ _mongocrypt_buffer_to_binary (in, &in_bin);
303
+
304
+ ret = crypto->hmac_sha_512 (
305
+ crypto->ctx, &hmac_key_bin, &in_bin, &out_bin, status);
306
+ return ret;
307
+ }
308
+ return _native_crypto_hmac_sha_512 (hmac_key, in, out, status);
309
+ }
310
+
311
+
312
+ static bool
313
+ _crypto_random (_mongocrypt_crypto_t *crypto,
314
+ _mongocrypt_buffer_t *out,
315
+ uint32_t count,
316
+ mongocrypt_status_t *status)
317
+ {
318
+ BSON_ASSERT_PARAM (crypto);
319
+ BSON_ASSERT_PARAM (out);
320
+
321
+ if (out->len != count) {
322
+ CLIENT_ERR ("out does not contain %u bytes", count);
323
+ return false;
324
+ }
325
+
326
+ if (crypto->hooks_enabled) {
327
+ mongocrypt_binary_t out_bin;
328
+
329
+ _mongocrypt_buffer_to_binary (out, &out_bin);
330
+ return crypto->random (crypto->ctx, &out_bin, count, status);
331
+ }
332
+ return _native_crypto_random (out, count, status);
333
+ }
334
+
335
+
336
+ /*
337
+ * Secure memcmp copied from the C driver.
338
+ */
339
+ int
340
+ _mongocrypt_memequal (const void *const b1, const void *const b2, size_t len)
341
+ {
342
+ const unsigned char *p1 = b1, *p2 = b2;
343
+ int ret = 0;
344
+
345
+ BSON_ASSERT_PARAM (b1);
346
+ BSON_ASSERT_PARAM (b2);
347
+
348
+ for (; len > 0; len--) {
349
+ ret |= *p1++ ^ *p2++;
350
+ }
351
+
352
+ return ret;
353
+ }
354
+
355
+ /* ----------------------------------------------------------------------------
356
+ *
357
+ * _mongocrypt_calculate_ciphertext_len --
358
+ *
359
+ * For a given plaintext length, return the length of the ciphertext.
360
+ * This includes IV and HMAC.
361
+ *
362
+ * To compute that I'm following section 2.3 in [MCGREW]:
363
+ * L = 16 * ( floor(M / 16) + 2)
364
+ * This formula includes space for the IV, but not the sha512 HMAC.
365
+ * Add 32 for the sha512 HMAC.
366
+ *
367
+ * Parameters:
368
+ * @plaintext_len then length of the plaintext.
369
+ * @status set on error.
370
+ *
371
+ * Returns:
372
+ * The calculated length of the ciphertext.
373
+ *
374
+ * ----------------------------------------------------------------------------
375
+ */
376
+ uint32_t
377
+ _mongocrypt_calculate_ciphertext_len (uint32_t plaintext_len,
378
+ mongocrypt_status_t *status)
379
+ {
380
+ if ((plaintext_len / 16u) >
381
+ ((UINT32_MAX - (uint32_t) MONGOCRYPT_HMAC_LEN) / 16u) - 2u) {
382
+ CLIENT_ERR ("plaintext too long");
383
+ return 0;
384
+ }
385
+ return 16 * ((plaintext_len / 16) + 2) + MONGOCRYPT_HMAC_LEN;
386
+ }
387
+
388
+ uint32_t
389
+ _mongocrypt_fle2aead_calculate_ciphertext_len (uint32_t plaintext_len,
390
+ mongocrypt_status_t *status)
391
+ {
392
+ if (plaintext_len > UINT32_MAX - MONGOCRYPT_IV_LEN - MONGOCRYPT_HMAC_LEN) {
393
+ CLIENT_ERR ("plaintext too long");
394
+ return 0;
395
+ }
396
+ /* FLE2 AEAD uses CTR mode. CTR mode does not pad. */
397
+ return MONGOCRYPT_IV_LEN + plaintext_len + MONGOCRYPT_HMAC_LEN;
398
+ }
399
+
400
+ uint32_t
401
+ _mongocrypt_fle2_calculate_ciphertext_len (uint32_t plaintext_len,
402
+ mongocrypt_status_t *status)
403
+ {
404
+ if (plaintext_len > UINT32_MAX - MONGOCRYPT_IV_LEN) {
405
+ CLIENT_ERR ("plaintext too long");
406
+ return 0;
407
+ }
408
+ /* FLE2 AEAD uses CTR mode. CTR mode does not pad. */
409
+ return MONGOCRYPT_IV_LEN + plaintext_len;
410
+ }
411
+
412
+
413
+ /* ----------------------------------------------------------------------------
414
+ *
415
+ * _mongocrypt_calculate_plaintext_len --
416
+ *
417
+ * For a given ciphertext length, return the length of the plaintext.
418
+ * This excludes the IV and HMAC, but includes the padding.
419
+ *
420
+ * Parameters:
421
+ * @ciphertext_len then length of the ciphertext.
422
+ * @status set on error.
423
+ *
424
+ * Returns:
425
+ * The calculated length of the plaintext.
426
+ *
427
+ * ----------------------------------------------------------------------------
428
+ */
429
+ uint32_t
430
+ _mongocrypt_calculate_plaintext_len (uint32_t ciphertext_len,
431
+ mongocrypt_status_t *status)
432
+ {
433
+ if (ciphertext_len <
434
+ MONGOCRYPT_HMAC_LEN + MONGOCRYPT_IV_LEN + MONGOCRYPT_BLOCK_SIZE) {
435
+ CLIENT_ERR ("ciphertext too short");
436
+ return 0;
437
+ }
438
+ return ciphertext_len - (MONGOCRYPT_IV_LEN + MONGOCRYPT_HMAC_LEN);
439
+ }
440
+
441
+ uint32_t
442
+ _mongocrypt_fle2aead_calculate_plaintext_len (uint32_t ciphertext_len,
443
+ mongocrypt_status_t *status)
444
+ {
445
+ /* FLE2 AEAD uses CTR mode. CTR mode does not pad. */
446
+ if (ciphertext_len < MONGOCRYPT_IV_LEN + MONGOCRYPT_HMAC_LEN) {
447
+ CLIENT_ERR ("ciphertext too short");
448
+ return 0;
449
+ }
450
+ return ciphertext_len - MONGOCRYPT_IV_LEN - MONGOCRYPT_HMAC_LEN;
451
+ }
452
+
453
+ uint32_t
454
+ _mongocrypt_fle2_calculate_plaintext_len (uint32_t ciphertext_len,
455
+ mongocrypt_status_t *status)
456
+ {
457
+ /* FLE2 AEAD uses CTR mode. CTR mode does not pad. */
458
+ if (ciphertext_len < MONGOCRYPT_IV_LEN) {
459
+ CLIENT_ERR ("ciphertext too short");
460
+ return 0;
461
+ }
462
+ return ciphertext_len - MONGOCRYPT_IV_LEN;
463
+ }
464
+
465
+ /* ----------------------------------------------------------------------------
466
+ *
467
+ * _aes256_cbc_encrypt --
468
+ *
469
+ * Encrypts using AES256 CBC using a secret key and a known IV.
470
+ *
471
+ * Parameters:
472
+ * @iv a 16 byte IV.
473
+ * @enc_key a 32 byte key.
474
+ * @plaintext the plaintext to encrypt.
475
+ * @ciphertext the resulting ciphertext.
476
+ * @bytes_written a location for the resulting number of bytes written into
477
+ * ciphertext->data.
478
+ * @status set on error.
479
+ *
480
+ * Returns:
481
+ * True on success. On error, sets @status and returns false.
482
+ *
483
+ * Preconditions:
484
+ * 1. ciphertext->data has been pre-allocated with enough space for the
485
+ * resulting ciphertext.
486
+ *
487
+ * Postconditions:
488
+ * 1. bytes_written is set to the length of the written ciphertext. This
489
+ * is the same as
490
+ * _mongocrypt_calculate_ciphertext_len (plaintext->len, status).
491
+ *
492
+ * ----------------------------------------------------------------------------
493
+ */
494
+ static bool
495
+ _encrypt_step (_mongocrypt_crypto_t *crypto,
496
+ const _mongocrypt_buffer_t *iv,
497
+ const _mongocrypt_buffer_t *enc_key,
498
+ const _mongocrypt_buffer_t *plaintext,
499
+ _mongocrypt_buffer_t *ciphertext,
500
+ uint32_t *bytes_written,
501
+ mongocrypt_status_t *status)
502
+ {
503
+ uint32_t unaligned;
504
+ uint32_t padding_byte;
505
+ _mongocrypt_buffer_t intermediates[2];
506
+ _mongocrypt_buffer_t to_encrypt;
507
+ uint8_t final_block_storage[MONGOCRYPT_BLOCK_SIZE];
508
+ bool ret = false;
509
+
510
+ BSON_ASSERT_PARAM (crypto);
511
+ BSON_ASSERT_PARAM (iv);
512
+ BSON_ASSERT_PARAM (enc_key);
513
+ BSON_ASSERT_PARAM (plaintext);
514
+ BSON_ASSERT_PARAM (ciphertext);
515
+
516
+ _mongocrypt_buffer_init (&to_encrypt);
517
+
518
+ BSON_ASSERT_PARAM (bytes_written);
519
+ *bytes_written = 0;
520
+
521
+ if (MONGOCRYPT_IV_LEN != iv->len) {
522
+ CLIENT_ERR ("IV should have length %d, but has length %d",
523
+ MONGOCRYPT_IV_LEN,
524
+ iv->len);
525
+ goto done;
526
+ }
527
+
528
+ if (MONGOCRYPT_ENC_KEY_LEN != enc_key->len) {
529
+ CLIENT_ERR ("Encryption key should have length %d, but has length %d",
530
+ MONGOCRYPT_ENC_KEY_LEN,
531
+ enc_key->len);
532
+ goto done;
533
+ }
534
+
535
+ /* calculate how many extra bytes there are after a block boundary */
536
+ unaligned = plaintext->len % MONGOCRYPT_BLOCK_SIZE;
537
+
538
+ /* Some crypto providers disallow variable length inputs, and require
539
+ * the input to be a multiple of the block size. So add everything up
540
+ * to but excluding the last block if not block aligned, then add
541
+ * the last block with padding. */
542
+ _mongocrypt_buffer_init (&intermediates[0]);
543
+ _mongocrypt_buffer_init (&intermediates[1]);
544
+ intermediates[0].data = (uint8_t *) plaintext->data;
545
+ /* don't check plaintext->len, as the above modulo operation guarantees
546
+ * that unaligned will be smaller */
547
+ intermediates[0].len = plaintext->len - unaligned;
548
+ intermediates[1].data = final_block_storage;
549
+ intermediates[1].len = sizeof (final_block_storage);
550
+
551
+ /* [MCGREW]: "Prior to CBC encryption, the plaintext P is padded by appending
552
+ * a padding string PS to that data, to ensure that len(P || PS) is a
553
+ * multiple of 128". This is also known as PKCS #7 padding. */
554
+ if (unaligned) {
555
+ /* Copy the unaligned bytes. */
556
+ memcpy (intermediates[1].data,
557
+ plaintext->data + (plaintext->len - unaligned),
558
+ unaligned);
559
+ /* Fill the rest with the padding byte. */
560
+ BSON_ASSERT (MONGOCRYPT_BLOCK_SIZE >= unaligned);
561
+ padding_byte = MONGOCRYPT_BLOCK_SIZE - unaligned;
562
+ /* it is certain that padding_byte is in range for a cast to int */
563
+ memset (
564
+ intermediates[1].data + unaligned, (int) padding_byte, padding_byte);
565
+ } else {
566
+ /* Fill the rest with the padding byte. */
567
+ padding_byte = MONGOCRYPT_BLOCK_SIZE;
568
+ memset (intermediates[1].data, (int) padding_byte, padding_byte);
569
+ }
570
+
571
+ if (!_mongocrypt_buffer_concat (&to_encrypt, intermediates, 2)) {
572
+ CLIENT_ERR ("failed to allocate buffer");
573
+ goto done;
574
+ }
575
+
576
+ if (!_crypto_aes_256_cbc_encrypt (
577
+ crypto,
578
+ (aes_256_args_t){.key = enc_key,
579
+ .iv = iv,
580
+ .in = &to_encrypt,
581
+ .out = ciphertext,
582
+ .bytes_written = bytes_written,
583
+ .status = status})) {
584
+ goto done;
585
+ }
586
+
587
+
588
+ if (*bytes_written % MONGOCRYPT_BLOCK_SIZE != 0) {
589
+ CLIENT_ERR ("encryption failure, wrote %d bytes, not a multiple of %d",
590
+ *bytes_written,
591
+ MONGOCRYPT_BLOCK_SIZE);
592
+ goto done;
593
+ }
594
+
595
+ ret = true;
596
+ done:
597
+ _mongocrypt_buffer_cleanup (&to_encrypt);
598
+ return ret;
599
+ }
600
+
601
+
602
+ /* ----------------------------------------------------------------------------
603
+ *
604
+ * _hmac_sha512 --
605
+ *
606
+ * Compute the SHA512 HMAC with a secret key.
607
+ *
608
+ * Parameters:
609
+ * @mac_key a 32 byte key.
610
+ * @associated_data associated data to add into the HMAC. This may be
611
+ * an empty buffer.
612
+ * @ciphertext the ciphertext to add into the HMAC.
613
+ * @out a location for the resulting HMAC tag.
614
+ * @status set on error.
615
+ *
616
+ * Returns:
617
+ * True on success. On error, sets @status and returns false.
618
+ *
619
+ * Preconditions:
620
+ * 1. out->data has been pre-allocated with at least 64 bytes.
621
+ *
622
+ * Postconditions:
623
+ * 1. out->data will have a 64 byte tag appended.
624
+ *
625
+ * ----------------------------------------------------------------------------
626
+ */
627
+ static bool
628
+ _hmac_step (_mongocrypt_crypto_t *crypto,
629
+ const _mongocrypt_buffer_t *mac_key,
630
+ const _mongocrypt_buffer_t *associated_data,
631
+ const _mongocrypt_buffer_t *ciphertext,
632
+ _mongocrypt_buffer_t *out,
633
+ mongocrypt_status_t *status)
634
+ {
635
+ _mongocrypt_buffer_t intermediates[3];
636
+ _mongocrypt_buffer_t to_hmac;
637
+ uint64_t associated_data_len_be;
638
+ uint8_t tag_storage[64];
639
+ _mongocrypt_buffer_t tag;
640
+ bool ret = false;
641
+
642
+ BSON_ASSERT_PARAM (crypto);
643
+ BSON_ASSERT_PARAM (mac_key);
644
+ BSON_ASSERT_PARAM (associated_data);
645
+ BSON_ASSERT_PARAM (ciphertext);
646
+ BSON_ASSERT_PARAM (out);
647
+
648
+ _mongocrypt_buffer_init (&to_hmac);
649
+
650
+ if (MONGOCRYPT_MAC_KEY_LEN != mac_key->len) {
651
+ CLIENT_ERR ("HMAC key wrong length: %d", mac_key->len);
652
+ goto done;
653
+ }
654
+
655
+ if (out->len != MONGOCRYPT_HMAC_LEN) {
656
+ CLIENT_ERR ("out wrong length: %d", out->len);
657
+ goto done;
658
+ }
659
+
660
+ /* [MCGREW]:
661
+ * """
662
+ * 4. The octet string AL is equal to the number of bits in A expressed as a
663
+ * 64-bit unsigned integer in network byte order.
664
+ * 5. A message authentication tag T is computed by applying HMAC [RFC2104]
665
+ * to the following data, in order:
666
+ * the associated data A,
667
+ * the ciphertext S computed in the previous step, and
668
+ * the octet string AL defined above.
669
+ * """
670
+ */
671
+
672
+ /* Add associated data. */
673
+ _mongocrypt_buffer_init (&intermediates[0]);
674
+ _mongocrypt_buffer_init (&intermediates[1]);
675
+ _mongocrypt_buffer_init (&intermediates[2]);
676
+ intermediates[0].data = associated_data->data;
677
+ intermediates[0].len = associated_data->len;
678
+ /* Add ciphertext. */
679
+ intermediates[1].data = ciphertext->data;
680
+ intermediates[1].len = ciphertext->len;
681
+ /* Add associated data length in bits. */
682
+ /* multiplying a uint32_t by 8 won't bring it anywhere close to UINT64_MAX */
683
+ associated_data_len_be = 8 * (uint64_t) associated_data->len;
684
+ associated_data_len_be = BSON_UINT64_TO_BE (associated_data_len_be);
685
+ intermediates[2].data = (uint8_t *) &associated_data_len_be;
686
+ intermediates[2].len = sizeof (uint64_t);
687
+ tag.data = tag_storage;
688
+ tag.len = sizeof (tag_storage);
689
+
690
+
691
+ if (!_mongocrypt_buffer_concat (&to_hmac, intermediates, 3)) {
692
+ CLIENT_ERR ("failed to allocate buffer");
693
+ goto done;
694
+ }
695
+ if (!_crypto_hmac_sha_512 (crypto, mac_key, &to_hmac, &tag, status)) {
696
+ goto done;
697
+ }
698
+
699
+ /* [MCGREW 2.7] "The HMAC-SHA-512 value is truncated to T_LEN=32 octets" */
700
+ memcpy (out->data, tag.data, MONGOCRYPT_HMAC_LEN);
701
+ ret = true;
702
+ done:
703
+ _mongocrypt_buffer_cleanup (&to_hmac);
704
+ return ret;
705
+ }
706
+
707
+ /* ----------------------------------------------------------------------------
708
+ *
709
+ * _mongocrypt_do_encryption --
710
+ *
711
+ * Defer encryption to whichever crypto library libmongocrypt is using.
712
+ *
713
+ * Parameters:
714
+ * @iv a 16 byte IV.
715
+ * @associated_data associated data for the HMAC. May be NULL.
716
+ * @key a 96 byte key.
717
+ * @plaintext the plaintext to encrypt.
718
+ * @ciphertext a location for the resulting ciphertext and HMAC tag.
719
+ * @bytes_written a location for the resulting bytes written.
720
+ * @status set on error.
721
+ *
722
+ * Returns:
723
+ * True on success. On error, sets @status and returns false.
724
+ *
725
+ * Preconditions:
726
+ * 1. ciphertext->data has been pre-allocated with enough space for the
727
+ * resulting ciphertext. Use _mongocrypt_calculate_ciphertext_len.
728
+ *
729
+ * Postconditions:
730
+ * 1. bytes_written is set to the length of the written ciphertext. This
731
+ * is the same as
732
+ * _mongocrypt_calculate_ciphertext_len (plaintext->len, status).
733
+ *
734
+ * ----------------------------------------------------------------------------
735
+ */
736
+ bool
737
+ _mongocrypt_do_encryption (_mongocrypt_crypto_t *crypto,
738
+ const _mongocrypt_buffer_t *iv,
739
+ const _mongocrypt_buffer_t *associated_data,
740
+ const _mongocrypt_buffer_t *key,
741
+ const _mongocrypt_buffer_t *plaintext,
742
+ _mongocrypt_buffer_t *ciphertext,
743
+ uint32_t *bytes_written,
744
+ mongocrypt_status_t *status)
745
+ {
746
+ _mongocrypt_buffer_t mac_key = {0}, enc_key = {0}, intermediate = {0},
747
+ intermediate_hmac = {0}, empty_buffer = {0};
748
+ uint32_t intermediate_bytes_written = 0;
749
+
750
+ BSON_ASSERT_PARAM (crypto);
751
+ BSON_ASSERT_PARAM (iv);
752
+ /* associated_data is checked at the point it is used, so it can be NULL */
753
+ BSON_ASSERT_PARAM (key);
754
+ BSON_ASSERT_PARAM (plaintext);
755
+ BSON_ASSERT_PARAM (ciphertext);
756
+
757
+ memset (ciphertext->data, 0, ciphertext->len);
758
+
759
+ if (ciphertext->len !=
760
+ _mongocrypt_calculate_ciphertext_len (plaintext->len, status)) {
761
+ CLIENT_ERR (
762
+ "output ciphertext should have been allocated with %d bytes",
763
+ _mongocrypt_calculate_ciphertext_len (plaintext->len, status));
764
+ return false;
765
+ }
766
+
767
+ BSON_ASSERT_PARAM (bytes_written);
768
+ *bytes_written = 0;
769
+
770
+ if (MONGOCRYPT_IV_LEN != iv->len) {
771
+ CLIENT_ERR ("IV should have length %d, but has length %d",
772
+ MONGOCRYPT_IV_LEN,
773
+ iv->len);
774
+ return false;
775
+ }
776
+ if (MONGOCRYPT_KEY_LEN != key->len) {
777
+ CLIENT_ERR ("key should have length %d, but has length %d",
778
+ MONGOCRYPT_KEY_LEN,
779
+ key->len);
780
+ return false;
781
+ }
782
+
783
+ intermediate.len = ciphertext->len;
784
+ intermediate.data = ciphertext->data;
785
+
786
+ /* [MCGREW]: Step 1. "MAC_KEY consists of the initial MAC_KEY_LEN octets of
787
+ * K, in order. ENC_KEY consists of the final ENC_KEY_LEN octets of K, in
788
+ * order." */
789
+ mac_key.data = (uint8_t *) key->data;
790
+ mac_key.len = MONGOCRYPT_MAC_KEY_LEN;
791
+ enc_key.data = (uint8_t *) key->data + MONGOCRYPT_MAC_KEY_LEN;
792
+ enc_key.len = MONGOCRYPT_ENC_KEY_LEN;
793
+
794
+ /* Prepend the IV. */
795
+ memcpy (intermediate.data, iv->data, iv->len);
796
+ intermediate.data += iv->len;
797
+ BSON_ASSERT (intermediate.len >= iv->len);
798
+ intermediate.len -= iv->len;
799
+ BSON_ASSERT (*bytes_written <= UINT32_MAX - iv->len);
800
+ *bytes_written += iv->len;
801
+
802
+ /* [MCGREW]: Steps 2 & 3. */
803
+ if (!_encrypt_step (crypto,
804
+ iv,
805
+ &enc_key,
806
+ plaintext,
807
+ &intermediate,
808
+ &intermediate_bytes_written,
809
+ status)) {
810
+ return false;
811
+ }
812
+
813
+ BSON_ASSERT (*bytes_written <= UINT32_MAX - intermediate_bytes_written);
814
+ *bytes_written += intermediate_bytes_written;
815
+
816
+ /* Append the HMAC tag. */
817
+ intermediate_hmac.data = ciphertext->data + *bytes_written;
818
+ intermediate_hmac.len = MONGOCRYPT_HMAC_LEN;
819
+
820
+ intermediate.data = ciphertext->data;
821
+ intermediate.len = *bytes_written;
822
+
823
+ /* [MCGREW]: Steps 4 & 5, compute the HMAC. */
824
+ if (!_hmac_step (crypto,
825
+ &mac_key,
826
+ associated_data ? associated_data : &empty_buffer,
827
+ &intermediate,
828
+ &intermediate_hmac,
829
+ status)) {
830
+ return false;
831
+ }
832
+
833
+ *bytes_written += MONGOCRYPT_HMAC_LEN;
834
+ return true;
835
+ }
836
+
837
+
838
+ /* ----------------------------------------------------------------------------
839
+ *
840
+ * _aes256_cbc_decrypt --
841
+ *
842
+ * Decrypts using AES256 CBC using a secret key and a known IV.
843
+ *
844
+ * Parameters:
845
+ * @enc_key a 32 byte key.
846
+ * @ciphertext the ciphertext to decrypt.
847
+ * @plaintext the resulting plaintext.
848
+ * @bytes_written a location for the resulting number of bytes written into
849
+ * plaintext->data.
850
+ * @status set on error.
851
+ *
852
+ * Returns:
853
+ * True on success. On error, sets @status and returns false.
854
+ *
855
+ * Preconditions:
856
+ * 1. plaintext->data has been pre-allocated with enough space for the
857
+ * resulting plaintext.
858
+ *
859
+ * Postconditions:
860
+ * 1. bytes_written is set to the length of the written plaintext, excluding
861
+ * padding. This may be less than
862
+ * _mongocrypt_calculate_plaintext_len (ciphertext->len, status).
863
+ *
864
+ * ----------------------------------------------------------------------------
865
+ */
866
+ static bool
867
+ _decrypt_step (_mongocrypt_crypto_t *crypto,
868
+ const _mongocrypt_buffer_t *iv,
869
+ const _mongocrypt_buffer_t *enc_key,
870
+ const _mongocrypt_buffer_t *ciphertext,
871
+ _mongocrypt_buffer_t *plaintext,
872
+ uint32_t *bytes_written,
873
+ mongocrypt_status_t *status)
874
+ {
875
+ uint8_t padding_byte;
876
+
877
+ BSON_ASSERT_PARAM (crypto);
878
+ BSON_ASSERT_PARAM (iv);
879
+ BSON_ASSERT_PARAM (enc_key);
880
+ BSON_ASSERT_PARAM (ciphertext);
881
+ BSON_ASSERT_PARAM (plaintext);
882
+
883
+ BSON_ASSERT_PARAM (bytes_written);
884
+ *bytes_written = 0;
885
+
886
+ if (MONGOCRYPT_IV_LEN != iv->len) {
887
+ CLIENT_ERR ("IV should have length %d, but has length %d",
888
+ MONGOCRYPT_IV_LEN,
889
+ iv->len);
890
+ return false;
891
+ }
892
+ if (MONGOCRYPT_ENC_KEY_LEN != enc_key->len) {
893
+ CLIENT_ERR ("encryption key should have length %d, but has length %d",
894
+ MONGOCRYPT_ENC_KEY_LEN,
895
+ enc_key->len);
896
+ return false;
897
+ }
898
+
899
+
900
+ if (ciphertext->len % MONGOCRYPT_BLOCK_SIZE > 0) {
901
+ CLIENT_ERR ("error, ciphertext length is not a multiple of block size");
902
+ return false;
903
+ }
904
+
905
+ if (!_crypto_aes_256_cbc_decrypt (
906
+ crypto,
907
+ (aes_256_args_t){.iv = iv,
908
+ .key = enc_key,
909
+ .in = ciphertext,
910
+ .out = plaintext,
911
+ .bytes_written = bytes_written,
912
+ .status = status})) {
913
+ return false;
914
+ }
915
+
916
+ BSON_ASSERT (*bytes_written > 0);
917
+ padding_byte = plaintext->data[*bytes_written - 1];
918
+ if (padding_byte > 16) {
919
+ CLIENT_ERR ("error, ciphertext malformed padding");
920
+ return false;
921
+ }
922
+ *bytes_written -= padding_byte;
923
+ return true;
924
+ }
925
+
926
+
927
+ /* ----------------------------------------------------------------------------
928
+ *
929
+ * _mongocrypt_do_decryption --
930
+ *
931
+ * Defer decryption to whichever crypto library libmongocrypt is using.
932
+ *
933
+ * Parameters:
934
+ * @associated_data associated data for the HMAC. May be NULL.
935
+ * @key a 96 byte key.
936
+ * @ciphertext the ciphertext to decrypt. This contains the IV prepended.
937
+ * @plaintext a location for the resulting plaintext.
938
+ * @bytes_written a location for the resulting bytes written.
939
+ * @status set on error.
940
+ *
941
+ * Returns:
942
+ * True on success. On error, sets @status and returns false.
943
+ *
944
+ * Preconditions:
945
+ * 1. plaintext->data has been pre-allocated with enough space for the
946
+ * resulting plaintext and padding. See _mongocrypt_calculate_plaintext_len.
947
+ *
948
+ * Postconditions:
949
+ * 1. bytes_written is set to the length of the written plaintext, excluding
950
+ * padding. This may be less than
951
+ * _mongocrypt_calculate_plaintext_len (ciphertext->len, status).
952
+ *
953
+ * ----------------------------------------------------------------------------
954
+ */
955
+ bool
956
+ _mongocrypt_do_decryption (_mongocrypt_crypto_t *crypto,
957
+ const _mongocrypt_buffer_t *associated_data,
958
+ const _mongocrypt_buffer_t *key,
959
+ const _mongocrypt_buffer_t *ciphertext,
960
+ _mongocrypt_buffer_t *plaintext,
961
+ uint32_t *bytes_written,
962
+ mongocrypt_status_t *status)
963
+ {
964
+ bool ret = false;
965
+ _mongocrypt_buffer_t mac_key = {0}, enc_key = {0}, intermediate = {0},
966
+ hmac_tag = {0}, iv = {0}, empty_buffer = {0};
967
+ uint8_t hmac_tag_storage[MONGOCRYPT_HMAC_LEN];
968
+
969
+ BSON_ASSERT_PARAM (crypto);
970
+ /* associated_data is checked at the point it is used, so it can be NULL */
971
+ BSON_ASSERT_PARAM (key);
972
+ BSON_ASSERT_PARAM (ciphertext);
973
+ BSON_ASSERT_PARAM (plaintext);
974
+ BSON_ASSERT_PARAM (bytes_written);
975
+
976
+ if (plaintext->len !=
977
+ _mongocrypt_calculate_plaintext_len (ciphertext->len, status)) {
978
+ CLIENT_ERR ("output plaintext should have been allocated with %d bytes, "
979
+ "but has: %d",
980
+ _mongocrypt_calculate_plaintext_len (ciphertext->len, status),
981
+ plaintext->len);
982
+ return false;
983
+ }
984
+
985
+ if (MONGOCRYPT_KEY_LEN != key->len) {
986
+ CLIENT_ERR ("key should have length %d, but has length %d",
987
+ MONGOCRYPT_KEY_LEN,
988
+ key->len);
989
+ return false;
990
+ }
991
+
992
+ if (ciphertext->len <
993
+ MONGOCRYPT_HMAC_LEN + MONGOCRYPT_IV_LEN + MONGOCRYPT_BLOCK_SIZE) {
994
+ CLIENT_ERR ("corrupt ciphertext - must be > %d bytes",
995
+ MONGOCRYPT_HMAC_LEN + MONGOCRYPT_IV_LEN +
996
+ MONGOCRYPT_BLOCK_SIZE);
997
+ goto done;
998
+ }
999
+
1000
+ mac_key.data = (uint8_t *) key->data;
1001
+ mac_key.len = MONGOCRYPT_MAC_KEY_LEN;
1002
+ enc_key.data = (uint8_t *) key->data + MONGOCRYPT_MAC_KEY_LEN;
1003
+ enc_key.len = MONGOCRYPT_ENC_KEY_LEN;
1004
+
1005
+ iv.data = ciphertext->data;
1006
+ iv.len = MONGOCRYPT_IV_LEN;
1007
+
1008
+ intermediate.data = (uint8_t *) ciphertext->data;
1009
+ intermediate.len = ciphertext->len - MONGOCRYPT_HMAC_LEN;
1010
+
1011
+ hmac_tag.data = hmac_tag_storage;
1012
+ hmac_tag.len = MONGOCRYPT_HMAC_LEN;
1013
+
1014
+ /* [MCGREW 2.2]: Step 3: HMAC check. */
1015
+ if (!_hmac_step (crypto,
1016
+ &mac_key,
1017
+ associated_data ? associated_data : &empty_buffer,
1018
+ &intermediate,
1019
+ &hmac_tag,
1020
+ status)) {
1021
+ goto done;
1022
+ }
1023
+
1024
+ /* [MCGREW] "using a comparison routine that takes constant time". */
1025
+ if (0 != _mongocrypt_memequal (hmac_tag.data,
1026
+ ciphertext->data +
1027
+ (ciphertext->len - MONGOCRYPT_HMAC_LEN),
1028
+ MONGOCRYPT_HMAC_LEN)) {
1029
+ CLIENT_ERR ("HMAC validation failure");
1030
+ goto done;
1031
+ }
1032
+
1033
+ /* Decrypt data excluding IV + HMAC. */
1034
+ intermediate.data = (uint8_t *) ciphertext->data + MONGOCRYPT_IV_LEN;
1035
+ intermediate.len =
1036
+ ciphertext->len - (MONGOCRYPT_IV_LEN + MONGOCRYPT_HMAC_LEN);
1037
+
1038
+ if (!_decrypt_step (crypto,
1039
+ &iv,
1040
+ &enc_key,
1041
+ &intermediate,
1042
+ plaintext,
1043
+ bytes_written,
1044
+ status)) {
1045
+ goto done;
1046
+ }
1047
+
1048
+ ret = true;
1049
+ done:
1050
+ return ret;
1051
+ }
1052
+
1053
+
1054
+ /* ----------------------------------------------------------------------------
1055
+ *
1056
+ * _mongocrypt_random --
1057
+ *
1058
+ * Generates a string of random bytes.
1059
+ *
1060
+ * Parameters:
1061
+ * @out an output buffer that has been pre-allocated.
1062
+ * @status set on error.
1063
+ * @count the size of the random string in bytes.
1064
+ *
1065
+ * Returns:
1066
+ * True on success. On error, sets @status and returns false.
1067
+ *
1068
+ * Preconditions:
1069
+ * 1. out has been pre-allocated with at least 'count' bytes of space.
1070
+ *
1071
+ * ----------------------------------------------------------------------------
1072
+ */
1073
+ bool
1074
+ _mongocrypt_random (_mongocrypt_crypto_t *crypto,
1075
+ _mongocrypt_buffer_t *out,
1076
+ uint32_t count,
1077
+ mongocrypt_status_t *status)
1078
+ {
1079
+ BSON_ASSERT_PARAM (crypto);
1080
+ BSON_ASSERT_PARAM (out);
1081
+
1082
+ if (count != out->len) {
1083
+ CLIENT_ERR (
1084
+ "out should have length %d, but has length %d", count, out->len);
1085
+ return false;
1086
+ }
1087
+
1088
+ return _crypto_random (crypto, out, count, status);
1089
+ }
1090
+
1091
+
1092
+ /* ----------------------------------------------------------------------------
1093
+ *
1094
+ * _mongocrypt_calculate_deterministic_iv --
1095
+ *
1096
+ * Compute the IV for deterministic encryption from the plaintext and IV
1097
+ * key by using HMAC function.
1098
+ *
1099
+ * Parameters:
1100
+ * @key the 96 byte key. The last 32 represent the IV key.
1101
+ * @plaintext the plaintext to be encrypted.
1102
+ * @associated_data associated data to include in the HMAC.
1103
+ * @out an output buffer that has been pre-allocated.
1104
+ * @status set on error.
1105
+ *
1106
+ * Returns:
1107
+ * True on success. On error, sets @status and returns false.
1108
+ *
1109
+ * Preconditions:
1110
+ * 1. out has been pre-allocated with at least MONGOCRYPT_IV_LEN bytes.
1111
+ *
1112
+ * ----------------------------------------------------------------------------
1113
+ */
1114
+ bool
1115
+ _mongocrypt_calculate_deterministic_iv (
1116
+ _mongocrypt_crypto_t *crypto,
1117
+ const _mongocrypt_buffer_t *key,
1118
+ const _mongocrypt_buffer_t *plaintext,
1119
+ const _mongocrypt_buffer_t *associated_data,
1120
+ _mongocrypt_buffer_t *out,
1121
+ mongocrypt_status_t *status)
1122
+ {
1123
+ _mongocrypt_buffer_t intermediates[3];
1124
+ _mongocrypt_buffer_t to_hmac;
1125
+ _mongocrypt_buffer_t iv_key;
1126
+ uint64_t associated_data_len_be;
1127
+ uint8_t tag_storage[64];
1128
+ _mongocrypt_buffer_t tag;
1129
+ bool ret = false;
1130
+
1131
+ _mongocrypt_buffer_init (&to_hmac);
1132
+
1133
+ BSON_ASSERT_PARAM (crypto);
1134
+ BSON_ASSERT_PARAM (key);
1135
+ BSON_ASSERT_PARAM (plaintext);
1136
+ BSON_ASSERT_PARAM (associated_data);
1137
+ BSON_ASSERT_PARAM (out);
1138
+
1139
+ if (MONGOCRYPT_KEY_LEN != key->len) {
1140
+ CLIENT_ERR ("key should have length %d, but has length %d\n",
1141
+ MONGOCRYPT_KEY_LEN,
1142
+ key->len);
1143
+ goto done;
1144
+ }
1145
+ if (MONGOCRYPT_IV_LEN != out->len) {
1146
+ CLIENT_ERR ("out should have length %d, but has length %d\n",
1147
+ MONGOCRYPT_IV_LEN,
1148
+ out->len);
1149
+ goto done;
1150
+ }
1151
+
1152
+ _mongocrypt_buffer_init (&iv_key);
1153
+ iv_key.data = key->data + MONGOCRYPT_ENC_KEY_LEN + MONGOCRYPT_MAC_KEY_LEN;
1154
+ iv_key.len = MONGOCRYPT_IV_KEY_LEN;
1155
+
1156
+ _mongocrypt_buffer_init (&intermediates[0]);
1157
+ _mongocrypt_buffer_init (&intermediates[1]);
1158
+ _mongocrypt_buffer_init (&intermediates[2]);
1159
+ /* Add associated data. */
1160
+ intermediates[0].data = associated_data->data;
1161
+ intermediates[0].len = associated_data->len;
1162
+ /* Add associated data length in bits. */
1163
+ /* multiplying a uint32_t by 8 won't bring it anywhere close to UINT64_MAX */
1164
+ associated_data_len_be = 8 * (uint64_t) associated_data->len;
1165
+ associated_data_len_be = BSON_UINT64_TO_BE (associated_data_len_be);
1166
+ intermediates[1].data = (uint8_t *) &associated_data_len_be;
1167
+ intermediates[1].len = sizeof (uint64_t);
1168
+ /* Add plaintext. */
1169
+ intermediates[2].data = (uint8_t *) plaintext->data;
1170
+ intermediates[2].len = plaintext->len;
1171
+
1172
+ tag.data = tag_storage;
1173
+ tag.len = sizeof (tag_storage);
1174
+
1175
+ if (!_mongocrypt_buffer_concat (&to_hmac, intermediates, 3)) {
1176
+ CLIENT_ERR ("failed to allocate buffer");
1177
+ goto done;
1178
+ }
1179
+
1180
+ if (!_crypto_hmac_sha_512 (crypto, &iv_key, &to_hmac, &tag, status)) {
1181
+ goto done;
1182
+ }
1183
+
1184
+ /* Truncate to IV length */
1185
+ memcpy (out->data, tag.data, MONGOCRYPT_IV_LEN);
1186
+
1187
+ ret = true;
1188
+ done:
1189
+ _mongocrypt_buffer_cleanup (&to_hmac);
1190
+ return ret;
1191
+ }
1192
+
1193
+ bool
1194
+ _mongocrypt_wrap_key (_mongocrypt_crypto_t *crypto,
1195
+ _mongocrypt_buffer_t *kek,
1196
+ _mongocrypt_buffer_t *dek,
1197
+ _mongocrypt_buffer_t *encrypted_dek,
1198
+ mongocrypt_status_t *status)
1199
+ {
1200
+ uint32_t bytes_written;
1201
+ _mongocrypt_buffer_t iv = {0};
1202
+ bool ret = false;
1203
+
1204
+ BSON_ASSERT_PARAM (crypto);
1205
+ BSON_ASSERT_PARAM (kek);
1206
+ BSON_ASSERT_PARAM (dek);
1207
+ BSON_ASSERT_PARAM (encrypted_dek);
1208
+
1209
+ _mongocrypt_buffer_init (encrypted_dek);
1210
+
1211
+ if (dek->len != MONGOCRYPT_KEY_LEN) {
1212
+ CLIENT_ERR ("data encryption key is incorrect length, expected: %" PRIu32
1213
+ ", got: %" PRIu32,
1214
+ MONGOCRYPT_KEY_LEN,
1215
+ dek->len);
1216
+ goto done;
1217
+ }
1218
+
1219
+ _mongocrypt_buffer_resize (
1220
+ encrypted_dek, _mongocrypt_calculate_ciphertext_len (dek->len, status));
1221
+ _mongocrypt_buffer_resize (&iv, MONGOCRYPT_IV_LEN);
1222
+
1223
+ if (!_mongocrypt_random (crypto, &iv, MONGOCRYPT_IV_LEN, status)) {
1224
+ goto done;
1225
+ }
1226
+
1227
+ if (!_mongocrypt_do_encryption (crypto,
1228
+ &iv,
1229
+ NULL /* associated data. */,
1230
+ kek,
1231
+ dek,
1232
+ encrypted_dek,
1233
+ &bytes_written,
1234
+ status)) {
1235
+ goto done;
1236
+ }
1237
+
1238
+ ret = true;
1239
+ done:
1240
+ _mongocrypt_buffer_cleanup (&iv);
1241
+ return ret;
1242
+ }
1243
+
1244
+ bool
1245
+ _mongocrypt_unwrap_key (_mongocrypt_crypto_t *crypto,
1246
+ _mongocrypt_buffer_t *kek,
1247
+ _mongocrypt_buffer_t *encrypted_dek,
1248
+ _mongocrypt_buffer_t *dek,
1249
+ mongocrypt_status_t *status)
1250
+ {
1251
+ uint32_t bytes_written;
1252
+
1253
+ BSON_ASSERT_PARAM (crypto);
1254
+ BSON_ASSERT_PARAM (kek);
1255
+ BSON_ASSERT_PARAM (dek);
1256
+ BSON_ASSERT_PARAM (encrypted_dek);
1257
+
1258
+ _mongocrypt_buffer_init (dek);
1259
+ _mongocrypt_buffer_resize (
1260
+ dek, _mongocrypt_calculate_plaintext_len (encrypted_dek->len, status));
1261
+
1262
+ if (!_mongocrypt_do_decryption (crypto,
1263
+ NULL /* associated data. */,
1264
+ kek,
1265
+ encrypted_dek,
1266
+ dek,
1267
+ &bytes_written,
1268
+ status)) {
1269
+ return false;
1270
+ }
1271
+ dek->len = bytes_written;
1272
+
1273
+ if (dek->len != MONGOCRYPT_KEY_LEN) {
1274
+ CLIENT_ERR ("decrypted key is incorrect length, expected: %" PRIu32
1275
+ ", got: %" PRIu32,
1276
+ MONGOCRYPT_KEY_LEN,
1277
+ dek->len);
1278
+ return false;
1279
+ }
1280
+ return true;
1281
+ }
1282
+
1283
+ bool
1284
+ _mongocrypt_hmac_sha_256 (_mongocrypt_crypto_t *crypto,
1285
+ const _mongocrypt_buffer_t *key,
1286
+ const _mongocrypt_buffer_t *in,
1287
+ _mongocrypt_buffer_t *out,
1288
+ mongocrypt_status_t *status)
1289
+ {
1290
+ BSON_ASSERT_PARAM (crypto);
1291
+ BSON_ASSERT_PARAM (key);
1292
+ BSON_ASSERT_PARAM (in);
1293
+ BSON_ASSERT_PARAM (out);
1294
+
1295
+ if (key->len != MONGOCRYPT_MAC_KEY_LEN) {
1296
+ CLIENT_ERR ("invalid hmac_sha_256 key length. Got %" PRIu32
1297
+ ", expected: %" PRIu32,
1298
+ key->len,
1299
+ MONGOCRYPT_MAC_KEY_LEN);
1300
+ return false;
1301
+ }
1302
+
1303
+ if (crypto->hooks_enabled) {
1304
+ mongocrypt_binary_t key_bin, out_bin, in_bin;
1305
+ _mongocrypt_buffer_to_binary (key, &key_bin);
1306
+ _mongocrypt_buffer_to_binary (out, &out_bin);
1307
+ _mongocrypt_buffer_to_binary (in, &in_bin);
1308
+
1309
+ return crypto->hmac_sha_256 (
1310
+ crypto->ctx, &key_bin, &in_bin, &out_bin, status);
1311
+ }
1312
+ return _native_crypto_hmac_sha_256 (key, in, out, status);
1313
+ }
1314
+
1315
+ bool
1316
+ _mongocrypt_fle2aead_do_encryption (_mongocrypt_crypto_t *crypto,
1317
+ const _mongocrypt_buffer_t *iv,
1318
+ const _mongocrypt_buffer_t *associated_data,
1319
+ const _mongocrypt_buffer_t *key,
1320
+ const _mongocrypt_buffer_t *plaintext,
1321
+ _mongocrypt_buffer_t *ciphertext,
1322
+ uint32_t *bytes_written,
1323
+ mongocrypt_status_t *status)
1324
+ {
1325
+ BSON_ASSERT_PARAM (crypto);
1326
+ BSON_ASSERT_PARAM (iv);
1327
+ BSON_ASSERT_PARAM (associated_data);
1328
+ BSON_ASSERT_PARAM (key);
1329
+ BSON_ASSERT_PARAM (plaintext);
1330
+ BSON_ASSERT_PARAM (ciphertext);
1331
+ BSON_ASSERT_PARAM (bytes_written);
1332
+
1333
+ if (ciphertext->len !=
1334
+ _mongocrypt_fle2aead_calculate_ciphertext_len (plaintext->len, status)) {
1335
+ CLIENT_ERR ("output ciphertext must be allocated with %" PRIu32 " bytes",
1336
+ _mongocrypt_fle2aead_calculate_ciphertext_len (plaintext->len,
1337
+ status));
1338
+ return false;
1339
+ }
1340
+
1341
+ if (plaintext->len <= 0) {
1342
+ CLIENT_ERR ("input plaintext too small. Must be more than zero bytes.");
1343
+ return false;
1344
+ }
1345
+
1346
+ if (MONGOCRYPT_IV_LEN != iv->len) {
1347
+ CLIENT_ERR ("IV must be length %d, but is length %" PRIu32,
1348
+ MONGOCRYPT_IV_LEN,
1349
+ iv->len);
1350
+ return false;
1351
+ }
1352
+ if (MONGOCRYPT_KEY_LEN != key->len) {
1353
+ CLIENT_ERR ("key must be length %d, but is length %" PRIu32,
1354
+ MONGOCRYPT_KEY_LEN,
1355
+ key->len);
1356
+ return false;
1357
+ }
1358
+
1359
+ memset (ciphertext->data, 0, ciphertext->len);
1360
+ *bytes_written = 0;
1361
+
1362
+ /* Declare variable names matching [AEAD with
1363
+ * CTR](https://docs.google.com/document/d/1eCU7R8Kjr-mdyz6eKvhNIDVmhyYQcAaLtTfHeK7a_vE/).
1364
+ */
1365
+ /* M is the input plaintext. */
1366
+ _mongocrypt_buffer_t M;
1367
+ if (!_mongocrypt_buffer_from_subrange (&M, plaintext, 0, plaintext->len)) {
1368
+ CLIENT_ERR ("unable to create M view from plaintext");
1369
+ return false;
1370
+ }
1371
+ /* Ke is 32 byte Key for encryption. */
1372
+ _mongocrypt_buffer_t Ke;
1373
+ if (!_mongocrypt_buffer_from_subrange (
1374
+ &Ke, key, 0, MONGOCRYPT_ENC_KEY_LEN)) {
1375
+ CLIENT_ERR ("unable to create Ke view from key");
1376
+ return false;
1377
+ }
1378
+ /* IV is 16 byte IV. */
1379
+ _mongocrypt_buffer_t IV;
1380
+ if (!_mongocrypt_buffer_from_subrange (&IV, iv, 0, iv->len)) {
1381
+ CLIENT_ERR ("unable to create IV view from iv");
1382
+ return false;
1383
+ }
1384
+ /* Km is 32 byte Key for HMAC. */
1385
+ _mongocrypt_buffer_t Km;
1386
+ if (!_mongocrypt_buffer_from_subrange (
1387
+ &Km, key, MONGOCRYPT_ENC_KEY_LEN, MONGOCRYPT_MAC_KEY_LEN)) {
1388
+ CLIENT_ERR ("unable to create Km view from key");
1389
+ return false;
1390
+ }
1391
+ /* AD is Associated Data. */
1392
+ _mongocrypt_buffer_t AD;
1393
+ if (!_mongocrypt_buffer_from_subrange (
1394
+ &AD, associated_data, 0, associated_data->len)) {
1395
+ CLIENT_ERR ("unable to create AD view from associated_data");
1396
+ return false;
1397
+ }
1398
+ /* C is the output ciphertext. */
1399
+ _mongocrypt_buffer_t C;
1400
+ if (!_mongocrypt_buffer_from_subrange (&C, ciphertext, 0, ciphertext->len)) {
1401
+ CLIENT_ERR ("unable to create C view from ciphertext");
1402
+ return false;
1403
+ }
1404
+ /* S is the output of the symmetric cipher. It is appended after IV in C. */
1405
+ _mongocrypt_buffer_t S;
1406
+ BSON_ASSERT (C.len >= MONGOCRYPT_IV_LEN + MONGOCRYPT_HMAC_LEN);
1407
+ if (!_mongocrypt_buffer_from_subrange (&S,
1408
+ &C,
1409
+ MONGOCRYPT_IV_LEN,
1410
+ C.len - MONGOCRYPT_IV_LEN -
1411
+ MONGOCRYPT_HMAC_LEN)) {
1412
+ CLIENT_ERR ("unable to create S view from C");
1413
+ return false;
1414
+ }
1415
+ uint32_t S_bytes_written = 0;
1416
+ /* T is the output of the HMAC tag. It is appended after S in C. */
1417
+ _mongocrypt_buffer_t T;
1418
+ if (!_mongocrypt_buffer_from_subrange (
1419
+ &T, &C, C.len - MONGOCRYPT_HMAC_LEN, MONGOCRYPT_HMAC_LEN)) {
1420
+ CLIENT_ERR ("unable to create T view from C");
1421
+ return false;
1422
+ }
1423
+
1424
+ /* Compute S = AES-CTR.Enc(Ke, IV, M). */
1425
+ if (!_crypto_aes_256_ctr_encrypt (
1426
+ crypto,
1427
+ (aes_256_args_t){.key = &Ke,
1428
+ .iv = &IV,
1429
+ .in = &M,
1430
+ .out = &S,
1431
+ .bytes_written = &S_bytes_written,
1432
+ .status = status})) {
1433
+ return false;
1434
+ }
1435
+
1436
+ /* Compute T = HMAC-SHA256(Km, AD || IV || S). */
1437
+ {
1438
+ _mongocrypt_buffer_t hmac_inputs[] = {AD, IV, S};
1439
+ _mongocrypt_buffer_t hmac_input = {0};
1440
+ _mongocrypt_buffer_concat (&hmac_input, hmac_inputs, 3);
1441
+ if (!_mongocrypt_hmac_sha_256 (crypto, &Km, &hmac_input, &T, status)) {
1442
+ _mongocrypt_buffer_cleanup (&hmac_input);
1443
+ return false;
1444
+ }
1445
+ _mongocrypt_buffer_cleanup (&hmac_input);
1446
+ }
1447
+
1448
+ /* Output C = IV || S || T. */
1449
+ /* S and T are already in C. Prepend IV. */
1450
+ memmove (C.data, IV.data, MONGOCRYPT_IV_LEN);
1451
+
1452
+ *bytes_written = MONGOCRYPT_IV_LEN + S_bytes_written + MONGOCRYPT_HMAC_LEN;
1453
+ return true;
1454
+ }
1455
+
1456
+ bool
1457
+ _mongocrypt_fle2aead_do_decryption (_mongocrypt_crypto_t *crypto,
1458
+ const _mongocrypt_buffer_t *associated_data,
1459
+ const _mongocrypt_buffer_t *key,
1460
+ const _mongocrypt_buffer_t *ciphertext,
1461
+ _mongocrypt_buffer_t *plaintext,
1462
+ uint32_t *bytes_written,
1463
+ mongocrypt_status_t *status)
1464
+ {
1465
+ BSON_ASSERT_PARAM (crypto);
1466
+ BSON_ASSERT_PARAM (associated_data);
1467
+ BSON_ASSERT_PARAM (key);
1468
+ BSON_ASSERT_PARAM (ciphertext);
1469
+ BSON_ASSERT_PARAM (plaintext);
1470
+ BSON_ASSERT_PARAM (bytes_written);
1471
+
1472
+ if (ciphertext->len <= MONGOCRYPT_IV_LEN + MONGOCRYPT_HMAC_LEN) {
1473
+ CLIENT_ERR ("input ciphertext too small. Must be more than %" PRIu32
1474
+ " bytes",
1475
+ MONGOCRYPT_IV_LEN + MONGOCRYPT_HMAC_LEN);
1476
+ return false;
1477
+ }
1478
+
1479
+ if (plaintext->len !=
1480
+ _mongocrypt_fle2aead_calculate_plaintext_len (ciphertext->len, status)) {
1481
+ CLIENT_ERR ("output plaintext must be allocated with %" PRIu32 " bytes",
1482
+ _mongocrypt_fle2aead_calculate_plaintext_len (ciphertext->len,
1483
+ status));
1484
+ return false;
1485
+ }
1486
+
1487
+ if (MONGOCRYPT_KEY_LEN != key->len) {
1488
+ CLIENT_ERR ("key must be length %d, but is length %" PRIu32,
1489
+ MONGOCRYPT_KEY_LEN,
1490
+ key->len);
1491
+ return false;
1492
+ }
1493
+
1494
+ memset (plaintext->data, 0, plaintext->len);
1495
+ *bytes_written = 0;
1496
+
1497
+ /* Declare variable names matching [AEAD with
1498
+ * CTR](https://docs.google.com/document/d/1eCU7R8Kjr-mdyz6eKvhNIDVmhyYQcAaLtTfHeK7a_vE/).
1499
+ */
1500
+ /* C is the input ciphertext. */
1501
+ _mongocrypt_buffer_t C;
1502
+ if (!_mongocrypt_buffer_from_subrange (&C, ciphertext, 0, ciphertext->len)) {
1503
+ CLIENT_ERR ("unable to create C view from ciphertext");
1504
+ return false;
1505
+ }
1506
+ /* IV is 16 byte IV. It is the first part of C. */
1507
+ _mongocrypt_buffer_t IV;
1508
+ if (!_mongocrypt_buffer_from_subrange (
1509
+ &IV, ciphertext, 0, MONGOCRYPT_IV_LEN)) {
1510
+ CLIENT_ERR ("unable to create IV view from ciphertext");
1511
+ return false;
1512
+ }
1513
+ /* S is the symmetric cipher output from C. It is after the IV in C. */
1514
+ _mongocrypt_buffer_t S;
1515
+ if (!_mongocrypt_buffer_from_subrange (&S,
1516
+ ciphertext,
1517
+ MONGOCRYPT_IV_LEN,
1518
+ C.len - MONGOCRYPT_IV_LEN -
1519
+ MONGOCRYPT_HMAC_LEN)) {
1520
+ CLIENT_ERR ("unable to create S view from C");
1521
+ return false;
1522
+ }
1523
+ /* T is the HMAC tag from C. It is after S in C. */
1524
+ _mongocrypt_buffer_t T;
1525
+ if (!_mongocrypt_buffer_from_subrange (
1526
+ &T, &C, C.len - MONGOCRYPT_HMAC_LEN, MONGOCRYPT_HMAC_LEN)) {
1527
+ CLIENT_ERR ("unable to create T view from C");
1528
+ return false;
1529
+ }
1530
+ /* Tp is the computed HMAC of the input. */
1531
+ _mongocrypt_buffer_t Tp = {0};
1532
+ /* M is the output plaintext. */
1533
+ _mongocrypt_buffer_t M;
1534
+ if (!_mongocrypt_buffer_from_subrange (&M, plaintext, 0, plaintext->len)) {
1535
+ CLIENT_ERR ("unable to create M view from plaintext");
1536
+ return false;
1537
+ }
1538
+ /* Ke is 32 byte Key for encryption. */
1539
+ _mongocrypt_buffer_t Ke;
1540
+ if (!_mongocrypt_buffer_from_subrange (
1541
+ &Ke, key, 0, MONGOCRYPT_ENC_KEY_LEN)) {
1542
+ CLIENT_ERR ("unable to create Ke view from key");
1543
+ return false;
1544
+ }
1545
+ /* Km is 32 byte Key for HMAC. */
1546
+ _mongocrypt_buffer_t Km;
1547
+ if (!_mongocrypt_buffer_from_subrange (
1548
+ &Km, key, MONGOCRYPT_ENC_KEY_LEN, MONGOCRYPT_MAC_KEY_LEN)) {
1549
+ CLIENT_ERR ("unable to create Km view from key");
1550
+ return false;
1551
+ }
1552
+ /* AD is Associated Data. */
1553
+ _mongocrypt_buffer_t AD;
1554
+ if (!_mongocrypt_buffer_from_subrange (
1555
+ &AD, associated_data, 0, associated_data->len)) {
1556
+ CLIENT_ERR ("unable to create AD view from associated_data");
1557
+ return false;
1558
+ }
1559
+
1560
+ /* Compute Tp = HMAC-SHA256(Km, AD || IV || S). Check that it matches input
1561
+ * ciphertext T. */
1562
+ {
1563
+ _mongocrypt_buffer_t hmac_inputs[] = {AD, IV, S};
1564
+ _mongocrypt_buffer_t hmac_input = {0};
1565
+ _mongocrypt_buffer_concat (&hmac_input, hmac_inputs, 3);
1566
+ _mongocrypt_buffer_resize (&Tp, MONGOCRYPT_HMAC_LEN);
1567
+ if (!_mongocrypt_hmac_sha_256 (crypto, &Km, &hmac_input, &Tp, status)) {
1568
+ _mongocrypt_buffer_cleanup (&hmac_input);
1569
+ _mongocrypt_buffer_cleanup (&Tp);
1570
+ return false;
1571
+ }
1572
+ if (0 != _mongocrypt_buffer_cmp (&T, &Tp)) {
1573
+ CLIENT_ERR ("decryption error");
1574
+ _mongocrypt_buffer_cleanup (&hmac_input);
1575
+ _mongocrypt_buffer_cleanup (&Tp);
1576
+ return false;
1577
+ }
1578
+ _mongocrypt_buffer_cleanup (&hmac_input);
1579
+ _mongocrypt_buffer_cleanup (&Tp);
1580
+ }
1581
+
1582
+ /* Compute and output M = AES-CTR.Dec(Ke, S) */
1583
+ if (!_crypto_aes_256_ctr_decrypt (
1584
+ crypto,
1585
+ (aes_256_args_t){.key = &Ke,
1586
+ .iv = &IV,
1587
+ .in = &S,
1588
+ .out = &M,
1589
+ .bytes_written = bytes_written,
1590
+ .status = status})) {
1591
+ return false;
1592
+ }
1593
+
1594
+ return true;
1595
+ }
1596
+
1597
+ bool
1598
+ _mongocrypt_fle2_do_encryption (_mongocrypt_crypto_t *crypto,
1599
+ const _mongocrypt_buffer_t *iv,
1600
+ const _mongocrypt_buffer_t *key,
1601
+ const _mongocrypt_buffer_t *plaintext,
1602
+ _mongocrypt_buffer_t *ciphertext,
1603
+ uint32_t *bytes_written,
1604
+ mongocrypt_status_t *status)
1605
+ {
1606
+ BSON_ASSERT_PARAM (crypto);
1607
+ BSON_ASSERT_PARAM (iv);
1608
+ BSON_ASSERT_PARAM (key);
1609
+ BSON_ASSERT_PARAM (plaintext);
1610
+ BSON_ASSERT_PARAM (ciphertext);
1611
+ BSON_ASSERT_PARAM (bytes_written);
1612
+
1613
+ if (ciphertext->len !=
1614
+ _mongocrypt_fle2_calculate_ciphertext_len (plaintext->len, status)) {
1615
+ CLIENT_ERR (
1616
+ "output ciphertext must be allocated with %" PRIu32 " bytes",
1617
+ _mongocrypt_fle2_calculate_ciphertext_len (plaintext->len, status));
1618
+ return false;
1619
+ }
1620
+
1621
+ if (plaintext->len <= 0) {
1622
+ CLIENT_ERR ("input plaintext too small. Must be more than zero bytes.");
1623
+ return false;
1624
+ }
1625
+
1626
+ if (MONGOCRYPT_IV_LEN != iv->len) {
1627
+ CLIENT_ERR ("IV must be length %d, but is length %" PRIu32,
1628
+ MONGOCRYPT_IV_LEN,
1629
+ iv->len);
1630
+ return false;
1631
+ }
1632
+ if (MONGOCRYPT_ENC_KEY_LEN != key->len) {
1633
+ CLIENT_ERR ("key must be length %d, but is length %" PRIu32,
1634
+ MONGOCRYPT_ENC_KEY_LEN,
1635
+ key->len);
1636
+ return false;
1637
+ }
1638
+
1639
+ BSON_ASSERT (ciphertext->len >= MONGOCRYPT_IV_LEN);
1640
+ memset (ciphertext->data + MONGOCRYPT_IV_LEN,
1641
+ 0,
1642
+ ciphertext->len - MONGOCRYPT_IV_LEN);
1643
+ *bytes_written = 0;
1644
+
1645
+ /* Declare variable names matching [AEAD with
1646
+ * CTR](https://docs.google.com/document/d/1eCU7R8Kjr-mdyz6eKvhNIDVmhyYQcAaLtTfHeK7a_vE/).
1647
+ */
1648
+ /* M is the input plaintext. */
1649
+ _mongocrypt_buffer_t M = *plaintext;
1650
+ /* Ke is 32 byte Key for encryption. */
1651
+ _mongocrypt_buffer_t Ke = *key;
1652
+ /* IV is 16 byte IV. */
1653
+ _mongocrypt_buffer_t IV = *iv;
1654
+ /* C is the output ciphertext. */
1655
+ _mongocrypt_buffer_t C = *ciphertext;
1656
+ /* S is the output of the symmetric cipher. It is appended after IV in C. */
1657
+ _mongocrypt_buffer_t S;
1658
+ if (!_mongocrypt_buffer_from_subrange (
1659
+ &S, &C, MONGOCRYPT_IV_LEN, C.len - MONGOCRYPT_IV_LEN)) {
1660
+ CLIENT_ERR ("unable to create S view from C");
1661
+ return false;
1662
+ }
1663
+ uint32_t S_bytes_written = 0;
1664
+
1665
+ /* Compute S = AES-CTR.Enc(Ke, IV, M). */
1666
+ if (!_crypto_aes_256_ctr_encrypt (
1667
+ crypto,
1668
+ (aes_256_args_t){.key = &Ke,
1669
+ .iv = &IV,
1670
+ .in = &M,
1671
+ .out = &S,
1672
+ .bytes_written = &S_bytes_written,
1673
+ .status = status})) {
1674
+ return false;
1675
+ }
1676
+
1677
+ if (S_bytes_written != M.len) {
1678
+ CLIENT_ERR ("expected S_bytes_written=%" PRIu32 " got %" PRIu32,
1679
+ M.len,
1680
+ S_bytes_written);
1681
+ return false;
1682
+ }
1683
+
1684
+ /* Output C = IV || S. */
1685
+ /* S is already in C. Prepend IV. */
1686
+ memmove (C.data, IV.data, MONGOCRYPT_IV_LEN);
1687
+
1688
+ *bytes_written = MONGOCRYPT_IV_LEN + S_bytes_written;
1689
+ return true;
1690
+ }
1691
+
1692
+ bool
1693
+ _mongocrypt_fle2_do_decryption (_mongocrypt_crypto_t *crypto,
1694
+ const _mongocrypt_buffer_t *key,
1695
+ const _mongocrypt_buffer_t *ciphertext,
1696
+ _mongocrypt_buffer_t *plaintext,
1697
+ uint32_t *bytes_written,
1698
+ mongocrypt_status_t *status)
1699
+ {
1700
+ BSON_ASSERT_PARAM (crypto);
1701
+ BSON_ASSERT_PARAM (key);
1702
+ BSON_ASSERT_PARAM (ciphertext);
1703
+ BSON_ASSERT_PARAM (plaintext);
1704
+ BSON_ASSERT_PARAM (bytes_written);
1705
+
1706
+ if (ciphertext->len <= MONGOCRYPT_IV_LEN) {
1707
+ CLIENT_ERR ("input ciphertext too small. Must be more than %" PRIu32
1708
+ " bytes",
1709
+ MONGOCRYPT_IV_LEN);
1710
+ return false;
1711
+ }
1712
+
1713
+ if (plaintext->len !=
1714
+ _mongocrypt_fle2_calculate_plaintext_len (ciphertext->len, status)) {
1715
+ CLIENT_ERR (
1716
+ "output plaintext must be allocated with %" PRIu32 " bytes",
1717
+ _mongocrypt_fle2_calculate_plaintext_len (ciphertext->len, status));
1718
+ return false;
1719
+ }
1720
+
1721
+ if (MONGOCRYPT_ENC_KEY_LEN != key->len) {
1722
+ CLIENT_ERR ("key must be length %d, but is length %" PRIu32,
1723
+ MONGOCRYPT_ENC_KEY_LEN,
1724
+ key->len);
1725
+ return false;
1726
+ }
1727
+
1728
+ memset (plaintext->data, 0, plaintext->len);
1729
+ *bytes_written = 0;
1730
+
1731
+ /* Declare variable names matching [AEAD with
1732
+ * CTR](https://docs.google.com/document/d/1eCU7R8Kjr-mdyz6eKvhNIDVmhyYQcAaLtTfHeK7a_vE/).
1733
+ */
1734
+ /* C is the input ciphertext. */
1735
+ _mongocrypt_buffer_t C = *ciphertext;
1736
+ /* IV is 16 byte IV. It is the first part of C. */
1737
+ _mongocrypt_buffer_t IV;
1738
+ if (!_mongocrypt_buffer_from_subrange (
1739
+ &IV, ciphertext, 0, MONGOCRYPT_IV_LEN)) {
1740
+ CLIENT_ERR ("unable to create IV view from ciphertext");
1741
+ return false;
1742
+ }
1743
+ /* S is the symmetric cipher output from C. It is after the IV in C. */
1744
+ _mongocrypt_buffer_t S;
1745
+ if (!_mongocrypt_buffer_from_subrange (
1746
+ &S, ciphertext, MONGOCRYPT_IV_LEN, C.len - MONGOCRYPT_IV_LEN)) {
1747
+ CLIENT_ERR ("unable to create S view from C");
1748
+ return false;
1749
+ }
1750
+ /* M is the output plaintext. */
1751
+ _mongocrypt_buffer_t M = *plaintext;
1752
+ /* Ke is 32 byte Key for encryption. */
1753
+ _mongocrypt_buffer_t Ke = *key;
1754
+
1755
+ /* Compute and output M = AES-CTR.Dec(Ke, S) */
1756
+ if (!_crypto_aes_256_ctr_decrypt (
1757
+ crypto,
1758
+ (aes_256_args_t){.key = &Ke,
1759
+ .iv = &IV,
1760
+ .in = &S,
1761
+ .out = &M,
1762
+ .bytes_written = bytes_written,
1763
+ .status = status})) {
1764
+ return false;
1765
+ }
1766
+
1767
+ if (*bytes_written != S.len) {
1768
+ CLIENT_ERR ("expected bytes_written=%" PRIu32 " got %" PRIu32,
1769
+ S.len,
1770
+ *bytes_written);
1771
+ return false;
1772
+ }
1773
+
1774
+ return true;
1775
+ }
1776
+
1777
+ /* This implementation avoids modulo bias. It is based on arc4random_uniform:
1778
+ https://github.com/openbsd/src/blob/2207c4325726fdc5c4bcd0011af0fdf7d3dab137/lib/libc/crypt/arc4random_uniform.c#L33
1779
+ */
1780
+ bool
1781
+ _mongocrypt_random_uint64 (_mongocrypt_crypto_t *crypto,
1782
+ uint64_t exclusive_upper_bound,
1783
+ uint64_t *out,
1784
+ mongocrypt_status_t *status)
1785
+ {
1786
+ BSON_ASSERT_PARAM (crypto);
1787
+ BSON_ASSERT_PARAM (out);
1788
+
1789
+ *out = 0;
1790
+
1791
+ if (exclusive_upper_bound < 2) {
1792
+ *out = 0;
1793
+ return true;
1794
+ }
1795
+
1796
+ /* 2**64 % x == (2**64 - x) % x */
1797
+ uint64_t min = (0 - exclusive_upper_bound) % exclusive_upper_bound;
1798
+
1799
+ _mongocrypt_buffer_t rand_u64_buf;
1800
+ _mongocrypt_buffer_init (&rand_u64_buf);
1801
+ _mongocrypt_buffer_resize (&rand_u64_buf, (uint32_t) sizeof (uint64_t));
1802
+
1803
+ uint64_t rand_u64;
1804
+ for (;;) {
1805
+ if (!_mongocrypt_random (
1806
+ crypto, &rand_u64_buf, rand_u64_buf.len, status)) {
1807
+ _mongocrypt_buffer_cleanup (&rand_u64_buf);
1808
+ return false;
1809
+ }
1810
+
1811
+ memcpy (&rand_u64, rand_u64_buf.data, rand_u64_buf.len);
1812
+
1813
+ if (rand_u64 >= min) {
1814
+ break;
1815
+ }
1816
+ }
1817
+
1818
+ *out = rand_u64 % exclusive_upper_bound;
1819
+
1820
+ _mongocrypt_buffer_cleanup (&rand_u64_buf);
1821
+ return true;
1822
+ }
1823
+
1824
+ bool
1825
+ _mongocrypt_random_int64 (_mongocrypt_crypto_t *crypto,
1826
+ int64_t exclusive_upper_bound,
1827
+ int64_t *out,
1828
+ mongocrypt_status_t *status)
1829
+ {
1830
+ BSON_ASSERT_PARAM (crypto);
1831
+ BSON_ASSERT_PARAM (out);
1832
+
1833
+ if (exclusive_upper_bound <= 0) {
1834
+ CLIENT_ERR ("Expected exclusive_upper_bound > 0");
1835
+ return false;
1836
+ }
1837
+
1838
+ uint64_t u64_exclusive_upper_bound = (uint64_t) exclusive_upper_bound;
1839
+ uint64_t u64_out;
1840
+
1841
+ if (!_mongocrypt_random_uint64 (
1842
+ crypto, u64_exclusive_upper_bound, &u64_out, status)) {
1843
+ return false;
1844
+ }
1845
+
1846
+ /* Zero the leading bit to ensure rand_i64 is non-negative. */
1847
+ u64_out &= (~(1ull << 63));
1848
+ *out = (int64_t) u64_out;
1849
+ return true;
1850
+ }