goals of crypto?
Confidentiality, Integrity, Composability
Kerckhoffs’s Principle
the security of crypto system lies in the secure hex and not the algorithm.
On Time Pad
c := m xor k
m
Pseudorandom Permutation
is a function that takes a key k and a message m of length n and holds the following:
Advanced Encryption with Block Ciphers
AES: Advanced Encryption Standard
4 steps:
Electronic Code Book (ECB) Mode
Encryption parallelizable: Yes
Decryption parallelizable: Yes
Cipher Block Chaining (CBC) Mode
c_i = F_k(m_i xor c_i-1)
->also: uses cipher block from before and xor’s it with input block before putting into encryption function; first uses Initialization Vector (IV)
m_i = c_i-1 xor F_k^-1(c_i)
-> also: uses on deception function on cipher then uses from previous block cipher and xor to get plain text; first uses IV
pros:
- some input block not same output twice
- bit flip affects whole message
Encryption parallelizable: No
Decryption parallelizable: Yes
Message Authentication Code (MAC)
Hash Functions
H(m); m = message
hold following:
1. Compression - Output has fixed length
2. Collision resistant - hard to find m and m’ so that H(m)=H’(m)
3. one way - impossible for random m to finding m from H(m) (exception: trying all possibilities)
quality criteria:
Merkle–Damgård Construction
SHA - 1
Hash + MAC
HMAC(k, m) = H((k’ xor opad) | H((k’ xor ipad) | m))
k’ = padded k
opad = 36 in hexadecimal
ipad = 5C in hexadecimal
Diffie-Hellman Key Exchange
X=g^x mod p
Y=g^y mod p
K(ey) = Y^x mod p = X^y mod p
publicly agree on g and p
choose secretly big x and y
calculate key and encrypt, decrypt
Man-in-the-Middle Attack Against DH
RSA – Encryption and Decryption
en- & decryption via modular arithmetic:
m(essage) < n
c = m^e mod n m = c^d mod n
two large primes p and q
n = p * q; z =φ(n) = (p-1)*(q-1)
choose e < z -> no commentary factor with z
find d so that ed-1 exactly divisible by z
p=47 and q=73
e = 425
Show that e is a valid choice for a public RSA exponent and compute the corresponding private exponent d.
we want to show: gcd(e, φ(p · q)) = gcd(425, (47 − 1) · (73 − 1)) = gcd(425, 3312) = 1
3312 = 7·425+337 425 = 1·337+88 337 = 3·88+73 88 = 1·73+15 73 = 4·15+13 15 = 1·13+2 13 = 6·2+1 so gcd(e, φ(p · q)) = 1
1 = 13 − 6 · 2 = 13 − 6 · (15 − 1 · 13)
= 7 · 13 − 6 · 15 = 7 · (73 − 4 · 15) − 6 · 15
= 7 · 73 − 34 · 15 = 7 · 73 − 34 · (88 − 1 · 73)
= 41·73−34·88 = 41·(337−3·88)−34·88
= 41·337−157·88 = 41·337−157·(425−1·337)
= 198·337−157·425 = 198·(3312−7·425)−157·425
= 198·3312−1543·425
So, (−1543) · 425 = 1 mod 3312
d=(−1543)=1769 mod 3312
p = 47 and q = 73
sk = (N,d = 2341) and pk = (N,e = 2125)
Encrypt the message m = 1611
Decrypt the ciphertext c = 3430
c = me = 1611^2125 ≡ 3207 (mod N) m = cd = 3430^2125 ≡ 3430 (mod N)
Hybrid Encryption
- then use private key encryption to communicate
RSA – Digital Signatures
a to b: m, sig = (H(m))^d mod n
b can test via: H(m) = ? = sig^e mod n
e = public key alice d = private key alice