I\'ve got a message contained in an byte[], encrypted with \"RSA/ECB/PKCS1Padding\". To decrypt it I create a Cipher c and initiate it with
c = Cipher.getIns
I think using RSA encryption for anything but key transport is abuse.
Generate a new key for a symmetric cipher and encrypt your bulk data with that. Then encrypt the key with RSA. Send the symmetrically-encrypted cipher-text along with the asymmetrically-encrypted content encryption key to your recipient.
Like Erickson said,
The steps you should take encrypt are:
To decrypt:
With RSA you can only encrypt/decrypt block with size up to your key length minus padding length. If you have data longer than your key maybe it is just merged in one array so you should split it into chunks with size of your key (128 bytes suggests 1024 key with no padding, I'm not sure if it's possible). Using update() is not the case here.
Simply, you have to know how this array was created.
Generally speaking, RSA shouldn't be used to encrypt large amount of data as it's quite time consuming. Should be used to encrypt key to symmetric cipher, like AES.
Take a look here: https://www.owasp.org/index.php/Digital_Signature_Implementation_in_Java