package org.bouncycastle.crypto.signers;

/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
public class Ed448phSigner implements org.bouncycastle.crypto.Signer {
    private final org.bouncycastle.crypto.Xof g;
    private final byte[] h;
    private boolean i;
    private org.bouncycastle.crypto.params.Ed448PrivateKeyParameters j;
    private org.bouncycastle.crypto.params.Ed448PublicKeyParameters k;

    @Override // org.bouncycastle.crypto.Signer
    public boolean a(byte[] bArr) {
        if (this.i || this.k == null) {
            throw new java.lang.IllegalStateException("Ed448phSigner not initialised for verification");
        }
        if (114 != bArr.length) {
            this.g.reset();
            return false;
        }
        byte[] bArr2 = new byte[64];
        if (64 == this.g.b(bArr2, 0, 64)) {
            return this.k.j(1, this.h, bArr2, 0, 64, bArr, 0);
        }
        throw new java.lang.IllegalStateException("Prehash digest failed");
    }

    @Override // org.bouncycastle.crypto.Signer
    public byte[] b() {
        if (!this.i || this.j == null) {
            throw new java.lang.IllegalStateException("Ed448phSigner not initialised for signature generation.");
        }
        byte[] bArr = new byte[64];
        if (64 != this.g.b(bArr, 0, 64)) {
            throw new java.lang.IllegalStateException("Prehash digest failed");
        }
        byte[] bArr2 = new byte[114];
        this.j.h(1, this.h, bArr, 0, 64, bArr2, 0);
        return bArr2;
    }

    public void c() {
        this.g.reset();
    }

    @Override // org.bouncycastle.crypto.Signer
    public void init(boolean z, org.bouncycastle.crypto.CipherParameters cipherParameters) {
        this.i = z;
        org.bouncycastle.crypto.params.Ed448PublicKeyParameters ed448PublicKeyParameters = null;
        if (z) {
            this.j = (org.bouncycastle.crypto.params.Ed448PrivateKeyParameters) cipherParameters;
        } else {
            this.j = null;
            ed448PublicKeyParameters = (org.bouncycastle.crypto.params.Ed448PublicKeyParameters) cipherParameters;
        }
        this.k = ed448PublicKeyParameters;
        org.bouncycastle.crypto.CryptoServicesRegistrar.a(org.bouncycastle.crypto.signers.Utils.a("Ed448", 224, cipherParameters, z));
        c();
    }

    @Override // org.bouncycastle.crypto.Signer
    public void update(byte b) {
        this.g.update(b);
    }

    @Override // org.bouncycastle.crypto.Signer
    public void update(byte[] bArr, int i, int i2) {
        this.g.update(bArr, i, i2);
    }
}
