Re: RFR: 8002277: Refactor two PBE classes to simplify maintenance [v2]

2022-05-11 Thread Valerie Peng
On Wed, 11 May 2022 04:05:27 GMT, Weijun Wang wrote: >> It's possible, more refactoring would be needed and not necessarily less >> lines of code. With your suggested change, the caller has to explicitly >> destroy the derived key after the cipher.engineInit() call. This would be >> repeated

Re: RFR: 8002277: Refactor two PBE classes to simplify maintenance [v2]

2022-05-10 Thread Weijun Wang
On Wed, 11 May 2022 01:14:00 GMT, Valerie Peng wrote: >> The `core.init(..., cipher)` is actually >> `cipher.init(core.translateKeyAndParams())`. Is it possible we write it this >> way? > > It's possible, more refactoring would be needed and not necessarily less > lines of code. With your

Re: RFR: 8002277: Refactor two PBE classes to simplify maintenance [v2]

2022-05-10 Thread Valerie Peng
On Tue, 10 May 2022 02:27:13 GMT, Weijun Wang wrote: >> Currently, the specified CipherSpi object is one of RC4, RC2, DESede. The >> "else" part is for catching new PKCS12 PBE algorithms support which uses >> other cipher algorithms. >> CipherSpi.engineInit(...) is protected, so that's why we

Re: RFR: 8002277: Refactor two PBE classes to simplify maintenance [v2]

2022-05-10 Thread Valerie Peng
On Tue, 10 May 2022 00:09:16 GMT, Weijun Wang wrote: >> Oh, the comment about "may be 0" is meant toward the >> pbeKey.getInterationCount() call... Hmm, I will make it clearer. > > I see. Another question, shall we reset `salt` and `iCount` at the beginning? > If `params` is null and `key` is

Re: RFR: 8002277: Refactor two PBE classes to simplify maintenance [v2]

2022-05-09 Thread Weijun Wang
On Tue, 10 May 2022 01:22:21 GMT, Valerie Peng wrote: >> src/java.base/share/classes/com/sun/crypto/provider/PKCS12PBECipherCore.java >> line 314: >> >>> 312: } else if (cipher instanceof DESedeCipher >>> tripleDes) { >>> 313:

Re: RFR: 8002277: Refactor two PBE classes to simplify maintenance [v2]

2022-05-09 Thread Valerie Peng
On Mon, 9 May 2022 14:09:28 GMT, Weijun Wang wrote: > It's a pity you have to implement all those `engineXyz` methods in all three > `CipherSpi` implementations here. Is there something simpler? I debated shifting all these "engineXyz" methods into the PKCS12PBECipherCore class and store the

Re: RFR: 8002277: Refactor two PBE classes to simplify maintenance [v2]

2022-05-09 Thread Valerie Peng
On Fri, 6 May 2022 22:24:57 GMT, Weijun Wang wrote: >> Valerie Peng has updated the pull request incrementally with one additional >> commit since the last revision: >> >> update copyright year for PBES2Core.java > >

Re: RFR: 8002277: Refactor two PBE classes to simplify maintenance [v2]

2022-05-09 Thread Weijun Wang
On Mon, 9 May 2022 23:23:05 GMT, Valerie Peng wrote: >> src/java.base/share/classes/com/sun/crypto/provider/PBES2Core.java line 229: >> >>> 227: if (key instanceof javax.crypto.interfaces.PBEKey >>> pbeKey) { >>> 228: salt = check(pbeKey.getSalt()); // may

Re: RFR: 8002277: Refactor two PBE classes to simplify maintenance [v2]

2022-05-09 Thread Valerie Peng
On Fri, 6 May 2022 22:22:47 GMT, Weijun Wang wrote: >> Valerie Peng has updated the pull request incrementally with one additional >> commit since the last revision: >> >> update copyright year for PBES2Core.java > >

Re: RFR: 8002277: Refactor two PBE classes to simplify maintenance [v2]

2022-05-09 Thread Valerie Peng
On Fri, 6 May 2022 22:26:31 GMT, Weijun Wang wrote: >> Valerie Peng has updated the pull request incrementally with one additional >> commit since the last revision: >> >> update copyright year for PBES2Core.java > >

Re: RFR: 8002277: Refactor two PBE classes to simplify maintenance [v2]

2022-05-09 Thread Valerie Peng
On Fri, 6 May 2022 22:20:32 GMT, Weijun Wang wrote: >> Valerie Peng has updated the pull request incrementally with one additional >> commit since the last revision: >> >> update copyright year for PBES2Core.java > >

Re: RFR: 8002277: Refactor two PBE classes to simplify maintenance [v2]

2022-05-09 Thread Valerie Peng
On Mon, 9 May 2022 14:00:58 GMT, Weijun Wang wrote: >> Valerie Peng has updated the pull request incrementally with one additional >> commit since the last revision: >> >> update copyright year for PBES2Core.java > > src/java.base/share/classes/com/sun/crypto/provider/PBES2Core.java line

Re: RFR: 8002277: Refactor two PBE classes to simplify maintenance [v2]

2022-05-09 Thread Weijun Wang
On Thu, 5 May 2022 19:38:06 GMT, Valerie Peng wrote: >> This change refactors the PBES2Core and PKCS12PBECipherCore classes in >> SunJCE provider as requested in the bug record. Functionality should remain >> the same with a clearer and simplified code/control flow with less lines of >> code.

Re: RFR: 8002277: Refactor two PBE classes to simplify maintenance [v2]

2022-05-05 Thread Valerie Peng
> This change refactors the PBES2Core and PKCS12PBECipherCore classes in SunJCE > provider as requested in the bug record. Functionality should remain the same > with a clearer and simplified code/control flow with less lines of code. > This should improve readability and maintenance. I