Questions tagged [modes-of-operation]

ways of applying a block cipher to multi-block messages and enabling repeated use without changing the key.

The trivial mode of operation, ECB (Electronic Code Book), is insecure, as it maps repeated plaintext block always to the same ciphertext block.

Better encryption modes include:

  • CBC (Cipher-Block Chaining, which feeds the previous ciphertext block back into next plaintext),
  • PCBC (Propagating Cipher-Block Chaining, which feeds previous ciphertext and plaintext blocks back into the next plaintext),
  • CFB (Cipher Feedback, which feeds the previous ciphertext block into the cipher, then combines with the plaintext),
  • OFB (Output Feedback, which feeds the output of the cipher as the input for the next block, before combining with plaintext)
  • CTR (Counter, which encrypts a nounce+counter and combines the result with the plaintext)

There are also some modes which support authenticated encryption (AE), or authenticated encryption with associated data (AEAD):

  • OCB (offset codebook - adds a counter-like value to each plaintext block before and after encryption, and encrypts a checksum of the plaintext for authentication)
  • CCM (Counter with CBC-MAC, combines CTR mode with a CBC-bases MAC)
  • EAX (which combines CTR mode with OMAC for authentication and creation of an initialization vector from a nonce)
  • GCM (Galois/Counter mode, combines CTR with a new authentication based on a finite field), and its variant SGCM (Sophie Germain Counter mode, which uses a different field).
344 questions
101
votes
1 answer

What is the difference between PKCS#5 padding and PKCS#7 padding

One runtime platform provides an API that supplies PKCS#5 padding for block cipher modes such as ECB and CBC. These modes have been defined for the triple DES, AES and Blowfish block ciphers. The other platform API only provides PKCS#7 padding. Are…
Maarten Bodewes
  • 96,351
  • 14
  • 169
  • 323
92
votes
2 answers

What is the difference between CBC and GCM mode?

I am trying to learn more about GCM mode and how it differs from CBC. I already know that GCM provides a MAC, which is used for message authentication. From what I have read and from the code snippets I've seen, GCM does an exclusive-or much like…
Bob Bryan
  • 1,283
  • 2
  • 10
  • 11
83
votes
9 answers

Should I use ECB or CBC encryption mode for my block cipher?

Can someone tell me which mode out of ECB and CBC is better, and how to decide which mode to use? Are there any other modes which are better?
midhunhk
  • 1,151
  • 2
  • 13
  • 19
61
votes
3 answers

Hashing or encrypting twice to increase security?

Over on the bitcoin forums I asked why the bitcoin client computes SHA-256(SHA-256(x)) as its cryptographic hash for a variety of purposes. The leading theory--since the bitcoin author has disappeared--seems to be that from a security standpoint it…
maaku
  • 711
  • 1
  • 5
  • 4
39
votes
3 answers

Why was AES CBC removed in TLS 1.3?

I don't quite understand why AES CBC was removed in TLS1.3. From what I know CBC is the most secure Mode of operation for the AES block cipher (if you can say it like that). It only needs a TRND IV and has not been broken. If you pair it with a…
Richard R. Matthews
  • 4,545
  • 9
  • 31
  • 49
39
votes
2 answers

Why should I use Authenticated Encryption instead of just encryption?

There are various different modes of operation for block cipher use, some of which provide "encryption" and some of which provide authenticated encryption. Why should I use an authenticated encryption mode rather than just an encryption mode? This…
37
votes
1 answer

What is the advantage of XTS over CBC mode (with diffuser)?

I have some problems in understanding the "advantage" of AES-XTS compared to CBC with diffuser. I read something about FileVault, in this paper they mention the two modes of operations XTS and CBC (with diffuser) and the advantages of XTS. Both…
tommynogger
  • 473
  • 1
  • 4
  • 4
36
votes
3 answers

Practical disadvantages of GCM mode encryption

It seems that GCM mode encryption has a clear advantage over CBC + HMAC in the sense that it only requires a single key. But it seems that there are some experts here that do not trust it enough to recommend it. This question is a call to those…
33
votes
2 answers

Why do we need special key-wrap algorithms?

Wikipedia says: Key Wrap constructions are a class of symmetric encryption algorithms designed to encapsulate (encrypt) cryptographic key material. We are using these algorithms to encrypt (and authenticate) a key, using a symmetric algorithm…
24
votes
3 answers

Is AES in CBC mode secure if a known and/or fixed IV is used?

I have a need to encrypt credentials for a third-party app used by a secured internal app. Over on ITSec.SE, I was helpfully shown a scheme to encrypt the third-party credentials based on a hash of the credentials for the internal app. I picked AES…
KeithS
  • 570
  • 1
  • 3
  • 11
24
votes
1 answer

Is it safe to use a randomized IV for CTR mode?

I'm currently reading the chapter of Cryptographic Engineering (Ferguson, Schneier, Kohno 2010) about block cipher modes of operation. They have recommended CBC with random IV instead of CTR due to the difficulty of generating nonces for CTR: In…
user1114
  • 855
  • 2
  • 10
  • 26
22
votes
5 answers

Using CBC with a fixed IV and a random first plaintext block

What if, instead of using CBC mode in the normal way with a random IV, I used this approach: Use a fixed IV (like a block of 0's). Before encrypting, generate a random block and prepend it to the plaintext. After decrypting, ignore the first…
22
votes
2 answers

Is (AES-)GCM parallelizable?

I recentely faced the issue of random access decryption while AES-GCM was being used. I said this person that the underlying CTR should allow parallelization but I have no idea how authentication comes into play. Now I know that one of the cool…
SEJPM
  • 46,697
  • 9
  • 103
  • 214
21
votes
1 answer

Why choose an authenticated encryption mode instead of a separate MAC?

What are cryptographic reasons to choose an authenticated-encryption mode of operation (such as GCM) over a traditional encryption mode plus an independent MAC, or vice versa? Assume there is no implementation reason to pick one or the other (crypto…
21
votes
4 answers

Can CBC ciphertext be decrypted if the key is known, but the IV not?

Let's say that there is a binary file encrypted with AES in CBC mode (i.e. using a key and initialization vector). If key is known, but IV is not, is it easy to fully decrypt the file? How hard is it?
Ben
  • 375
  • 1
  • 3
  • 7
1
2 3
22 23