what-the-bank/sources/org/bouncycastle/jcajce/provider/asymmetric/util/DSABase.java

73 lines
2.7 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.jcajce.provider.asymmetric.util;
import java.math.BigInteger;
import java.security.SignatureException;
import java.security.SignatureSpi;
import java.security.spec.AlgorithmParameterSpec;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.x509.X509ObjectIdentifiers;
import org.bouncycastle.crypto.DSA;
import org.bouncycastle.crypto.Digest;
/* loaded from: classes6.dex */
public abstract class DSABase extends SignatureSpi implements PKCSObjectIdentifiers, X509ObjectIdentifiers {
public Digest digest;
protected DSAEncoder encoder;
public DSA signer;
@Override // java.security.SignatureSpi
protected boolean engineVerify(byte[] bArr) throws SignatureException {
byte[] bArr2 = new byte[this.digest.getDigestSize()];
this.digest.doFinal(bArr2, 0);
try {
BigInteger[] decode = this.encoder.decode(bArr);
return this.signer.verifySignature(bArr2, decode[0], decode[1]);
} catch (Exception unused) {
throw new SignatureException("error decoding signature bytes.");
}
}
@Override // java.security.SignatureSpi
protected void engineUpdate(byte[] bArr, int i, int i2) throws SignatureException {
this.digest.update(bArr, i, i2);
}
@Override // java.security.SignatureSpi
protected void engineUpdate(byte b) throws SignatureException {
this.digest.update(b);
}
@Override // java.security.SignatureSpi
protected byte[] engineSign() throws SignatureException {
byte[] bArr = new byte[this.digest.getDigestSize()];
this.digest.doFinal(bArr, 0);
try {
BigInteger[] generateSignature = this.signer.generateSignature(bArr);
return this.encoder.encode(generateSignature[0], generateSignature[1]);
} catch (Exception e) {
throw new SignatureException(e.toString());
}
}
@Override // java.security.SignatureSpi
protected void engineSetParameter(AlgorithmParameterSpec algorithmParameterSpec) {
throw new UnsupportedOperationException("engineSetParameter unsupported");
}
@Override // java.security.SignatureSpi
protected void engineSetParameter(String str, Object obj) {
throw new UnsupportedOperationException("engineSetParameter unsupported");
}
@Override // java.security.SignatureSpi
protected Object engineGetParameter(String str) {
throw new UnsupportedOperationException("engineSetParameter unsupported");
}
public DSABase(Digest digest, DSA dsa, DSAEncoder dSAEncoder) {
this.digest = digest;
this.signer = dsa;
this.encoder = dSAEncoder;
}
}