package org.bouncycastle.gpg;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.edec.EdECObjectIdentifiers;
import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
import org.bouncycastle.asn1.x9.ECNamedCurveTable;
import org.bouncycastle.asn1.x9.X9ECParametersHolder;
import org.bouncycastle.bcpg.BCPGKey;
import org.bouncycastle.bcpg.DSAPublicBCPGKey;
import org.bouncycastle.bcpg.DSASecretBCPGKey;
import org.bouncycastle.bcpg.ECDSAPublicBCPGKey;
import org.bouncycastle.bcpg.ECPublicBCPGKey;
import org.bouncycastle.bcpg.ECSecretBCPGKey;
import org.bouncycastle.bcpg.EdDSAPublicBCPGKey;
import org.bouncycastle.bcpg.EdSecretBCPGKey;
import org.bouncycastle.bcpg.ElGamalPublicBCPGKey;
import org.bouncycastle.bcpg.ElGamalSecretBCPGKey;
import org.bouncycastle.bcpg.PublicKeyAlgorithmTags;
import org.bouncycastle.bcpg.PublicKeyPacket;
import org.bouncycastle.bcpg.RSAPublicBCPGKey;
import org.bouncycastle.bcpg.RSASecretBCPGKey;
import org.bouncycastle.bcpg.S2K;
import org.bouncycastle.bcpg.SecretKeyPacket;
import org.bouncycastle.crypto.ec.CustomNamedCurves;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPSecretKey;
import org.bouncycastle.openpgp.PGPUtil;
import org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator;
import org.bouncycastle.openpgp.operator.PBEProtectionRemoverFactory;
import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor;
import org.bouncycastle.openpgp.operator.PGPDigestCalculator;
import org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider;
import org.bouncycastle.openpgp.operator.PGPSecretKeyDecryptorWithAAD;
import org.bouncycastle.util.Arrays;
import org.bouncycastle.util.BigIntegers;
import org.bouncycastle.util.Strings;

/* JADX INFO: loaded from: classes.dex */
public class SExprParser {
    private final PGPDigestCalculatorProvider digestProvider;
    private static final Map<Integer, String[]> rsaLabels = new HashMap<Integer, String[]>() { // from class: org.bouncycastle.gpg.SExprParser.1
        {
            put(2, new String[]{"rsa", "n", "e", "protected-at"});
            put(1, new String[]{"rsa", "n", "e", "d", "p", "q", "u", "protected-at"});
        }
    };
    private static final Map<Integer, String[]> eccLabels = new HashMap<Integer, String[]>() { // from class: org.bouncycastle.gpg.SExprParser.2
        {
            put(2, new String[]{"ecc", "curve", "flags", "q", "protected-at"});
            put(1, new String[]{"ecc", "curve", "q", "d", "protected-at"});
        }
    };
    private static final Map<Integer, String[]> dsaLabels = new HashMap<Integer, String[]>() { // from class: org.bouncycastle.gpg.SExprParser.3
        {
            put(2, new String[]{"dsa", "p", "q", "g", "y", "protected-at"});
            put(1, new String[]{"dsa", "p", "q", "g", "y", "x", "protected-at"});
        }
    };
    private static final Map<Integer, String[]> elgLabels = new HashMap<Integer, String[]>() { // from class: org.bouncycastle.gpg.SExprParser.4
        {
            put(2, new String[]{"elg", "p", "q", "g", "y", "protected-at"});
            put(1, new String[]{"elg", "p", "q", "g", "y", "x", "protected-at"});
        }
    };
    private static final String[] rsaBigIntegers = {"n", "e"};
    private static final String[] dsaBigIntegers = {"p", "q", "g", "y"};
    private static final String[] elgBigIntegers = {"p", "g", "y"};

    /* JADX INFO: loaded from: classes3.dex */
    private interface GetSecKeyDataOperation {
        byte[] getSecKeyData(SExpression sExpression);
    }

    public interface ProtectionFormatTypeTags {
        public static final int OPENPGP_PRIVATE_KEY = 4;
        public static final int PRIVATE_KEY = 1;
        public static final int PROTECTED_PRIVATE_KEY = 2;
        public static final int PROTECTED_SHARED_SECRET = 5;
        public static final int SHADOWED_PRIVATE_KEY = 3;
    }

