@@ -277,12 +277,14 @@ def test_encrypt_decrypt(self):
277
277
278
278
doc = {'_id' : 0 , 'ssn' : '000' }
279
279
encrypted_ssn = client_encryption .encrypt (
280
- doc ['ssn' ], Algorithm .Deterministic , key_id = key_id )
280
+ doc ['ssn' ], Algorithm .AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic ,
281
+ key_id = key_id )
281
282
282
283
# Ensure encryption via key_alt_name for the same key produces the
283
284
# same output.
284
285
encrypted_ssn2 = client_encryption .encrypt (
285
- doc ['ssn' ], Algorithm .Deterministic , key_alt_name = 'name' )
286
+ doc ['ssn' ], Algorithm .AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic ,
287
+ key_alt_name = 'name' )
286
288
self .assertEqual (encrypted_ssn , encrypted_ssn2 )
287
289
288
290
# Test decryption.
@@ -309,7 +311,8 @@ def test_bson_errors(self):
309
311
unencodable_value = object ()
310
312
with self .assertRaises (BSONError ):
311
313
client_encryption .encrypt (
312
- unencodable_value , Algorithm .Deterministic ,
314
+ unencodable_value ,
315
+ Algorithm .AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic ,
313
316
key_id = Binary (uuid .uuid4 ().bytes , UUID_SUBTYPE ))
314
317
315
318
def test_codec_options (self ):
@@ -328,7 +331,8 @@ def test_codec_options(self):
328
331
# Encrypt a UUID with JAVA_LEGACY codec options.
329
332
value = uuid .uuid4 ()
330
333
encrypted_legacy = client_encryption_legacy .encrypt (
331
- value , Algorithm .Deterministic , key_id = key_id )
334
+ value , Algorithm .AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic ,
335
+ key_id = key_id )
332
336
decrypted_value_legacy = client_encryption_legacy .decrypt (
333
337
encrypted_legacy )
334
338
self .assertEqual (decrypted_value_legacy , value )
@@ -338,7 +342,8 @@ def test_codec_options(self):
338
342
KMS_PROVIDERS , 'admin.datakeys' , client_context .client , OPTS )
339
343
self .addCleanup (client_encryption .close )
340
344
encrypted_standard = client_encryption .encrypt (
341
- value , Algorithm .Deterministic , key_id = key_id )
345
+ value , Algorithm .AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic ,
346
+ key_id = key_id )
342
347
decrypted_standard = client_encryption .decrypt (encrypted_standard )
343
348
self .assertEqual (decrypted_standard , value )
344
349
@@ -531,7 +536,9 @@ def test_data_key(self):
531
536
532
537
# Local encrypt by key_id.
533
538
local_encrypted = client_encryption .encrypt (
534
- 'hello local' , Algorithm .Deterministic , key_id = local_datakey_id )
539
+ 'hello local' ,
540
+ Algorithm .AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic ,
541
+ key_id = local_datakey_id )
535
542
self .assertEncrypted (local_encrypted )
536
543
client_encrypted .db .coll .insert_one (
537
544
{'_id' : 'local' , 'value' : local_encrypted })
@@ -540,7 +547,8 @@ def test_data_key(self):
540
547
541
548
# Local encrypt by key_alt_name.
542
549
local_encrypted_altname = client_encryption .encrypt (
543
- 'hello local' , Algorithm .Deterministic ,
550
+ 'hello local' ,
551
+ Algorithm .AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic ,
544
552
key_alt_name = 'local_altname' )
545
553
self .assertEqual (local_encrypted_altname , local_encrypted )
546
554
@@ -559,7 +567,9 @@ def test_data_key(self):
559
567
560
568
# AWS encrypt by key_id.
561
569
aws_encrypted = client_encryption .encrypt (
562
- 'hello aws' , Algorithm .Deterministic , key_id = aws_datakey_id )
570
+ 'hello aws' ,
571
+ Algorithm .AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic ,
572
+ key_id = aws_datakey_id )
563
573
self .assertEncrypted (aws_encrypted )
564
574
client_encrypted .db .coll .insert_one (
565
575
{'_id' : 'aws' , 'value' : aws_encrypted })
@@ -568,7 +578,9 @@ def test_data_key(self):
568
578
569
579
# AWS encrypt by key_alt_name.
570
580
aws_encrypted_altname = client_encryption .encrypt (
571
- 'hello aws' , Algorithm .Deterministic , key_alt_name = 'aws_altname' )
581
+ 'hello aws' ,
582
+ Algorithm .AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic ,
583
+ key_alt_name = 'aws_altname' )
572
584
self .assertEqual (aws_encrypted_altname , aws_encrypted )
573
585
574
586
# Explicitly encrypting an auto encrypted field.
@@ -627,13 +639,16 @@ def _test_external_key_vault(self, with_external_key_vault):
627
639
# Authentication error.
628
640
with self .assertRaises (EncryptionError ) as ctx :
629
641
client_encryption .encrypt (
630
- "test" , Algorithm .Deterministic , key_id = LOCAL_KEY_ID )
642
+ "test" ,
643
+ Algorithm .AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic ,
644
+ key_id = LOCAL_KEY_ID )
631
645
# AuthenticationFailed error.
632
646
self .assertIsInstance (ctx .exception .cause , OperationFailure )
633
647
self .assertEqual (ctx .exception .cause .code , 18 )
634
648
else :
635
649
client_encryption .encrypt (
636
- "test" , Algorithm .Deterministic , key_id = LOCAL_KEY_ID )
650
+ "test" , Algorithm .AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic ,
651
+ key_id = LOCAL_KEY_ID )
637
652
638
653
def test_external_key_vault_1 (self ):
639
654
self ._test_external_key_vault (True )
@@ -744,9 +759,10 @@ def _test_corpus(self, opts):
744
759
745
760
self .assertIn (value ['algo' ], ('det' , 'rand' ))
746
761
if value ['algo' ] == 'det' :
747
- algo = Algorithm .Deterministic
762
+ algo = (Algorithm .
763
+ AEAD_AES_256_CBC_HMAC_SHA_512_Deterministic )
748
764
else :
749
- algo = Algorithm .Random
765
+ algo = Algorithm .AEAD_AES_256_CBC_HMAC_SHA_512_Random
750
766
751
767
try :
752
768
encrypted_val = client_encryption .encrypt (
0 commit comments