What is it?
![](https://velog.velcdn.com/images/brandonnam/post/21baa4f7-4206-4df6-9be4-a7832a4533be/image.png)
- Confidentiality: only the sender and the receiver can understand the message.
- Authentication: needs to authenticate the sender and the receiver.
- Message Integrity: any alteration can be detected easily (inviolable)
Confidentiality
![](https://velog.velcdn.com/images/brandonnam/post/a216cc52-4b7c-46e9-9759-1858579510bc/image.png)
- m: plaintext message
- K_a: encryption key (string or number that is used in the encryption / decription algorithm)
- K_a(), K_a: encryption algorithm
- K_b: decryption key
- K_b(), K_b: decryption algorithm
![](https://velog.velcdn.com/images/brandonnam/post/a0554294-2e17-4462-8f37-3c10f2b5367a/image.png)
- The two types of cryptography are: symmetric key cryptography and asymmetric key cryptography.
Symmetric Key Cryptography
![](https://velog.velcdn.com/images/brandonnam/post/afeb85dc-c830-4967-9eb2-3fb2a84ec3e8/image.png)
- It is important to know how the receiver and the sender decided on which key to use.
- TCP handshake? Then that should be secure as well!
- Need to think of a way to securely communicate the key to use.
![](https://velog.velcdn.com/images/brandonnam/post/b6a33bd5-8f6a-4156-9787-73259a365bf1/image.png)
- Only 25 possible values of shifting.
- The key in this case is number of shifting (ex: 3)
![](https://velog.velcdn.com/images/brandonnam/post/ef0502e5-675a-455c-841e-a30fd8c768c2/image.png)
- The key here is the mapping of alphabet to the permutation (permutation string).
- 26! possible permutations
![](https://velog.velcdn.com/images/brandonnam/post/fc74d318-841d-425f-b0b9-406981ba70cc/image.png)
- Monoalphabetic cipher can be deciphered using statistical analysis.
- Some consonants appear more frequently than others.
- Knowing that "bob" or "alice" appears in the text already gives out some letters.
![](https://velog.velcdn.com/images/brandonnam/post/2ce03c78-df94-4107-b37c-4395c99244ea/image.png)
- Ciphertext only attack: Trudy has only the ciphertext she can analyze using statistical analysis.
- Known-plaintext attack: Trudy knows the mapping for "alice" and "bob" and the permutation string.
- Chosen-plaintext attack: Trudy forces Alice to send a string of message, from which the mapping can be figured out.
![](https://velog.velcdn.com/images/brandonnam/post/390ada65-c763-4194-8e95-3399a49e2490/image.png)
- Use several mappings in cycle.
- The encryption key here is the cycle pattern, and substitution ciphers.
![](https://velog.velcdn.com/images/brandonnam/post/3deaa40c-848c-467d-8d8a-10bd43daa8a9/image.png)
- You can see for the same b, it is now mapped to different alphabets.
![](https://velog.velcdn.com/images/brandonnam/post/f5a82b29-fe03-44f0-9f92-2f93daba5b38/image.png)
- Number of permutations of mappings: (2^(k))!
- where k is the number of bits in a block.
![](https://velog.velcdn.com/images/brandonnam/post/78631a11-a4e3-47e1-847d-8d16898c27a5/image.png)
- DES and AES.
- AES > DES.
- DES can be solved easily now due to the technological advancement.
![](https://velog.velcdn.com/images/brandonnam/post/50d0955d-07eb-4894-adc1-c776b8a37537/image.png)
- The key issue with symmetric key cryptography is that both ends need to know the key.
- This is problematic when the two have never met.
- Thus, the motivation for asymmetric cryptography.
- The sender uses public key to encrypt,
- The receiver uses private key to decrypt.
Asymmetric Key Cryptography
![](https://velog.velcdn.com/images/brandonnam/post/7293bd6d-7607-4c60-b67a-79e389888648/image.png)
- Requirements:
- Need the encryption and decryption algorithms.
- Even if there is a coupling between the public and private keys, it should be impossible to even guess what the private key is from the public key.
![](https://velog.velcdn.com/images/brandonnam/post/fa449902-3105-4ed1-8f23-869f32cb766a/image.png)
![](https://velog.velcdn.com/images/brandonnam/post/049185b2-b62e-4c16-97d8-b07f0435e38a/image.png)
- Message is just a bit pattern, and bit pattern can be translate to a number.
- RSA encrypts a number to produce another number.
![](https://velog.velcdn.com/images/brandonnam/post/74396072-aa6c-4afc-ad46-03017caa1a46/image.png)
- Choose 4 numbers to encrypt:
- p and q (very large different prime numbers)
- e (no common factor with z)
- d (ed - 1 is divisible by z)
- (n, e) become public, (n, d) become private key.
![](https://velog.velcdn.com/images/brandonnam/post/75fe2c49-2a6b-4adc-8871-4f3a2925b1a0/image.png)
![](https://velog.velcdn.com/images/brandonnam/post/20f9db24-ba6d-4a85-9fae-ac459abb5900/image.png)
![](https://velog.velcdn.com/images/brandonnam/post/2ac26120-ed81-47f1-a63a-92aac4536e3a/image.png)
- swapping between public and private encryption algos still work.
![](https://velog.velcdn.com/images/brandonnam/post/112b3a9c-f17f-4a82-bbfb-69f432b3e4dd/image.png)
- RSA on its own is too computationally-expensive.
- Use RSA on K_s. Decrypting the key to decrypt the DES.
Message Integrity
- We can use checksum, parity, and CRC.
![](https://velog.velcdn.com/images/brandonnam/post/7e398d99-5b5f-427a-8b6d-8bebe57a4fa0/image.png)
- Checksum is not good for preventing attacks.
![](https://velog.velcdn.com/images/brandonnam/post/18bfb679-f190-43aa-b430-34d3e8376007/image.png)
- Two input strings can have the same CRC checksum.
![](https://velog.velcdn.com/images/brandonnam/post/ac861a03-5e73-4f38-8a7d-50b9c6af49af/image.png)
- The hash function should not have two input values that can generate the same hash outputs.
Hash Function: MD5
![](https://velog.velcdn.com/images/brandonnam/post/a4c38848-7561-41ec-bce6-35e84e4518c2/image.png)
- Even though the file sizes are very different, they still produce 128 bits hash output.
![](https://velog.velcdn.com/images/brandonnam/post/2a4cd014-eb98-4e0b-bd25-3ab597f351df/image.png)
- A small change in the input shows great difference in output.
![](https://velog.velcdn.com/images/brandonnam/post/7cf64b63-dea5-47db-97ae-70b2c5929da6/image.png)
- The sender cannot send the pair (m, H(m)) because if both of them are replaced with something correct, there is no way to detect the replacement.
![](https://velog.velcdn.com/images/brandonnam/post/819127ee-2ffd-4465-8027-006b9f73e5c4/image.png)
- Send the hash code of message + authentication key.
- Since the authentication key is only known between the sender and the receiver, there is no way an intruder can replace the H(m+s) since then it will be easily detected.
![](https://velog.velcdn.com/images/brandonnam/post/7133f495-5e83-4832-8018-e8de4dfbe3b3/image.png)
Authentication
![](https://velog.velcdn.com/images/brandonnam/post/ea21a25e-12fd-4b6d-a251-e158ba2d16bf/image.png)
- Digital siganture: cryptographic technique used to authenticate the sender and the receiver.
![](https://velog.velcdn.com/images/brandonnam/post/c51558b1-b3f0-4901-a06e-74258cbf8281/image.png)
- In digital signature, we use the private key to encrypt and public key to decrypt.
- This way, if the public key can decrypt the message, then we know that it is send by Bob, because it is using Bob's private key to encrypt.
![](https://velog.velcdn.com/images/brandonnam/post/7d6e1469-e4af-4c53-9fe3-6f43975502de/image.png)
![](https://velog.velcdn.com/images/brandonnam/post/c892bab6-0ca8-4992-a56e-fdf1d60d77f3/image.png)
- It is quite expensive to encrypt the entire message, since the message can be long.
- The solution is to hash first so that a fixed size of hashed message can be encrypted.
![](https://velog.velcdn.com/images/brandonnam/post/1d132c8f-5ff4-47b2-97ee-2c1251975419/image.png)
- the message m is sent with the hased m.
![](https://velog.velcdn.com/images/brandonnam/post/bc276240-9afe-4dfe-b2b0-bd8c952a3a64/image.png)
- The issue right now is that there is no way to tell if the public key provided is by the intruder's or the sender's.
![](https://velog.velcdn.com/images/brandonnam/post/86e9ce29-32bf-489d-bd30-48e96b936e76/image.png)
- We do not know if it is Bob's public key.
- Ask Certification Authority (CA) - which keeps the data base for public keys - if it is indeed Bob's public key.
- But what if Trudy intercepts the communication between CA?:
- Problem: We do not know CA's public key?
![](https://velog.velcdn.com/images/brandonnam/post/fabd028e-3fcf-431e-a1be-8c9de3cd2fbd/image.png)
- Use CA key to verify that it is indeed bob's public key.
![](https://velog.velcdn.com/images/brandonnam/post/512b87ce-9d28-422a-9625-91aa4d0cac0c/image.png)
- Firewall is used to block the external people from accessing the internal network.
![](https://velog.velcdn.com/images/brandonnam/post/3687b0ed-7bef-4e98-9743-c38313744d94/image.png)
1. prevents DoS attacks by an outsider.
- DoS attack sends countless TCP connection requests that any proper TCP request cannot be succeded.
![](https://velog.velcdn.com/images/brandonnam/post/eb62e781-d836-422d-8580-dc897d80fee6/image.png)
![](https://velog.velcdn.com/images/brandonnam/post/a0877a0b-8883-4361-ae5a-c25c6a19dc61/image.png)
- The packets go through the list of rules known as Access Control Lists to be checked if they can be passed.
![](https://velog.velcdn.com/images/brandonnam/post/d81ccf80-f85a-4c7a-a6f6-a03ce10cc95c/image.png)
- IP spoofing: when packets fake the IP address, there is no way to tell it by the firewall.