    private interface ProtectionModeTags {
        public static final int OPENPGP_NATIVE = 3;
        public static final int OPENPGP_S2K3_OCB_AES = 2;
        public static final int OPENPGP_S2K3_SHA1_AES_CBC = 1;
    }

    /* JADX INFO: loaded from: classes3.dex */
    private interface getPublicKeyOperation {
        void assertPublicKeyMatch(BCPGKey bCPGKey, BCPGKey bCPGKey2) throws PGPException;

        BCPGKey getBasePublicKey(BigInteger[] bigIntegerArr);
    }

    public SExprParser(PGPDigestCalculatorProvider pGPDigestCalculatorProvider) {
        this.digestProvider = pGPDigestCalculatorProvider;
    }

    private static void assertEccPublicKeyMath(BCPGKey bCPGKey, PGPPublicKey pGPPublicKey) throws PGPException {
        if (bCPGKey instanceof ECDSAPublicBCPGKey) {
            ECPublicBCPGKey eCPublicBCPGKey = (ECPublicBCPGKey) pGPPublicKey.getPublicKeyPacket().getKey();
            ECDSAPublicBCPGKey eCDSAPublicBCPGKey = (ECDSAPublicBCPGKey) bCPGKey;
            if (!eCDSAPublicBCPGKey.getCurveOID().equals((ASN1Primitive) eCPublicBCPGKey.getCurveOID()) || !eCDSAPublicBCPGKey.getEncodedPoint().equals(eCPublicBCPGKey.getEncodedPoint())) {
                throw new PGPException("passed in public key does not match secret key");
            }
            return;
        }
        if (!(bCPGKey instanceof EdDSAPublicBCPGKey)) {
            throw new PGPException("unknown key type: " + (bCPGKey != null ? bCPGKey.getClass().getName() : "null"));
        }
        EdDSAPublicBCPGKey edDSAPublicBCPGKey = (EdDSAPublicBCPGKey) pGPPublicKey.getPublicKeyPacket().getKey();
        EdDSAPublicBCPGKey edDSAPublicBCPGKey2 = (EdDSAPublicBCPGKey) bCPGKey;
        if (!edDSAPublicBCPGKey2.getCurveOID().equals((ASN1Primitive) edDSAPublicBCPGKey.getCurveOID()) || !edDSAPublicBCPGKey2.getEncodedPoint().equals(edDSAPublicBCPGKey.getEncodedPoint())) {
            throw new PGPException("passed in public key does not match secret key");
        }
    }

    private static BCPGKey getECCBasePublicKey(SExpression sExpression) {
        byte[] bytes = null;
        String strTrim = null;
        int i = 0;
        for (Object obj : sExpression.getValues()) {
            if (obj instanceof SExpression) {
                SExpression sExpression2 = (SExpression) obj;
                String string = sExpression2.getString(0);
                if (string.equals("curve")) {
                    strTrim = sExpression2.getString(1);
                    i |= 1;
                } else if (string.equals("q")) {
                    bytes = sExpression2.getBytes(1);
                    i |= 2;
                }
                if (i == 3) {
                    break;
                }
            }
        }
        if (i != 3) {
            throw new IllegalArgumentException("no curve expression");
        }
        if (strTrim.startsWith("NIST")) {
            strTrim = strTrim.substring("NIST".length()).trim();
        }
        String lowerCase = Strings.toLowerCase(strTrim);
        if (lowerCase.equals("ed25519")) {
            return new EdDSAPublicBCPGKey(EdECObjectIdentifiers.id_Ed25519, new BigInteger(1, bytes));
        }
        if (lowerCase.equals("ed448")) {
            return new EdDSAPublicBCPGKey(EdECObjectIdentifiers.id_Ed448, new BigInteger(1, bytes));
        }
        ASN1ObjectIdentifier oid = ECNamedCurveTable.getOID(strTrim);
        X9ECParametersHolder byNameLazy = CustomNamedCurves.getByNameLazy(strTrim);
        if (byNameLazy == null && oid != null) {
            byNameLazy = TeleTrusTNamedCurves.getByOIDLazy(oid);
        }
        if (byNameLazy != null) {
            return new ECDSAPublicBCPGKey(oid, byNameLazy.getCurve().decodePoint(bytes));
        }
        throw new IllegalStateException("unable to resolve parameters for " + strTrim);
    }

