what-the-bank/sources/org/bouncycastle/jcajce/provider/asymmetric/rsa/ISOSignatureSpi.java

153 lines
5.5 KiB
Java

package org.bouncycastle.jcajce.provider.asymmetric.rsa;
import java.security.InvalidKeyException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SignatureException;
import java.security.SignatureSpi;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.AlgorithmParameterSpec;
import org.bouncycastle.crypto.AsymmetricBlockCipher;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.crypto.digests.MD5Digest;
import org.bouncycastle.crypto.digests.RIPEMD160Digest;
import org.bouncycastle.crypto.digests.SHA1Digest;
import org.bouncycastle.crypto.digests.SHA224Digest;
import org.bouncycastle.crypto.digests.SHA256Digest;
import org.bouncycastle.crypto.digests.SHA384Digest;
import org.bouncycastle.crypto.digests.SHA512Digest;
import org.bouncycastle.crypto.digests.SHA512tDigest;
import org.bouncycastle.crypto.digests.WhirlpoolDigest;
import org.bouncycastle.crypto.engines.RSABlindedEngine;
import org.bouncycastle.crypto.signers.ISO9796d2Signer;
import org.jmrtd.PassportService;
/* loaded from: classes6.dex */
public class ISOSignatureSpi extends SignatureSpi {
private ISO9796d2Signer signer;
@Override // java.security.SignatureSpi
protected boolean engineVerify(byte[] bArr) throws SignatureException {
return this.signer.verifySignature(bArr);
}
@Override // java.security.SignatureSpi
protected void engineUpdate(byte[] bArr, int i, int i2) throws SignatureException {
this.signer.update(bArr, i, i2);
}
@Override // java.security.SignatureSpi
protected void engineUpdate(byte b) throws SignatureException {
this.signer.update(b);
}
@Override // java.security.SignatureSpi
protected byte[] engineSign() throws SignatureException {
try {
return this.signer.generateSignature();
} 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 void engineInitVerify(PublicKey publicKey) throws InvalidKeyException {
this.signer.init(false, RSAUtil.generatePublicKeyParameter((RSAPublicKey) publicKey));
}
@Override // java.security.SignatureSpi
protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException {
this.signer.init(true, RSAUtil.generatePrivateKeyParameter((RSAPrivateKey) privateKey));
}
/* loaded from: classes6.dex */
public static class MD5WithRSAEncryption extends ISOSignatureSpi {
public MD5WithRSAEncryption() {
super(new MD5Digest(), new RSABlindedEngine());
}
}
/* loaded from: classes6.dex */
public static class RIPEMD160WithRSAEncryption extends ISOSignatureSpi {
public RIPEMD160WithRSAEncryption() {
super(new RIPEMD160Digest(), new RSABlindedEngine());
}
}
/* loaded from: classes6.dex */
public static class SHA1WithRSAEncryption extends ISOSignatureSpi {
public SHA1WithRSAEncryption() {
super(new SHA1Digest(), new RSABlindedEngine());
}
}
/* loaded from: classes6.dex */
public static class SHA224WithRSAEncryption extends ISOSignatureSpi {
public SHA224WithRSAEncryption() {
super(new SHA224Digest(), new RSABlindedEngine());
}
}
/* loaded from: classes6.dex */
public static class SHA256WithRSAEncryption extends ISOSignatureSpi {
public SHA256WithRSAEncryption() {
super(new SHA256Digest(), new RSABlindedEngine());
}
}
/* loaded from: classes6.dex */
public static class SHA384WithRSAEncryption extends ISOSignatureSpi {
public SHA384WithRSAEncryption() {
super(new SHA384Digest(), new RSABlindedEngine());
}
}
/* loaded from: classes6.dex */
public static class SHA512WithRSAEncryption extends ISOSignatureSpi {
public SHA512WithRSAEncryption() {
super(new SHA512Digest(), new RSABlindedEngine());
}
}
/* loaded from: classes6.dex */
public static class SHA512_224WithRSAEncryption extends ISOSignatureSpi {
public SHA512_224WithRSAEncryption() {
super(new SHA512tDigest(PassportService.DEFAULT_MAX_BLOCKSIZE), new RSABlindedEngine());
}
}
/* loaded from: classes6.dex */
public static class SHA512_256WithRSAEncryption extends ISOSignatureSpi {
public SHA512_256WithRSAEncryption() {
super(new SHA512tDigest(256), new RSABlindedEngine());
}
}
/* loaded from: classes6.dex */
public static class WhirlpoolWithRSAEncryption extends ISOSignatureSpi {
public WhirlpoolWithRSAEncryption() {
super(new WhirlpoolDigest(), new RSABlindedEngine());
}
}
@Override // java.security.SignatureSpi
protected Object engineGetParameter(String str) {
throw new UnsupportedOperationException("engineSetParameter unsupported");
}
protected ISOSignatureSpi(Digest digest, AsymmetricBlockCipher asymmetricBlockCipher) {
this.signer = new ISO9796d2Signer(asymmetricBlockCipher, digest, true);
}
}