Skip to content

Commit a5f4b50

Browse files
authored
CSHARP-5469: Support $lookup in CSFLE and QE (#1626)
1 parent 85ed653 commit a5f4b50

File tree

12 files changed

+450
-29
lines changed

12 files changed

+450
-29
lines changed

purls.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pkg:github/mongodb/libmongocrypt@1.12.0
1+
pkg:github/mongodb/libmongocrypt@1.13.0

sbom.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
{
22
"components": [
33
{
4-
"bom-ref": "pkg:github/mongodb/libmongocrypt@1.12.0",
4+
"bom-ref": "pkg:github/mongodb/libmongocrypt@1.13.0",
55
"externalReferences": [
66
{
77
"type": "distribution",
8-
"url": "https://github.com/mongodb/libmongocrypt/archive/refs/tags/1.12.0.tar.gz"
8+
"url": "https://github.com/mongodb/libmongocrypt/archive/refs/tags/1.13.0.tar.gz"
99
},
1010
{
1111
"type": "website",
12-
"url": "https://github.com/mongodb/libmongocrypt/tree/1.12.0"
12+
"url": "https://github.com/mongodb/libmongocrypt/tree/1.13.0"
1313
}
1414
],
1515
"group": "mongodb",
1616
"name": "libmongocrypt",
17-
"purl": "pkg:github/mongodb/libmongocrypt@1.12.0",
17+
"purl": "pkg:github/mongodb/libmongocrypt@1.13.0",
1818
"type": "library",
19-
"version": "1.12.0"
19+
"version": "1.13.0"
2020
}
2121
],
2222
"dependencies": [
2323
{
24-
"ref": "pkg:github/mongodb/libmongocrypt@1.12.0"
24+
"ref": "pkg:github/mongodb/libmongocrypt@1.13.0"
2525
}
2626
],
2727
"metadata": {
28-
"timestamp": "2025-02-12T16:19:17.310191+00:00",
28+
"timestamp": "2025-02-27T17:40:47.367492+00:00",
2929
"tools": [
3030
{
3131
"externalReferences": [
@@ -68,7 +68,7 @@
6868
}
6969
]
7070
},
71-
"serialNumber": "urn:uuid:d3f1dd75-96b4-4a63-896e-2c7ef9944f89",
71+
"serialNumber": "urn:uuid:03b0f88b-8efc-4e12-9853-00b138b64e67",
7272
"version": 1,
7373
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
7474
"bomFormat": "CycloneDX",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"_id": {
3+
"$binary": {
4+
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
5+
"subType": "04"
6+
}
7+
},
8+
"keyMaterial": {
9+
"$binary": {
10+
"base64": "sHe0kz57YW7v8g9VP9sf/+K1ex4JqKc5rf/URX3n3p8XdZ6+15uXPaSayC6adWbNxkFskuMCOifDoTT+rkqMtFkDclOy884RuGGtUysq3X7zkAWYTKi8QAfKkajvVbZl2y23UqgVasdQu3OVBQCrH/xY00nNAs/52e958nVjBuzQkSb1T8pKJAyjZsHJ60+FtnfafDZSTAIBJYn7UWBCwQ==",
11+
"subType": "00"
12+
}
13+
},
14+
"creationDate": {
15+
"$date": {
16+
"$numberLong": "1648914851981"
17+
}
18+
},
19+
"updateDate": {
20+
"$date": {
21+
"$numberLong": "1648914851981"
22+
}
23+
},
24+
"status": {
25+
"$numberInt": "0"
26+
},
27+
"masterKey": {
28+
"provider": "local"
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"properties": {
3+
"csfle": {
4+
"encrypt": {
5+
"keyId": [
6+
{
7+
"$binary": {
8+
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
9+
"subType": "04"
10+
}
11+
}
12+
],
13+
"bsonType": "string",
14+
"algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"
15+
}
16+
}
17+
},
18+
"bsonType": "object"
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"properties": {
3+
"csfle2": {
4+
"encrypt": {
5+
"keyId": [
6+
{
7+
"$binary": {
8+
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
9+
"subType": "04"
10+
}
11+
}
12+
],
13+
"bsonType": "string",
14+
"algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"
15+
}
16+
}
17+
},
18+
"bsonType": "object"
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"escCollection": "enxcol_.qe.esc",
3+
"ecocCollection": "enxcol_.qe.ecoc",
4+
"fields": [
5+
{
6+
"keyId": {
7+
"$binary": {
8+
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
9+
"subType": "04"
10+
}
11+
},
12+
"path": "qe",
13+
"bsonType": "string",
14+
"queries": {
15+
"queryType": "equality",
16+
"contention": 0
17+
}
18+
}
19+
]
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"escCollection": "enxcol_.qe2.esc",
3+
"ecocCollection": "enxcol_.qe2.ecoc",
4+
"fields": [
5+
{
6+
"keyId": {
7+
"$binary": {
8+
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
9+
"subType": "04"
10+
}
11+
},
12+
"path": "qe2",
13+
"bsonType": "string",
14+
"queries": {
15+
"queryType": "equality",
16+
"contention": 0
17+
}
18+
}
19+
]
20+
}

src/MongoDB.Driver.Encryption/CryptClientFactory.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,8 @@ public static CryptClient Create(CryptOptions options)
162162
}
163163

164164
Library.mongocrypt_setopt_use_need_kms_credentials_state(handle);
165-
165+
Library.mongocrypt_setopt_enable_multiple_collinfo(handle);
166166
Library.mongocrypt_setopt_retry_kms(handle, true);
167-
168167
Library.mongocrypt_init(handle);
169168

170169
if (options.IsCryptSharedLibRequired)

src/MongoDB.Driver.Encryption/Library.cs

+10
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ static Library()
7272
_mongocrypt_setopt_schema_map = new Lazy<Delegates.mongocrypt_setopt_schema_map>(
7373
() => __loader.Value.GetFunction<Delegates.mongocrypt_setopt_schema_map>(
7474
("mongocrypt_setopt_schema_map")), true);
75+
_mongocrypt_setopt_enable_multiple_collinfo = new Lazy<Delegates.mongocrypt_setopt_enable_multiple_collinfo>(
76+
() => __loader.Value.GetFunction<Delegates.mongocrypt_setopt_enable_multiple_collinfo>(
77+
("mongocrypt_setopt_enable_multiple_collinfo")), true);
7578

7679
_mongocrypt_setopt_append_crypt_shared_lib_search_path = new Lazy<Delegates.mongocrypt_setopt_append_crypt_shared_lib_search_path>(
7780
() => __loader.Value.GetFunction<Delegates.mongocrypt_setopt_append_crypt_shared_lib_search_path>(("mongocrypt_setopt_append_crypt_shared_lib_search_path")), true);
@@ -251,6 +254,7 @@ public static string Version
251254
internal static Delegates.mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs1_v1_5 mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs1_v1_5 => _mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs1_v1_5.Value;
252255
internal static Delegates.mongocrypt_setopt_encrypted_field_config_map mongocrypt_setopt_encrypted_field_config_map => _mongocrypt_setopt_encrypted_field_config_map.Value;
253256
internal static Delegates.mongocrypt_setopt_schema_map mongocrypt_setopt_schema_map => _mongocrypt_setopt_schema_map.Value;
257+
internal static Delegates.mongocrypt_setopt_enable_multiple_collinfo mongocrypt_setopt_enable_multiple_collinfo => _mongocrypt_setopt_enable_multiple_collinfo.Value;
254258

255259
internal static Delegates.mongocrypt_setopt_append_crypt_shared_lib_search_path mongocrypt_setopt_append_crypt_shared_lib_search_path => _mongocrypt_setopt_append_crypt_shared_lib_search_path.Value;
256260
internal static Delegates.mongocrypt_setopt_set_crypt_shared_lib_path_override mongocrypt_setopt_set_crypt_shared_lib_path_override => _mongocrypt_setopt_set_crypt_shared_lib_path_override.Value;
@@ -334,6 +338,7 @@ public static string Version
334338
private static readonly Lazy<Delegates.mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs1_v1_5> _mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs1_v1_5;
335339
private static readonly Lazy<Delegates.mongocrypt_setopt_encrypted_field_config_map> _mongocrypt_setopt_encrypted_field_config_map;
336340
private static readonly Lazy<Delegates.mongocrypt_setopt_schema_map> _mongocrypt_setopt_schema_map;
341+
private static readonly Lazy<Delegates.mongocrypt_setopt_enable_multiple_collinfo> _mongocrypt_setopt_enable_multiple_collinfo;
337342

338343
private static readonly Lazy<Delegates.mongocrypt_setopt_append_crypt_shared_lib_search_path> _mongocrypt_setopt_append_crypt_shared_lib_search_path;
339344
private static readonly Lazy<Delegates.mongocrypt_setopt_set_crypt_shared_lib_path_override> _mongocrypt_setopt_set_crypt_shared_lib_path_override;
@@ -520,6 +525,11 @@ public delegate bool mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs1_v1_5(
520525
[return: MarshalAs(UnmanagedType.I1)]
521526
public delegate bool mongocrypt_setopt_schema_map(MongoCryptSafeHandle handle, BinarySafeHandle schema);
522527
/// <summary>
528+
/// bool mongocrypt_setopt_enable_multiple_collinfo(mongocrypt_t *crypt);
529+
/// </summary>
530+
[return: MarshalAs(UnmanagedType.I1)]
531+
public delegate bool mongocrypt_setopt_enable_multiple_collinfo(MongoCryptSafeHandle handle);
532+
/// <summary>
523533
/// void mongocrypt_setopt_append_crypt_shared_lib_search_path(mongocrypt_t* crypt, const char* path);
524534
/// </summary>
525535
public delegate void mongocrypt_setopt_append_crypt_shared_lib_search_path(MongoCryptSafeHandle handle, [MarshalAs(UnmanagedType.LPStr)] string path);

src/MongoDB.Driver.Encryption/MongoDB.Driver.Encryption.csproj

+7-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
<NoWarn>CA1060;CA2101;CA1307;SYSLIB0022;SYSLIB0004</NoWarn>
1414
</PropertyGroup>
1515

16-
<Target Name="DownloadNativeBinaries_MacOS" BeforeTargets="BeforeBuild" Condition="!Exists('$(MSBuildProjectDirectory)/runtimes/osx/native/libmongocrypt.dylib')">
16+
<Target Name="DownloadNativeBinaries_MacOS"
17+
BeforeTargets="BeforeBuild" Condition="!Exists('$(MSBuildProjectDirectory)/runtimes/osx/native/libmongocrypt.dylib')">
1718
<PropertyGroup>
18-
<LibMongoCryptSourceUrl>https://mciuploads.s3.amazonaws.com/libmongocrypt-release/macos/r1.12/085a0ce6538a28179da6bfd2927aea106924443a/libmongocrypt.tar.gz</LibMongoCryptSourceUrl>
19+
<LibMongoCryptSourceUrl>https://mciuploads.s3.amazonaws.com/libmongocrypt-release/macos/r1.13/1cf03f1fdd8fa439d43b8548b546c00ce71d1bc1/libmongocrypt.tar.gz</LibMongoCryptSourceUrl>
1920
<LibMongoCryptSourcePath>lib/libmongocrypt.dylib</LibMongoCryptSourcePath>
2021
<LibMongoCryptPackagePath>runtimes/osx/native</LibMongoCryptPackagePath>
2122
</PropertyGroup>
@@ -27,7 +28,7 @@
2728

2829
<Target Name="DownloadNativeBinaries_UbuntuX64" BeforeTargets="BeforeBuild" Condition="!Exists('$(MSBuildProjectDirectory)/runtimes/linux/native/x64/libmongocrypt.so')">
2930
<PropertyGroup>
30-
<LibMongoCryptSourceUrl>https://mciuploads.s3.amazonaws.com/libmongocrypt-release/ubuntu1804-64/r1.12/085a0ce6538a28179da6bfd2927aea106924443a/libmongocrypt.tar.gz</LibMongoCryptSourceUrl>
31+
<LibMongoCryptSourceUrl>https://mciuploads.s3.amazonaws.com/libmongocrypt-release/ubuntu1804-64/r1.13/1cf03f1fdd8fa439d43b8548b546c00ce71d1bc1/libmongocrypt.tar.gz</LibMongoCryptSourceUrl>
3132
<LibMongoCryptSourcePath>nocrypto/lib/libmongocrypt.so</LibMongoCryptSourcePath>
3233
<LibMongoCryptPackagePath>runtimes/linux/native/x64</LibMongoCryptPackagePath>
3334
</PropertyGroup>
@@ -39,7 +40,7 @@
3940

4041
<Target Name="DownloadNativeBinaries_UbuntuARM64" BeforeTargets="BeforeBuild" Condition="!Exists('$(MSBuildProjectDirectory)/runtimes/linux/native/arm64/libmongocrypt.so')">
4142
<PropertyGroup>
42-
<LibMongoCryptSourceUrl>https://mciuploads.s3.amazonaws.com/libmongocrypt-release/ubuntu1804-arm64/r1.12/085a0ce6538a28179da6bfd2927aea106924443a/libmongocrypt.tar.gz</LibMongoCryptSourceUrl>
43+
<LibMongoCryptSourceUrl>https://mciuploads.s3.amazonaws.com/libmongocrypt-release/ubuntu1804-arm64/r1.13/1cf03f1fdd8fa439d43b8548b546c00ce71d1bc1/libmongocrypt.tar.gz</LibMongoCryptSourceUrl>
4344
<LibMongoCryptSourcePath>nocrypto/lib/libmongocrypt.so</LibMongoCryptSourcePath>
4445
<LibMongoCryptPackagePath>runtimes/linux/native/arm64</LibMongoCryptPackagePath>
4546
</PropertyGroup>
@@ -51,7 +52,7 @@
5152

5253
<Target Name="DownloadNativeBinaries_Alpine" BeforeTargets="BeforeBuild" Condition="!Exists('$(MSBuildProjectDirectory)/runtimes/linux/native/alpine/libmongocrypt.so')">
5354
<PropertyGroup>
54-
<LibMongoCryptSourceUrl>https://mciuploads.s3.amazonaws.com/libmongocrypt-release/alpine-arm64-earthly/r1.12/085a0ce6538a28179da6bfd2927aea106924443a/libmongocrypt.tar.gz</LibMongoCryptSourceUrl>
55+
<LibMongoCryptSourceUrl>https://mciuploads.s3.amazonaws.com/libmongocrypt-release/alpine-arm64-earthly/r1.13/1cf03f1fdd8fa439d43b8548b546c00ce71d1bc1/libmongocrypt.tar.gz</LibMongoCryptSourceUrl>
5556
<LibMongoCryptSourcePath>nocrypto/lib/libmongocrypt.so</LibMongoCryptSourcePath>
5657
<LibMongoCryptPackagePath>runtimes/linux/native/alpine</LibMongoCryptPackagePath>
5758
</PropertyGroup>
@@ -63,7 +64,7 @@
6364

6465
<Target Name="DownloadNativeBinaries_Windows" BeforeTargets="BeforeBuild" Condition="!Exists('$(MSBuildProjectDirectory)/runtimes/win/native/mongocrypt.dll')">
6566
<PropertyGroup>
66-
<LibMongoCryptSourceUrl>https://mciuploads.s3.amazonaws.com/libmongocrypt-release/windows-test/r1.12/085a0ce6538a28179da6bfd2927aea106924443a/libmongocrypt.tar.gz</LibMongoCryptSourceUrl>
67+
<LibMongoCryptSourceUrl>https://mciuploads.s3.amazonaws.com/libmongocrypt-release/windows-test/r1.13/1cf03f1fdd8fa439d43b8548b546c00ce71d1bc1/libmongocrypt.tar.gz</LibMongoCryptSourceUrl>
6768
<LibMongoCryptSourcePath>bin/mongocrypt.dll</LibMongoCryptSourcePath>
6869
<LibMongoCryptPackagePath>runtimes/win/native</LibMongoCryptPackagePath>
6970
</PropertyGroup>

src/MongoDB.Driver/Core/Misc/Feature.cs

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class Feature
4747
private static readonly Feature __createIndexCommitQuorum = new Feature("CreateIndexCommitQuorum", WireVersion.Server44);
4848
private static readonly Feature __createIndexesUsingInsertOperations = new Feature("CreateIndexesUsingInsertOperations", WireVersion.Zero, WireVersion.Server42);
4949
private static readonly Feature __csfleRangeAlgorithm = new Feature("CsfleRangeAlgorithm", WireVersion.Server62);
50+
private static readonly Feature __csfle2Qev2Lookup = new Feature("csfle2Qev2Lookup", WireVersion.Server81);
5051
private static readonly Feature __csfle2Qev2RangeAlgorithm = new Feature("csfle2Qev2RangeAlgorithm", WireVersion.Server80);
5152
private static readonly Feature __csfle2 = new Feature("Csfle2", WireVersion.Server60);
5253
private static readonly Feature __csfle2Qev2 = new Feature("Csfle2Qev2", WireVersion.Server70, notSupportedMessage: "Driver support of Queryable Encryption is incompatible with server. Upgrade server to use Queryable Encryption.");
@@ -217,6 +218,11 @@ public class Feature
217218
/// </summary>
218219
public static Feature Csfle2QEv2 => __csfle2Qev2;
219220

221+
/// <summary>
222+
/// Gets the csfle2 $lookup support feature.
223+
/// </summary>
224+
public static Feature Csfle2QEv2Lookup => __csfle2Qev2Lookup;
225+
220226
/// <summary>
221227
/// Gets the csfle2 range algorithm feature.
222228
/// </summary>

0 commit comments

Comments
 (0)