what-the-bank/sources/com/huawei/hms/hatool/h0.java

87 lines
3.1 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.huawei.hms.hatool;
import android.util.Base64;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import o.Yqs;
/* loaded from: classes2.dex */
public class h0 {
private static byte[] a(byte[] bArr, PublicKey publicKey) {
String str;
try {
if (publicKey == null) {
throw new UnsupportedEncodingException("The loaded public key is null");
}
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding");
cipher.init(1, publicKey);
return cipher.doFinal(bArr);
} catch (UnsupportedEncodingException unused) {
str = "rsaEncrypt(): getBytes - Unsupported coding format!";
v.f("hmsSdk", str);
return new byte[0];
} catch (InvalidKeyException unused2) {
str = "rsaEncrypt(): init - Invalid key!";
v.f("hmsSdk", str);
return new byte[0];
} catch (NoSuchAlgorithmException unused3) {
str = "rsaEncrypt(): getInstance - No such algorithm,transformation";
v.f("hmsSdk", str);
return new byte[0];
} catch (BadPaddingException unused4) {
str = "rsaEncrypt():False filling parameters!";
v.f("hmsSdk", str);
return new byte[0];
} catch (IllegalBlockSizeException unused5) {
str = "rsaEncrypt(): doFinal - The provided block is not filled with";
v.f("hmsSdk", str);
return new byte[0];
} catch (NoSuchPaddingException unused6) {
str = "rsaEncrypt(): No such filling parameters ";
v.f("hmsSdk", str);
return new byte[0];
}
}
private static PublicKey a(byte[] bArr) {
return KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(bArr));
}
public static String a(String str, byte[] bArr) {
String str2;
if (bArr == null || bArr.length == 0) {
v.f("hmsSdk", "encrypt: content is empty or null");
return "";
}
try {
return Yqs.b(a(bArr, a(Base64.decode(str, 0))));
} catch (NoSuchAlgorithmException unused) {
str2 = "encrypt(): getInstance - No such algorithm,transformation";
v.f("hmsSdk", str2);
return "";
} catch (InvalidKeySpecException unused2) {
str2 = "encrypt(): Invalid key specification";
v.f("hmsSdk", str2);
return "";
}
}
public static String a(String str, String str2) {
try {
return a(str, str2.getBytes("UTF-8"));
} catch (UnsupportedEncodingException unused) {
v.c("hmsSdk", "Unsupported encoding exception,utf-8");
return "";
}
}
}