Title: INTROSEC / symmetric_cryptography
Tags: symmetric_cryptography block_cipher classic_cryptography hash_functions message_authentication_codes perfect_secrecy authenticated_encryption modern_cryptography stream_cipher

What is the difference between symmetric and assymettric cryptography?

Q: Explain the Shift Cipher (Ceasar Cipher).
A: Each letter of the plaintext is replaced by a letter some fixed number of positions further down the alphabet. After the last letter, counting starts again from the beginning of the alphabet. The fixed number of positions is the cryptographic key of the scheme.

Q: How large is the key space of the Shift (Caesar) Cipher?
A: \(\text{alphabet length}-1\)

Q: Explain Monoalphabetic Substitution.
A: Each plaintext symbol is replaced with a (possibly) different symbol in the ciphertext.

Q: What is the Vigenère Cipher?
A: The Vigenère cipher is a Substitution Cipher which hides the letter frequency by performing different substitutions depending on the letter’s position in the plaintext.
- The key is a sequence of numbers (of arbitrary length)
- Every plaintext letter is assigned a number from the key
- The key is cyclically repeated if shorter than the plaintext
- Each number represents the size of a shift in the alphabet
- Bruteforcing is infeasible

Q: Explain Columnar Transposition
A: - key is a list of numbers (of length \(l\)) containing each number from 1 to \(l\)
- plaintext is entered line by line into a matrix with \(l\) columns
- ciphertex is obtained by reading the matrix column by column

Q: What is the definition of Correctness of a Symmetric Encryption Scheme?
A: \(Dec(k, Enc(k, m)) = m\)

Q: What is perfect secrecy?
A: An encryption scheme provides perfect secrecy if a ciphertext does not reveal any information about the corresponding plaintext.

What is the formal definition of Perfect Secrecy?

Q: How long does a key need to be at leasat for perfect ciphers?
A: \(|K|\ge|M|\)

Q: What is the One-Time-Pad Cipher?
A: First perfect secrecy cipher. Bitwise XOR operation on the bitstrings of the messange and key.

Q: What is a product cipher?
A: A product cipher is a cipher that consists of the combination of multiple, possibly iterated transformations.

Q: What is Confusion?
A: Confusion: No relationship between plaintext and ciphertext should be recognizable.

Q: What is diffusion?
A: Diffusion: every bit of the plaintext and the key should spread over the ciphertext and influence as many of its bits as possible.

What is the difference between block and stream ciphers?

Q: Explain Stream Ciphers
A: Stream Ciphers are an approximation of the One-Time-Pad. The key is used as a seed for a pseudorandom generator (PRG). The PRG genersates the keystream, which is combined with the plaintext via XOR.
PRG State is updated periodically, e.g. before key generation.
No perfect secrecy.

Q: What does it mean if an encryption algorithm is malleable?
A: An encryption algorithm is malleable if it is possible to transform a ciphertext into another one that decrypts to a message bearing some relation with the original plaintext.

Q: What is AES Encryption?
A: The AES encryption algorithm operates by iteratively applying a series of substitution, permutation, and mixing operations to input data blocks, using a key to guide these transformations.

Q: How does the SubBytes Step work in AES?
A: Every byte in the current state is substituted with another byte according to a fixed substitution table (S-Box).

Q: How does the ShiftRows step work in AES?
A: State elements are left shifted by an offset that depends on the line.

Q: How does the MixColumn Step in AES work?
A: Each column of the state is multiplied with a fixed matrix. In this way, each input byte affects all output bytes and therefore contributes to diffusion.

Q: How does the AddRoundKey Step in AES work?
A: The subkey (128 bit) for the current round is XORed with the current state.

Q: What is "Modes of Operation"?
A: A mode of operation is an algorithm that determines how to use a block cipher to process messages larger than a block.

Q: Explain the characteristics of Modes of Operation.
A: - Parallelization - Possibility to parallelize encryption or decryption of message blocks
- Random read access - Possibility to access the content of a specific message block without decrypting all preceding blocks
- Error propagation - Impact of a change in the ciphertext to the decrypted plaintext

Q: How does Electronic Code Book Mode (ECB) work?
A: Plaintext blocks of a message are encrypted independently from each other.

Q: What are common issues of ECB (Electronic Code Book Mode)?
A: ● Patterns in the plaintext are visible in the ciphertext
● Strong malleability: new ciphertexts (for a given key) can be generated by piecing together blocks from previously observed ciphertexts

Q: How does the Cipher Block Chaining Mode (CBC) work?
A: Each message block is XORed with the encryption of the previous block before being encrypted. The first block uses a randomly generated initialization vector, which is typically prepended to the ciphertext.

What is the major difference between ECB and CBC?

Q: How does Counter Mode (CTR) work?
A: Counter Mode implements a stream cipher, starting from a block cipher.
A random nonce, followed by a counter is encrypted by the key. This XORed by the message generates the ciphertext. As this is a per-block operation, CTR enables random read access and parallelization.

Q: How does the PKCS#7 padding algorithm work?
A: - If N bytes are missing in the last block, add \(N\) bytes with value \(N\)
- If the last block is full, add a new block where all bytes match the block size

Q: What is the definition of a hash function?
A: A hash function is any function that maps inputs of arbitrary size to outputs of a fixed size.

Q: What are desired properties of hash functions?
A: - very fast
- minimal number of collisions

Q: What are the properties of cryptographic hash functions? (4)
A: - One-way: easy to compute hash for an input, infeasible to compute an input that maps to a given hash value
- Uniformity: probability of obtaining a particular n-bit output for a random input should be \(2^{-n}\)
- Diffusion: each bit of the input message should affect as many output bits as possible
- Collision resistance

Q: What are hash functions used for?
A: - Ensure integrity of messages and files
- Digital signatures
- Password storage

Q: What are Message Authentication Codes (MAC) and what are they used for?
A: MACs are used to guarantee the integrity and authenticity of a message.
They are based on block ciphers or hash functions and need a shared key for generation and verification.

Q: How deos CBC-MAC work?
A: A block cipher is used to encrypt the messages in CBC mode (with null initialisation vector).
MAC is the block resulting from the last encryption.
Only secure for fixed length messages.

Q: What is the difference between CBC-Mac and encryptec CBC-Mac
A: In encrypted CBC-Mac the last block (MAC of the CBC-MAC scheme) is encrypted under a different key. This makes it secure to use with variable-length messages.

What is HMAC and how does it work?

Q: What is Encrypt-then-MAC?
A: First the plaintext is encrypted, then a MAC is computed over the ciphertext.

Q: What is MAC-then-Encrypt?
A: he MAC is computed over the plaintext, then
plaintext and MAC are encrypted together.

Q: What is Encrypt-and-Mac?
A: The plaintext is encrypted, the MAC is also
computed over the plaintext.