Cryptography is one of the more complicated topics in security if you dive deep into the mathematics . It is definitely a topic that is worth learning about and being able to converse about when it comes to common best practices. I particularly enjoy it because of all the research that goes into creating these cryptography techniques and to see how far we have come in it.
1. What is secret-key cryptography?
This is the same as symmetric encryption, where Alice and Bob have the same key to encrypt and decrypt the messages. Both parties need to have the key and need to agree on the cryptographic algorithm.
· How to get the key from 1 party to another securely, typically fixed with asymmetric encryption to transport key;
· Compromised key means the whole session is compromised;
· Compromised key can be used to send data to one of the parties and impersonate one of the participants.
Examples: 3DES, DES, RC2, RC4
2. What is public-key cryptography?
This is the same as asymmetric encryption. Public key cryptography uses a public key and private key. The public key can be sent openly through the network, but the private key is private to whoever owns it. They are complementary and what the public key encrypts, the private key can decrypt. Bob is sending a message to Alice, so he uses her public key to send a message, and she decrypts it using her private key, which theoretically, she only has. Public key-cryptography can be used to establish a session key, which is shared between the two parties. Since asymmetric encryption is more costly in terms over resources, it can be used to establish a symmetrically encrypted session, which is less costly.
Digital signatures work off of this. Alice can send Bob a message that she encrypted using her private key. He will use her public to decrypt the message, so he knows that she is the one that sent it. Anyone can decrypt this, but this also confirms to everyone that she is the one that sent it. This is how SSL authenticates a client or a server. This is an important part of how SSL certificates provide authentication.
Certificate Authorities and browser authentication use public-key encryption to identify the web server to the browser. For example, Symantec could be the Certificate Authority that is hired by Amazon. When you access Amazon, the issued certificate by Symantec will verify Amazon's identity to your browser by using it's public key to establish a session. You can use the websites public key to send an encrypted message or session key, then the server can de-crypt and confirm back to the browser, therefore verifying the identity of the server.
· Extensive computations, slow;
· Mainly used for encrypting small amounts of data, such as a session key.
Examples: RSA, DH (both are used with SSL), SHA-256 (a hashing algorithm used to hash digital signatures on SSL certificates)
3. What is a session key?
Generally speaking, a session key is used to secure communications between two computers or a user and a client or a client and a server. A session key is a single use type of key that can be transmitted along with each message and is encrypted with the recipient’s public key.
Single use symmetric keys are faster, but they will need to be generated randomly.
Session keys are used in Open PGP. There can be a public key encrypted session key or a passphrase based encryption.
4. What is RSA?
RSA is a public key algorithm for key management digital signatures, and is used for asymmetric encryption. There is 1024 bit RSA and 2048 bit RSA. It uses large prime factors to calculate a modulus that can be used as a key, along with the recipients public key to send an encrypted message.
5. How fast is RSA?
It is slower than symmetric key encryption. It is relatively slow, so it is less commonly used to encrypt user data. A hybrid approach is taken, use RSA to share a secret key then use that as the shared key for a symmetrically encrypted session.
6. What would it take to break RSA?
You would have to calculate the prime numbers of the modulus used.
7. Are strong primes necessary for RSA?
Simply put, yes. You need huge, strong primes.
8. How large a module (key) should be used in RSA?
The best size for an RSA module (or key) really depends on the situation and need. The simple answer is that the larger the key, the higher complexity involved in solving for it. Thus, there is greater security when using a larger key. However, the tradeoff is that the RSA Operations are slower. Taking those tradeoffs into consideration, the length should also be chosen based on the value of the data being protected, the length of time it needs to be protected for, how strong your adversaries are, what your vulnerabilities are, etc.
9. How large should the primes be?
Thousands of digits.
10. How is RSA used for authentication in practice? What are RSA digital signatures?
RSA is combined with a hash function in order to sign a message. One way that it works in practice is if User A sends a message to User B and encrypts it with their private key. When User B receives it, they would need to decrypt the message with the public RSA key of User A. Once decrypted, User B can verify the hash of the message by using the same hash function that User A used. If the hashes match, then the message has maintained its integrity. MD5 and SHA have been designed in such a way that no two messages, files, etc have the same hash. Therefore, this unique hash provides a way to check for integrity of files.
The RSA public key exponent is typically much smaller than the RSA private key exponent. In other words, it is much more resource extensive to sign a signature than it is to perform the verification process with the public key.
11. What are the alternatives to RSA?
There are alternatives to RSA, and some have been part of SSL since the days of SSL 3.0, two decades ago. With the standard core protocol (TLS 1.2 at the time of writing), you have the DH_DSS and DHE_DSS cipher suites, which involve DH for key exchange, and DSA for signatures (with DH_DSS, the server's certificate contains a DH public key and the issuing CA contains a DSA public key; with DHE_DSS the server's certificate contains a DSA public key and the DH key pair is produced on-the-fly). ECC is another option. Duo is also a popular alternative that is used in practice.
The reason why RSA is so widely used is because it can be used for both encryption and authentication.
12. Is RSA currently in use today?
Ubiquitously - both by private and governments.
13. What are DSS and DSA?
DSS - Digital Signature Standard.
DSA - Digital Signature Algorithm.
DSA is used in the implementation of DSS. DSA is essentially a cryptographic algorithm that generates kets, signs data, and verifies signatures. The signature generation is faster than signature verification.
14. What is difference between DSA and RSA?
DSA is faster in signing, but slower in verifying. DSA uses 1024 bits. RSA can go up to 2048 bits. RSA can be used for encryption and authentication, but DSA can only be used for encryption.
16. What are special signature schemes?
Signature schemes can be categorized as either special or conventional schemes. Examples of conventional schemes include RSA or DSA. Conventional signature schemes have the following characteristics:
Signer knows the contents of the message.
Anyone who knows the public key can verify the correctness of the signature.
17. What is a blind signature scheme?
In this type of a digital signature, the content of the message is disguised before it is signed. This could be useful in the case where the signer and the message author are different parties. Examples of use cases would be digital cash schemes or voting protocols. RSA and DSA can be used to implement blind signature schemes.
18. What is a group signature?
A group signature scheme is a method that allows a member of a group to anonymously sign a message on behalf of the group. A group signature scheme may have a group manager; this person would be in charge of adding members. they would be aware of the original signer, and revoking signature anonymity.
19. What is blowfish?
Blowfish is a symmetric-key block cipher. It is relatively fast, but when changing keys which requires some pre-processing equivalent. The key length can vary from 32 bits to 448 bits. bcrypt is a password hashing function that was derived using the key setup phase of Blowfish. Because the key setup phase of Blowfish is extremely slow, this reduces the threat of a brute force attack.
20. What is FEAL?
FEAL, or the fast data encipherment algorithm, is a block cipher. It was designed to be faster than DES.
21. What is Shipjack?
Shipjack is used only for encryption. The algorithm uses an 80 bit key to encrypt and decrypt 64-bit data blocks.
22. What is a stream cipher?
This is a way to encrypt text in which a cryptographic key and algorithm are applied to each binary digit in a data stream. Stream Cipher is an encryption algorithm that encrypts arbitrary length plaintext using a key. Some use a key stream to XOR with the plaintext. It is reversible because if you XOR it with the ciphertext, then you decrypt the cipher.
23. What is the advantage of public-key cryptography over secret-key cryptography?
Public key cryptography (aymmetric) and secret-key cryptography (symmetric) have the following advantages and disadvantages.
+ No need for exchanging keys
+ private keys stay private
- slower than symmetric keys
+ No key transmitted with the data, so the data getting decrypted on the way there is null
+ Only the recipient with the secret key can decrypt the message
- Not too many ways to securely exchange keys (key transportation)
24. What is Message Authentication Code (MAC)?
Message Authentication code (checking message integrity/authenticity) or media access control address (id device).
25. What is a block cipher?
Block cipher is more commonly used in which the key and algorithm are applied to blocks of data rather than individual bits in a stream. It takes the block of data as input, then runs multiple rounds on it. A sequential number is inputted to the block cipher and its output is XOR’ed with plaintext to make ciphertext. These examples are ways to encrypt data at rest.
Examples: AES 256, 3DES.
There are 3 types of encryption: symmetric, asymmetric, and hash functions. Block and stream ciphers are a part of symmetric encryption.
26. What are different block cipher modes of operation?
The earlier modes of operation included: ECB, CBC, OFB, CFB, CTR, and XTS. These methods did provide confidentiality, but did not provide integrity. MAC (message authentication codes) came in where these modes of operation lacked.
27. What is one-way hash function?
Hash you can’t undo. Password hashes. 2 way hash is reversible.
28. What is collision when we talk about hash functions?
A collision is what occurs when a hash functions matches two different inputs to the same output, or hash. A hashing algorithm is considered collision resistant it is harder for this algorithm to output the same hash. The hashing algorithm doesn't necessarily have completely eliminate the chance of having a collision to be collision resistant, but simply be highly unlikely.
29. What are the applications of a hash function?
A hash function can be used in a verity of ways when a function is needed to map data of arbitrary size to data of a fixed size. It is used to store password hashes. In other words it is used to protect data in a way that uniquely identifies each data set since they are one way functions.
30. What is trapdoor function?
Trapdoor functions are easy to compute in one direction and difficult in the other. However, there is a secret that is needed in order to perform the reverse calculation efficiently. Hashes are not trapdoor functions because hashes and one way.
31. Cryptographically speaking, what is the main method of building a shared secret over a public medium?
DH key exchanges are widely used for exchanging private keys over public keys.
32. What’s the difference between Diffie-Hellman and RSA?
RSA is an algorithm for public-key cryptography that is based on the presumed difficulty of factoring large integers, the factoring problem. RSA stands for Ron Rivest, Adi Shamir and Leonard Adleman.
Diffie-Hellman key exchange (D-H) is a specific method of exchanging cryptographic keys. It is one of the earliest practical examples of key exchange implemented within the field of cryptography. The Diffie-Hellman key exchange method allows two parties that have no prior knowledge of each other to jointly establish a shared secret key over an insecure channel.
33. What kind of attack is a standard Diffie-Hellman exchange vulnerable to?
It is vulnerable to man in the middle attacks.
34. If you had to both encrypt and compress data during transmission, which would you do first, and why?
Compress first, then encrypt. If compression must be done, then that is the order to go. If compression is not needed, then just encrypting is the best way to go.
35. What is SSL and why is it not enough when it comes to encryption?
SSL is used to establish an encrypted link between a server and a client that allows secure transmission of sensitive data. This is a security protocol so it describes how algorithms are used and it determines variables of the encryption for both the link and data being transmitted. When a browser tries to connect to a web server, a SSL handshake occurs. Three keys are used to set up the SSL connection: public, private, and session keys. The public and private keys are used to create a symmetric session key. After that, the session key is used to encrypt the transmitted data. Browser connects to web server. Server sends SSL Cert, and public key. Browser checks cert root against trusted CAs. If it’s okay, then it creates, encrypts and sends back a symmetric session key encrypted with the server’s public key. Server decrypts the symmetric session key with its private key and sends back an acknowledgement encrypted with the session key. After that, the server and browser encrypt the data with the session key. SSL (application layer) works on top of TCP (transport layer). The order goes: HTTPS/SSL (app), TCP (transport), IPSEC (internet).
SSL only helps protect your data while it is in transit, but once it has reached its destination, then it cannot do much. SSL does not encrypt all of your data. One example is the metadata that is created and not encrypted. One real weak point is the handling of metadata. Metadata can help attackers build user profiles, and can help them map out a network. Examples of metadata is: IP and MAC addresses, protocol types, other network information. Certificate authorities that are trusted could also be compromised. Certificates could be outdated, they could be duplicates if an attacker has compromised it.
Encryption and data protection while data is in transit and while data is at rest are very important.
36. What is salting, and why is it used?
Salting is when a random value is added to passwords in order to obfuscate the password after hashing.
People tend to use the same passwords and not randomly, so it makes it easier for an attacker who has access to a list of commonly used passwords or stolen passwords. Rainbow tables have passwords and their hashes listed out , so this makes it even easier for an attacker. A salt is generated at random and can be small, but the main purpose is to lower the probability of the hash value to be found in a pre-calculated table. You can concatenate the password and the salt prior to hashing it. Salts can be stored in the clear in the DB, next to the hashed value.
Another defense against stolen passwords is to hash the passwords multiple times. A pepper is similar to a salt, and is used by concatenating it with the salt and the password, but the pepper is not stored at all.
37. What are salted hashes?
Salted hashes are passwords that have been hashed using a proven hashing algorithm, like SHA2, but before they are hashed, a salt value has been added.
38. What is the Three-way handshake? How can it be used to create a DOS attack?
The 3 way handshake is a method that is used in a TCP/IP network to create a connection between a local host or client and a server. Essentially it is used to create a TCP socket connection. The client requests a connection to the server by initially sending a SYN message. The server upon receiving the ping, will respond with a SYN-ACK message. When the client receives this ping, they will respond with an ACK message and the connection is then established. After this point, data will be exchanged between the two over this connection.
Exploitations of this process can be done to launch a DDoS attack. Examples include: a SYN Flood attack, UDP Flood, TCP SYN+ACK, TCP FIN. TCP RESET, TCP ACK, TCP ACK+PSH, TCP Fragment.
39. What’s more secure, SSL or HTTPS?
SSL, or Secure Sockets Layer, is the technology that is used to keep an internet connection secure and safeguard any sensitive data being sent between two systems. The two systems in this case can be a server and a client, or a server and server. Encryption algorithms are used to scramble the data in transit, such as ECC, RSA or DSA encryption. TLS (Transport Layer security) is an updated version of SSL.
HTTPS, or hyper text transfer protocol secure, is what websites use when they are secured by a SSL certificate. The certificate is issued by a certificate authority and it contains the corporate name of the website owner.
40. Can you describe rainbow tables?
Rainbow tables are pre-computed tables filled with hash values that are pre-matched to plaintext passwords. Hackers can use this to match up stolen hashes to possible passwords. Rainbow tables allow passwords to be cracked in a very short amount of time compared to other methods, like brute force. The tradeoff is that it requires a lot storage.
Protection against rainbow tables include:
· Don’t use MD5 or SHA1 in your password hashing function (SHA2 is more modern);
· Use a Salt in your password hashing routine, which will make it harder for those with rainbow tables to predict the salt used.