use of com.toshi.exception.KeyStoreException in project toshi-android-client by toshiapp.
the class KeystoreHandler23 method createNewKeysIfNeeded.
@Override
protected void createNewKeysIfNeeded() throws KeyStoreException {
try {
if (this.keyStore.containsAlias(this.alias))
return;
final KeyGenerator keyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, KeyStoreBase.ANDROID_KEY_STORE);
keyGenerator.init(new KeyGenParameterSpec.Builder(this.alias, KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT).setBlockModes(KeyProperties.BLOCK_MODE_GCM).setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE).setRandomizedEncryptionRequired(false).build());
keyGenerator.generateKey();
} catch (NoSuchAlgorithmException | NoSuchProviderException | InvalidAlgorithmParameterException | java.security.KeyStoreException e) {
throw new KeyStoreException(new Throwable(e.getMessage()));
}
}
Aggregations