package org.bouncycastle.openpgp;

import org.bouncycastle.bcpg.KeyIdentifier;
import org.bouncycastle.bcpg.PublicSubkeyPacket;
import org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator;

/* JADX INFO: loaded from: classes.dex */
public class PGPKeyPair {
    protected PGPPrivateKey priv;
    protected PGPPublicKey pub;

    protected PGPKeyPair() {
    }

    public PGPKeyPair(PGPPublicKey pGPPublicKey, PGPPrivateKey pGPPrivateKey) {
        this.pub = pGPPublicKey;
        this.priv = pGPPrivateKey;
    }

    public PGPKeyPair asSubkey(KeyFingerPrintCalculator keyFingerPrintCalculator) throws PGPException {
        if (this.pub.getPublicKeyPacket() instanceof PublicSubkeyPacket) {
            return this;
        }
        PublicSubkeyPacket publicSubkeyPacket = new PublicSubkeyPacket(this.pub.getVersion(), this.pub.getAlgorithm(), this.pub.getCreationTime(), this.pub.getPublicKeyPacket().getKey());
        return new PGPKeyPair(new PGPPublicKey(publicSubkeyPacket, keyFingerPrintCalculator), new PGPPrivateKey(this.pub.getKeyID(), publicSubkeyPacket, this.priv.getPrivateKeyDataPacket()));
    }

    public long getKeyID() {
        return this.pub.getKeyID();
    }

    public KeyIdentifier getKeyIdentifier() {
        return getPublicKey().getKeyIdentifier();
    }

    public PGPPrivateKey getPrivateKey() {
        return this.priv;
    }

    public PGPPublicKey getPublicKey() {
        return this.pub;
    }
}
