Package org.cryptacular.asn
Class AbstractPrivateKeyDecoder<T>
java.lang.Object
org.cryptacular.asn.AbstractPrivateKeyDecoder<T>
- Type Parameters:
T- Type produced by decode operation.
- All Implemented Interfaces:
ASN1Decoder<T>
- Direct Known Subclasses:
OpenSSLPrivateKeyDecoder,PKCS8PrivateKeyDecoder
Base class for all private key decoders.
- Author:
- Middleware Services
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionProduces an object from an encoded representation.protected abstract TdecodeASN1(byte[] encoded) Decodes the given raw ASN.1 encoded data into a private key of the type supported by this class.protected abstract byte[]decryptKey(byte[] encrypted, char[] password) Decrypts an encrypted key in either PKCS#8 or OpenSSL "traditional" format.protected byte[]tryConvertPem(byte[] input) Tests the given encoded input and converts it to PEM if it is detected, stripping out any header/footer data in the process.
-
Constructor Details
-
AbstractPrivateKeyDecoder
public AbstractPrivateKeyDecoder()
-
-
Method Details
-
decode
Description copied from interface:ASN1DecoderProduces an object from an encoded representation.- Specified by:
decodein interfaceASN1Decoder<T>- Parameters:
encoded- ASN.1 encoded data.args- Additional data required to perform decoding.- Returns:
- Decoded object.
- Throws:
EncodingException- on encoding errors.
-
tryConvertPem
protected byte[] tryConvertPem(byte[] input) Tests the given encoded input and converts it to PEM if it is detected, stripping out any header/footer data in the process.- Parameters:
input- Encoded data that may be PEM encoded.- Returns:
- Decoded data if PEM encoding detected, otherwise original data.
-
decryptKey
protected abstract byte[] decryptKey(byte[] encrypted, char[] password) Decrypts an encrypted key in either PKCS#8 or OpenSSL "traditional" format. Both PEM and DER encodings are supported.- Parameters:
encrypted- Encoded encrypted key data.password- Password to decrypt key.- Returns:
- Decrypted key.
-
decodeASN1
Decodes the given raw ASN.1 encoded data into a private key of the type supported by this class.- Parameters:
encoded- Encoded ASN.1 data.- Returns:
- Private key object.
-