    public static PublicKeyAlgorithmTags[] getPGPSecretKey(PBEProtectionRemoverFactory pBEProtectionRemoverFactory, KeyFingerPrintCalculator keyFingerPrintCalculator, PGPPublicKey pGPPublicKey, int i, int i2, final SExpression sExpression, String str, PGPDigestCalculatorProvider pGPDigestCalculatorProvider) throws IOException, PGPException {
        PGPPublicKey publicKey;
        Map<Integer, String[]> map;
        GetSecKeyDataOperation getSecKeyDataOperation;
        SecretKeyPacket secKeyPacket;
        PGPPublicKey pGPPublicKey2;
        PublicKeyPacket publicKeyPacket;
        if (str.equals("ecc")) {
            BCPGKey eCCBasePublicKey = getECCBasePublicKey(sExpression);
            if (pGPPublicKey != null) {
                assertEccPublicKeyMath(eCCBasePublicKey, pGPPublicKey);
                pGPPublicKey2 = pGPPublicKey;
            } else {
                if (eCCBasePublicKey instanceof EdDSAPublicBCPGKey) {
                    publicKeyPacket = new PublicKeyPacket(22, new Date(), eCCBasePublicKey);
                } else {
                    publicKeyPacket = eCCBasePublicKey instanceof ECPublicBCPGKey ? new PublicKeyPacket(19, new Date(), eCCBasePublicKey) : null;
                }
                pGPPublicKey2 = new PGPPublicKey(publicKeyPacket, keyFingerPrintCalculator);
            }
            secKeyPacket = getSecKeyPacket(pGPPublicKey2, pBEProtectionRemoverFactory, i, i2, sExpression, pGPDigestCalculatorProvider, eccLabels, new GetSecKeyDataOperation() { // from class: org.bouncycastle.gpg.SExprParser.5
                @Override // org.bouncycastle.gpg.SExprParser.GetSecKeyDataOperation
                public byte[] getSecKeyData(SExpression sExpression2) {
                    BigInteger bigIntegerFromUnsignedByteArray = BigIntegers.fromUnsignedByteArray(sExpression2.getExpressionWithLabelOrFail("d").getBytes(1));
                    String string = sExpression.getExpressionWithLabel("curve").getString(1);
                    return (string.startsWith("NIST") || string.startsWith("brain")) ? new ECSecretBCPGKey(bigIntegerFromUnsignedByteArray).getEncoded() : new EdSecretBCPGKey(bigIntegerFromUnsignedByteArray).getEncoded();
                }
            });
        } else {
            if (str.equals("dsa")) {
                publicKey = getPublicKey(keyFingerPrintCalculator, pGPPublicKey, sExpression, 17, dsaBigIntegers, new getPublicKeyOperation() { // from class: org.bouncycastle.gpg.SExprParser.6
                    @Override // org.bouncycastle.gpg.SExprParser.getPublicKeyOperation
                    public void assertPublicKeyMatch(BCPGKey bCPGKey, BCPGKey bCPGKey2) throws PGPException {
                        DSAPublicBCPGKey dSAPublicBCPGKey = (DSAPublicBCPGKey) bCPGKey;
                        DSAPublicBCPGKey dSAPublicBCPGKey2 = (DSAPublicBCPGKey) bCPGKey2;
                        if (!dSAPublicBCPGKey.getP().equals(dSAPublicBCPGKey2.getP()) || !dSAPublicBCPGKey.getQ().equals(dSAPublicBCPGKey2.getQ()) || !dSAPublicBCPGKey.getG().equals(dSAPublicBCPGKey2.getG()) || !dSAPublicBCPGKey.getY().equals(dSAPublicBCPGKey2.getY())) {
                            throw new PGPException("passed in public key does not match secret key");
                        }
                    }

                    @Override // org.bouncycastle.gpg.SExprParser.getPublicKeyOperation
                    public BCPGKey getBasePublicKey(BigInteger[] bigIntegerArr) {
                        return new DSAPublicBCPGKey(bigIntegerArr[0], bigIntegerArr[1], bigIntegerArr[2], bigIntegerArr[3]);
                    }
                });
                map = dsaLabels;
                getSecKeyDataOperation = new GetSecKeyDataOperation() { // from class: org.bouncycastle.gpg.SExprParser.7
                    @Override // org.bouncycastle.gpg.SExprParser.GetSecKeyDataOperation
                    public byte[] getSecKeyData(SExpression sExpression2) {
                        return new DSASecretBCPGKey(BigIntegers.fromUnsignedByteArray(sExpression2.getExpressionWithLabelOrFail("x").getBytes(1))).getEncoded();
                    }
                };
            } else if (str.equals("elg")) {
                publicKey = getPublicKey(keyFingerPrintCalculator, pGPPublicKey, sExpression, 16, elgBigIntegers, new getPublicKeyOperation() { // from class: org.bouncycastle.gpg.SExprParser.8
                    @Override // org.bouncycastle.gpg.SExprParser.getPublicKeyOperation
                    public void assertPublicKeyMatch(BCPGKey bCPGKey, BCPGKey bCPGKey2) throws PGPException {
                        ElGamalPublicBCPGKey elGamalPublicBCPGKey = (ElGamalPublicBCPGKey) bCPGKey;
                        ElGamalPublicBCPGKey elGamalPublicBCPGKey2 = (ElGamalPublicBCPGKey) bCPGKey2;
                        if (!elGamalPublicBCPGKey.getP().equals(elGamalPublicBCPGKey2.getP()) || !elGamalPublicBCPGKey.getG().equals(elGamalPublicBCPGKey2.getG()) || !elGamalPublicBCPGKey.getY().equals(elGamalPublicBCPGKey2.getY())) {
                            throw new PGPException("passed in public key does not match secret key");
                        }
                    }

                    @Override // org.bouncycastle.gpg.SExprParser.getPublicKeyOperation
                    public BCPGKey getBasePublicKey(BigInteger[] bigIntegerArr) {
                        return new ElGamalPublicBCPGKey(bigIntegerArr[0], bigIntegerArr[1], bigIntegerArr[2]);
                    }
                });
                map = elgLabels;
                getSecKeyDataOperation = new GetSecKeyDataOperation() { // from class: org.bouncycastle.gpg.SExprParser.9
                    @Override // org.bouncycastle.gpg.SExprParser.GetSecKeyDataOperation
                    public byte[] getSecKeyData(SExpression sExpression2) {
                        return new ElGamalSecretBCPGKey(BigIntegers.fromUnsignedByteArray(sExpression2.getExpressionWithLabelOrFail("x").getBytes(1))).getEncoded();
                    }
                };
            } else {
                if (!str.equals("rsa")) {
                    throw new PGPException("unknown key type: " + str);
                }
                publicKey = getPublicKey(keyFingerPrintCalculator, pGPPublicKey, sExpression, 1, rsaBigIntegers, new getPublicKeyOperation() { // from class: org.bouncycastle.gpg.SExprParser.10
                    @Override // org.bouncycastle.gpg.SExprParser.getPublicKeyOperation
                    public void assertPublicKeyMatch(BCPGKey bCPGKey, BCPGKey bCPGKey2) throws PGPException {
                        RSAPublicBCPGKey rSAPublicBCPGKey = (RSAPublicBCPGKey) bCPGKey;
                        RSAPublicBCPGKey rSAPublicBCPGKey2 = (RSAPublicBCPGKey) bCPGKey2;
                        if (!rSAPublicBCPGKey.getModulus().equals(rSAPublicBCPGKey2.getModulus()) || !rSAPublicBCPGKey.getPublicExponent().equals(rSAPublicBCPGKey2.getPublicExponent())) {
                            throw new PGPException("passed in public key does not match secret key");
                        }
                    }

                    @Override // org.bouncycastle.gpg.SExprParser.getPublicKeyOperation
                    public BCPGKey getBasePublicKey(BigInteger[] bigIntegerArr) {
                        return new RSAPublicBCPGKey(bigIntegerArr[0], bigIntegerArr[1]);
                    }
                });
                map = rsaLabels;
                getSecKeyDataOperation = new GetSecKeyDataOperation() { // from class: org.bouncycastle.gpg.SExprParser.11
                    @Override // org.bouncycastle.gpg.SExprParser.GetSecKeyDataOperation
                    public byte[] getSecKeyData(SExpression sExpression2) {
                        return new RSASecretBCPGKey(BigIntegers.fromUnsignedByteArray(sExpression2.getExpressionWithLabelOrFail("d").getBytes(1)), BigIntegers.fromUnsignedByteArray(sExpression2.getExpressionWithLabelOrFail("p").getBytes(1)), BigIntegers.fromUnsignedByteArray(sExpression2.getExpressionWithLabelOrFail("q").getBytes(1))).getEncoded();
                    }
                };
            }
            secKeyPacket = getSecKeyPacket(publicKey, pBEProtectionRemoverFactory, i, i2, sExpression, pGPDigestCalculatorProvider, map, getSecKeyDataOperation);
            pGPPublicKey2 = publicKey;
        }
        return new PublicKeyAlgorithmTags[]{secKeyPacket, pGPPublicKey2};
    }

