summaryrefslogtreecommitdiff
path: root/src/mongo/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/crypto')
-rw-r--r--src/mongo/crypto/fle_crypto.cpp30
-rw-r--r--src/mongo/crypto/fle_crypto.h2
-rw-r--r--src/mongo/crypto/fle_crypto_test.cpp3
3 files changed, 27 insertions, 8 deletions
diff --git a/src/mongo/crypto/fle_crypto.cpp b/src/mongo/crypto/fle_crypto.cpp
index e268701b450..c3162c6dc25 100644
--- a/src/mongo/crypto/fle_crypto.cpp
+++ b/src/mongo/crypto/fle_crypto.cpp
@@ -1157,10 +1157,20 @@ void convertToFLE2Payload(FLEKeyVault* keyVault,
auto rangeFindSpec =
FLE2RangeFindSpec::parse(ctx, ep.getValue().getElement().Obj());
- auto edges = getMinCover(rangeFindSpec, ep.getSparsity().value());
-
- auto findpayload = FLEClientCrypto::serializeFindRangePayload(
- indexKey, userKey, edges, ep.getMaxContentionCounter(), rangeFindSpec);
+ auto findpayload = [&]() {
+ if (rangeFindSpec.getEdgesInfo().has_value()) {
+ auto edges = getMinCover(rangeFindSpec, ep.getSparsity().value());
+
+ return FLEClientCrypto::serializeFindRangePayload(
+ indexKey,
+ userKey,
+ std::move(edges),
+ ep.getMaxContentionCounter(),
+ rangeFindSpec);
+ } else {
+ return FLEClientCrypto::serializeFindRangeStub(rangeFindSpec);
+ }
+ }();
toEncryptedBinData(fieldNameToSerialize,
EncryptedBinDataType::kFLE2FindRangePayload,
@@ -1509,7 +1519,7 @@ std::vector<std::string> getMinCover(const FLE2RangeFindSpec& spec, uint8_t spar
"getMinCover should never be passed a findSpec without edges information",
spec.getEdgesInfo());
- auto& edgesInfo = spec.getEdgesInfo().get();
+ auto& edgesInfo = spec.getEdgesInfo().value();
auto indexMin = edgesInfo.getIndexMin().getElement();
auto indexMax = edgesInfo.getIndexMax().getElement();
@@ -2273,6 +2283,16 @@ FLE2FindRangePayload FLEClientCrypto::serializeFindRangePayload(
return payload;
}
+FLE2FindRangePayload FLEClientCrypto::serializeFindRangeStub(const FLE2RangeFindSpec& spec) {
+ FLE2FindRangePayload payload;
+
+ payload.setFirstOperator(spec.getFirstOperator());
+ payload.setSecondOperator(spec.getSecondOperator());
+ payload.setPayloadId(spec.getPayloadId());
+
+ return payload;
+}
+
StatusWith<ECCDocument> ECCCollection::decryptDocument(ECCTwiceDerivedValueToken valueToken,
const BSONObj& doc) {
BSONElement encryptedValue;
diff --git a/src/mongo/crypto/fle_crypto.h b/src/mongo/crypto/fle_crypto.h
index d1281d0e903..298092c8bec 100644
--- a/src/mongo/crypto/fle_crypto.h
+++ b/src/mongo/crypto/fle_crypto.h
@@ -586,6 +586,8 @@ public:
uint64_t maxContentionFactor,
const FLE2RangeFindSpec& spec);
+ static FLE2FindRangePayload serializeFindRangeStub(const FLE2RangeFindSpec& spec);
+
/**
* Generates a client-side payload that is sent to the server.
*
diff --git a/src/mongo/crypto/fle_crypto_test.cpp b/src/mongo/crypto/fle_crypto_test.cpp
index c47f6e54e21..652e56dab2f 100644
--- a/src/mongo/crypto/fle_crypto_test.cpp
+++ b/src/mongo/crypto/fle_crypto_test.cpp
@@ -773,7 +773,6 @@ std::vector<char> generatePlaceholder(
findSpec.setEdgesInfo(edgesInfo);
- // TODO: SERVER-70302 update query analysis to generate payloads in gt/lt pairs.
findSpec.setFirstOperator(Fle2RangeOperator::kGt);
findSpec.setPayloadId(1234);
@@ -2599,7 +2598,6 @@ void assertMinCoverResult(A lb,
FLE2RangeFindSpec spec;
spec.setEdgesInfo(edgesInfo);
- // TODO: SERVER-70302 update query analysis to generate payloads in gt/lt pairs.
spec.setFirstOperator(Fle2RangeOperator::kGt);
spec.setPayloadId(1234);
@@ -3531,7 +3529,6 @@ DEATH_TEST_REGEX(MinCoverInterfaceTest, Error_MinMaxTypeMismatch, "Tripwire asse
FLE2RangeFindSpec spec;
spec.setEdgesInfo(edgesInfo);
- // TODO: SERVER-70302 update query analysis to generate payloads in gt/lt pairs.
spec.setFirstOperator(Fle2RangeOperator::kGt);
spec.setPayloadId(1234);