96 lines
3.6 KiB
Java
96 lines
3.6 KiB
Java
package org.bouncycastle.asn1;
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.IOException;
|
|
import org.bouncycastle.util.Arrays;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public class DERUniversalString extends ASN1Primitive implements ASN1String {
|
|
private static final char[] table = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
|
private final byte[] string;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // org.bouncycastle.asn1.ASN1Primitive
|
|
public boolean isConstructed() {
|
|
return false;
|
|
}
|
|
|
|
public String toString() {
|
|
return getString();
|
|
}
|
|
|
|
@Override // org.bouncycastle.asn1.ASN1Primitive, org.bouncycastle.asn1.ASN1Object
|
|
public int hashCode() {
|
|
return Arrays.hashCode(this.string);
|
|
}
|
|
|
|
@Override // org.bouncycastle.asn1.ASN1String
|
|
public String getString() {
|
|
StringBuffer stringBuffer = new StringBuffer("#");
|
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
try {
|
|
new ASN1OutputStream(byteArrayOutputStream).writeObject(this);
|
|
byte[] byteArray = byteArrayOutputStream.toByteArray();
|
|
for (int i = 0; i != byteArray.length; i++) {
|
|
char[] cArr = table;
|
|
stringBuffer.append(cArr[(byteArray[i] >>> 4) & 15]);
|
|
stringBuffer.append(cArr[byteArray[i] & 15]);
|
|
}
|
|
return stringBuffer.toString();
|
|
} catch (IOException unused) {
|
|
throw new ASN1ParsingException("internal error encoding BitString");
|
|
}
|
|
}
|
|
|
|
public byte[] getOctets() {
|
|
return Arrays.clone(this.string);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // org.bouncycastle.asn1.ASN1Primitive
|
|
public int encodedLength() {
|
|
return StreamUtil.calculateBodyLength(this.string.length) + 1 + this.string.length;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // org.bouncycastle.asn1.ASN1Primitive
|
|
public void encode(ASN1OutputStream aSN1OutputStream) throws IOException {
|
|
aSN1OutputStream.writeEncoded(28, getOctets());
|
|
}
|
|
|
|
@Override // org.bouncycastle.asn1.ASN1Primitive
|
|
boolean asn1Equals(ASN1Primitive aSN1Primitive) {
|
|
if (aSN1Primitive instanceof DERUniversalString) {
|
|
return Arrays.areEqual(this.string, ((DERUniversalString) aSN1Primitive).string);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static DERUniversalString getInstance(ASN1TaggedObject aSN1TaggedObject, boolean z) {
|
|
ASN1Primitive object = aSN1TaggedObject.getObject();
|
|
return (z || (object instanceof DERUniversalString)) ? getInstance(object) : new DERUniversalString(((ASN1OctetString) object).getOctets());
|
|
}
|
|
|
|
public static DERUniversalString getInstance(Object obj) {
|
|
if (obj == null || (obj instanceof DERUniversalString)) {
|
|
return (DERUniversalString) obj;
|
|
}
|
|
if (!(obj instanceof byte[])) {
|
|
StringBuilder sb = new StringBuilder("illegal object in getInstance: ");
|
|
sb.append(obj.getClass().getName());
|
|
throw new IllegalArgumentException(sb.toString());
|
|
}
|
|
try {
|
|
return (DERUniversalString) fromByteArray((byte[]) obj);
|
|
} catch (Exception e) {
|
|
StringBuilder sb2 = new StringBuilder("encoding error getInstance: ");
|
|
sb2.append(e.toString());
|
|
throw new IllegalArgumentException(sb2.toString());
|
|
}
|
|
}
|
|
|
|
public DERUniversalString(byte[] bArr) {
|
|
this.string = Arrays.clone(bArr);
|
|
}
|
|
}
|