package org.bouncycastle.crypto.util;

/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
class SSHBuilder {
    private final java.io.ByteArrayOutputStream a = new java.io.ByteArrayOutputStream();

    SSHBuilder() {
    }

    public byte[] a() {
        return this.a.toByteArray();
    }

    public byte[] b() {
        return c(8);
    }

    public byte[] c(int i) {
        int size = this.a.size() % i;
        if (size != 0) {
            int i2 = i - size;
            for (int i3 = 1; i3 <= i2; i3++) {
                this.a.write(i3);
            }
        }
        return this.a.toByteArray();
    }

    public void d(int i) {
        this.a.write((i >>> 24) & 255);
        this.a.write((i >>> 16) & 255);
        this.a.write((i >>> 8) & 255);
        this.a.write(i & 255);
    }

    public void e(java.math.BigInteger bigInteger) {
        f(bigInteger.toByteArray());
    }

    public void f(byte[] bArr) {
        d(bArr.length);
        try {
            this.a.write(bArr);
        } catch (java.io.IOException e) {
            throw new java.lang.IllegalStateException(e.getMessage(), e);
        }
    }

    public void g(byte[] bArr) {
        try {
            this.a.write(bArr);
        } catch (java.io.IOException e) {
            throw new java.lang.IllegalStateException(e.getMessage(), e);
        }
    }

    public void h(java.lang.String str) {
        f(org.bouncycastle.util.Strings.f(str));
    }
}
