1
1
/*
2
- * Copyright (c) 1997, 2023 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 1997, 2025 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -503,6 +503,8 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
503
503
boolean attrsVerified = true ;
504
504
// If only weak algorithms are used.
505
505
boolean weakAlgs = true ;
506
+ // If only unsupported algorithms are used.
507
+ boolean unsupportedAlgs = true ;
506
508
// If a ATTR_DIGEST entry is found.
507
509
boolean validEntry = false ;
508
510
@@ -527,6 +529,7 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
527
529
528
530
MessageDigest digest = getDigest (algorithm );
529
531
if (digest != null ) {
532
+ unsupportedAlgs = false ;
530
533
ManifestDigester .Entry mde =
531
534
md .get (ManifestDigester .MF_MAIN_ATTRS , false );
532
535
if (mde == null ) {
@@ -570,12 +573,22 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
570
573
}
571
574
}
572
575
573
- // If there were only weak algorithms entries used, throw an exception.
574
- if (validEntry && weakAlgs ) {
575
- throw new SignatureException ("Manifest Main Attribute check " +
576
- "failed (" + ATTR_DIGEST + "). " +
577
- "Disabled algorithm(s) used: " +
578
- getWeakAlgorithms (ATTR_DIGEST ));
576
+ if (validEntry ) {
577
+ // If there were only weak algorithms entries used, throw an exception.
578
+ if (weakAlgs ) {
579
+ throw new SignatureException (
580
+ "Manifest Main Attribute check "
581
+ + "failed (" + ATTR_DIGEST + "). "
582
+ + "Disabled algorithm(s) used: "
583
+ + getWeakAlgorithms (ATTR_DIGEST ));
584
+ }
585
+
586
+ // If there were only unsupported algorithms entries used, throw an exception.
587
+ if (unsupportedAlgs ) {
588
+ throw new SignatureException (
589
+ "Manifest Main Attribute check failed ("
590
+ + ATTR_DIGEST + "). Unsupported algorithm(s) used" );
591
+ }
579
592
}
580
593
581
594
// this method returns 'true' if either:
0 commit comments