2022-01-31 19:15:01 +00:00
|
|
|
= RSA =
|
2022-01-31 19:30:01 +00:00
|
|
|
|
|
|
|
RSA is an asymetric encryption algorithm based on the difficulty of factoring
|
|
|
|
large prime numbers.
|
|
|
|
|
|
|
|
== algoirthm ==
|
|
|
|
|
2022-01-31 19:45:01 +00:00
|
|
|
1) choose some `p` and `q`
|
|
|
|
* where `p` and `q` are very large primes
|
|
|
|
* `n = p * q`
|
2022-01-31 19:30:01 +00:00
|
|
|
2) T = (p-1)(q-1)
|
|
|
|
* known as eulers totient
|
|
|
|
3) choose 2 values e and d
|
|
|
|
* where (e * d) mod T = 1
|
|
|
|
* where e < T
|
|
|
|
* [[../math/relative_prime]] with T and N
|
|
|
|
4) we now have our keys
|
|
|
|
* n and e are public keys
|
|
|
|
* n and d are private keys
|
|
|
|
|
2022-01-31 19:38:26 +00:00
|
|
|
=== encryption ===
|
|
|
|
|
|
|
|
`(plaintext value)^e mod N = ciphertext value`
|
|
|
|
|
|
|
|
=== decryption ===
|
|
|
|
|
|
|
|
`(ciphertext value)^d mod N = plaintext vlaue`
|
|
|
|
|
2022-01-31 19:30:01 +00:00
|
|
|
=== example ===
|
|
|
|
|
2022-01-31 19:38:26 +00:00
|
|
|
`p = 2; q = 7`
|
2022-01-31 19:30:01 +00:00
|
|
|
|
|
|
|
therefore,
|
|
|
|
|
2022-01-31 19:38:26 +00:00
|
|
|
`n = 14; T = 6`
|
2022-01-31 19:30:01 +00:00
|
|
|
|
|
|
|
Due to restrictions, choose e = 5
|
2022-01-31 19:38:26 +00:00
|
|
|
|
|
|
|
Then choose d from pool of canidiates satisfying `(e * d) mod T = 1`
|
|
|
|
|
|
|
|
For example then, choose 14 as d
|
|
|
|
|
|
|
|
Private key `(11,14)` and public key `(5,14)`
|
|
|
|
|
|
|
|
For example Encrypt B
|
|
|
|
|
|
|
|
`2^5 mod 14 = 4` or `D`
|
|
|
|
|
|
|
|
Decrypt value
|
|
|
|
|
|
|
|
`4^11 mod 14 = 2` or our original `B`
|
2022-01-31 20:00:01 +00:00
|
|
|
|
|
|
|
== Also see ==
|
|
|
|
|
|
|
|
* [[Eliptic_Curve]]
|