    private static int getProtectionMode(String str) {
        if (str.equals("openpgp-s2k3-sha1-aes-cbc")) {
            return 1;
        }
        return str.equals("openpgp-s2k3-ocb-aes") ? 2 : -1;
    }

    public static int getProtectionType(String str) {
        if (str.equals("private-key")) {
            return 1;
        }
        if (str.equals("protected-private-key")) {
            return 2;
        }
        return str.equals("shadowed-private-key") ? 3 : -1;
    }

    private static PGPPublicKey getPublicKey(KeyFingerPrintCalculator keyFingerPrintCalculator, PGPPublicKey pGPPublicKey, SExpression sExpression, int i, String[] strArr, getPublicKeyOperation getpublickeyoperation) throws PGPException {
        int length = (1 << strArr.length) - 1;
        BigInteger[] bigIntegerArr = new BigInteger[strArr.length];
        int i2 = 0;
        for (Object obj : sExpression.getValues()) {
            if (obj instanceof SExpression) {
                SExpression sExpression2 = (SExpression) obj;
                String string = sExpression2.getString(0);
                for (int i3 = 0; i3 < strArr.length; i3++) {
                    int i4 = 1 << i3;
                    if ((i2 & i4) == 0 && string.equals(strArr[i3])) {
                        bigIntegerArr[i3] = BigIntegers.fromUnsignedByteArray(sExpression2.getBytes(1));
                        i2 |= i4;
                        if (i2 == length) {
                            break;
                        }
                    }
                }
            }
        }
        if (i2 != length) {
            throw new IllegalArgumentException("The public key should not be null");
        }
        BCPGKey basePublicKey = getpublickeyoperation.getBasePublicKey(bigIntegerArr);
        if (pGPPublicKey == null) {
            return new PGPPublicKey(new PublicKeyPacket(i, new Date(), basePublicKey), keyFingerPrintCalculator);
        }
        getpublickeyoperation.assertPublicKeyMatch(basePublicKey, pGPPublicKey.getPublicKeyPacket().getKey());
        return pGPPublicKey;
    }

