2023-08-23 17:09:04 +00:00
|
|
|
# Real World Crypto 101
|
|
|
|
|
|
|
|
My notes when reading
|
|
|
|
[Real-World Cryptography](https://www.manning.com/books/real-world-cryptography)
|
|
|
|
|
|
|
|
**Hash** function convert from input to digest:
|
|
|
|
|
|
|
|
- Pre-image resistance: Given digest, can not find input
|
|
|
|
- Second pre-image resistance: Given input, digest, can not find another input
|
|
|
|
produce same digest. Small change to input make digest big change.
|
|
|
|
- Collision resistance: Can not find 2 input produce same digest.
|
|
|
|
|
|
|
|
**MAC** aka Message Authentication Code produce from key, message to
|
2023-08-24 04:44:53 +00:00
|
|
|
authentication tag. **HMAC** is MAC using hash.
|
|
|
|
|
|
|
|
- A send B message with MAC (generate from message and A key).
|
|
|
|
- B double check message with MAC (generate from receive message and B key).
|
|
|
|
- A and B use same key.
|
2023-09-10 16:39:41 +00:00
|
|
|
|
2023-09-10 16:41:21 +00:00
|
|
|
```mermaid
|
2023-09-10 16:39:41 +00:00
|
|
|
sequenceDiagram
|
|
|
|
participant alice
|
|
|
|
participant bob
|
|
|
|
|
|
|
|
alice ->> bob: send username, password
|
|
|
|
bob -->> alice: return alice|mac(private_key, alice)
|
|
|
|
alice ->> bob: send alice|mac(private_key, alice)
|
|
|
|
bob -->> alice: return OK
|
|
|
|
alice ->> bob: send bob|mac(private_key, alice)
|
|
|
|
bob -->> alice: return ERROR
|
|
|
|
```
|