Class SExprParser


  • public class SExprParser
    extends Object
    A parser for secret keys stored in s-expressions. Original BouncyCastle code modified by the JGit team to:
    • handle unencrypted DSA, EC, and ElGamal keys (upstream only handles unencrypted RSA), and
    • handle secret keys using AES/OCB as encryption (those don't have a hash).
    • Constructor Summary

      Constructors 
      Constructor Description
      SExprParser​(org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider digestProvider)
      Base constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.bouncycastle.openpgp.PGPSecretKey parseSecretKey​(InputStream inputStream, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory, org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator fingerPrintCalculator)
      Parse a secret key from one of the GPG S expression keys.
      org.bouncycastle.openpgp.PGPSecretKey parseSecretKey​(InputStream inputStream, org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory, org.bouncycastle.openpgp.PGPPublicKey pubKey)
      Parse a secret key from one of the GPG S expression keys associating it with the passed in public key.
    • Constructor Detail

      • SExprParser

        public SExprParser​(org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider digestProvider)
        Base constructor.
        Parameters:
        digestProvider - a provider for digest calculations. Used to confirm key protection hashes.
    • Method Detail

      • parseSecretKey

        public org.bouncycastle.openpgp.PGPSecretKey parseSecretKey​(InputStream inputStream,
                                                                    org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory,
                                                                    org.bouncycastle.openpgp.PGPPublicKey pubKey)
                                                             throws IOException,
                                                                    org.bouncycastle.openpgp.PGPException
        Parse a secret key from one of the GPG S expression keys associating it with the passed in public key.
        Parameters:
        inputStream - to read from
        keyProtectionRemoverFactory - for decrypting encrypted keys
        pubKey - the private key should belong to
        Returns:
        a secret key object.
        Throws:
        IOException
        org.bouncycastle.openpgp.PGPException
      • parseSecretKey

        public org.bouncycastle.openpgp.PGPSecretKey parseSecretKey​(InputStream inputStream,
                                                                    org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory keyProtectionRemoverFactory,
                                                                    org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator fingerPrintCalculator)
                                                             throws IOException,
                                                                    org.bouncycastle.openpgp.PGPException
        Parse a secret key from one of the GPG S expression keys.
        Parameters:
        inputStream - to read from
        keyProtectionRemoverFactory - for decrypting encrypted keys
        fingerPrintCalculator - for calculating key fingerprints
        Returns:
        a secret key object.
        Throws:
        IOException
        org.bouncycastle.openpgp.PGPException