Package org.cryptacular.asn
Class OpenSSLPrivateKeyDecoder
java.lang.Object
org.cryptacular.asn.AbstractPrivateKeyDecoder<org.bouncycastle.crypto.params.AsymmetricKeyParameter>
org.cryptacular.asn.OpenSSLPrivateKeyDecoder
- All Implemented Interfaces:
ASN1Decoder<org.bouncycastle.crypto.params.AsymmetricKeyParameter>
public class OpenSSLPrivateKeyDecoder
extends AbstractPrivateKeyDecoder<org.bouncycastle.crypto.params.AsymmetricKeyParameter>
Decrypts PEM-encoded OpenSSL "traditional" format private keys.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.bouncycastle.crypto.params.AsymmetricKeyParameterdecodeASN1(byte[] encoded) Decodes the given raw ASN.1 encoded data into a private key of the type supported by this class.protected byte[]decryptKey(byte[] encrypted, char[] password) Decrypts an encrypted key in either PKCS#8 or OpenSSL "traditional" format.private org.bouncycastle.crypto.params.ECPrivateKeyParametersparseECPrivateKey(org.bouncycastle.asn1.ASN1Sequence seq) Parses an EC private key as defined in RFC 5915.Methods inherited from class org.cryptacular.asn.AbstractPrivateKeyDecoder
decode, tryConvertPem
-
Constructor Details
-
OpenSSLPrivateKeyDecoder
public OpenSSLPrivateKeyDecoder()
-
-
Method Details
-
decryptKey
protected byte[] decryptKey(byte[] encrypted, char[] password) Description copied from class:AbstractPrivateKeyDecoderDecrypts an encrypted key in either PKCS#8 or OpenSSL "traditional" format. Both PEM and DER encodings are supported.- Specified by:
decryptKeyin classAbstractPrivateKeyDecoder<org.bouncycastle.crypto.params.AsymmetricKeyParameter>- Parameters:
encrypted- Encoded encrypted key data.password- Password to decrypt key.- Returns:
- Decrypted key.
-
decodeASN1
protected org.bouncycastle.crypto.params.AsymmetricKeyParameter decodeASN1(byte[] encoded) Description copied from class:AbstractPrivateKeyDecoderDecodes the given raw ASN.1 encoded data into a private key of the type supported by this class.- Specified by:
decodeASN1in classAbstractPrivateKeyDecoder<org.bouncycastle.crypto.params.AsymmetricKeyParameter>- Parameters:
encoded- Encoded ASN.1 data.- Returns:
- Private key object.
-
parseECPrivateKey
private org.bouncycastle.crypto.params.ECPrivateKeyParameters parseECPrivateKey(org.bouncycastle.asn1.ASN1Sequence seq) Parses an EC private key as defined in RFC 5915.ECPrivateKey ::= SEQUENCE { version INTEGER { ecPrivkeyVer1(1) } (ecPrivkeyVer1), privateKey OCTET STRING, parameters [0] ECParameters {{ NamedCurve }} OPTIONAL, publicKey [1] BIT STRING OPTIONAL }- Parameters:
seq- ASN1 sequence to parse- Returns:
- EC private key
-