|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iaik.utils.SSLeayPrivateKey
The SSLeayPrivateKey
is used to read/write and decrypt/encrypt
private keys created with SSLeay.
Parts based on code by Stephan Spitz / TUEV Sueddeutschland.
Fields inherited from interface java.security.PrivateKey |
serialVersionUID |
Constructor Summary | |
SSLeayPrivateKey(InputStream is)
Reads a private key created by SSLeay from the specified file. |
|
SSLeayPrivateKey(PrivateKey privateKey)
This constructor gets a private key object to convert it into the OpenSSL format. |
|
SSLeayPrivateKey(String fileName)
Reads a private key created by SSLeay from the specified file. |
Method Summary | |
void |
decrypt(String password)
Decrypts this private key. |
void |
encrypt(String password,
String encryptionAlg,
byte[] iv)
Encrypts this private key. |
String |
getAlgorithm()
Returns the symmetric encryption algorithm used to protect this private key. |
byte[] |
getEncoded()
This method returns the DER encoded OpenSSL key which has PKCS#1 format. |
String |
getFormat()
Returns the format used to encode the key or null if the key does not support encoding. |
PrivateKey |
getPrivateKey()
Returns the included private key. |
boolean |
isEncrypted()
Test if this private key is encrypted. |
void |
writeTo(OutputStream out)
Write the SSLeayPrivateKey to a file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SSLeayPrivateKey(PrivateKey privateKey) throws InvalidKeyException, CodingException
privaeKey
- the key objectInvalidKeyException
- if the key is invalidCodingException
- if the key cannot be encodedpublic SSLeayPrivateKey(String fileName) throws IOException, InvalidKeyException
fileName
- the name of the file containing the private keyIOException
- if an error occurs during reading the keyInvalidKeyException
- if the key can not be parsedpublic SSLeayPrivateKey(InputStream is) throws IOException, InvalidKeyException
is
- an input stream containing the private keyIOException
- if an error occurs during reading the keyInvalidKeyException
- if the key can not be parsedMethod Detail |
public boolean isEncrypted()
public PrivateKey getPrivateKey() throws InvalidKeyException
InvalidKeyException
- if an error occurs during parsing this private key or the
is not decrypted yetpublic void decrypt(String password) throws InvalidKeyException
password
- the password to decrypt the private keypublic void encrypt(String password, String encryptionAlg, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, GeneralSecurityException
DES-CBC
, DES-EDE3-CBC
(default if null),
or IDEA/CBC/PKCS5Padding
. If iv is null, a new value is generatedpassword
- the password to decrypt the private keyencryptionalg
- the algorithm used to encrypt the private keypublic String getAlgorithm()
getAlgorithm
in interface Key
public byte[] getEncoded()
getEncoded
in interface Key
public String getFormat()
getFormat
in interface Key
public void writeTo(OutputStream out) throws IOException
|
This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |