You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by sm...@apache.org on 2006/04/05 13:15:39 UTC
svn commit: r391585 - in
/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src:
main/java/javax/crypto/spec/PBEKeySpec.java
test/java/javax/crypto/spec/PBEKeySpecTest.java
Author: smishura
Date: Wed Apr 5 04:15:36 2006
New Revision: 391585
URL: http://svn.apache.org/viewcvs?rev=391585&view=rev
Log:
Apply patch HARMONY-249 (javax.crypto.spec.PBEKeySpec constructors exception behaviour doesn't match reference implementation)
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/PBEKeySpec.java
incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/javax/crypto/spec/PBEKeySpecTest.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/PBEKeySpec.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/PBEKeySpec.java?rev=391585&r1=391584&r2=391585&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/PBEKeySpec.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/PBEKeySpec.java Wed Apr 5 04:15:36 2006
@@ -60,11 +60,12 @@
if (salt.length == 0) {
throw new IllegalArgumentException("salt is empty");
}
- if (iterationCount < 0) {
- throw new IllegalArgumentException("iterationCount < 0");
+ if (iterationCount <= 0) {
+ throw new IllegalArgumentException(
+ "iterationCount is not positive.");
}
- if (keyLength < 0) {
- throw new IllegalArgumentException("keyLength < 0");
+ if (keyLength <= 0) {
+ throw new IllegalArgumentException("keyLength is not positive.");
}
if (password == null) {
@@ -89,8 +90,9 @@
if (salt.length == 0) {
throw new IllegalArgumentException("salt is empty");
}
- if (iterationCount < 0) {
- throw new IllegalArgumentException("iterationCount < 0");
+ if (iterationCount <= 0) {
+ throw new IllegalArgumentException(
+ "iterationCount is not positive.");
}
if (password == null) {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/javax/crypto/spec/PBEKeySpecTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/javax/crypto/spec/PBEKeySpecTest.java?rev=391585&r1=391584&r2=391585&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/javax/crypto/spec/PBEKeySpecTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/javax/crypto/spec/PBEKeySpecTest.java Wed Apr 5 04:15:36 2006
@@ -111,6 +111,22 @@
} catch (IllegalArgumentException e) {
}
+ try {
+ PBEKeySpec pbeks = new PBEKeySpec(password, salt,
+ 0, keyLength);
+ fail("An IllegalArgumentException should be thrown "
+ + "in the case of zero iterationCount.");
+ } catch (IllegalArgumentException e) {
+ }
+
+ try {
+ PBEKeySpec pbeks = new PBEKeySpec(password, salt,
+ iterationCount, 0);
+ fail("An IllegalArgumentException should be thrown "
+ + "in the case of zero keyLength.");
+ } catch (IllegalArgumentException e) {
+ }
+
PBEKeySpec pbeks = new PBEKeySpec(password, salt,
iterationCount, keyLength);
password[0] ++;
@@ -165,6 +181,13 @@
PBEKeySpec pbeks = new PBEKeySpec(password, salt, -1);
fail("An IllegalArgumentException should be thrown "
+ "in the case of negative iterationCount.");
+ } catch (IllegalArgumentException e) {
+ }
+
+ try {
+ PBEKeySpec pbeks = new PBEKeySpec(password, salt, 0);
+ fail("An IllegalArgumentException should be thrown "
+ + "in the case of zero iterationCount.");
} catch (IllegalArgumentException e) {
}