[In progess]
Implementation of cryptography algorithms in C#.
The algorithms are implemented purely for educational purposes and are not meant to be used in production.
$$ \begin{array}{c} p \in \mathbb{Z}{26} \ c \in \mathbb{Z}{26} \ k \in \mathbb{Z}{26} \ e{k}(p) = (p + k)\pmod{26} \ d_{k}(c) = (c - k)\pmod{26} \end{array} $$
- Monoalphabetic Substitution Cipher
- Rail fence Cipher
- Polyalphabetic Cipher
- Permutation Cipher
- Playfair Cipher
- Substitution Permutation Network
- Data Encryption Standard (DES)
- TripleDES
- Advanced Encryption Standard (AES)
- Let
$p$ be a prime number. - Let
$g$ be the generator of the cyclic group$\mathbb{Z}_p^{*}$ . - Alice (the sender) chooses
$a$ such that$0 < a < p-1$ . - Bob (the receiver) chooses
$b$ such that$0 < b < p-1$ . - Alice computes
$A = g^a$ and sends it to Bob. - Bob computes
$B = g^b$ and sends it to Alice. - Alice receives
$B$ and computes$B^a = {(g^b)^a}\pmod p$ . - Bob receives
$A$ and computes$A^b = {(g^a)^b}\pmod p$ .
- Based on integer factorization (mathematical hard problem):
Given a large semiprime number
- Select two primes
$p$ and$q$ . - Compute
$n = pq$ . - Compute
$\phi(n) = (p - 1)(q - 1)$ . - Select
$e$ such that$\gcd(e,\phi(n)) = 1$ . - Find
$d$ such that$ed = 1\pmod {\phi(n)}$ .
- Public Key:
$(e, n)$ - Private Key:
$(d, p, q)$ .
- Choose a superincreasing sequence of
$n$ integers:
- Choose
$m$ such that$m > \sum{a_i}$ . - Choose
$w$ such that$\gcd(m, w) = 1$ . - Generate public sequence:
Message:
- Find
$w^{-1}$ under$\pmod m$ . - Compute
${w^{-1}c}\pmod m$ . - Solve the subset sum problem.
- Choose a prime
$p$ . - For cyclic group
$\mathbb{Z}_p^{*} = \mathbb{Z}_p - \lbrace 0 \rbrace$ ,$\alpha$ is the generator. - Compute
$\beta = {\alpha^a}\pmod p$ where$0 \le a \le p-2$ . - Given
$(\alpha, \beta, p)$ find$a$ .
- Choose
$p$ such that DLP is hard. - For the cyclic group
$\mathbb{Z}_p^{*}$ whose generator is$\alpha$ , choose such that$0 \le a \le p-2$ . - Compute
$\beta = {\alpha^a}\pmod p$ .
- Public Key:
$(\alpha, \beta, p)$ - Private Key:
$a$ .
- Choose
$k$ such that$k \in \mathbb{Z}_p^{*}$ . - Message:
$x \in \mathbb{Z}_p^{*}$ .
where,
- Based on CRT.
- Invented before RSA.
- Choose two primes
$p$ and$q$ . - Compute
$n = pq$ .
- Public Key:
$(n)$ - Private Key:
$(p, q)$
- Choose two large primes
$p$ and$q$ . - Compute
$n=pq$ . - Choose
$m$ such that:$$(\frac{m}{p}) = -1 = (\frac{m}{q})$$ $$m \notin {QR}_p$$ $$m \notin {QR}_q$$
-
$m \in {QR}\pmod n$ if$m \in {QR}\pmod p$ and$m \in {QR}\pmod q$ and$n = pq$ . - Public Key:
$(m, n)$ - Private Key:
$(p, q)$
- Plaintext:
$X = \lbrace x_i | x_i \in \lbrace 0, 1 \rbrace \rbrace$ - Ciphertext:
$y \in \mathbb{Z}_n^{*}$
For each bit
Choose a random number
- Select two primes
$p$ and$q$ . - Compute
$n = pq$ . - Compute
$\phi(n) = (p - 1)(q - 1)$ . - Select
$e$ such that$\gcd(e,\phi(n)) = 1$ . - Find
$d$ such that$ed = 1\pmod {\phi(n)}$ .
- Public Key:
$(e, n)$ - Private Key:
$(d, p, q)$ .
- Choose
$p$ such that DLP is hard. - For the cyclic group
$\mathbb{Z}_p^{*}$ whose generator is$\alpha$ , choose such that$0 \le a \le p-2$ . - Compute
$\beta = {\alpha^a}\pmod p$ .
- Public Key:
$(\alpha, \beta, p)$ - Private Key:
$a$ .
- Choose
$k$ such that$k \in \mathbb{Z}_p^{*}$ . - Message:
$x \in \mathbb{Z}_p^{*}$ .
where,
- Calculate
$\beta^\gamma \gamma^\delta$ . - Calculate
$\alpha^x$ . - Check if
$\beta^\gamma \gamma^\delta = \alpha^x$ .