11/*
2- * Copyright (c) 1997, 2024 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 1997, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -518,6 +518,8 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
518518 boolean attrsVerified = true ;
519519 // If only weak algorithms are used.
520520 boolean weakAlgs = true ;
521+ // If only unsupported algorithms are used.
522+ boolean unsupportedAlgs = true ;
521523 // If a ATTR_DIGEST entry is found.
522524 boolean validEntry = false ;
523525
@@ -542,6 +544,7 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
542544
543545 MessageDigest digest = getDigest (algorithm );
544546 if (digest != null ) {
547+ unsupportedAlgs = false ;
545548 ManifestDigester .Entry mde = md .getMainAttsEntry (false );
546549 if (mde == null ) {
547550 throw new SignatureException ("Manifest Main Attribute check " +
@@ -584,12 +587,22 @@ private boolean verifyManifestMainAttrs(Manifest sf, ManifestDigester md)
584587 }
585588 }
586589
587- // If there were only weak algorithms entries used, throw an exception.
588- if (validEntry && weakAlgs ) {
589- throw new SignatureException ("Manifest Main Attribute check " +
590- "failed (" + ATTR_DIGEST + "). " +
591- "Disabled algorithm(s) used: " +
592- getWeakAlgorithms (ATTR_DIGEST ));
590+ if (validEntry ) {
591+ // If there were only weak algorithms entries used, throw an exception.
592+ if (weakAlgs ) {
593+ throw new SignatureException (
594+ "Manifest Main Attribute check "
595+ + "failed (" + ATTR_DIGEST + "). "
596+ + "Disabled algorithm(s) used: "
597+ + getWeakAlgorithms (ATTR_DIGEST ));
598+ }
599+
600+ // If there were only unsupported algorithms entries used, throw an exception.
601+ if (unsupportedAlgs ) {
602+ throw new SignatureException (
603+ "Manifest Main Attribute check failed ("
604+ + ATTR_DIGEST + "). Unsupported algorithm(s) used" );
605+ }
593606 }
594607
595608 // this method returns 'true' if either:
0 commit comments