How do I check if the output of my CFB TEA encryption algorithm is correct? I have an assignment question regarding the TEA cipher in CFB mode. After much difficulty and research, I managed to produce an 8-bit TEA / CFB encryption algorithm. My input is supposed to be a number in string format; for example; "12345678".

This is the result of the encryption



However, i do not have any way to check if the encrypted message is indeed correct. 

I do understand a way to find out if it is correct is by programming a CFB mode decryption. Unfortunately, THE decryption of the ciphertext I generated is different from the initial plaintext. 

Hence, I'm a little confused on whether is it my encryption that is incorrect or is my decryption that is incorrect.

Is there any way to verify if the encrypted message output is correct? Or is the CFB mode decryption method the only way to verify?
No, there are of course other methods of verifying your implementation.

Note that there are a few separate steps that can be distinguished:


the TEA block cipher;
the CFB mode (using the right number of bits to forward);
The encoding of the message and ciphertext.


First, test your block cipher (without CFB mode of operation) against any available test vectors. There seem to be a few available.

Second, test your CFB mode of encryption with a well known block cipher, e.g. DES, Triple-DES or blowfish (all come with 64 bit block size, just like TEA). You will need to establish key, IV and number of bits that are forwarded within CFB mode encryption (CFB-8 or CFB-64?).

Thirdly, test your encoding / decoding. You should treat the output of TEA as binary, not as text. For the input message you need a well described, canonical way of creating a message using numbers. Of course this encoding / decoding must be reversible. The codec should be tested separately first.

Finally, try and see if the combination of all three works as expected. If you cannot find text vectors directly then try and use a different implementation (and test that against text vectors first).



You could also use a third party implementation to create intermediate values, so you can verify the correctness of your implementation.

Here's a test vector created using Bouncy Castle (Java, v1.57) and, of course, hexadecimals to represent the bytes:

TEA in CFB-8 mode
K : 2c1003d83c3c3707a92a10f45a3bd72f
IV: 681574192889be9d
M : 3132333435363738
C : d2751754c6699453


This is the kind of representation you need to test. Note that the input message M consists of the ASCII encoding of the string "12345678". The 128 bit key and full 64 bit IV have been randomized.