|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.dstc.security.keymanage.SSLeayEncryptedPrivateKey
This class encrypts/decrypts a PrivateKey to/from the the proprietary encryption format used in SSLeay. The encrypted keys are stored in the ASCII format
-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,ivBytes Base 64 encoding goes here -----END RSA PRIVATE KEY-----Here, ivBytes is the hexadecimal representation of the Initialization Vector used in the encryption process.
Typical usage of this class would be the following:
To encrypt the PrivateKey object privateKey using
the password "myPassword" and store it in a file with the above format,
SSLeayEncryptedPrivateKey encKey =
new SSLeayEncryptedPrivateKey(privateKey);
FileOutputStream fos = new FileOutputStream(fileName);
encKey.encrypt("myPassword".toCharArray());
fos.write(encKey.getEncoded());
Conversely, to decrypt the encrypted private key stored in the file
"fileName",
FileInputStream fis = new FileInputStream("fileName");
SSLeayEncryptedPrivateKey encKey = new SSLeayEncryptedPrivateKey(fis);
encKey.decrypt("myPassword".toCharArray());
PrivateKey privateKey = encKey.getPrivateKey();
| Constructor Summary | |
SSLeayEncryptedPrivateKey(byte[] encoding)
Construct an SSLeayEncryptedPrivateKey object from
a byte array containing the (base-64 encoded) encrypted private key. |
|
SSLeayEncryptedPrivateKey(InputStream is)
Construct an SSLeayEncryptedPrivateKey object from
an InputStream containing the (base-64 encoded)
encrypted private key. |
|
SSLeayEncryptedPrivateKey(SecureRandom rand,
PrivateKey priv)
Construct an SSLeayEncryptedPrivateKey object from
a PrivateKey |
|
| Method Summary | |
void |
decrypt(char[] pass)
Decrypts the SSLeayEncryptedPrivateKey object using
the given password. |
void |
encrypt(char[] pass)
Encrypts the SSLeayEncryptedPrivateKey object using
the given password. |
byte[] |
getEncoded()
Returns the Base64-encoding of the SSLeayEncryptedPrivateKey
. |
PrivateKey |
getPrivateKey()
Returns the PrivateKey associated with this object. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public SSLeayEncryptedPrivateKey(byte[] encoding)
throws SSLeayException
Construct an SSLeayEncryptedPrivateKey object from
a byte array containing the (base-64 encoded) encrypted private key.
encoding - the byte array containing the (base-64 encoded)
encrypted private key.
public SSLeayEncryptedPrivateKey(InputStream is)
throws SSLeayException,
IOException
Construct an SSLeayEncryptedPrivateKey object from
an InputStream containing the (base-64 encoded)
encrypted private key.
is - the InputStream containing the (base-64 encoded)
encrypted private key.
public SSLeayEncryptedPrivateKey(SecureRandom rand,
PrivateKey priv)
throws SSLeayException
Construct an SSLeayEncryptedPrivateKey object from
a PrivateKey
rand - source of randomness (can be null ).priv - the PrivateKey to be encrypted. PrivateKey is not an instance
of java.security.interfaces.RSAPrivateCrtKey .| Method Detail |
public void encrypt(char[] pass)
throws SSLeayException
Encrypts the SSLeayEncryptedPrivateKey object using
the given password.
password - the character array containing the password used to
encrypt the key.
public byte[] getEncoded()
throws SSLeayException
Returns the Base64-encoding of the SSLeayEncryptedPrivateKey
.
encrypt() has not yet
been called.
public PrivateKey getPrivateKey()
throws SSLeayException
Returns the PrivateKey associated with this object.
decrypt() has not yet
been called.
public void decrypt(char[] pass)
throws SSLeayException
Decrypts the SSLeayEncryptedPrivateKey object using
the given password.
password - the character array containing the password used to
decrypt the key.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||