use of java.security.NoSuchAlgorithmException in project android_frameworks_base by ParanoidAndroid.
the class SslCertificate method getDigest.
/**
* Convenience for UI presentation, not intended as public API.
*/
private static String getDigest(X509Certificate x509Certificate, String algorithm) {
if (x509Certificate == null) {
return "";
}
try {
byte[] bytes = x509Certificate.getEncoded();
MessageDigest md = MessageDigest.getInstance(algorithm);
byte[] digest = md.digest(bytes);
return fingerprint(digest);
} catch (CertificateEncodingException ignored) {
return "";
} catch (NoSuchAlgorithmException ignored) {
return "";
}
}
use of java.security.NoSuchAlgorithmException in project android_frameworks_base by ParanoidAndroid.
the class RequestHandle method H.
/**
* @return MD5 hash of param.
*/
private String H(String param) {
if (param != null) {
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
byte[] d = md5.digest(param.getBytes());
if (d != null) {
return bufferToHex(d);
}
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
return null;
}
use of java.security.NoSuchAlgorithmException in project LolliPin by OrangeGangsters.
the class FingerprintUiHelper method initCipher.
/**
* Initialize the {@link Cipher} instance with the created key in the {@link #createKey()}
* method.
*
* @return {@code true} if initialization is successful, {@code false} if the lock screen has
* been disabled or reset after the key was generated, or if a fingerprint got enrolled after
* the key was generated.
*/
private boolean initCipher() {
try {
if (mKeyStore == null) {
mKeyStore = KeyStore.getInstance("AndroidKeyStore");
}
createKey();
mKeyStore.load(null);
SecretKey key = (SecretKey) mKeyStore.getKey(KEY_NAME, null);
mCipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
mCipher.init(Cipher.ENCRYPT_MODE, key);
return true;
} catch (NoSuchPaddingException | KeyStoreException | CertificateException | UnrecoverableKeyException | IOException | NoSuchAlgorithmException | InvalidKeyException e) {
return false;
}
}
use of java.security.NoSuchAlgorithmException in project android_frameworks_base by ParanoidAndroid.
the class BackupManagerService method buildCharArrayKey.
private SecretKey buildCharArrayKey(char[] pwArray, byte[] salt, int rounds) {
try {
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
KeySpec ks = new PBEKeySpec(pwArray, salt, rounds, PBKDF2_KEY_SIZE);
return keyFactory.generateSecret(ks);
} catch (InvalidKeySpecException e) {
Slog.e(TAG, "Invalid key spec for PBKDF2!");
} catch (NoSuchAlgorithmException e) {
Slog.e(TAG, "PBKDF2 unavailable!");
}
return null;
}
use of java.security.NoSuchAlgorithmException in project android_frameworks_base by ParanoidAndroid.
the class ConfigUpdateInstallReceiver method getCurrentHash.
private static String getCurrentHash(byte[] content) {
if (content == null) {
return "0";
}
try {
MessageDigest dgst = MessageDigest.getInstance("SHA512");
byte[] fingerprint = dgst.digest(content);
return IntegralToString.bytesToHexString(fingerprint, false);
} catch (NoSuchAlgorithmException e) {
throw new AssertionError(e);
}
}
Aggregations