    private static SecretKeyPacket getSecKeyPacket(PGPPublicKey pGPPublicKey, PBEProtectionRemoverFactory pBEProtectionRemoverFactory, int i, int i2, SExpression sExpression, PGPDigestCalculatorProvider pGPDigestCalculatorProvider, Map<Integer, String[]> map, GetSecKeyDataOperation getSecKeyDataOperation) throws IOException, PGPException {
        byte[] secKeyData;
        byte[] bytes;
        SExpression expression;
        SExpression canonical;
        S2K s2k = null;
        if (i2 != 3) {
            if (i2 == 2) {
                SExpression expressionWithLabel = sExpression.getExpressionWithLabel("protected");
                if (expressionWithLabel == null) {
                    throw new IllegalArgumentException(i2 + " does not have protected block");
                }
                String string = expressionWithLabel.getString(1);
                int protectionMode = getProtectionMode(string);
                if (protectionMode != 2 && protectionMode != 1) {
                    throw new PGPException("unsupported protection type " + expressionWithLabel.getString(1));
                }
                SExpression expression2 = expressionWithLabel.getExpression(2);
                SExpression expression3 = expression2.getExpression(0);
                S2K s2k2 = new S2K(PGPUtil.getDigestIDForName(expression3.getString(0)), expression3.getBytes(1), expression3.getInt(2));
                bytes = expression2.getBytes(1);
                PBESecretKeyDecryptor pBESecretKeyDecryptorCreateDecryptor = pBEProtectionRemoverFactory.createDecryptor(string);
                byte[] bArrMakeKeyFromPassPhrase = pBESecretKeyDecryptorCreateDecryptor.makeKeyFromPassPhrase(7, s2k2);
                byte[] bytes2 = expressionWithLabel.getBytes(3);
                if (protectionMode == 1) {
                    canonical = SExpression.parseCanonical(new ByteArrayInputStream(pBESecretKeyDecryptorCreateDecryptor.recoverKeyData(7, bArrMakeKeyFromPassPhrase, bytes, bytes2, 0, bytes2.length)), i);
                    if (pGPDigestCalculatorProvider != null) {
                        PGPDigestCalculator pGPDigestCalculator = pGPDigestCalculatorProvider.get(2);
                        pGPDigestCalculator.getOutputStream().write(SExpression.buildExpression(sExpression, canonical.getExpression(0), map.get(Integer.valueOf(protectionMode))).toCanonicalForm());
                        if (!Arrays.constantTimeAreEqual(pGPDigestCalculator.getDigest(), canonical.getExpression(1).getBytes(2))) {
                            throw new PGPException("checksum on protected data failed in SExpr");
                        }
                    }
                } else {
                    String[] strArr = map.get(Integer.valueOf(protectionMode));
                    if (strArr == null) {
                        throw new IllegalStateException("no decryption support for protected elgamal keys");
                    }
                    canonical = SExpression.parseCanonical(new ByteArrayInputStream(((PGPSecretKeyDecryptorWithAAD) pBESecretKeyDecryptorCreateDecryptor).recoverKeyData(7, bArrMakeKeyFromPassPhrase, bytes, SExpression.buildExpression(sExpression, strArr).toCanonicalForm(), bytes2, 0, bytes2.length)), i);
                }
                expression = canonical.getExpression(0);
                s2k = s2k2;
            } else {
                expression = sExpression;
                bytes = null;
            }
            secKeyData = getSecKeyDataOperation.getSecKeyData(expression);
        } else {
            secKeyData = null;
            bytes = null;
        }
        return new SecretKeyPacket(pGPPublicKey.getPublicKeyPacket(), 0, s2k, bytes, secKeyData);
    }

