0
$\begingroup$

Can someone please explain to me how the Cipher Feedback Mode works? From what I have read some examples have a shift register in its explanation but some examples don't. Is there two versions of CFB and what is the difference? What is and how does a shift register work?

The first picture shows the process without a shift register and the second picture uses a shift register.

Screenshots from the related video:

Image 1

Image 2

Also, in the explanation of AES on Wikipedia it says that the four steps sub bytes, shift rows, mix columns and round key addition is done in 14 cycles for a 256 bit key. Is that the case for the CFB mode as well or is that just for a different mode of operation?

$\endgroup$
  • $\begingroup$ Note that most likely the "cycles" you found there correspond to "CPU-cycles", ie the thing that your 1GHz CPU does 1 billion per second of. $\endgroup$ – SEJPM May 27 '17 at 14:35
1
$\begingroup$

To address the last bit first: CFB and AES aren't really the same thing. AES is a block encryption algorithm (encrypts a single block of data, 128-bits in the case of AES). CFB is a mode of operation, which defines how multiple blocks are encrypted, and is agnostic to the algorithm. CFB is used the same way no matter what the "Encrypt" function in the middle is.

For your first question.. I'll start by saying that I have no idea what's going on in the second photo; between the hand writing and abbreviated notations, not to mention the literal hand, I can't follow it.

But the first one is much clearer.

For each block...

  • Either the IV or previous ciphertext is encrypted using the AES algorithm (or whatever algorithm is being used) to produce what's effectively a key stream (like a stream encryption algorithm)
  • The current block of plaintext is XOR'd with the key stream to produce the ciphertext

It's basically using a block encryption algorithm (AES) as a stream encryption algorithm.

The cool thing about this is that (with the key) you can easily decrypt arbitrary data from the middle of the stream - all you need is the ciphertext of the previous block (or the IV), which you encrypt and XOR with whatever you're decrypting. But you can't encrypt new data in the middle - changing a block changes the entire rest of the cipher. So it's optimized for encrypting in-order and decrypting in any order.

Typical attacks against stream ciphers may also work; for example, you don't get any real integrity protection. Somebody can XOR a byte from the block to change it to something they control (although I suspect this can only be done in the final block, otherwise it's going to change the remainder of the ciphertext).

But yeah, I think the first diagram is pretty straight forward. No clue what the second is talking about..

$\endgroup$
  • 3
    $\begingroup$ Second is probably the 'bit-shift' or 'partial-block' form of CFB, usually designated with the number of bits like CFB-1 or CFB-8, summarized in wikipedia and detailed in SP800-38a (as cited) and previously in FIPS81 and (TTBOMK originally) FIPS74. $\endgroup$ – dave_thompson_085 May 26 '17 at 5:33
  • $\begingroup$ Okay so how many cycles is there in CFB mode? In the first figure there is 3 cycles before it outputs the final ciphertext. And also, the Block CIpher Encryption box in that figure, does that represent for example AES and all its operations such as subtypes and mixcolumns? $\endgroup$ – user48297 May 26 '17 at 9:46
  • 1
    $\begingroup$ It depends on the plaintext length. The plaintext is broken up into blocks (128 bits on AES, 64 bits on DES, etc), and each block of plaintext goes through the process. $\endgroup$ – Ron Bowes May 26 '17 at 15:57
  • $\begingroup$ Ah ok so if I have 4 blocks of data(512 bits), it would first encrypt the IV and the key and XOR that output with the plaintext, then it would use the output of that XOR operation as the IV for the next 128 bit block of data? Essentially the last output would be the last block of 128 bits? Am I correct? $\endgroup$ – user48297 May 28 '17 at 17:02
  • $\begingroup$ Yup, that sounds right! $\endgroup$ – Ron Bowes May 28 '17 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy