Definitions

  • Information security: protecting information and information systems from unauthorized access, use, disclosure, disruption, modification, or destruction.

Security Properties

  • Confidentiality:

    • No improper disclosure of information. or
    • No unauthorized access to information.
  • Privacy: Confidentiality of information that you don’t want to share.

  • Anonymity: Confidentiality of your identity.

  • Integrity:

    • No improper modification of information. or
    • No unauthorized modification of information.
  • Availability:

    • No improper impairment of functionality/service. or
    • No unauthorized impairment of functionality
  • Authentication: Principals or data origin can be identified accurately

  • Non-repudiation: Actions done cannot be denied

  • Accountability: Actions can be traced to responsible principals

Encryption Scheme

where E(Key1,P)=CE(Key_1, P) = C and D(Key2,C)=PD(Key_2, C) = P.

  • Symmetric algorithms:
    • Key1=Key2Key_1 = Key_2, or are easily derived from each other.
  • Asymmetric algorithms:
    • Key1Key2Key_1 \neq Key_2
    • Public key can be published without compromising private key.

Security depends only on secrecy of the key, not on the algorithm

Mathematical Formalization

Let MM be the message space, and mMm \in M is plaintext.

Similarly, let CC be the ciphertext space, and cCc \in C is ciphertext.

Let KK be the key space, and e,dKe, d \in K.

For each eKe \in K determines a bijective function EeE_e from MM to CC, and similarly, for each dKd \in K determines a bijective function DdD_d from CC to MM.

So we could represent as follows:

Ee(M)=CE_e(M) = C or E(M,e)=CE(M, e) = C

and

Dd(C)=MD_d(C) = M or D(C,d)=MD(C, d) = M

Since that the encryption function EE and decryption function DD are bijiective, for each element in set MM and CC should have its pair in the opposite set.

Characteristics of Cryptographic Systems

  • Type of operations used to transform plaintext into ciphertext

    • based on two general principles:
      • Substitution: each element in plaintext (bit, letter) is mapped into another element.
      • Transposition: elements in plaintext are rearranged
    • Most systems involve multiple stage substitutions and transpositions.
  • Number of keys used

    • Symmetric, single-key, secret-key, or conventional encryption: sender and receiver use same key
    • Asymmetric, two-key, public-key encryption: sender and receiver use different keys
  • Way in which plaintext is processed

    • Block cipher: processes input one block of elements at a time, producing an output block for each input block.
    • Stream cipher: processes input elements continuously, producing in output one element at a time, as it goes along.

Symmetric key encryption

For symmetric encryption scheme EeeK\\{E_e | e \in K\\} and DddK\\{D_d | d \in K\\}, e,d\\{e, d\\} are easy to derived from each other or just e=de = d

  • Also known as: secret-key, single-key, one-key, shared-key, conventional encryption.

Historical Ciphers

Caesar Cipher

C=E(K,M)=(M+K)mod26C = E(K, M) = (M + K) \mod 26

M=D(K,C)=(CK)mod26M = D(K, C) = (C - K) \mod 26

where M,CAlphabetsM, C \in Alphabets and AlphabetsAlphabets are mapped into 0,1,...,25\\{0, 1, ..., 25\\}

Especially, when we set K=13K = 13, the function is called ROT13, where EE is equivalent to DD

Mono-alphabetic substitution ciphers

Map a element in AA into a element in CC

Homophonic substitution ciphers

Map a element in AA into multiple elements in CC

For communicators: This relationship/set is the key

For cryptanalysis: frequency analysis is more difficult

For example:

for A=x,yA = \\{x, y\\}, declares keys Kx=00,10K_x = \\{00, 10\\} and Ky=01,11K_y = \\{01, 11\\}.

The plaintext xy encrypts to one of 0001, 0011, 1001, 1011

Playfair Cipher

