Cryptography Flashcards
(108 cards)
Explain the Caesar Cipher & Shift Cipher and why they are different?
Caesar Cipher is a special case of the shift cipher, because it uses a usual number as a the k for its shifting of letter which is usually 3, whereas shift cipher can use any arbitrary number. Both ciphers shift the words from the alphabet e.g. A->D if shift = 3
Why is the affine cipher considered stronger than a basic shift cipher?
The affine cipher is considered stronger than the shift cipher because it adds an extra level of complexity which is to add multiplication and addition mod 26 increasing the key space.
How does modular arithmetic help define ciphers like caesar and affine?
It helps by wrapping values around the alphabet using remainders, allowing letter positions to “loop” from Z back to A, this is what makes substitution reversible.
What does it mean for 2 numbers to be congruent mod n?
Two numbers a and b are congruent mod n if n divides their difference: a = b mod n if and only if n divides a-b
When does a number have a multiplicative inverse mod n?
When it is comprime with n, i.e. gcd(a,n) = 1 for example 3 has an inverse mod 7 which is 5 but 2 has no inverse mod 4
Why is frequency analysis and brute force effective against classical substitution ciphers?
Because frequency analysis allow us to see the most frequent letters. If a cipher text uses a simple substitution common letters like ‘E’ or ‘T’ still appear more often, also with brute force because they have very small key space we can try all possible values.
Explain a stream cipher and why XOR (mod 2 addition) allow both encryption and decryption in a stream cipher?
A stream cipher encrypt one bit at a time, using a keystream that is XORed with the plaintext and we use XOR for both encryption and decryption because XOR is reversible.e
What is perfect secrecy in cryptography?
A system has perfect secrecy if the ciphertext reveals no information about the plaintext - even with infinite computing power. The OTP achieves this
Why is the one-time pad not used in practice?
Because it requires a truly random key that is as long as the message, shared securly and never reused, which makes OTP impractical for most real-world systems.
What happens if you reuse a key in a stream cipher like OTP?
It completely breaks the encryption because if you XOR two ciphertexts with the same key it removes the key and exposes relationships between plaintexts, attackers can recover both
What is a CSPRNG and how does it differ from a regular PRNG?
A CSPRNGs produces an output that is unpredictable, even if some output is known because of secure key and keystream generation, a regular PRNG like rand in C only needs to look random statistically and also public seed and guessable that.
Why are nonces important in modern stream ciphers?
They ensure a unique keystream even if the key is reused. This prevents keystream reuse attacks and enables safe encryption of multiple messages under the same key.
How can a modern stream cipher safely generate a long keystream from a short key?
By using a CSPRNG seeded with the key + a unique nonce, which generates a pseudorandom keystream on demand.
What is crib dragging, and when is it possible?
Crib dragging is an attack on reused keystreams, where the attacker guesses parts of one plaintext and uses XOR to recover parts of the other message.
What do modern stream ciphers use to generate a keystream?
They use a CSPRNG seeded with a secret key and usually a nonce, to produce a long pseudorandom keystream for XOR encryption
What is an LFSR and why is it insecure on its own?
An LFSR is a Linear-Feedback Shift Register which means its a register of bits that shifts with each clock tick just like a flip-flop, alone its insecure because its internal state can be reconstructed if enough output is known because it uses a trivial linear function.
How does Trivium improve on basic LFSRs? and what’s one problem that it has?
Trivium improves on basic LFSRs by combining three LFSRs with non-linear feedback, using AND and XOR gates, rather than just XOR like traditional LFSRs. This non-linearity makes it more resistant to reverse engineering and statistical attacks. It’s problem is that it’s a synchronous stream cipher which means there’s no way to jump anywhere in a file system using this strategy since the keystream bits depend on each other.
What are the key operations used in ChaCha20?
Add, XOR and Rotate bits - these are efficient and help mix input securely without complex structures like s-boxes.
How does ChaCha20 generate a keystream?
It initialises a 512 bit matrix with a key, nonce and constants then applies 20 rounds of transformations to mix the state and produce a secure keystream.
What’s the issues with ChaCha20 and Trivium?
They do not provide integrity! meaning if a ciphertext is flipped, the decrypted plaintext bit flips too and there’s no way to detect tampering.
How can we ensure integrity when using a stream cipher?
Use a MAC (Message Authentication Code) alongside the stream cipher to verify the message hasn’t been tampered with (modified)
What is a block cipher and how is it different from a stream cipher?
A block cipher encrypts a fixed-sized blocks e.g. 64 or 128 bits, whereas stream ciphers encrypt one bit at a time, using a keystream.
What is a pseudorandom permutation
A PRP is a function that looks indistinguishable from a random permutation to someone without the key. It’s reversible
What are shannons principle of confusion and diffusion
Confusion hides the relationship between the key and the cipher text (substitution) making it seem like random noise and diffusion spreads the influence of each input bit across many output bits (permutation)