Tags

links:

https://www.thesslstore.com/blog/block-cipher-vs-stream-cipher/ (very clear)
https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf (NIST file)

https://www.highgo.ca/2019/08/08/the-difference-in-five-modes-in-the-aes-encryption-algorithm/
https://cryptopals.com/sets/3/challenges/18
https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Counter_(CTR)
https://medium.com/@arie.valiant/java-cryptography-blowfish-encryption-decryption-tutorial-1db5f2cc15f1
https://stackoverflow.com/questions/24985105/user-defined-counter-increment-function-for-blowfish-ctr-in-java

summary:

– block cipher can work like a stream cipher when it runs in some of its supported mode, for example, CTR
– javax crypto standard CTR mode does not allow custom IV nor increment
– Blowfish encryption decryption using same logic same single function,

import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

SecretKeySpec KS = new SecretKeySpec(secKey, “Blowfish”);
Cipher cipher = Cipher.getInstance(“Blowfish/ECB/NoPadding”); // ECB example
cipher.init(Cipher.ENCRYPT_MODE, KS);

byte[] plainText = “some data to be encrypted”.getBytes();
byte[] cipherText = cipher.doFinal(plainText);

CTR mode cipher (stream) is built base on block cipher (e.g. ECB) with IV/counter/nonce
– ECB block cipher does not use or need IV initialization vector
– Instead of encrypting the plaintext directly, encrypts a running counter to get a 16byte block of keystream, which is XOR’d against the plaintext

– if all counter values are known ahead of time, CTR can perform parallel encryption which is not possible with most stream ciphers