infosec-info-and-interview-questions

A collection of interview questions and answers I created while studying for interviews.

View on GitHub

Cryptography

Acronyms you should know

Concepts you should know

Asymmetric keys

Think RSA. Public and private key pair. Public used to encrypt/verify signatures. Private used to sign/decrypt. Public can be shared without limits. Signature is proof of ownership.

Symmetric Keys

One key, so cannot be shared publicly. Used in standards like AES. Much faster than Asymmetric keys for encryption.

Certificate

This is a public key container that is signed by an entity like a Root CA. Has info like public key, host name, etc.

Perfect Forward Secrecy

If you use DH and generate a new session key every time, you cannot crack one key to decrypt all previous or future sessions.

Envelope Encryption

The big worry with encryption is exposing or losing keys. Why not let the cloud provider worry about it?

It starts with a single master key - Customer Master Key as it is referred to in most CSPs. This CMK can never be exposed by you - you will never see the plaintext key.

Using their API, or on your own, you can generate a data key. You can/should generate many data keys for encrypting files to minimize your attack surface. If using a KMS, you will get a plaintext and ciphertext data key. You can encrypt your data as needed, then discard the plaintext key (shred --zero --remove=wipesync --iterations=100). Store the ciphertext data and key somewhere. When you need the data, just decrypt the key and then decrypt the data with your data key.

You never need to store the plaintext key long term. This is amazing, seriously.

Why use this?

Diffie-Hellman Authentication

DH algorithms (DH, ECCDHE, etc) are susceptible to MITM. While no secrets are shared per se, an attacker can agree on a shared secret with both parties - A<->C<->B - while A and B think they are talking to each other. To combat this, you need to sign the DH parameters with a private key. Assuming the private key has not been stolen or cracked, it proves those parameters have not been forged and the key exchange is secure, even if someone is eavesdropping on the conversation. Remember, someone can see all of the DH parameters and still not be able to generate the session key. This is the magic of DH.

TLS

Putting all the above in context, we can finally start to understand TLS. Here is a simplified overview of the process:

RSA

DH

Communication with TLS also has integrity which is done with MAC/HMAC. cipher suites include hashing algorithms which are used for HMACs. A simple explanation is if you have a message, you can hash the message and the shared key together. Since both parties have the key, once the message is decrypted, a client can hash that message with the key and if it matches the HMAC it received, it knows that the message was not modified. An attacker can modify the message but if they do not have the key, they cannot forge the HMAC.

MACs also contain a sequence number to prevent a replay attack

TLS 1.3 does not use RSA and only supports ECDHE