use of org.bouncycastle.crypto.params.KeyParameter in project bitcoin-wallet by bitcoin-wallet.
the class RaiseFeeDialogFragment method handleGo.
private void handleGo() {
state = State.DECRYPTING;
updateView();
final Wallet wallet = walletActivityViewModel.wallet.getValue();
if (wallet.isEncrypted()) {
new DeriveKeyTask(backgroundHandler, application.scryptIterationsTarget()) {
@Override
protected void onSuccess(final KeyParameter encryptionKey, final boolean wasChanged) {
if (wasChanged)
WalletUtils.autoBackupWallet(activity, wallet);
doRaiseFee(wallet, encryptionKey);
}
}.deriveKey(wallet, passwordView.getText().toString().trim());
updateView();
} else {
doRaiseFee(wallet, null);
}
}
use of org.bouncycastle.crypto.params.KeyParameter in project openremote by openremote.
the class SecureUtils method decryptCCM.
public static byte[] decryptCCM(@NotNull final byte[] data, @NotNull final byte[] key, @NotNull final byte[] nonce, @NotNull final byte[] additionalData, final int micSize) throws InvalidCipherTextException {
Objects.requireNonNull(data);
Objects.requireNonNull(key);
Objects.requireNonNull(nonce);
Objects.requireNonNull(additionalData);
final byte[] ccm = new byte[data.length - micSize];
final CCMBlockCipher ccmBlockCipher = new CCMBlockCipher(new AESEngine());
final AEADParameters aeadParameters = new AEADParameters(new KeyParameter(key), micSize * 8, nonce, additionalData);
ccmBlockCipher.init(false, aeadParameters);
ccmBlockCipher.processBytes(data, 0, data.length, ccm, 0);
ccmBlockCipher.doFinal(ccm, 0);
return ccm;
}
use of org.bouncycastle.crypto.params.KeyParameter in project openremote by openremote.
the class SecureUtils method calculateCMAC.
public static byte[] calculateCMAC(final byte[] data, final byte[] key) {
final byte[] cmac = new byte[16];
CipherParameters cipherParameters = new KeyParameter(key);
BlockCipher blockCipher = new AESEngine();
CMac mac = new CMac(blockCipher);
mac.init(cipherParameters);
mac.update(data, 0, data.length);
mac.doFinal(cmac, 0);
return cmac;
}
use of org.bouncycastle.crypto.params.KeyParameter in project openremote by openremote.
the class SecureUtils method encryptWithAES.
public static byte[] encryptWithAES(final byte[] data, final byte[] key) {
final byte[] encrypted = new byte[data.length];
final CipherParameters cipherParameters = new KeyParameter(key);
final AESLightEngine engine = new AESLightEngine();
engine.init(true, cipherParameters);
engine.processBlock(data, 0, encrypted, 0);
return encrypted;
}
use of org.bouncycastle.crypto.params.KeyParameter in project bitcoin-wallet by bitcoin-wallet.
the class SendCoinsFragment method handleGo.
private void handleGo() {
privateKeyBadPasswordView.setVisibility(View.INVISIBLE);
final Wallet wallet = walletActivityViewModel.wallet.getValue();
if (wallet.isEncrypted()) {
new DeriveKeyTask(backgroundHandler, application.scryptIterationsTarget()) {
@Override
protected void onSuccess(final KeyParameter encryptionKey, final boolean wasChanged) {
if (wasChanged)
WalletUtils.autoBackupWallet(activity, wallet);
signAndSendPayment(encryptionKey);
}
}.deriveKey(wallet, privateKeyPasswordView.getText().toString().trim());
setState(SendCoinsViewModel.State.DECRYPTING);
} else {
signAndSendPayment(null);
}
}
Aggregations