use of org.bouncycastle.crypto.InvalidCipherTextException in project OsmAnd-tools by osmandapp.
the class SigningUtils method encryptPassphrase.
/**
* Used only for testing: encrypt secret passphrase
* @param plain plain passphrase
* @param key secret key
* @return encrypted passphrase
* @throws BlockIOException
*/
static byte[] encryptPassphrase(String plain, byte[] key) throws BlockIOException {
PaddedBufferedBlockCipher aes = new PaddedBufferedBlockCipher(new AESEngine());
CipherParameters aesKey = new KeyParameter(key);
aes.init(true, aesKey);
try {
return cipherData(aes, plain.getBytes("UTF-8"));
} catch (InvalidCipherTextException e) {
throw new BlockIOException("Unexpected error while signing transaction. Please file an issue report.");
} catch (UnsupportedEncodingException e) {
throw new BlockIOException("Your system does not seem to support UTF-8 encoding! Aborting signing process.");
}
}
Aggregations