Block Cipher Operation

Block Cipher Operation

When the amount of plaintext to be encrypted is greater than b bits, then the block cipher can still be used by breaking the plaintext into b bits. so some security issues comes so 5 mode of operations are used. 

1. Electronic Code Book (ECB)

In ECB mode plaintext is handled one block at a time and each block is encrypted using same key. 

Note 1 : The ECB is called codebook because for given key there is unique ciphertext for every plaintext so we can imagine b- bit plaintext pattern showing its corresponding ciphertext. 

The most significant thing regarding ECB is if b bits of plaintext is repeating then it will produce same ciphertext. ECB mode is generally used when we have a short message length because if the message length is large then it is not secure. 

Advantages : ECB can handles the loss of block without affecting other available blocks. 

Note 2:  if b-bits are repeating everytime then it is easy to break. 

Fig. 1: ECB (Encryption and Decryption)
For Encryption : 

Ci = E(k, Pi)

For Decryption:

Pi = D(k, Ci)

2. Cipher Block Chaining Mode (CBC) 

In case of ECB if the block of plaintext is repeated then it will produce the same ciphertext so CBC will overcome this problem. 

The input to the encryption function for each plaintext block bears no fixed relationship. 

For Encryption

C(i) = E(K, [P(i) xor C(i-1)]

For Decryption

P(i) = D(k, C(i)) xor C(i-1) 

Fig. 2: Cipher Block Chaining Mode

IV - Initialization Vector, it must be known to both sender and receiver but kept secret to third party. and IV is chosen random. 

Note 3:  What happen if IV is constant. 

Then it will show common prefix leakage. suppose we have message M1 = mo||m1||m2... and M2 = mo||m1||m3

so both message have mo||m1 as a common so it will produce C1 = co||c1||c'' and C2 = co||c1||c' which means in that case it will become quite simple to break. 

Leakage with Random IV: Assume C(i) = C(j) for some 1<=i, j<=n with i!=j 

C(i) = C(j)  --> E(k, P(i) xorC(i-1)) = E(k, P(j) xor C(j-1))

--> P(i) xorC(i-1) = P(j) xor C(j-1)

or --> P(i) xor P(j) = C(i-1) xor C(j-1) , which means info leakage. 

Note 3.1 : If a single bit is flip or lost then due to diffusion several bits get changed. 

Now, it is possible to convert a block cipher into a stream cipher, using one of the three modes to be discussed in the upcoming section i.e 3,4,5. 

3. Cipher Feedback Mode (CFB)

 The working of CFB is shown in  Fig. 3. 

Fig. 3: Cipher Feedback Mode

In shift register 'b-s' bits are come from IV and s bits are come from cipher-1

For Encryption:

For Decryption:

Advantage : There is some data loss so this is quite difficult to break. 

4. Output Feedback Mode (OFB)

The OFB mode is similar to CFB. For OFB, the output of the encryption function is fed back to become the input for encrypting function is fed back to become the input for encrypting the next block of plaintext (as shown in Fig. 4). In CFB, the output of the XOR unit is fed back to become input for encrypting the next block. 

OFB mode operates on full blocks of plaintext and ciphertext, whereas CFB operates on the s- bit subset. 

Fig. 4: Output Feedback Mode

For Encryption and For Decryption:

Advantage: Since blocks are independent of one another using the OFB mode. The lack of interdependency also means that the OFB mode is tolerant to the loss of blocks. 

Disadvantage: Repeatedly encrypting the IV may produce the same state that has occured before. 

5. Counter Mode (CTR)

The counter is equal to the size of plaintext block. The value of counter is increased by 1 for each subsequent block. 

Fig. 5: Counter Mode

Given a sequence of Counter T1, T2,...Tn so

For Encryption and Decryption:

Advantage : Good Performance due to high parallelism.

6*. XTS-AES Mode for Block Oriented Storage Device

In 2010, NIST approved an additional block cipher mode of operation, XTS-AES. It describes a method of encryption for data stored in sector based devices where the threat model includes possible access to stored data by the adversary. 

Tweakable Block Ciphers

The XTS-AES mode is based on Tweakable block cipher. A tweakable block cipher has three inputs symmetric key 'k', a tweak 'T', plaintext 'P', and Ciphertext 'C'. 

C = E(k,T,P)

K--> Kept secret, T--> purpose is to provide variability. 

Fig. 6: Tweakable Block Cipher

For Encryption:

C = H(T) xor E(k, H(T) xor P))

For Decryption:

P = H(T) xor D(k, H(T) xor C))

Operation on a single Block

The operation involves two instance of the AES algorithm with two keys. 

Fig. 7: XTS-AES operation on single Block
For Encryption and Decryption

Operation on Sector
Since XTS-AES consists of m 128-bit blocks and the last block is may be partially filled. 
In this case each block is treated as independently and in this case the last two blocks are encrypted decrypted using ciphertext -stealing technique of padding. 

NOTE 4: Ciphertext stealing stole some bits from the temporary ciphertexts (as shown in Fig. 8).

Advantage: Multiple block can be encrypted decrypted simultaneously. 

For Encryption and Decryption: 


Fig. 8: XTS-AES Mode

Comments

Popular posts from this blog

Elliptic Curve Cryptography (ECC) and ECDSA

Fast Base Conversion and Its Application

NP-Hardness vs Cryptographic Hardness