hg: jdk8/tl/jdk: 6330275: Rework the PaddingTest regression test.

jitesh dundas jbdundas at gmail.com
Fri Jul 22 13:32:41 PDT 2011


Dear Sir.

Thank you for your reply. My apologies for the delay in reply as I get a
chance to work on this in after office hours. I will study this and give you
further findings on the same.

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 10:26 AM, Weijun Wang <weijun.wang at oracle.com>wrote:

> [ Removed several CC ]
>
> Thanks for watching the code changes of JDK 8.
>
> In this test, if the file does not exist, it's certainly a failure. Either
> the test itself is not complete (if pinfile not found), or the first part of
> the test has some error (if cfile not found). In either case, a
> FileNotFoundException will be thrown. The exception is unhandled and the
> test will report a failure. By looking at the stack trace for the exception,
> we will have a basic understanding of where the problem is.
>
> Isn't that what a regression test is for?
>
> There are altogether 3 try keywords here. The first is a normal try-catch,
> and you can see only IllegalBlockSizeException is caught. The other 2 ones
> are of the new try-with-resources JDK 7 feature. See
>
>
> http://download.oracle.com/**javase/tutorial/essential/**
> exceptions/tryResourceClose.**html<http://download.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html>
>
> The color describes the code changes, red means removed, and green newly
> added. You can always click the "file" link to view the final version.
>
> Thanks
> Max
>
>
> On 07/22/2011 12:42 PM, jitesh dundas wrote:
>
>>
>> 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<http://openwetware.org/wiki/Jitesh_Dundas_Lab>
>>
>> Phone:- +91-9004618282
>>
>>
>>
>>
>> On Fri, Jul 22, 2011 at 7:55 AM, <weijun.wang at oracle.com
>> <mailto: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<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: http://mail.openjdk.java.net/pipermail/security-dev/attachments/20110723/3cfe4916/attachment.html 


More information about the security-dev mailing list