what-the-bank/sources/org/bouncycastle/asn1/isismtt/ocsp/CertHash.java

62 lines
2.3 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.asn1.isismtt.ocsp;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
/* loaded from: classes6.dex */
public class CertHash extends ASN1Object {
private byte[] certificateHash;
private AlgorithmIdentifier hashAlgorithm;
@Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector aSN1EncodableVector = new ASN1EncodableVector();
aSN1EncodableVector.add(this.hashAlgorithm);
aSN1EncodableVector.add(new DEROctetString(this.certificateHash));
return new DERSequence(aSN1EncodableVector);
}
public AlgorithmIdentifier getHashAlgorithm() {
return this.hashAlgorithm;
}
public byte[] getCertificateHash() {
return this.certificateHash;
}
public static CertHash getInstance(Object obj) {
if (obj == null || (obj instanceof CertHash)) {
return (CertHash) obj;
}
if (obj instanceof ASN1Sequence) {
return new CertHash((ASN1Sequence) obj);
}
StringBuilder sb = new StringBuilder("illegal object in getInstance: ");
sb.append(obj.getClass().getName());
throw new IllegalArgumentException(sb.toString());
}
public CertHash(AlgorithmIdentifier algorithmIdentifier, byte[] bArr) {
this.hashAlgorithm = algorithmIdentifier;
byte[] bArr2 = new byte[bArr.length];
this.certificateHash = bArr2;
System.arraycopy(bArr, 0, bArr2, 0, bArr.length);
}
private CertHash(ASN1Sequence aSN1Sequence) {
if (aSN1Sequence.size() == 2) {
this.hashAlgorithm = AlgorithmIdentifier.getInstance(aSN1Sequence.getObjectAt(0));
this.certificateHash = DEROctetString.getInstance(aSN1Sequence.getObjectAt(1)).getOctets();
} else {
StringBuilder sb = new StringBuilder("Bad sequence size: ");
sb.append(aSN1Sequence.size());
throw new IllegalArgumentException(sb.toString());
}
}
}