@@ -8,9 +8,6 @@ class Verifier
8
8
const COMMENTHDRLEN = 19 ;
9
9
const COMMENTMAXLEN = 1024 ;
10
10
11
- // Allowed checksum list verification algorithms and their base64-encoded lengths.
12
- protected $ HASH_ALGO_BASE64_LENGTHS = array ('SHA256 ' => 64 , 'SHA512 ' => 128 );
13
-
14
11
/**
15
12
* @var string
16
13
*/
@@ -173,7 +170,7 @@ public function verifyChecksumList($signed_checksum_list, $working_directory)
173
170
}
174
171
175
172
protected function verifyTrustedChecksumList ($ checksum_list_raw , $ working_directory ) {
176
- $ checksum_list = $ this -> parseChecksumList ($ checksum_list_raw , true );
173
+ $ checksum_list = new ChecksumList ($ checksum_list_raw , true );
177
174
$ verified_count = 0 ;
178
175
179
176
/**
@@ -227,35 +224,6 @@ public function verifyChecksumFile($checksum_file) {
227
224
return $ this ->verifyChecksumList ($ signed_checksum_list , $ working_directory );
228
225
}
229
226
230
- protected function parseChecksumList ($ checksum_list_raw , $ list_is_trusted )
231
- {
232
- $ lines = explode ("\n" , $ checksum_list_raw );
233
- $ verified_checksums = array ();
234
- foreach ($ lines as $ line ) {
235
- if (trim ($ line ) == '' ) {
236
- continue ;
237
- }
238
-
239
- if (substr ($ line , 0 , 1 ) === '\\' ) {
240
- throw new VerifierException ('Filenames with problematic characters are not yet supported. ' );
241
- }
242
-
243
- $ algo = substr ($ line , 0 , strpos ($ line , ' ' ));
244
- if (empty ($ this ->HASH_ALGO_BASE64_LENGTHS [$ algo ])) {
245
- throw new VerifierException ("Algorithm \"$ algo \" is unsupported for checksum verification. " );
246
- }
247
-
248
- $ filename_start = strpos ($ line , '( ' ) + 1 ;
249
- $ bytes_after_filename = $ this ->HASH_ALGO_BASE64_LENGTHS [$ algo ] + 4 ;
250
- $ filename = substr ($ line , $ filename_start , -$ bytes_after_filename );
251
-
252
- $ verified_checksum = new VerifierFileChecksum ($ filename , $ algo , substr ($ line , -$ this ->HASH_ALGO_BASE64_LENGTHS [$ algo ]), $ list_is_trusted );
253
- $ verified_checksums [] = $ verified_checksum ;
254
- }
255
-
256
- return $ verified_checksums ;
257
- }
258
-
259
227
/**
260
228
* Verify a string message signed with CSIG chained-signature extended Signify format.
261
229
*
0 commit comments