@@ -24,6 +24,16 @@ const PBES2_PBKDF2_SHA256_AES256CBC_ALG_ID: &[u8] = &hex!(
24
24
4801650304012a0410b2d02d78b2efd9dff694cf8e0af40925"
25
25
) ;
26
26
27
+ /// PBES2 + PBKDF2-SHA256 + AES-256-CBC `AlgorithmIdentifier` example without PRF NULL parameter.
28
+ ///
29
+ /// Generated by Smallstep CLI: `step certificate p12 out.p12 in.crt in.key`, extracted from PKCS#12.
30
+ /// `tests/examples/pbes2_aes-256-cbc_hmacWithSHA256_algid-no-param.der` test vector.
31
+ const PBES2_PBKDF2_SHA256_AES256CBC_ALG_ID_NO_NULL_PARAM : & [ u8 ] = & hex ! (
32
+ "305d06092a864886f70d01050d3050302f06092a864886f70d01050c30220410
33
+ 0c12aa39d743d1633ddbb615a5ec1b6a02020800300a06082a864886f70d0209
34
+ 301d060960864801650304012a0410baba52272b5a30263d62f81ae27ad768"
35
+ ) ;
36
+
27
37
/// PBES2 + scrypt + AES-256-CBC `AlgorithmIdentifier` example.
28
38
///
29
39
/// Generated by OpenSSL and extracted from the `pkcs8` crate's
@@ -96,6 +106,31 @@ fn decode_pbes2_pbkdf2_sha256_aes256cbc() {
96
106
}
97
107
}
98
108
109
+ /// Decoding test for PBES2 + PBKDF2-SHA256 + AES-256-CBC `AlgorithmIdentifier` without NULL prf parameter
110
+ #[ test]
111
+ fn decode_pbes2_pbkdf2_sha256_aes256cbc_without_null_parameter ( ) {
112
+ let scheme =
113
+ pkcs5:: EncryptionScheme :: try_from ( PBES2_PBKDF2_SHA256_AES256CBC_ALG_ID_NO_NULL_PARAM )
114
+ . unwrap ( ) ;
115
+ let params = scheme. pbes2 ( ) . unwrap ( ) ;
116
+
117
+ let pbkdf2_params = params. kdf . pbkdf2 ( ) . unwrap ( ) ;
118
+ assert_eq ! (
119
+ pbkdf2_params. salt. as_bytes( ) ,
120
+ & hex!( "0C12AA39D743D1633DDBB615A5EC1B6A" )
121
+ ) ;
122
+ assert_eq ! ( pbkdf2_params. iteration_count, 2048 ) ;
123
+ assert_eq ! ( pbkdf2_params. key_length, None ) ;
124
+ assert_eq ! ( pbkdf2_params. prf, pbes2:: Pbkdf2Prf :: HmacWithSha256 ) ;
125
+
126
+ match params. encryption {
127
+ pbes2:: EncryptionScheme :: Aes256Cbc { iv } => {
128
+ assert_eq ! ( iv, hex!( "BABA52272B5A30263D62F81AE27AD768" ) ) ;
129
+ }
130
+ other => panic ! ( "unexpected encryption scheme: {:?}" , other) ,
131
+ }
132
+ }
133
+
99
134
/// Decoding test for PBES2 + scrypt + AES-256-CBC `AlgorithmIdentifier`
100
135
#[ test]
101
136
fn decode_pbes2_scrypt_aes256cbc ( ) {
0 commit comments