Block Cipher Modes

Algorithms of 5 different Block Ciphers

Block Cipher Modes:

ECB Mode (Electronic CodeBook):

Plain text divided into equal sized blocks (depends on blocksize) These blocks are encrypted using same secret to create correspondind cipertexts. These ciphertexts are combined to get the final ciphertext. As ciphertext is equal in size to the plain text. Decryption is perfomed by the same secret key. Divide secret into blocks, decrypt, combine plain texts

XOR: OR: Same bits = 0, different =1 Either or Both 1 = 1, Both 0 = 0 0 xor 0 = 0 0 or 0 = 0 0 xor 1 = 1 0 or 1 = 1 1 xor 0 = 1 1 or 0 = 1 1 xor 1 = 0 1 or 1 = 1

AND has 75 % for 0 and 25 % for 1 OR has 25% chance for 0, XOR has 50% chance for both.

XOR is best for not leaking plaintext as unable to predict plaintext from ciphertext XOR is involuntary function

Because of this: https://www.khanacademy.org/computing/computer-science/cryptography/ciphers/a/xor-and-the-one-time-pad According to khan academy,

A 24 bit image, xor with 24bit random string vs and, or with random string.

Decryption algorithm applied at decryption process.

CBC (Cipher Block Chaining):

Plain text divided into blocks. An initialization Vector (IV) is calculated. P1 = (PlainText Block 1) Previous block cipher text is XOR to current plaintext, then encrypted using secret key to get current cipher text, as no previous ciphertext for P1, hence IV is used for first ciphertext P1 XORed with IV and Encrypted using secret to get C1 (CipherText 1), in other words IV acts as ciphertext for XOR P1. This CipherText is then XORed with P2 and encryted using secret for C2, this chain is repeated till Cn. C1...Cn are concatenated to get final ciphertext.

As PlainText and CipherText are XORed, means of same length, hence if block of size 64, PT = 64 = CT, then IV = 64 as it is kinda a replacement for CipherText used for XOR of P1.

Decryption algorithm applied at decryption process.

OUTPUT(/CIPHER) FEEDBACK MODE:

Process S bits at a time. If S = 8, then IV (initialization vector) = 8^2 = 64 bits, also size of shift register is 64.

For ciphertext1 Now, with IV = 64, inside Shift Register consider 2 sections of size,

(IV - S) bits and S bits , or 64 - 8 = 56 bits and 8 bits.

This Shift Register is Encrypted using a k value, The resultant value is of 64 bits.

From this resultant, select (S bits), discard the rest (or remaining IV - S bits i.e 64 - S in this case)

The selected S bits are then XOR with the P1 (PlainText 1), to gives us the C1 (CipherText 1). note that P1 is of S bit size.

For subsequent Pn, Selected S number of bits in prior step, are sent into shift register as [(IV - S) and (S) number of bits]. The shift register gets encrypted using secret (k), from resutant select S bits and discard remaining (IV - S) number of bits. Selected S bits are XORed with P2 (size of S bits) to get C2

So on till n.

Encryption algorithm is used for decryption, the key usage is different i.e for decrypting first block, need to apply last key, while for the encryption of first block used first key.

//https://www.youtube.com/watch?v=v1JwSaAqVNY - 18:34

https://stackoverflow.com/questions/5796954/secret-vs-non-secret-initialization-vector

Cipher Feedback Mode

Sampe as Output Feedback Mode, just the cipher is used as input for subsequent shift register unlike the selected s bits post encryption used otherwise.

Encryption algorithm is used for decryption

Counter Mode

counter value = length(plaintext)

[P1(counter)k] () - encrypted with [] - XOR within

// counter encrypted using secret (k) resultant and P1 are XORed to Get C1

For second block (2nd ciphertext) // increment counter by 1 counter encrypted using secret (k) resultant and P2 are XORed to Get C2

Continue till "Counter + (N-1)" for Pn and Cn

Encryption algorithm is used for decryption

Last updated

Was this helpful?