0
$\begingroup$

I am studying about different operation modes of block ciphers my question isn't something specific to that, but is how these operation modes are used in cryptography?

I have this picture here (OFB-mode):

enter image description here (source)

I would like to know how these operations are combined with a block cipher algorithm? For example we have the DES encryption, while the DES has it's own encryption method where does these operations intersect with the algorithm? I mean when these operations are used in the actual DES algorithm? And why we need them if we know that the DES itself is an encryption method?

$\endgroup$
  • $\begingroup$ Do you know what $\oplus$ means? $\;$ $\endgroup$ – user991 May 27 '15 at 20:49
  • $\begingroup$ Yes is the XOR operation. $\endgroup$ – Dr. Cryptography May 27 '15 at 20:50
  • $\begingroup$ @StevePeltz so you mean that each block uses a different key? Is that in general or for the specific example of the DES (because as I know the OFB is for block ciphers in general..)? $\endgroup$ – Dr. Cryptography May 27 '15 at 21:03
  • $\begingroup$ possible duplicate of Using CBC with a fixed IV and a random first plaintext block $\endgroup$ – cygnusv May 27 '15 at 21:06
  • $\begingroup$ @cygnusv Hi sorry I don't think is a duplicate with that one because my question is about why to use that one.. $\endgroup$ – Dr. Cryptography May 27 '15 at 21:08
1
$\begingroup$

DES would be the box in your diagram that's labeled "Block Cipher Encryption", and it participates in the encryption mode you show in two ways: the output is XORed with the plaintext, and the output is used as the input to the next block's use of DES (the second "Block Cipher Encryption").

In this mode, you're using DES to generate a sequence of random blocks based on the IV and key, so it's operating as a stream cipher (which means you must NEVER use the same IV and key more than once, in other words you need to use a new unique IV for each new set of message blocks as long as the key stays the same). OFB turns a block cipher such as DES into a stream cipher.

The requirements for an IV can be different for different modes, as are the consequences of re-using an IV with the same key.

Using the "raw" encryption algorithm on each block is known as ECB, Electronic Code Book. The reason you don't normally use ECB is that any time you encrypt the same block with the same key, you'll get the same output. This can easily yield a lot of information about the message, something that you don't want. There's a nice image showing how much information can leak using ECB mode in the Wiki link above.

The different chaining modes have different requirements, before using one you need to understand what the pitfalls, advantages and drawbacks are. In particular, most of the modes need to have some form of message authentication to prevent an attacker from changing parts of the encoded data. The way to do this with the common chaining modes is called a MAC, a Message Authentication Code. An example of a MAC is called HMAC (Hash-based message authentication code)(which, itself, is a mode of operation using some underlying hashing algorithm).

The problem with not using any message authentication (which is not the same as authenticating WHO you're talking to) is that an attacker can do many nasty things, depending on the chaining mode. This can lead to them being able to change messages or determine part or all of what's in a message.

$\endgroup$
  • $\begingroup$ Thank you. Just a last question using these operation modes is required for a block cipher I mean is something that is need to be done, or is something optional that will add more security to the crypto-text? $\endgroup$ – Dr. Cryptography May 27 '15 at 22:49
  • $\begingroup$ In practice it's required. In theory a block cipher alone can be used, but each key can only ever be used to encrypt exactly one block worth of data. So it's not exactly useful. $\endgroup$ – SAI Peregrinus May 27 '15 at 23:44
  • $\begingroup$ There are a few circumstances where you could just use ECB (with no chaining mode), but for almost any situation where you need security you'll need more than that, e.g. AES-CBC-HMAC-SHA-256 might be a specification for the encryption portion of a complete system (and that's still leaving off some details, such as when to do the MAC, or what message padding to use). $\endgroup$ – Steve Peltz May 27 '15 at 23:47
1
$\begingroup$

General descryption

The block cipher is an operation that lives in the box [block cipher encryption]. A block cipher can do two things: encrypt and decrypt. It is parametrized by a key, which is one of two inputs. The other input is a block of data. The output is the keyed permutation of that block of data. A permutation is a 1:1 relation; each input block of data will have a relationship with exactly one output block of data.

The block size of a block cipher is always the same. As there is a 1:1 relationship the input and output block sizes are identical. The key size is not directly related to the block size. Block ciphers usually have a key schedule to calculate the sub keys used for the various rounds that are invariably present in a block cipher. For DES the block size is 64 bits / 8 bytes. The key size is 56 bits or 7 bytes, not counting the parity bits.

In a block cipher mode of encryption the key always stays the same for the cipher. A key schedule can be expensive, so this is one good reason not to change keys for the block cipher for a mode of operation. The block size remains static as well.

Example: DES in OFB mode

Now if DES is inserted in the above picture showing OFB then the mode runs with a block size of 8 bytes. The block cipher therefore receives 8 bytes: the IV (initialization vector). So you can derive that the IV must be 8 bytes for OFB. This is encrypted, giving the 8 byte permutation of the original 8 bytes in return. This encrypted IV is then XORed with 8 bytes of plaintext, giving 8 bytes of ciphertext. The encrypted IV is also used as next vector to allow for the encryption of the next block of plaintext.

Why modes of operation are required

We need these modes because DES itself is completely deterministic. Giving a key you can only get the same block of output for each specific block of input. This means that if we use DES then we either have to keep to one block for each key, or we have to somehow introduce change. This change is brought by specifying a unique IV. The change is propagated to the next bytes using the mode. The mode of operation may have additional constraints besides uniqueness for the IV.

So in the end the output of the mode of operation should be indistinguishable from random. It's time to use another key if the user expects at some point that an identical block of output could be produced because the sheer amount of data being processed.

ECB

ECB is a special mode of operation: it basically just cuts the block in plaintext into block, encrypts each block and then stitches the encrypted blocks back together again. It is relatively unique in the sense that it doesn't use an IV. Because of that it is not secure, except when used on data that itself is unrelated and meaningless to an attacker. A good example would be a randomly generated key.


Notes:

  • This mode above is also known as OFB-64 or OFB-N (N being the block size) as all 64 bits are used directly to calculate the ciphertext.
$\endgroup$
  • $\begingroup$ Thank you so much. That was really helpful and solve most of my questions. I can't vote up because I don't yet have this permission, the only thing I can do is to say thank you! $\endgroup$ – Dr. Cryptography May 27 '15 at 23:18
  • $\begingroup$ OK, I'll just say you're welcome then :) $\endgroup$ – Maarten Bodewes May 27 '15 at 23:20

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.