hg: jdk8/tl/jdk: 6330275: Rework the PaddingTest regression test.
jitesh dundas
jbdundas at gmail.com
Fri Jul 22 04:42:23 UTC 2011
Dear Sir.
Thank you for your reply.
* I was going through the code of your below patch and I thought of maybe
pointing you to this direction:-
*
catch (IllegalBlockSizeException ex) {
- if ((totalInputLen % 8 != 0) && (padding.equals("NoPadding")))
+ try (FileInputStream fin = new FileInputStream(pinfile);
+ BufferedInputStream pin = new BufferedInputStream(fin);
+ FileOutputStream fout = new FileOutputStream(cfile);
+ BufferedOutputStream cout = new BufferedOutputStream(fout)) {
+ cipher.init(Cipher.ENCRYPT_MODE, cipherKey, params);
+
+ while ((len = pin.read(input, 0, bufferLen)) > 0) {
+ totalInputLen += len;
+ byte[] output = cipher.update(input, 0, len);
+ cout.write(output, 0, output.length);
+ }
+
+ len = cipher.getOutputSize(0);
+
+ byte[] out = new byte[len];
+ len = cipher.doFinal(out, 0);
+ cout.write(out, 0, len);
+ }
*+ *
*+ try (FileInputStream fin = new FileInputStream(cfile); *
*+ BufferedInputStream cin = new BufferedInputStream(fin); *
*+ FileOutputStream fout = new FileOutputStream(poutfile); *
*+ BufferedOutputStream pout = new BufferedOutputStream(fout)) { *
+ cipher.init(Cipher.DECRYPT_MODE, cipherKey, params);
+
+ byte[] output = null;
+ while ((len = cin.read(input, 0, bufferLen)) > 0) {
+ output = cipher.update(input, 0, len);
+ pout.write(output, 0, output.length);
+ }
+
+ len = cipher.getOutputSize(0);
+ byte[] out = new byte[len];
+ len = cipher.doFinal(out, 0);
+ pout.write(out, 0, len);
+ }
+
+ diff(pinfile, poutfile);
*+ } catch (IllegalBlockSizeException ex) { *
*+ if ((totalInputLen % 8 != 0) && (padding.equals("NoPadding"))) { *
* *return;
- else {
*I think that this needs a more specific approach to handling exceptions.
What if a file is not found? general exception handling is ok but not a
standard way of doing that.
May i suggest:-
1) if you are using a try-catch, please put specific error handlers in
place. I am sure that you aware of that..
also, is this code commented. i do not know the meaning of each color in the
code. My apologies for the ignorance as am new to this group and still
getting started...
Nice work....
*
Please let me know if you need anything else from my side.
Thanks & Regards,
Jitesh Dundas
http://openwetware.org/wiki/Jitesh_Dundas_Lab
Phone:- +91-9004618282
On Fri, Jul 22, 2011 at 7:55 AM, <weijun.wang at oracle.com> wrote:
> Changeset: c8dbb9e19355
> Author: weijun
> Date: 2011-07-22 10:25 +0800
> URL: http://hg.openjdk.java.net/jdk8/tl/jdk/rev/c8dbb9e19355
>
> 6330275: Rework the PaddingTest regression test.
> Reviewed-by: wetmore, smarks
>
> ! test/ProblemList.txt
> ! test/com/sun/crypto/provider/Cipher/DES/PaddingTest.java
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/security-dev/attachments/20110722/3983e5eb/attachment.htm>
More information about the security-dev
mailing list