Cryptography Interview Questions

Master Cryptography with these comprehensive interview questions and expert answers.

Here are the top Cryptography interview questions to prepare for your next role.

1️⃣ What is the difference between encoding (like Base64) and encryption?

  • A) Encoding is a one-way process that is not reversible, used for integrity checks. Encryption is a two-way process that is reversible with the correct key, used for confidentiality.
  • B) Encoding is used to make data secret and confidential, while encryption is used to format data for transport over text-based protocols like JSON or XML.
  • C) Encoding is a reversible transformation to represent binary data in a text format for transport, offering no security. Encryption is a security process using a key to make data unreadable, providing confidentiality.
  • D) Encoding requires a public/private key pair to transform the data, while encryption (like AES) uses a single, shared algorithm that everyone knows and requires no key.

2️⃣ How does a cryptographic hash function (like SHA-256) help ensure data 'integrity'?

  • A) By computing a hash of the data and sending it with the data, the recipient can re-compute the hash. If the hashes match, it provides high assurance the data was not altered.
  • B) It uses a private key to create a unique 'signature' of the data. This proves the sender's identity, and a change in data would also invalidate the signature.
  • C) It encrypts the data using a secret key, which prevents unauthorized parties from reading or altering the data, thus ensuring the data's integrity and confidentiality.
  • D) It slows down the data verification process (key-stretching), which makes it computationally difficult for an attacker to modify the data and re-compute the hash in time.

3️⃣ What is the primary difference between a simple hash (like SHA-256) and a Message Authentication Code (MAC, like HMAC-SHA256)?

  • A) A simple hash (SHA-256) is a symmetric operation, while a MAC (HMAC) is an asymmetric operation that requires a public/private key pair to verify.
  • B) A simple hash only provides integrity. A MAC provides both integrity and authentication because it is a hash that is 'keyed' with a shared secret key.
  • C) A simple hash is used to verify file integrity, while a MAC is used to encrypt the entire message for confidentiality. It is functionally the same as AES in CBC mode.
  • D) A simple hash (SHA-256) is considered secure, while a MAC (HMAC) is an older, faster algorithm that is vulnerable to collision attacks and should not be used.

4️⃣ What is a 'padding oracle' attack, and which symmetric cipher mode is famously vulnerable to it?

  • A) An attack on CTR-mode encryption where an attacker 'pads' the plaintext with null bytes, which causes the XOR operation to fail and leak the keystream via an 'oracle' error.
  • B) An attack on CBC-mode encryption where an attacker uses the server's 'padding invalid' error messages (an 'oracle') to iteratively guess and confirm the contents of the plaintext.
  • C) An attack on ECB-mode encryption where the 'oracle' is the predictable ciphertext pattern, which allows an attacker to 'pad' the message with known data to reveal its structure.
  • D) An attack on GCM-mode encryption where the 'oracle' is the authentication tag. An attacker can 'pad' the tag with guesses until it is valid, allowing them to forge messages.

5️⃣ What is the 'avalanche effect' in the context of cryptographic hash functions?

  • A) It is the desirable property where a tiny, single-bit change in the input (e.g., flipping one bit) will cause a drastic, unpredictable, and complete change in the output hash.
  • B) It is the term for a 'length extension attack,' where an attacker can append data to a message and the hash 'avalanches,' allowing them to forge a new, valid hash without the key.
  • C) It is a type of 'birthday attack' where a large number of inputs are hashed at once, causing a 'cascade' or 'avalanche' of collisions that can be used to break the algorithm.
  • D) It is the 'chaining' property of a Merkle tree, where a change in one leaf node 'avalanches' up the tree, changing every parent hash all the way to the root hash.
Cryptography Interview Questions | Squizzu