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

david_page
09.47.2007 ef9cb7de7d05217a8deb9507f067eebf99b37249
issue 466 (partial)
Remove "SECRET_KEY" from ds-cfg-symmetric-key attribute syntax because Cipher.SECRET_KEY is implied by symmetric key.

For example,
ds-cfg-symmetric-key: EE16497A0BC56D04C0A5C68FC8236247:RSA/ECB/OAEPWITHSHA-1ANDMGF1PADDING:AES/CBC/PKCS5Padding:SECRET_KEY:7F23DB3450182583EC91F7024E6...
is now
ds-cfg-symmetric-key: EE16497A0BC56D04C0A5C68FC8236247:RSA/ECB/OAEPWITHSHA-1ANDMGF1PADDING:AES/CBC/PKCS5Padding:7F23DB3450182583EC91F7024E6...
1 files modified
29 ■■■■ changed files
opends/src/server/org/opends/server/types/CryptoManager.java 29 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/types/CryptoManager.java
@@ -688,7 +688,6 @@
   * wrappingTransformation
   *                   ::= e.g., RSA/ECB/OAEPWITHSHA-1ANDMGF1PADDING
   * wrappedKeyAlgorithm ::= e.g., DESede
   * wrappedKeyType ::= SECRET_KEY
   * hexifiedwrappedKey ::= 0123456789abcdef01...
   * </pre>
   *
@@ -746,8 +745,6 @@
    symmetricKeyAttribute.append(":");
    symmetricKeyAttribute.append(secretKey.getAlgorithm());
    symmetricKeyAttribute.append(":");
    symmetricKeyAttribute.append("SECRET_KEY");
    symmetricKeyAttribute.append(":");
    symmetricKeyAttribute.append(wrappedKeyElement);
    return symmetricKeyAttribute.toString();
@@ -762,7 +759,7 @@
   * ds-cfg-symmetric-key-attribute value.
   * @return A SecretKey object instantiated with the key data,
   * algorithm, and Ciper.SECRET_KEY type, or {@code null} if the
   * supplied symmetricKeyAttribute was encoded at another instance.
   * supplied symmetricKeyAttribute was encoded for another instance.
   * @throws CryptoManagerException If there is a problem decomposing
   * the supplied attribute value or unwrapping the encoded key.
   */
@@ -771,7 +768,7 @@
          throws CryptoManagerException {
    // Initial decomposition.
    String[] elements = symmetricKeyAttribute.split(":", 0);
    if (5 != elements.length) {
    if (4 != elements.length) {
      throw new CryptoManagerException(
         ERR_CRYPTOMGR_DECODE_SYMMETRIC_KEY_ATTRIBUTE_FIELD_COUNT.get(
                  symmetricKeyAttribute));
@@ -781,7 +778,6 @@
    String wrappingKeyIDElement;
    String wrappingTransformationElement;
    String wrappedKeyAlgorithmElement;
    int wrappedKeyTypeElement;
    byte[] wrappedKeyCipherTextElement;
    String fieldName = null;
    try {
@@ -791,26 +787,9 @@
      wrappingTransformationElement = elements[1];
      fieldName = "wrapped key algorithm";
      wrappedKeyAlgorithmElement = elements[2];
      fieldName = "wrapped key type";
      final String rawKeyType = elements[3];
      if ("SECRET_KEY".equals(rawKeyType)) {
        wrappedKeyTypeElement = Cipher.SECRET_KEY;
      }
      else if ("PRIVATE_KEY".equals(rawKeyType)) {
        wrappedKeyTypeElement = Cipher.PRIVATE_KEY;
      }
      else if ("PUBLIC_KEY".equals(rawKeyType)) {
        wrappedKeyTypeElement = Cipher.PUBLIC_KEY;
      }
      else {
        throw new ParseException(
                // TODO: i18n
                Message.raw("Invalid type \"%s\".",
                        rawKeyType).toString(), 0);
      }
      fieldName = "wrapped key data";
      wrappedKeyCipherTextElement
              = StaticUtils.hexStringToByteArray(elements[4]);
              = StaticUtils.hexStringToByteArray(elements[3]);
    }
    catch (ParseException ex) {
      if (debugEnabled()) {
@@ -853,7 +832,7 @@
      secretKey = (SecretKey)unwrapper.unwrap(
              wrappedKeyCipherTextElement,
              wrappedKeyAlgorithmElement,
              wrappedKeyTypeElement);
              Cipher.SECRET_KEY);
    } catch(GeneralSecurityException ex) {
      if (debugEnabled()) {
        TRACER.debugCaught(DebugLogLevel.ERROR, ex);