summaryrefslogtreecommitdiff
path: root/src/mongo/crypto/encryption_fields_util.h
diff options
context:
space:
mode:
authorYuhong Zhang <yuhong.zhang@mongodb.com>2022-09-01 19:16:42 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-09-01 20:38:13 +0000
commit8834bd03c22a3a0d21227def26d7a474dafaabc8 (patch)
treec6ea3dc392e8575782d9210745ab923b5474cb8a /src/mongo/crypto/encryption_fields_util.h
parentd2979f3ee500ed4dfd5f67fe2c9412f44c9ceb62 (diff)
downloadmongo-8834bd03c22a3a0d21227def26d7a474dafaabc8.tar.gz
SERVER-67879 Check encrypted BSON value's structural consistency
Diffstat (limited to 'src/mongo/crypto/encryption_fields_util.h')
-rw-r--r--src/mongo/crypto/encryption_fields_util.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mongo/crypto/encryption_fields_util.h b/src/mongo/crypto/encryption_fields_util.h
index 0a67601d91f..521a4c736ab 100644
--- a/src/mongo/crypto/encryption_fields_util.h
+++ b/src/mongo/crypto/encryption_fields_util.h
@@ -34,6 +34,7 @@
#include "mongo/base/string_data.h"
#include "mongo/bson/bsontypes.h"
#include "mongo/crypto/encryption_fields_gen.h"
+#include "mongo/crypto/fle_field_schema_gen.h"
#include "mongo/db/field_ref.h"
#include "mongo/util/assert_util.h"
@@ -150,6 +151,20 @@ inline bool isFLE2UnindexedSupportedType(BSONType type) {
}
}
+// Wrapper of the three helper functions above. Should only be used on FLE type 6, 7, and 9.
+inline bool isFLE2SupportedType(EncryptedBinDataType fleType, BSONType bsonType) {
+ switch (fleType) {
+ case EncryptedBinDataType::kFLE2UnindexedEncryptedValue:
+ return isFLE2UnindexedSupportedType(bsonType);
+ case EncryptedBinDataType::kFLE2EqualityIndexedValue:
+ return isFLE2EqualityIndexedSupportedType(bsonType);
+ case EncryptedBinDataType::kFLE2RangeIndexedValue:
+ return isFLE2RangeIndexedSupportedType(bsonType);
+ default:
+ MONGO_UNREACHABLE;
+ }
+}
+
struct EncryptedFieldMatchResult {
FieldRef encryptedField;
bool keyIsPrefixOrEqual;