@@ -18,17 +18,19 @@ fn pkcs12_key_derive_sha256() {
1818 Pkcs12KeyType :: EncryptionKey ,
1919 100 ,
2020 32
21- ) ,
21+ )
22+ . unwrap( ) ,
2223 hex!( "fae4d4957a3cc781e1180b9d4fb79c1e0c8579b746a3177e5b0768a3118bf863" )
2324 ) ;
2425
2526 assert_eq ! (
26- derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: Iv , 100 , 32 ) ,
27+ derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: Iv , 100 , 32 ) . unwrap ( ) ,
2728 hex!( "e5ff813bc6547de5155b14d2fada85b3201a977349db6e26ccc998d9e8f83d6c" )
2829 ) ;
2930
3031 assert_eq ! (
31- derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: Mac , 100 , 32 ) ,
32+ derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: Mac , 100 , 32 )
33+ . unwrap( ) ,
3234 hex!( "136355ed9434516682534f46d63956db5ff06b844702c2c1f3b46321e2524a4d" )
3335 ) ;
3436
@@ -39,17 +41,19 @@ fn pkcs12_key_derive_sha256() {
3941 Pkcs12KeyType :: EncryptionKey ,
4042 100 ,
4143 20
42- ) ,
44+ )
45+ . unwrap( ) ,
4346 hex!( "fae4d4957a3cc781e1180b9d4fb79c1e0c8579b7" )
4447 ) ;
4548
4649 assert_eq ! (
47- derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: Iv , 100 , 20 ) ,
50+ derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: Iv , 100 , 20 ) . unwrap ( ) ,
4851 hex!( "e5ff813bc6547de5155b14d2fada85b3201a9773" )
4952 ) ;
5053
5154 assert_eq ! (
52- derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: Mac , 100 , 20 ) ,
55+ derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: Mac , 100 , 20 )
56+ . unwrap( ) ,
5357 hex!( "136355ed9434516682534f46d63956db5ff06b84" )
5458 ) ;
5559
@@ -60,17 +64,19 @@ fn pkcs12_key_derive_sha256() {
6064 Pkcs12KeyType :: EncryptionKey ,
6165 100 ,
6266 12
63- ) ,
67+ )
68+ . unwrap( ) ,
6469 hex!( "fae4d4957a3cc781e1180b9d" )
6570 ) ;
6671
6772 assert_eq ! (
68- derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: Iv , 100 , 12 ) ,
73+ derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: Iv , 100 , 12 ) . unwrap ( ) ,
6974 hex!( "e5ff813bc6547de5155b14d2" )
7075 ) ;
7176
7277 assert_eq ! (
73- derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: Mac , 100 , 12 ) ,
78+ derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: Mac , 100 , 12 )
79+ . unwrap( ) ,
7480 hex!( "136355ed9434516682534f46" )
7581 ) ;
7682
@@ -81,34 +87,38 @@ fn pkcs12_key_derive_sha256() {
8187 Pkcs12KeyType :: EncryptionKey ,
8288 1000 ,
8389 32
84- ) ,
90+ )
91+ . unwrap( ) ,
8592 hex!( "2b95a0569b63f641fae1efca32e84db3699ab74540628ba66283b58cf5400527" )
8693 ) ;
8794
8895 assert_eq ! (
89- derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: Iv , 1000 , 32 ) ,
96+ derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: Iv , 1000 , 32 )
97+ . unwrap( ) ,
9098 hex!( "6472c0ebad3fab4123e8b5ed7834de21eeb20187b3eff78a7d1cdffa4034851d" )
9199 ) ;
92100
93101 assert_eq ! (
94- derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: Mac , 1000 , 32 ) ,
102+ derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: Mac , 1000 , 32 )
103+ . unwrap( ) ,
95104 hex!( "3f9113f05c30a996c4a516409bdac9d065f44296ccd52bb75de3fcfdbe2bf130" )
96105 ) ;
97106
98107 assert_eq ! (
99- derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: Mac , 1000 , 32 ) ,
108+ derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: Mac , 1000 , 32 )
109+ . unwrap( ) ,
100110 hex!( "3f9113f05c30a996c4a516409bdac9d065f44296ccd52bb75de3fcfdbe2bf130" )
101111 ) ;
102112
103113 assert_eq ! (
104- derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: EncryptionKey , 1000 , 100 ) ,
105- hex!( "2b95a0569b63f641fae1efca32e84db3699ab74540628ba66283b58cf5400527d8d0ebe2ccbf768c51c4d8fbd1bb156be06c1c59cbb69e44052ffc37376fdb47b2de7f9e543de9d096d8e5474b220410ff1c5d8bb7e5bc0f61baeaa12fd0da1d7a970172" )
106- ) ;
114+ derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: EncryptionKey , 1000 , 100 ) . unwrap ( ) ,
115+ hex!( "2b95a0569b63f641fae1efca32e84db3699ab74540628ba66283b58cf5400527d8d0ebe2ccbf768c51c4d8fbd1bb156be06c1c59cbb69e44052ffc37376fdb47b2de7f9e543de9d096d8e5474b220410ff1c5d8bb7e5bc0f61baeaa12fd0da1d7a970172" )
116+ ) ;
107117
108118 assert_eq ! (
109- derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: EncryptionKey , 1000 , 200 ) ,
110- hex!( "2b95a0569b63f641fae1efca32e84db3699ab74540628ba66283b58cf5400527d8d0ebe2ccbf768c51c4d8fbd1bb156be06c1c59cbb69e44052ffc37376fdb47b2de7f9e543de9d096d8e5474b220410ff1c5d8bb7e5bc0f61baeaa12fd0da1d7a9701729cea6014d7fe62a2ed926dc36b61307f119d64edbceb5a9c58133bbf75ba0bef000a1a5180e4b1de7d89c89528bcb7899a1e46fd4da0d9de8f8e65e8d0d775e33d1247e76d596a34303161b219f39afda448bf518a2835fc5e28f0b55a1b6137a2c70cf7" )
111- ) ;
119+ derive_key_utf8:: <sha2:: Sha256 >( PASS_SHORT , & SALT_INC , Pkcs12KeyType :: EncryptionKey , 1000 , 200 ) . unwrap ( ) ,
120+ hex!( "2b95a0569b63f641fae1efca32e84db3699ab74540628ba66283b58cf5400527d8d0ebe2ccbf768c51c4d8fbd1bb156be06c1c59cbb69e44052ffc37376fdb47b2de7f9e543de9d096d8e5474b220410ff1c5d8bb7e5bc0f61baeaa12fd0da1d7a9701729cea6014d7fe62a2ed926dc36b61307f119d64edbceb5a9c58133bbf75ba0bef000a1a5180e4b1de7d89c89528bcb7899a1e46fd4da0d9de8f8e65e8d0d775e33d1247e76d596a34303161b219f39afda448bf518a2835fc5e28f0b55a1b6137a2c70cf7" )
121+ ) ;
112122}
113123
114124#[ test]
@@ -123,7 +133,8 @@ fn pkcs12_key_derive_sha512() {
123133 Pkcs12KeyType :: EncryptionKey ,
124134 100 ,
125135 32
126- ) ,
136+ )
137+ . unwrap( ) ,
127138 hex!( "b14a9f01bfd9dce4c9d66d2fe9937e5fd9f1afa59e370a6fa4fc81c1cc8ec8ee" )
128139 ) ;
129140}
@@ -140,7 +151,8 @@ fn pkcs12_key_derive_whirlpool() {
140151 Pkcs12KeyType :: EncryptionKey ,
141152 100 ,
142153 32
143- ) ,
154+ )
155+ . unwrap( ) ,
144156 hex!( "3324282adb468bff0734d3b7e399094ec8500cb5b0a3604055da107577aaf766" )
145157 ) ;
146158}
@@ -150,14 +162,12 @@ fn pkcs12_key_derive_special_chars() {
150162 const PASS_SHORT : & str = "🔥" ;
151163 const SALT_INC : [ u8 ; 8 ] = [ 0x1 , 0x2 , 0x3 , 0x4 , 0x5 , 0x6 , 0x7 , 0x8 ] ;
152164
153- assert_eq ! (
154- derive_key_utf8:: <sha2:: Sha256 >(
155- PASS_SHORT ,
156- & SALT_INC ,
157- Pkcs12KeyType :: EncryptionKey ,
158- 100 ,
159- 32
160- ) ,
161- hex!( "d01e72a940b4b1a7a5707fc8264a60cb7606ff9051dedff90930687d2513c006" )
162- ) ;
165+ assert ! ( derive_key_utf8:: <sha2:: Sha256 >(
166+ PASS_SHORT ,
167+ & SALT_INC ,
168+ Pkcs12KeyType :: EncryptionKey ,
169+ 100 ,
170+ 32
171+ )
172+ . is_err( ) ) ; // Emoji is not in the Basic Multilingual Plane
163173}
0 commit comments