package org.bouncycastle.bcpg.sig;

import org.bouncycastle.bcpg.FingerprintUtil;
import org.bouncycastle.bcpg.KeyIdentifier;
import org.bouncycastle.bcpg.SignatureSubpacket;
import org.bouncycastle.util.Arrays;

/* JADX INFO: loaded from: classes3.dex */
public class IssuerFingerprint extends SignatureSubpacket {
    public IssuerFingerprint(boolean z, int i, byte[] bArr) {
        super(33, z, false, Arrays.prepend(bArr, (byte) i));
    }

    public IssuerFingerprint(boolean z, boolean z2, byte[] bArr) {
        super(33, z, z2, verifyData(bArr));
    }

    private static byte[] verifyData(byte[] bArr) {
        if (bArr.length >= 1) {
            return bArr;
        }
        throw new IllegalArgumentException("Data too short. Expect at least one octet of key version.");
    }

    public byte[] getFingerprint() {
        return Arrays.copyOfRange(this.data, 1, this.data.length);
    }

    public long getKeyID() {
        if (getKeyVersion() == 4) {
            return FingerprintUtil.keyIdFromV4Fingerprint(getFingerprint());
        }
        if (getKeyVersion() == 5) {
            return FingerprintUtil.keyIdFromLibrePgpFingerprint(getFingerprint());
        }
        if (getKeyVersion() == 6) {
            return FingerprintUtil.keyIdFromV6Fingerprint(getFingerprint());
        }
        return 0L;
    }

    public KeyIdentifier getKeyIdentifier() {
        return new KeyIdentifier(getFingerprint());
    }

    public int getKeyVersion() {
        return this.data[0] & 255;
    }
}
