package org.bouncycastle.est;

/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
public class ESTResponse {
    private static final java.lang.Long c = 0L;
    private java.lang.Long a;
    private long b;

    /* JADX INFO: renamed from: org.bouncycastle.est.ESTResponse$1, reason: invalid class name */
    class AnonymousClass1 extends java.io.InputStream {
        @Override // java.io.InputStream
        public int read() {
            return -1;
        }
    }

    /* JADX INFO: renamed from: org.bouncycastle.est.ESTResponse$2, reason: invalid class name */
    class AnonymousClass2 extends java.io.InputStream {
        final /* synthetic */ java.io.InputStream a;
        final /* synthetic */ java.lang.Long b;
        final /* synthetic */ org.bouncycastle.est.ESTResponse c;

        @Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
        public void close() throws java.io.IOException {
            if (this.c.a == null || this.c.a.longValue() - 1 <= this.c.b) {
                if (this.a.available() > 0) {
                    throw new java.io.IOException("Stream closed with extra content in pipe that exceeds content length.");
                }
                this.a.close();
            } else {
                throw new java.io.IOException("Stream closed before limit fully read, Read: " + this.c.b + " ContentLength: " + this.c.a);
            }
        }

        @Override // java.io.InputStream
        public int read() throws java.io.IOException {
            int i = this.a.read();
            if (i > -1) {
                org.bouncycastle.est.ESTResponse.b(this.c);
                if (this.b != null && this.c.b >= this.b.longValue()) {
                    throw new java.io.IOException("Absolute Read Limit exceeded: " + this.b);
                }
            }
            return i;
        }
    }

    private static class PrintingInputStream extends java.io.InputStream {
        private final java.io.InputStream a;

        @Override // java.io.InputStream
        public int available() {
            return this.a.available();
        }

        @Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
        public void close() throws java.io.IOException {
            this.a.close();
        }

        @Override // java.io.InputStream
        public int read() {
            return this.a.read();
        }
    }

    static /* synthetic */ long b(org.bouncycastle.est.ESTResponse eSTResponse) {
        long j = eSTResponse.b;
        eSTResponse.b = 1 + j;
        return j;
    }
}
