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

44 lines
2.2 KiB
Java

package org.bouncycastle.jcajce.provider.asymmetric.rsa;
import java.security.interfaces.RSAPrivateCrtKey;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.x509.X509ObjectIdentifiers;
import org.bouncycastle.crypto.params.RSAKeyParameters;
import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters;
/* loaded from: classes6.dex */
public class RSAUtil {
public static final ASN1ObjectIdentifier[] rsaOids = {PKCSObjectIdentifiers.rsaEncryption, X509ObjectIdentifiers.id_ea_rsa, PKCSObjectIdentifiers.id_RSAES_OAEP, PKCSObjectIdentifiers.id_RSASSA_PSS};
public static boolean isRsaOid(ASN1ObjectIdentifier aSN1ObjectIdentifier) {
int i = 0;
while (true) {
ASN1ObjectIdentifier[] aSN1ObjectIdentifierArr = rsaOids;
if (i == aSN1ObjectIdentifierArr.length) {
return false;
}
if (aSN1ObjectIdentifier.equals(aSN1ObjectIdentifierArr[i])) {
return true;
}
i++;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static RSAKeyParameters generatePublicKeyParameter(RSAPublicKey rSAPublicKey) {
return new RSAKeyParameters(false, rSAPublicKey.getModulus(), rSAPublicKey.getPublicExponent());
}
/* JADX INFO: Access modifiers changed from: package-private */
public static RSAKeyParameters generatePrivateKeyParameter(RSAPrivateKey rSAPrivateKey) {
if (!(rSAPrivateKey instanceof RSAPrivateCrtKey)) {
return new RSAKeyParameters(true, rSAPrivateKey.getModulus(), rSAPrivateKey.getPrivateExponent());
}
RSAPrivateCrtKey rSAPrivateCrtKey = (RSAPrivateCrtKey) rSAPrivateKey;
return new RSAPrivateCrtKeyParameters(rSAPrivateCrtKey.getModulus(), rSAPrivateCrtKey.getPublicExponent(), rSAPrivateCrtKey.getPrivateExponent(), rSAPrivateCrtKey.getPrimeP(), rSAPrivateCrtKey.getPrimeQ(), rSAPrivateCrtKey.getPrimeExponentP(), rSAPrivateCrtKey.getPrimeExponentQ(), rSAPrivateCrtKey.getCrtCoefficient());
}
}