Cryptography Unit 2
Cryptography Unit 2
Question no 1. What are streams and block cipher? Distinguish between Stream and
block cipher
Answer: Stream Cipher:
• Stream cipher is a type of encryption algorithm that operates on individual bits or
bytes of plaintext and produces a corresponding stream of ciphertext.
• It encrypts and decrypts data bit-by-bit or byte-by-byte.
• It uses a key to generate a keystream, which is then combined with the plaintext
using XOR operation to produce the ciphertext.
• Stream ciphers are generally faster in encryption and decryption compared to block
ciphers.
• Examples of stream ciphers include RC4, ChaCha20, and A5/1.
Key=01001 Key=01001
Block Cipher:
• Block cipher is a type of encryption algorithm that operates on fixed-size blocks of
plaintext and produces corresponding blocks of ciphertext.
• It encrypts and decrypts data in fixed-size blocks, typically 64 bits or more.
• It uses a key to determine the encryption and decryption transformations for each
block of plaintext.
• Block ciphers can handle larger amounts of data and provide better security than
stream ciphers.
• Examples of block ciphers include AES (Advanced Encryption Standard), DES (Data
Encryption Standard), Blowfish, and 3DES.
N Bit
KEY
N Bit
Question no. 2 Explain DES algorithm with steps and diagram
Answer:
1. The Data Encryption Standard (DES) is a symmetric encryption algorithm used to secure
sensitive data. DES is a block cipher algorithm, which means it encrypts data in fixed-size
blocks.
2. 64 bit Plain Text is passed through DES algorithm and using 56bit key 64 bit Cipher text is
obtain.
Question No. 4 What are Electronic Code Book (ECB) Algorithm Mode and Cipher Block
Chaining (CBC)? Explain
Answer:
Electronic Code Book (ECB) and Cipher Block Chaining (CBC) are two modes of operation in
block cipher algorithms. They determine how the plaintext is divided into blocks and
encrypted using the key.
1. Electronic Code Book (ECB) Algorithm Mode:
• In ECB mode, the plaintext is divided into fixed-size blocks (usually 64 or 128 bits).
• Each block is encrypted independently using the same encryption key.
• The same plaintext block will always produce the same ciphertext block.
• ECB mode is simple and easy to implement but is considered less secure because
identical plaintext blocks will result in identical ciphertext blocks, which can be
exploited by attackers.
2. Cipher Block Chaining (CBC) Algorithm Mode:
• In CBC mode, each plaintext block is XORed with the previous ciphertext block before
encryption.
• The first block is XORed with an initialization vector (IV) instead of a previous
ciphertext block.
• This XOR operation introduces randomness and dependencies between blocks,
making it more secure than ECB mode.
• CBC mode ensures that identical plaintext blocks do not produce identical ciphertext
blocks.
• To decrypt, each ciphertext block is decrypted and XORed with the previous
ciphertext block or IV.
RC 5:
• RC5 (Rivest Cipher 5) is a symmetric block cipher algorithm.
• It supports variable-length keys (0-2040 bit).
• The block size can be 32, 64, or 128 bits.
• The algorithm consists of a specific number of rounds (12,16,20).
Steps:
1. Key Expansion: Generate round keys for each round based on the original key.
2. Initialization: Set up the block size, number of rounds, and other parameters.
3. Round Function: Perform a series of rounds using mixing and transformation
operations.
4. Key Mixing: Combine each round key with a portion of the data block.
5. Data Mixing: Apply mixing operations to the data block, such as bit rotations and XOR
operations.
6. Round Feistel Network: Further mix and transform the data block using the round
function.
7. Final Round: Perform a final round using a modified version of the round function.
8. Output: Obtain the encrypted or decrypted data block as the final result.