Skip to content

Commit bdfc953

Browse files
committed
update for libmongocrypt 1.5.2 (#1037)
Resolve GODRIVER-2511: * Add CSFLE prose test 16. * Update tests to use libmongocrypt 1.5.2. Resolve GODRIVER-2513: * Return error if libmongocrypt < 1.5.2 is detected in RewrapManyDataKey. * Retract Go driver release v1.10.0. Resolve GODRIVER-2509: * Resync RewrapManyDataKey specification tests to mongodb/specifications@10b4a41. * Resolve GODRIVER-2512: Resolve GODRIVER-2512: - Resync fle2-InsertFind-Unindexed.json
1 parent 51ecabd commit bdfc953

13 files changed

+183
-15
lines changed

.evergreen/config.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ functions:
9494
go version
9595
go env
9696
97-
LIBMONGOCRYPT_TAG="1.5.0"
97+
LIBMONGOCRYPT_BRANCH="r1.5"
98+
LIBMONGOCRYPT_TAG="1.5.2"
9899
# LIBMONGOCRYPT_COMMIT is the commit on libmongocrypt for the tag LIBMONGOCRYPT_TAG.
99-
LIBMONGOCRYPT_COMMIT="c3be59f9b0d756caa4c22c254e0704084cf6bca4"
100+
LIBMONGOCRYPT_COMMIT="8f8675fa11922f00a4516a7f8a60621aa1ca1550"
100101
# Install libmongocrypt based on OS.
101102
if [ "Windows_NT" = "$OS" ]; then
102103
mkdir -p c:/libmongocrypt/include
@@ -105,7 +106,7 @@ functions:
105106
mkdir libmongocrypt-all
106107
cd libmongocrypt-all
107108
# The following URL is published from the upload-all task in the libmongocrypt Evergreen project.
108-
curl https://mciuploads.s3.amazonaws.com/libmongocrypt/all/master/$LIBMONGOCRYPT_COMMIT/libmongocrypt-all.tar.gz -o libmongocrypt-all.tar.gz
109+
curl https://mciuploads.s3.amazonaws.com/libmongocrypt/all/$LIBMONGOCRYPT_BRANCH/$LIBMONGOCRYPT_COMMIT/libmongocrypt-all.tar.gz -o libmongocrypt-all.tar.gz
109110
tar -xf libmongocrypt-all.tar.gz
110111
cd ..
111112
cp libmongocrypt-all/windows-test/bin/mongocrypt.dll c:/libmongocrypt/bin
@@ -120,7 +121,7 @@ functions:
120121
mkdir libmongocrypt-all
121122
cd libmongocrypt-all
122123
# The following URL is published from the upload-all task in the libmongocrypt Evergreen project.
123-
curl https://mciuploads.s3.amazonaws.com/libmongocrypt/all/master/$LIBMONGOCRYPT_COMMIT/libmongocrypt-all.tar.gz -o libmongocrypt-all.tar.gz
124+
curl https://mciuploads.s3.amazonaws.com/libmongocrypt/all/$LIBMONGOCRYPT_BRANCH/$LIBMONGOCRYPT_COMMIT/libmongocrypt-all.tar.gz -o libmongocrypt-all.tar.gz
124125
tar -xf libmongocrypt-all.tar.gz
125126
cd ..
126127
mv libmongocrypt-all/macos/include ./install/libmongocrypt

data/client-side-encryption/legacy/fle2-InsertFind-Unindexed.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@
241241
}
242242
},
243243
"result": {
244-
"errorContains": "Cannot query"
244+
"errorContains": "encrypt"
245245
}
246246
}
247247
]

data/client-side-encryption/legacy/fle2-InsertFind-Unindexed.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,8 @@ tests:
8080
arguments:
8181
filter: { encryptedUnindexed: "value123" }
8282
result:
83-
errorContains: "Cannot query"
83+
# Expected error message changed in https://github.com/10gen/mongo-enterprise-modules/commit/212b584d4f7a44bed41c826a180a4aff00923d7a#diff-5f12b55e8d5c52c2f62853ec595dc2c1e2e5cb4fdbf7a32739a8e3acb3c6f818
84+
# Before the message was "cannot query non-indexed fields with the randomized encryption algorithm"
85+
# After: "can only execute encrypted equality queries with an encrypted equality index"
86+
# Use a small common substring.
87+
errorContains: "encrypt"

