APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.crypto.provider

pack-priv final Class KeyProtector

Additional top-level class in compilation unit: CipherForKeyProtector.

extends Object
Class Inheritance
Imports
java.io.IOException, java.security.Key, .PrivateKey, .Provider, .KeyFactory, .MessageDigest, .GeneralSecurityException, .NoSuchAlgorithmException, .UnrecoverableKeyException, .AlgorithmParameters, java.security.spec.InvalidParameterSpecException, .PKCS8EncodedKeySpec, java.util.Arrays, javax.crypto.Cipher, .CipherSpi, .SecretKey, .SealedObject, javax.crypto.spec.*, javax.security.auth.DestroyFailedException, jdk.internal.access.SharedSecrets, sun.security.x509.AlgorithmId, sun.security.util.ObjectIdentifier, .KnownOIDs, .SecurityProperties

This class implements a protection mechanism for private keys. In JCE, we use a stronger protection mechanism than in the JDK, because we can use the Cipher class. Private keys are protected using the JCE mechanism, and are recovered using either the JDK or JCE mechanism, depending on how the key has been protected. This allows us to parse Sun's keystore implementation that ships with JDK 1.2.
Author
Jan Luehe
See Also
JceKeyStore

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int
private static final int
private static final int
private final char[]
private static final int

Constructor Summary

AccessConstructor and Description
pack-priv
KeyProtector(char[] password)

Method Summary

Modifier and TypeMethod and Description
pack-priv byte[]
protect(PrivateKey key)

Protects the given cleartext private key, using the password provided at construction time.

pack-priv Key
private byte[]
recover(byte[] protectedKey)

pack-priv SealedObject
seal(Key key)

Seals the given cleartext key, using the password provided at construction time

pack-priv Key
unseal(SealedObject so, int
Maximum possible length of so. If bigger, must be illegal.
maxLength
)

Unseals the sealed key.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_ITERATION_COUNTback to summary
private static final int DEFAULT_ITERATION_COUNT
DIGEST_LENback to summary
private static final int DIGEST_LEN
ITERATION_COUNTback to summary
private static final int ITERATION_COUNT
MAX_ITERATION_COUNTback to summary
private static final int MAX_ITERATION_COUNT
MIN_ITERATION_COUNTback to summary
private static final int MIN_ITERATION_COUNT
passwordback to summary
private final char[] password
SALT_LENback to summary
private static final int SALT_LEN

Constructor Detail

KeyProtectorback to summary
pack-priv KeyProtector(char[] password)

Method Detail

protectback to summary
pack-priv byte[] protect(PrivateKey key) throws Exception

Protects the given cleartext private key, using the password provided at construction time.

recoverback to summary
pack-priv Key recover(EncryptedPrivateKeyInfo encrInfo) throws UnrecoverableKeyException, NoSuchAlgorithmException
recoverback to summary
private byte[] recover(byte[] protectedKey) throws UnrecoverableKeyException, NoSuchAlgorithmException
sealback to summary
pack-priv SealedObject seal(Key key) throws Exception

Seals the given cleartext key, using the password provided at construction time

unsealback to summary
pack-priv Key unseal(SealedObject so, int maxLength) throws NoSuchAlgorithmException, UnrecoverableKeyException

Unseals the sealed key.

Parameters
maxLength:int

Maximum possible length of so. If bigger, must be illegal.