    private PGPSecretKey parse(InputStream inputStream, PBEProtectionRemoverFactory pBEProtectionRemoverFactory, KeyFingerPrintCalculator keyFingerPrintCalculator, PGPPublicKey pGPPublicKey) throws IOException, PGPException {
        SExpression canonical = SExpression.parseCanonical(inputStream, 10);
        int protectionType = getProtectionType(canonical.getString(0));
        if (protectionType != 1 && protectionType != 2 && protectionType != 3) {
            throw new PGPException("unknown key type found");
        }
        SExpression expression = canonical.getExpression(1);
        PublicKeyAlgorithmTags[] pGPSecretKey = getPGPSecretKey(pBEProtectionRemoverFactory, keyFingerPrintCalculator, pGPPublicKey, 10, protectionType, expression, expression.getString(0), this.digestProvider);
        return new PGPSecretKey((SecretKeyPacket) pGPSecretKey[0], (PGPPublicKey) pGPSecretKey[1]);
    }

    public PGPSecretKey parseSecretKey(InputStream inputStream, PBEProtectionRemoverFactory pBEProtectionRemoverFactory, PGPPublicKey pGPPublicKey) throws IOException, PGPException {
        if (pGPPublicKey != null) {
            return parse(inputStream, pBEProtectionRemoverFactory, null, pGPPublicKey);
        }
        throw new NullPointerException("Public key cannot be null");
    }

    public PGPSecretKey parseSecretKey(InputStream inputStream, PBEProtectionRemoverFactory pBEProtectionRemoverFactory, KeyFingerPrintCalculator keyFingerPrintCalculator) throws IOException, PGPException {
        return parse(inputStream, pBEProtectionRemoverFactory, keyFingerPrintCalculator, null);
    }
}