data/client-side-encryption/unified/createDataKey-kms_providers-invalid.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"description": "createDataKey-provider-invalid",
2+
"description": "createDataKey-kms_providers-invalid",
33
"schemaVersion": "1.8",
44
"runOnRequirements": [
55
{

data/client-side-encryption/unified/createDataKey-kms_providers-invalid.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
description: createDataKey-provider-invalid
1+
description: createDataKey-kms_providers-invalid
22

33
schemaVersion: "1.8"
44

data/client-side-encryption/unified/rewrapManyDataKey.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"description": "rewrapManyDataKey-kms_providers",
2+
"description": "rewrapManyDataKey",
33
"schemaVersion": "1.8",
44
"runOnRequirements": [
55
{
@@ -128,7 +128,7 @@
128128
],
129129
"keyMaterial": {
130130
"$binary": {
131-
"base64": "AQICAHhQNmWG2CzOm1dq3kWLM+iDUZhEqnhJwH9wZVpuZ94A8gEGkNTybTc7Eyif0f+qqE0lAAAAwjCBvwYJKoZIhvcNAQcGoIGxMIGuAgEAMIGoBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDB2j78AeuIQxcRh8cQIBEIB7vj9buHEaT7XHFIsKBJiyzZRmNnjvqMK5LSdzonKdx97jlqauvPvTDXSsdQDcspUs5oLrGmAXpbFResscxmbwZoKgUtWiuIOpeAcYuszCiMKt15s1WIMLDXUhYtfCmhRhekvgHnRAaK4HJMlGE+lKJXYI84E0b86Cd/g+",
131+
"base64": "pr01l7qDygUkFE/0peFwpnNlv3iIy8zrQK38Q9i12UCN2jwZHDmfyx8wokiIKMb9kAleeY+vnt3Cf1MKu9kcDmI+KxbNDd+V3ytAAGzOVLDJr77CiWjF9f8ntkXRHrAY9WwnVDANYkDwXlyU0Y2GQFTiW65jiQhUtYLYH63Tk48SsJuQvnWw1Q+PzY8ga+QeVec8wbcThwtm+r2IHsCFnc72Gv73qq7weISw+O4mN08z3wOp5FOS2ZM3MK7tBGmPdBcktW7F8ODGsOQ1FU53OrWUnyX2aTi2ftFFFMWVHqQo7EYuBZHru8RRODNKMyQk0BFfKovAeTAVRv9WH9QU7g==",
132132
"subType": "00"
133133
}
134134
},
@@ -196,7 +196,7 @@
196196
],
197197
"keyMaterial": {
198198
"$binary": {
199-
"base64": "VoI9J8HusQ3u2gT9i8Awgg/6W4/igvLwRzn3SRDGx0Dl/1ayDMubphOw0ONPVKfuvS6HL3e4gAoCJ/uEz2KLFTVsEqYCpMhfAhgXxm8Ena8vDcOkCzFX+euvN/N2ES3wpzAD18b3qIH0MbBwKJP82d5GQ4pVfGnPW8Ujp9aO1qC/s0EqNqYyzJ1SyzhV9lAjHHGIENYJx+bBrekg2EeZBA==",
199+
"base64": "CklVctHzke4mcytd0TxGqvepkdkQN8NUF4+jV7aZQITAKdz6WjdDpq3lMt9nSzWGG2vAEfvRb3mFEVjV57qqGqxjq2751gmiMRHXz0btStbIK3mQ5xbY9kdye4tsixlCryEwQONr96gwlwKKI9Nubl9/8+uRF6tgYjje7Q7OjauEf1SrJwKcoQ3WwnjZmEqAug0kImCpJ/irhdqPzivRiA==",
200200
"subType": "00"
201201
}
202202
},

data/client-side-encryption/unified/rewrapManyDataKey.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# commands sort the resulting documents in ascending order by the single-element
33
# keyAltNames array to ensure alphabetic order by original KMS provider as
44
# defined in initialData.
5-
description: rewrapManyDataKey-kms_providers
5+
description: rewrapManyDataKey
66

77
schemaVersion: "1.8"
88

@@ -50,7 +50,7 @@ initialData:
5050
region: us-east-1
5151
- _id: &azure_key_id { $binary: { base64: YXp1cmVhenVyZWF6dXJlYQ==, subType: "04" } }
5252
keyAltNames: ["azure_key"]
53-
keyMaterial: { $binary: { base64: AQICAHhQNmWG2CzOm1dq3kWLM+iDUZhEqnhJwH9wZVpuZ94A8gEGkNTybTc7Eyif0f+qqE0lAAAAwjCBvwYJKoZIhvcNAQcGoIGxMIGuAgEAMIGoBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDB2j78AeuIQxcRh8cQIBEIB7vj9buHEaT7XHFIsKBJiyzZRmNnjvqMK5LSdzonKdx97jlqauvPvTDXSsdQDcspUs5oLrGmAXpbFResscxmbwZoKgUtWiuIOpeAcYuszCiMKt15s1WIMLDXUhYtfCmhRhekvgHnRAaK4HJMlGE+lKJXYI84E0b86Cd/g+, subType: "00" } }
53+
keyMaterial: { $binary: { base64: pr01l7qDygUkFE/0peFwpnNlv3iIy8zrQK38Q9i12UCN2jwZHDmfyx8wokiIKMb9kAleeY+vnt3Cf1MKu9kcDmI+KxbNDd+V3ytAAGzOVLDJr77CiWjF9f8ntkXRHrAY9WwnVDANYkDwXlyU0Y2GQFTiW65jiQhUtYLYH63Tk48SsJuQvnWw1Q+PzY8ga+QeVec8wbcThwtm+r2IHsCFnc72Gv73qq7weISw+O4mN08z3wOp5FOS2ZM3MK7tBGmPdBcktW7F8ODGsOQ1FU53OrWUnyX2aTi2ftFFFMWVHqQo7EYuBZHru8RRODNKMyQk0BFfKovAeTAVRv9WH9QU7g==, subType: "00" } }
5454
creationDate: { $date: { $numberLong: "1641024000000" } }
5555
updateDate: { $date: { $numberLong: "1641024000000" } }
5656
status: 1
@@ -72,7 +72,7 @@ initialData:
7272
keyName: key-name-csfle
7373
- _id: &kmip_key_id { $binary: { base64: a21pcGttaXBrbWlwa21pcA==, subType: "04" } }
7474
keyAltNames: ["kmip_key"]
75-
keyMaterial: { $binary: { base64: VoI9J8HusQ3u2gT9i8Awgg/6W4/igvLwRzn3SRDGx0Dl/1ayDMubphOw0ONPVKfuvS6HL3e4gAoCJ/uEz2KLFTVsEqYCpMhfAhgXxm8Ena8vDcOkCzFX+euvN/N2ES3wpzAD18b3qIH0MbBwKJP82d5GQ4pVfGnPW8Ujp9aO1qC/s0EqNqYyzJ1SyzhV9lAjHHGIENYJx+bBrekg2EeZBA==, subType: "00" } }
75+
keyMaterial: { $binary: { base64: CklVctHzke4mcytd0TxGqvepkdkQN8NUF4+jV7aZQITAKdz6WjdDpq3lMt9nSzWGG2vAEfvRb3mFEVjV57qqGqxjq2751gmiMRHXz0btStbIK3mQ5xbY9kdye4tsixlCryEwQONr96gwlwKKI9Nubl9/8+uRF6tgYjje7Q7OjauEf1SrJwKcoQ3WwnjZmEqAug0kImCpJ/irhdqPzivRiA==, subType: "00" } }
7676
creationDate: { $date: { $numberLong: "1641024000000" } }
7777
updateDate: { $date: { $numberLong: "1641024000000" } }
7878
status: 1

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module go.mongodb.org/mongo-driver
33
go 1.10
44

55
retract (
6+
v1.10.0 // Contains a possible data corruption bug in RewrapManyDataKey when using libmongocrypt versions less than 1.5.2.
67
[v1.7.0, v1.7.1] // Contains data race bug in background connection establishment.
78
[v1.6.0, v1.6.1] // Contains data race bug in background connection establishment.
89
)

mongo/client_encryption.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,17 @@ func setRewrapManyDataKeyWriteModels(rewrappedDocuments []bsoncore.Document, wri
249249
// RewrapManyDataKey decrypts and encrypts all matching data keys with a possibly new masterKey value. For all
250250
// matching documents, this method will overwrite the "masterKey", "updateDate", and "keyMaterial". On error, some
251251
// matching data keys may have been rewrapped.
252+
// libmongocrypt 1.5.2 is required. An error is returned if the detected version of libmongocrypt is less than 1.5.2.
252253
func (ce *ClientEncryption) RewrapManyDataKey(ctx context.Context, filter interface{},
253254
opts ...*options.RewrapManyDataKeyOptions) (*RewrapManyDataKeyResult, error) {
254255

256+
// libmongocrypt versions 1.5.0 and 1.5.1 have a severe bug in RewrapManyDataKey.
257+
// Check if the version string starts with 1.5.0 or 1.5.1. This accounts for pre-release versions, like 1.5.0-rc0.
258+
libmongocryptVersion := mongocrypt.Version()
259+
if strings.HasPrefix(libmongocryptVersion, "1.5.0") || strings.HasPrefix(libmongocryptVersion, "1.5.1") {
260+
return nil, fmt.Errorf("RewrapManyDataKey requires libmongocrypt 1.5.2 or newer. Detected version: %v", libmongocryptVersion)
261+
}
262+
255263
rmdko := options.MergeRewrapManyDataKeyOptions(opts...)
256264
if ctx == nil {
257265
ctx = context.Background()

mongo/doc.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,17 @@
107107
//
108108
// The libmongocrypt C library is required when using client-side encryption. Specific versions of libmongocrypt
109109
// are required for different versions of the Go Driver:
110+
//
110111
// - Go Driver v1.2.0 requires libmongocrypt v1.0.0 or higher
112+
//
111113
// - Go Driver v1.5.0 requires libmongocrypt v1.1.0 or higher
114+
//
112115
// - Go Driver v1.8.0 requires libmongocrypt v1.3.0 or higher
113-
// - Go Driver v1.10.0 requires libmongocrypt v1.5.0 or higher
116+
//
117+
// - Go Driver v1.10.0 requires libmongocrypt v1.5.0 or higher.
118+
// There is a severe bug when calling RewrapManyDataKey with libmongocrypt versions less than 1.5.2.
119+
// This bug may result in data corruption.
120+
// Please use libmongocrypt 1.5.2 or higher when calling RewrapManyDataKey.
114121
//
115122
// To install libmongocrypt, follow the instructions for your
116123
// operating system:

0 commit comments

Comments
 (0)