Lecture 2 - Message Integrity
eecs-388
Introduction
- cryptography - the study of techniques for communicating securely in the presence of an adversary
- cryptanalysis - the study of techniques for breaking cryptosystems
- gap between cryptographic theory (beautiful, highly rigorous) and cryptographic practice (delicate engineering)
- message integrity - ensures that attackers cannot modify messages without being detected
Scenario
Setup
- Alice wants to send message m to Bob
- they don’t fully trust the messenger
- they want to ensure Bob receives exactly what Alice sent ()
Threat Model
- adversary Mallory can see/modify/forge messages
- Mallory wants to trick Bob into accepting a message Alice didn’t send
flowchart LR
A[Alice] -- m --> B[Mallory]
B -- m' --> C[Bob]
Approach: Message Verifier
- Alice computes verifier
graph LR A[Alice] -- m,v --> B[Mallory] B -- m',v' --> C[Bob] - Bob verifies that , accepts message iff this is true
is a function that maps every possible input to a pre-computed random output this would require a massive lookup table of size bits
Pseudorandom Functions
Overview
- objective - a function that performs like a random function, but is still within practical constraints
- start with a family of functions , all known to Mallory
- let our verification function where is a secret -bit index known only to Alice and Bob
Security Definition (testing the effectiveness of PRF ):
- choose secret and an RF
- flip a coin to get bit
- if , let if , let
- Mallory chooses ; we announce repeat as many times as Mallory likes
- Mallory guesses in polynomial time
-
in plain english, give Mallory a black box function that is randomly either a RF or PRF. let her run the function on as many functions as she wants, within polynomial time. if she can’t tell the PRF from the RF across multiple runs of this game, then the PRF is secure.
-
we say PRF is a secure if Mallory can’t do meaningfully better than random at guessing if it’s a PRF or RF
-
note that Mallory can always determine if a function is a PRF given infinite time via a brute force attack
Using a PRF for Message Integrity
- let be a secure PRF (public)
- in advance, choose a random key known only to Alice and Bob
- Alice computes $v := f_k(m)
-
graph LR A[Alice w/ k] -- m,v --> B[Mallory] B -- m',v' --> C[Bob w/ k] - Bob verifies that , accepts message iff they are equal
-
if Bob accepts , then is identical to with chance
-
Kerckhoff’s Principle - a cryptosystem should remain secure even if attackers know everything but the key
-
we don’t know if PRFs actually exist (would imply )
Cryptographic Hashes
-
cryptographic hash function - fixed function with no key, and takes inputs of arbitrary length data and outputs a fixed size digest ( bits)
-
properties:
- pre-image resistance - for a given output , hard to find any input such that
- collision resistance - hard to find any pair of inputs
- second pre-image resistance - for a given input , hard to find
-
note that there must exist an infinite number of collisions due to the pigeonhole principle; however, hard to find means computing them is intractable
Hashes with Broken Collision Resistance
MD5
- broken in 2004
- now it’s easy to find collisions SHA-1
- broken in 2017
- computing first collision cost > $100,000
- today costs < $10,000
SHA-256
-
widely used hash function that is currently thought to be strong
-
input: arbitrary length data
-
output: 256-bit digest
-
built from a c
-
uses the Merkle-Damgard (MD) construction to accept arbitrary-length input by repeatedly applying :
- pad the input to next multiple of 512 bits (adds at least 1 bit, uses fixed algorithm) and split into 512-bit blocks:
- <256-bit constant>
- return which is defined to be SHA-256(m)