~
My notes when reading Real-World Cryptography
sequenceDiagram
participant alice
participant bob
alice ->> bob: send alice, mac(secret_key_alice, alice)
bob ->> bob: compare mac(secret_key_alice, alice) with mac(secret_key_bob, alice)
Constant time comparision:
for i := 0; i < len(x); i++ {
// Use XOR instead of compare x[i] == y[i]
// If x[i] == y[i] -> XOR is 1
// Otherwise XOR is 0
v |= x[i] ^ y[i]
}
// v == 1 means all XOR is 1 means x == y
Use for:
sequenceDiagram
participant alice
participant bob
alice ->> bob: send username, password
bob -->> alice: return alice|mac(secret_key, alice)
alice ->> bob: send alice|mac(secret_key, alice)
bob -->> alice: return OK
alice ->> bob: send bob|mac(secret_key, alice)
bob -->> alice: return ERROR
HMAC is MAC using hash
Currently (2023) the world using AES-128 which take a key 128 bits == 16 bytes/
AES is kind of cipher, handle fixed-size plaintext so we called block cipher.