1

I have come across the following task:

Implement a 4-bit OFB TEA algorithm

which I don't understand fully.

As far as I understand the TEA algorithm, it encrypts/decrypts 64 bits at a time. There's a variant of it called "Block TEA" which allows multiple blocks or words but still uses a 64 bit block size (I may be wrong at this). So I am confused about how nOFB can work alongside TEA to encrypt any text data.

I have been following the implementation of TEA provided by wikipedia, link - TEA Encryption. And also this - TEA Variants pdf. I am still in dark how I can combine OFB or nOFB and TEA.

All I need is some guideline or text or reference or idea that explains the above mentioned task in some details. I can implement it myself.

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263

1 Answers1

1

First of all, when you don't understand an assignment, then please ask your mentor! If the mentor doesn't answer then you probably missed some vital information. Ask around, if you cannot find anything, ask again. If still no answer is forthcoming, then escalate the issue to an advisor.

What you are likely asked to do is to implement a toy cipher. Such a toy cipher fully implements a cryptographic primitive such as TEA, however it will scale everything down to human proportions so it is easier to understand and - of course - debug. So there are tiny versions of AES and DES that can be used to learn about the algorithms and algorithm implementations.

For TEA there is Demitasse - a wordplay on tea (or coffee) served in a small cup, geddit? this is also called Simplified TEA by its original name. This cipher uses a word size of 4 bits internally, exactly what your assignment seems to require. Of course, this cipher is neither secure nor compatible with the full versions of TEA nor XTEA.

As for OFB, well, OFB is Output Feedback Mode, easily found on Wikipedia. The only question is which feedback size is required. By default I would make it easy for myself and implement full block output (nOFB, in other words, using the full 16 bit output of Demitasse / Simplified TEA), leaving 8 bit OFB as possible option if there is any time left. TEA itself is a block cipher, so if you configure it with OFB it turns itself into a full cipher providing confidentiality for binary messages with (almost) any size or contents.

In principle it is possible to perform OFB with an output size of 4 bits using the normal TEA algorithm. You just shift with 4 bits internally and output 4 bits as well. Of course, computers are very much byte-based, so this is slightly strange. Furthermore, you'd need one block encrypt per four bits which won't really help performance (however, with TEA and CPU's being pretty fast, it depends if this is an issue or not).

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
  • Hi, i am very sorry if i have given you any wrong impression. The thing is i am not from computer science or security background. i have been doing freelance programming for some earning and i was assigned to this task along with some others. i got the others done but couldn't understand the context of this one. You see i don't have any mentor, not a person or a teacher, my mentors are mostly books, experiments, web articles. So i was actually asking my mentor. Again, thanks, the paper link did help a little but not fully. – Asif Mahmud Shimon May 07 '19 at 17:43
  • I think i will first divide the incoming data bytes into word vector where word's bit size is the predefined/desired size and then perform OFB with TEA as block cipher encryption algorithm. i thought about it already but this way, i end up with larger ciphertext, whereas block ciphers are designed to produce same sized ciphertext. – Asif Mahmud Shimon May 07 '19 at 17:44
  • OFB is a stream cipher mode. If you end up with a larger ciphertext then you're doing something wrong (unless you include the IV in the ciphertext, but OK) – Maarten Bodewes May 08 '19 at 00:05