Cryptography practice questions with answers
Fifteen free cryptography practice questions with explained answers, written as scenarios. Cryptography protects confidentiality, integrity and authenticity using ciphers, hashes, digital signatures and certificates, and exam questions ask which tool fits which goal. The topic is tested in the CompTIA Security+ V8 exam (SY0-801), objective 1.3 on cryptographic solutions.
How to use these questions
Attempt every question before reading the explanation. Identify the goal first (confidentiality, integrity, authentication or non-repudiation), then pick the primitive that provides it. Wrong options are explained, because the usual trap is a real technique applied to the wrong goal. The cryptography basics guide explains each concept in depth.
Warm-up: which tool for which goal
Question 1. A company must encrypt large nightly database backups quickly using a single shared key. Which algorithm is the best fit for bulk encryption at rest?
- A. RSA-2048
- B. ECDSA
- C. SHA-256
- D. AES-256
Show answer
Answer: D
AES-256 is a symmetric cipher, fast and suitable for large data. RSA-2048 is asymmetric and far too slow for bulk data. ECDSA is a signature algorithm, not a cipher. SHA-256 is a hash function, which cannot be reversed to recover the backup.
Question 2. Which key does a sender use to create a digital signature on a document?
- A. The recipient’s public key
- B. The sender’s private key
- C. The recipient’s private key
- D. The sender’s public key
Show answer
Answer: B
A signature is created with the sender’s private key, so anyone with the matching public key can verify it. The recipient’s public key is used to encrypt for the recipient, not to sign. The recipient’s private key is secret to the recipient. The sender’s public key is used for verification, not creation.
Question 3. A vendor publishes a fixed-length digest next to a downloadable ISO file so customers can confirm the file was not altered. Which algorithm produces this digest?
- A. AES
- B. RSA
- C. SHA-256
- D. 3DES
Show answer
Answer: C
SHA-256 is a hash function that produces a fixed-length digest used to check integrity. AES and 3DES are symmetric ciphers that produce ciphertext, not a verifiable digest. RSA is an asymmetric algorithm, not a hash.
Question 4. Alice wants to send Bob a message that only Bob can read, using asymmetric encryption. Which key does Alice use to encrypt it?
- A. Bob’s public key
- B. Alice’s private key
- C. Bob’s private key
- D. Alice’s public key
Show answer
Answer: A
Confidentiality is achieved by encrypting with the recipient’s public key, so only Bob’s private key can decrypt. Alice’s own private key would produce something anyone could decrypt with her public key. Bob’s private key is not available to Alice. Alice’s public key would let only Alice decrypt.
Question 5. What is the main purpose of adding a unique salt to each password before hashing it?
- A. To make the hash reversible for password recovery
- B. To defeat precomputed rainbow tables and make identical passwords hash differently
- C. To make hashing faster for the login server
- D. To keep the hash secret from the database administrator
Show answer
Answer: B
A unique salt makes identical passwords produce different hashes and defeats precomputed rainbow tables. It does not make the hash reversible or encrypt anything. It does not speed up hashing, and it is not secret key material that must be hidden from attackers.
Scenarios: storage, key exchange and PKI
Question 6. A development team is choosing how to store user passwords in a new application. Which approach is the most appropriate?
- A. MD5 hashing
- B. Unsalted SHA-256 hashing
- C. bcrypt hashing
- D. AES-256 encryption with the key in a config file
Show answer
Answer: C
bcrypt is a deliberately slow, salted, adaptive password hashing function. MD5 is fast and broken for security use. An unsalted SHA-256 is fast and vulnerable to rainbow tables. Reversible AES encryption with a key stored in the configuration lets a breach expose every password.
Question 7. Network traffic is recorded today by an adversary. The organisation wants it to stay protected even if the server's private key is stolen next year. Which TLS design provides this?
- A. Ephemeral elliptic-curve Diffie-Hellman key exchange
- B. RSA key transport with the static server key
- C. A certificate with a longer validity period
- D. A reused pre-shared symmetric key
Show answer
Answer: A
Ephemeral Diffie-Hellman key exchange (such as ECDHE) generates a fresh session key for each connection, which gives perfect forward secrecy. RSA key transport with a static key lets a stolen private key decrypt recorded sessions. A longer certificate lifetime or a reused pre-shared key does not protect past sessions.
Question 8. A browser needs the real-time revocation status of a single certificate without downloading a complete list of revoked certificates. Which mechanism does this?
- A. CSR
- B. CRL
- C. Key escrow
- D. OCSP
Show answer
Answer: D
OCSP returns the status of one certificate on request. A CRL is a periodically published list of all revoked certificates that the client downloads. A CSR is a request for a new certificate, and key escrow is the safekeeping of copies of keys.
Question 9. An administrator generates a certificate signing request (CSR) to obtain a server certificate from a public certificate authority. What does the CSR contain?
- A. The public key and subject information
- B. The private key and subject information
- C. The CA’s private key
- D. A symmetric session key
Show answer
Answer: A
A CSR contains the public key and the subject information (such as the domain name), and is signed with the private key to prove possession. The private key never leaves the server. The CA’s private key is never shared, and a symmetric session key is created later during the TLS handshake.
Question 10. A company runs app1.example.com, app2.example.com and app3.example.com and wants to minimise the number of TLS certificates to manage. Which certificate type fits best?
- A. A self-signed certificate for each server
- B. A wildcard certificate
- C. A code-signing certificate
- D. A root CA certificate
Show answer
Answer: B
A wildcard certificate for *.example.com covers all single-level subdomains. A separate self-signed certificate per server increases management and triggers trust warnings. A code-signing certificate is for signing software, not TLS. A root CA certificate is a trust anchor and is not installed on a web server for this purpose.
Edge cases and traps: levels, signatures and trust
Question 11. A laptop that is powered off is stolen. The company wants to protect every file, including the swap file and temporary files, without relying on user behaviour. Which control fits best?
- A. File-level encryption of the Documents folder
- B. Hashing every file on the disk
- C. TLS on the network connection
- D. Full-disk encryption
Show answer
Answer: D
Full-disk encryption protects everything on the drive, including swap and temporary files, while the device is off. File-level encryption of one folder leaves other locations exposed. Hashing the files does not hide their contents. TLS protects data in transit, not data at rest on a stolen device.
Question 12. Why does TLS use asymmetric cryptography during the handshake but symmetric encryption for the application data?
- A. Symmetric encryption is cryptographically weaker than asymmetric
- B. Asymmetric encryption cannot encrypt any data
- C. Asymmetric solves key distribution but is slow, symmetric is fast for bulk data
- D. Both are required for backward compatibility only
Show answer
Answer: C
Asymmetric methods solve the key distribution problem but are slow, while symmetric ciphers are fast for bulk data once both sides share a session key. The statement that symmetric encryption is weaker is wrong for modern ciphers such as AES. Asymmetric encryption is not unable to encrypt data, only impractical at scale. The two are not used for compatibility reasons.
Question 13. Which set of properties does a valid digital signature provide?
- A. Confidentiality, integrity and availability
- B. Integrity, authentication and non-repudiation
- C. Confidentiality and non-repudiation only
- D. Availability and authentication
Show answer
Answer: B
A valid signature provides integrity (the content is unchanged), authentication (the signer holds the key) and support for non-repudiation (the signer cannot credibly deny it). It does not provide confidentiality, because the document stays readable, and it does not provide availability.
Question 14. Why is MD5 no longer acceptable for digital signatures?
- A. Practical collision attacks allow two different inputs with the same digest
- B. Its output is too long to store
- C. Anyone with a key can reverse it
- D. It requires a key exchange before use
Show answer
Answer: A
Practical collision attacks exist, so an attacker can craft two different inputs with the same digest and substitute one for the other. The output length is not the problem, MD5 is not reversible with a key, and it does not require a key exchange.
Question 15. Users see a browser warning when connecting to an internal server that uses a self-signed certificate, although the connection is encrypted. What is the reason for the warning?
- A. The key length is too short for TLS
- B. Self-signed certificates cannot encrypt traffic
- C. It does not chain to a root certificate the client trusts
- D. A wildcard name was used
Show answer
Answer: C
The certificate is not signed by a CA that chains to a root in the client’s trust store, so the browser cannot verify who issued it. Self-signed certificates can encrypt traffic, so B is wrong. Key length and wildcard use are not the cause of the warning.
Where to go next
Study the cryptography basics guide, then continue with security controls practice questions and zero trust and IAM practice questions. For a timed run, take the free 20-question Security+ practice test, and read the multiple-choice exam tips.