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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.bouncycastle.crypto.params.AsymmetricKeyParameter
    decodeASN1(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.ECPrivateKeyParameters
    parseECPrivateKey(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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OpenSSLPrivateKeyDecoder

      public OpenSSLPrivateKeyDecoder()
  • Method Details

    • decryptKey

      protected byte[] decryptKey(byte[] encrypted, char[] password)
      Description copied from class: AbstractPrivateKeyDecoder
      Decrypts an encrypted key in either PKCS#8 or OpenSSL "traditional" format. Both PEM and DER encodings are supported.
      Specified by:
      decryptKey in class AbstractPrivateKeyDecoder<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: AbstractPrivateKeyDecoder
      Decodes the given raw ASN.1 encoded data into a private key of the type supported by this class.
      Specified by:
      decodeASN1 in class AbstractPrivateKeyDecoder<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