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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/ext/libmongocrypt/extconf.rb +70 -0
- data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +164 -0
- data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +699 -0
- data/ext/libmongocrypt/libmongocrypt/CODEOWNERS +13 -0
- data/ext/libmongocrypt/libmongocrypt/LICENSE +201 -0
- data/ext/libmongocrypt/libmongocrypt/README.md +250 -0
- data/ext/libmongocrypt/libmongocrypt/VERSION_CURRENT +1 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/CMakeLists.txt +16 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/AssemblyInfo.cs +4 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Binary.cs +131 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/BinarySafeHandle.cs +60 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CheckableSafeHandle.cs +46 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CipherCallbacks.cs +168 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/ContextSafeHandle.cs +48 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClient.cs +238 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClientFactory.cs +134 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptContext.cs +214 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptException.cs +37 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptOptions.cs +67 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/HashCallback.cs +59 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/HmacShaCallbacks.cs +96 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/IStatus.cs +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/KmsCredentials.cs +53 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/KmsKeyId.cs +91 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/KmsRequest.cs +125 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/KmsRequestCollection.cs +60 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Library.cs +652 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/LibraryLoader.cs +252 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/LibraryLoadingException.cs +34 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/License.txt +14 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/LogLevel.cs +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/MongoCryptSafeHandle.cs +48 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/MongoDB.Libmongocrypt.csproj +106 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/MongoDB.Libmongocrypt.ruleset +85 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/MongoDB.Libmongocrypt.targets +21 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/OperatingSystemHelper.cs +59 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Package.include.template.csproj +38 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/PinnedBinary.cs +49 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/SecureRandomCallback.cs +51 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/SigningRSAESPKCSCallback.cs +74 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Status.cs +94 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/StatusSafeHandle.cs +60 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/StyleCop.ruleset +11 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/stylecop.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Example/MongoDB.Libmongocrypt.Example.csproj +23 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Example/Package.include.template.csproj +11 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Example/Program.cs +442 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/BasicTests.cs +748 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/BsonUtil.cs +82 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/CallbackUtils.cs +37 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/CipherCallbacksTests.cs +46 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/HashCallbackTests.cs +37 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/HmacShaCallbacksTests.cs +37 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/MongoDB.Libmongocrypt.Test.csproj +35 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/Package.include.template.csproj +23 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/SigningRSAESPKCSCallbackTests.cs +64 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/test/example/collection-info.json +37 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/test/example/command-reply.json +13 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/test/example/encrypted-command-reply.json +16 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/test/example/encrypted-command.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/test/example/encrypted-value.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/test/example/key-document.json +36 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/test/example/key-filter.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/test/example/list-collections-filter.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/test/example/mongocryptd-command.json +22 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/xunit.runner.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test32/BasicTests.cs +54 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test32/MongoDB.Libmongocrypt.Test32.csproj +42 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test32/Package.include.template.csproj +23 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/README.md +66 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.cake +219 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.ps1 +275 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.sh +77 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/README.md +36 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/build.gradle.kts +339 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradle/wrapper/gradle-wrapper.properties +5 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradlew +188 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradlew.bat +100 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/BinaryHolder.java +45 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CAPI.java +1130 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CAPIHelper.java +96 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CipherCallback.java +66 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/DisposableMemory.java +31 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/JULLogger.java +130 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/Logger.java +144 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/Loggers.java +50 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MacCallback.java +60 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MessageDigestCallback.java +55 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoAwsKmsProviderOptions.java +104 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCrypt.java +100 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptContext.java +137 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptContextImpl.java +164 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptException.java +67 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptImpl.java +408 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptOptions.java +284 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCrypts.java +38 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoDataKeyOptions.java +125 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoExplicitEncryptOptions.java +225 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoKeyDecryptor.java +76 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoKeyDecryptorImpl.java +105 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoLocalKmsProviderOptions.java +83 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoRewrapManyDataKeyOptions.java +104 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/SLF4JLogger.java +110 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/SecureRandomCallback.java +51 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/SigningRSAESPKCSCallback.java +76 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/package-info.java +18 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java +345 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/collection-info.json +37 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/command-reply.json +13 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/command.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/encrypted-command-reply.json +16 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/encrypted-command.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/encrypted-value.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/encrypted-payload.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/key-document.json +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/key-filter.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/rangeopts.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/value-to-encrypt.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/json-schema.json +15 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/key-document.json +36 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/key-filter-keyAltName.json +14 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/key-filter.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/keys/ABCDEFAB123498761234123456789012-local-document.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/kms-reply.txt +6 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/list-collections-filter.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/mongocryptd-command.json +22 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/mongocryptd-reply.json +18 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/CHANGELOG.md +81 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/LICENSE +201 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/README.md +773 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/binding.gyp +79 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/README.hbs +44 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/build-static.sh +39 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/index.d.ts +515 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/autoEncrypter.js +420 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/buffer_pool.js +123 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/clientEncryption.js +699 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/common.js +100 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/credentialsProvider.js +33 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/cryptoCallbacks.js +87 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/index.js +42 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/mongocryptdManager.js +66 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/stateMachine.js +487 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package-lock.json +16051 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package.json +81 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.cc +929 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.h +114 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/autoEncrypter.test.js +953 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/buffer_pool.test.js +91 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/clientEncryption.test.js +701 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/credentialsProvider.test.js +163 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/cryptoCallbacks.test.js +284 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/README.md +5 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/collection-info.json +37 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encrypted-document-nested.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encrypted-document.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encryptedFields.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/key-document.json +32 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/key1-document.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/kms-decrypt-reply.txt +6 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/kms-encrypt-reply.txt +7 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/mongocryptd-reply.json +18 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/mongocryptdManager.test.js +48 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/release.test.js +59 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/requirements.helper.js +29 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/stateMachine.test.js +331 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/mongodb_reporter.js +325 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +121 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/LICENSE +201 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/README.rst +187 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/RELEASE.rst +107 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/build-manylinux-wheel.sh +16 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/__init__.py +16 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/auto_encrypter.py +61 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binary.py +94 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +1561 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/compat.py +61 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/credentials.py +136 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/crypto.py +162 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/errors.py +39 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/explicit_encrypter.py +248 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +808 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/state_machine.py +156 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +17 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/release.sh +92 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/setup.py +84 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/strip_header.py +51 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/__init__.py +37 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/collection-info.json +39 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/command-reply.json +13 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/command.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/compact/success/cmd.json +1 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/compact/success/encrypted-field-config-map.json +47 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/compact/success/encrypted-payload.json +23 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-command-reply.json +16 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-command.json +13 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-field-config-map.json +48 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-value.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit/int32/encrypted-payload.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit/int32/rangeopts.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit/int32/value-to-encrypt.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document-azure.json +33 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document-gcp.json +35 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document.json +33 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-filter.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/keys/12345678123498761234123456789012-local-document.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/keys/12345678123498761234123456789013-local-document.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/keys/ABCDEFAB123498761234123456789012-local-document.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/kms-encrypt-reply.txt +7 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/kms-reply-azure.txt +6 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/kms-reply-gcp.txt +6 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/kms-reply.txt +6 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/list-collections-filter.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/mongocryptd-command.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/mongocryptd-reply.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/schema-map.json +40 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_binding.py +71 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_crypto.py +49 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_mongocrypt.py +825 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test-requirements.txt +12 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/FetchMongoC.cmake +20 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/ImportBSON.cmake +209 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/ImportDFP.cmake +70 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/IntelDFP.cmake +409 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/LTO.cmake +57 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/MongoC-Warnings.cmake +74 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/libmongocrypt-hidden-symbols.map +8 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/libmongocrypt-hidden-symbols.txt +5 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/libmongocrypt-static.pc.in +9 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/libmongocrypt.pc.in +10 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/ltocheck-lib.c +6 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/ltocheck-main.c +9 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/mongocrypt-config.cmake +42 -0
- data/ext/libmongocrypt/libmongocrypt/debian/build_snapshot.sh +79 -0
- data/ext/libmongocrypt/libmongocrypt/debian/changelog +105 -0
- data/ext/libmongocrypt/libmongocrypt/debian/compat +1 -0
- data/ext/libmongocrypt/libmongocrypt/debian/control +41 -0
- data/ext/libmongocrypt/libmongocrypt/debian/copyright +129 -0
- data/ext/libmongocrypt/libmongocrypt/debian/gbp.conf +23 -0
- data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt-dev.dirs +2 -0
- data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt-dev.install +5 -0
- data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt0.dirs +1 -0
- data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt0.install +1 -0
- data/ext/libmongocrypt/libmongocrypt/debian/rules +46 -0
- data/ext/libmongocrypt/libmongocrypt/debian/source/format +1 -0
- data/ext/libmongocrypt/libmongocrypt/debian/source/lintian-overrides +3 -0
- data/ext/libmongocrypt/libmongocrypt/debian/source/options +1 -0
- data/ext/libmongocrypt/libmongocrypt/debian/watch +3 -0
- data/ext/libmongocrypt/libmongocrypt/doc/Doxygen +2474 -0
- data/ext/libmongocrypt/libmongocrypt/etc/calc_release_version.py +265 -0
- data/ext/libmongocrypt/libmongocrypt/etc/debian/control +33 -0
- data/ext/libmongocrypt/libmongocrypt/etc/debian/rules +41 -0
- data/ext/libmongocrypt/libmongocrypt/etc/debian/source/format +1 -0
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_aead_generate_tests.py +41 -0
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_crypto.py +105 -0
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_crypto_selftest.py +52 -0
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_generate_tests.py +34 -0
- data/ext/libmongocrypt/libmongocrypt/etc/generate-kek-tests.py +69 -0
- data/ext/libmongocrypt/libmongocrypt/etc/generate-test-data.py +141 -0
- data/ext/libmongocrypt/libmongocrypt/etc/list-compile-files.py +20 -0
- data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-MONGOCRYPT-571.patch +25 -0
- data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-s390x.patch +134 -0
- data/ext/libmongocrypt/libmongocrypt/etc/packager.py +854 -0
- data/ext/libmongocrypt/libmongocrypt/etc/print-marking.py +36 -0
- data/ext/libmongocrypt/libmongocrypt/etc/repo_config.yaml +257 -0
- data/ext/libmongocrypt/libmongocrypt/etc/requirements.txt +2 -0
- data/ext/libmongocrypt/libmongocrypt/etc/rewrite.py +16 -0
- data/ext/libmongocrypt/libmongocrypt/etc/rpm/libmongocrypt.spec +67 -0
- data/ext/libmongocrypt/libmongocrypt/etc/rpm/tweak.awk +19 -0
- data/ext/libmongocrypt/libmongocrypt/integrating.md +251 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/CMakeLists.txt +305 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/COPYING +177 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/README.md +41 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/THIRD_PARTY_NOTICES +42 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/LICENSE +202 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/NOTICE +2 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-key-duplicate/get-header-key-duplicate.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-key-duplicate/get-header-key-duplicate.creq +9 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-key-duplicate/get-header-key-duplicate.req +6 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-key-duplicate/get-header-key-duplicate.sreq +7 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-key-duplicate/get-header-key-duplicate.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-multiline/get-header-value-multiline.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-multiline/get-header-value-multiline.creq +9 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-multiline/get-header-value-multiline.req +6 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-multiline/get-header-value-multiline.sreq +7 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-multiline/get-header-value-multiline.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-order/get-header-value-order.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-order/get-header-value-order.creq +9 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-order/get-header-value-order.req +7 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-order/get-header-value-order.sreq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-order/get-header-value-order.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-trim/get-header-value-trim.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-trim/get-header-value-trim.creq +10 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-trim/get-header-value-trim.req +5 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-trim/get-header-value-trim.sreq +6 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-header-value-trim/get-header-value-trim.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-unreserved/get-unreserved.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-unreserved/get-unreserved.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-unreserved/get-unreserved.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-unreserved/get-unreserved.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-unreserved/get-unreserved.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-utf8/get-utf8.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-utf8/get-utf8.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-utf8/get-utf8.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-utf8/get-utf8.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-utf8/get-utf8.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla/get-vanilla.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla/get-vanilla.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla/get-vanilla.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla/get-vanilla.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla/get-vanilla.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-empty-query-key/get-vanilla-empty-query-key.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-empty-query-key/get-vanilla-empty-query-key.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-empty-query-key/get-vanilla-empty-query-key.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-empty-query-key/get-vanilla-empty-query-key.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-empty-query-key/get-vanilla-empty-query-key.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query/get-vanilla-query.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query/get-vanilla-query.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query/get-vanilla-query.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query/get-vanilla-query.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query/get-vanilla-query.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-key/get-vanilla-query-order-key.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-key/get-vanilla-query-order-key.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-key/get-vanilla-query-order-key.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-key/get-vanilla-query-order-key.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-key/get-vanilla-query-order-key.sts +4 -0
- 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
- 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
- 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
- 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
- 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
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-value/get-vanilla-query-order-value.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-value/get-vanilla-query-order-value.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-value/get-vanilla-query-order-value.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-value/get-vanilla-query-order-value.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-order-value/get-vanilla-query-order-value.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-unreserved/get-vanilla-query-unreserved.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-unreserved/get-vanilla-query-unreserved.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-unreserved/get-vanilla-query-unreserved.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-unreserved/get-vanilla-query-unreserved.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-query-unreserved/get-vanilla-query-unreserved.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-utf8-query/get-vanilla-utf8-query.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-utf8-query/get-vanilla-utf8-query.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-utf8-query/get-vanilla-utf8-query.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-utf8-query/get-vanilla-utf8-query.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/get-vanilla-utf8-query/get-vanilla-utf8-query.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative/get-relative.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative/get-relative.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative/get-relative.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative/get-relative.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative/get-relative.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative-relative/get-relative-relative.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative-relative/get-relative-relative.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative-relative/get-relative-relative.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative-relative/get-relative-relative.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-relative-relative/get-relative-relative.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash/get-slash.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash/get-slash.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash/get-slash.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash/get-slash.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash/get-slash.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-dot-slash/get-slash-dot-slash.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-dot-slash/get-slash-dot-slash.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-dot-slash/get-slash-dot-slash.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-dot-slash/get-slash-dot-slash.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-dot-slash/get-slash-dot-slash.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-pointless-dot/get-slash-pointless-dot.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-pointless-dot/get-slash-pointless-dot.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-pointless-dot/get-slash-pointless-dot.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-pointless-dot/get-slash-pointless-dot.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slash-pointless-dot/get-slash-pointless-dot.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slashes/get-slashes.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slashes/get-slashes.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slashes/get-slashes.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slashes/get-slashes.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-slashes/get-slashes.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-space/get-space.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-space/get-space.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-space/get-space.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-space/get-space.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/get-space/get-space.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/normalize-path/normalize-path.txt +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-case/post-header-key-case.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-case/post-header-key-case.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-case/post-header-key-case.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-case/post-header-key-case.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-case/post-header-key-case.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-sort/post-header-key-sort.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-sort/post-header-key-sort.creq +9 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-sort/post-header-key-sort.req +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-sort/post-header-key-sort.sreq +5 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-key-sort/post-header-key-sort.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-value-case/post-header-value-case.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-value-case/post-header-value-case.creq +9 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-value-case/post-header-value-case.req +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-value-case/post-header-value-case.sreq +5 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-header-value-case/post-header-value-case.sts +4 -0
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-sts-token/readme.txt +15 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla/post-vanilla.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla/post-vanilla.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla/post-vanilla.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla/post-vanilla.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla/post-vanilla.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-empty-query-value/post-vanilla-empty-query-value.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-empty-query-value/post-vanilla-empty-query-value.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-empty-query-value/post-vanilla-empty-query-value.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-empty-query-value/post-vanilla-empty-query-value.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-empty-query-value/post-vanilla-empty-query-value.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-query/post-vanilla-query.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-query/post-vanilla-query.creq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-query/post-vanilla-query.req +3 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-query/post-vanilla-query.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-vanilla-query/post-vanilla-query.sts +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-x-www-form-urlencoded/post-x-www-form-urlencoded.authz +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-x-www-form-urlencoded/post-x-www-form-urlencoded.creq +9 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-x-www-form-urlencoded/post-x-www-form-urlencoded.req +6 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-x-www-form-urlencoded/post-x-www-form-urlencoded.sreq +7 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/aws-sig-v4-test-suite/post-x-www-form-urlencoded/post-x-www-form-urlencoded.sts +4 -0
- 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
- 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
- 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
- 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
- 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
- data/ext/libmongocrypt/libmongocrypt/kms-message/cmake/kms_message-config.cmake +1 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/cmake/libkms_message.pc.in +9 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/hexlify.c +67 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/hexlify.h +24 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_azure_request.c +219 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_b64.c +654 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_caller_identity_request.c +52 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_crypto.h +70 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_crypto_apple.c +159 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_crypto_libcrypto.c +142 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_crypto_none.c +65 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_crypto_windows.c +268 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_decrypt_request.c +72 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_encrypt_request.c +73 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_endian_private.h +165 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_gcp_request.c +286 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_item_type_private.h +59 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_reader_writer.c +502 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_reader_writer_private.h +150 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_request.c +256 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_response.c +323 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_response_parser.c +148 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_response_parser_private.h +55 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_result_reason_private.h +77 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_result_status_private.h +54 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_tag_type_private.h +343 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kv_list.c +149 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kv_list.h +56 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_azure_request.h +110 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_b64.h +70 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_caller_identity_request.h +36 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_decrypt_request.h +37 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_encrypt_request.h +39 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_gcp_request.h +124 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_kmip_request.h +58 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_kmip_response.h +40 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_kmip_response_parser.h +26 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_message.h +34 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_message_defines.h +72 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_request.h +103 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_request_opt.h +80 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_response.h +43 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_response_parser.h +64 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message.c +47 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message_private.h +142 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_port.c +33 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_port.h +34 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request.c +925 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_opt.c +88 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_opt_private.h +32 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_str.c +520 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_str.h +89 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_response.c +54 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_response_parser.c +408 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/sort.c +74 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/sort.h +21 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/connection_close/connection_close.sreq +5 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/content_length/content_length.sreq +7 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/decrypt/decrypt.creq +11 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/decrypt/decrypt.sreq +9 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/encrypt/encrypt.creq +11 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/encrypt/encrypt.sreq +9 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/example-chunked-response.bin +20 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/example-multi-chunked-response.bin +22 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/example-response.bin +6 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/host/host.sreq +4 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/multibyte/multibyte.creq +10 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/multibyte/multibyte.sreq +8 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kmip_reader_writer.c +485 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_assert.h +147 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_azure_online.c +260 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_gcp_online.c +250 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_kmip_request.c +223 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_kmip_response.c +214 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_kmip_response_parser.c +197 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_online_util.c +120 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_online_util.h +35 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_request.c +1302 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_util.c +92 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_util.h +45 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/windows/dirent.h +1224 -0
- data/ext/libmongocrypt/libmongocrypt/src/crypto/cng.c +640 -0
- data/ext/libmongocrypt/libmongocrypt/src/crypto/commoncrypto.c +326 -0
- data/ext/libmongocrypt/libmongocrypt/src/crypto/libcrypto.c +341 -0
- data/ext/libmongocrypt/libmongocrypt/src/crypto/none.c +97 -0
- data/ext/libmongocrypt/libmongocrypt/src/csfle-markup.cpp +237 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-array-private.h +54 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-array.c +102 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-check-conversions-private.h +36 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.h +743 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.test.cpp +86 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-efc-private.h +48 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +127 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle-blob-subtype-private.h +40 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +152 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +487 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private.h +47 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload.c +156 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private.h +95 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload.c +158 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private.h +124 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload.c +316 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private.h +179 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev.c +385 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-private.h +93 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev.c +269 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-range-operator-private.h +29 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds-private.h +91 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +658 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +124 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +161 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +242 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +128 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +620 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +308 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +112 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +341 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +99 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +382 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-reader-private.h +130 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-reader.c +235 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-tokens-private.h +118 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +151 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/check.hpp +89 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/endian.h +42 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/error.h +59 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.h +685 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.c +3 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +407 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/macros.h +53 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/path.h +381 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/path.test.c +93 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/str.h +1028 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/str.test.c +137 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/thread.h +88 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/user-check.h +4 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/windows-lean.h +19 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongo_crypt-v1.h +320 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary-private.h +34 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary.c +87 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer-private.h +236 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer.c +691 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo-private.h +24 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo.c +82 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key-private.h +55 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key.c +190 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth-private.h +46 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth.c +126 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-private.h +96 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache.c +341 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext-private.h +64 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext.c +212 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-compat.h +44 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-config.h.in +87 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto-private.h +303 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto.c +1850 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +534 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +773 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +3005 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-private.h +269 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-rewrap-many-datakey.c +415 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +1283 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +97 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endian-private.h +168 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint-private.h +64 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint.c +212 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek-private.h +109 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek.c +325 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker-private.h +209 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +1189 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-private.h +87 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key.c +473 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx-private.h +154 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx.c +1785 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log-private.h +111 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log.c +123 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking-private.h +74 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +1624 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-mutex-private.h +46 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +231 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +493 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +197 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status-private.h +39 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status.c +169 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util-private.h +59 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util.c +234 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util-private.h +84 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util.c +203 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +1605 -0
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +1610 -0
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +132 -0
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_mutex.c +57 -0
- data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +92 -0
- data/ext/libmongocrypt/libmongocrypt/src/os_win/os_mutex.c +45 -0
- data/ext/libmongocrypt/libmongocrypt/test/crypt_shared-stub.cpp +155 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/NIST-CAVP.cstructs +1350 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/aes-ctr.cstructs +359 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cache-tests.json +197 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/collection-info-no-schema.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/collection-info-no-validator.json +13 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/collection-info-view.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/collinfo-siblings.json +40 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/missing-key-id/collinfo.json +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-fields/collinfo.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-fields/encrypted-payload.json +4 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/cmd.json +1 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/collinfo.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-field-config-map.json +47 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-payload.json +23 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/mongocryptd-reply.json +72 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/omitted/cmd-to-mongocryptd.json +34 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/omitted/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/omitted/collinfo.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/omitted/encrypted-payload.json +39 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/omitted/mongocryptd-reply.json +45 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved/cmd-to-mongocryptd.json +34 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved/cmd.json +7 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved/collinfo.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved/encrypted-payload.json +40 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved/mongocryptd-reply.json +45 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_empty/cmd-to-mongocryptd.json +17 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_empty/cmd.json +7 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_empty/collinfo.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_empty/encrypted-payload.json +7 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_empty/mongocryptd-reply.json +23 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_fle1/cmd-to-mongocryptd.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_fle1/cmd.json +7 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_fle1/collinfo.json +25 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_fle1/encrypted-payload.json +14 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_fle1/mongocryptd-reply.json +15 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-extraField.json +24 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-missingKeyId.json +17 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-oneField.json +23 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-twoFields.json +39 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/encrypted-cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/encrypted-field-config-map.json +48 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decryption-input.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/find-with-encryptionInformation.json +16 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-collMod/cmd-to-mongocryptd.json +12 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-collMod/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-collMod/insert/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-collMod/insert/collinfo.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-collMod/mongocryptd-reply.json +14 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/old-mongocryptd/cmd.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/old-mongocryptd/encrypted-payload.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/old-mongocryptd/ismaster-to-mongocryptd.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/old-mongocryptd/mongocryptd-ismaster.json +12 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-cmd-schema/cmd-to-mongocryptd.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-cmd-schema/cmd.json +12 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-cmd-schema/encrypted-payload.json +12 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-cmd-schema/ismaster-to-mongocryptd.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-cmd-schema/mongocryptd-ismaster.json +12 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-cmd-schema/mongocryptd-reply.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-schema/cmd-to-mongocryptd.json +7 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-schema/cmd.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-schema/encrypted-payload.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-schema/ismaster-to-mongocryptd.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-schema/mongocryptd-ismaster.json +12 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-schema/mongocryptd-reply.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/with-schema/schema-map.json +5 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/without-schema/cmd-to-mongocryptd.json +5 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/without-schema/cmd.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/without-schema/encrypted-payload.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/without-schema/ismaster-to-mongocryptd.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/without-schema/mongocryptd-ismaster.json +12 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-create/without-schema/mongocryptd-reply.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-explain/with-csfle/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-explain/with-csfle/collinfo.json +7 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-explain/with-csfle/encrypted-payload.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-explain/with-mongocryptd/cmd-to-mongocryptd.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-explain/with-mongocryptd/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-explain/with-mongocryptd/collinfo.json +7 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-explain/with-mongocryptd/encrypted-payload.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle1-explain/with-mongocryptd/mongocryptd-reply.json +14 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-aead.cstructs +109 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create/cmd-to-mongocryptd.json +14 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create/cmd.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create/encrypted-field-config-map.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create/encrypted-payload.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create/ismaster-to-mongocryptd.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create/mongocryptd-ismaster.json +12 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create/mongocryptd-reply.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-decrypt-ieev/first-filter.json +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-decrypt-ieev/second-filter.json +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/collinfo.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/encrypted-field-config-map.json +47 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/encrypted-payload.json +91 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/mongocryptd-reply.json +66 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/collinfo.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/encrypted-field-config-map.json +47 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/encrypted-payload.json +98 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/mongocryptd-reply.json +72 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/collinfo.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/encrypted-payload.json +46 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-mongocryptd/cmd-to-mongocryptd.json +36 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-mongocryptd/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-mongocryptd/collinfo.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-mongocryptd/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-mongocryptd/mongocryptd-reply.json +47 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-contentionFactor1.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-contentionFactor1.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-same-user-and-index-key.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality/encrypted-field-map.json +23 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality/mongocryptd-reply.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-explicit/cmd-to-mongocryptd.json +24 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-explicit/cmd-to-mongod.json +24 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-explicit/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-explicit/reply-from-mongocryptd.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/README.md +2 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date/cmd.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date/encrypted-field-map.json +28 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date/encrypted-payload.json +42 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date/mongocryptd-reply.json +50 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128/encrypted-field-map.json +28 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128/encrypted-payload.json +42 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128/mongocryptd-reply.json +50 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision/encrypted-field-map.json +31 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision/encrypted-payload.json +51 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision/mongocryptd-reply.json +59 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double/encrypted-field-map.json +28 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double/encrypted-payload.json +42 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double/mongocryptd-reply.json +50 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision/encrypted-field-map.json +31 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision/encrypted-payload.json +45 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision/mongocryptd-reply.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32/encrypted-field-map.json +28 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32/encrypted-payload.json +42 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32/mongocryptd-reply.json +50 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64/encrypted-field-map.json +28 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64/encrypted-payload.json +42 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64/mongocryptd-reply.json +50 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/encrypted-payload.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/rangeopts.json +5 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/value-to-encrypt.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/encrypted-payload.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/rangeopts.json +14 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/value-to-encrypt.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/encrypted-payload.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/rangeopts.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/value-to-encrypt.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/rangeopts.json +5 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/value-to-encrypt.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/encrypted-payload.json +16 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/rangeopts.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/value-to-encrypt.json +13 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert/encrypted-field-map.json +23 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert/encrypted-payload.json +40 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert/mongocryptd-reply.json +50 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/README.md +2 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/RNG_DATA.h +67 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/cmd.json +13 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/encrypted-field-map.json +28 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/encrypted-payload.json +45 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/mongocryptd-reply.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/RNG_DATA.h +134 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/encrypted-field-map.json +28 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/encrypted-payload.json +45 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/mongocryptd-reply.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/RNG_DATA.h +73 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/encrypted-field-map.json +31 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/encrypted-payload.json +54 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/mongocryptd-reply.json +62 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/RNG_DATA.h +70 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/encrypted-field-map.json +28 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/encrypted-payload.json +45 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/mongocryptd-reply.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/RNG_DATA.h +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/encrypted-field-map.json +31 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/encrypted-payload.json +48 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/mongocryptd-reply.json +56 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/RNG_DATA.h +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/encrypted-field-map.json +28 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/encrypted-payload.json +45 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/mongocryptd-reply.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/RNG_DATA.h +67 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/encrypted-field-map.json +28 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/encrypted-payload.json +45 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/mongocryptd-reply.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/RNG_DATA.h +70 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/encrypted-payload.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/rangeopts.json +5 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/value-to-encrypt.json +5 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/RNG_DATA.h +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/encrypted-payload.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/rangeopts.json +14 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/value-to-encrypt.json +5 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/RNG_DATA.h +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/encrypted-payload.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/rangeopts.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/value-to-encrypt.json +5 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/RNG_DATA.h +70 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/rangeopts.json +5 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/value-to-encrypt.json +5 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/RNG_DATA.h +17 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/encrypted-payload.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/rangeopts.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/value-to-encrypt.json +5 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed/encrypted-field-map.json +23 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed/encrypted-payload.json +14 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed/mongocryptd-reply.json +46 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2.cstructs +33 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/gcp-auth/decrypt-response.txt +5 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/gcp-auth/encrypt-response.txt +5 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/gcp-auth/oauth-response.txt +5 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/kek-tests.json +169 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/key-document-azure.json +33 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/key-document-full.json +36 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/key-document-gcp.json +35 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/key-document-kmip.json +34 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/key-document-local.json +18 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/key-document-no-region.json +31 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/key-document-with-alt-name-duplicate-id.json +36 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/key-document-with-alt-name.json +33 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/key-document-with-alt-name2.json +33 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789012-aws-decrypt-reply.txt +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789012-aws-document.json +32 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789012-key-material.txt +1 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789012-local-document.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789013-aws-decrypt-reply.txt +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789013-aws-document.json +32 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789013-key-material.txt +1 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789013-local-document.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789014-key-material.txt +1 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/keys/12345678123498761234123456789014-local-document.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/keys/ABCDEFAB123498761234123456789012-aws-decrypt-reply.txt +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/keys/ABCDEFAB123498761234123456789012-aws-document.json +32 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/keys/ABCDEFAB123498761234123456789012-key-material.txt +1 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/keys/ABCDEFAB123498761234123456789012-local-document.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/keys/README.md +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/kms-encrypt-reply.txt +7 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/kms-tests.json +297 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/mongocryptd-cmd.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/mongocryptd-reply-existing-ciphertext.json +24 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/mongocryptd-reply-invalid.json +18 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/mongocryptd-reply-key-alt-name.json +18 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/mongocryptd-reply-key-alt-name2.json +18 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/mongocryptd-reply-no-encryption-needed.json +7 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/mongocryptd-reply-no-markings.json +7 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/mongocryptd-reply-random.json +18 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_decimal128.cstruct +14527 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_double.cstruct +7959 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_int32.cstruct +6906 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_int64.cstruct +9429 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_decimal128.cstruct +4565 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_decimal128_precision.cstruct +312 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_double.cstruct +3277 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_double_precision.cstruct +369 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_int32.cstruct +4612 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_int64.cstruct +3398 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/rmd/key-document-a.json +35 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/rmd/key-document-b.json +37 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/rmd/key-document-local.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/rmd/kms-decrypt-reply-a.txt +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/rmd/kms-decrypt-reply-b.txt +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/rmd/kms-encrypt-reply-a.txt +7 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/rmd/kms-encrypt-reply-b.txt +7 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/schema-map.json +40 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/schema.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/example/README.md +5 -0
- data/ext/libmongocrypt/libmongocrypt/test/example/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/example/collection-info.json +39 -0
- data/ext/libmongocrypt/libmongocrypt/test/example/encrypted-command.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/example/key-document-custom-endpoint.json +34 -0
- data/ext/libmongocrypt/libmongocrypt/test/example/key-document.json +33 -0
- data/ext/libmongocrypt/libmongocrypt/test/example/kms-decrypt-reply.txt +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/example/mongocryptd-reply.json +18 -0
- data/ext/libmongocrypt/libmongocrypt/test/example-no-bson.c +23 -0
- data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +368 -0
- data/ext/libmongocrypt/libmongocrypt/test/fuzz_kms.c +42 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-dll.cpp +22 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-gcp-auth.c +312 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-efc.c +104 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev.c +443 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup.c +184 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev.c +200 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-rfds.c +518 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-edge-generation.c +468 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +886 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +609 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +174 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-reader.c +251 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +245 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +1079 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.h +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert.h +218 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-buffer.c +266 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache-oauth.c +57 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache.c +264 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ciphertext.c +259 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-compact.c +478 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +917 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +177 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.h +110 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto.c +892 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-csfle-lib.c +208 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-decrypt.c +1134 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +5096 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +1061 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +1301 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +489 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-dll.c +48 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-endpoint.c +138 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kek.c +104 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-broker.c +1174 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-cache.c +475 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key.c +282 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-ctx.c +561 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-responses.c +206 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-local-kms.c +89 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-log.c +137 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-marking.c +738 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-status.c +88 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-traverse-util.c +548 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.c +105 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.h +42 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +1060 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +290 -0
- data/ext/libmongocrypt/libmongocrypt/test/util/HELP.autogen +102 -0
- data/ext/libmongocrypt/libmongocrypt/test/util/README.md +103 -0
- data/ext/libmongocrypt/libmongocrypt/test/util/csfle.c +612 -0
- data/ext/libmongocrypt/libmongocrypt/test/util/helpgen.py +7 -0
- data/ext/libmongocrypt/libmongocrypt/test/util/make_includes.py +845 -0
- data/ext/libmongocrypt/libmongocrypt/test/util/util.c +969 -0
- data/ext/libmongocrypt/libmongocrypt/test/util/util.h +96 -0
- data/ext/libmongocrypt/libmongocrypt/third-party/IntelRDFPMathLib20U2.tar.xz +0 -0
- data/lib/libmongocrypt_helper/version.rb +2 -2
- data/lib/libmongocrypt_helper.rb +13 -1
- data.tar.gz.sig +0 -0
- metadata +988 -6
- metadata.gz.sig +0 -0
- data/so/libmongocrypt.so +0 -0
@@ -0,0 +1,3005 @@
|
|
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
|
+
#include "mongocrypt-ciphertext-private.h"
|
18
|
+
#include "mongocrypt-crypto-private.h"
|
19
|
+
#include "mongocrypt-ctx-private.h"
|
20
|
+
#include "mongocrypt-key-broker-private.h"
|
21
|
+
#include "mongocrypt-marking-private.h"
|
22
|
+
#include "mongocrypt-traverse-util-private.h"
|
23
|
+
#include "mc-fle2-rfds-private.h"
|
24
|
+
#include "mc-tokens-private.h"
|
25
|
+
#include "mongocrypt-util-private.h" // mc_iter_document_as_bson
|
26
|
+
|
27
|
+
/* _fle2_append_encryptedFieldConfig copies encryptedFieldConfig and applies
|
28
|
+
* default state collection names for escCollection, eccCollection, and
|
29
|
+
* ecocCollection if required. */
|
30
|
+
static bool
|
31
|
+
_fle2_append_encryptedFieldConfig (bson_t *dst,
|
32
|
+
bson_t *encryptedFieldConfig,
|
33
|
+
const char *coll_name,
|
34
|
+
mongocrypt_status_t *status)
|
35
|
+
{
|
36
|
+
bson_iter_t iter;
|
37
|
+
bool has_escCollection = false;
|
38
|
+
bool has_eccCollection = false;
|
39
|
+
bool has_ecocCollection = false;
|
40
|
+
|
41
|
+
BSON_ASSERT_PARAM (dst);
|
42
|
+
BSON_ASSERT_PARAM (encryptedFieldConfig);
|
43
|
+
BSON_ASSERT_PARAM (coll_name);
|
44
|
+
|
45
|
+
if (!bson_iter_init (&iter, encryptedFieldConfig)) {
|
46
|
+
CLIENT_ERR ("unable to iterate encryptedFieldConfig");
|
47
|
+
return false;
|
48
|
+
}
|
49
|
+
|
50
|
+
while (bson_iter_next (&iter)) {
|
51
|
+
if (strcmp (bson_iter_key (&iter), "escCollection") == 0) {
|
52
|
+
has_escCollection = true;
|
53
|
+
}
|
54
|
+
if (strcmp (bson_iter_key (&iter), "eccCollection") == 0) {
|
55
|
+
has_eccCollection = true;
|
56
|
+
}
|
57
|
+
if (strcmp (bson_iter_key (&iter), "ecocCollection") == 0) {
|
58
|
+
has_ecocCollection = true;
|
59
|
+
}
|
60
|
+
if (!BSON_APPEND_VALUE (
|
61
|
+
dst, bson_iter_key (&iter), bson_iter_value (&iter))) {
|
62
|
+
CLIENT_ERR ("unable to append field: %s", bson_iter_key (&iter));
|
63
|
+
return false;
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
if (!has_escCollection) {
|
68
|
+
char *default_escCollection =
|
69
|
+
bson_strdup_printf ("enxcol_.%s.esc", coll_name);
|
70
|
+
if (!BSON_APPEND_UTF8 (dst, "escCollection", default_escCollection)) {
|
71
|
+
CLIENT_ERR ("unable to append escCollection");
|
72
|
+
bson_free (default_escCollection);
|
73
|
+
return false;
|
74
|
+
}
|
75
|
+
bson_free (default_escCollection);
|
76
|
+
}
|
77
|
+
if (!has_eccCollection) {
|
78
|
+
char *default_eccCollection =
|
79
|
+
bson_strdup_printf ("enxcol_.%s.ecc", coll_name);
|
80
|
+
if (!BSON_APPEND_UTF8 (dst, "eccCollection", default_eccCollection)) {
|
81
|
+
CLIENT_ERR ("unable to append eccCollection");
|
82
|
+
bson_free (default_eccCollection);
|
83
|
+
return false;
|
84
|
+
}
|
85
|
+
bson_free (default_eccCollection);
|
86
|
+
}
|
87
|
+
if (!has_ecocCollection) {
|
88
|
+
char *default_ecocCollection =
|
89
|
+
bson_strdup_printf ("enxcol_.%s.ecoc", coll_name);
|
90
|
+
if (!BSON_APPEND_UTF8 (dst, "ecocCollection", default_ecocCollection)) {
|
91
|
+
CLIENT_ERR ("unable to append ecocCollection");
|
92
|
+
bson_free (default_ecocCollection);
|
93
|
+
return false;
|
94
|
+
}
|
95
|
+
bson_free (default_ecocCollection);
|
96
|
+
}
|
97
|
+
return true;
|
98
|
+
}
|
99
|
+
|
100
|
+
static bool
|
101
|
+
_fle2_append_encryptionInformation (bson_t *dst,
|
102
|
+
const char *ns,
|
103
|
+
bson_t *encryptedFieldConfig,
|
104
|
+
bson_t *deleteTokens,
|
105
|
+
const char *coll_name,
|
106
|
+
mongocrypt_status_t *status)
|
107
|
+
{
|
108
|
+
bson_t encryption_information_bson;
|
109
|
+
bson_t schema_bson;
|
110
|
+
bson_t encrypted_field_config_bson;
|
111
|
+
|
112
|
+
BSON_ASSERT_PARAM (dst);
|
113
|
+
BSON_ASSERT_PARAM (ns);
|
114
|
+
BSON_ASSERT_PARAM (encryptedFieldConfig);
|
115
|
+
/* deleteTokens may be NULL */
|
116
|
+
BSON_ASSERT_PARAM (coll_name);
|
117
|
+
|
118
|
+
if (!BSON_APPEND_DOCUMENT_BEGIN (
|
119
|
+
dst, "encryptionInformation", &encryption_information_bson)) {
|
120
|
+
CLIENT_ERR ("unable to begin appending 'encryptionInformation'");
|
121
|
+
return false;
|
122
|
+
}
|
123
|
+
if (!BSON_APPEND_INT32 (&encryption_information_bson, "type", 1)) {
|
124
|
+
CLIENT_ERR ("unable to append type to 'encryptionInformation'");
|
125
|
+
return false;
|
126
|
+
}
|
127
|
+
if (!BSON_APPEND_DOCUMENT_BEGIN (
|
128
|
+
&encryption_information_bson, "schema", &schema_bson)) {
|
129
|
+
CLIENT_ERR (
|
130
|
+
"unable to begin appending 'schema' to 'encryptionInformation'");
|
131
|
+
return false;
|
132
|
+
}
|
133
|
+
|
134
|
+
if (!BSON_APPEND_DOCUMENT_BEGIN (
|
135
|
+
&schema_bson, ns, &encrypted_field_config_bson)) {
|
136
|
+
CLIENT_ERR ("unable to begin appending 'encryptedFieldConfig' to "
|
137
|
+
"'encryptionInformation'.'schema'");
|
138
|
+
return false;
|
139
|
+
}
|
140
|
+
|
141
|
+
if (!_fle2_append_encryptedFieldConfig (&encrypted_field_config_bson,
|
142
|
+
encryptedFieldConfig,
|
143
|
+
coll_name,
|
144
|
+
status)) {
|
145
|
+
return false;
|
146
|
+
}
|
147
|
+
|
148
|
+
if (!bson_append_document_end (&schema_bson, &encrypted_field_config_bson)) {
|
149
|
+
CLIENT_ERR ("unable to end appending 'encryptedFieldConfig' to "
|
150
|
+
"'encryptionInformation'.'schema'");
|
151
|
+
return false;
|
152
|
+
}
|
153
|
+
if (!bson_append_document_end (&encryption_information_bson, &schema_bson)) {
|
154
|
+
CLIENT_ERR (
|
155
|
+
"unable to end appending 'schema' to 'encryptionInformation'");
|
156
|
+
return false;
|
157
|
+
}
|
158
|
+
|
159
|
+
if (deleteTokens != NULL) {
|
160
|
+
bson_t delete_tokens_bson;
|
161
|
+
if (!BSON_APPEND_DOCUMENT_BEGIN (&encryption_information_bson,
|
162
|
+
"deleteTokens",
|
163
|
+
&delete_tokens_bson)) {
|
164
|
+
CLIENT_ERR ("unable to begin appending 'deleteTokens' to "
|
165
|
+
"'encryptionInformation'");
|
166
|
+
return false;
|
167
|
+
}
|
168
|
+
if (!BSON_APPEND_DOCUMENT (&delete_tokens_bson, ns, deleteTokens)) {
|
169
|
+
CLIENT_ERR ("unable to append '%s' to 'deleteTokens'", ns);
|
170
|
+
return false;
|
171
|
+
}
|
172
|
+
if (!bson_append_document_end (&encryption_information_bson,
|
173
|
+
&delete_tokens_bson)) {
|
174
|
+
CLIENT_ERR ("unable to end appending 'deleteTokens' to "
|
175
|
+
"'encryptionInformation'");
|
176
|
+
return false;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
if (!bson_append_document_end (dst, &encryption_information_bson)) {
|
181
|
+
CLIENT_ERR ("unable to end appending 'encryptionInformation'");
|
182
|
+
return false;
|
183
|
+
}
|
184
|
+
return true;
|
185
|
+
}
|
186
|
+
|
187
|
+
typedef enum { MC_TO_CSFLE, MC_TO_MONGOCRYPTD, MC_TO_MONGOD } mc_cmd_target_t;
|
188
|
+
|
189
|
+
/**
|
190
|
+
* @brief Add "encryptionInformation" to a command.
|
191
|
+
*
|
192
|
+
* @param cmd_name The name of the command.
|
193
|
+
* @param cmd The command being rewritten. It is an input and output.
|
194
|
+
* @param ns The <db>.<collection> namespace for the command.
|
195
|
+
* @param encryptedFieldConfig The "encryptedFields" document for the
|
196
|
+
* collection.
|
197
|
+
* @param deleteTokens Delete tokens to append to "encryptionInformation". May
|
198
|
+
* be NULL.
|
199
|
+
* @param coll_name The collection name.
|
200
|
+
* @param cmd_target The intended destination of the command. csfle,
|
201
|
+
* mongocryptd, and mongod have different requirements for the location of
|
202
|
+
* "encryptionInformation".
|
203
|
+
* @param status Output status.
|
204
|
+
* @return true On success
|
205
|
+
* @return false Otherwise. Sets a failing status message in this case.
|
206
|
+
*/
|
207
|
+
static bool
|
208
|
+
_fle2_insert_encryptionInformation (const char *cmd_name,
|
209
|
+
bson_t *cmd /* in and out */,
|
210
|
+
const char *ns,
|
211
|
+
bson_t *encryptedFieldConfig,
|
212
|
+
bson_t *deleteTokens,
|
213
|
+
const char *coll_name,
|
214
|
+
mc_cmd_target_t cmd_target,
|
215
|
+
mongocrypt_status_t *status)
|
216
|
+
{
|
217
|
+
bson_t out = BSON_INITIALIZER;
|
218
|
+
bson_t explain = BSON_INITIALIZER;
|
219
|
+
bson_iter_t iter;
|
220
|
+
bool ok = false;
|
221
|
+
|
222
|
+
BSON_ASSERT_PARAM (cmd_name);
|
223
|
+
BSON_ASSERT_PARAM (cmd);
|
224
|
+
BSON_ASSERT_PARAM (ns);
|
225
|
+
BSON_ASSERT_PARAM (encryptedFieldConfig);
|
226
|
+
/* deleteTokens may be NULL */
|
227
|
+
BSON_ASSERT_PARAM (coll_name);
|
228
|
+
|
229
|
+
if (0 != strcmp (cmd_name, "explain") || cmd_target == MC_TO_MONGOCRYPTD) {
|
230
|
+
// All commands except "explain" expect "encryptionInformation"
|
231
|
+
// at top-level. "explain" sent to mongocryptd expects
|
232
|
+
// "encryptionInformation" at top-level.
|
233
|
+
if (!_fle2_append_encryptionInformation (
|
234
|
+
cmd, ns, encryptedFieldConfig, deleteTokens, coll_name, status)) {
|
235
|
+
goto fail;
|
236
|
+
}
|
237
|
+
goto success;
|
238
|
+
}
|
239
|
+
|
240
|
+
// The "explain" command for csfle is a special case.
|
241
|
+
// mongocryptd expects "encryptionInformation" to be a sibling of the
|
242
|
+
// "explain" document. Example:
|
243
|
+
// {
|
244
|
+
// "explain": { "find": "to-mongocryptd" },
|
245
|
+
// "encryptionInformation": {}
|
246
|
+
// }
|
247
|
+
// csfle and mongod expect "encryptionInformation" to be nested in the
|
248
|
+
// "explain" document. Example:
|
249
|
+
// {
|
250
|
+
// "explain": {
|
251
|
+
// "find": "to-csfle-or-mongod"
|
252
|
+
// "encryptionInformation": {}
|
253
|
+
// }
|
254
|
+
// }
|
255
|
+
BSON_ASSERT (bson_iter_init_find (&iter, cmd, "explain"));
|
256
|
+
if (!BSON_ITER_HOLDS_DOCUMENT (&iter)) {
|
257
|
+
CLIENT_ERR ("expected 'explain' to be document");
|
258
|
+
goto fail;
|
259
|
+
}
|
260
|
+
|
261
|
+
{
|
262
|
+
bson_t tmp;
|
263
|
+
if (!mc_iter_document_as_bson (&iter, &tmp, status)) {
|
264
|
+
goto fail;
|
265
|
+
}
|
266
|
+
bson_copy_to (&tmp, &explain);
|
267
|
+
}
|
268
|
+
|
269
|
+
if (!_fle2_append_encryptionInformation (&explain,
|
270
|
+
ns,
|
271
|
+
encryptedFieldConfig,
|
272
|
+
deleteTokens,
|
273
|
+
coll_name,
|
274
|
+
status)) {
|
275
|
+
goto fail;
|
276
|
+
}
|
277
|
+
|
278
|
+
if (!BSON_APPEND_DOCUMENT (&out, "explain", &explain)) {
|
279
|
+
CLIENT_ERR ("unable to append 'explain' document");
|
280
|
+
goto fail;
|
281
|
+
}
|
282
|
+
|
283
|
+
bson_copy_to_excluding_noinit (cmd, &out, "explain", NULL);
|
284
|
+
bson_destroy (cmd);
|
285
|
+
if (!bson_steal (cmd, &out)) {
|
286
|
+
CLIENT_ERR ("failed to steal BSON without encryptionInformation");
|
287
|
+
goto fail;
|
288
|
+
}
|
289
|
+
|
290
|
+
success:
|
291
|
+
ok = true;
|
292
|
+
fail:
|
293
|
+
bson_destroy (&explain);
|
294
|
+
if (!ok) {
|
295
|
+
bson_destroy (&out);
|
296
|
+
}
|
297
|
+
return ok;
|
298
|
+
}
|
299
|
+
|
300
|
+
/* Construct the list collections command to send. */
|
301
|
+
static bool
|
302
|
+
_mongo_op_collinfo (mongocrypt_ctx_t *ctx, mongocrypt_binary_t *out)
|
303
|
+
{
|
304
|
+
_mongocrypt_ctx_encrypt_t *ectx;
|
305
|
+
bson_t *cmd;
|
306
|
+
|
307
|
+
BSON_ASSERT_PARAM (ctx);
|
308
|
+
BSON_ASSERT_PARAM (out);
|
309
|
+
|
310
|
+
ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
311
|
+
cmd = BCON_NEW ("name", BCON_UTF8 (ectx->coll_name));
|
312
|
+
CRYPT_TRACEF (&ectx->parent.crypt->log, "constructed: %s\n", tmp_json (cmd));
|
313
|
+
_mongocrypt_buffer_steal_from_bson (&ectx->list_collections_filter, cmd);
|
314
|
+
out->data = ectx->list_collections_filter.data;
|
315
|
+
out->len = ectx->list_collections_filter.len;
|
316
|
+
return true;
|
317
|
+
}
|
318
|
+
|
319
|
+
static bool
|
320
|
+
_set_schema_from_collinfo (mongocrypt_ctx_t *ctx, bson_t *collinfo)
|
321
|
+
{
|
322
|
+
bson_iter_t iter;
|
323
|
+
_mongocrypt_ctx_encrypt_t *ectx;
|
324
|
+
bool found_jsonschema = false;
|
325
|
+
|
326
|
+
BSON_ASSERT_PARAM (ctx);
|
327
|
+
BSON_ASSERT_PARAM (collinfo);
|
328
|
+
|
329
|
+
/* Parse out the schema. */
|
330
|
+
ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
331
|
+
|
332
|
+
/* Disallow views. */
|
333
|
+
if (bson_iter_init_find (&iter, collinfo, "type") &&
|
334
|
+
BSON_ITER_HOLDS_UTF8 (&iter) && bson_iter_utf8 (&iter, NULL) &&
|
335
|
+
0 == strcmp ("view", bson_iter_utf8 (&iter, NULL))) {
|
336
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "cannot auto encrypt a view");
|
337
|
+
}
|
338
|
+
|
339
|
+
if (!bson_iter_init (&iter, collinfo)) {
|
340
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "BSON malformed");
|
341
|
+
}
|
342
|
+
|
343
|
+
if (bson_iter_find_descendant (&iter, "options.encryptedFields", &iter)) {
|
344
|
+
if (!BSON_ITER_HOLDS_DOCUMENT (&iter)) {
|
345
|
+
return _mongocrypt_ctx_fail_w_msg (
|
346
|
+
ctx, "options.encryptedFields is not a BSON document");
|
347
|
+
}
|
348
|
+
if (!_mongocrypt_buffer_copy_from_document_iter (
|
349
|
+
&ectx->encrypted_field_config, &iter)) {
|
350
|
+
return _mongocrypt_ctx_fail_w_msg (
|
351
|
+
ctx, "unable to copy options.encryptedFields");
|
352
|
+
}
|
353
|
+
bson_t efc_bson;
|
354
|
+
if (!_mongocrypt_buffer_to_bson (&ectx->encrypted_field_config,
|
355
|
+
&efc_bson)) {
|
356
|
+
return _mongocrypt_ctx_fail_w_msg (
|
357
|
+
ctx, "unable to create BSON from encrypted_field_config");
|
358
|
+
}
|
359
|
+
if (!mc_EncryptedFieldConfig_parse (&ectx->efc, &efc_bson, ctx->status)) {
|
360
|
+
_mongocrypt_ctx_fail (ctx);
|
361
|
+
return false;
|
362
|
+
}
|
363
|
+
}
|
364
|
+
|
365
|
+
BSON_ASSERT (bson_iter_init (&iter, collinfo));
|
366
|
+
|
367
|
+
if (bson_iter_find_descendant (&iter, "options.validator", &iter) &&
|
368
|
+
BSON_ITER_HOLDS_DOCUMENT (&iter)) {
|
369
|
+
if (!bson_iter_recurse (&iter, &iter)) {
|
370
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "BSON malformed");
|
371
|
+
}
|
372
|
+
while (bson_iter_next (&iter)) {
|
373
|
+
const char *key;
|
374
|
+
|
375
|
+
key = bson_iter_key (&iter);
|
376
|
+
BSON_ASSERT (key);
|
377
|
+
if (0 == strcmp ("$jsonSchema", key)) {
|
378
|
+
if (found_jsonschema) {
|
379
|
+
return _mongocrypt_ctx_fail_w_msg (
|
380
|
+
ctx, "duplicate $jsonSchema fields found");
|
381
|
+
}
|
382
|
+
if (!_mongocrypt_buffer_copy_from_document_iter (&ectx->schema,
|
383
|
+
&iter)) {
|
384
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "malformed $jsonSchema");
|
385
|
+
}
|
386
|
+
found_jsonschema = true;
|
387
|
+
} else {
|
388
|
+
ectx->collinfo_has_siblings = true;
|
389
|
+
}
|
390
|
+
}
|
391
|
+
}
|
392
|
+
|
393
|
+
if (!found_jsonschema) {
|
394
|
+
bson_t empty = BSON_INITIALIZER;
|
395
|
+
|
396
|
+
_mongocrypt_buffer_steal_from_bson (&ectx->schema, &empty);
|
397
|
+
}
|
398
|
+
|
399
|
+
|
400
|
+
return true;
|
401
|
+
}
|
402
|
+
|
403
|
+
/* get_command_name returns the name of a command. The command name is the first
|
404
|
+
* field. For example, the command name of: {"find": "foo", "filter": {"bar":
|
405
|
+
* 1}} is "find". */
|
406
|
+
static const char *
|
407
|
+
get_command_name (_mongocrypt_buffer_t *cmd, mongocrypt_status_t *status)
|
408
|
+
{
|
409
|
+
bson_t cmd_bson;
|
410
|
+
bson_iter_t iter;
|
411
|
+
const char *cmd_name;
|
412
|
+
|
413
|
+
BSON_ASSERT_PARAM (cmd);
|
414
|
+
|
415
|
+
if (!_mongocrypt_buffer_to_bson (cmd, &cmd_bson)) {
|
416
|
+
CLIENT_ERR ("unable to convert command buffer to BSON");
|
417
|
+
return NULL;
|
418
|
+
}
|
419
|
+
|
420
|
+
if (!bson_iter_init (&iter, &cmd_bson)) {
|
421
|
+
CLIENT_ERR ("unable to iterate over command BSON");
|
422
|
+
return NULL;
|
423
|
+
}
|
424
|
+
|
425
|
+
/* The command name is the first key. */
|
426
|
+
if (!bson_iter_next (&iter)) {
|
427
|
+
CLIENT_ERR ("unexpected empty BSON for command");
|
428
|
+
return NULL;
|
429
|
+
}
|
430
|
+
|
431
|
+
cmd_name = bson_iter_key (&iter);
|
432
|
+
if (!cmd_name) {
|
433
|
+
CLIENT_ERR ("unable to get command name from BSON");
|
434
|
+
return NULL;
|
435
|
+
}
|
436
|
+
return cmd_name;
|
437
|
+
}
|
438
|
+
|
439
|
+
static bool
|
440
|
+
command_needs_deleteTokens (const char *command_name)
|
441
|
+
{
|
442
|
+
const char *cmds_needing_deleteTokens[] = {
|
443
|
+
"delete", "update", "findAndModify"};
|
444
|
+
|
445
|
+
BSON_ASSERT_PARAM (command_name);
|
446
|
+
|
447
|
+
size_t i;
|
448
|
+
for (i = 0; i < sizeof (cmds_needing_deleteTokens) /
|
449
|
+
sizeof (cmds_needing_deleteTokens[0]);
|
450
|
+
i++) {
|
451
|
+
if (0 == strcmp (cmds_needing_deleteTokens[i], command_name)) {
|
452
|
+
return true;
|
453
|
+
}
|
454
|
+
}
|
455
|
+
return false;
|
456
|
+
}
|
457
|
+
|
458
|
+
/* context_uses_fle2 returns true if the context uses FLE 2 behavior.
|
459
|
+
* If a collection has an encryptedFields document, it uses FLE 2.
|
460
|
+
*/
|
461
|
+
static bool
|
462
|
+
context_uses_fle2 (mongocrypt_ctx_t *ctx)
|
463
|
+
{
|
464
|
+
_mongocrypt_ctx_encrypt_t *ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
465
|
+
|
466
|
+
BSON_ASSERT_PARAM (ctx);
|
467
|
+
|
468
|
+
return !_mongocrypt_buffer_empty (&ectx->encrypted_field_config);
|
469
|
+
}
|
470
|
+
|
471
|
+
/* _fle2_collect_keys_for_deleteTokens requests keys required to produce
|
472
|
+
* deleteTokens. deleteTokens is only applicable to FLE 2. */
|
473
|
+
static bool
|
474
|
+
_fle2_collect_keys_for_deleteTokens (mongocrypt_ctx_t *ctx)
|
475
|
+
{
|
476
|
+
_mongocrypt_ctx_encrypt_t *ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
477
|
+
|
478
|
+
BSON_ASSERT_PARAM (ctx);
|
479
|
+
|
480
|
+
/* deleteTokens are only appended for FLE 2. */
|
481
|
+
if (!context_uses_fle2 (ctx)) {
|
482
|
+
return true;
|
483
|
+
}
|
484
|
+
|
485
|
+
const char *cmd_name = ectx->cmd_name;
|
486
|
+
|
487
|
+
if (!command_needs_deleteTokens (cmd_name)) {
|
488
|
+
/* Command does not require deleteTokens. */
|
489
|
+
return true;
|
490
|
+
}
|
491
|
+
|
492
|
+
mc_EncryptedField_t *field;
|
493
|
+
|
494
|
+
for (field = ectx->efc.fields; field != NULL; field = field->next) {
|
495
|
+
if (field->has_queries) {
|
496
|
+
if (!_mongocrypt_key_broker_request_id (&ctx->kb, &field->keyId)) {
|
497
|
+
_mongocrypt_key_broker_status (&ctx->kb, ctx->status);
|
498
|
+
_mongocrypt_ctx_fail (ctx);
|
499
|
+
return false;
|
500
|
+
}
|
501
|
+
}
|
502
|
+
}
|
503
|
+
return true;
|
504
|
+
}
|
505
|
+
|
506
|
+
/* _fle2_collect_keys_for_compact requests keys required to produce
|
507
|
+
* compactionTokens. compactionTokens is only applicable to FLE 2. */
|
508
|
+
static bool
|
509
|
+
_fle2_collect_keys_for_compact (mongocrypt_ctx_t *ctx)
|
510
|
+
{
|
511
|
+
_mongocrypt_ctx_encrypt_t *ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
512
|
+
|
513
|
+
BSON_ASSERT_PARAM (ctx);
|
514
|
+
|
515
|
+
/* compactionTokens are only appended for FLE 2. */
|
516
|
+
if (!context_uses_fle2 (ctx)) {
|
517
|
+
return true;
|
518
|
+
}
|
519
|
+
|
520
|
+
const char *cmd_name = ectx->cmd_name;
|
521
|
+
|
522
|
+
if (0 != strcmp (cmd_name, "compactStructuredEncryptionData")) {
|
523
|
+
return true;
|
524
|
+
}
|
525
|
+
|
526
|
+
/* compactStructuredEncryptionData must not be sent to mongocryptd. */
|
527
|
+
ectx->bypass_query_analysis = true;
|
528
|
+
|
529
|
+
mc_EncryptedField_t *field;
|
530
|
+
|
531
|
+
for (field = ectx->efc.fields; field != NULL; field = field->next) {
|
532
|
+
if (!_mongocrypt_key_broker_request_id (&ctx->kb, &field->keyId)) {
|
533
|
+
_mongocrypt_key_broker_status (&ctx->kb, ctx->status);
|
534
|
+
_mongocrypt_ctx_fail (ctx);
|
535
|
+
return false;
|
536
|
+
}
|
537
|
+
}
|
538
|
+
return true;
|
539
|
+
}
|
540
|
+
|
541
|
+
static bool
|
542
|
+
_mongo_feed_collinfo (mongocrypt_ctx_t *ctx, mongocrypt_binary_t *in)
|
543
|
+
{
|
544
|
+
bson_t as_bson;
|
545
|
+
|
546
|
+
_mongocrypt_ctx_encrypt_t *ectx;
|
547
|
+
|
548
|
+
BSON_ASSERT_PARAM (ctx);
|
549
|
+
BSON_ASSERT_PARAM (in);
|
550
|
+
|
551
|
+
ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
552
|
+
if (!bson_init_static (&as_bson, in->data, in->len)) {
|
553
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "BSON malformed");
|
554
|
+
}
|
555
|
+
|
556
|
+
/* Cache the received collinfo. */
|
557
|
+
if (!_mongocrypt_cache_add_copy (
|
558
|
+
&ctx->crypt->cache_collinfo, ectx->ns, &as_bson, ctx->status)) {
|
559
|
+
return _mongocrypt_ctx_fail (ctx);
|
560
|
+
}
|
561
|
+
|
562
|
+
if (!_set_schema_from_collinfo (ctx, &as_bson)) {
|
563
|
+
return false;
|
564
|
+
}
|
565
|
+
|
566
|
+
return true;
|
567
|
+
}
|
568
|
+
|
569
|
+
static bool
|
570
|
+
_try_run_csfle_marking (mongocrypt_ctx_t *ctx);
|
571
|
+
|
572
|
+
static bool
|
573
|
+
_mongo_done_collinfo (mongocrypt_ctx_t *ctx)
|
574
|
+
{
|
575
|
+
_mongocrypt_ctx_encrypt_t *ectx;
|
576
|
+
|
577
|
+
BSON_ASSERT_PARAM (ctx);
|
578
|
+
|
579
|
+
ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
580
|
+
if (_mongocrypt_buffer_empty (&ectx->schema)) {
|
581
|
+
bson_t empty_collinfo = BSON_INITIALIZER;
|
582
|
+
|
583
|
+
/* If no collinfo was fed, cache an empty collinfo. */
|
584
|
+
if (!_mongocrypt_cache_add_copy (&ctx->crypt->cache_collinfo,
|
585
|
+
ectx->ns,
|
586
|
+
&empty_collinfo,
|
587
|
+
ctx->status)) {
|
588
|
+
bson_destroy (&empty_collinfo);
|
589
|
+
return _mongocrypt_ctx_fail (ctx);
|
590
|
+
}
|
591
|
+
bson_destroy (&empty_collinfo);
|
592
|
+
}
|
593
|
+
|
594
|
+
if (!_fle2_collect_keys_for_deleteTokens (ctx)) {
|
595
|
+
return false;
|
596
|
+
}
|
597
|
+
|
598
|
+
if (!_fle2_collect_keys_for_compact (ctx)) {
|
599
|
+
return false;
|
600
|
+
}
|
601
|
+
|
602
|
+
if (ectx->bypass_query_analysis) {
|
603
|
+
/* Keys may have been requested for deleteTokens or compactionTokens.
|
604
|
+
* Finish key requests. */
|
605
|
+
_mongocrypt_key_broker_requests_done (&ctx->kb);
|
606
|
+
return _mongocrypt_ctx_state_from_key_broker (ctx);
|
607
|
+
}
|
608
|
+
ectx->parent.state = MONGOCRYPT_CTX_NEED_MONGO_MARKINGS;
|
609
|
+
return _try_run_csfle_marking (ctx);
|
610
|
+
}
|
611
|
+
|
612
|
+
|
613
|
+
static bool
|
614
|
+
_fle2_mongo_op_markings (mongocrypt_ctx_t *ctx, bson_t *out)
|
615
|
+
{
|
616
|
+
_mongocrypt_ctx_encrypt_t *ectx;
|
617
|
+
bson_t cmd_bson = BSON_INITIALIZER,
|
618
|
+
encrypted_field_config_bson = BSON_INITIALIZER;
|
619
|
+
|
620
|
+
BSON_ASSERT_PARAM (ctx);
|
621
|
+
BSON_ASSERT_PARAM (out);
|
622
|
+
|
623
|
+
ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
624
|
+
|
625
|
+
BSON_ASSERT (ctx->state == MONGOCRYPT_CTX_NEED_MONGO_MARKINGS);
|
626
|
+
BSON_ASSERT (context_uses_fle2 (ctx));
|
627
|
+
|
628
|
+
if (!_mongocrypt_buffer_to_bson (&ectx->original_cmd, &cmd_bson)) {
|
629
|
+
return _mongocrypt_ctx_fail_w_msg (
|
630
|
+
ctx, "unable to convert original_cmd to BSON");
|
631
|
+
}
|
632
|
+
|
633
|
+
if (!_mongocrypt_buffer_to_bson (&ectx->encrypted_field_config,
|
634
|
+
&encrypted_field_config_bson)) {
|
635
|
+
return _mongocrypt_ctx_fail_w_msg (
|
636
|
+
ctx, "unable to convert encrypted_field_config to BSON");
|
637
|
+
}
|
638
|
+
|
639
|
+
const char *cmd_name = ectx->cmd_name;
|
640
|
+
|
641
|
+
// If input command included $db, do not include it in the command to
|
642
|
+
// mongocryptd. Drivers are expected to append $db in the RunCommand helper
|
643
|
+
// used to send the command.
|
644
|
+
bson_init (out);
|
645
|
+
bson_copy_to_excluding_noinit (&cmd_bson, out, "$db", NULL);
|
646
|
+
if (!_fle2_insert_encryptionInformation (
|
647
|
+
cmd_name,
|
648
|
+
out,
|
649
|
+
ectx->ns,
|
650
|
+
&encrypted_field_config_bson,
|
651
|
+
NULL /* deleteTokens */,
|
652
|
+
ectx->coll_name,
|
653
|
+
ctx->crypt->csfle.okay ? MC_TO_CSFLE : MC_TO_MONGOCRYPTD,
|
654
|
+
ctx->status)) {
|
655
|
+
return _mongocrypt_ctx_fail (ctx);
|
656
|
+
}
|
657
|
+
return true;
|
658
|
+
}
|
659
|
+
|
660
|
+
|
661
|
+
/**
|
662
|
+
* @brief Create the server-side command that contains information for
|
663
|
+
* generating encryption markings via query analysis.
|
664
|
+
*
|
665
|
+
* @param ctx The encryption context.
|
666
|
+
* @param out The destination of the generated BSON document
|
667
|
+
* @return true On success
|
668
|
+
* @return false Otherwise. Sets a failing status message in this case.
|
669
|
+
*/
|
670
|
+
static bool
|
671
|
+
_create_markings_cmd_bson (mongocrypt_ctx_t *ctx, bson_t *out)
|
672
|
+
{
|
673
|
+
_mongocrypt_ctx_encrypt_t *ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
674
|
+
|
675
|
+
BSON_ASSERT_PARAM (ctx);
|
676
|
+
BSON_ASSERT_PARAM (out);
|
677
|
+
|
678
|
+
if (context_uses_fle2 (ctx)) {
|
679
|
+
// Defer to FLE2 to generate the markings command
|
680
|
+
return _fle2_mongo_op_markings (ctx, out);
|
681
|
+
}
|
682
|
+
|
683
|
+
// For FLE1:
|
684
|
+
// Get the original command document
|
685
|
+
bson_t bson_view = BSON_INITIALIZER;
|
686
|
+
if (!_mongocrypt_buffer_to_bson (&ectx->original_cmd, &bson_view)) {
|
687
|
+
_mongocrypt_ctx_fail_w_msg (ctx, "invalid BSON cmd");
|
688
|
+
return false;
|
689
|
+
}
|
690
|
+
|
691
|
+
// Copy the command to the output
|
692
|
+
// If input command included $db, do not include it in the command to
|
693
|
+
// mongocryptd. Drivers are expected to append $db in the RunCommand helper
|
694
|
+
// used to send the command.
|
695
|
+
bson_init (out);
|
696
|
+
bson_copy_to_excluding_noinit (&bson_view, out, "$db", NULL);
|
697
|
+
|
698
|
+
if (!_mongocrypt_buffer_empty (&ectx->schema)) {
|
699
|
+
// We have a schema buffer. View it as BSON:
|
700
|
+
if (!_mongocrypt_buffer_to_bson (&ectx->schema, &bson_view)) {
|
701
|
+
_mongocrypt_ctx_fail_w_msg (ctx, "invalid BSON schema");
|
702
|
+
return false;
|
703
|
+
}
|
704
|
+
// Append the jsonSchema to the output command
|
705
|
+
BSON_APPEND_DOCUMENT (out, "jsonSchema", &bson_view);
|
706
|
+
} else {
|
707
|
+
bson_t empty = BSON_INITIALIZER;
|
708
|
+
BSON_APPEND_DOCUMENT (out, "jsonSchema", &empty);
|
709
|
+
}
|
710
|
+
|
711
|
+
// if a local schema was not set, set isRemoteSchema=true
|
712
|
+
BSON_APPEND_BOOL (out, "isRemoteSchema", !ectx->used_local_schema);
|
713
|
+
return true;
|
714
|
+
}
|
715
|
+
|
716
|
+
|
717
|
+
static bool
|
718
|
+
_mongo_op_markings (mongocrypt_ctx_t *ctx, mongocrypt_binary_t *out)
|
719
|
+
{
|
720
|
+
_mongocrypt_ctx_encrypt_t *ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
721
|
+
|
722
|
+
BSON_ASSERT_PARAM (ctx);
|
723
|
+
BSON_ASSERT_PARAM (out);
|
724
|
+
|
725
|
+
if (ectx->ismaster.needed) {
|
726
|
+
if (_mongocrypt_buffer_empty (&ectx->ismaster.cmd)) {
|
727
|
+
bson_t ismaster_cmd = BSON_INITIALIZER;
|
728
|
+
// Store the generated command:
|
729
|
+
BSON_APPEND_INT32 (&ismaster_cmd, "isMaster", 1);
|
730
|
+
_mongocrypt_buffer_steal_from_bson (&ectx->ismaster.cmd,
|
731
|
+
&ismaster_cmd);
|
732
|
+
}
|
733
|
+
|
734
|
+
out->data = ectx->ismaster.cmd.data;
|
735
|
+
out->len = ectx->ismaster.cmd.len;
|
736
|
+
return true;
|
737
|
+
}
|
738
|
+
|
739
|
+
if (_mongocrypt_buffer_empty (&ectx->mongocryptd_cmd)) {
|
740
|
+
// We need to generate the command document
|
741
|
+
bson_t cmd_bson = BSON_INITIALIZER;
|
742
|
+
if (!_create_markings_cmd_bson (ctx, &cmd_bson)) {
|
743
|
+
// Failed
|
744
|
+
bson_destroy (&cmd_bson);
|
745
|
+
return false;
|
746
|
+
}
|
747
|
+
// Store the generated command:
|
748
|
+
_mongocrypt_buffer_steal_from_bson (&ectx->mongocryptd_cmd, &cmd_bson);
|
749
|
+
}
|
750
|
+
|
751
|
+
// If we reach here, we have a valid mongocrypt_cmd
|
752
|
+
out->data = ectx->mongocryptd_cmd.data;
|
753
|
+
out->len = ectx->mongocryptd_cmd.len;
|
754
|
+
return true;
|
755
|
+
}
|
756
|
+
|
757
|
+
|
758
|
+
static bool
|
759
|
+
_collect_key_from_marking (void *ctx,
|
760
|
+
_mongocrypt_buffer_t *in,
|
761
|
+
mongocrypt_status_t *status)
|
762
|
+
{
|
763
|
+
_mongocrypt_marking_t marking;
|
764
|
+
_mongocrypt_key_broker_t *kb;
|
765
|
+
bool res;
|
766
|
+
|
767
|
+
BSON_ASSERT_PARAM (ctx);
|
768
|
+
BSON_ASSERT_PARAM (in);
|
769
|
+
|
770
|
+
kb = (_mongocrypt_key_broker_t *) ctx;
|
771
|
+
|
772
|
+
if (!_mongocrypt_marking_parse_unowned (in, &marking, status)) {
|
773
|
+
_mongocrypt_marking_cleanup (&marking);
|
774
|
+
return false;
|
775
|
+
}
|
776
|
+
|
777
|
+
if (marking.type == MONGOCRYPT_MARKING_FLE1_BY_ID) {
|
778
|
+
res = _mongocrypt_key_broker_request_id (kb, &marking.key_id);
|
779
|
+
} else if (marking.type == MONGOCRYPT_MARKING_FLE1_BY_ALTNAME) {
|
780
|
+
res = _mongocrypt_key_broker_request_name (kb, &marking.key_alt_name);
|
781
|
+
} else {
|
782
|
+
BSON_ASSERT (marking.type == MONGOCRYPT_MARKING_FLE2_ENCRYPTION);
|
783
|
+
res =
|
784
|
+
_mongocrypt_key_broker_request_id (kb, &marking.fle2.index_key_id) &&
|
785
|
+
_mongocrypt_key_broker_request_id (kb, &marking.fle2.user_key_id);
|
786
|
+
}
|
787
|
+
|
788
|
+
if (!res) {
|
789
|
+
_mongocrypt_key_broker_status (kb, status);
|
790
|
+
_mongocrypt_marking_cleanup (&marking);
|
791
|
+
return false;
|
792
|
+
}
|
793
|
+
|
794
|
+
_mongocrypt_marking_cleanup (&marking);
|
795
|
+
|
796
|
+
return true;
|
797
|
+
}
|
798
|
+
|
799
|
+
|
800
|
+
static bool
|
801
|
+
_mongo_feed_markings (mongocrypt_ctx_t *ctx, mongocrypt_binary_t *in)
|
802
|
+
{
|
803
|
+
/* Find keys. */
|
804
|
+
bson_t as_bson;
|
805
|
+
bson_iter_t iter;
|
806
|
+
_mongocrypt_ctx_encrypt_t *ectx;
|
807
|
+
|
808
|
+
BSON_ASSERT_PARAM (ctx);
|
809
|
+
BSON_ASSERT_PARAM (in);
|
810
|
+
|
811
|
+
ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
812
|
+
if (!_mongocrypt_binary_to_bson (in, &as_bson)) {
|
813
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "malformed BSON");
|
814
|
+
}
|
815
|
+
|
816
|
+
if (ectx->ismaster.needed) {
|
817
|
+
/* This is a response to the 'isMaster' command. */
|
818
|
+
if (!bson_iter_init_find (&iter, &as_bson, "maxWireVersion")) {
|
819
|
+
return _mongocrypt_ctx_fail_w_msg (
|
820
|
+
ctx,
|
821
|
+
"expected to find 'maxWireVersion' in isMaster response, but did "
|
822
|
+
"not.");
|
823
|
+
}
|
824
|
+
if (!BSON_ITER_HOLDS_INT32 (&iter)) {
|
825
|
+
return _mongocrypt_ctx_fail_w_msg (
|
826
|
+
ctx, "expected 'maxWireVersion' to be int32.");
|
827
|
+
}
|
828
|
+
ectx->ismaster.maxwireversion = bson_iter_int32 (&iter);
|
829
|
+
return true;
|
830
|
+
}
|
831
|
+
|
832
|
+
if (bson_iter_init_find (&iter, &as_bson, "schemaRequiresEncryption") &&
|
833
|
+
!bson_iter_as_bool (&iter)) {
|
834
|
+
/* TODO: update cache: this schema does not require encryption. */
|
835
|
+
|
836
|
+
/* If using a local schema, warn if there are no encrypted fields. */
|
837
|
+
if (ectx->used_local_schema) {
|
838
|
+
_mongocrypt_log (
|
839
|
+
&ctx->crypt->log,
|
840
|
+
MONGOCRYPT_LOG_LEVEL_WARNING,
|
841
|
+
"local schema used but does not have encryption specifiers");
|
842
|
+
}
|
843
|
+
return true;
|
844
|
+
} else {
|
845
|
+
/* if the schema requires encryption, but has sibling validators, error.
|
846
|
+
*/
|
847
|
+
if (ectx->collinfo_has_siblings) {
|
848
|
+
return _mongocrypt_ctx_fail_w_msg (ctx,
|
849
|
+
"schema requires encryption, "
|
850
|
+
"but collection JSON schema "
|
851
|
+
"validator has siblings");
|
852
|
+
}
|
853
|
+
}
|
854
|
+
|
855
|
+
if (bson_iter_init_find (&iter, &as_bson, "hasEncryptedPlaceholders") &&
|
856
|
+
!bson_iter_as_bool (&iter)) {
|
857
|
+
return true;
|
858
|
+
}
|
859
|
+
|
860
|
+
if (!bson_iter_init_find (&iter, &as_bson, "result")) {
|
861
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "malformed marking, no 'result'");
|
862
|
+
}
|
863
|
+
|
864
|
+
if (!_mongocrypt_buffer_copy_from_document_iter (&ectx->marked_cmd, &iter)) {
|
865
|
+
return _mongocrypt_ctx_fail_w_msg (
|
866
|
+
ctx, "malformed marking, 'result' must be a document");
|
867
|
+
}
|
868
|
+
|
869
|
+
if (!bson_iter_recurse (&iter, &iter)) {
|
870
|
+
return _mongocrypt_ctx_fail_w_msg (
|
871
|
+
ctx, "malformed marking, could not recurse into 'result'");
|
872
|
+
}
|
873
|
+
if (!_mongocrypt_traverse_binary_in_bson (_collect_key_from_marking,
|
874
|
+
(void *) &ctx->kb,
|
875
|
+
TRAVERSE_MATCH_MARKING,
|
876
|
+
&iter,
|
877
|
+
ctx->status)) {
|
878
|
+
return _mongocrypt_ctx_fail (ctx);
|
879
|
+
}
|
880
|
+
|
881
|
+
return true;
|
882
|
+
}
|
883
|
+
|
884
|
+
static bool
|
885
|
+
mongocrypt_ctx_encrypt_ismaster_done (mongocrypt_ctx_t *ctx);
|
886
|
+
|
887
|
+
static bool
|
888
|
+
_mongo_done_markings (mongocrypt_ctx_t *ctx)
|
889
|
+
{
|
890
|
+
_mongocrypt_ctx_encrypt_t *ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
891
|
+
|
892
|
+
BSON_ASSERT_PARAM (ctx);
|
893
|
+
|
894
|
+
if (ectx->ismaster.needed) {
|
895
|
+
return mongocrypt_ctx_encrypt_ismaster_done (ctx);
|
896
|
+
}
|
897
|
+
(void) _mongocrypt_key_broker_requests_done (&ctx->kb);
|
898
|
+
return _mongocrypt_ctx_state_from_key_broker (ctx);
|
899
|
+
}
|
900
|
+
|
901
|
+
/**
|
902
|
+
* @brief Append $db to a command being passed to csfle.
|
903
|
+
*/
|
904
|
+
static bool
|
905
|
+
_add_dollar_db (const char *cmd_name,
|
906
|
+
bson_t *cmd,
|
907
|
+
const char *db_name,
|
908
|
+
mongocrypt_status_t *status)
|
909
|
+
{
|
910
|
+
bson_t out = BSON_INITIALIZER;
|
911
|
+
bson_t explain = BSON_INITIALIZER;
|
912
|
+
bson_iter_t iter;
|
913
|
+
bool ok = false;
|
914
|
+
|
915
|
+
BSON_ASSERT_PARAM (cmd_name);
|
916
|
+
BSON_ASSERT_PARAM (cmd);
|
917
|
+
BSON_ASSERT_PARAM (db_name);
|
918
|
+
|
919
|
+
if (!bson_iter_init_find (&iter, cmd, "$db")) {
|
920
|
+
if (!BSON_APPEND_UTF8 (cmd, "$db", db_name)) {
|
921
|
+
CLIENT_ERR ("failed to append '$db'");
|
922
|
+
goto fail;
|
923
|
+
}
|
924
|
+
}
|
925
|
+
|
926
|
+
if (0 != strcmp (cmd_name, "explain")) {
|
927
|
+
goto success;
|
928
|
+
}
|
929
|
+
|
930
|
+
// The "explain" command for csfle is a special case.
|
931
|
+
// csfle expects "$db" to be nested in the "explain" document and match the
|
932
|
+
// top-level "$db". Example:
|
933
|
+
// {
|
934
|
+
// "explain": {
|
935
|
+
// "find": "to-csfle"
|
936
|
+
// "$db": "db"
|
937
|
+
// }
|
938
|
+
// "$db": "db"
|
939
|
+
// }
|
940
|
+
BSON_ASSERT (bson_iter_init_find (&iter, cmd, "explain"));
|
941
|
+
if (!BSON_ITER_HOLDS_DOCUMENT (&iter)) {
|
942
|
+
CLIENT_ERR ("expected 'explain' to be document");
|
943
|
+
goto fail;
|
944
|
+
}
|
945
|
+
|
946
|
+
{
|
947
|
+
bson_t tmp;
|
948
|
+
if (!mc_iter_document_as_bson (&iter, &tmp, status)) {
|
949
|
+
goto fail;
|
950
|
+
}
|
951
|
+
bson_copy_to (&tmp, &explain);
|
952
|
+
}
|
953
|
+
|
954
|
+
if (!BSON_APPEND_UTF8 (&explain, "$db", db_name)) {
|
955
|
+
CLIENT_ERR ("failed to append '$db'");
|
956
|
+
goto fail;
|
957
|
+
}
|
958
|
+
|
959
|
+
if (!BSON_APPEND_DOCUMENT (&out, "explain", &explain)) {
|
960
|
+
CLIENT_ERR ("unable to append 'explain' document");
|
961
|
+
goto fail;
|
962
|
+
}
|
963
|
+
|
964
|
+
bson_copy_to_excluding_noinit (cmd, &out, "explain", NULL);
|
965
|
+
bson_destroy (cmd);
|
966
|
+
if (!bson_steal (cmd, &out)) {
|
967
|
+
CLIENT_ERR ("failed to steal BSON without encryptionInformation");
|
968
|
+
goto fail;
|
969
|
+
}
|
970
|
+
|
971
|
+
success:
|
972
|
+
ok = true;
|
973
|
+
fail:
|
974
|
+
bson_destroy (&explain);
|
975
|
+
if (!ok) {
|
976
|
+
bson_destroy (&out);
|
977
|
+
}
|
978
|
+
return ok;
|
979
|
+
}
|
980
|
+
|
981
|
+
/**
|
982
|
+
* @brief Attempt to generate csfle markings using a csfle dynamic library.
|
983
|
+
*
|
984
|
+
* @param ctx A context which has state NEED_MONGO_MARKINGS
|
985
|
+
* @return true On success
|
986
|
+
* @return false On error.
|
987
|
+
*
|
988
|
+
* This should be called only when we are ready for markings in the command
|
989
|
+
* document. This function will only do anything if the csfle dynamic library
|
990
|
+
* is loaded, otherwise it returns success immediately and leaves the state
|
991
|
+
* as NEED_MONGO_MARKINGS.
|
992
|
+
*
|
993
|
+
* If csfle is loaded, this function will request the csfle library generate a
|
994
|
+
* marked command document based on the caller's schema. If successful, the
|
995
|
+
* state will be changed via @ref _mongo_done_markings().
|
996
|
+
*
|
997
|
+
* The purpose of this function is to short-circuit the phase of encryption
|
998
|
+
* wherein we would normally return to the driver and give them the opportunity
|
999
|
+
* to generate the markings by passing a special command to a mongocryptd daemon
|
1000
|
+
* process. Instead, we'll do it ourselves here, if possible.
|
1001
|
+
*/
|
1002
|
+
static bool
|
1003
|
+
_try_run_csfle_marking (mongocrypt_ctx_t *ctx)
|
1004
|
+
{
|
1005
|
+
BSON_ASSERT_PARAM (ctx);
|
1006
|
+
|
1007
|
+
BSON_ASSERT (
|
1008
|
+
ctx->state == MONGOCRYPT_CTX_NEED_MONGO_MARKINGS &&
|
1009
|
+
"_try_run_csfle_marking() should only be called when mongocrypt is "
|
1010
|
+
"ready for markings");
|
1011
|
+
|
1012
|
+
_mongocrypt_ctx_encrypt_t *ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
1013
|
+
|
1014
|
+
BSON_ASSERT (ctx->crypt);
|
1015
|
+
|
1016
|
+
// We have a valid schema and just need to mark the fields for encryption
|
1017
|
+
if (!ctx->crypt->csfle.okay) {
|
1018
|
+
// We don't have a csfle library to use to obtain the markings. It's up to
|
1019
|
+
// caller to resolve them.
|
1020
|
+
return true;
|
1021
|
+
}
|
1022
|
+
|
1023
|
+
_mongo_crypt_v1_vtable csfle = ctx->crypt->csfle;
|
1024
|
+
mongo_crypt_v1_lib *csfle_lib = ctx->crypt->csfle_lib;
|
1025
|
+
BSON_ASSERT (csfle_lib);
|
1026
|
+
bool okay = false;
|
1027
|
+
|
1028
|
+
// Obtain the command for markings
|
1029
|
+
bson_t cmd = BSON_INITIALIZER;
|
1030
|
+
if (!_create_markings_cmd_bson (ctx, &cmd)) {
|
1031
|
+
goto fail_create_cmd;
|
1032
|
+
}
|
1033
|
+
|
1034
|
+
const char *cmd_name = ectx->cmd_name;
|
1035
|
+
|
1036
|
+
if (!_add_dollar_db (cmd_name, &cmd, ectx->db_name, ctx->status)) {
|
1037
|
+
_mongocrypt_ctx_fail (ctx);
|
1038
|
+
goto fail_create_cmd;
|
1039
|
+
}
|
1040
|
+
|
1041
|
+
#define CHECK_CSFLE_ERROR(Func, FailLabel) \
|
1042
|
+
if (1) { \
|
1043
|
+
if (csfle.status_get_error (status)) { \
|
1044
|
+
_mongocrypt_set_error (ctx->status, \
|
1045
|
+
MONGOCRYPT_STATUS_ERROR_CRYPT_SHARED, \
|
1046
|
+
MONGOCRYPT_GENERIC_ERROR_CODE, \
|
1047
|
+
"csfle " #Func \
|
1048
|
+
" failed: %s [Error %d, code %d]", \
|
1049
|
+
csfle.status_get_explanation (status), \
|
1050
|
+
csfle.status_get_error (status), \
|
1051
|
+
csfle.status_get_code (status)); \
|
1052
|
+
_mongocrypt_ctx_fail (ctx); \
|
1053
|
+
goto FailLabel; \
|
1054
|
+
} \
|
1055
|
+
} else \
|
1056
|
+
((void) 0)
|
1057
|
+
|
1058
|
+
mongo_crypt_v1_status *status = csfle.status_create ();
|
1059
|
+
BSON_ASSERT (status);
|
1060
|
+
|
1061
|
+
mongo_crypt_v1_query_analyzer *qa =
|
1062
|
+
csfle.query_analyzer_create (csfle_lib, status);
|
1063
|
+
CHECK_CSFLE_ERROR ("query_analyzer_create", fail_qa_create);
|
1064
|
+
|
1065
|
+
uint32_t marked_bson_len = 0;
|
1066
|
+
uint8_t *marked_bson = csfle.analyze_query (qa,
|
1067
|
+
bson_get_data (&cmd),
|
1068
|
+
ectx->ns,
|
1069
|
+
(uint32_t) strlen (ectx->ns),
|
1070
|
+
&marked_bson_len,
|
1071
|
+
status);
|
1072
|
+
CHECK_CSFLE_ERROR ("analyze_query", fail_analyze_query);
|
1073
|
+
|
1074
|
+
// Copy out the marked document.
|
1075
|
+
mongocrypt_binary_t *marked =
|
1076
|
+
mongocrypt_binary_new_from_data (marked_bson, marked_bson_len);
|
1077
|
+
if (!_mongo_feed_markings (ctx, marked)) {
|
1078
|
+
// Wrap error with additional information.
|
1079
|
+
_mongocrypt_set_error (
|
1080
|
+
ctx->status,
|
1081
|
+
MONGOCRYPT_STATUS_ERROR_CLIENT,
|
1082
|
+
MONGOCRYPT_GENERIC_ERROR_CODE,
|
1083
|
+
"Consuming the generated csfle markings failed: %s",
|
1084
|
+
mongocrypt_status_message (ctx->status, NULL /* len */));
|
1085
|
+
goto fail_feed_markings;
|
1086
|
+
}
|
1087
|
+
|
1088
|
+
okay = _mongo_done_markings (ctx);
|
1089
|
+
if (!okay) {
|
1090
|
+
// Wrap error with additional information.
|
1091
|
+
_mongocrypt_set_error (
|
1092
|
+
ctx->status,
|
1093
|
+
MONGOCRYPT_STATUS_ERROR_CLIENT,
|
1094
|
+
MONGOCRYPT_GENERIC_ERROR_CODE,
|
1095
|
+
"Finalizing the generated csfle markings failed: %s",
|
1096
|
+
mongocrypt_status_message (ctx->status, NULL /* len */));
|
1097
|
+
}
|
1098
|
+
|
1099
|
+
fail_feed_markings:
|
1100
|
+
mongocrypt_binary_destroy (marked);
|
1101
|
+
csfle.bson_free (marked_bson);
|
1102
|
+
fail_analyze_query:
|
1103
|
+
csfle.query_analyzer_destroy (qa);
|
1104
|
+
fail_qa_create:
|
1105
|
+
csfle.status_destroy (status);
|
1106
|
+
fail_create_cmd:
|
1107
|
+
bson_destroy (&cmd);
|
1108
|
+
return okay;
|
1109
|
+
}
|
1110
|
+
|
1111
|
+
|
1112
|
+
static bool
|
1113
|
+
_marking_to_bson_value (void *ctx,
|
1114
|
+
_mongocrypt_marking_t *marking,
|
1115
|
+
bson_value_t *out,
|
1116
|
+
mongocrypt_status_t *status)
|
1117
|
+
{
|
1118
|
+
_mongocrypt_ciphertext_t ciphertext;
|
1119
|
+
_mongocrypt_buffer_t serialized_ciphertext = {0};
|
1120
|
+
bool ret = false;
|
1121
|
+
|
1122
|
+
BSON_ASSERT_PARAM (ctx);
|
1123
|
+
BSON_ASSERT_PARAM (marking);
|
1124
|
+
BSON_ASSERT_PARAM (out);
|
1125
|
+
|
1126
|
+
_mongocrypt_ciphertext_init (&ciphertext);
|
1127
|
+
|
1128
|
+
if (!_mongocrypt_marking_to_ciphertext (ctx, marking, &ciphertext, status)) {
|
1129
|
+
goto fail;
|
1130
|
+
}
|
1131
|
+
|
1132
|
+
if ((ciphertext.blob_subtype == MC_SUBTYPE_FLE2InsertUpdatePayload) ||
|
1133
|
+
(ciphertext.blob_subtype == MC_SUBTYPE_FLE2FindEqualityPayload) ||
|
1134
|
+
(ciphertext.blob_subtype == MC_SUBTYPE_FLE2FindRangePayload)) {
|
1135
|
+
/* ciphertext_data is already a BSON object, just need to prepend
|
1136
|
+
* blob_subtype */
|
1137
|
+
if (ciphertext.data.len > UINT32_MAX - 1u) {
|
1138
|
+
CLIENT_ERR ("ciphertext too long");
|
1139
|
+
goto fail;
|
1140
|
+
}
|
1141
|
+
_mongocrypt_buffer_init_size (&serialized_ciphertext,
|
1142
|
+
ciphertext.data.len + 1);
|
1143
|
+
/* ciphertext->blob_subtype is an enum and easily fits in uint8_t */
|
1144
|
+
serialized_ciphertext.data[0] = (uint8_t) ciphertext.blob_subtype;
|
1145
|
+
memcpy (serialized_ciphertext.data + 1,
|
1146
|
+
ciphertext.data.data,
|
1147
|
+
ciphertext.data.len);
|
1148
|
+
|
1149
|
+
} else if (!_mongocrypt_serialize_ciphertext (&ciphertext,
|
1150
|
+
&serialized_ciphertext)) {
|
1151
|
+
CLIENT_ERR ("malformed ciphertext");
|
1152
|
+
goto fail;
|
1153
|
+
};
|
1154
|
+
|
1155
|
+
/* ownership of serialized_ciphertext is transferred to caller. */
|
1156
|
+
out->value_type = BSON_TYPE_BINARY;
|
1157
|
+
out->value.v_binary.data = serialized_ciphertext.data;
|
1158
|
+
out->value.v_binary.data_len = serialized_ciphertext.len;
|
1159
|
+
out->value.v_binary.subtype = (bson_subtype_t) BSON_SUBTYPE_ENCRYPTED;
|
1160
|
+
|
1161
|
+
ret = true;
|
1162
|
+
|
1163
|
+
fail:
|
1164
|
+
_mongocrypt_ciphertext_cleanup (&ciphertext);
|
1165
|
+
return ret;
|
1166
|
+
}
|
1167
|
+
|
1168
|
+
|
1169
|
+
static bool
|
1170
|
+
_replace_marking_with_ciphertext (void *ctx,
|
1171
|
+
_mongocrypt_buffer_t *in,
|
1172
|
+
bson_value_t *out,
|
1173
|
+
mongocrypt_status_t *status)
|
1174
|
+
{
|
1175
|
+
_mongocrypt_marking_t marking;
|
1176
|
+
bool ret;
|
1177
|
+
|
1178
|
+
BSON_ASSERT_PARAM (ctx);
|
1179
|
+
BSON_ASSERT_PARAM (in);
|
1180
|
+
|
1181
|
+
memset (&marking, 0, sizeof (marking));
|
1182
|
+
|
1183
|
+
if (!_mongocrypt_marking_parse_unowned (in, &marking, status)) {
|
1184
|
+
_mongocrypt_marking_cleanup (&marking);
|
1185
|
+
return false;
|
1186
|
+
}
|
1187
|
+
|
1188
|
+
ret = _marking_to_bson_value (ctx, &marking, out, status);
|
1189
|
+
_mongocrypt_marking_cleanup (&marking);
|
1190
|
+
return ret;
|
1191
|
+
}
|
1192
|
+
|
1193
|
+
|
1194
|
+
/* generate_delete_tokens generates the 'deleteTokens' document to be appended
|
1195
|
+
* to 'encryptionInformation'. */
|
1196
|
+
static bson_t *
|
1197
|
+
generate_delete_tokens (_mongocrypt_crypto_t *crypto,
|
1198
|
+
_mongocrypt_key_broker_t *kb,
|
1199
|
+
mc_EncryptedFieldConfig_t *efc,
|
1200
|
+
mongocrypt_status_t *status)
|
1201
|
+
{
|
1202
|
+
bool ret = false;
|
1203
|
+
bson_t *out = bson_new ();
|
1204
|
+
mc_EncryptedField_t *ef;
|
1205
|
+
|
1206
|
+
BSON_ASSERT_PARAM (crypto);
|
1207
|
+
BSON_ASSERT_PARAM (kb);
|
1208
|
+
BSON_ASSERT_PARAM (efc);
|
1209
|
+
|
1210
|
+
for (ef = efc->fields; ef != NULL; ef = ef->next) {
|
1211
|
+
_mongocrypt_buffer_t IndexKey = {0};
|
1212
|
+
_mongocrypt_buffer_t TokenKey = {0};
|
1213
|
+
mc_ServerDataEncryptionLevel1Token_t *sdel1t = NULL;
|
1214
|
+
mc_CollectionsLevel1Token_t *cl1t = NULL;
|
1215
|
+
mc_ECOCToken_t *ecoc = NULL;
|
1216
|
+
bool loop_ok = false;
|
1217
|
+
/* deleteTokens are only necessary for indexed fields. */
|
1218
|
+
if (!ef->has_queries) {
|
1219
|
+
goto loop_continue;
|
1220
|
+
}
|
1221
|
+
|
1222
|
+
if (!_mongocrypt_key_broker_decrypted_key_by_id (
|
1223
|
+
kb, &ef->keyId, &IndexKey)) {
|
1224
|
+
_mongocrypt_key_broker_status (kb, status);
|
1225
|
+
goto loop_fail;
|
1226
|
+
}
|
1227
|
+
|
1228
|
+
/* Get the TokenKey from the last 32 bytes of IndexKey */
|
1229
|
+
if (IndexKey.len < MONGOCRYPT_TOKEN_KEY_LEN) {
|
1230
|
+
CLIENT_ERR ("IndexKey too short");
|
1231
|
+
goto loop_fail;
|
1232
|
+
}
|
1233
|
+
if (!_mongocrypt_buffer_from_subrange (&TokenKey,
|
1234
|
+
&IndexKey,
|
1235
|
+
IndexKey.len -
|
1236
|
+
MONGOCRYPT_TOKEN_KEY_LEN,
|
1237
|
+
MONGOCRYPT_TOKEN_KEY_LEN)) {
|
1238
|
+
CLIENT_ERR (
|
1239
|
+
"generate_delete_tokens unable to parse TokenKey from IndexKey");
|
1240
|
+
goto loop_fail;
|
1241
|
+
}
|
1242
|
+
|
1243
|
+
sdel1t =
|
1244
|
+
mc_ServerDataEncryptionLevel1Token_new (crypto, &TokenKey, status);
|
1245
|
+
if (!sdel1t) {
|
1246
|
+
goto loop_fail;
|
1247
|
+
}
|
1248
|
+
|
1249
|
+
cl1t = mc_CollectionsLevel1Token_new (crypto, &TokenKey, status);
|
1250
|
+
if (!cl1t) {
|
1251
|
+
goto loop_fail;
|
1252
|
+
}
|
1253
|
+
|
1254
|
+
ecoc = mc_ECOCToken_new (crypto, cl1t, status);
|
1255
|
+
if (!ecoc) {
|
1256
|
+
goto loop_fail;
|
1257
|
+
}
|
1258
|
+
|
1259
|
+
bson_t field_bson;
|
1260
|
+
if (!BSON_APPEND_DOCUMENT_BEGIN (out, ef->path, &field_bson)) {
|
1261
|
+
CLIENT_ERR ("failed to begin document for 'deleteTokens.%s'",
|
1262
|
+
ef->path);
|
1263
|
+
goto loop_fail;
|
1264
|
+
}
|
1265
|
+
|
1266
|
+
if (!BSON_APPEND_BINARY (
|
1267
|
+
&field_bson,
|
1268
|
+
"e",
|
1269
|
+
BSON_SUBTYPE_BINARY,
|
1270
|
+
mc_ServerDataEncryptionLevel1Token_get (sdel1t)->data,
|
1271
|
+
mc_ServerDataEncryptionLevel1Token_get (sdel1t)->len)) {
|
1272
|
+
CLIENT_ERR ("failed to append ServerDataEncryptionLevel1Token for %s",
|
1273
|
+
ef->path);
|
1274
|
+
goto loop_fail;
|
1275
|
+
}
|
1276
|
+
|
1277
|
+
if (!BSON_APPEND_BINARY (&field_bson,
|
1278
|
+
"o",
|
1279
|
+
BSON_SUBTYPE_BINARY,
|
1280
|
+
mc_ECOCToken_get (ecoc)->data,
|
1281
|
+
mc_ECOCToken_get (ecoc)->len)) {
|
1282
|
+
CLIENT_ERR ("failed to append ECOCToken for %s", ef->path);
|
1283
|
+
goto loop_fail;
|
1284
|
+
}
|
1285
|
+
|
1286
|
+
if (!bson_append_document_end (out, &field_bson)) {
|
1287
|
+
CLIENT_ERR ("failed to end document for 'deleteTokens.%s'", ef->path);
|
1288
|
+
goto loop_fail;
|
1289
|
+
}
|
1290
|
+
|
1291
|
+
loop_continue:
|
1292
|
+
loop_ok = true;
|
1293
|
+
loop_fail:
|
1294
|
+
_mongocrypt_buffer_cleanup (&IndexKey);
|
1295
|
+
_mongocrypt_buffer_cleanup (&TokenKey);
|
1296
|
+
mc_ServerDataEncryptionLevel1Token_destroy (sdel1t);
|
1297
|
+
mc_CollectionsLevel1Token_destroy (cl1t);
|
1298
|
+
mc_ECOCToken_destroy (ecoc);
|
1299
|
+
if (!loop_ok) {
|
1300
|
+
goto fail;
|
1301
|
+
}
|
1302
|
+
}
|
1303
|
+
|
1304
|
+
ret = true;
|
1305
|
+
fail:
|
1306
|
+
if (!ret) {
|
1307
|
+
bson_destroy (out);
|
1308
|
+
return NULL;
|
1309
|
+
}
|
1310
|
+
return out;
|
1311
|
+
}
|
1312
|
+
|
1313
|
+
static bool
|
1314
|
+
_check_for_payload_requiring_encryptionInformation (void *ctx,
|
1315
|
+
_mongocrypt_buffer_t *in,
|
1316
|
+
mongocrypt_status_t *status)
|
1317
|
+
{
|
1318
|
+
bool *out = (bool *) ctx;
|
1319
|
+
|
1320
|
+
BSON_ASSERT_PARAM (ctx);
|
1321
|
+
BSON_ASSERT_PARAM (in);
|
1322
|
+
|
1323
|
+
if (in->len < 1) {
|
1324
|
+
CLIENT_ERR ("unexpected empty FLE payload");
|
1325
|
+
return false;
|
1326
|
+
}
|
1327
|
+
|
1328
|
+
if (in->data[0] == MC_SUBTYPE_FLE2InsertUpdatePayload) {
|
1329
|
+
*out = true;
|
1330
|
+
return true;
|
1331
|
+
}
|
1332
|
+
|
1333
|
+
if (in->data[0] == MC_SUBTYPE_FLE2FindEqualityPayload) {
|
1334
|
+
*out = true;
|
1335
|
+
return true;
|
1336
|
+
}
|
1337
|
+
|
1338
|
+
if (in->data[0] == MC_SUBTYPE_FLE2FindRangePayload) {
|
1339
|
+
*out = true;
|
1340
|
+
return true;
|
1341
|
+
}
|
1342
|
+
|
1343
|
+
return true;
|
1344
|
+
}
|
1345
|
+
|
1346
|
+
typedef struct {
|
1347
|
+
bool must_omit;
|
1348
|
+
bool ok;
|
1349
|
+
} moe_result;
|
1350
|
+
|
1351
|
+
// must_omit_encryptionInformation returns true if the command
|
1352
|
+
// must omit the "encryptionInformation" field when sent to mongod / mongos.
|
1353
|
+
static moe_result
|
1354
|
+
must_omit_encryptionInformation (const char *command_name,
|
1355
|
+
const bson_t *command,
|
1356
|
+
mongocrypt_status_t *status)
|
1357
|
+
{
|
1358
|
+
// eligible_commands may omit encryptionInformation if the command does not
|
1359
|
+
// contain payloads requiring encryption.
|
1360
|
+
const char *eligible_commands[] = {
|
1361
|
+
"find", "aggregate", "distinct", "count", "insert"};
|
1362
|
+
size_t i;
|
1363
|
+
bool found = false;
|
1364
|
+
|
1365
|
+
// prohibited_commands prohibit encryptionInformation on mongod / mongos.
|
1366
|
+
const char *prohibited_commands[] = {
|
1367
|
+
"compactStructuredEncryptionData", "create", "collMod", "createIndexes"};
|
1368
|
+
|
1369
|
+
BSON_ASSERT_PARAM (command_name);
|
1370
|
+
BSON_ASSERT_PARAM (command);
|
1371
|
+
|
1372
|
+
for (i = 0;
|
1373
|
+
i < sizeof (prohibited_commands) / sizeof (prohibited_commands[0]);
|
1374
|
+
i++) {
|
1375
|
+
if (0 == strcmp (prohibited_commands[i], command_name)) {
|
1376
|
+
return (moe_result){.ok = true, .must_omit = true};
|
1377
|
+
}
|
1378
|
+
}
|
1379
|
+
|
1380
|
+
for (i = 0; i < sizeof (eligible_commands) / sizeof (eligible_commands[0]);
|
1381
|
+
i++) {
|
1382
|
+
if (0 == strcmp (eligible_commands[i], command_name)) {
|
1383
|
+
found = true;
|
1384
|
+
break;
|
1385
|
+
}
|
1386
|
+
}
|
1387
|
+
if (!found) {
|
1388
|
+
return (moe_result){.ok = true};
|
1389
|
+
}
|
1390
|
+
|
1391
|
+
bool has_payload_requiring_encryptionInformation = false;
|
1392
|
+
bson_iter_t iter;
|
1393
|
+
if (!bson_iter_init (&iter, command)) {
|
1394
|
+
CLIENT_ERR ("unable to iterate command");
|
1395
|
+
return (moe_result){.ok = false};
|
1396
|
+
}
|
1397
|
+
if (!_mongocrypt_traverse_binary_in_bson (
|
1398
|
+
_check_for_payload_requiring_encryptionInformation,
|
1399
|
+
&has_payload_requiring_encryptionInformation,
|
1400
|
+
TRAVERSE_MATCH_SUBTYPE6,
|
1401
|
+
&iter,
|
1402
|
+
status)) {
|
1403
|
+
return (moe_result){.ok = false};
|
1404
|
+
}
|
1405
|
+
|
1406
|
+
if (!has_payload_requiring_encryptionInformation) {
|
1407
|
+
return (moe_result){.ok = true, .must_omit = true};
|
1408
|
+
}
|
1409
|
+
return (moe_result){.ok = true, .must_omit = false};
|
1410
|
+
}
|
1411
|
+
|
1412
|
+
/* _fle2_append_compactionTokens appends compactionTokens if command_name is
|
1413
|
+
* "compactStructuredEncryptionData" */
|
1414
|
+
static bool
|
1415
|
+
_fle2_append_compactionTokens (_mongocrypt_crypto_t *crypto,
|
1416
|
+
_mongocrypt_key_broker_t *kb,
|
1417
|
+
mc_EncryptedFieldConfig_t *efc,
|
1418
|
+
const char *command_name,
|
1419
|
+
bson_t *out,
|
1420
|
+
mongocrypt_status_t *status)
|
1421
|
+
{
|
1422
|
+
bson_t result_compactionTokens;
|
1423
|
+
bool ret = false;
|
1424
|
+
|
1425
|
+
BSON_ASSERT_PARAM (crypto);
|
1426
|
+
BSON_ASSERT_PARAM (kb);
|
1427
|
+
BSON_ASSERT_PARAM (efc);
|
1428
|
+
BSON_ASSERT_PARAM (command_name);
|
1429
|
+
BSON_ASSERT_PARAM (out);
|
1430
|
+
|
1431
|
+
if (0 != strcmp (command_name, "compactStructuredEncryptionData")) {
|
1432
|
+
return true;
|
1433
|
+
}
|
1434
|
+
|
1435
|
+
BSON_APPEND_DOCUMENT_BEGIN (
|
1436
|
+
out, "compactionTokens", &result_compactionTokens);
|
1437
|
+
|
1438
|
+
mc_EncryptedField_t *ptr;
|
1439
|
+
for (ptr = efc->fields; ptr != NULL; ptr = ptr->next) {
|
1440
|
+
/* Append ECOC token. */
|
1441
|
+
_mongocrypt_buffer_t key = {0};
|
1442
|
+
_mongocrypt_buffer_t tokenkey = {0};
|
1443
|
+
mc_CollectionsLevel1Token_t *cl1t = NULL;
|
1444
|
+
mc_ECOCToken_t *ecoct = NULL;
|
1445
|
+
bool ecoc_ok = false;
|
1446
|
+
|
1447
|
+
if (!_mongocrypt_key_broker_decrypted_key_by_id (kb, &ptr->keyId, &key)) {
|
1448
|
+
_mongocrypt_key_broker_status (kb, status);
|
1449
|
+
goto ecoc_fail;
|
1450
|
+
}
|
1451
|
+
/* The last 32 bytes of the user key are the token key. */
|
1452
|
+
if (key.len < MONGOCRYPT_TOKEN_KEY_LEN) {
|
1453
|
+
CLIENT_ERR ("key too short");
|
1454
|
+
goto ecoc_fail;
|
1455
|
+
}
|
1456
|
+
if (!_mongocrypt_buffer_from_subrange (&tokenkey,
|
1457
|
+
&key,
|
1458
|
+
key.len - MONGOCRYPT_TOKEN_KEY_LEN,
|
1459
|
+
MONGOCRYPT_TOKEN_KEY_LEN)) {
|
1460
|
+
CLIENT_ERR ("unable to get TokenKey from Data Encryption Key");
|
1461
|
+
goto ecoc_fail;
|
1462
|
+
}
|
1463
|
+
cl1t = mc_CollectionsLevel1Token_new (crypto, &tokenkey, status);
|
1464
|
+
if (!cl1t) {
|
1465
|
+
goto ecoc_fail;
|
1466
|
+
}
|
1467
|
+
|
1468
|
+
ecoct = mc_ECOCToken_new (crypto, cl1t, status);
|
1469
|
+
if (!ecoct) {
|
1470
|
+
goto ecoc_fail;
|
1471
|
+
}
|
1472
|
+
|
1473
|
+
const _mongocrypt_buffer_t *ecoct_buf = mc_ECOCToken_get (ecoct);
|
1474
|
+
|
1475
|
+
BSON_APPEND_BINARY (&result_compactionTokens,
|
1476
|
+
ptr->path,
|
1477
|
+
BSON_SUBTYPE_BINARY,
|
1478
|
+
ecoct_buf->data,
|
1479
|
+
ecoct_buf->len);
|
1480
|
+
|
1481
|
+
ecoc_ok = true;
|
1482
|
+
ecoc_fail:
|
1483
|
+
mc_ECOCToken_destroy (ecoct);
|
1484
|
+
mc_CollectionsLevel1Token_destroy (cl1t);
|
1485
|
+
_mongocrypt_buffer_cleanup (&key);
|
1486
|
+
if (!ecoc_ok) {
|
1487
|
+
goto fail;
|
1488
|
+
}
|
1489
|
+
}
|
1490
|
+
|
1491
|
+
bson_append_document_end (out, &result_compactionTokens);
|
1492
|
+
|
1493
|
+
ret = true;
|
1494
|
+
fail:
|
1495
|
+
return ret;
|
1496
|
+
}
|
1497
|
+
|
1498
|
+
|
1499
|
+
/**
|
1500
|
+
* @brief Removes "encryptionInformation" from cmd.
|
1501
|
+
*/
|
1502
|
+
static bool
|
1503
|
+
_fle2_strip_encryptionInformation (const char *cmd_name,
|
1504
|
+
bson_t *cmd /* in and out */,
|
1505
|
+
mongocrypt_status_t *status)
|
1506
|
+
{
|
1507
|
+
bson_t stripped = BSON_INITIALIZER;
|
1508
|
+
bool ok = false;
|
1509
|
+
|
1510
|
+
BSON_ASSERT_PARAM (cmd_name);
|
1511
|
+
BSON_ASSERT_PARAM (cmd);
|
1512
|
+
|
1513
|
+
if (0 != strcmp (cmd_name, "explain")) {
|
1514
|
+
bson_copy_to_excluding_noinit (
|
1515
|
+
cmd, &stripped, "encryptionInformation", NULL);
|
1516
|
+
goto success;
|
1517
|
+
}
|
1518
|
+
|
1519
|
+
// The 'explain' command is a special case.
|
1520
|
+
// 'encryptionInformation' is returned from mongocryptd and csfle nested
|
1521
|
+
// inside 'explain'. Example:
|
1522
|
+
// {
|
1523
|
+
// "explain": {
|
1524
|
+
// "find": "coll"
|
1525
|
+
// "encryptionInformation": {}
|
1526
|
+
// }
|
1527
|
+
// }
|
1528
|
+
bson_iter_t iter;
|
1529
|
+
bson_t explain;
|
1530
|
+
|
1531
|
+
BSON_ASSERT (bson_iter_init_find (&iter, cmd, "explain"));
|
1532
|
+
if (!BSON_ITER_HOLDS_DOCUMENT (&iter)) {
|
1533
|
+
CLIENT_ERR ("expected 'explain' to be document");
|
1534
|
+
goto fail;
|
1535
|
+
}
|
1536
|
+
|
1537
|
+
{
|
1538
|
+
bson_t tmp;
|
1539
|
+
if (!mc_iter_document_as_bson (&iter, &tmp, status)) {
|
1540
|
+
goto fail;
|
1541
|
+
}
|
1542
|
+
bson_init (&explain);
|
1543
|
+
bson_copy_to_excluding_noinit (
|
1544
|
+
&tmp, &explain, "encryptionInformation", NULL);
|
1545
|
+
}
|
1546
|
+
|
1547
|
+
if (!BSON_APPEND_DOCUMENT (&stripped, "explain", &explain)) {
|
1548
|
+
bson_destroy (&explain);
|
1549
|
+
CLIENT_ERR ("unable to append 'explain'");
|
1550
|
+
goto fail;
|
1551
|
+
}
|
1552
|
+
bson_destroy (&explain);
|
1553
|
+
bson_copy_to_excluding_noinit (cmd, &stripped, "explain", NULL);
|
1554
|
+
|
1555
|
+
success:
|
1556
|
+
bson_destroy (cmd);
|
1557
|
+
if (!bson_steal (cmd, &stripped)) {
|
1558
|
+
CLIENT_ERR ("failed to steal BSON without encryptionInformation");
|
1559
|
+
goto fail;
|
1560
|
+
}
|
1561
|
+
ok = true;
|
1562
|
+
fail:
|
1563
|
+
if (!ok) {
|
1564
|
+
bson_destroy (&stripped);
|
1565
|
+
}
|
1566
|
+
return ok;
|
1567
|
+
}
|
1568
|
+
|
1569
|
+
/* Process a call to mongocrypt_ctx_finalize when an encryptedFieldConfig is
|
1570
|
+
* associated with the command. */
|
1571
|
+
static bool
|
1572
|
+
_fle2_finalize (mongocrypt_ctx_t *ctx, mongocrypt_binary_t *out)
|
1573
|
+
{
|
1574
|
+
bson_t converted;
|
1575
|
+
_mongocrypt_ctx_encrypt_t *ectx;
|
1576
|
+
bson_t encrypted_field_config_bson;
|
1577
|
+
bson_t original_cmd_bson;
|
1578
|
+
|
1579
|
+
BSON_ASSERT_PARAM (ctx);
|
1580
|
+
BSON_ASSERT_PARAM (out);
|
1581
|
+
|
1582
|
+
ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
1583
|
+
|
1584
|
+
BSON_ASSERT (context_uses_fle2 (ctx));
|
1585
|
+
BSON_ASSERT (ctx->state == MONGOCRYPT_CTX_READY);
|
1586
|
+
|
1587
|
+
if (ectx->explicit) {
|
1588
|
+
return _mongocrypt_ctx_fail_w_msg (
|
1589
|
+
ctx, "explicit encryption is not yet supported. See MONGOCRYPT-409.");
|
1590
|
+
}
|
1591
|
+
|
1592
|
+
if (!_mongocrypt_buffer_to_bson (&ectx->encrypted_field_config,
|
1593
|
+
&encrypted_field_config_bson)) {
|
1594
|
+
return _mongocrypt_ctx_fail_w_msg (
|
1595
|
+
ctx, "malformed bson in encrypted_field_config_bson");
|
1596
|
+
}
|
1597
|
+
|
1598
|
+
if (!_mongocrypt_buffer_to_bson (&ectx->original_cmd, &original_cmd_bson)) {
|
1599
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "malformed bson in original_cmd");
|
1600
|
+
}
|
1601
|
+
|
1602
|
+
/* If marked_cmd buffer is empty, there are no markings to encrypt. */
|
1603
|
+
if (_mongocrypt_buffer_empty (&ectx->marked_cmd)) {
|
1604
|
+
/* Append 'encryptionInformation' to the original command. */
|
1605
|
+
bson_copy_to (&original_cmd_bson, &converted);
|
1606
|
+
} else {
|
1607
|
+
bson_t as_bson;
|
1608
|
+
bson_iter_t iter;
|
1609
|
+
|
1610
|
+
if (!_mongocrypt_buffer_to_bson (&ectx->marked_cmd, &as_bson)) {
|
1611
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "malformed bson");
|
1612
|
+
}
|
1613
|
+
|
1614
|
+
bson_iter_init (&iter, &as_bson);
|
1615
|
+
bson_init (&converted);
|
1616
|
+
if (!_mongocrypt_transform_binary_in_bson (
|
1617
|
+
_replace_marking_with_ciphertext,
|
1618
|
+
&ctx->kb,
|
1619
|
+
TRAVERSE_MATCH_MARKING,
|
1620
|
+
&iter,
|
1621
|
+
&converted,
|
1622
|
+
ctx->status)) {
|
1623
|
+
bson_destroy (&converted);
|
1624
|
+
return _mongocrypt_ctx_fail (ctx);
|
1625
|
+
}
|
1626
|
+
}
|
1627
|
+
|
1628
|
+
const char *command_name = ectx->cmd_name;
|
1629
|
+
|
1630
|
+
/* Remove the 'encryptionInformation' field. It is appended in the response
|
1631
|
+
* from mongocryptd or csfle. */
|
1632
|
+
if (!_fle2_strip_encryptionInformation (
|
1633
|
+
command_name, &converted, ctx->status)) {
|
1634
|
+
bson_destroy (&converted);
|
1635
|
+
return _mongocrypt_ctx_fail (ctx);
|
1636
|
+
}
|
1637
|
+
|
1638
|
+
bson_t *deleteTokens = NULL;
|
1639
|
+
if (command_needs_deleteTokens (command_name)) {
|
1640
|
+
deleteTokens = generate_delete_tokens (
|
1641
|
+
ctx->crypt->crypto, &ctx->kb, &ectx->efc, ctx->status);
|
1642
|
+
if (!deleteTokens) {
|
1643
|
+
bson_destroy (&converted);
|
1644
|
+
return _mongocrypt_ctx_fail (ctx);
|
1645
|
+
}
|
1646
|
+
}
|
1647
|
+
|
1648
|
+
moe_result result =
|
1649
|
+
must_omit_encryptionInformation (command_name, &converted, ctx->status);
|
1650
|
+
if (!result.ok) {
|
1651
|
+
bson_destroy (&converted);
|
1652
|
+
bson_destroy (deleteTokens);
|
1653
|
+
return _mongocrypt_ctx_fail (ctx);
|
1654
|
+
}
|
1655
|
+
|
1656
|
+
/* Append a new 'encryptionInformation'. */
|
1657
|
+
if (!result.must_omit) {
|
1658
|
+
if (!_fle2_insert_encryptionInformation (command_name,
|
1659
|
+
&converted,
|
1660
|
+
ectx->ns,
|
1661
|
+
&encrypted_field_config_bson,
|
1662
|
+
deleteTokens,
|
1663
|
+
ectx->coll_name,
|
1664
|
+
MC_TO_MONGOD,
|
1665
|
+
ctx->status)) {
|
1666
|
+
bson_destroy (&converted);
|
1667
|
+
bson_destroy (deleteTokens);
|
1668
|
+
return _mongocrypt_ctx_fail (ctx);
|
1669
|
+
}
|
1670
|
+
}
|
1671
|
+
bson_destroy (deleteTokens);
|
1672
|
+
|
1673
|
+
if (!_fle2_append_compactionTokens (ctx->crypt->crypto,
|
1674
|
+
&ctx->kb,
|
1675
|
+
&ectx->efc,
|
1676
|
+
command_name,
|
1677
|
+
&converted,
|
1678
|
+
ctx->status)) {
|
1679
|
+
bson_destroy (&converted);
|
1680
|
+
return _mongocrypt_ctx_fail (ctx);
|
1681
|
+
}
|
1682
|
+
|
1683
|
+
// If input command has $db, ensure output command has $db.
|
1684
|
+
bson_iter_t iter;
|
1685
|
+
if (bson_iter_init_find (&iter, &original_cmd_bson, "$db")) {
|
1686
|
+
if (!bson_iter_init_find (&iter, &converted, "$db")) {
|
1687
|
+
BSON_APPEND_UTF8 (&converted, "$db", ectx->db_name);
|
1688
|
+
}
|
1689
|
+
}
|
1690
|
+
|
1691
|
+
_mongocrypt_buffer_steal_from_bson (&ectx->encrypted_cmd, &converted);
|
1692
|
+
_mongocrypt_buffer_to_binary (&ectx->encrypted_cmd, out);
|
1693
|
+
ctx->state = MONGOCRYPT_CTX_DONE;
|
1694
|
+
|
1695
|
+
return true;
|
1696
|
+
}
|
1697
|
+
|
1698
|
+
static bool
|
1699
|
+
FLE2RangeFindDriverSpec_to_ciphertexts (mongocrypt_ctx_t *ctx,
|
1700
|
+
mongocrypt_binary_t *out)
|
1701
|
+
{
|
1702
|
+
bool ok = false;
|
1703
|
+
_mongocrypt_ctx_encrypt_t *ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
1704
|
+
|
1705
|
+
BSON_ASSERT_PARAM (ctx);
|
1706
|
+
BSON_ASSERT_PARAM (out);
|
1707
|
+
|
1708
|
+
if (!ctx->opts.rangeopts.set) {
|
1709
|
+
_mongocrypt_ctx_fail_w_msg (
|
1710
|
+
ctx, "Expected RangeOpts to be set for Range Find");
|
1711
|
+
goto fail;
|
1712
|
+
}
|
1713
|
+
if (!ctx->opts.contention_factor.set) {
|
1714
|
+
_mongocrypt_ctx_fail_w_msg (
|
1715
|
+
ctx, "Expected Contention Factor to be set for Range Find");
|
1716
|
+
goto fail;
|
1717
|
+
}
|
1718
|
+
|
1719
|
+
bson_t with_placholders = BSON_INITIALIZER;
|
1720
|
+
bson_t with_ciphertexts = BSON_INITIALIZER;
|
1721
|
+
bson_t in_bson;
|
1722
|
+
if (!_mongocrypt_buffer_to_bson (&ectx->original_cmd, &in_bson)) {
|
1723
|
+
_mongocrypt_ctx_fail_w_msg (ctx, "unable to convert input to BSON");
|
1724
|
+
goto fail;
|
1725
|
+
}
|
1726
|
+
|
1727
|
+
bson_t v_doc;
|
1728
|
+
// Parse 'v' document from input.
|
1729
|
+
{
|
1730
|
+
bson_iter_t v_iter;
|
1731
|
+
if (!bson_iter_init_find (&v_iter, &in_bson, "v")) {
|
1732
|
+
_mongocrypt_ctx_fail_w_msg (ctx,
|
1733
|
+
"invalid input BSON, must contain 'v'");
|
1734
|
+
goto fail;
|
1735
|
+
}
|
1736
|
+
if (!BSON_ITER_HOLDS_DOCUMENT (&v_iter)) {
|
1737
|
+
_mongocrypt_ctx_fail_w_msg (
|
1738
|
+
ctx, "invalid input BSON, expected 'v' to be document");
|
1739
|
+
goto fail;
|
1740
|
+
}
|
1741
|
+
if (!mc_iter_document_as_bson (&v_iter, &v_doc, ctx->status)) {
|
1742
|
+
_mongocrypt_ctx_fail (ctx);
|
1743
|
+
goto fail;
|
1744
|
+
}
|
1745
|
+
}
|
1746
|
+
|
1747
|
+
// Parse FLE2RangeFindDriverSpec.
|
1748
|
+
{
|
1749
|
+
mc_FLE2RangeFindDriverSpec_t rfds;
|
1750
|
+
|
1751
|
+
if (!mc_FLE2RangeFindDriverSpec_parse (&rfds, &v_doc, ctx->status)) {
|
1752
|
+
_mongocrypt_ctx_fail (ctx);
|
1753
|
+
goto fail;
|
1754
|
+
}
|
1755
|
+
|
1756
|
+
// Convert FLE2RangeFindDriverSpec into a document with placeholders.
|
1757
|
+
if (!mc_FLE2RangeFindDriverSpec_to_placeholders (
|
1758
|
+
&rfds,
|
1759
|
+
&ctx->opts.rangeopts.value,
|
1760
|
+
ctx->opts.contention_factor.value,
|
1761
|
+
&ctx->opts.key_id,
|
1762
|
+
_mongocrypt_buffer_empty (&ctx->opts.index_key_id)
|
1763
|
+
? &ctx->opts.key_id
|
1764
|
+
: &ctx->opts.index_key_id,
|
1765
|
+
mc_getNextPayloadId (),
|
1766
|
+
&with_placholders,
|
1767
|
+
ctx->status)) {
|
1768
|
+
_mongocrypt_ctx_fail (ctx);
|
1769
|
+
goto fail;
|
1770
|
+
}
|
1771
|
+
}
|
1772
|
+
|
1773
|
+
// Convert document with placeholders into document with ciphertexts.
|
1774
|
+
{
|
1775
|
+
bson_iter_t iter;
|
1776
|
+
if (!bson_iter_init (&iter, &with_placholders)) {
|
1777
|
+
_mongocrypt_ctx_fail_w_msg (
|
1778
|
+
ctx, "unable to iterate into placeholder document");
|
1779
|
+
goto fail;
|
1780
|
+
}
|
1781
|
+
if (!_mongocrypt_transform_binary_in_bson (
|
1782
|
+
_replace_marking_with_ciphertext,
|
1783
|
+
&ctx->kb,
|
1784
|
+
TRAVERSE_MATCH_MARKING,
|
1785
|
+
&iter,
|
1786
|
+
&with_ciphertexts,
|
1787
|
+
ctx->status)) {
|
1788
|
+
goto fail;
|
1789
|
+
}
|
1790
|
+
}
|
1791
|
+
|
1792
|
+
// Wrap result in the document: { 'v': <result> }.
|
1793
|
+
{
|
1794
|
+
/* v_wrapped is the BSON document { 'v': <v_out> }. */
|
1795
|
+
bson_t v_wrapped = BSON_INITIALIZER;
|
1796
|
+
if (!bson_append_document (
|
1797
|
+
&v_wrapped, MONGOCRYPT_STR_AND_LEN ("v"), &with_ciphertexts)) {
|
1798
|
+
_mongocrypt_ctx_fail_w_msg (ctx, "unable to append document to 'v'");
|
1799
|
+
goto fail;
|
1800
|
+
}
|
1801
|
+
_mongocrypt_buffer_steal_from_bson (&ectx->encrypted_cmd, &v_wrapped);
|
1802
|
+
_mongocrypt_buffer_to_binary (&ectx->encrypted_cmd, out);
|
1803
|
+
ctx->state = MONGOCRYPT_CTX_DONE;
|
1804
|
+
}
|
1805
|
+
|
1806
|
+
ok = true;
|
1807
|
+
fail:
|
1808
|
+
bson_destroy (&with_ciphertexts);
|
1809
|
+
bson_destroy (&with_placholders);
|
1810
|
+
return ok;
|
1811
|
+
}
|
1812
|
+
|
1813
|
+
static bool
|
1814
|
+
_fle2_finalize_explicit (mongocrypt_ctx_t *ctx, mongocrypt_binary_t *out)
|
1815
|
+
{
|
1816
|
+
bool ret = false;
|
1817
|
+
_mongocrypt_marking_t marking;
|
1818
|
+
_mongocrypt_ctx_encrypt_t *ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
1819
|
+
|
1820
|
+
BSON_ASSERT_PARAM (ctx);
|
1821
|
+
BSON_ASSERT_PARAM (out);
|
1822
|
+
|
1823
|
+
BSON_ASSERT (ctx->opts.index_type.set);
|
1824
|
+
|
1825
|
+
if (ctx->opts.rangeopts.set && ctx->opts.query_type.set) {
|
1826
|
+
// RangeOpts with query type is a special case. The result contains two
|
1827
|
+
// ciphertext values.
|
1828
|
+
return FLE2RangeFindDriverSpec_to_ciphertexts (ctx, out);
|
1829
|
+
}
|
1830
|
+
|
1831
|
+
bson_t new_v = BSON_INITIALIZER;
|
1832
|
+
|
1833
|
+
_mongocrypt_marking_init (&marking);
|
1834
|
+
marking.type = MONGOCRYPT_MARKING_FLE2_ENCRYPTION;
|
1835
|
+
if (ctx->opts.query_type.set) {
|
1836
|
+
switch (ctx->opts.query_type.value) {
|
1837
|
+
case MONGOCRYPT_QUERY_TYPE_RANGEPREVIEW:
|
1838
|
+
case MONGOCRYPT_QUERY_TYPE_EQUALITY:
|
1839
|
+
marking.fle2.type = MONGOCRYPT_FLE2_PLACEHOLDER_TYPE_FIND;
|
1840
|
+
break;
|
1841
|
+
default:
|
1842
|
+
_mongocrypt_ctx_fail_w_msg (ctx,
|
1843
|
+
"Invalid value for EncryptOpts.queryType");
|
1844
|
+
goto fail;
|
1845
|
+
}
|
1846
|
+
} else {
|
1847
|
+
marking.fle2.type = MONGOCRYPT_FLE2_PLACEHOLDER_TYPE_INSERT;
|
1848
|
+
}
|
1849
|
+
|
1850
|
+
switch (ctx->opts.index_type.value) {
|
1851
|
+
case MONGOCRYPT_INDEX_TYPE_EQUALITY:
|
1852
|
+
marking.fle2.algorithm = MONGOCRYPT_FLE2_ALGORITHM_EQUALITY;
|
1853
|
+
break;
|
1854
|
+
case MONGOCRYPT_INDEX_TYPE_NONE:
|
1855
|
+
marking.fle2.algorithm = MONGOCRYPT_FLE2_ALGORITHM_UNINDEXED;
|
1856
|
+
break;
|
1857
|
+
case MONGOCRYPT_INDEX_TYPE_RANGEPREVIEW:
|
1858
|
+
marking.fle2.algorithm = MONGOCRYPT_FLE2_ALGORITHM_RANGE;
|
1859
|
+
break;
|
1860
|
+
default:
|
1861
|
+
// This might be unreachable because of other validation. Better safe than
|
1862
|
+
// sorry.
|
1863
|
+
_mongocrypt_ctx_fail_w_msg (ctx,
|
1864
|
+
"Invalid value for EncryptOpts.indexType");
|
1865
|
+
goto fail;
|
1866
|
+
}
|
1867
|
+
|
1868
|
+
if (ctx->opts.rangeopts.set) {
|
1869
|
+
// Process the RangeOpts and the input 'v' document into a new 'v'.
|
1870
|
+
// The new 'v' document will be a FLE2RangeFindSpec or
|
1871
|
+
// FLE2RangeInsertSpec.
|
1872
|
+
bson_t old_v;
|
1873
|
+
|
1874
|
+
if (!_mongocrypt_buffer_to_bson (&ectx->original_cmd, &old_v)) {
|
1875
|
+
_mongocrypt_ctx_fail_w_msg (ctx, "unable to convert input to BSON");
|
1876
|
+
goto fail;
|
1877
|
+
}
|
1878
|
+
|
1879
|
+
// RangeOpts with query_type is handled above.
|
1880
|
+
BSON_ASSERT (!ctx->opts.query_type.set);
|
1881
|
+
if (!mc_RangeOpts_to_FLE2RangeInsertSpec (
|
1882
|
+
&ctx->opts.rangeopts.value, &old_v, &new_v, ctx->status)) {
|
1883
|
+
_mongocrypt_ctx_fail (ctx);
|
1884
|
+
goto fail;
|
1885
|
+
}
|
1886
|
+
|
1887
|
+
|
1888
|
+
if (!bson_iter_init_find (&marking.v_iter, &new_v, "v")) {
|
1889
|
+
_mongocrypt_ctx_fail_w_msg (ctx,
|
1890
|
+
"invalid input BSON, must contain 'v'");
|
1891
|
+
goto fail;
|
1892
|
+
}
|
1893
|
+
|
1894
|
+
marking.fle2.sparsity = ctx->opts.rangeopts.value.sparsity;
|
1895
|
+
|
1896
|
+
} else {
|
1897
|
+
bson_t as_bson;
|
1898
|
+
|
1899
|
+
/* Get iterator to input 'v' BSON value. */
|
1900
|
+
if (!_mongocrypt_buffer_to_bson (&ectx->original_cmd, &as_bson)) {
|
1901
|
+
_mongocrypt_ctx_fail_w_msg (ctx, "unable to convert input to BSON");
|
1902
|
+
goto fail;
|
1903
|
+
}
|
1904
|
+
|
1905
|
+
if (!bson_iter_init_find (&marking.v_iter, &as_bson, "v")) {
|
1906
|
+
_mongocrypt_ctx_fail_w_msg (ctx,
|
1907
|
+
"invalid input BSON, must contain 'v'");
|
1908
|
+
goto fail;
|
1909
|
+
}
|
1910
|
+
}
|
1911
|
+
|
1912
|
+
_mongocrypt_buffer_copy_to (&ctx->opts.key_id, &marking.fle2.user_key_id);
|
1913
|
+
if (!_mongocrypt_buffer_empty (&ctx->opts.index_key_id)) {
|
1914
|
+
_mongocrypt_buffer_copy_to (&ctx->opts.index_key_id,
|
1915
|
+
&marking.fle2.index_key_id);
|
1916
|
+
} else {
|
1917
|
+
_mongocrypt_buffer_copy_to (&ctx->opts.key_id,
|
1918
|
+
&marking.fle2.index_key_id);
|
1919
|
+
}
|
1920
|
+
|
1921
|
+
if (ctx->opts.contention_factor.set) {
|
1922
|
+
marking.fle2.maxContentionCounter = ctx->opts.contention_factor.value;
|
1923
|
+
} else if (ctx->opts.index_type.value == MONGOCRYPT_INDEX_TYPE_EQUALITY) {
|
1924
|
+
_mongocrypt_ctx_fail_w_msg (
|
1925
|
+
ctx, "contention factor required for indexed algorithm");
|
1926
|
+
goto fail;
|
1927
|
+
}
|
1928
|
+
|
1929
|
+
/* Convert marking to ciphertext. */
|
1930
|
+
{
|
1931
|
+
bson_value_t v_out;
|
1932
|
+
/* v_wrapped is the BSON document { 'v': <v_out> }. */
|
1933
|
+
bson_t v_wrapped = BSON_INITIALIZER;
|
1934
|
+
|
1935
|
+
if (!_marking_to_bson_value (&ctx->kb, &marking, &v_out, ctx->status)) {
|
1936
|
+
bson_destroy (&v_wrapped);
|
1937
|
+
_mongocrypt_ctx_fail (ctx);
|
1938
|
+
goto fail;
|
1939
|
+
}
|
1940
|
+
|
1941
|
+
bson_append_value (&v_wrapped, MONGOCRYPT_STR_AND_LEN ("v"), &v_out);
|
1942
|
+
_mongocrypt_buffer_steal_from_bson (&ectx->encrypted_cmd, &v_wrapped);
|
1943
|
+
_mongocrypt_buffer_to_binary (&ectx->encrypted_cmd, out);
|
1944
|
+
ctx->state = MONGOCRYPT_CTX_DONE;
|
1945
|
+
bson_value_destroy (&v_out);
|
1946
|
+
}
|
1947
|
+
|
1948
|
+
ret = true;
|
1949
|
+
fail:
|
1950
|
+
bson_destroy (&new_v);
|
1951
|
+
_mongocrypt_marking_cleanup (&marking);
|
1952
|
+
return ret;
|
1953
|
+
}
|
1954
|
+
|
1955
|
+
static bool
|
1956
|
+
_finalize (mongocrypt_ctx_t *ctx, mongocrypt_binary_t *out)
|
1957
|
+
{
|
1958
|
+
bson_t as_bson, converted;
|
1959
|
+
bson_iter_t iter;
|
1960
|
+
_mongocrypt_ctx_encrypt_t *ectx;
|
1961
|
+
bool res;
|
1962
|
+
|
1963
|
+
BSON_ASSERT_PARAM (ctx);
|
1964
|
+
BSON_ASSERT_PARAM (out);
|
1965
|
+
|
1966
|
+
ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
1967
|
+
|
1968
|
+
if (context_uses_fle2 (ctx)) {
|
1969
|
+
return _fle2_finalize (ctx, out);
|
1970
|
+
} else if (ctx->opts.index_type.set) {
|
1971
|
+
return _fle2_finalize_explicit (ctx, out);
|
1972
|
+
}
|
1973
|
+
|
1974
|
+
if (!ectx->explicit) {
|
1975
|
+
if (ctx->nothing_to_do) {
|
1976
|
+
_mongocrypt_buffer_to_binary (&ectx->original_cmd, out);
|
1977
|
+
ctx->state = MONGOCRYPT_CTX_DONE;
|
1978
|
+
return true;
|
1979
|
+
}
|
1980
|
+
if (!_mongocrypt_buffer_to_bson (&ectx->marked_cmd, &as_bson)) {
|
1981
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "malformed bson");
|
1982
|
+
}
|
1983
|
+
|
1984
|
+
bson_iter_init (&iter, &as_bson);
|
1985
|
+
bson_init (&converted);
|
1986
|
+
if (!_mongocrypt_transform_binary_in_bson (
|
1987
|
+
_replace_marking_with_ciphertext,
|
1988
|
+
&ctx->kb,
|
1989
|
+
TRAVERSE_MATCH_MARKING,
|
1990
|
+
&iter,
|
1991
|
+
&converted,
|
1992
|
+
ctx->status)) {
|
1993
|
+
bson_destroy (&converted);
|
1994
|
+
return _mongocrypt_ctx_fail (ctx);
|
1995
|
+
}
|
1996
|
+
|
1997
|
+
bson_t original_cmd_bson;
|
1998
|
+
if (!_mongocrypt_buffer_to_bson (&ectx->original_cmd,
|
1999
|
+
&original_cmd_bson)) {
|
2000
|
+
return _mongocrypt_ctx_fail_w_msg (ctx,
|
2001
|
+
"malformed bson in original_cmd");
|
2002
|
+
}
|
2003
|
+
|
2004
|
+
// If input command has $db, ensure output command has $db.
|
2005
|
+
bson_iter_t iter;
|
2006
|
+
if (bson_iter_init_find (&iter, &original_cmd_bson, "$db")) {
|
2007
|
+
if (!bson_iter_init_find (&iter, &converted, "$db")) {
|
2008
|
+
BSON_APPEND_UTF8 (&converted, "$db", ectx->db_name);
|
2009
|
+
}
|
2010
|
+
}
|
2011
|
+
} else {
|
2012
|
+
/* For explicit encryption, we have no marking, but we can fake one */
|
2013
|
+
_mongocrypt_marking_t marking;
|
2014
|
+
bson_value_t value;
|
2015
|
+
|
2016
|
+
memset (&value, 0, sizeof (value));
|
2017
|
+
|
2018
|
+
_mongocrypt_marking_init (&marking);
|
2019
|
+
|
2020
|
+
if (!_mongocrypt_buffer_to_bson (&ectx->original_cmd, &as_bson)) {
|
2021
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "malformed bson");
|
2022
|
+
}
|
2023
|
+
|
2024
|
+
if (!bson_iter_init_find (&iter, &as_bson, "v")) {
|
2025
|
+
return _mongocrypt_ctx_fail_w_msg (ctx,
|
2026
|
+
"invalid msg, must contain 'v'");
|
2027
|
+
}
|
2028
|
+
|
2029
|
+
|
2030
|
+
memcpy (&marking.v_iter, &iter, sizeof (bson_iter_t));
|
2031
|
+
marking.algorithm = ctx->opts.algorithm;
|
2032
|
+
_mongocrypt_buffer_set_to (&ctx->opts.key_id, &marking.key_id);
|
2033
|
+
if (ctx->opts.key_alt_names) {
|
2034
|
+
bson_value_copy (&ctx->opts.key_alt_names->value,
|
2035
|
+
&marking.key_alt_name);
|
2036
|
+
marking.type = MONGOCRYPT_MARKING_FLE1_BY_ALTNAME;
|
2037
|
+
}
|
2038
|
+
|
2039
|
+
bson_init (&converted);
|
2040
|
+
res = _marking_to_bson_value (&ctx->kb, &marking, &value, ctx->status);
|
2041
|
+
if (res) {
|
2042
|
+
bson_append_value (&converted, MONGOCRYPT_STR_AND_LEN ("v"), &value);
|
2043
|
+
}
|
2044
|
+
|
2045
|
+
bson_value_destroy (&value);
|
2046
|
+
_mongocrypt_marking_cleanup (&marking);
|
2047
|
+
|
2048
|
+
if (!res) {
|
2049
|
+
bson_destroy (&converted);
|
2050
|
+
return _mongocrypt_ctx_fail (ctx);
|
2051
|
+
}
|
2052
|
+
}
|
2053
|
+
|
2054
|
+
_mongocrypt_buffer_steal_from_bson (&ectx->encrypted_cmd, &converted);
|
2055
|
+
_mongocrypt_buffer_to_binary (&ectx->encrypted_cmd, out);
|
2056
|
+
ctx->state = MONGOCRYPT_CTX_DONE;
|
2057
|
+
|
2058
|
+
return true;
|
2059
|
+
}
|
2060
|
+
|
2061
|
+
|
2062
|
+
static void
|
2063
|
+
_cleanup (mongocrypt_ctx_t *ctx)
|
2064
|
+
{
|
2065
|
+
_mongocrypt_ctx_encrypt_t *ectx;
|
2066
|
+
|
2067
|
+
if (!ctx) {
|
2068
|
+
return;
|
2069
|
+
}
|
2070
|
+
|
2071
|
+
ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
2072
|
+
bson_free (ectx->ns);
|
2073
|
+
bson_free (ectx->db_name);
|
2074
|
+
bson_free (ectx->coll_name);
|
2075
|
+
_mongocrypt_buffer_cleanup (&ectx->list_collections_filter);
|
2076
|
+
_mongocrypt_buffer_cleanup (&ectx->schema);
|
2077
|
+
_mongocrypt_buffer_cleanup (&ectx->encrypted_field_config);
|
2078
|
+
_mongocrypt_buffer_cleanup (&ectx->original_cmd);
|
2079
|
+
_mongocrypt_buffer_cleanup (&ectx->mongocryptd_cmd);
|
2080
|
+
_mongocrypt_buffer_cleanup (&ectx->marked_cmd);
|
2081
|
+
_mongocrypt_buffer_cleanup (&ectx->encrypted_cmd);
|
2082
|
+
_mongocrypt_buffer_cleanup (&ectx->ismaster.cmd);
|
2083
|
+
mc_EncryptedFieldConfig_cleanup (&ectx->efc);
|
2084
|
+
}
|
2085
|
+
|
2086
|
+
|
2087
|
+
static bool
|
2088
|
+
_try_schema_from_schema_map (mongocrypt_ctx_t *ctx)
|
2089
|
+
{
|
2090
|
+
mongocrypt_t *crypt;
|
2091
|
+
_mongocrypt_ctx_encrypt_t *ectx;
|
2092
|
+
bson_t schema_map;
|
2093
|
+
bson_iter_t iter;
|
2094
|
+
|
2095
|
+
BSON_ASSERT_PARAM (ctx);
|
2096
|
+
|
2097
|
+
crypt = ctx->crypt;
|
2098
|
+
ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
2099
|
+
|
2100
|
+
if (_mongocrypt_buffer_empty (&crypt->opts.schema_map)) {
|
2101
|
+
/* No schema map set. */
|
2102
|
+
return true;
|
2103
|
+
}
|
2104
|
+
|
2105
|
+
if (!_mongocrypt_buffer_to_bson (&crypt->opts.schema_map, &schema_map)) {
|
2106
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "malformed schema map");
|
2107
|
+
}
|
2108
|
+
|
2109
|
+
if (bson_iter_init_find (&iter, &schema_map, ectx->ns)) {
|
2110
|
+
if (!_mongocrypt_buffer_copy_from_document_iter (&ectx->schema, &iter)) {
|
2111
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "malformed schema map");
|
2112
|
+
}
|
2113
|
+
ectx->used_local_schema = true;
|
2114
|
+
ctx->state = MONGOCRYPT_CTX_NEED_MONGO_MARKINGS;
|
2115
|
+
}
|
2116
|
+
|
2117
|
+
/* No schema found in map. */
|
2118
|
+
return true;
|
2119
|
+
}
|
2120
|
+
|
2121
|
+
/* Check if the local encrypted field config map has an entry for this
|
2122
|
+
* collection.
|
2123
|
+
* If an encrypted field config is found, the context transitions to
|
2124
|
+
* MONGOCRYPT_CTX_NEED_MONGO_MARKINGS. */
|
2125
|
+
static bool
|
2126
|
+
_fle2_try_encrypted_field_config_from_map (mongocrypt_ctx_t *ctx)
|
2127
|
+
{
|
2128
|
+
mongocrypt_t *crypt;
|
2129
|
+
_mongocrypt_ctx_encrypt_t *ectx;
|
2130
|
+
bson_t encrypted_field_config_map;
|
2131
|
+
bson_iter_t iter;
|
2132
|
+
|
2133
|
+
BSON_ASSERT_PARAM (ctx);
|
2134
|
+
|
2135
|
+
crypt = ctx->crypt;
|
2136
|
+
ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
2137
|
+
|
2138
|
+
if (_mongocrypt_buffer_empty (&crypt->opts.encrypted_field_config_map)) {
|
2139
|
+
/* No encrypted_field_config_map set. */
|
2140
|
+
return true;
|
2141
|
+
}
|
2142
|
+
|
2143
|
+
if (!_mongocrypt_buffer_to_bson (&crypt->opts.encrypted_field_config_map,
|
2144
|
+
&encrypted_field_config_map)) {
|
2145
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2146
|
+
ctx, "unable to convert encrypted_field_config_map to BSON");
|
2147
|
+
}
|
2148
|
+
|
2149
|
+
if (bson_iter_init_find (&iter, &encrypted_field_config_map, ectx->ns)) {
|
2150
|
+
if (!_mongocrypt_buffer_copy_from_document_iter (
|
2151
|
+
&ectx->encrypted_field_config, &iter)) {
|
2152
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2153
|
+
ctx,
|
2154
|
+
"unable to copy encrypted_field_config from "
|
2155
|
+
"encrypted_field_config_map");
|
2156
|
+
}
|
2157
|
+
bson_t efc_bson;
|
2158
|
+
if (!_mongocrypt_buffer_to_bson (&ectx->encrypted_field_config,
|
2159
|
+
&efc_bson)) {
|
2160
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2161
|
+
ctx, "unable to create BSON from encrypted_field_config");
|
2162
|
+
}
|
2163
|
+
if (!mc_EncryptedFieldConfig_parse (&ectx->efc, &efc_bson, ctx->status)) {
|
2164
|
+
_mongocrypt_ctx_fail (ctx);
|
2165
|
+
return false;
|
2166
|
+
}
|
2167
|
+
ctx->state = MONGOCRYPT_CTX_NEED_MONGO_MARKINGS;
|
2168
|
+
}
|
2169
|
+
|
2170
|
+
/* No encrypted_field_config found in map. */
|
2171
|
+
return true;
|
2172
|
+
}
|
2173
|
+
|
2174
|
+
|
2175
|
+
static bool
|
2176
|
+
_try_schema_from_cache (mongocrypt_ctx_t *ctx)
|
2177
|
+
{
|
2178
|
+
_mongocrypt_ctx_encrypt_t *ectx;
|
2179
|
+
bson_t *collinfo = NULL;
|
2180
|
+
|
2181
|
+
BSON_ASSERT_PARAM (ctx);
|
2182
|
+
|
2183
|
+
ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
2184
|
+
|
2185
|
+
/* Otherwise, we need a remote schema. Check if we have a response to
|
2186
|
+
* listCollections cached. */
|
2187
|
+
if (!_mongocrypt_cache_get (&ctx->crypt->cache_collinfo,
|
2188
|
+
ectx->ns /* null terminated */,
|
2189
|
+
(void **) &collinfo)) {
|
2190
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "failed to retrieve from cache");
|
2191
|
+
}
|
2192
|
+
|
2193
|
+
if (collinfo) {
|
2194
|
+
if (!_set_schema_from_collinfo (ctx, collinfo)) {
|
2195
|
+
return _mongocrypt_ctx_fail (ctx);
|
2196
|
+
}
|
2197
|
+
ctx->state = MONGOCRYPT_CTX_NEED_MONGO_MARKINGS;
|
2198
|
+
} else {
|
2199
|
+
/* we need to get it. */
|
2200
|
+
ctx->state = MONGOCRYPT_CTX_NEED_MONGO_COLLINFO;
|
2201
|
+
}
|
2202
|
+
|
2203
|
+
bson_destroy (collinfo);
|
2204
|
+
return true;
|
2205
|
+
}
|
2206
|
+
|
2207
|
+
/* _try_empty_schema_for_create uses an empty JSON schema for the create
|
2208
|
+
* command. This is to avoid an unnecessary 'listCollections' command for
|
2209
|
+
* create. */
|
2210
|
+
static bool
|
2211
|
+
_try_empty_schema_for_create (mongocrypt_ctx_t *ctx)
|
2212
|
+
{
|
2213
|
+
_mongocrypt_ctx_encrypt_t *ectx;
|
2214
|
+
|
2215
|
+
BSON_ASSERT_PARAM (ctx);
|
2216
|
+
|
2217
|
+
ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
2218
|
+
/* As a special case, use an empty schema for the 'create' command. */
|
2219
|
+
const char *cmd_name = ectx->cmd_name;
|
2220
|
+
|
2221
|
+
if (0 != strcmp (cmd_name, "create")) {
|
2222
|
+
return true;
|
2223
|
+
}
|
2224
|
+
|
2225
|
+
bson_t empty = BSON_INITIALIZER;
|
2226
|
+
_mongocrypt_buffer_steal_from_bson (&ectx->schema, &empty);
|
2227
|
+
ctx->state = MONGOCRYPT_CTX_NEED_MONGO_MARKINGS;
|
2228
|
+
return true;
|
2229
|
+
}
|
2230
|
+
|
2231
|
+
/* _try_schema_from_create_or_collMod_cmd tries to find a JSON schema included
|
2232
|
+
* in a create or collMod command by checking for "validator.$jsonSchema".
|
2233
|
+
* Example:
|
2234
|
+
* {
|
2235
|
+
* "create" : "coll",
|
2236
|
+
* "validator" : {
|
2237
|
+
* "$jsonSchema" : {
|
2238
|
+
* "properties" : { "a" : { "bsonType" : "number" } }
|
2239
|
+
* }
|
2240
|
+
* }
|
2241
|
+
* }
|
2242
|
+
* If the "create" command does not include a JSON schema, an empty JSON schema
|
2243
|
+
* is returned. This is to avoid an unnecessary 'listCollections' command for
|
2244
|
+
* create.
|
2245
|
+
*
|
2246
|
+
* If the "collMod" command does not include a JSON schema, a schema is later
|
2247
|
+
* requested by entering the MONGOCRYPT_CTX_NEED_MONGO_COLLINFO state.
|
2248
|
+
* This is because a "collMod" command may have sensitive data in the
|
2249
|
+
* "validator" field.
|
2250
|
+
*/
|
2251
|
+
static bool
|
2252
|
+
_try_schema_from_create_or_collMod_cmd (mongocrypt_ctx_t *ctx)
|
2253
|
+
{
|
2254
|
+
_mongocrypt_ctx_encrypt_t *ectx;
|
2255
|
+
mongocrypt_status_t *status;
|
2256
|
+
|
2257
|
+
BSON_ASSERT_PARAM (ctx);
|
2258
|
+
|
2259
|
+
status = ctx->status;
|
2260
|
+
|
2261
|
+
ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
2262
|
+
const char *cmd_name = ectx->cmd_name;
|
2263
|
+
|
2264
|
+
if (0 != strcmp (cmd_name, "create") && 0 != strcmp (cmd_name, "collMod")) {
|
2265
|
+
return true;
|
2266
|
+
}
|
2267
|
+
|
2268
|
+
bson_t cmd_bson;
|
2269
|
+
bson_iter_t iter;
|
2270
|
+
|
2271
|
+
if (!_mongocrypt_buffer_to_bson (&ectx->original_cmd, &cmd_bson)) {
|
2272
|
+
CLIENT_ERR ("unable to convert command buffer to BSON");
|
2273
|
+
_mongocrypt_ctx_fail (ctx);
|
2274
|
+
return false;
|
2275
|
+
}
|
2276
|
+
|
2277
|
+
if (!bson_iter_init (&iter, &cmd_bson)) {
|
2278
|
+
CLIENT_ERR ("unable to iterate over command BSON");
|
2279
|
+
_mongocrypt_ctx_fail (ctx);
|
2280
|
+
return false;
|
2281
|
+
}
|
2282
|
+
|
2283
|
+
if (bson_iter_find_descendant (&iter, "validator.$jsonSchema", &iter)) {
|
2284
|
+
if (!_mongocrypt_buffer_copy_from_document_iter (&ectx->schema, &iter)) {
|
2285
|
+
CLIENT_ERR (
|
2286
|
+
"failed to parse BSON document from create validator.$jsonSchema");
|
2287
|
+
_mongocrypt_ctx_fail (ctx);
|
2288
|
+
return false;
|
2289
|
+
}
|
2290
|
+
ctx->state = MONGOCRYPT_CTX_NEED_MONGO_MARKINGS;
|
2291
|
+
return true;
|
2292
|
+
}
|
2293
|
+
|
2294
|
+
return true;
|
2295
|
+
}
|
2296
|
+
|
2297
|
+
static bool
|
2298
|
+
_permitted_for_encryption (bson_iter_t *iter,
|
2299
|
+
mongocrypt_encryption_algorithm_t algo,
|
2300
|
+
mongocrypt_status_t *status)
|
2301
|
+
{
|
2302
|
+
bson_type_t bson_type;
|
2303
|
+
const bson_value_t *bson_value;
|
2304
|
+
bool ret = false;
|
2305
|
+
|
2306
|
+
BSON_ASSERT_PARAM (iter);
|
2307
|
+
|
2308
|
+
bson_value = bson_iter_value (iter);
|
2309
|
+
if (!bson_value) {
|
2310
|
+
CLIENT_ERR ("Unknown BSON type");
|
2311
|
+
goto fail;
|
2312
|
+
}
|
2313
|
+
bson_type = bson_value->value_type;
|
2314
|
+
switch (bson_type) {
|
2315
|
+
case BSON_TYPE_NULL:
|
2316
|
+
case BSON_TYPE_MINKEY:
|
2317
|
+
case BSON_TYPE_MAXKEY:
|
2318
|
+
case BSON_TYPE_UNDEFINED:
|
2319
|
+
CLIENT_ERR ("BSON type invalid for encryption");
|
2320
|
+
goto fail;
|
2321
|
+
case BSON_TYPE_BINARY:
|
2322
|
+
if (bson_value->value.v_binary.subtype == BSON_SUBTYPE_ENCRYPTED) {
|
2323
|
+
CLIENT_ERR ("BSON binary subtype 6 is invalid for encryption");
|
2324
|
+
goto fail;
|
2325
|
+
}
|
2326
|
+
/* ok */
|
2327
|
+
break;
|
2328
|
+
case BSON_TYPE_DOUBLE:
|
2329
|
+
case BSON_TYPE_DOCUMENT:
|
2330
|
+
case BSON_TYPE_ARRAY:
|
2331
|
+
case BSON_TYPE_CODEWSCOPE:
|
2332
|
+
case BSON_TYPE_BOOL:
|
2333
|
+
case BSON_TYPE_DECIMAL128:
|
2334
|
+
if (algo == MONGOCRYPT_ENCRYPTION_ALGORITHM_DETERMINISTIC) {
|
2335
|
+
CLIENT_ERR ("BSON type invalid for deterministic encryption");
|
2336
|
+
goto fail;
|
2337
|
+
}
|
2338
|
+
break;
|
2339
|
+
case BSON_TYPE_UTF8:
|
2340
|
+
case BSON_TYPE_OID:
|
2341
|
+
case BSON_TYPE_DATE_TIME:
|
2342
|
+
case BSON_TYPE_REGEX:
|
2343
|
+
case BSON_TYPE_DBPOINTER:
|
2344
|
+
case BSON_TYPE_CODE:
|
2345
|
+
case BSON_TYPE_SYMBOL:
|
2346
|
+
case BSON_TYPE_INT32:
|
2347
|
+
case BSON_TYPE_TIMESTAMP:
|
2348
|
+
case BSON_TYPE_INT64:
|
2349
|
+
/* ok */
|
2350
|
+
break;
|
2351
|
+
case BSON_TYPE_EOD:
|
2352
|
+
default:
|
2353
|
+
CLIENT_ERR ("invalid BSON value type 00");
|
2354
|
+
goto fail;
|
2355
|
+
}
|
2356
|
+
|
2357
|
+
ret = true;
|
2358
|
+
fail:
|
2359
|
+
return ret;
|
2360
|
+
}
|
2361
|
+
|
2362
|
+
// explicit_encrypt_init is common code shared by
|
2363
|
+
// mongocrypt_ctx_explicit_encrypt_init and
|
2364
|
+
// mongocrypt_ctx_explicit_encrypt_expression_init.
|
2365
|
+
static bool
|
2366
|
+
explicit_encrypt_init (mongocrypt_ctx_t *ctx, mongocrypt_binary_t *msg)
|
2367
|
+
{
|
2368
|
+
_mongocrypt_ctx_encrypt_t *ectx;
|
2369
|
+
bson_t as_bson;
|
2370
|
+
bson_iter_t iter;
|
2371
|
+
_mongocrypt_ctx_opts_spec_t opts_spec;
|
2372
|
+
|
2373
|
+
if (!ctx) {
|
2374
|
+
return false;
|
2375
|
+
}
|
2376
|
+
memset (&opts_spec, 0, sizeof (opts_spec));
|
2377
|
+
opts_spec.key_descriptor = OPT_REQUIRED;
|
2378
|
+
opts_spec.algorithm = OPT_OPTIONAL;
|
2379
|
+
opts_spec.rangeopts = OPT_OPTIONAL;
|
2380
|
+
|
2381
|
+
if (!_mongocrypt_ctx_init (ctx, &opts_spec)) {
|
2382
|
+
return false;
|
2383
|
+
}
|
2384
|
+
|
2385
|
+
/* Error if any mutually exclusive FLE 1 and FLE 2 options are set. */
|
2386
|
+
{
|
2387
|
+
/* key_alt_names is FLE 1 only. */
|
2388
|
+
if (ctx->opts.key_alt_names != NULL) {
|
2389
|
+
if (ctx->opts.index_type.set) {
|
2390
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2391
|
+
ctx, "cannot set both key alt name and index type");
|
2392
|
+
}
|
2393
|
+
if (!_mongocrypt_buffer_empty (&ctx->opts.index_key_id)) {
|
2394
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2395
|
+
ctx, "cannot set both key alt name and index key id");
|
2396
|
+
}
|
2397
|
+
if (ctx->opts.contention_factor.set) {
|
2398
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2399
|
+
ctx, "cannot set both key alt name and contention factor");
|
2400
|
+
}
|
2401
|
+
if (ctx->opts.query_type.set) {
|
2402
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2403
|
+
ctx, "cannot set both key alt name and query type");
|
2404
|
+
}
|
2405
|
+
if (ctx->opts.rangeopts.set) {
|
2406
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2407
|
+
ctx, "cannot set both key alt name and range opts");
|
2408
|
+
}
|
2409
|
+
}
|
2410
|
+
/* algorithm is FLE 1 only. */
|
2411
|
+
if (ctx->opts.algorithm != MONGOCRYPT_ENCRYPTION_ALGORITHM_NONE) {
|
2412
|
+
if (!_mongocrypt_buffer_empty (&ctx->opts.index_key_id)) {
|
2413
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2414
|
+
ctx, "cannot set both algorithm and index key id");
|
2415
|
+
}
|
2416
|
+
if (ctx->opts.contention_factor.set) {
|
2417
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2418
|
+
ctx, "cannot set both algorithm and contention factor");
|
2419
|
+
}
|
2420
|
+
if (ctx->opts.query_type.set) {
|
2421
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2422
|
+
ctx, "cannot set both algorithm and query type");
|
2423
|
+
}
|
2424
|
+
if (ctx->opts.rangeopts.set) {
|
2425
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2426
|
+
ctx, "cannot set both algorithm and range opts");
|
2427
|
+
}
|
2428
|
+
}
|
2429
|
+
}
|
2430
|
+
|
2431
|
+
if (ctx->opts.algorithm == MONGOCRYPT_ENCRYPTION_ALGORITHM_NONE &&
|
2432
|
+
!ctx->opts.index_type.set) {
|
2433
|
+
return _mongocrypt_ctx_fail_w_msg (ctx,
|
2434
|
+
"algorithm or index type required");
|
2435
|
+
}
|
2436
|
+
|
2437
|
+
if (ctx->opts.contention_factor.set && ctx->opts.index_type.set &&
|
2438
|
+
ctx->opts.index_type.value == MONGOCRYPT_INDEX_TYPE_NONE) {
|
2439
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2440
|
+
ctx, "cannot set contention factor with no index type");
|
2441
|
+
}
|
2442
|
+
|
2443
|
+
if (ctx->opts.query_type.set && ctx->opts.index_type.set &&
|
2444
|
+
ctx->opts.index_type.value == MONGOCRYPT_INDEX_TYPE_NONE) {
|
2445
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2446
|
+
ctx, "cannot set query type with no index type");
|
2447
|
+
}
|
2448
|
+
|
2449
|
+
if (ctx->opts.rangeopts.set && ctx->opts.index_type.set) {
|
2450
|
+
if (ctx->opts.index_type.value == MONGOCRYPT_INDEX_TYPE_NONE) {
|
2451
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2452
|
+
ctx, "cannot set range opts with no index type");
|
2453
|
+
}
|
2454
|
+
|
2455
|
+
if (ctx->opts.index_type.value == MONGOCRYPT_INDEX_TYPE_EQUALITY) {
|
2456
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2457
|
+
ctx, "cannot set range opts with equality index type");
|
2458
|
+
}
|
2459
|
+
}
|
2460
|
+
|
2461
|
+
if (ctx->opts.contention_factor.set &&
|
2462
|
+
!mc_validate_contention (ctx->opts.contention_factor.value,
|
2463
|
+
ctx->status)) {
|
2464
|
+
return _mongocrypt_ctx_fail (ctx);
|
2465
|
+
}
|
2466
|
+
|
2467
|
+
if (ctx->opts.index_type.set &&
|
2468
|
+
ctx->opts.index_type.value == MONGOCRYPT_INDEX_TYPE_EQUALITY &&
|
2469
|
+
!ctx->opts.contention_factor.set) {
|
2470
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2471
|
+
ctx, "contention factor is required for indexed algorithm");
|
2472
|
+
}
|
2473
|
+
|
2474
|
+
if (ctx->opts.index_type.set &&
|
2475
|
+
ctx->opts.index_type.value == MONGOCRYPT_INDEX_TYPE_RANGEPREVIEW) {
|
2476
|
+
if (!ctx->opts.contention_factor.set) {
|
2477
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2478
|
+
ctx, "contention factor is required for range indexed algorithm");
|
2479
|
+
}
|
2480
|
+
|
2481
|
+
if (!ctx->opts.rangeopts.set) {
|
2482
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2483
|
+
ctx, "range opts are required for range indexed algorithm");
|
2484
|
+
}
|
2485
|
+
}
|
2486
|
+
|
2487
|
+
if (ctx->opts.rangeopts.set &&
|
2488
|
+
!mc_validate_sparsity (ctx->opts.rangeopts.value.sparsity,
|
2489
|
+
ctx->status)) {
|
2490
|
+
return _mongocrypt_ctx_fail (ctx);
|
2491
|
+
}
|
2492
|
+
|
2493
|
+
// If query type is set, it must match the index type.
|
2494
|
+
if (ctx->opts.query_type.set && ctx->opts.index_type.set) {
|
2495
|
+
mongocrypt_status_t *const status = ctx->status;
|
2496
|
+
bool matches = false;
|
2497
|
+
|
2498
|
+
switch (ctx->opts.query_type.value) {
|
2499
|
+
case MONGOCRYPT_QUERY_TYPE_RANGEPREVIEW:
|
2500
|
+
matches =
|
2501
|
+
(ctx->opts.index_type.value == MONGOCRYPT_INDEX_TYPE_RANGEPREVIEW);
|
2502
|
+
break;
|
2503
|
+
case MONGOCRYPT_QUERY_TYPE_EQUALITY:
|
2504
|
+
matches =
|
2505
|
+
(ctx->opts.index_type.value == MONGOCRYPT_INDEX_TYPE_EQUALITY);
|
2506
|
+
break;
|
2507
|
+
default:
|
2508
|
+
CLIENT_ERR ("unsupported value for query_type: %d",
|
2509
|
+
ctx->opts.query_type.value);
|
2510
|
+
return _mongocrypt_ctx_fail (ctx);
|
2511
|
+
}
|
2512
|
+
|
2513
|
+
if (!matches) {
|
2514
|
+
CLIENT_ERR (
|
2515
|
+
"query_type (%s) must match index_type (%s)",
|
2516
|
+
_mongocrypt_query_type_to_string (ctx->opts.query_type.value),
|
2517
|
+
_mongocrypt_index_type_to_string (ctx->opts.index_type.value));
|
2518
|
+
return _mongocrypt_ctx_fail (ctx);
|
2519
|
+
}
|
2520
|
+
}
|
2521
|
+
|
2522
|
+
ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
2523
|
+
ctx->type = _MONGOCRYPT_TYPE_ENCRYPT;
|
2524
|
+
ectx->explicit = true;
|
2525
|
+
ctx->vtable.finalize = _finalize;
|
2526
|
+
ctx->vtable.cleanup = _cleanup;
|
2527
|
+
|
2528
|
+
if (!msg || !msg->data) {
|
2529
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2530
|
+
ctx, "msg required for explicit encryption");
|
2531
|
+
}
|
2532
|
+
|
2533
|
+
if (ctx->opts.key_alt_names) {
|
2534
|
+
if (!_mongocrypt_key_broker_request_name (
|
2535
|
+
&ctx->kb, &ctx->opts.key_alt_names->value)) {
|
2536
|
+
return _mongocrypt_ctx_fail (ctx);
|
2537
|
+
}
|
2538
|
+
} else {
|
2539
|
+
if (!_mongocrypt_key_broker_request_id (&ctx->kb, &ctx->opts.key_id)) {
|
2540
|
+
return _mongocrypt_ctx_fail (ctx);
|
2541
|
+
}
|
2542
|
+
}
|
2543
|
+
|
2544
|
+
if (!_mongocrypt_buffer_empty (&ctx->opts.index_key_id)) {
|
2545
|
+
if (!_mongocrypt_key_broker_request_id (&ctx->kb,
|
2546
|
+
&ctx->opts.index_key_id)) {
|
2547
|
+
return _mongocrypt_ctx_fail (ctx);
|
2548
|
+
}
|
2549
|
+
}
|
2550
|
+
|
2551
|
+
_mongocrypt_buffer_init (&ectx->original_cmd);
|
2552
|
+
|
2553
|
+
_mongocrypt_buffer_copy_from_binary (&ectx->original_cmd, msg);
|
2554
|
+
if (!_mongocrypt_buffer_to_bson (&ectx->original_cmd, &as_bson)) {
|
2555
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "msg must be bson");
|
2556
|
+
}
|
2557
|
+
|
2558
|
+
if (ctx->crypt->log.trace_enabled) {
|
2559
|
+
char *cmd_val;
|
2560
|
+
cmd_val = _mongocrypt_new_json_string_from_binary (msg);
|
2561
|
+
_mongocrypt_log (&ctx->crypt->log,
|
2562
|
+
MONGOCRYPT_LOG_LEVEL_TRACE,
|
2563
|
+
"%s (%s=\"%s\")",
|
2564
|
+
BSON_FUNC,
|
2565
|
+
"msg",
|
2566
|
+
cmd_val);
|
2567
|
+
bson_free (cmd_val);
|
2568
|
+
}
|
2569
|
+
|
2570
|
+
if (!bson_iter_init_find (&iter, &as_bson, "v")) {
|
2571
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "invalid msg, must contain 'v'");
|
2572
|
+
}
|
2573
|
+
|
2574
|
+
if (!_permitted_for_encryption (&iter, ctx->opts.algorithm, ctx->status)) {
|
2575
|
+
return _mongocrypt_ctx_fail (ctx);
|
2576
|
+
}
|
2577
|
+
|
2578
|
+
(void) _mongocrypt_key_broker_requests_done (&ctx->kb);
|
2579
|
+
return _mongocrypt_ctx_state_from_key_broker (ctx);
|
2580
|
+
}
|
2581
|
+
|
2582
|
+
bool
|
2583
|
+
mongocrypt_ctx_explicit_encrypt_init (mongocrypt_ctx_t *ctx,
|
2584
|
+
mongocrypt_binary_t *msg)
|
2585
|
+
{
|
2586
|
+
if (!explicit_encrypt_init (ctx, msg)) {
|
2587
|
+
return false;
|
2588
|
+
}
|
2589
|
+
if (ctx->opts.query_type.set &&
|
2590
|
+
ctx->opts.query_type.value == MONGOCRYPT_QUERY_TYPE_RANGEPREVIEW) {
|
2591
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2592
|
+
ctx,
|
2593
|
+
"Encrypt may not be used for range queries. Use EncryptExpression.");
|
2594
|
+
}
|
2595
|
+
return true;
|
2596
|
+
}
|
2597
|
+
|
2598
|
+
bool
|
2599
|
+
mongocrypt_ctx_explicit_encrypt_expression_init (mongocrypt_ctx_t *ctx,
|
2600
|
+
mongocrypt_binary_t *msg)
|
2601
|
+
{
|
2602
|
+
if (!explicit_encrypt_init (ctx, msg)) {
|
2603
|
+
return false;
|
2604
|
+
}
|
2605
|
+
if (!ctx->opts.query_type.set ||
|
2606
|
+
ctx->opts.query_type.value != MONGOCRYPT_QUERY_TYPE_RANGEPREVIEW) {
|
2607
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2608
|
+
ctx, "EncryptExpression may only be used for range queries.");
|
2609
|
+
}
|
2610
|
+
return true;
|
2611
|
+
}
|
2612
|
+
|
2613
|
+
static bool
|
2614
|
+
_check_cmd_for_auto_encrypt (mongocrypt_binary_t *cmd,
|
2615
|
+
bool *bypass,
|
2616
|
+
char **collname,
|
2617
|
+
mongocrypt_status_t *status)
|
2618
|
+
{
|
2619
|
+
bson_t as_bson;
|
2620
|
+
bson_iter_t iter, ns_iter;
|
2621
|
+
const char *cmd_name;
|
2622
|
+
bool eligible = false;
|
2623
|
+
|
2624
|
+
BSON_ASSERT_PARAM (cmd);
|
2625
|
+
BSON_ASSERT_PARAM (bypass);
|
2626
|
+
BSON_ASSERT_PARAM (collname);
|
2627
|
+
|
2628
|
+
*bypass = false;
|
2629
|
+
|
2630
|
+
if (!_mongocrypt_binary_to_bson (cmd, &as_bson) ||
|
2631
|
+
!bson_iter_init (&iter, &as_bson)) {
|
2632
|
+
CLIENT_ERR ("invalid BSON");
|
2633
|
+
return false;
|
2634
|
+
}
|
2635
|
+
|
2636
|
+
/* The command name is the first key. */
|
2637
|
+
if (!bson_iter_next (&iter)) {
|
2638
|
+
CLIENT_ERR ("invalid empty BSON");
|
2639
|
+
return false;
|
2640
|
+
}
|
2641
|
+
|
2642
|
+
cmd_name = bson_iter_key (&iter);
|
2643
|
+
BSON_ASSERT (cmd_name);
|
2644
|
+
|
2645
|
+
/* get the collection name (or NULL if database/client command). */
|
2646
|
+
if (0 == strcmp (cmd_name, "explain")) {
|
2647
|
+
if (!BSON_ITER_HOLDS_DOCUMENT (&iter)) {
|
2648
|
+
CLIENT_ERR ("explain value is not a document");
|
2649
|
+
return false;
|
2650
|
+
}
|
2651
|
+
if (!bson_iter_recurse (&iter, &ns_iter)) {
|
2652
|
+
CLIENT_ERR ("malformed BSON for encrypt command");
|
2653
|
+
return false;
|
2654
|
+
}
|
2655
|
+
if (!bson_iter_next (&ns_iter)) {
|
2656
|
+
CLIENT_ERR ("invalid empty BSON");
|
2657
|
+
return false;
|
2658
|
+
}
|
2659
|
+
} else {
|
2660
|
+
memcpy (&ns_iter, &iter, sizeof (iter));
|
2661
|
+
}
|
2662
|
+
|
2663
|
+
if (BSON_ITER_HOLDS_UTF8 (&ns_iter)) {
|
2664
|
+
*collname = bson_strdup (bson_iter_utf8 (&ns_iter, NULL));
|
2665
|
+
} else {
|
2666
|
+
*collname = NULL;
|
2667
|
+
}
|
2668
|
+
|
2669
|
+
/* check if command is eligible for auto encryption, bypassed, or ineligible.
|
2670
|
+
*/
|
2671
|
+
if (0 == strcmp (cmd_name, "aggregate")) {
|
2672
|
+
/* collection level aggregate ok, database/client is not. */
|
2673
|
+
eligible = true;
|
2674
|
+
} else if (0 == strcmp (cmd_name, "count")) {
|
2675
|
+
eligible = true;
|
2676
|
+
} else if (0 == strcmp (cmd_name, "distinct")) {
|
2677
|
+
eligible = true;
|
2678
|
+
} else if (0 == strcmp (cmd_name, "delete")) {
|
2679
|
+
eligible = true;
|
2680
|
+
} else if (0 == strcmp (cmd_name, "find")) {
|
2681
|
+
eligible = true;
|
2682
|
+
} else if (0 == strcmp (cmd_name, "findAndModify")) {
|
2683
|
+
eligible = true;
|
2684
|
+
} else if (0 == strcmp (cmd_name, "getMore")) {
|
2685
|
+
*bypass = true;
|
2686
|
+
} else if (0 == strcmp (cmd_name, "insert")) {
|
2687
|
+
eligible = true;
|
2688
|
+
} else if (0 == strcmp (cmd_name, "update")) {
|
2689
|
+
eligible = true;
|
2690
|
+
} else if (0 == strcmp (cmd_name, "authenticate")) {
|
2691
|
+
*bypass = true;
|
2692
|
+
} else if (0 == strcmp (cmd_name, "getnonce")) {
|
2693
|
+
*bypass = true;
|
2694
|
+
} else if (0 == strcmp (cmd_name, "logout")) {
|
2695
|
+
*bypass = true;
|
2696
|
+
} else if (0 == bson_strcasecmp (cmd_name, "isMaster")) {
|
2697
|
+
/* use case insensitive compare for ismaster, since some drivers send
|
2698
|
+
* "ismaster" and others send "isMaster" */
|
2699
|
+
*bypass = true;
|
2700
|
+
} else if (0 == strcmp (cmd_name, "abortTransaction")) {
|
2701
|
+
*bypass = true;
|
2702
|
+
} else if (0 == strcmp (cmd_name, "commitTransaction")) {
|
2703
|
+
*bypass = true;
|
2704
|
+
} else if (0 == strcmp (cmd_name, "endSessions")) {
|
2705
|
+
*bypass = true;
|
2706
|
+
} else if (0 == strcmp (cmd_name, "startSession")) {
|
2707
|
+
*bypass = true;
|
2708
|
+
} else if (0 == strcmp (cmd_name, "create")) {
|
2709
|
+
eligible = true;
|
2710
|
+
} else if (0 == strcmp (cmd_name, "createIndexes")) {
|
2711
|
+
eligible = true;
|
2712
|
+
} else if (0 == strcmp (cmd_name, "drop")) {
|
2713
|
+
*bypass = true;
|
2714
|
+
} else if (0 == strcmp (cmd_name, "dropDatabase")) {
|
2715
|
+
*bypass = true;
|
2716
|
+
} else if (0 == strcmp (cmd_name, "dropIndexes")) {
|
2717
|
+
*bypass = true;
|
2718
|
+
} else if (0 == strcmp (cmd_name, "killCursors")) {
|
2719
|
+
*bypass = true;
|
2720
|
+
} else if (0 == strcmp (cmd_name, "listCollections")) {
|
2721
|
+
*bypass = true;
|
2722
|
+
} else if (0 == strcmp (cmd_name, "listDatabases")) {
|
2723
|
+
*bypass = true;
|
2724
|
+
} else if (0 == strcmp (cmd_name, "listIndexes")) {
|
2725
|
+
*bypass = true;
|
2726
|
+
} else if (0 == strcmp (cmd_name, "renameCollection")) {
|
2727
|
+
*bypass = true;
|
2728
|
+
} else if (0 == strcmp (cmd_name, "explain")) {
|
2729
|
+
eligible = true;
|
2730
|
+
} else if (0 == strcmp (cmd_name, "ping")) {
|
2731
|
+
*bypass = true;
|
2732
|
+
} else if (0 == strcmp (cmd_name, "saslStart")) {
|
2733
|
+
*bypass = true;
|
2734
|
+
} else if (0 == strcmp (cmd_name, "saslContinue")) {
|
2735
|
+
*bypass = true;
|
2736
|
+
} else if (0 == strcmp (cmd_name, "killAllSessions")) {
|
2737
|
+
*bypass = true;
|
2738
|
+
} else if (0 == strcmp (cmd_name, "killSessions")) {
|
2739
|
+
*bypass = true;
|
2740
|
+
} else if (0 == strcmp (cmd_name, "killAllSessionsByPattern")) {
|
2741
|
+
*bypass = true;
|
2742
|
+
} else if (0 == strcmp (cmd_name, "refreshSessions")) {
|
2743
|
+
*bypass = true;
|
2744
|
+
} else if (0 == strcmp (cmd_name, "compactStructuredEncryptionData")) {
|
2745
|
+
eligible = true;
|
2746
|
+
} else if (0 == strcmp (cmd_name, "collMod")) {
|
2747
|
+
eligible = true;
|
2748
|
+
} else if (0 == strcmp (cmd_name, "hello")) {
|
2749
|
+
*bypass = true;
|
2750
|
+
} else if (0 == strcmp (cmd_name, "buildInfo")) {
|
2751
|
+
*bypass = true;
|
2752
|
+
} else if (0 == strcmp (cmd_name, "getCmdLineOpts")) {
|
2753
|
+
*bypass = true;
|
2754
|
+
} else if (0 == strcmp (cmd_name, "getLog")) {
|
2755
|
+
*bypass = true;
|
2756
|
+
}
|
2757
|
+
|
2758
|
+
/* database/client commands are ineligible. */
|
2759
|
+
if (eligible) {
|
2760
|
+
if (!*collname) {
|
2761
|
+
CLIENT_ERR (
|
2762
|
+
"non-collection command not supported for auto encryption: %s",
|
2763
|
+
cmd_name);
|
2764
|
+
return false;
|
2765
|
+
}
|
2766
|
+
if (0 == strlen (*collname)) {
|
2767
|
+
CLIENT_ERR ("empty collection name on command: %s", cmd_name);
|
2768
|
+
return false;
|
2769
|
+
}
|
2770
|
+
}
|
2771
|
+
|
2772
|
+
if (eligible || *bypass) {
|
2773
|
+
return true;
|
2774
|
+
}
|
2775
|
+
|
2776
|
+
CLIENT_ERR ("command not supported for auto encryption: %s", cmd_name);
|
2777
|
+
return false;
|
2778
|
+
}
|
2779
|
+
|
2780
|
+
static bool
|
2781
|
+
needs_ismaster_check (mongocrypt_ctx_t *ctx)
|
2782
|
+
{
|
2783
|
+
_mongocrypt_ctx_encrypt_t *ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
2784
|
+
|
2785
|
+
BSON_ASSERT_PARAM (ctx);
|
2786
|
+
|
2787
|
+
bool using_mongocryptd =
|
2788
|
+
!ectx->bypass_query_analysis && !ctx->crypt->csfle.okay;
|
2789
|
+
// The "create" and "createIndexes" command require an isMaster check when
|
2790
|
+
// using mongocryptd. See MONGOCRYPT-429.
|
2791
|
+
return using_mongocryptd && (0 == strcmp (ectx->cmd_name, "create") ||
|
2792
|
+
0 == strcmp (ectx->cmd_name, "createIndexes"));
|
2793
|
+
}
|
2794
|
+
|
2795
|
+
bool
|
2796
|
+
mongocrypt_ctx_encrypt_init (mongocrypt_ctx_t *ctx,
|
2797
|
+
const char *db,
|
2798
|
+
int32_t db_len,
|
2799
|
+
mongocrypt_binary_t *cmd)
|
2800
|
+
{
|
2801
|
+
_mongocrypt_ctx_encrypt_t *ectx;
|
2802
|
+
_mongocrypt_ctx_opts_spec_t opts_spec;
|
2803
|
+
bool bypass;
|
2804
|
+
|
2805
|
+
if (!ctx) {
|
2806
|
+
return false;
|
2807
|
+
}
|
2808
|
+
|
2809
|
+
if (!db) {
|
2810
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "invalid db");
|
2811
|
+
}
|
2812
|
+
|
2813
|
+
memset (&opts_spec, 0, sizeof (opts_spec));
|
2814
|
+
opts_spec.schema = OPT_OPTIONAL;
|
2815
|
+
if (!_mongocrypt_ctx_init (ctx, &opts_spec)) {
|
2816
|
+
return false;
|
2817
|
+
}
|
2818
|
+
|
2819
|
+
ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
2820
|
+
ctx->type = _MONGOCRYPT_TYPE_ENCRYPT;
|
2821
|
+
ectx->explicit = false;
|
2822
|
+
ctx->vtable.mongo_op_collinfo = _mongo_op_collinfo;
|
2823
|
+
ctx->vtable.mongo_feed_collinfo = _mongo_feed_collinfo;
|
2824
|
+
ctx->vtable.mongo_done_collinfo = _mongo_done_collinfo;
|
2825
|
+
ctx->vtable.mongo_op_collinfo = _mongo_op_collinfo;
|
2826
|
+
ctx->vtable.mongo_op_markings = _mongo_op_markings;
|
2827
|
+
ctx->vtable.mongo_feed_markings = _mongo_feed_markings;
|
2828
|
+
ctx->vtable.mongo_done_markings = _mongo_done_markings;
|
2829
|
+
ctx->vtable.finalize = _finalize;
|
2830
|
+
ctx->vtable.cleanup = _cleanup;
|
2831
|
+
ctx->vtable.mongo_op_collinfo = _mongo_op_collinfo;
|
2832
|
+
ctx->vtable.mongo_feed_collinfo = _mongo_feed_collinfo;
|
2833
|
+
ctx->vtable.mongo_done_collinfo = _mongo_done_collinfo;
|
2834
|
+
ectx->bypass_query_analysis = ctx->crypt->opts.bypass_query_analysis;
|
2835
|
+
|
2836
|
+
|
2837
|
+
if (!cmd || !cmd->data) {
|
2838
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "invalid command");
|
2839
|
+
}
|
2840
|
+
|
2841
|
+
_mongocrypt_buffer_copy_from_binary (&ectx->original_cmd, cmd);
|
2842
|
+
|
2843
|
+
ectx->cmd_name = get_command_name (&ectx->original_cmd, ctx->status);
|
2844
|
+
if (!ectx->cmd_name) {
|
2845
|
+
return _mongocrypt_ctx_fail (ctx);
|
2846
|
+
}
|
2847
|
+
|
2848
|
+
if (!_check_cmd_for_auto_encrypt (
|
2849
|
+
cmd, &bypass, &ectx->coll_name, ctx->status)) {
|
2850
|
+
return _mongocrypt_ctx_fail (ctx);
|
2851
|
+
}
|
2852
|
+
|
2853
|
+
if (bypass) {
|
2854
|
+
ctx->nothing_to_do = true;
|
2855
|
+
ctx->state = MONGOCRYPT_CTX_READY;
|
2856
|
+
return true;
|
2857
|
+
}
|
2858
|
+
|
2859
|
+
/* if _check_cmd_for_auto_encrypt did not bypass or error, a collection name
|
2860
|
+
* must have been set. */
|
2861
|
+
if (!ectx->coll_name) {
|
2862
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2863
|
+
ctx,
|
2864
|
+
"unexpected error: did not bypass or error but no collection name");
|
2865
|
+
}
|
2866
|
+
|
2867
|
+
if (!_mongocrypt_validate_and_copy_string (db, db_len, &ectx->db_name) ||
|
2868
|
+
0 == strlen (ectx->db_name)) {
|
2869
|
+
return _mongocrypt_ctx_fail_w_msg (ctx, "invalid db");
|
2870
|
+
}
|
2871
|
+
|
2872
|
+
ectx->ns = bson_strdup_printf ("%s.%s", ectx->db_name, ectx->coll_name);
|
2873
|
+
|
2874
|
+
if (ctx->opts.kek.provider.aws.region || ctx->opts.kek.provider.aws.cmk) {
|
2875
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2876
|
+
ctx, "aws masterkey options must not be set");
|
2877
|
+
}
|
2878
|
+
|
2879
|
+
if (!_mongocrypt_buffer_empty (&ctx->opts.key_id)) {
|
2880
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2881
|
+
ctx, "key_id must not be set for auto encryption");
|
2882
|
+
}
|
2883
|
+
|
2884
|
+
if (ctx->opts.algorithm != MONGOCRYPT_ENCRYPTION_ALGORITHM_NONE) {
|
2885
|
+
return _mongocrypt_ctx_fail_w_msg (
|
2886
|
+
ctx, "algorithm must not be set for auto encryption");
|
2887
|
+
}
|
2888
|
+
|
2889
|
+
if (ctx->crypt->log.trace_enabled) {
|
2890
|
+
char *cmd_val;
|
2891
|
+
cmd_val = _mongocrypt_new_json_string_from_binary (cmd);
|
2892
|
+
_mongocrypt_log (&ctx->crypt->log,
|
2893
|
+
MONGOCRYPT_LOG_LEVEL_TRACE,
|
2894
|
+
"%s (%s=\"%s\", %s=%d, %s=\"%s\")",
|
2895
|
+
BSON_FUNC,
|
2896
|
+
"db",
|
2897
|
+
ectx->db_name,
|
2898
|
+
"db_len",
|
2899
|
+
db_len,
|
2900
|
+
"cmd",
|
2901
|
+
cmd_val);
|
2902
|
+
bson_free (cmd_val);
|
2903
|
+
}
|
2904
|
+
|
2905
|
+
/* The "create" and "createIndexes" command require sending an isMaster
|
2906
|
+
* request to mongocryptd. */
|
2907
|
+
if (needs_ismaster_check (ctx)) {
|
2908
|
+
/* We are using mongocryptd. We need to ensure that mongocryptd
|
2909
|
+
* maxWireVersion >= 17. */
|
2910
|
+
ectx->ismaster.needed = true;
|
2911
|
+
ctx->state = MONGOCRYPT_CTX_NEED_MONGO_MARKINGS;
|
2912
|
+
return true;
|
2913
|
+
}
|
2914
|
+
|
2915
|
+
return mongocrypt_ctx_encrypt_ismaster_done (ctx);
|
2916
|
+
}
|
2917
|
+
|
2918
|
+
#define WIRE_VERSION_SERVER_6 17
|
2919
|
+
/* mongocrypt_ctx_encrypt_ismaster_done is called when:
|
2920
|
+
* 1. The max wire version of mongocryptd is known.
|
2921
|
+
* 2. The max wire version of mongocryptd is not required for the command.
|
2922
|
+
*/
|
2923
|
+
static bool
|
2924
|
+
mongocrypt_ctx_encrypt_ismaster_done (mongocrypt_ctx_t *ctx)
|
2925
|
+
{
|
2926
|
+
_mongocrypt_ctx_encrypt_t *ectx = (_mongocrypt_ctx_encrypt_t *) ctx;
|
2927
|
+
|
2928
|
+
BSON_ASSERT_PARAM (ctx);
|
2929
|
+
|
2930
|
+
ectx->ismaster.needed = false;
|
2931
|
+
|
2932
|
+
/* The "create" and "createIndexes" command require bypassing on mongocryptd
|
2933
|
+
* older than version 6.0. */
|
2934
|
+
if (needs_ismaster_check (ctx)) {
|
2935
|
+
if (ectx->ismaster.maxwireversion < WIRE_VERSION_SERVER_6) {
|
2936
|
+
/* Bypass. */
|
2937
|
+
ctx->nothing_to_do = true;
|
2938
|
+
ctx->state = MONGOCRYPT_CTX_READY;
|
2939
|
+
return true;
|
2940
|
+
}
|
2941
|
+
}
|
2942
|
+
|
2943
|
+
/* Check if there is an encrypted field config in encrypted_field_config_map
|
2944
|
+
*/
|
2945
|
+
if (!_fle2_try_encrypted_field_config_from_map (ctx)) {
|
2946
|
+
return false;
|
2947
|
+
}
|
2948
|
+
if (_mongocrypt_buffer_empty (&ectx->encrypted_field_config)) {
|
2949
|
+
if (!_try_schema_from_create_or_collMod_cmd (ctx)) {
|
2950
|
+
return false;
|
2951
|
+
}
|
2952
|
+
|
2953
|
+
/* Check if we have a local schema from schema_map */
|
2954
|
+
if (_mongocrypt_buffer_empty (&ectx->schema)) {
|
2955
|
+
if (!_try_schema_from_schema_map (ctx)) {
|
2956
|
+
return false;
|
2957
|
+
}
|
2958
|
+
}
|
2959
|
+
|
2960
|
+
/* If we didn't have a local schema, try the cache. */
|
2961
|
+
if (_mongocrypt_buffer_empty (&ectx->schema)) {
|
2962
|
+
if (!_try_schema_from_cache (ctx)) {
|
2963
|
+
return false;
|
2964
|
+
}
|
2965
|
+
}
|
2966
|
+
|
2967
|
+
/* If we did not have a local or cached schema, check if this is a
|
2968
|
+
* "create" command. If it is a "create" command, do not run
|
2969
|
+
* "listCollections" to get a server-side schema. */
|
2970
|
+
if (_mongocrypt_buffer_empty (&ectx->schema) &&
|
2971
|
+
!_try_empty_schema_for_create (ctx)) {
|
2972
|
+
return false;
|
2973
|
+
}
|
2974
|
+
|
2975
|
+
/* Otherwise, we need the the driver to fetch the schema. */
|
2976
|
+
if (_mongocrypt_buffer_empty (&ectx->schema)) {
|
2977
|
+
ctx->state = MONGOCRYPT_CTX_NEED_MONGO_COLLINFO;
|
2978
|
+
}
|
2979
|
+
}
|
2980
|
+
|
2981
|
+
/* If an encrypted_field_config was set, check if keys are required for
|
2982
|
+
* delete tokens. */
|
2983
|
+
if (!_fle2_collect_keys_for_deleteTokens (ctx)) {
|
2984
|
+
return false;
|
2985
|
+
}
|
2986
|
+
|
2987
|
+
if (!_fle2_collect_keys_for_compact (ctx)) {
|
2988
|
+
return false;
|
2989
|
+
}
|
2990
|
+
|
2991
|
+
if (ctx->state == MONGOCRYPT_CTX_NEED_MONGO_MARKINGS) {
|
2992
|
+
if (ectx->bypass_query_analysis) {
|
2993
|
+
/* Keys may have been requested for deleteTokens or compactionTokens.
|
2994
|
+
* Finish key requests.
|
2995
|
+
*/
|
2996
|
+
_mongocrypt_key_broker_requests_done (&ctx->kb);
|
2997
|
+
return _mongocrypt_ctx_state_from_key_broker (ctx);
|
2998
|
+
}
|
2999
|
+
// We're ready for markings. Try to generate them ourself.
|
3000
|
+
return _try_run_csfle_marking (ctx);
|
3001
|
+
} else {
|
3002
|
+
// Other state, return to caller.
|
3003
|
+
return true;
|
3004
|
+
}
|
3005
|
+
}
|