mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

ludovicp
05.34.2010 61f9c830bc47c574b1d58e017c2007bed788126c
Fix issue #2448.
Improves error messages with password storage schemes when attempting to set a key length greater than allowed by the "Strong juridiction" policy files.
2 files modified
15 ■■■■■ changed files
opends/src/messages/messages/core.properties 3 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/crypto/CryptoManagerImpl.java 12 ●●●●● patch | view | raw | blame | history
opends/src/messages/messages/core.properties
@@ -1834,3 +1834,6 @@
MILD_ERR_RDN_MISSING_ATTRIBUTE_VALUE_727=Unable to decode the provided string "%s" \
 as a relative distinguished name because it does not contain a value \
 for attribute type %s
MILD_ERR_CRYPTOMGR_INVALID_SYMMETRIC_KEY_LENGTH_728=CryptoManager failed to \
 initialize because the specified cipher key length "%d" is beyond the \
 allowed cryptography strength "%d" in jurisdiction policy files
opends/src/server/org/opends/server/crypto/CryptoManagerImpl.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2009 Parametric Technology Corporation (PTC)
 */
package org.opends.server.crypto;
@@ -1526,14 +1526,24 @@
    public SecretKeyEntry(final String algorithm, final int keyLengthBits)
    throws CryptoManagerException {
      KeyGenerator keyGen;
      int maxAllowedKeyLengthBits;
      try {
        keyGen = KeyGenerator.getInstance(algorithm);
        maxAllowedKeyLengthBits = Cipher.getMaxAllowedKeyLength(algorithm);
      }
      catch (NoSuchAlgorithmException ex) {
        throw new CryptoManagerException(
               ERR_CRYPTOMGR_INVALID_SYMMETRIC_KEY_ALGORITHM.get(
                       algorithm, getExceptionMessage(ex)), ex);
      }
      //See if key length is beyond the permissible value.
      if(maxAllowedKeyLengthBits < keyLengthBits)
      {
        throw new CryptoManagerException(
                ERR_CRYPTOMGR_INVALID_SYMMETRIC_KEY_LENGTH.get(keyLengthBits,
                maxAllowedKeyLengthBits));
      }
      keyGen.init(keyLengthBits, secureRandom);
      final byte[] key = keyGen.generateKey().getEncoded();