I’m trying to encrypt a string with rijndael (keysize 256 bit, blocksize 256 bit, CFB mode)
currently i’m doing something like this:
BufferedBlockCipher c = new BufferedBlockCipher(new CFBBlockCipher(new RijndaelEngine(256), 256));
c.init(false, new ParametersWithIV(new KeyParameter(keybytes), iv));
I can encrypt and decrypt my own stuff just fine. Unfortunately the string i have to decrypt comes from mcrypt in php.
I cant decrypt this string and i guess the failure is on my side. could anybody give me an example how to configure a cipher with the required parameters?
EDIT:
following some advice here and in the php documentation comments. i changed my cypher to:
PaddedBufferedBlockCipher c = new PaddedBufferedBlockCipher(new CFBBlockCipher(new RijndaelEngine(256)), new ZeroBytePadding());
still the encryptions are not compatible.
EDIT 2
got it working in CBC mode. I guess the problem is somewhere in iv.
this did the trick. All examples and tutorials say that the second param of the CFBBlockCipher object is the blocksize of the chiffre, which would work, but mcrypt uses a blocksize of 8 bit for CFB.