115 lines
3.3 KiB
Java
115 lines
3.3 KiB
Java
package org.spongycastle.asn1;
|
|
|
|
import com.google.common.primitives.UnsignedBytes;
|
|
import java.io.IOException;
|
|
import java.math.BigInteger;
|
|
import o.AbstractC15315gnE;
|
|
import o.AbstractC15321gnP;
|
|
import o.InterfaceC15342gnr;
|
|
import o.gnD;
|
|
import o.gnG;
|
|
import o.goV;
|
|
import o.grK;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public final class ASN1Integer extends AbstractC15315gnE {
|
|
public final byte[] b;
|
|
|
|
@Override // o.AbstractC15315gnE
|
|
public final boolean d() {
|
|
return false;
|
|
}
|
|
|
|
public static ASN1Integer e(Object obj) {
|
|
if (obj == null || (obj instanceof ASN1Integer)) {
|
|
return (ASN1Integer) obj;
|
|
}
|
|
if (obj instanceof byte[]) {
|
|
try {
|
|
return (ASN1Integer) b((byte[]) obj);
|
|
} catch (Exception e) {
|
|
StringBuilder sb = new StringBuilder("encoding error in getInstance: ");
|
|
sb.append(e.toString());
|
|
throw new IllegalArgumentException(sb.toString());
|
|
}
|
|
}
|
|
StringBuilder sb2 = new StringBuilder("illegal object in getInstance: ");
|
|
sb2.append(obj.getClass().getName());
|
|
throw new IllegalArgumentException(sb2.toString());
|
|
}
|
|
|
|
public static ASN1Integer d(AbstractC15321gnP abstractC15321gnP, boolean z) {
|
|
InterfaceC15342gnr interfaceC15342gnr = abstractC15321gnP.d;
|
|
AbstractC15315gnE i = interfaceC15342gnr != null ? interfaceC15342gnr.i() : null;
|
|
if (z || (i instanceof ASN1Integer)) {
|
|
return e((Object) i);
|
|
}
|
|
InterfaceC15342gnr interfaceC15342gnr2 = abstractC15321gnP.d;
|
|
return new ASN1Integer(gnD.b(interfaceC15342gnr2 != null ? interfaceC15342gnr2.i() : null).b());
|
|
}
|
|
|
|
public ASN1Integer(long j) {
|
|
this.b = BigInteger.valueOf(j).toByteArray();
|
|
}
|
|
|
|
public ASN1Integer(BigInteger bigInteger) {
|
|
this.b = bigInteger.toByteArray();
|
|
}
|
|
|
|
private ASN1Integer(byte[] bArr) {
|
|
this(bArr, true);
|
|
}
|
|
|
|
public ASN1Integer(byte[] bArr, boolean z) {
|
|
if (z) {
|
|
if (bArr == null) {
|
|
bArr = null;
|
|
} else {
|
|
byte[] bArr2 = new byte[bArr.length];
|
|
System.arraycopy(bArr, 0, bArr2, 0, bArr.length);
|
|
bArr = bArr2;
|
|
}
|
|
}
|
|
this.b = bArr;
|
|
}
|
|
|
|
@Override // o.AbstractC15315gnE
|
|
public final int c() {
|
|
return goV.d(this.b.length) + 1 + this.b.length;
|
|
}
|
|
|
|
@Override // o.AbstractC15346gnv
|
|
public final int hashCode() {
|
|
int i = 0;
|
|
int i2 = 0;
|
|
while (true) {
|
|
byte[] bArr = this.b;
|
|
if (i == bArr.length) {
|
|
return i2;
|
|
}
|
|
i2 ^= (bArr[i] & UnsignedBytes.MAX_VALUE) << (i % 4);
|
|
i++;
|
|
}
|
|
}
|
|
|
|
@Override // o.AbstractC15315gnE
|
|
public final boolean e(AbstractC15315gnE abstractC15315gnE) {
|
|
if (abstractC15315gnE instanceof ASN1Integer) {
|
|
return grK.b(this.b, ((ASN1Integer) abstractC15315gnE).b);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // o.AbstractC15315gnE
|
|
public final void c(gnG gng) throws IOException {
|
|
byte[] bArr = this.b;
|
|
gng.a(2);
|
|
gng.d(bArr.length);
|
|
gng.a.write(bArr);
|
|
}
|
|
|
|
public final String toString() {
|
|
return new BigInteger(this.b).toString();
|
|
}
|
|
}
|