what-the-bank/sources/org/bouncycastle/asn1/x509/KeyUsage.java

75 lines
2.3 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.asn1.x509;
import com.google.common.primitives.UnsignedBytes;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.DERBitString;
/* loaded from: classes6.dex */
public class KeyUsage extends ASN1Object {
public static final int cRLSign = 2;
public static final int dataEncipherment = 16;
public static final int decipherOnly = 32768;
public static final int digitalSignature = 128;
public static final int encipherOnly = 1;
public static final int keyAgreement = 8;
public static final int keyCertSign = 4;
public static final int keyEncipherment = 32;
public static final int nonRepudiation = 64;
private DERBitString bitString;
public String toString() {
StringBuilder sb;
int i;
byte[] bytes = this.bitString.getBytes();
if (bytes.length == 1) {
sb = new StringBuilder("KeyUsage: 0x");
i = bytes[0] & UnsignedBytes.MAX_VALUE;
} else {
sb = new StringBuilder("KeyUsage: 0x");
i = (bytes[0] & UnsignedBytes.MAX_VALUE) | ((bytes[1] & UnsignedBytes.MAX_VALUE) << 8);
}
sb.append(Integer.toHexString(i));
return sb.toString();
}
@Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
public ASN1Primitive toASN1Primitive() {
return this.bitString;
}
public boolean hasUsages(int i) {
return (this.bitString.intValue() & i) == i;
}
public int getPadBits() {
return this.bitString.getPadBits();
}
public byte[] getBytes() {
return this.bitString.getBytes();
}
public static KeyUsage getInstance(Object obj) {
if (obj instanceof KeyUsage) {
return (KeyUsage) obj;
}
if (obj != null) {
return new KeyUsage(DERBitString.getInstance(obj));
}
return null;
}
public static KeyUsage fromExtensions(Extensions extensions) {
return getInstance(extensions.getExtensionParsedValue(Extension.keyUsage));
}
private KeyUsage(DERBitString dERBitString) {
this.bitString = dERBitString;
}
public KeyUsage(int i) {
this.bitString = new DERBitString(i);
}
}