You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2009/10/07 12:50:08 UTC
svn commit: r822652 - in /harmony/enhanced/classlib/trunk/modules/crypto/src:
main/java/javax/crypto/spec/SecretKeySpec.java
test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java
Author: hindessm
Date: Wed Oct 7 10:50:07 2009
New Revision: 822652
URL: http://svn.apache.org/viewvc?rev=822652&view=rev
Log:
Fix for SecretKeySpec from "[#HARMONY-6347] crypto bugfixes" modified to
fix exception message to something less confusing and added a regression
test.
Also fixed some confusing failure messages in tests adjacent to the new
regression test.
Modified:
harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/SecretKeySpec.java
harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java
Modified: harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/SecretKeySpec.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/SecretKeySpec.java?rev=822652&r1=822651&r2=822652&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/SecretKeySpec.java (original)
+++ harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/SecretKeySpec.java Wed Oct 7 10:50:07 2009
@@ -103,6 +103,9 @@
if (len < 0) {
throw new ArrayIndexOutOfBoundsException(Messages.getString("crypto.36")); //$NON-NLS-1$
}
+ if (offset < 0) {
+ throw new ArrayIndexOutOfBoundsException(Messages.getString("crypto.33")); //$NON-NLS-1$
+ }
if ((key.length - offset < len)) {
throw new IllegalArgumentException(Messages.getString("crypto.37")); //$NON-NLS-1$
}
Modified: harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java?rev=822652&r1=822651&r2=822652&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java Wed Oct 7 10:50:07 2009
@@ -109,14 +109,24 @@
try {
new SecretKeySpec(key, offset, key.length, algorithm);
fail("An IllegalArgumentException should be thrown "
- + "in the case of null key.");
+ + "when offset and len specify an invalid chunk of key.");
} catch (IllegalArgumentException e) {
}
try {
new SecretKeySpec(key, -1, key.length, algorithm);
- fail("An IllegalArgumentException should be thrown "
- + "in the case of null key.");
+ fail("An ArrayIndexOutOfBoundsxception should be thrown "
+ + "in the case of negative offset.");
+ } catch (IllegalArgumentException e) {
+ fail("Not expected IllegalArgumentException was thrown.");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ }
+
+ // Regression test for HARMONY-6347
+ try {
+ new SecretKeySpec(key, -1, key.length+2, algorithm);
+ fail("An ArrayIndexOutOfBoundsxception should be thrown "
+ + "in the case of negative offset.");
} catch (IllegalArgumentException e) {
fail("Not expected IllegalArgumentException was thrown.");
} catch (ArrayIndexOutOfBoundsException e) {