what-the-bank/sources/com/facetec/sdk/na.java

137 lines
3.9 KiB
Java

package com.facetec.sdk;
import java.io.EOFException;
import java.io.IOException;
import java.util.zip.CRC32;
import java.util.zip.Inflater;
/* loaded from: classes.dex */
public final class na implements nk {
private int a = 0;
private final CRC32 b = new CRC32();
private final mr c;
private final Inflater d;
private final mx e;
public na(nk nkVar) {
if (nkVar == null) {
throw new IllegalArgumentException("source == null");
}
Inflater inflater = new Inflater(true);
this.d = inflater;
mr c = nb.c(nkVar);
this.c = c;
this.e = new mx(c, inflater);
}
@Override // com.facetec.sdk.nk
public final nh b() {
return this.c.b();
}
@Override // com.facetec.sdk.nk, java.io.Closeable, java.lang.AutoCloseable
public final void close() throws IOException {
this.e.close();
}
private void c(ms msVar, long j, long j2) {
nc ncVar = msVar.b;
while (j >= ncVar.a - ncVar.e) {
j -= ncVar.a - ncVar.e;
ncVar = ncVar.i;
}
while (j2 > 0) {
int min = (int) Math.min(ncVar.a - r6, j2);
this.b.update(ncVar.b, (int) (ncVar.e + j), min);
j2 -= min;
ncVar = ncVar.i;
j = 0;
}
}
private static void c(String str, int i, int i2) throws IOException {
if (i2 != i) {
throw new IOException(String.format("%s: actual 0x%08x != expected 0x%08x", str, Integer.valueOf(i2), Integer.valueOf(i)));
}
}
@Override // com.facetec.sdk.nk
public final long b(ms msVar, long j) throws IOException {
long j2;
if (j < 0) {
throw new IllegalArgumentException("byteCount < 0: ".concat(String.valueOf(j)));
}
if (j == 0) {
return 0L;
}
if (this.a == 0) {
this.c.e(10L);
byte c = this.c.d().c(3L);
boolean z = ((c >> 1) & 1) == 1;
if (z) {
c(this.c.d(), 0L, 10L);
}
c("ID1ID2", 8075, this.c.i());
this.c.f(8L);
if (((c >> 2) & 1) == 1) {
this.c.e(2L);
if (z) {
c(this.c.d(), 0L, 2L);
}
long j3 = this.c.d().j();
this.c.e(j3);
if (z) {
j2 = j3;
c(this.c.d(), 0L, j3);
} else {
j2 = j3;
}
this.c.f(j2);
}
if (((c >> 3) & 1) == 1) {
long s = this.c.s();
if (s == -1) {
throw new EOFException();
}
if (z) {
c(this.c.d(), 0L, s + 1);
}
this.c.f(s + 1);
}
if (((c >> 4) & 1) == 1) {
long s2 = this.c.s();
if (s2 == -1) {
throw new EOFException();
}
if (z) {
c(this.c.d(), 0L, s2 + 1);
}
this.c.f(s2 + 1);
}
if (z) {
c("FHCRC", this.c.j(), (short) this.b.getValue());
this.b.reset();
}
this.a = 1;
}
if (this.a == 1) {
long j4 = msVar.e;
long b = this.e.b(msVar, j);
if (b != -1) {
c(msVar, j4, b);
return b;
}
this.a = 2;
}
if (this.a == 2) {
c("CRC", this.c.f(), (int) this.b.getValue());
c("ISIZE", this.c.f(), (int) this.d.getBytesWritten());
this.a = 3;
if (!this.c.a()) {
throw new IOException("gzip finished without exhausting source");
}
}
return -1L;
}
}