# RSA

- I enjoyed playfair's method last class and wanted to build on it.
- This is from 12.3 starting on page 795.
- There is some math here I don't really expect you to get.
- RSA is named after the creators Rivest, Shamir, Adelman in 1977
- Apparently a version was created by British Intelligence in 1973.
- And not declassified until 1997

- This is a public-key private key encryption system.
- The security of the system is based on the difficulty of factoring large numbers.
- There are no known methods to defeat the system when a large enough key is used.

- Because of the method RSA is slow, and not normally used for basic exchanges
- But it is great for exchanges of a symmetric key.

- The basic of the system.
- Given three appropriate integers, e, d and n
- $(m^e)^d = m \pmod n$
- $(m^d)^e = m \pmod n$

- IN the above example
- the public key is (n, e)
- The private key is (n,d)

- Key Generation
- This relies on number theory.
- The Euler Totient Function $\varphi(n)$
- Also Euler's Phi function.
- Returns the number of posotive integers up to a given integer n that are relatively prime to n.
- For a prime number n, it is n-1, since all numbers less than n are prime to n.
- If two numbers, p and q are relatively prime (gcd(p,q)=1), then $\varphi(nm) = \varphi(n)\varphi(m)$
- I don't really know this, I asked Doug.

- Select two relatively prime numbers p and q.
- $n = pq$
- Compute the Carmichael function
- $\lambda(n)$.
- is the smallest positive integer m such that $a^m = 1 \pmod n$
for every integer $a$ between 1 and n that is coprime to n.
- We want $\lambda(n) = lcm(p-1, q-1)$.

- Select an ecryption key $e$ such that $ 1 \le e \le \lambda(n)$ and e coprime to $\lambda(n)$
- Find $d$ such that $de = 1 \pmod n$

- This algorithm is strong because factoring is an open problem.
- Typically
- p and q are selected to be nearly 100 digits each.
- Thus n is 200 digits, or about 512 bits.

- Practical
- ssh-keygen is part of openssh.
- A discussion of the file format.