CSEC3616Cybersecurity Engineering

    Formula sheet

    Every formula across the unit, grouped by module. Every symbol is named — a formula with an unexplained variable is not revision material.

    02Human factors

    Password combinatorics

    N=CLN = C^L
    NN
    total number of possible passwords
    CC
    size of the character set
    LL
    password length in characters

    Password strength and generation

    Password entropy

    H=log⁡2N=Llog⁡2CH = \log_2 N = L \log_2 C
    HH
    entropy in bits
    NN
    total combinations, C^L
    LL
    password length
    CC
    character-set size

    H, not N, is what the lecture and this site mean by "strength" - bits of uncertainty, not a raw count of passwords.

    Password strength and generation

    Passphrase entropy (dice method)

    H=nlog⁡2WH = n \log_2 W
    HH
    entropy in bits
    nn
    number of words chosen
    WW
    wordlist size, 7,776 for the EFF long list, since 6^5 = 7,776

    The same formula as password entropy, with a word standing in for a character and the wordlist standing in for the character set.

    Password strength and generation

    03Access control

    Octal permission digit

    d=4r+2w+xd = 4r + 2w + x
    r,w,xr, w, x
    Each is 1 if that permission is granted, 0 if not.
    dd
    The resulting octal digit, 0 to 7.

    The same formula gives the leading special-bits digit, with r -> SUID (4), w -> SGID (2), x -> sticky (1).

    Unix and Linux permissions

    04Mathematics for cryptography

    Divisibility

    b∣a  ⟺  a=mb for some integer mb \mid a \iff a = mb \text{ for some integer } m
    b∣ab \mid a
    "b divides a" — b is a divisor of a
    a,b,ma, b, m
    integers, b nonzero

    There is no remainder when a is divided by b.

    Divisibility and the greatest common divisor

    Linear combination property

    b∣g and b∣h  ⟹  b∣(mg+nh)b \mid g \text{ and } b \mid h \implies b \mid (mg + nh)
    g,hg, h
    two integers b divides
    m,nm, n
    any integers

    Divisibility and the greatest common divisor

    Division algorithm

    a=qn+r,0≤r<n,q=⌊an⌋a = qn + r, \quad 0 \le r < n, \quad q = \left\lfloor \frac{a}{n} \right\rfloor
    aa
    the dividend, a non-negative integer
    nn
    the divisor, a positive integer
    qq
    the quotient, found by flooring a/n
    rr
    the remainder, always in [0, n)

    Divisibility and the greatest common divisor

    Greatest common divisor

    gcd⁡(a,b)=max⁡{ k:k∣a and k∣b }\gcd(a, b) = \max\{\, k : k \mid a \text{ and } k \mid b \,\}
    a,ba, b
    the two integers
    kk
    a common divisor of a and b

    gcd(a, 0) = |a|, and gcd(0, 0) is defined to be 0.

    Divisibility and the greatest common divisor

    The mod operator

    a mod n=r,a=qn+r,  0≤r<n,  q=⌊an⌋a \bmod n = r, \quad a = qn + r, \ \ 0 \le r < n, \ \ q = \left\lfloor \frac{a}{n} \right\rfloor
    aa
    any integer, positive or negative
    nn
    the modulus, a positive integer
    qq
    the quotient, floor(a/n)
    rr
    the remainder, always in [0, n)

    For negative a, q rounds toward negative infinity, not toward zero — that is what keeps r non-negative.

    Modular arithmetic and residue classes

    Congruence modulo n

    a≡b(modn)  ⟺  (a mod n)=(b mod n)a \equiv b \pmod{n} \iff (a \bmod n) = (b \bmod n)
    a≡b(modn)a \equiv b \pmod{n}
    "a is congruent to b modulo n"
    a,b,na, b, n
    integers; n is the modulus

    a ≡ 0 (mod n) if and only if n | a.

    Modular arithmetic and residue classes

    Modular arithmetic properties

    [(a mod n)∘(b mod n)] mod n=(a∘b) mod n[(a \bmod n) \circ (b \bmod n)] \bmod n = (a \circ b) \bmod n
    ∘\circ
    any of +, -, x
    a,ba, b
    any integers
    nn
    the modulus

    Reduce before combining or after — addition, subtraction and multiplication all give the same answer either way.

    Modular arithmetic and residue classes

    Residue class [r]

    [r]={a:a is an integer, a≡r(modn)}[r] = \{a : a \text{ is an integer}, \ a \equiv r \pmod{n}\}
    [r][r]
    the residue class of r modulo n
    aa
    any integer congruent to r mod n

    The smallest non-negative member of a class is the one normally used to name it.

    Modular arithmetic and residue classes

    Bezout identity

    ax+by=d=gcd⁡(a,b)ax + by = d = \gcd(a, b)
    a,ba, b
    the two input integers
    dd
    gcd(a, b)
    x,yx, y
    the Bezout coefficients — the extended Euclidean algorithm finds both

    x and y are not unique, but the algorithm always produces one valid pair.

    The extended Euclidean algorithm and modular inverses

    Fundamental theorem of arithmetic

    a=p1a1×p2a2×…×ptata = p_1^{a_1} \times p_2^{a_2} \times \ldots \times p_t^{a_t}
    aa
    any integer greater than 1
    p1<p2<…<ptp_1 < p_2 < \ldots < p_t
    the distinct prime factors of a, in increasing order
    aia_i
    the positive integer power of p_i in the factorisation

    This factorisation is unique: there is exactly one way to write a as a product of prime powers.

    Primes, Fermat, Euler and fast modular exponentiation

    Euler's totient function

    φ(n)=∣{ k:1≤k<n, gcd⁡(k,n)=1 }∣\varphi(n) = |\{\, k : 1 \le k < n, \ \gcd(k, n) = 1 \,\}|
    φ(n)\varphi(n)
    the count of positive integers below n that are coprime to n
    nn
    any positive integer

    phi(p) = p - 1 for prime p, since every integer from 1 to p-1 is coprime to p.

    Primes, Fermat, Euler and fast modular exponentiation

    Totient of a product of two primes

    φ(pq)=φ(p)×φ(q)=(p−1)(q−1)\varphi(pq) = \varphi(p) \times \varphi(q) = (p - 1)(q - 1)
    p,qp, q
    two distinct prime numbers
    n=pqn = pq
    their product

    This is the identity RSA key generation runs directly: n = pq, phi(n) = (p-1)(q-1).

    Primes, Fermat, Euler and fast modular exponentiation

    Euler's theorem

    aφ(n)≡1(modn)a^{\varphi(n)} \equiv 1 \pmod{n}
    a,na, n
    any two relatively prime integers, n positive
    φ(n)\varphi(n)
    the Euler totient of n

    Alternative form: a^{phi(n)+1} = a (mod n). Setting n = p prime recovers Fermat's little theorem.

    Primes, Fermat, Euler and fast modular exponentiation

    Order of an element

    ordp(a)=min⁡{ n>0:an≡1(modp) }\mathrm{ord}_p(a) = \min\{\, n > 0 : a^n \equiv 1 \pmod{p} \,\}
    ordp(a)\mathrm{ord}_p(a)
    the order of a modulo p
    pp
    a prime modulus
    aa
    an integer not divisible by p

    The order always divides phi(p) = p - 1.

    Discrete logarithms and primitive roots

    Primitive root condition

    ordp(g)=φ(p)=p−1\mathrm{ord}_p(g) = \varphi(p) = p - 1
    gg
    a primitive root of p
    pp
    a prime

    A primitive root's powers g^1, g^2, ..., g^{p-1} run through every nonzero residue mod p exactly once before repeating.

    Discrete logarithms and primitive roots

    Discrete logarithm problem (DLP)

    y=gx mod py = g^x \bmod p
    pp
    a prime
    gg
    a primitive root of p
    xx
    the discrete logarithm of y to base g: the unknown the problem asks for
    yy
    the given result of the exponentiation

    Computing y from g, x, p is fast (square-and-multiply); recovering x from g, y, p has no known fast general method.

    Discrete logarithms and primitive roots

    Group axioms

    ∀a,b∈G: a+b∈G;∃ 0∈G: a+0=a;∃ −a∈G: a+(−a)=0\forall a, b \in G: \ a + b \in G; \quad \exists\, 0 \in G: \ a + 0 = a; \quad \exists\, -a \in G: \ a + (-a) = 0
    GG
    the set, with a binary operation written + here
    00
    the identity element
    −a-a
    the inverse of a

    Closure, associativity, identity, inverse. Add commutativity (a+b=b+a) and the group is abelian.

    Groups, rings and fields

    Ring axioms

    (R,+) abelian;a⋅(b+c)=a⋅b+a⋅c;(a+b)⋅c=a⋅c+b⋅c(R, +) \text{ abelian}; \quad a \cdot (b + c) = a \cdot b + a \cdot c; \quad (a+b) \cdot c = a \cdot c + b \cdot c
    RR
    the set, with addition and multiplication
    (R,+) abelian(R, +) \text{ abelian}
    R is an abelian group under addition

    Multiplication must be closed and associative, and distribute over addition. Neither a multiplicative identity nor multiplicative commutativity is required.

    Groups, rings and fields

    Commutative ring

    a⋅b=b⋅a∀a,b∈Ra \cdot b = b \cdot a \quad \forall a, b \in R
    RR
    a ring

    A ring where multiplication is also commutative.

    Groups, rings and fields

    Field axioms

    ∀a≠0∈F, ∃ a−1∈F: a⋅a−1=1\forall a \neq 0 \in F, \ \exists\, a^{-1} \in F: \ a \cdot a^{-1} = 1
    FF
    a commutative ring with a multiplicative identity 1
    a−1a^{-1}
    the multiplicative inverse of a

    A field is a commutative ring where every nonzero element has a multiplicative inverse. Z is not a field; Q is.

    Groups, rings and fields

    Prime field GF(p)

    GF(p)={0,1,…,p−1},addition and multiplication mod p\mathrm{GF}(p) = \{0, 1, \ldots, p-1\}, \quad \text{addition and multiplication mod } p
    pp
    a prime number

    Also written F_p. Characteristic p is the smallest number of copies of any element that sum to 0.

    Finite fields, GF(p) and GF(2^n)

    Extension field GF(p^n)

    GF(pn),n>1\mathrm{GF}(p^n), \quad n > 1
    pp
    a prime (2 for every field on this page)
    nn
    the extension degree

    Built from GF(p) by adjoining the roots of a degree-n irreducible polynomial over GF(p).

    Finite fields, GF(p) and GF(2^n)

    GF(2^3) irreducible polynomial

    p(x)=x3+x+1p(x) = x^3 + x + 1
    p(x)p(x)
    the modulus every multiplication in GF(2^3) reduces by

    Cannot be factored into lower-degree polynomials with coefficients in GF(2), which is what makes it irreducible over GF(2).

    Finite fields, GF(p) and GF(2^n)

    AES irreducible polynomial

    m(x)=x8+x4+x3+x+1m(x) = x^8 + x^4 + x^3 + x + 1
    m(x)m(x)
    the modulus every GF(2^8) multiplication in AES reduces by

    In binary: 100011011, or 0x11B.

    Finite fields, GF(p) and GF(2^n)

    05Symmetric cryptography

    Encryption and decryption

    Encke(p)=c,Deckd(c)=p\text{Enc}_{k_e}(p) = c, \qquad \text{Dec}_{k_d}(c) = p
    pp
    plaintext, drawn from an alphabet R
    cc
    ciphertext, drawn from an alphabet S that need not match R, in size or content
    kek_e
    the encryption key
    kdk_d
    the decryption key

    In symmetric cryptography k_e = k_d, or k_d is trivially derivable from k_e. In asymmetric cryptography neither holds.

    Cryptography basics and Kerckhoffs's principle

    Caesar cipher

    Ci=(Pi+n) mod 26,Pi=(Ci−n) mod 26C_i = (P_i + n) \bmod 26, \qquad P_i = (C_i - n) \bmod 26
    Pi,CiP_i, C_i
    the numeric value (A=0 .. Z=25) of the i-th plaintext and ciphertext letter
    nn
    the shift, a fixed integer from 0 to 25

    Every letter uses the same shift n: one fixed rule for the whole message, which is exactly what frequency analysis exploits.

    Substitution, transposition and frequency analysis

    Caesar cipher keyspace

    ∣K∣=26|K| = 26
    ∣K∣|K|
    the number of distinct keys

    A 26-letter alphabet gives 26 possible shifts, of which the shift of 0 does nothing to the plaintext, so 25 keys actually change the message.

    Substitution, transposition and frequency analysis

    Vigenère encryption and decryption

    Ci=(Pi+Ki mod L) mod 26,Pi=(Ci−Ki mod L+26) mod 26C_i = (P_i + K_{i \bmod L}) \bmod 26, \qquad P_i = (C_i - K_{i \bmod L} + 26) \bmod 26
    Pi,CiP_i, C_i
    the numeric value of the i-th plaintext and ciphertext letter
    KjK_j
    the numeric value of the j-th letter of the key
    LL
    the length of the key

    i mod L cycles the key to match however long the plaintext is; +26 before the mod in decryption keeps the result non-negative.

    The Vigenère cipher and the Kasiski examination

    Vigenère keyspace

    ∣K∣=26L|K| = 26^{L}
    ∣K∣|K|
    the number of distinct keys of length L
    LL
    the key length in letters

    Grows exponentially with key length: a 3-letter key already gives 26^3 = 17,576 possible keys, far more than Caesar's 26, but still small enough that a short key is worth attacking directly, which is exactly what the Kasiski examination does.

    The Vigenère cipher and the Kasiski examination

    One-time pad encryption and decryption

    c=p⊕k,p=c⊕kc = p \oplus k, \qquad p = c \oplus k
    pp
    plaintext bits
    cc
    ciphertext bits
    kk
    the one-time key (the pad), the same length as p

    XOR is its own inverse, so encryption and decryption are the same operation.

    Stream ciphers and the one-time pad

    Many-time pad key-reuse relationship

    P=C1⊕C2=P1⊕P2P = C_1 \oplus C_2 = P_1 \oplus P_2
    C1,C2C_1, C_2
    two ciphertexts produced under the same reused key K
    P1,P2P_1, P_2
    the plaintexts behind them
    PP
    C_1 XOR C_2, independent of the key entirely

    The key cancels out completely, because K XOR K is all zeros.

    Stream ciphers and the one-time pad

    DES S-box addressing

    row=2b0+b5,col=8b1+4b2+2b3+b4\text{row} = 2b_0 + b_5, \qquad \text{col} = 8b_1 + 4b_2 + 2b_3 + b_4
    b0,b5b_0, b_5
    the outer two bits of the 6-bit S-box input — together they give a row from 0 to 3
    b1b2b3b4b_1 b_2 b_3 b_4
    the inner four bits, read as a 4-bit number — a column from 0 to 15

    DES has eight S-boxes addressed this way. S[0] is worked in full below.

    Block ciphers, S-boxes, P-boxes and Feistel

    Feistel round

    Ln+1=Rn,Rn+1=Ln⊕F(Rn,Kn)L_{n+1} = R_n, \qquad R_{n+1} = L_n \oplus F(R_n, K_n)
    Ln,RnL_n, R_n
    the left and right halves entering round n
    FF
    the round function, keyed by the round subkey
    KnK_n
    the subkey used in round n
    ⊕\oplus
    bitwise XOR

    Block ciphers, S-boxes, P-boxes and Feistel

    DES keyspace

    ∣K∣=256≈7.2×1016|K| = 2^{56} \approx 7.2 \times 10^{16}
    KK
    the set of all possible DES keys
    5656
    the DES key length in bits

    DES and 3DES

    Average-case brute-force time

    T=255RT = \frac{2^{55}}{R}
    TT
    expected time to find the key, in seconds
    2552^{55}
    half the keyspace — the average number of keys tried before a hit
    RR
    attack rate, in keys tried per second

    Worst case tries the full 2^56; on average a hit comes after trying half the keyspace.

    DES and 3DES

    3DES effective key sizes

    56×2=112,56×3=16856 \times 2 = 112, \qquad 56 \times 3 = 168
    5656
    one DES key length
    2,32, 3
    the number of independent DES keys, for two-key and three-key 3DES

    The unit teaches these as the effective strengths. See the discrepancy noted below for what NIST rates instead.

    DES and 3DES

    AES round count by key size

    Nr={10Nk=412Nk=614Nk=8N_r = \begin{cases} 10 & N_k = 4 \\ 12 & N_k = 6 \\ 14 & N_k = 8 \end{cases}
    NkN_k
    key length in 32-bit words — 4, 6 or 8 for AES-128, AES-192, AES-256
    NrN_r
    number of rounds for that key size

    AES

    Key expansion size

    w=Nb(Nr+1)w = N_b (N_r + 1)
    NbN_b
    block size in 32-bit words — fixed at 4 for every AES key size, since the block is always 128 bits
    NrN_r
    number of rounds for the chosen key size
    ww
    total 32-bit words produced by key expansion, one round key of N_b words per round plus one extra for the initial AddRoundKey

    The lecture works the AES-128 case only: w = 4(10+1) = 44 words, 176 bytes. The same formula gives 52 words for AES-192 and 60 for AES-256.

    AES

    AES finite field

    m(x)=x8+x4+x3+x+1m(x) = x^8 + x^4 + x^3 + x + 1
    m(x)m(x)
    the irreducible polynomial AES reduces modulo, defining GF(2^8)

    Every AES byte operation — SubBytes and MixColumns — is arithmetic in this field.

    AES

    ECB

    Ci=Ek(Pi)C_i = E_k(P_i)
    PiP_i
    plaintext block i
    CiC_i
    ciphertext block i
    EkE_k
    the block cipher's encryption function under key k

    No chain-in at all. Every block is encrypted exactly as if it were the only block in the message.

    Modes of operation

    CBC encrypt

    Ci=Ek(Pi⊕Ci−1)C_i = E_k(P_i \oplus C_{i-1})
    Pi,CiP_i, C_i
    plaintext and ciphertext block i
    Ci−1C_{i-1}
    the previous ciphertext block, or the IV when i = 0
    EkE_k
    the block cipher's encryption function under key k

    The first block has no previous ciphertext, so C_{-1} is replaced by the IV.

    Modes of operation

    CBC decrypt

    Pi=Dk(Ci)⊕Ci−1P_i = D_k(C_i) \oplus C_{i-1}
    DkD_k
    the block cipher's decryption function under key k
    Ci,Ci−1C_i, C_{i-1}
    the current and previous ciphertext blocks

    Every block of ciphertext is already available before decryption starts, unlike encryption, which must run in order.

    Modes of operation

    CTR keystream

    Ci=Pi⊕Ek(nonce∥i)C_i = P_i \oplus E_k(\text{nonce} \Vert i)
    ii
    the per-block counter value, incremented once per block
    nonce\text{nonce}
    a value combined with the counter, never reused under the same key
    Ek(nonce∥i)E_k(\text{nonce}\Vert i)
    the keystream block for position i

    Every block's keystream depends only on the nonce and its own counter value, never on another block's ciphertext. This is what lets CTR parallelise.

    Modes of operation

    06Asymmetric cryptography

    One-way function

    Y=f(X)  ⟹  easy,X=f−1(Y)  ⟹  infeasibleY = f(X) \implies \text{easy}, \qquad X = f^{-1}(Y) \implies \text{infeasible}
    XX
    the input, from the function's domain
    YY
    the output, from the function's range
    ff
    the one-way function itself

    Every output has a unique inverse; computing it just is not feasible without extra information.

    Public-key cryptography and trapdoor functions

    Trapdoor one-way function

    Y=fk(X)  ⟹  easy,X=fk−1(Y)  ⟹  easy if k known, infeasible if k unknownY = f_k(X) \implies \text{easy}, \qquad X = f_k^{-1}(Y) \implies \text{easy if } k \text{ known, infeasible if } k \text{ unknown}
    X,YX, Y
    input and output, as above
    kk
    the trapdoor — a piece of extra information
    fkf_k
    the function, parameterised by the trapdoor

    Every public-key cryptosystem in this module is one instance of this idea.

    Public-key cryptography and trapdoor functions

    Discrete Logarithm Problem (DLP)

    y=gx mod py = g^{x} \bmod p
    pp
    a prime number
    gg
    a primitive root of p
    xx
    the value to find — the discrete logarithm of y
    yy
    the given result of raising g to the power x

    Finding x given p, g and y is believed infeasible for a large enough p.

    Public-key cryptography and trapdoor functions

    RSA problem

    c=me mod nc = m^{e} \bmod n
    nn
    the modulus
    ee
    the public exponent
    mm
    the value to find — the e-th root of c
    cc
    the given result of raising m to the power e

    Finding m given c, e and n is believed infeasible for certain n.

    Public-key cryptography and trapdoor functions

    RSA key generation

    n=pq,φ(n)=(p−1)(q−1),gcd⁡(e,φ(n))=1,d≡e−1(modφ(n))n = pq, \qquad \varphi(n) = (p-1)(q-1), \qquad \gcd(e, \varphi(n)) = 1, \qquad d \equiv e^{-1} \pmod{\varphi(n)}
    p,qp, q
    two distinct primes, chosen and then discarded
    nn
    the modulus, published as part of both keys
    φ(n)\varphi(n)
    Euler's totient of n — kept secret, discarded after key generation
    ee
    the public exponent, 1 < e < \varphi(n)
    dd
    the private exponent, the modular inverse of e mod \varphi(n)

    Public key PU = {e, n}. Private key PR = {d, n}.

    RSA

    Euler's totient of a semiprime

    φ(n)=(p−1)(q−1)when n=pq, p≠q both prime\varphi(n) = (p-1)(q-1) \quad \text{when } n = pq,\ p \neq q \text{ both prime}
    nn
    the RSA modulus, a product of two distinct primes
    p,qp, q
    the two prime factors of n

    The shortcut used throughout RSA key generation — see 04-04 for the general definition of phi.

    RSA

    RSA encryption

    C=Me mod nC = M^{e} \bmod n
    MM
    the plaintext, an integer with 0 \le M < n
    e,ne, n
    the public key
    CC
    the ciphertext

    RSA

    RSA decryption

    M=Cd mod nM = C^{d} \bmod n
    CC
    the ciphertext
    d,nd, n
    the private key
    MM
    the recovered plaintext

    RSA

    RSA malleability

    c′≡c⋅re(modn),(c′)d≡m⋅r(modn)c' \equiv c \cdot r^{e} \pmod{n}, \qquad (c')^{d} \equiv m \cdot r \pmod{n}
    cc
    the intercepted ciphertext, c = m^e mod n
    rr
    any value the attacker chooses
    e,ne, n
    the victim's public key
    c′c'
    the modified ciphertext the attacker submits for decryption
    dd
    the victim's private exponent, never seen by the attacker
    mm
    the original plaintext, still unknown to the attacker at this point

    The attacker never learns d and never sees m directly, but recovers m from the decrypted (c')^d by dividing out r.

    RSA security, attacks, padding and hybrid encryption

    Diffie-Hellman shared secret

    K=Ya mod p=Xb mod p=gab mod pK = Y^{a} \bmod p = X^{b} \bmod p = g^{ab} \bmod p
    pp
    a public prime modulus
    gg
    a public primitive root (generator) of p
    a,ba, b
    Alice's and Bob's private exponents, never sent
    X,YX, Y
    the public values X = g^a mod p and Y = g^b mod p, exchanged in the open
    KK
    the shared secret both sides compute independently

    K = g^(ab) mod p either way the exponents are applied, which is why the two sides agree without ever sending a or b.

    Diffie-Hellman key exchange

    Elliptic curve over a prime field

    Ep(a,b):y2≡x3+ax+b(modp)E_p(a,b): \quad y^{2} \equiv x^{3} + ax + b \pmod{p}
    pp
    a prime defining the field the curve is drawn over
    a,ba, b
    the curve's two coefficients
    x,yx, y
    coordinates of a point on the curve, both reduced mod p

    Over the reals (no modulus) this is the same equation and gives the familiar smooth curve used for the geometric picture of point addition.

    Elliptic curve cryptography

    Elliptic curve over a binary field

    y2+xy=x3+ax2+bover GF(2m)y^{2} + xy = x^{3} + ax^{2} + b \quad \text{over } GF(2^{m})
    GF(2m)GF(2^m)
    the binary field the curve is defined over, see finite fields for the general construction
    a,ba, b
    the curve's coefficients, themselves elements of GF(2^m)
    x,yx, y
    coordinates, also elements of GF(2^m)

    A different equation from the prime-field case, not the same one with a different modulus. Addition and subtraction in GF(2^m) both reduce to XOR.

    Elliptic curve cryptography

    Elliptic curve discrete logarithm problem

    Q=kPQ = kP
    PP
    a known point on the curve, often the agreed base point G
    kk
    the value to find: a scalar less than the order of P
    QQ
    the given result of adding P to itself k times

    Finding k given only P and Q is believed harder, bit for bit, than the classical discrete logarithm problem, which is why ECC keys are shorter than RSA or Diffie-Hellman keys for the same security level.

    Elliptic curve cryptography

    ECDH shared secret

    K=nA⋅PB=nA⋅(nB⋅G)=nB⋅(nA⋅G)=nB⋅PAK = n_A \cdot P_B = n_A \cdot (n_B \cdot G) = n_B \cdot (n_A \cdot G) = n_B \cdot P_A
    GG
    the public base point, with public order n
    nA,nBn_A, n_B
    Alice's and Bob's private scalars
    PA,PBP_A, P_B
    the public points P_A = n_A G and P_B = n_B G
    KK
    the shared point both sides compute independently

    The same commutativity trick as classical Diffie-Hellman, with scalar point multiplication standing in for modular exponentiation.

    Elliptic curve cryptography

    Grover's algorithm: effective symmetric key strength

    beff=b2b_{\text{eff}} = \frac{b}{2}
    bb
    the nominal length of a symmetric key, in bits
    beffb_{\text{eff}}
    the effective security level against a quantum adversary running Grover's algorithm

    A 256-bit key offers security comparable to a 128-bit key against a quantum adversary, per the lecture. Doubling key sizes is the stated mitigation.

    Post-quantum cryptography

    08Hashes and MACs

    Hash function

    h=H(M)h = H(M)
    MM
    the input message, of variable length
    HH
    the hash function
    hh
    the hash value, digest or checksum: fixed-size regardless of the length of M

    The input space is far larger than the fixed output space, so collisions, two different messages with the same hash, always exist. A good hash function still spreads its outputs evenly enough that finding one is infeasible.

    Hash functions and what they are for

    Preimage resistance

    ∀y∈range(H): finding x such that H(x)=y is computationally infeasible\forall y \in \text{range}(H):\ \text{finding } x \text{ such that } H(x) = y \text{ is computationally infeasible}
    yy
    a hash value, chosen at random from H's range of possible outputs
    xx
    the preimage being searched for
    HH
    the hash function

    Not impossible, brute force always works in principle, just infeasible in practice.

    Preimage, second preimage and collision resistance

    Second preimage resistance

    given a random x: finding x′≠x such that H(x′)=H(x) is computationally infeasible\text{given a random } x:\ \text{finding } x' \neq x \text{ such that } H(x') = H(x) \text{ is computationally infeasible}
    xx
    a given, already-known input
    x′x'
    a different input the attacker searches for

    The attacker is handed x and must match it exactly, unlike collision resistance below.

    Preimage, second preimage and collision resistance

    Collision resistance

    finding any pair (x,x′), x≠x′, with H(x)=H(x′) is computationally infeasible\text{finding any pair } (x, x'),\ x \neq x',\ \text{with } H(x) = H(x') \text{ is computationally infeasible}
    x,x′x, x'
    any two distinct inputs, neither fixed in advance

    Collision resistance implies second preimage resistance: a successful second-preimage attack is itself a valid collision. The reverse implication does not hold.

    Preimage, second preimage and collision resistance

    Birthday attack, general form

    after N choices, P(repeat)>0.5\text{after } \sqrt{N} \text{ choices, } P(\text{repeat}) > 0.5
    NN
    the size of the uniform range the values are drawn from

    Applies to any uniformly-distributed random variable, not only hash outputs, the classic case being 365 possible birthdays.

    The birthday attack and output length

    Birthday attack on an n-bit hash

    2n=2n/2\sqrt{2^n} = 2^{n/2}
    nn
    the hash function's output length, in bits
    2n2^n
    the total number of possible hash values
    2n/22^{n/2}
    the number of attempts needed for a better-than-50% chance of finding some collision

    For n = 160, the currently accepted minimum, this is 2^80 attempts.

    The birthday attack and output length

    SHA-512 padding

    L+1+k≡896(mod1024)L + 1 + k \equiv 896 \pmod{1024}
    LL
    the original message length, in bits
    11
    a single appended 1 bit
    kk
    the number of 0 bits appended after it, chosen to satisfy the congruence

    After this padding, a 128-bit encoding of L is appended, bringing the total to an exact multiple of 1024 bits.

    SHA-2 and SHA-3

    SHA-3 state size

    b=r+cb = r + c
    bb
    the total width of the permutation state, in bits
    rr
    the rate: bits absorbed or squeezed per application of the permutation f
    cc
    the capacity: bits held back from direct message input or output, the security margin

    A larger r means faster hashing (more bits processed per round) at the cost of a smaller c, and therefore less security margin. Different SHA-3 variants just move this split.

    SHA-2 and SHA-3

    MAC

    MAC=C(K,M)MAC = C(K, M)
    MM
    the input message
    KK
    the secret key, shared between sender and receiver
    CC
    the MAC function

    Also called a cryptographic checksum. The MAC is sent alongside the original message, unlike encryption, which replaces it.

    Message authentication codes and HMAC

    HMAC

    HMAC(K,M)=H[(K⊕opad)∥H[(K⊕ipad)∥M]]HMAC(K, M) = H\big[(K \oplus \text{opad}) \Vert H[(K \oplus \text{ipad}) \Vert M]\big]
    HH
    any cryptographic hash function, e.g. MD5, SHA-1, SHA-2
    KK
    the shared secret key
    MM
    the input message
    ipad,opad\text{ipad}, \text{opad}
    publicly known constant bit strings, required for HMAC's security proof to hold

    ipad = 0x36 repeated for the block length; opad = 0x5c repeated for the block length. Their precise values matter little beyond that, per the slides.

    Message authentication codes and HMAC

    The four AE approaches

    H→E:EK(M∥H(M))A→E:EK2(M∥MACK1(M))E→A:(EK2(M), MACK1(EK2(M)))E + A:(EK2(M), MACK1(M))\begin{aligned} \text{H} \to \text{E}: &\quad E_K(M \Vert H(M)) \\ \text{A} \to \text{E}: &\quad E_{K_2}(M \Vert \text{MAC}_{K_1}(M)) \\ \text{E} \to \text{A}: &\quad \big(E_{K_2}(M),\ \text{MAC}_{K_1}(E_{K_2}(M))\big) \\ \text{E + A}: &\quad \big(E_{K_2}(M),\ \text{MAC}_{K_1}(M)\big) \end{aligned}
    MM
    the plaintext message
    EKE_K
    encryption under key K
    H(M)H(M)
    the message's hash
    MACK(x)\text{MAC}_{K}(x)
    the MAC of x under key K
    K1,K2K_1, K_2
    two independent keys, one for the MAC and one for encryption, used in every approach except H then E

    A->E is used in SSL/TLS, E->A is used in IPSec and is considered the strongest, E+A is used in SSH.

    Authenticated encryption, GCM and CCM

    RSA signature generation

    Signature=E(PRa,H(M))\text{Signature} = E(PR_a, H(M))
    MM
    the message being signed
    H(M)H(M)
    the message's secure hash, e.g. under SHA
    PRaPR_a
    the sender's (Alice's) private key
    EE
    RSA encryption, here used to produce the signature rather than for confidentiality

    Digital signatures, DSA and RSA

    RSA signature verification

    D(PUa,Signature)=?H(M)D(PU_a, \text{Signature}) \stackrel{?}{=} H(M)
    PUaPU_a
    the sender's public key
    DD
    RSA decryption, applied here to the received signature
    H(M)H(M)
    the verifier's own hash of the received message

    The signature is accepted only if decrypting it with the sender's public key reproduces the verifier's own computed hash exactly.

    Digital signatures, DSA and RSA

    09Authentication and key distribution

    Confidentiality and authentication of a secret key

    M=E(PUb,E(PRa,Ks))M = E(PU_b, E(PR_a, K_s))
    KsK_s
    the secret (session) key A wants to give B
    PRaPR_a
    A's private key: encrypting with it is what only A could have produced
    PUbPU_b
    B's public key: encrypting with it means only B can read the result
    MM
    the message A actually sends, protected by both layers at once

    B recovers K_s by undoing the layers in reverse: D(PU_a, D(PR_b, M)). Encrypting with A's own private key is what proves origin; encrypting again with B's public key is what hides it from anyone but B.

    Distributing symmetric keys with public-key encryption

    Certificate creation

    CA=E(PRauth,[T∥IDA∥PUa])C_A = E(PR_{auth}, [T \Vert ID_A \Vert PU_a])
    PRauthPR_{auth}
    the certificate authority's private key
    TT
    a timestamp, used to judge whether the certificate is still valid
    IDA,PUaID_A, PU_a
    the holder's identifier and public key, the binding the certificate vouches for

    The whole block is encrypted (signed) with the authority's private key, which is what makes the binding trustworthy to anyone who trusts that authority.

    Public-key certificates and X.509

    Certificate verification

    D(PUauth,CA)=(T∥IDA∥PUa)D(PU_{auth}, C_A) = (T \Vert ID_A \Vert PU_a)
    PUauthPU_{auth}
    the certificate authority's public key, known in advance by the verifier
    CAC_A
    the certificate as received from A or from a directory

    A successful decryption under PU_auth is itself the proof the certificate came from the authority, since only the authority holds PR_auth.

    Public-key certificates and X.509

    Combined session key from a mutual hybrid exchange

    k=f(kA∥kB)k = f(k_A \Vert k_B)
    kAk_A
    the key half A contributes, sent as Enc_{k_e,B}(k_A), Sig_A(k_A)
    kBk_B
    the key half B contributes, sent as Enc_{k_e,A}(k_B), Sig_B(k_B)
    ff
    a combining function applied to both halves

    Both parties contribute to k, so one party accidentally picking a poor key half does not, by itself, make the scheme insecure.

    Authenticated key establishment

    Needham-Schroeder message 1: initiate

    A→AS:IDA∥IDB∥N1A \to AS: ID_A \Vert ID_B \Vert N_1
    IDA,IDBID_A, ID_B
    identifiers of A and B
    N1N_1
    a nonce identifying this session, chosen by A

    Needham-Schroeder and Kerberos

    Needham-Schroeder message 2: AS response

    AS→A:E(Ka,[Ks∥IDA∥IDB∥N1])∥E(Kb,[Ks∥IDA])AS \to A: E(K_a, [K_s \Vert ID_A \Vert ID_B \Vert N_1]) \Vert E(K_b, [K_s \Vert ID_A])
    KsK_s
    the fresh session key the AS generates for this exchange
    Ka,KbK_a, K_b
    the long-term master keys A and B each share with the AS

    The first block, decryptable only by A, carries K_s and A's own request (including N_1) back, so A can confirm freshness. The second block is the ticket meant for B; A cannot read it.

    Needham-Schroeder and Kerberos

    Needham-Schroeder message 3: forward the ticket

    A→B:E(Kb,[Ks∥IDA])A \to B: E(K_b, [K_s \Vert ID_A])
    E(Kb,[Ks∥IDA])E(K_b, [K_s \Vert ID_A])
    the ticket A relays to B unopened, exactly as received from the AS

    Needham-Schroeder and Kerberos

    Needham-Schroeder message 4: B's challenge

    B→A:E(Ks,N2)B \to A: E(K_s, N_2)
    N2N_2
    a fresh nonce B generates, proving to itself that A's next reply is current

    Needham-Schroeder and Kerberos

    Needham-Schroeder message 5: A's response

    A→B:E(Ks,f(N2))A \to B: E(K_s, f(N_2))
    f(N2)f(N_2)
    a generic transformation of N_2, e.g. incrementing it, proving A holds K_s and answered this specific challenge

    Needham-Schroeder and Kerberos

    Kerberos exchange 1: client requests a ticket-granting ticket

    C→AS:IDc∥IDtgs∥TS1C \to AS: ID_c \Vert ID_{tgs} \Vert TS_1
    IDcID_c
    the client's identity
    IDtgsID_{tgs}
    tells the AS the user requests access to the TGS
    TS1TS_1
    lets the AS verify the client's clock is synchronised with its own

    Needham-Schroeder and Kerberos

    Kerberos exchange 2: AS returns the ticket-granting ticket

    AS→C:E(Kc,[Kc,tgs∥IDtgs∥TS2∥Lifetime2∥Tickettgs])AS \to C: E(K_c, [K_{c,tgs} \Vert ID_{tgs} \Vert TS_2 \Vert \text{Lifetime}_2 \Vert \text{Ticket}_{tgs}])
    KcK_c
    a key derived from the user's password, letting the AS and client verify the password and protecting the message contents
    Kc,tgsK_{c,tgs}
    a session key the AS creates for the client and TGS to use, so they need no permanent shared key
    IDtgsID_{tgs}
    confirms this ticket is for the TGS
    TS2TS_2
    tells the client when this ticket was issued
    Lifetime2\text{Lifetime}_2
    tells the client how long this ticket remains valid
    Tickettgs\text{Ticket}_{tgs}
    the ticket-granting ticket itself, used by the client to access the TGS

    Needham-Schroeder and Kerberos

    Kerberos exchange 3: client requests a service-granting ticket

    C→TGS:IDv∥Tickettgs∥AuthenticatorcC \to TGS: ID_v \Vert \text{Ticket}_{tgs} \Vert \text{Authenticator}_c
    IDvID_v
    tells the TGS the user requests access to server V
    Tickettgs\text{Ticket}_{tgs}
    assures the TGS this user was already authenticated by the AS
    Authenticatorc\text{Authenticator}_c
    generated by the client to let the TGS validate the ticket

    Needham-Schroeder and Kerberos

    Kerberos exchange 4: TGS returns the service-granting ticket

    TGS→C:E(Kc,tgs,[Kc,v∥IDv∥TS4∥Ticketv])TGS \to C: E(K_{c,tgs}, [K_{c,v} \Vert ID_v \Vert TS_4 \Vert \text{Ticket}_v])
    Kc,tgsK_{c,tgs}
    the key shared only by client and TGS, protecting this message's contents
    Kc,vK_{c,v}
    the session key for the client and server V
    IDvID_v
    confirms this ticket is for server V
    Ticketv\text{Ticket}_v
    the ticket used to access server V

    TS_4 is not separately glossed in the notes; by the same pattern as TS_2, it records when this ticket was issued.

    Needham-Schroeder and Kerberos

    Kerberos exchange 5: client requests service

    C→Sv:Ticketv∥AuthenticatorcC \to S_v: \text{Ticket}_v \Vert \text{Authenticator}_c
    Ticketv\text{Ticket}_v
    assures server V this user was authenticated by the AS

    Needham-Schroeder and Kerberos

    Kerberos exchange 6: optional server authentication

    Sv→C:E(Kc,v,[TS5+1])S_v \to C: E(K_{c,v}, [TS_5 + 1])
    Kc,vK_{c,v}
    assures the client this reply genuinely came from V
    TS5+1TS_5 + 1
    assures the client this is not a replay of an earlier reply

    Needham-Schroeder and Kerberos

    10Network security: protocols

    Usable hosts per subnet

    2h−22^{h} - 2
    hh
    number of bits remaining for the host portion of the address

    The 2 subtracted are the subnet's network address and its broadcast address, neither of which can be assigned to a host.

    Network layer: IP addressing, subnets, NAT and IPv6