@@ -52,63 +52,3 @@ fn pbkdf2_tests() {
52
52
Ok ( ( ) )
53
53
} ) ;
54
54
}
55
-
56
- /// The API documentation specifies that derive/verify should panic, if the designated output length
57
- /// is too long. Ring checks for an output array length while pbkdf2 is being ran, while we check
58
- /// the array length before everything is processed.
59
- /// Most platforms will fail to allocate this much memory, so we only test on platforms which can.
60
- #[ cfg( all( target_arch = "x86_64" , target_vendor = "apple" ) ) ]
61
- #[ cfg( test) ]
62
- mod tests {
63
- use aws_lc_rs:: { digest, pbkdf2} ;
64
- use core:: num:: NonZeroU32 ;
65
- use mirai_annotations:: assume;
66
-
67
- #[ test]
68
- #[ should_panic( expected = "derived key too long" ) ]
69
- fn pbkdf2_derive_too_long ( ) {
70
- let iterations = NonZeroU32 :: new ( 1_u32 ) . unwrap ( ) ;
71
- let max_usize32 = u32:: MAX as usize ;
72
- for & alg in & [
73
- pbkdf2:: PBKDF2_HMAC_SHA1 ,
74
- pbkdf2:: PBKDF2_HMAC_SHA256 ,
75
- pbkdf2:: PBKDF2_HMAC_SHA384 ,
76
- pbkdf2:: PBKDF2_HMAC_SHA512 ,
77
- ] {
78
- let output_len = match_pbkdf2_digest ( & alg) . output_len ;
79
- assume ! ( output_len < 2048 ) ;
80
- let mut out = vec ! [ 0u8 ; max_usize32 * output_len + 1 ] ;
81
- pbkdf2:: derive ( alg, iterations, b"salt" , b"password" , & mut out) ;
82
- }
83
- }
84
-
85
- #[ test]
86
- #[ should_panic( expected = "derived key too long" ) ]
87
- fn pbkdf2_verify_too_long ( ) {
88
- let iterations = NonZeroU32 :: new ( 1_u32 ) . unwrap ( ) ;
89
- let max_usize32 = u32:: MAX as usize ;
90
- for & alg in & [
91
- pbkdf2:: PBKDF2_HMAC_SHA1 ,
92
- pbkdf2:: PBKDF2_HMAC_SHA256 ,
93
- pbkdf2:: PBKDF2_HMAC_SHA384 ,
94
- pbkdf2:: PBKDF2_HMAC_SHA512 ,
95
- ] {
96
- let out = vec ! [ 0u8 ; max_usize32 * match_pbkdf2_digest( & alg) . output_len + 1 ] ;
97
- pbkdf2:: verify ( alg, iterations, b"salt" , b"password" , & out) . unwrap ( ) ;
98
- }
99
- }
100
-
101
- fn match_pbkdf2_digest ( & algorithm: & pbkdf2:: Algorithm ) -> & digest:: Algorithm {
102
- if algorithm == pbkdf2:: PBKDF2_HMAC_SHA1 {
103
- & digest:: SHA1_FOR_LEGACY_USE_ONLY
104
- } else if algorithm == pbkdf2:: PBKDF2_HMAC_SHA256 {
105
- & digest:: SHA256
106
- } else if algorithm == pbkdf2:: PBKDF2_HMAC_SHA384 {
107
- & digest:: SHA384
108
- } else if algorithm == pbkdf2:: PBKDF2_HMAC_SHA512 {
109
- & digest:: SHA512
110
- } else {
111
- unreachable ! ( )
112
- }
113
- }
114
- }
0 commit comments