🌑

Explore / Study / Computer Science / Cryptography 1.3k words | 8 minutes

§1 Private-Key Cryptography

  1. Private-Key Cryptography
    1. Private-Key Encryption for Communication over an Insecure Channel
    2. Private-Key Encryption for Secure storage of data
    3. Private-Key Encryption: Formal Definition
    4. Private-Key Encryption: Correctness
    5. Security: Kerckhoff’s Principle
  2. Illustrative Private-Key Cryptosystems
    1. The Shift Cipher
    2. Shift Cipher / Caesar Cipher
    3. Security of Shift Cipher?
    4. Mono-Alphabetic Substitution Cipher
    5. Mono-Alphabetic Substitution Cipher: Sufficient Key-Space
    6. Security of Mono-Alphabetic Substitution?
  3. Formalising Security of Private-Key Cryptosystems
    1. Threat Models
    2. Probability distributions of the Key and Message
    3. Probability Distribution of Ciphertext
    4. Private-Key Encryption Formulae

Private-Key Cryptography

Private-Key Encryption for Communication over an Insecure Channel

  • Private-Key Encryption offers the following solution:

    Alice and Bob first establish a secret random key kk over a Secure channel.

    Alice encrypts the message (plaintext) mm using the key to obtain a ciphertext cc.

    Alice sends the ciphertext cc over the Insecure channel.

    Bob decrypts the ciphertext cc using the key kk to decipher the message mm.

Private-Key Encryption for Secure storage of data

  • Private-Key Encryption offers a solution:

    Before time t0t_0 Bob generates a private key kk.

    At time t0t_0 Bob encrypts his data mm using the key kk and stores the resulting ciphertext cc in his laptop at t0t_0.

    At time t1t_1 Bob decrypts the ciphertext cc using the key kk to recover the data mm.

Private-Key Encryption: Formal Definition

  • Definition. A private-key encryption scheme on message space M\mathscr M is defined by algorithms (Gen,Enc,Dec)(Gen, Enc, Dec) :
    1. GenGen (Key Generation Algorithm): Generates (randomly) a key kk belonging to the key space K\mathscr K.
    2. EncEnc (Encryption Algorithm): Given as inputs a key kKk \in \mathscr K and plaintext mMm \in \mathscr M, outputs a ciphertext cEnck(m)c \leftarrow {Enc}_{k}(m).
    3. DecDec (Decryption Algorithm): Given as inputs a key kKk \in \mathscr K and ciphertext cc, outputs m:=Deck(c)\underline{m} := {Dec}_{k}(c) or \perp.

Private-Key Encryption: Correctness

  • Correctness: For all plaintexts mMm \in \mathscr M, and keys kKk \in \mathscr K output by GenGen, it must hold that

    Deck(Enck(m))=m{Dec}_{k} ({Enc}_{k}(m)) = m

Security: Kerckhoff’s Principle

  • Kerckhoff’s Principle: A cryptosystem should be secure even if the attacker knows all details about the system, other than the key.

Illustrative Private-Key Cryptosystems

The Shift Cipher

  • The Shift Cipher is an old private key-encryption scheme used to encrypt (English) text.
  • The key in the Shift Cipher is a single letter k{0,,25}=Kk \in \{0,\ldots,25\} = \mathscr{K}, which the GenGen algorithm picks at random.
  • The Encryption algorithm shifts each plaintext letter by kk positions (wrapping around modulo 2626). ci=Enck(mi)=mi+kmod26ic_i = {Enc}_{k}(m_i) = m_i + k \bmod 26 \quad \forall i.
  • The Decryption algorithm shifts back each letter of the ciphertext by kk positions (wrapping around modulo 2626). That is mi=cikmod26i\underline{m}_i = c_i - k \bmod 26 \quad \forall i.

Shift Cipher / Caesar Cipher

  • M\mathscr M = {strings over uppercase English alphabet (represented as numbers from 0 to 25)}.
  • GenGen: choose uniform k{0,,25}=Kk \in \{0,\ldots,25\} = \mathscr{K}.
  • Enck(m1ml)=c1clEnc_k (m_1 \ldots m_l) = c_1 \ldots c_l where ci=[mi+kmod26]c_i = [m_i + k \bmod 26], the remainder when mi+km_i + k is divided by 2626.
  • Deck(c1cl)=m1mlDec_k (c_1 \ldots c_l) = \underline{m}_1 \ldots \underline{m}_l where mi=[cikmod26]\underline{m}_i = [c_i - k \bmod 26]

