what-the-bank/sources/org/bouncycastle/asn1/pkcs/RSASSAPSSparams.java

116 lines
4.7 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.asn1.pkcs;
import java.math.BigInteger;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.DERNull;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.DERTaggedObject;
import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
/* loaded from: classes6.dex */
public class RSASSAPSSparams extends ASN1Object {
public static final AlgorithmIdentifier DEFAULT_HASH_ALGORITHM;
public static final AlgorithmIdentifier DEFAULT_MASK_GEN_FUNCTION;
public static final ASN1Integer DEFAULT_SALT_LENGTH;
public static final ASN1Integer DEFAULT_TRAILER_FIELD;
private AlgorithmIdentifier hashAlgorithm;
private AlgorithmIdentifier maskGenAlgorithm;
private ASN1Integer saltLength;
private ASN1Integer trailerField;
@Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector aSN1EncodableVector = new ASN1EncodableVector();
if (!this.hashAlgorithm.equals(DEFAULT_HASH_ALGORITHM)) {
aSN1EncodableVector.add(new DERTaggedObject(true, 0, this.hashAlgorithm));
}
if (!this.maskGenAlgorithm.equals(DEFAULT_MASK_GEN_FUNCTION)) {
aSN1EncodableVector.add(new DERTaggedObject(true, 1, this.maskGenAlgorithm));
}
if (!this.saltLength.equals(DEFAULT_SALT_LENGTH)) {
aSN1EncodableVector.add(new DERTaggedObject(true, 2, this.saltLength));
}
if (!this.trailerField.equals(DEFAULT_TRAILER_FIELD)) {
aSN1EncodableVector.add(new DERTaggedObject(true, 3, this.trailerField));
}
return new DERSequence(aSN1EncodableVector);
}
public BigInteger getTrailerField() {
return this.trailerField.getValue();
}
public BigInteger getSaltLength() {
return this.saltLength.getValue();
}
public AlgorithmIdentifier getMaskGenAlgorithm() {
return this.maskGenAlgorithm;
}
public AlgorithmIdentifier getHashAlgorithm() {
return this.hashAlgorithm;
}
public static RSASSAPSSparams getInstance(Object obj) {
if (obj instanceof RSASSAPSSparams) {
return (RSASSAPSSparams) obj;
}
if (obj != null) {
return new RSASSAPSSparams(ASN1Sequence.getInstance(obj));
}
return null;
}
public RSASSAPSSparams(AlgorithmIdentifier algorithmIdentifier, AlgorithmIdentifier algorithmIdentifier2, ASN1Integer aSN1Integer, ASN1Integer aSN1Integer2) {
this.hashAlgorithm = algorithmIdentifier;
this.maskGenAlgorithm = algorithmIdentifier2;
this.saltLength = aSN1Integer;
this.trailerField = aSN1Integer2;
}
private RSASSAPSSparams(ASN1Sequence aSN1Sequence) {
this.hashAlgorithm = DEFAULT_HASH_ALGORITHM;
this.maskGenAlgorithm = DEFAULT_MASK_GEN_FUNCTION;
this.saltLength = DEFAULT_SALT_LENGTH;
this.trailerField = DEFAULT_TRAILER_FIELD;
for (int i = 0; i != aSN1Sequence.size(); i++) {
ASN1TaggedObject aSN1TaggedObject = (ASN1TaggedObject) aSN1Sequence.getObjectAt(i);
int tagNo = aSN1TaggedObject.getTagNo();
if (tagNo == 0) {
this.hashAlgorithm = AlgorithmIdentifier.getInstance(aSN1TaggedObject, true);
} else if (tagNo == 1) {
this.maskGenAlgorithm = AlgorithmIdentifier.getInstance(aSN1TaggedObject, true);
} else if (tagNo == 2) {
this.saltLength = ASN1Integer.getInstance(aSN1TaggedObject, true);
} else {
if (tagNo != 3) {
throw new IllegalArgumentException("unknown tag");
}
this.trailerField = ASN1Integer.getInstance(aSN1TaggedObject, true);
}
}
}
public RSASSAPSSparams() {
this.hashAlgorithm = DEFAULT_HASH_ALGORITHM;
this.maskGenAlgorithm = DEFAULT_MASK_GEN_FUNCTION;
this.saltLength = DEFAULT_SALT_LENGTH;
this.trailerField = DEFAULT_TRAILER_FIELD;
}
static {
AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE);
DEFAULT_HASH_ALGORITHM = algorithmIdentifier;
DEFAULT_MASK_GEN_FUNCTION = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_mgf1, algorithmIdentifier);
DEFAULT_SALT_LENGTH = new ASN1Integer(20L);
DEFAULT_TRAILER_FIELD = new ASN1Integer(1L);
}
}