Week 3 Part 1 Flashcards
Compare between a stream cipher and a block cipher.
Stream ciphers encrypt bits/bytes but block ciphers encrypt block (128 bits). Stream ciphers have low diffusion (complexity between ciphertext and plaintext) but block ciphers have high diffusion. Stream ciphers only provide substitution but block ciphers provide substitution and transposition (change the position and order of the message) . The error propagation (changing one bit changes other bits) of stream ciphers is one symbol but block ciphers is 1 or more block. Stream ciphers are more efficient cus its easy to implement and less operations (just xoring)
What are the different multiple iterations of DES using multiple keys?
- EEE3: Encrypt 3 times using 3 different keys Enck3(Enck2(Enck1 (m)))
- EDE3: Encrypt, Decrypt, and Encrypt using 3 different keys. Enck3(Deck2(Enck1(m)))
- decrypting with a different key so it doesnt give back the same message
- EEE2: Encrypt 3 times using 2 different keys (1st and 3rd keys are the same) Enck1(Enck2(Enck1 (m)))
- EDE3: Encrypt, Decrypt, and Encrypt using 2 different keys. Enck1(Deck2(Enck1(m)))
How many bits is the key of DES? 3DES with 2 keys? 3DES with 3 keys?
56-bits, 112 bits, 168 bits
Why do we use 3DES instead of 2DES?
vulnerable to meet-in-the-middle attack:
- If attacker has a known plaintext/ciphertext pair (m, c), he/she proceeds as follows:
- Encrypt m with all possible keys and store the ciphertexts as a lookup-table
- Decrypt the ciphertext c with all possible keys
- A match between the above 2 sets reveals the right key pair
- if the key is n bits, the attack uses 2n+1 encryption/decryption steps compared to 2^2n if a native brute force is used
- If 2DES is used, the attack succeeds with only 257 steps!
What replaced 3DES? and why was it more secure?
AES
- Is a substitution- permutation network (not a feistel network)
- Substitution (S-box):Replace n-bits by another n-bits
- Provides Diffusion: One bit change in plaintext changes many bits in ciphertext
- Permutation (P-box): Bits are rearranged
- Provides Confusion: Make relationship between ciphertext and key complex
For a state array S, the key is arranged as 4 x k matrix, what is the key size when the array is 4 x 4, 4 x 6, and 4 x 8?
- 4 x 4 is n=128, k=128
- 4 x 6 is n=128, k=192
- 4 x 8 is n=128, k=256
In an AES-128 semantic cipher, what are the three steps of each round?
- SubByte: A non-linear substitution step where each byte is replaced with another according to the S-Box
- ShiftRows : A transposition step where each row of the state is shifted cyclically a certain number of times.
- MixColumns : A mixing operation which operates on the columns of the state, combining the bytes in each column. (provides diffusion) take each column and multiply by a constant matrix. reversible= just multiply by the inverse of the constant matrix
What are the benefits of AES implementation?
- Algorithms used in AES are simple and can be easily implemented using cheap processors and a minimum amount of memory
- very efficient
- one of the reasons why it was chosen
How to encrypt a message that is larger than the block size of the block cipher?
divide the message into multiple blocks (padding the last block if necessary) and encrypt them using one of the Encryption Modes
What are some encryption modes?
- Electronic Code Book (ECB)
- Cipher Block Chaining(CBC) Mode
- Counter (CTR) Mode
- Output Feedback (OFB) Mode
- Cipher Feedback Mode (CFB) Mode
How do different encryption modes work?
- ECB is the simplest but least secure because it is deterministic (Similar plaintext blocks produce similar ciphertext blocks). Each block is encrypted separately using the block cipher.
- CBC encrypts the XOR of the block with the ciphertext of the previous block, also uses IV for the first block.
- CTR uses a counter plaintext is not fed into Enc (a stream cipher mode), IV and key are fed into encryption and then XORed with the message, produce the ciphertext. Advantages: can be parallelized, Blocks are encrypted independently of one another so can be encrypted in any order (ideal for random access data)
- OFB ENC here is used as a stream cipher to generate a key stream, its like CTR but connects the blocks together
- CFB Mode is similar to OFB but uses the cipher text as IV instead of the output of the encryption oracle
In a block cipher what do we do if |m| is not a multiple of the block length?
- Padding is needed so that |m| is a multiple of |block|
- The added padding is removed after decryption
- So that we can recover the original m
Briefly explain PKCS#7 Padding
- This is a standard padding scheme used to fill up the last block of data.
- If |m| is not a multiple of |block|, append to the last block n bytes each containing the (integer) value n until |m| is a multiple of |block|
If we have a |block| = 64 bits (8 bytes), and we want to encrypt the message m = “ABC” what is the block to be encrypted (in hex)?
4142430505050505
A=41, B=42 C=43, we have 5 remaining bytes, so we put 050505
What do we do if the block size is 8 bytes and the message m is eight bytes long? m = “AAAAAAAA” also why?
If the message exactly fills the block, an entire new block of padding is added, where each byte is the block size in bytes.
Block to be encrypted (in hex) is
41414141414141410808080808080808, i.e. we added 8 bytes containing the value 08
because to differentiate it from a message ending that might coincidentally match a padding pattern.