Security of Shift Cipher?

  • The Shift Cipher can be attacked by Brute-Force Analysis since there are only 26 possible keys.
  • Given ciphertext cc, simply try decrypting with every possible key k{0,,25}k' \in \{0,\ldots,25\}.
  • If the ciphertext is long enough, it is likely that only one message out of the 26 will ‘make sense’.

Mono-Alphabetic Substitution Cipher

  • In mono-alphabetic substitution, the key defines a fixed substitution for characters in the plaintext.
  • The size of the key space K\mathscr K is 26!28826! \approx 2^{88}.
  • Brute-force attacks on the substitution cipher are infeasible.

Mono-Alphabetic Substitution Cipher: Sufficient Key-Space

  • ci=Enck(mi)=Πk(mi)c_i = Enc_k (m_i) = \Pi_k(m_i).

  • mi=Deck(ci)=Πk1(ci)m_i = Dec_k (c_i) = \Pi^{-1} _k (c_i).

  • Mono-alphabetic substitution cipher satisfies the Sufficient Key Space principle:

    Any secure encryption scheme must have a key space that is sufficiently large to make an exhaustive-search attack infeasible.

Security of Mono-Alphabetic Substitution?

  • Even though the substitution cipher has large key space, it is still not secure.
  • The substitution cipher can be attacked using statistical patterns in the English language.
  • Long texts in English tend to have letter distributions that resemble the known average frequency distribution.

Formalising Security of Private-Key Cryptosystems

Threat Models

  • Ciphertext-only attack.

    Adversary observes one or more ciphertexts and attempts to obtain information about underlying plaintexts.

  • Known-plaintext attack.

    Adversary is able to learn one or more plaintext/ciphertext m/c pairs generated using some key, i.e., (m1,Enck(m1))(m_1, Enc_k(m_1)), (m2,Enck(m2))(m_2, Enc_k(m_2)), etc.

    Adversary wants to gain information about underlying plaintext of some other ciphertext produced using the same key.

  • Chosen-plaintext attack (CPA).

    Adversary can obtain plaintext/ciphertext m/cm/c pairs for plaintexts chosen by the adversary, i.e., (mi,Enck(mi))(m_i, Enc_k(m_i)) for mim_i chosen by Eve.

  • Chosen-ciphertext attack (CCA).

    Adversary can obtain decryption of ciphertexts cc of her choice. i.e., (ci,Deck(ci))(c_i, Dec_k(c_i)) for cic_i chosen by Eve.

Probability distributions of the Key and Message

  • In an encryption scheme, the algorithm GenGen defines a distribution over the key-space K\mathscr K. i.e., Pr[K=k]=Pr[Gen outputs k]\Pr [K = k] = \Pr [Gen \text{ outputs } k]
  • The probability distribution of the message, i.e. Pr[M=m]\Pr [M = m] gives the likelihood of message mMm \in \mathscr{M} being chosen by Alice in terms of the adversary’s a priori information about the message.

Probability Distribution of Ciphertext

  • The distribution over C\mathscr C is obtained by using GenGen to choose key k ∈ 𝒦 and message mMm \in \mathscr{M} according to the message distribution and then computing cEnck(m)c \leftarrow Enc_k(m) using the EncEnc algorithm.

    Pr[C=cM=m]=k:Enck(m)=cPr[K=k]\operatorname{Pr}[C=c \mid M=m]=\sum_{\substack{k: E n c_{k}(m)=c}} \operatorname{Pr}[K=k]

Private-Key Encryption Formulae

  • In general, we have the following useful formulae:

    Pr[C=cM=m]=k:Enck(m)=cPr[K=k]\operatorname{Pr}[C=c \mid M=m]=\sum_{\substack{k: E n c_{k}(m)=c}} \operatorname{Pr}[K=k]

    Pr[C=c]=mPr[C=cM=m]Pr[M=m]\operatorname{Pr}[C=c]=\sum_{m^{\prime}} \operatorname{Pr}\left[C=c \mid M=m^{\prime}\right] \cdot \operatorname{Pr}\left[M=m^{\prime}\right]

    Pr[M=mC=c]=Pr[C=cM=m]Pr[M=m]Pr[C=c]\operatorname{Pr}[M=m \mid C=c]=\operatorname{Pr}[C=c \mid M=m] \cdot \frac{\operatorname{Pr}[M=m]}{\operatorname{Pr}[C=c]}

— Feb 1, 2023

Creative Commons License
§1 Private-Key Cryptography by Lu Meng is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Permissions beyond the scope of this license may be available at About.