What is symmetric encryption?
Symmetric encryption uses the same secret key to encrypt and decrypt data.
Security depends on the key staying secret and on correct algorithm/mode usage.
What is asymmetric encryption?
Asymmetric encryption uses a key pair: a public key and a private key.
What is the difference between symmetric and asymmetric encryption?
They differ in keys and performance.
What is hashing?
What is the difference between hashing and encryption?
Encryption is reversible with the right key; hashing is not designed to be reversible.
What are Message Authentication Codes (MACs)?
A Message Authentication Code (MAC) proves integrity and shared-key authenticity for a message.
- Sender computes tag = MAC(key, message).
- Receiver recomputes tag with the same key and compares.
- If tags match, receiver accepts that the message was not modified and came from someone with the key.
What is HMAC?
HMAC (Hash-based Message Authentication Code) is a MAC built from a hash function and a secret key.
- Sender computes HMAC(key, message) and sends message + tag.
- Receiver recomputes HMAC with the same key and compares tags.
What is randomness and entropy in security?
Entropy is the unpredictability available for generating secrets.
- Systems need high entropy to make keys and tokens hard to guess.
- Low entropy values are guessable by brute force because the search space is small.
What is a nonce and how is it used?
A nonce is a value that must be unique for a specific context, usually per message or per session.
- Systems attach a nonce to a request or cryptographic operation.
- The receiver checks that the nonce is fresh (not seen before) or matches an expected sequence.
- Nonces help prevent replay because repeated messages can be detected.
What is a replay attack?
A replay attack is reusing a previously valid message or token to repeat an action.
- Attacker captures a valid request, token, or signed message.
- Attacker resends it later.
- If the system only checks “valid format/signature” and does not check freshness, it accepts the replay.
How do systems prevent replay attacks?
Systems prevent replay by adding and checking freshness.
- Nonce: receiver rejects previously seen nonces for a time window.
- Timestamp: receiver rejects messages outside an allowed time skew.
- Sequence number: receiver rejects out-of-order or repeated sequence values.
What is a public key?
A public key is the shareable part of an asymmetric key pair.
- Others use it to verify signatures made by the private key or to encrypt data to the key owner.
- The public key does not need secrecy; its integrity matters so it cannot be swapped by an attacker.
What is a private key?
A private key is the secret part of an asymmetric key pair.
- It is used to create digital signatures or to decrypt data encrypted to the matching public key.
- Anyone with the private key can impersonate the key owner in systems that trust that key.
What is a key pair?
A key pair is a linked public key and private key generated together.
- The public key is distributed to verifiers or senders.
- The private key is kept secret by the owner.
What is key exchange?
Key exchange is a protocol that lets two parties derive a shared secret over an untrusted network.
- Both parties input data into a math protocol (like Diffie-Hellman) to compute identical secrets.
- Key exchange lacks authentication - parties verify the secret matches but not who generated it.
How does Diffie-Hellman key exchange work?
Step 1: Both sides agree on public parameters.
Step 2: Each side generates a private value and computes a public value from it.
Step 3: They exchange public values over the network.
Step 4: Each side combines its private value with the other side’s public value to derive the same shared secret.
Basic Diffie-Hellman does not prove who the other side is; it only derives a secret.
Why must private keys remain secret?
Private keys must remain secret because possession equals authority in these systems.
- Systems accept signatures verified by the public key as proof from the owner.
- If an attacker has the private key, they can generate signatures that pass verification checks.
- That enables impersonation and unauthorized actions wherever that key is trusted.
What is a digital signature?
A digital signature is a cryptographic proof bound to data and a private key.
- Signer computes signature = Sign(private key, message).
- Verifier checks Verify(public key, message, signature) returns valid.
- If valid, verifier knows the signature matches that message under that public key.
What do digital signatures prove?
They prove message integrity and private-key possession at signing time.
- Integrity: the signed message cannot be modified without breaking verification.
- Authenticity (key-based): only someone with the private key could have produced the signature that verifies.
- Non-repudiation: “Can’t deny signing” - only works with your protected key + key proves it was you.
What do digital signatures not prove?
They do not prove trust, intent, or safety of content.
- A valid signature does not mean the signer is authorized by your system unless you trust that key for that purpose.
- A valid signature does not mean the message is “good,” only that it was signed by the key holder and not altered.
- Signatures do not prevent replay unless the signed data includes nonces and the receiver checks it.
What is a certificate?
A certificate binds an identity to a public key using a digital signature by a trusted issuer.
- It contains identity fields and a public key.
- A Certificate Authority (CA)** signs** it.
- Verifiers use the CA signature to decide whether to trust the binding.
What is a Certificate Authority (CA)?
A Certificate Authority (CA) is an entity whose public key is trusted to sign certificates for others.
- The CA signs a certificate after applying its issuance rules.
- Verifiers accept the certificate only if they trust the CA public key and validation checks pass.
What is a trust store?
A trust store is the set of CA certificates a verifier uses as trust anchors.
- During validation, the verifier checks whether a certificate chain can be built to one of these trusted CA roots.
- If no trusted anchor exists, validation fails because there is no trusted signer for the identity binding.
What is a trust chain?
A trust chain is a sequence of certificates linking an** end-entity certificate** to a trusted CA root.
- Each certificate in the chain is signed by the next issuer up the chain.
- The verifier validates each signature and checks constraints.
- Validation succeeds only if the chain ends at a trusted root in the trust store.