Skip to content

Commit

Permalink
RUST-1843 Driver fixes for breaking changes in libmongocrypt 1.10.0 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
abr-egn authored Jun 11, 2024
1 parent 71956b4 commit ac7fc24
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
4 changes: 3 additions & 1 deletion .evergreen/MSRV-Cargo.toml.diff
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
168c168
112a113
> url = "=2.5.0"
167c168
< time = "0.3.9"
---
> time = "=0.3.9"
1 change: 1 addition & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ allow = [
"BSD-3-Clause",
"MPL-2.0",
"Unicode-DFS-2016",
"Unicode-3.0",
]
# List of explicitly disallowed licenses
# See https://spdx.org/licenses/ for list of possible licenses
Expand Down
1 change: 1 addition & 0 deletions src/action/csfle/encrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl ClientEncryption {
client_enc: self,
mode: Expression { value: expression },
key: key.into(),
#[allow(deprecated)]
algorithm: Algorithm::RangePreview,
options: Some(EncryptOptions {
query_type: Some("rangePreview".into()),
Expand Down
2 changes: 1 addition & 1 deletion src/client/csfle/client_encryption/encrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl ClientEncryption {
}
if let Some(range_options) = &opts.range_options {
let options_doc = bson::to_document(range_options)?;
builder = builder.range_options(options_doc)?;
builder = builder.algorithm_range(options_doc)?;
}
Ok(builder)
}
Expand Down
31 changes: 14 additions & 17 deletions src/test/csfle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,7 @@ async fn custom_key_material() -> Result<()> {
datakeys.insert_one(key_doc).await?;

let encrypted = enc
.encrypt(
"test",
EncryptKey::Id(new_key_id),
Algorithm::AeadAes256CbcHmacSha512Deterministic,
)
.encrypt("test", EncryptKey::Id(new_key_id), Algorithm::Deterministic)
.await?;
let expected = base64::decode(
"AQAAAAAAAAAAAAAAAAAAAAACz0ZOLuuhEYi807ZXTdhbqhLaS2/t9wLifJnnNYwiw79d75QYIZ6M/\
Expand Down Expand Up @@ -370,7 +366,7 @@ async fn data_key_double_encryption() -> Result<()> {
.encrypt(
format!("hello {}", provider.name()),
EncryptKey::Id(datakey_id),
Algorithm::AeadAes256CbcHmacSha512Deterministic,
Algorithm::Deterministic,
)
.await?;
assert_eq!(encrypted.subtype, BinarySubtype::Encrypted);
Expand All @@ -390,7 +386,7 @@ async fn data_key_double_encryption() -> Result<()> {
.encrypt(
format!("hello {}", provider.name()),
EncryptKey::AltName(format!("{}_altname", provider.name())),
Algorithm::AeadAes256CbcHmacSha512Deterministic,
Algorithm::Deterministic,
)
.await?;
assert_eq!(other_encrypted.subtype, BinarySubtype::Encrypted);
Expand Down Expand Up @@ -491,7 +487,7 @@ async fn external_key_vault() -> Result<()> {
.encrypt(
"test",
EncryptKey::Id(base64_uuid("LOCALAAAAAAAAAAAAAAAAA==")?),
Algorithm::AeadAes256CbcHmacSha512Deterministic,
Algorithm::Deterministic,
)
.await;
if with_external_key_vault {
Expand Down Expand Up @@ -811,8 +807,8 @@ async fn run_corpus_test(local_schema: bool) -> Result<()> {
return Err(failure!("Invalid method {:?}", method));
}
let algo = match subdoc.get_str("algo")? {
"rand" => Algorithm::AeadAes256CbcHmacSha512Random,
"det" => Algorithm::AeadAes256CbcHmacSha512Deterministic,
"rand" => Algorithm::Random,
"det" => Algorithm::Deterministic,
s => return Err(failure!("Invalid algorithm {:?}", s)),
};
let kms = KmsProvider::from_name(subdoc.get_str("kms")?);
Expand Down Expand Up @@ -973,7 +969,7 @@ async fn validate_roundtrip(
.encrypt(
value.clone(),
EncryptKey::Id(key_id),
Algorithm::AeadAes256CbcHmacSha512Deterministic,
Algorithm::Deterministic,
)
.await?;
let decrypted = client_encryption.decrypt(encrypted.as_raw_binary()).await?;
Expand Down Expand Up @@ -1543,7 +1539,7 @@ impl DeadlockTestCase {
.encrypt(
RawBson::String("string0".to_string()),
EncryptKey::AltName("local".to_string()),
Algorithm::AeadAes256CbcHmacSha512Deterministic,
Algorithm::Deterministic,
)
.await?;

Expand Down Expand Up @@ -2551,11 +2547,7 @@ impl DecryptionEventsTestdata {
)?;
let key_id = client_encryption.create_data_key(MasterKey::Local).await?;
let ciphertext = client_encryption
.encrypt(
"hello",
EncryptKey::Id(key_id),
Algorithm::AeadAes256CbcHmacSha512Deterministic,
)
.encrypt("hello", EncryptKey::Id(key_id), Algorithm::Deterministic)
.await?;
let mut malformed_ciphertext = ciphertext.clone();
let last = malformed_ciphertext.bytes.last_mut().unwrap();
Expand Down Expand Up @@ -3125,6 +3117,7 @@ async fn range_explicit_encryption_test(
.encrypt(
bson_numbers[num].clone(),
key1_id.clone(),
#[allow(deprecated)]
Algorithm::RangePreview,
)
.contention_factor(0)
Expand All @@ -3144,6 +3137,7 @@ async fn range_explicit_encryption_test(
.encrypt(
bson_numbers[&6].clone(),
key1_id.clone(),
#[allow(deprecated)]
Algorithm::RangePreview,
)
.contention_factor(0)
Expand Down Expand Up @@ -3256,6 +3250,7 @@ async fn range_explicit_encryption_test(
// Case 6: Encrypting a document greater than the maximum errors
if bson_type != "DoubleNoPrecision" && bson_type != "DecimalNoPrecision" {
let num = get_raw_bson_from_num(bson_type, 201);
#[allow(deprecated)]
let error = client_encryption
.encrypt(num, key1_id.clone(), Algorithm::RangePreview)
.contention_factor(0)
Expand All @@ -3272,6 +3267,7 @@ async fn range_explicit_encryption_test(
} else {
rawdoc! { &key: { "$numberInt": "6" } }
};
#[allow(deprecated)]
let error = client_encryption
.encrypt(value, key1_id.clone(), Algorithm::RangePreview)
.contention_factor(0)
Expand All @@ -3293,6 +3289,7 @@ async fn range_explicit_encryption_test(
.encrypt(
bson_numbers[&6].clone(),
key1_id.clone(),
#[allow(deprecated)]
Algorithm::RangePreview,
)
.contention_factor(0)
Expand Down

0 comments on commit ac7fc24

Please sign in to comment.