@@ -60,10 +60,8 @@ mod hashers {
60
60
61
61
// ecdsa_secp256r1_sha512 requires truncating to 32 bytes
62
62
pub fn sha512 ( data : & [ u8 ] ) -> [ u8 ; 32 ] {
63
- let mut out = [ 0u8 ; 32 ] ;
64
63
let hash = Sha512 :: digest ( data) . to_vec ( ) ;
65
- out. copy_from_slice ( & hash[ 0 ..32 ] ) ;
66
- out
64
+ hash[ ..32 ] . try_into ( ) . unwrap ( )
67
65
}
68
66
69
67
pub fn sha3_256 ( data : & [ u8 ] ) -> [ u8 ; 32 ] {
@@ -72,10 +70,8 @@ mod hashers {
72
70
73
71
// ecdsa_secp256r1_sha3_512 requires truncating to 32 bytes
74
72
pub fn sha3_512 ( data : & [ u8 ] ) -> [ u8 ; 32 ] {
75
- let mut out = [ 0u8 ; 32 ] ;
76
73
let hash = Sha3_512 :: digest ( data) . to_vec ( ) ;
77
- out. copy_from_slice ( & hash[ 0 ..32 ] ) ;
78
- out
74
+ hash[ ..32 ] . try_into ( ) . unwrap ( )
79
75
}
80
76
}
81
77
@@ -86,7 +82,7 @@ fn ecdsa_secp256r1_sha256() {
86
82
number_of_tests,
87
83
test_groups,
88
84
} = read_file ( SECP256R1_SHA256 ) ;
89
- assert_eq ! ( number_of_tests, 471 , "Got unexpected number of tests" ) ;
85
+ assert ! ( number_of_tests >= 471 , "Got unexpected number of tests" ) ;
90
86
91
87
for group in test_groups {
92
88
let public_key = hex:: decode ( group. public_key . uncompressed ) . unwrap ( ) ;
@@ -95,7 +91,6 @@ fn ecdsa_secp256r1_sha256() {
95
91
for tc in group. tests {
96
92
tested += 1 ;
97
93
assert_eq ! ( tc. tc_id as usize , tested) ;
98
- // eprintln!("Test case ID: {}", tc.tc_id);
99
94
100
95
match tc. result . as_str ( ) {
101
96
"valid" | "acceptable" => {
@@ -135,7 +130,7 @@ fn ecdsa_secp256r1_sha512() {
135
130
number_of_tests,
136
131
test_groups,
137
132
} = read_file ( SECP256R1_SHA512 ) ;
138
- assert_eq ! ( number_of_tests, 541 , "Got unexpected number of tests" ) ;
133
+ assert ! ( number_of_tests >= 541 , "Got unexpected number of tests" ) ;
139
134
140
135
for group in test_groups {
141
136
let public_key = hex:: decode ( group. public_key . uncompressed ) . unwrap ( ) ;
@@ -144,7 +139,6 @@ fn ecdsa_secp256r1_sha512() {
144
139
for tc in group. tests {
145
140
tested += 1 ;
146
141
assert_eq ! ( tc. tc_id as usize , tested) ;
147
- // eprintln!("Test case ID: {}", tc.tc_id);
148
142
149
143
match tc. result . as_str ( ) {
150
144
"valid" | "acceptable" => {
@@ -184,7 +178,7 @@ fn ecdsa_secp256r1_sha3_256() {
184
178
number_of_tests,
185
179
test_groups,
186
180
} = read_file ( SECP256R1_SHA3_256 ) ;
187
- assert_eq ! ( number_of_tests, 479 , "Got unexpected number of tests" ) ;
181
+ assert ! ( number_of_tests >= 479 , "Got unexpected number of tests" ) ;
188
182
189
183
for group in test_groups {
190
184
let public_key = hex:: decode ( group. public_key . uncompressed ) . unwrap ( ) ;
@@ -193,7 +187,6 @@ fn ecdsa_secp256r1_sha3_256() {
193
187
for tc in group. tests {
194
188
tested += 1 ;
195
189
assert_eq ! ( tc. tc_id as usize , tested) ;
196
- // eprintln!("Test case ID: {}", tc.tc_id);
197
190
198
191
match tc. result . as_str ( ) {
199
192
"valid" | "acceptable" => {
@@ -233,7 +226,7 @@ fn ecdsa_secp256r1_sha3_512() {
233
226
number_of_tests,
234
227
test_groups,
235
228
} = read_file ( SECP256R1_SHA3_512 ) ;
236
- assert_eq ! ( number_of_tests, 545 , "Got unexpected number of tests" ) ;
229
+ assert ! ( number_of_tests >= 545 , "Got unexpected number of tests" ) ;
237
230
238
231
for group in test_groups {
239
232
let public_key = hex:: decode ( group. public_key . uncompressed ) . unwrap ( ) ;
@@ -242,7 +235,6 @@ fn ecdsa_secp256r1_sha3_512() {
242
235
for tc in group. tests {
243
236
tested += 1 ;
244
237
assert_eq ! ( tc. tc_id as usize , tested) ;
245
- // eprintln!("Test case ID: {}", tc.tc_id);
246
238
247
239
match tc. result . as_str ( ) {
248
240
"valid" | "acceptable" => {
0 commit comments