Draft API for JEP-166: Overhaul JKS-JCEKS-PKCS12 Keystores (original) (raw)

Vincent Ryan vincent.x.ryan at oracle.com
Mon Jan 14 14:31:57 UTC 2013


Hello all,

I am seeking feedback on a draft of the public APIs that I believe are needed to address the features described in JEP-166 [1].

JEP-166 is targeted to JDK 8 Milestone 6 so I am keen to get the bulk of these API changes integrated into the last remaining build of M6: Build 75. Note that there will be ample time in Milestone 7 to make API modifications and improvements as necessary.

I have divided the API changes into 5 main sections:

  1. To support metadata for keystore entries
  2. To support stronger entry protection algorithms
  3. To support the destruction of sensitive information associated with cryptographic keys
  4. To support the logical grouping of keystores and entries
  5. To support the secure storage of passwords

To speed up the process I am providing the javadoc specification now and will follow-up with a more complete webrev.

Your comments are welcome. Thanks.


[1] http://openjdk.java.net/jeps/166

=========================================== 1. To support metadata for keystore entries

This involves adding a new nested interface to the java.security.KeyStore.Entry interface along with a new getAttributes method. In addition a new constructor that takes a set of attributes is defined for each of the concrete classes that implement KeyStore.Entry. Finally a new PKCS12Attribute if defined to specifically support attributes in PKCS12 keystores.


New interface in the java.security.KeyStore.Entry interface

/**

}


New method in the java.security.KeyStore.Entry interface

/**


New constructor for the java.security.KeyStore.SecretKeyEntry class

/**


New constructor for the java.security.KeyStore.PrivateKeyEntry class

/**


New constructor for java.security.KeyStore.TrustedCertificateEntry class

/**


New class in the java.security package

/**

/**

/**

/**

/**

}

================================================== 2. To support stronger entry protection algorithms

This involves enhancing the KeyStore.PasswordProtection class to enable a password-based encryption algorithm (PBE) to be specified along with any necessary parameters. The PBE algorithm is used to encrypt a keystore entry containing a private key or a secret key when the KeyStore.setEntry or KeyStore.seyKeyEntry methods are used.


New methods in the java.security.KeyStore.PasswordProtection class

/**

/**

/**

========================================================== 3. To support the destruction of sensitive key information

This involves defining default method implementations for the destroy and isDestroyed methods of the javax.security.auth.Destroyable interface. And modifying the java.security.PrivateKey and javax.crypto.SecretKey interfaces to extend Destroyable.


Changes to methods in the javax.security.auth.Destroyable interface

 /**
  * Destroys this {@code Object}.
  * Sensitive information associated with this {@code Object} is
  * destroyed or cleared. Subsequent calls to methods on this
  * {@code Object} will result in an {@code IllegalStateException}
  * being thrown.
  * <p>
  * The default implementation throws {@code DestroyFailedException}.
  *
  * @exception DestroyFailedException if the destroy operation fails.
  * @exception SecurityException if the caller does not have
  *     permission to destroy this {@code Object}.
  *
  * @since 1.8
  */
 public default void destroy() throws DestroyFailedException { ... };

 /**
  * Determines if this {@code SecretKey} has been destroyed.
  * <p>
  * The default implementation returns false.
  *
  * @return true if this {@code SecretKey} has been destroyed,
  *     false otherwise.
  *
  * @since 1.8
  */
 public default boolean isDestroyed() { ... };

Changed class inheritance for the java.security.PrivateKey interface

/**

public interface PrivateKey extends Key, Destroyable { ... }


Changed class inheritance for the javax.crypto.SecretKey interface

/**

=========================================================== 4. To support the logical grouping of keystores and entries

This involves defining an implementation of the KeyStore.LoadStoreParameter interface that conveys the configuration data that defines a keystore domain to the load and store methods of KeyStore.


New class in the java.security.KeyStore class

/**

}

============================================= 5. To support the secure storage of passwords

This involves introducing a new command option for the keytool utility that accepts a password and stores it securely as a secret key.


Addition to the keytool manpage for the new command: -importpassword

 -importpassword {-alias alias} [-keypass keypass]
     {-storetype storetype}
     {-keystore keystore} [-storepass storepass]
     {-providerClass provider_class_name {-providerArg provider_arg}}
     {-v} {-protected} {-Jjavaoption}

 Imports a passphrase and stores it in a new KeyStore.SecretKeyEntry
 identified by alias.

 The passphrase may be supplied via the standard input stream;
 otherwise the user is prompted for it.
 keypass is a password used to protect the imported passphrase. If no
 password is provided, the user is prompted for it. If you press
 RETURN at the prompt, the key password is set to the same password
 as that used for the keystore. keypass must be at least 6
 characters long.


More information about the security-dev mailing list