steps:

  1. Pick keyword (here: monarchy)
  2. Construct matrix: fill in letters of keyword (minus duplicates) left2right & top2bottom, and remaining letters in alphabetic order, where I and J count as one letter.
  3. Plaintext is encrypted two letters at a time:
  4. If a pair is a repeated letter, insert filler like ‘X’ (e.g., “BALLOON” ; “BA LX LO ON"). Add an ‘X’ also at the end, if needed (or any other character).
  5. If both letters fall in the same row, replace each with letter to right, wrapping back to start from end (e.g., “AR" is encrypted as “RM").
  6. If both letters fall in the same column, replace each with the letter below it, wrapping to top from bottom (e.g., “MU” is encrypted as “CM").
  7. Otherwise each letter is replaced by the letter in the same row and in the column of the other letter of the pair (e.g., “HS" becomes “BP" and “EA" becomes “IM", or “JM", as the encipherer wishes)

Vigenere Cipher (polyalphabetic substitution cipher)

  • a sequence of plaintext letters P=p0,p1,p2,...,pn1P = p_0, p_1, p_2, ..., p_{n−1},
  • a key consisting of the sequence of letters K=k0,k1,k2,...,km1K = k_0, k_1, k_2, ..., k_{m−1}, typically m<nm < n.

The encryption/decryption is as follows:

Ci=(Pi+kimodm)mod26C_i = (P_i + k_{i \mod m}) \mod 26

and

Pi=(Cikimodm)mod26P_i = (C_i − k_{i \mod m}) \mod 26

Vernam Cipher

PK=CP \oplus K = C

CK=PC \oplus K = P

Rail Fence Cipher

Columnar transposition cipher

Example:

Also, we could perform another encryption to be more secure.

Feistel Cipher

Composite (product) ciphers: combining both substitution and transposition

Encryption:

LEi=REi1LE_i = RE_{i - 1}

REi=LEi1F(REi1,Ki)RE_i = LE_{i - 1} \oplus F(RE_{i - 1}, K_i)

Decryption:

Since LD16i=REiLD_{16 - i} = RE_i and RD16i=LEiRD_{16 - i} = LE_i

LDi=RDi1LD_i = RD_{i - 1}

RDi=LDi1F(RDi1,K17i)RD_i = LD_{i - 1} \oplus F(RD_{i - 1}, K_{17 - i})

Proof:

$\begin{equation} \begin{split} LD_i & = RE_{16 - i} \\\ & = LE_{16 - i - 1} \oplus F(RE_{16 - i - 1}, K_{16 - i}) \\\ & = LE_{15 - i} \oplus F(RE_{15 - i}, K_{16 - i}) \\\ & = RD_{16 - 15 + i} \oplus F(LD_{16 - 15 + i}, K_{16 - i}) \\\ & = RD_{i + 1} \oplus F(LD_{i + 1}, K_{16 - i}) \\\ & = RD_{i + 1} \oplus F(RD_i, K_{16 - i}) \end{split} \end{equation}$

$\begin{equation} \begin{split} RD_i & = LE_{16 - i} \\\ & = RE_{16 - i - 1} \\\ & = RE_{15 - i} \\\ & = LD_{16 - 15 + i} \\\ & = LD_{i + 1} \end{split} \end{equation}$

DES Encryption

  • Block size: 64 bits

  • Key size: 56 bits (last 1 bit for each 7 bits used to validate the key itself)

  • Key validation:

    i=18b8k+i1mod2,0k7\sum\limits_{i=1}^8 b_{8k + i} \equiv 1 \mod 2, 0 \leq k \leq 7

  • Single Round:

    • Expansion:

    • Substitution:

    • Permutation:

  • Key generation:

DES Security

  • two DES encryptions:

    Meet in the middle attack:

    Find two keys satisfying E(K1,P)=D(K2,C)E(K_1, P) = D(K_2, C)

  • Triple DES

    C=E(K1,D(K2,E(K1,P)))C = E(K_1, D(K_2, E(K_1, P))) or C=E(K1,E(K2,E(K3,P)))C = E(K_1, E(K_2, E(K_3, P)))

    For two keys in T-DES:

    • Compatibility is maintained with standard DES (K2=K1)(K_2 = K_1).
    • No known practical attack

S-DES

  • IP

  • fkf_k

  • Key generation:

Block Cipher Modes

ECB

  • Encryption: Ci=E(Pi,K)C_i = E(P_i, K)

  • Decryption: Pi=E(Ci,K)P_i = E(C_i, K)

  • Properties:

    1. Same encrypted block if the plaintext is same
    2. Could parallel process

CBC

Simplified CBC
  • Encryption:

    C1=E(K,IVP1)C_1 = E(K, IV \oplus P_1)
    Ci=E(K,Ci1Pi)C_i = E(K, C_{i - 1} \oplus P_i), i1i \geq 1

  • Decryption:

    P1=D(K,C1)IVP_1 = D(K, C_1) \oplus IV
    Pi=D(K,Ci)Ci1P_i = D(K, C_i) \oplus C_{i - 1}, i1i \geq 1

  • Properties:

    1. need pad last block if not full
    2. if an error occurs (changed bits, dropped blocks) in Ci but not Ci+1, then Ci+2 is correctly decrypted.

CFB

Simplified CFB
  • Encryption:

    Ci=PiMSBs(E(K,reg))C_i = P_i \oplus MSB_s(E(K, reg))

    MSBs(X)MSB_s(X) is the most significant ss bits of XX,

    regreg is the register initially contains IV, and fill with the CiC_i afterwards.

    Every encryption shifts the regreg ss bits to refresh value.

  • Decryption:

    Pi=CiMSBs(E(K,reg))P_i = C_i \oplus MSB_s(E(K, reg))

  • Properties:

    1. Only use encryption function
    2. Act like stream cipher

OFB

Simplified OFB
  • Encryption/Decryption:

    Ci=PiE(MSBs(K,reg))C_i = P_i \oplus E(MSB_s(K, reg))

    Pi=CiE(MSBs(K,reg))P_i = C_i \oplus E(MSB_s(K, reg))

  • Properties:

    1. Similar as CFB, except that OFB uses encrypted block to xor with text

Number Theory

  • GCD & Extended GCD

    • GCD
      gcd(a, b):
          if b == 0 
          then return a 
          else return gcd(b, a mod b)
      
    • Extended GCD
      exgcd(a, b):
          if b == 0
          then return (a, 1, 0)
          else
            (d', x', y') <- exgcd(b, a mod b)
            return (d', y', x' - (int(a / b) * y))
      

RSA

  • Primitives

    We must get two factors pp and qq of nn, which is hard.

  • Generate keys

    1. Select prime numbers

      p,qp, q

    2. Calculate n=pqn = p * q and ϕ(n)=(p1)(q1)\phi(n) = (p - 1) * (q - 1)

    3. select ee where,

      1<e<ϕ(n)1 < e < \phi(n), relatively prime to ϕ(n)\phi(n)

    4. Compute d=e1modϕ(n)d = e^{-1} \mod \phi(n)

    5. Set public key (e,n)(e, n) and private key (d,n)(d, n)

  • Encryption and Decryption

    C=MemodnC = M^e \mod n

    and

    M=CdmodnM = C^d \mod n

Asymmetric algorithms for distribution

  • Digital envelope

    Using asymmetric algorithm to encrypt symmetric key, for example, RSA

    Sender: C=(C1,C2)=(Kemodn,E(M,K))C = (C_1, C_2) = (K^e \mod n, E(M, K))

    Receiver: K=C1dmodnK = C_1^d \mod n and then M=D(C2,K)M = D(C_2, K)

  • Key exchange algorithms

Diffie-Hellman Key Exchange

  • Discrete logarithms

    bZ,i1,...,p1\forall b \in \mathbb{Z}, \exists i \in \\{1,...,p-1\\}, there is b=simodpb = s^i \mod p

    In other words: for any integer b and a primitive root s of prime number p, we can find a unique exponent i such that

    b=simodpb = s^i \mod p where 1i(p1)1 \leq i \leq (p − 1).

  • Key exchange

    1. share a prime number qq and an integer α\alpha which is a primitive root of qq
    2. A and B generate random numbers, XAX_A and XBX_B for A and B, respectively
    3. A and B computes Yi=αXimodqY_i = \alpha^{X_i} \mod q, where iA,Bi \in \\{A, B\\}
    4. exchange YAY_A and YBY_B
    5. compute K=YAXBmodq=YBXAmodqK = Y_A^{X_B} \mod q = Y_B^{X_A} \mod q
  • Group DH exchange

  • El Gamal
    1. ABA \rightarrow B: YA=αXAmodqY_A = \alpha^{X_A} \mod q
    2. BAB \rightarrow A: (C,YB)(C, Y_B) = (E(M,K),αXBmodq)(E(M, K), \alpha^{X_B} \mod q)
    3. AA: K=YBXAmodqK = Y_B^{X_A} \mod q, M=D(C,K)M = D(C, K)

Hash

  • Hash function:

    1. Maps an input with arbitrary bit length to an output of fixed bit length
    2. computable in limited time
  • Cryptographic hash function:

    1. One-way, it is hard to get xx when only given y=h(x)y = h(x)
    2. It's difficult to find xx' that h(x)=h(x)h(x) = h(x')
  • MAC (Message Authentication Code):

    1. Family of hash functions parameterized by secret key
    2. given (xi,hK(xi))(x_i, h_K(x_i)), it is infeasible to compute (x,hK(x))(x, h_K(x)) for xxix \neq x_i

Security Protocols

Needham-Schroeder Public Key Protocol (NSPK)

Procedure

  1. AB:NA,AKBA \rightarrow B: \\{NA, A\\}_{K_B}
  2. BA:NA,NBKAB \rightarrow A: \\{NA, NB\\}_{K_A}
  3. AB:NBKBA \rightarrow B: \\{NB\\}_{K_B}

MITM

  1. AC:NA,A_KC,CB:NA,AKBA \rightarrow C: \\{NA, A\\}\_{K_C}, C \rightarrow B: \\{NA, A\\}_{K_B}
  2. BC:NA,NB_KA,CA:NA,NBKAB \rightarrow C: \\{NA, NB\\}\_{K_A}, C \rightarrow A: \\{NA, NB\\}_{K_A}
  3. AC:NB_KC,CB:NBKBA \rightarrow C: \\{NB\\}\_{K_C}, C \rightarrow B: \\{NB\\}_{K_B}

NSL Protocol

Procedure

  1. AB:NA,AKBA \rightarrow B: \\{NA, A\\}_{K_B}
  2. BA:NA,NB,BKAB \rightarrow A: \\{NA, NB, B\\}_{K_A}
  3. AB:NBKBA \rightarrow B: \\{NB\\}_{K_B}

MITM

  1. AC:NA,A_KC,CB:NA,AKBA \rightarrow C: \\{NA, A\\}\_{K_C}, C \rightarrow B: \\{NA, A\\}_{K_B}
  2. BC:NA,NB,B_KAB \rightarrow C: \\{NA, NB, B\\}\_{K_A}, CA:NA,NB,BKAC \rightarrow A: \\{NA, NB, B\\}_{K_A}

AA received the message NA,NB,B\\{NA, NB, B\\} and found that AA is connecting to BB (should be CC).

Zero-knowledge Protocols

Principals

  • Prover: PeggyPeggy
  • Verifier: VictorVictor
  • Trusted Third Party: TrentTrent

Setup

  • TrentTrent: choose prime numbers pp, qq, publish n=pqn = p * q
  • PeggyPeggy: choose ss where 1<s<n11 < s < n - 1, and publish v=s2modnv = s^2 \mod n
  • VictorVictor: knows vv and nn

Verification (Peggy knows s)

  • PeggyPeggy: choose rr where 1<r<n11 < r < n - 1, calculate x=r2modnx = r^2 \mod n and send to VictorVictor
  • VictorVictor: send challenge cc where c0,1c \in \\{0, 1\\}
  • PeggyPeggy: calculate y=(rsc)modny = (r * s^c) \mod n
  • VictorVictor: calculate A=y2modnA = y^2 \mod n and B=(xvc)modnB = (x * v^c) \mod n and check if A=BA = B

Proof: $\begin{equation} \begin{split} y^2 \mod n & = (r * s^c)^2 \mod n \\\ & = (r^2 * s^2c) \mod n \\\ & = (r^2 * (S^2)^c) \mod n \\\ & = (x * v^c) \mod n \end{split} \end{equation}$

Cheating

Principal

  • PamelaPamela: Only knows v=s2modnv = s^2 \mod n

Cheat

  • VictorVictor choose c=0c = 0

    • PamelaPamela: choose rr where 1<r<n11 < r < n - 1, set x=r2modnx = r^2 \mod n
    • VictorVictor: choose c=0c = 0
    • PamelaPamela: set y=rmodny = r \mod n
    • VictorVictor: check y2modny^2 \mod n and (xv0)modn(x * v^0) \mod n
  • VictorVictor choose c=1c = 1

    • PamelaPamela: choose rr where 1<r<n11 < r < n - 1, set x=r2vmodnx = \frac{r^2}{v} \mod n
    • VictorVictor: choose c=1c = 1
    • PamelaPamela: set y=rmodny = r \mod n
    • VictorVictor: check y2modny^2 \mod n and (xv1)modn(x * v^1) \mod n