Tag Info

New answers tagged

0

You shouldn't have to call doFinal more than once. Although in CTR Mode the blocks are independent, you can call the API functions just like you would with any other mode. The Cipher implementation will take care of increasing the counter between each block. So, with private static byte[] encrypt(final byte[] plaintext, final byte[] aesKey, final byte[] ...


2

AES-CTR is very appropriate. Since a credit card number is 16 characters long, it can be encrypted using a single 128-bit block without any encoding. You will only need 1 block, and hence not require a block counter, just the nonce. Depending on the amount of card numbers being stored, you would only need to store a portion of the full nonce. A 32-bit ...


0

From what I understand, I can use the IV as a counter, and the IV only has to be unique for each key (generating unique IVs isn't a problem). Correct? Not exactly. The IV needs to be unique for each block per key. You can use a message counter for the Nonce component of the IV, then the block counter component is incremented from 0 in CTR. IV = [ ...


0

I decided to just implement something that's known to work, namely CTR with HMAC SHA256. So you are implementing your own mode after all? Don't. Combining MAC and encryption is actually tricky. You should use a standard authenticated encryption mode, such as GCM (which is CTR plus MAC done right). From what I understand, I can use the IV as a ...



Top 50 recent answers are included