@@ -499,3 +499,29 @@ fn reencode_enveloped_data_multi_test() {
499
499
// should match the original
500
500
assert_eq ! ( reencoded_data_in_ci, der_ci)
501
501
}
502
+
503
+ #[ test]
504
+ fn aws_kms_ciphertext_for_recipient ( ) {
505
+ let table = & [
506
+ ( include_bytes ! ( "examples/kms_ciphertext_for_recipient_1.ber" ) . as_slice ( ) , 16 , Some ( hex ! ( "CC74ADF65D973C8B72CD51E1B927F0F0" ) . as_slice ( ) ) ) ,
507
+ ( include_bytes ! ( "examples/kms_ciphertext_for_recipient_2.ber" ) . as_slice ( ) , 48 , Some ( hex ! ( "70E5CAAFFD49AD24EFE15BF903BE9D19895B777D269B57B025F6F67E7EF93F94464515F2EBE034EA0B7621A1FF19292E" ) . as_slice ( ) ) ) ,
508
+ ( include_bytes ! ( "examples/kms_ciphertext_for_recipient_3.ber" ) . as_slice ( ) , 16 , Some ( hex ! ( "1F943EB0105C1B0644DF4F7130448A28" ) . as_slice ( ) ) ) ,
509
+ ( include_bytes ! ( "examples/kms_ciphertext_for_recipient_4.ber" ) . as_slice ( ) , 4112 , None ) , // (5 elem) (1000, 1000, 1000, 1000, 112)
510
+ ] ;
511
+
512
+ for & ( row, encrypted_content_len, expected_encrypted_content) in table {
513
+ let ci = ContentInfo :: from_ber ( row) . unwrap ( ) ;
514
+ assert_eq ! ( ci. content_type, const_oid:: db:: rfc5911:: ID_ENVELOPED_DATA ) ;
515
+
516
+ let bytes = ci. content . to_der ( ) . unwrap ( ) ;
517
+ let data = EnvelopedData :: from_ber ( bytes. as_slice ( ) ) . unwrap ( ) ;
518
+ assert_eq ! ( CmsVersion :: V2 , data. version) ;
519
+
520
+ let encrypted_content = data. encrypted_content . encrypted_content . unwrap ( ) ;
521
+ assert_eq ! ( encrypted_content_len, encrypted_content. as_bytes( ) . len( ) ) ;
522
+
523
+ if let Some ( expected_encrypted_content) = expected_encrypted_content {
524
+ assert_eq ! ( expected_encrypted_content, encrypted_content. as_bytes( ) ) ;
525
+ }
526
+ }
527
+ }
0 commit comments