RFR: 8268427: Improve AlgorithmConstraints:checkAlgorithm performance [v2]

Dongbo He dongbohe at openjdk.java.net
Fri Jun 18 04:59:26 UTC 2021


On Fri, 18 Jun 2021 04:14:09 GMT, Xue-Lei Andrew Fan <xuelei at openjdk.org> wrote:

>> [checkAlgorithm](https://github.com/openjdk/jdk/blob/a051e735cda0d5ee5cb6ce0738aa549a7319a28c/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java#L94) check whether the item is in the collection by ignoring case. If the item in the HashSet is case-sensitive, the method will lose its original algorithmic logic, but will retain it by using a ` new TreeSet<>(String.CASE_INSENSITIVE_ORDER);`
>> 
>> Can we use case sensitivity in checkAlgorithm to check an algorithm?
>
> The checkAlgorithm is using equalsIgnoreCase(), so it is safe for it.  My concern is mainly about the keywords, like "keySize" used the property, not really the algorithm name.  It is good to keep the current case sensitive checking behavior unchanged.

Hi, Xuelei, thank you for your comments. I may not express it clearly, let me clarify. My concern is that if we use the HashSet:contains method to check whether an item is in the hash set, we cannot use equalsIgnoreCase(), so I used `new TreeSet<>(String.CASE_INSENSITIVE_ORDER)`  that can support equalsIgnoreCase().

According to my understanding, the current checkAlgorithm is not case sensitive, because it ignores the case of the item being checked. Looking forward to your suggestions。

-------------

PR: https://git.openjdk.java.net/jdk/pull/4424



More information about the security-dev mailing list