Search code examples
javaphpencryptioncryptographymcrypt

What is the Java equivalent of mcrypt "ncfb" mode?


I'm trying to port some code from PHP to java and this line is giving me trouble:

$decrypted = mcrypt_decrypt(MCRYPT_BLOWFISH, $key, $encrypted, "ncfb", $iv);

Looking through the javadocs on ciphers there is no 'ncfb' listed, is one of the other modes listed ncfb in disguise?


Solution

  • From this answer:

    Note that CFB and OFB in the rest of the document represent the "8bit CFB or OFB" mode. nOFB and nCFB modes represents a n-bit OFB/CFB mode, n is used to represent the algorithm's block size.

    nCFB: The Cipher-Feedback Mode (in nbit). n Is the size of the block of the algorithm. This is a self synchronizing stream cipher implemented from a block cipher. This mode operates in streams.

    Based on this doc there are following modes (nCFB) available for Blowfish in Java:

    CFB8..CFB64

    So the answer would be: yes, there are modes equivalent to nCFB in disguise.