Index: modules/security/src/common/javasrc/javax/crypto/spec/PBEKeySpec.java =================================================================== --- modules/security/src/common/javasrc/javax/crypto/spec/PBEKeySpec.java.orig 2006-03-20 18:38:37.000000000 +0000 +++ modules/security/src/common/javasrc/javax/crypto/spec/PBEKeySpec.java 2006-03-24 14:30:20.000000000 +0000 @@ -62,7 +62,7 @@ if (salt == null) { throw NULLSALT_EXC; } - if ((salt.length == 0) || (iterationCount < 0) || (keyLength < 0)) { + if ((salt.length == 0) || (iterationCount <= 0) || (keyLength <= 0)) { throw BADPARAMS_EXC; //throw new IllegalArgumentException( // "salt is empty or iterationCount < 0 or keyLength < 0"); @@ -86,7 +86,7 @@ if (salt == null) { throw NULLSALT_EXC; } - if ((salt.length == 0) || (iterationCount < 0)) { + if ((salt.length == 0) || (iterationCount <= 0)) { throw BADPARAMS_EXC; //throw new IllegalArgumentException( // "salt is empty or iterationCount < 0"); Index: modules/security/test/common/unit/javax/crypto/spec/PBEKeySpecTest.java =================================================================== --- modules/security/test/common/unit/javax/crypto/spec/PBEKeySpecTest.java.orig 2006-03-20 18:37:46.000000000 +0000 +++ modules/security/test/common/unit/javax/crypto/spec/PBEKeySpecTest.java 2006-03-24 14:28:45.000000000 +0000 @@ -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] ++; @@ -167,6 +183,12 @@ + "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) { + } PBEKeySpec pbeks = new PBEKeySpec(password, salt, iterationCount); password[0] ++;