On Tue, 19 Oct 2021 14:34:25 GMT, Weijun Wang <wei...@openjdk.org> wrote:
>> This fix improves the exception message to better indicate when the key (and >> not the signature algorithm) is restricted. This change also includes a few >> other improvements: >> >> - The constraints checking in `AlgorithmChecker.check()` has been improved. >> If the `AlgorithmConstraints` are an instance of >> `DisabledAlgorithmConstraints`, the internal `permits` methods are always >> called; otherwise the public `permits` methods are called. This makes the >> code easier to understand, and fixes at least one case where duplicate >> checks were being done. >> >> - The above change caused some of the exception messages to be slightly >> different, so some tests that checked the error messages had to be updated >> to reflect that. >> >> - AlgorithmDecomposer now stores the canonical algorithm names in a Map, >> which fixed a bug where "RSASSA-PSS" was not being restricted properly. > > src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java line > 48: > >> 46: "SHA-384", "SHA384", "SHA-512", "SHA512", "SHA-512/224", >> 47: "SHA512/224", "SHA-512/256", "SHA512/256"); >> 48: > > Do you want to support the "SHA" -> "SHA1" mapping? These should be standard digest names as specified by the disabled algorithm security property syntax. SHA is an alias. > src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java line > 196: > >> 194: static String canonicalName(String algorithm) { >> 195: return CANONICAL_NAME.getOrDefault(algorithm, algorithm); >> 196: } > > I'm not sure if `canonicalName` is good. Normally, we say "SHA-1" is the > standard name but this method changes it to "SHA1". Right, it's really just about using consistent message digest names so that it can match for example, "SHA-1" and also "SHA1withRSA". I'll change the name to something else. ------------- PR: https://git.openjdk.java.net/jdk/pull/5928