Cryptography Flashcards
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:
- output is exactly n long
- output should look random
Advanced Encryption with Block Ciphers
- separate long text in several smaller blocks
- ciphertext shouldn’t be longer than plaintext
- decryption efficient (comparable to encryption)
- patterns of plain text not visible in cipher
- same key user several times
AES: Advanced Encryption Standard
4 steps:
- Octet-for-Octet substitution with fixed Box
- Rearrangment of Octets with rotation of row/column
- MixColum; replace 4B columns by another
- AddRoundKey operation; e.g. xor
Electronic Code Book (ECB) Mode
- separate text into blocks -> then use on each block same encryption function with same key
cons: - twice same block will result in same cipher output
- attacker can modify single blocks without rest affected (harder detection)
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)
- both have a secret key
- > send message and then add message encrypted with secret key
- > reciter can with a secret key verify if m correct
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:
- Collision resistance - Find any m, m’ such that H(m) = H(m’)
- Preimage resistance - Given H(m) finding m
- Second preimage resistance - given H(m) and m hard to find m’ so that H(m) = H(m’), m != m’
Merkle–Damgård Construction
- separate m into blocks w_0 … w_n
- have an IV
take IV and w_0 and put into a function
take above output and w_1 and put into a function
do this till last word and have the hash
SHA - 1
- need at least 512 bit block; if not pading with 1x’1’ and rest ‘0’
- separate into 80 words
- have IV
- put each word into compression function and rotate inside with each w
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
- intercept X and Y from both parties
- send both different Y’ and X’, so when the key is computed attacker know from x and y the key
- can now decrypt all incoming texts since he has both keys