406 /**
407 * With a given header (*-DIGEST*), return a string that lists all the
408 * algorithms associated with the header.
409 * If there are none, return "Unknown Algorithm".
410 */
411 String getWeakAlgorithms(String header) {
412 String w = "";
413 try {
414 for (String key : permittedAlgs.keySet()) {
415 if (key.endsWith(header)) {
416 w += key.substring(0, key.length() - header.length()) + " ";
417 }
418 }
419 } catch (RuntimeException e) {
420 w = "Unknown Algorithm(s). Error processing " + header + ". " +
421 e.getMessage();
422 }
423
424 // This means we have an error in finding weak algorithms, run in
425 // debug mode to see permittedAlgs map's values.
426 if (w.length() == 0) {
427 return "Unknown Algorithm(s)";
428 }
429
430 return w;
431 }
432
433 /**
434 * See if the whole manifest was signed.
435 */
436 private boolean verifyManifestHash(Manifest sf,
437 ManifestDigester md,
438 List<Object> manifestDigests)
439 throws IOException, SignatureException
440 {
441 Attributes mattr = sf.getMainAttributes();
442 boolean manifestSigned = false;
443 // If only weak algorithms are used.
444 boolean weakAlgs = true;
445 // If a "*-DIGEST-MANIFEST" entry is found.
446 boolean validEntry = false;
|
406 /**
407 * With a given header (*-DIGEST*), return a string that lists all the
408 * algorithms associated with the header.
409 * If there are none, return "Unknown Algorithm".
410 */
411 String getWeakAlgorithms(String header) {
412 String w = "";
413 try {
414 for (String key : permittedAlgs.keySet()) {
415 if (key.endsWith(header)) {
416 w += key.substring(0, key.length() - header.length()) + " ";
417 }
418 }
419 } catch (RuntimeException e) {
420 w = "Unknown Algorithm(s). Error processing " + header + ". " +
421 e.getMessage();
422 }
423
424 // This means we have an error in finding weak algorithms, run in
425 // debug mode to see permittedAlgs map's values.
426 if (w.isEmpty()) {
427 return "Unknown Algorithm(s)";
428 }
429
430 return w;
431 }
432
433 /**
434 * See if the whole manifest was signed.
435 */
436 private boolean verifyManifestHash(Manifest sf,
437 ManifestDigester md,
438 List<Object> manifestDigests)
439 throws IOException, SignatureException
440 {
441 Attributes mattr = sf.getMainAttributes();
442 boolean manifestSigned = false;
443 // If only weak algorithms are used.
444 boolean weakAlgs = true;
445 // If a "*-DIGEST-MANIFEST" entry is found.
446 boolean validEntry = false;
|