Encryption / Cryptography Flashcards

1
Q

Describe how HMAC works

A

In cryptography, a keyed-hash message authentication code (HMAC) is a specific type of message authentication code (MAC) involving a cryptographic hash function and a secret cryptographic key.
Hash-based message authentication code (HMAC) provides the server and the client each with a private key that is known only to that specific server and that specific client. The client creates a unique HMAC, or hash, per request to the server by hashing the request data with the private keys and sending it as part of a request. What makes HMAC more secure than Message Authentication Code (MAC) is that the key and the message are hashed in separate steps.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Cryptographically speaking, what is the main method of building a shared secret over a public medium?

A

Diffie-helman

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In public-key cryptography you have a public and a private key, and you often perform both encryption and signing functions. Which key is used for which function?

A

You encrypt with the other person’s public key, and you sign with your own private.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is Perfect Forward Secrecy?

A

Is a feature of specific key agreement protocols that give assurances that session keys will not be compromised even if long-term secrets used in the session key exchange are compromised.
For HTTPS, the long-term secret is the private key of the server. A unique session key is generated for every session a user generates, so a compromised key will not affect any data other than the data exchanged in the specific session protected by that particular key. But this is not sufficient for PFS.
It protects past communications. Even if the long-term key is compromised, past encrypted communication and sessions recorded in the past cannot be decrypted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

If someone steals the server’s private key can they decrypt all previous content sent to that server?
Forward Secrecy.

A

This prevents an attacker from decrypting captured data that was sent to a server in the past, even if the server’s private key was stolen. A different key is used for each message sent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What’s the difference between Diffie-Hellman and RSA?

A

Diffie-Hellman is a key-exchange protocol, and RSA is an encryption/signing protocol. Make sure they can elaborate on the actual difference, which is that one requires you to have key material beforehand (RSA), while the other does not (DH).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What’s the difference between encoding, encryption, and hashing?

A

Encoding is designed to protect the integrity of data as it crosses networks and systems, i.e. to keep its original message upon arriving, and it isn’t primarily a security function. It is easily reversible because the system for encoding is almost necessarily and by definition in wide use. Encryption is designed purely for confidentiality and is reversible only if you have the appropriate key/keys. With hashing the operation is one-way (non-reversible), and the output is of a fixed length that is usually much smaller than the input.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is an IV used for in encryption?

A

An IV is used to initiate encryption by providing an additional (third) input in addition to the cleartext and the key. In general you want IVs that are random and unpredictable, which are used only once for each message. The goal is to ensure that two messages encrypted with the same key do not result in the same ciphertext.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are block and stream ciphers? What are the differences, and when would you use one vs. the other?

A

Block-based encryption algorithms work on a block of cleartext at a time, and are best used for situations where you know how large the message will be, e.g., for a file. Stream ciphers work on single units of cleartext, such as a bit or a byte, and they’re best used when you’re not sure how long the message will be.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are some examples of symmetric encryption algorithms?

A

DES, RCx, Blowfish, Rijndael (AES)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are some examples of asymmetric encryption algorithms?

A

Diffie Hellman, RSA, EC, El Gamal, DSAC

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are some common block cipher modes?

A

ECB and CBC.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What’s the main difference in security between ECB and CBC?

A

ECB just does a one-to-one lookup for encryption, without using an IV, which makes it fairly easy to attack using a chosen-plaintext attack. CBC uses an IV for the first block and then propagates the XOR of the previous block onto subsequent ones. The difference in results can be remarkable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is salting, and why is it used?

A

A salt is a randomly generated value that is added as another input to a one-way hash function. It is usually used when hashing a password. A unique salt is generated per password. The salt and hash are then stored instead of keeping the password in plaintext. The salt is used so that the same value/password does not result in the same hash.
They defend against rainbow tables. They make the size of the tables too large to launch a successful attack.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

If you had to both encrypt and compress data during transmission, which would you do first, and why?

A

First compress and then encrypt.
Compression works by reducing redundancy.
There’s no difference in the security provided.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is data protection in transit vs data protection at rest?

A

Data in transit is when data is moving from one location to another. Like across the internet or through a private network. Encrypt the data as it’s being moved. TLS, SFTP, etc. Automate detection of attempts to move data outside of the defined boundaries. For example, GuardDuty and look at Flow Logs.

Data at rest is not actively being moved. It’s stored somewhere like in a database, hard drive, laptop, etc. Encrypt the data. Rotate the keys. Keep a backup of the encrypted data.

17
Q

What is a TPM?

A

Trusted storage for certs and auth data locally on device/host.
Trusted Platform Module.
Dedicated microcontroller designed to secure hardware through integrated cryptographic keys.

18
Q

How large a module (key) should be used in RSA?

A

1024 bit key should not be used, deprecated. It’s been determined that it could be broken in the future
2048 bit key is recommended by NIST

19
Q

Why shouldn’t you use self-signed certificates?

A

Not issued by public CAs

You might also accidentally generate a certificate key pair without reasonable entropy. You might fail to protect the private key.
Self-signed certificates cannot be revoked.
Self-signed certificates never expire.
Ok for internal testing
Contain public and private keys in the same entity
Not meeting latest security requirements
Not validated by trusted CAs - will give a security warning on the browser