Skip to content

Commit f421b90

Browse files
committed
CSHARP-5625: Support text indexes for explicit encryption
1 parent 2b6782e commit f421b90

File tree

13 files changed

+835
-20
lines changed

13 files changed

+835
-20
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"fields": [
3+
{
4+
"keyId": {
5+
"$binary": {
6+
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
7+
"subType": "04"
8+
}
9+
},
10+
"path": "encryptedText",
11+
"bsonType": "string",
12+
"queries": [
13+
{
14+
"queryType": "prefixPreview",
15+
"strMinQueryLength": {
16+
"$numberInt": "2"
17+
},
18+
"strMaxQueryLength": {
19+
"$numberInt": "10"
20+
},
21+
"caseSensitive": true,
22+
"diacriticSensitive": true
23+
},
24+
{
25+
"queryType": "suffixPreview",
26+
"strMinQueryLength": {
27+
"$numberInt": "2"
28+
},
29+
"strMaxQueryLength": {
30+
"$numberInt": "10"
31+
},
32+
"caseSensitive": true,
33+
"diacriticSensitive": true
34+
}
35+
]
36+
}
37+
]
38+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"fields": [
3+
{
4+
"keyId": {
5+
"$binary": {
6+
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
7+
"subType": "04"
8+
}
9+
},
10+
"path": "encryptedText",
11+
"bsonType": "string",
12+
"queries": [
13+
{
14+
"queryType": "substringPreview",
15+
"strMaxLength": {
16+
"$numberInt": "10"
17+
},
18+
"strMinQueryLength": {
19+
"$numberInt": "2"
20+
},
21+
"strMaxQueryLength": {
22+
"$numberInt": "10"
23+
},
24+
"caseSensitive": true,
25+
"diacriticSensitive": true
26+
}
27+
]
28+
}
29+
]
30+
}

src/MongoDB.Driver.Encryption/CryptClient.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public CryptContext StartEncryptionContext(string db, byte[] command)
105105
/// <summary>
106106
/// Starts an explicit encryption context.
107107
/// </summary>
108-
public CryptContext StartExplicitEncryptionContext(byte[] keyId, byte[] keyAltName, string queryType, long? contentionFactor, string encryptionAlgorithm, byte[] message, byte[] rangeOptions, bool isExpressionMode = false)
108+
public CryptContext StartExplicitEncryptionContext(byte[] keyId, byte[] keyAltName, string queryType, long? contentionFactor, string encryptionAlgorithm, byte[] message, byte[] rangeOptions, byte[] textOptions, bool isExpressionMode = false)
109109
{
110110
var handle = Library.mongocrypt_ctx_new(_handle);
111111

@@ -123,6 +123,11 @@ public CryptContext StartExplicitEncryptionContext(byte[] keyId, byte[] keyAltNa
123123
PinnedBinary.RunAsPinnedBinary(handle, rangeOptions, _status, (h, pb) => Library.mongocrypt_ctx_setopt_algorithm_range(h, pb));
124124
}
125125

126+
if (textOptions != null)
127+
{
128+
PinnedBinary.RunAsPinnedBinary(handle, textOptions, _status, (h, pb) => Library.mongocrypt_ctx_setopt_algorithm_text(h, pb));
129+
}
130+
126131
handle.Check(_status, Library.mongocrypt_ctx_setopt_algorithm(handle, encryptionAlgorithm, -1));
127132

128133
if (queryType != null)

0 commit comments

Comments
 (0)