Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-06-08 Thread Valerie Peng
Hi Audrey, Thanks for the comment, we can apply your suggestion in the next update of KnownOIDs class. Valerie On 6/6/2020 9:03 AM, Andrey Turbanov wrote: List.of(KnownOIDs.values()).forEach(o -> { register(o); }); I wonder if this 'forEach' is better than plain old 'for' in some ways?

[15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-06-06 Thread Andrey Turbanov
>List.of(KnownOIDs.values()).forEach(o -> { >register(o); >}); I wonder if this 'forEach' is better than plain old 'for' in some ways? ``` for (KnownOIDs oid : KnownOIDs.values()) { register(oid); } ``` I think a variant with plain 'for' generates a bit less garbage. Andrey Turbanov

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-18 Thread Weijun Wang
Still looks fine to me. Thanks, Max > On May 19, 2020, at 5:36 AM, Valerie Peng wrote: > > Updated again due to the merge with Tony's EdDSA change: > > http://cr.openjdk.java.net/~valeriep/8242151/webrev.06 > > Added Ed25519 and Ed448 to KnownOIDs, and rest are just adjustments >

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-18 Thread Valerie Peng
Updated again due to the merge with Tony's EdDSA change: http://cr.openjdk.java.net/~valeriep/8242151/webrev.06 Added Ed25519 and Ed448 to KnownOIDs, and rest are just adjustments accordingly. Touched: src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAParameters.java

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-18 Thread Valerie Peng
Great, thanks much for the thorough review~ Valerie On 5/15/2020 8:57 PM, Weijun Wang wrote: Well done. Everything looks fine to me. --Max On May 16, 2020, at 5:47 AM, Valerie Peng wrote: Hi Max, I have updated the webrev (http://cr.openjdk.java.net/~valeriep/8242151/webrev.05/) to

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-15 Thread Weijun Wang
Well done. Everything looks fine to me. --Max > On May 16, 2020, at 5:47 AM, Valerie Peng wrote: > > Hi Max, > > I have updated the webrev > (http://cr.openjdk.java.net/~valeriep/8242151/webrev.05/) to address your > suggestion below. Touched classes are NamedCurve, CurveDB, >

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-15 Thread Valerie Peng
Hi Max, I have updated the webrev (http://cr.openjdk.java.net/~valeriep/8242151/webrev.05/) to address your suggestion below. Touched classes are NamedCurve, CurveDB, ConstraintsParameters, and SunEC. The result of using the single method looks pretty good - clean and shorter code. :)

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-13 Thread Weijun Wang
> On May 14, 2020, at 3:17 AM, Valerie Peng wrote: > > Hi Max, > > Thanks for review~ > > Webrev is updated accordingly for your comments: > http://cr.openjdk.java.net/~valeriep/8242151/webrev.04/ > > Please find replies inline below: > > On 5/11/2020 9:24 PM, Weijun Wang wrote: >> Some

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-13 Thread Valerie Peng
Hi Max, Thanks for review~ Webrev is updated accordingly for your comments: http://cr.openjdk.java.net/~valeriep/8242151/webrev.04/ Please find replies inline below: On 5/11/2020 9:24 PM, Weijun Wang wrote: Some files have trailing spaces. Yes, I generally check for white spaces before

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-11 Thread Weijun Wang
Some files have trailing spaces. KnownOIDs.java: - Is there an order for the fields? I see they are grouped but now always ordered. - Unused "import java.security.Provider;" - 1.3.14.3.2.29 used to be an alias for SHA1withRSA, now it's not. Is this intended? - s/_/-/ in process() is now

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-11 Thread Valerie Peng
Thanks for filing the bug for PBES2Parameters class. Webrev for 8242151 is updated at: http://cr.openjdk.java.net/~valeriep/8242151/webrev.03/ It addresses: - added KnownOIDs for CurveDB class - updated the KDF parsing code in PBES2Parameters class to match existing behavior - removed the

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-06 Thread Weijun Wang
> > It seems that existing impl of PBES2Parameters class only enforces that the > KDF algo is one of the HmacSHAxxx. But it does not throw exception if the > instance is requested with "PBEWithHmacSHA256AndAES_256" and then initialized > with DER encoding containing

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-06 Thread Valerie Peng
Hi Max, Thanks for the review, I find your comments very useful. Please find responses inline. On 5/6/2020 5:48 AM, Weijun Wang wrote: - PBES2Parameters.java: In parseKDF(), any OID can be accepted as kdfAlgo, wonder if it would lead to unexpected result: jshell> var a =

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-06 Thread Valerie Peng
Sure, I can include this in. Will address in webrev.03. Thanks, Valerie On 5/5/2020 3:33 AM, Weijun Wang wrote: I am playing with keytool + BouncyCastle and generate a key pair using the sigalg "SHA3-256WITHECDSA", and `keytool -list` cannot show the signature name. So I tried 2 changes in

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-06 Thread Weijun Wang
- PBES2Parameters.java: In parseKDF(), any OID can be accepted as kdfAlgo, wonder if it would lead to unexpected result: jshell> var a = AlgorithmParameters.getInstance("PBEWithHmacSHA256AndAES_256") jshell> a.init(new PBEParameterSpec("hello".getBytes(), 100, new

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-05 Thread Valerie Peng
Hi Max, Webrev has been updated, http://cr.openjdk.java.net/~valeriep/8242151/webrev.02/. Major changes are: - Moved oidTable caching from AlgorithmId class to ObjectIdentifier class. Made ObjectIdentifier constructor private and callers have to use the of(String) method which always check

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-05 Thread Valerie Peng
Hi Max, Thanks for the comments, they are very helpful. I should have webrev.02 ready in a bit. Please find comments below in line. On 5/1/2020 2:45 AM, Weijun Wang wrote: ObjectIdentifier.java - Have you thought about storing the ObjectIdentifier object somewhere?

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-05 Thread Weijun Wang
I am playing with keytool + BouncyCastle and generate a key pair using the sigalg "SHA3-256WITHECDSA", and `keytool -list` cannot show the signature name. So I tried 2 changes in AlgorithmId.java: 1. add both the name->oid and oid->name mapping inside collectOIDAliases() for 3rd party

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-04 Thread Weijun Wang
Do you want to add OIDs in CurveDB into KnownOIDs as well? Thanks, Max

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-01 Thread Valerie Peng
Hmm, I took a shot at keytool/Main.java and used KnownOIDs.findMatch(...) to construct the oid. They will be included in webrev.02. Thanks, Valerie On 5/1/2020 3:29 PM, Valerie Peng wrote: These two BASE ones are simply used to get rid of the hardcoded oid string code in

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-01 Thread Valerie Peng
These two BASE ones are simply used to get rid of the hardcoded oid string code in keytool/Main.java. I can remove them (in webrev.02) and maybe you can update keytool/Main.java later to use the right KnownOIDs enum for oid construction? There are a few places in keytool/Main.java which

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-01 Thread Weijun Wang
One more thing: In KnownOIDs.java, I found these 2 lines: PKIX_KP_BASE("1.3.6.1.5.5.7.3."), PKIX_OCSP_BASE("1.3.6.1.5.5.7.48."), IMHO, they should not belong here, at least, we should remove the dot at the end and make them real OIDs. I was testing the ObjectIdentifier generation and

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-05-01 Thread Weijun Wang
ObjectIdentifier.java - Have you thought about storing the ObjectIdentifier object somewhere? ObjectIdentifier.of() creates a new object each time and the conversion of string to byte[] might be a performance issue. We used to have a lot of ObjectIdentifier objects in

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-04-30 Thread Weijun Wang
> On Apr 30, 2020, at 9:55 PM, Weijun Wang wrote: > > Sorry, it's been a busy day on something else and I haven't looked at your > webrev.01 yet. Will look at it tomorrow. > >> On Apr 30, 2020, at 8:15 AM, Valerie Peng wrote: >> >> >> If you look at the original SunJCE impl, it also did

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-04-30 Thread Weijun Wang
Sorry, it's been a busy day on something else and I haven't looked at your webrev.01 yet. Will look at it tomorrow. > On Apr 30, 2020, at 8:15 AM, Valerie Peng wrote: > > > If you look at the original SunJCE impl, it also did not register oid for RC4 > cipher. So, that's why I didn't include

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-04-29 Thread Valerie Peng
If you look at the original SunJCE impl, it also did not register oid for RC4 cipher. So, that's why I didn't include RC4 oid in SecurityProviderConstants in the aliases for RC4. If I recall correctly, "RC4" is the algorithm name, however, due to some patent(?) concern, non-RSA vendors

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-04-29 Thread Valerie Peng
Hi Max, I believe most of your comments (except the two below) in this email should already be addressed in webrev.01. I caught them by looking at the "skipped" debug output. Can we add some logic to detect this? For example, for those nonpreferred OIDs, use a special constructor? Hmm, ok,

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-04-29 Thread Valerie Peng
toString() returns the standard name which the enum corresponds to. Yes, I agree that it's better to use a dedicated method name for this. Will address this in webrev.02. Valerie On 4/28/2020 3:37 AM, Weijun Wang wrote: Is OidString::toString really used anywhere? If so, I suggest we

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-04-29 Thread Valerie Peng
Hi Max, Here is the updated webrev http://cr.openjdk.java.net/~valeriep/8242151/webrev.01/ which should address your earlier comments (see below) - OidString renamed to KnownOIDs and updated the aliasing handling code in both KnownOIDs and SecurityProviderConstants classes - Removed

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-04-28 Thread Weijun Wang
Is OidString::toString really used anywhere? If so, I suggest we create a special method for it so it's easy to use an IDE to find out all usages. Finding toString returns usages of Object::toString and it's everywhere. --Max > On Apr 24, 2020, at 7:11 AM, Valerie Peng wrote: > > Hi Max, >

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-04-28 Thread Weijun Wang
I found two algorithm names in a very twisted relation, in SecurityProviderConstants.java: store("ARCFOUR", "RC4"); and in OidString.java: RC4("1.2.840.113549.3.4", "ARCFOUR") So each is the other's alias, and because of this, Cipher.ARCFOUR does not have OID aliases. I can see

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-04-28 Thread Weijun Wang
Where is the following OID used RSAEncryption("1.2.840.113549.1.1.1", "RSA"), // in RSA Cipher I only found in RSAUtil.java: case RSA: oid = AlgorithmId.RSAEncryption_oid; break; What if we do not give it a different stdName? Or,

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-04-27 Thread Weijun Wang
> On Apr 28, 2020, at 6:19 AM, Valerie Peng wrote: > > Hi Max, > > Thanks for reviewing this~ Please find my replies inline. > > On 4/25/2020 3:28 AM, Weijun Wang wrote: >> OidString.java >> == >> >> 1. ExtendedKeyUsage names: used to be "serverAuth", now "ServerAuth". First

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-04-27 Thread Weijun Wang
> On Apr 28, 2020, at 8:08 AM, Valerie Peng wrote: > > Yes, it can be quite a confusing scenario. Some algorithms have multiple oids > (say X) and multiple algorithm names (say Y). We need to be able to handle > all of them (X+Y). However, the separation of alias definition for OidString >

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-04-27 Thread Valerie Peng
Yes, it can be quite a confusing scenario. Some algorithms have multiple oids (say X) and multiple algorithm names (say Y). We need to be able to handle all of them (X+Y). However, the separation of alias definition for OidString and SecurityProviderConstants are intentional and I have them

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-04-27 Thread Valerie Peng
Hi Max, Thanks for reviewing this~ Please find my replies inline. On 4/25/2020 3:28 AM, Weijun Wang wrote: OidString.java == 1. ExtendedKeyUsage names: used to be "serverAuth", now "ServerAuth". First letter capitalized, is this necessary? Yes, I made a change here. Using

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-04-26 Thread Weijun Wang
I see this change in Provider$Service::toString output of SHA1withRSA: SunRsaSign: Signature.SHA1withRSA -> sun.security.rsa.RSASignature$SHA1withRSA - aliases: [1.2.840.113549.1.1.5, 1.3.14.3.2.29, OID.1.2.840.113549.1.1.5] + aliases: [1.2.840.113549.1.1.5, OID.1.2.840.113549.1.1.5]

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-04-25 Thread Weijun Wang
And I am confused by aliases in SecurityProviderConstants, together with the duplicated stdName in OidString, it seems to show that one OID could have multiple names, and one name could have multiple OIDs. Can we consolidate aliases inside OidString also? Also, looking at the store() calls in

Re: [15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-04-25 Thread Weijun Wang
OidString.java == 1. ExtendedKeyUsage names: used to be "serverAuth", now "ServerAuth". First letter capitalized, is this necessary? 2. Can we move name2oidStr() from OidString to AlgorithmId? The computeOidTable process looks like an alien. 3. Two questions on the following

[15] RFR JDK-8242151 Improve OID mapping and reuse among JDK security providers for aliases registration

2020-04-23 Thread Valerie Peng
Hi Max, Would you have time to review this change? The current webrev attempts to cover all security classes where hard-coded oid strings and consolidate these known oid string values into a single enum type. The changes are quite extensive, I can trim back and only cover the provider