52 lines
939 B
Plaintext
52 lines
939 B
Plaintext
= RSA =
|
|
|
|
RSA is an asymetric encryption algorithm based on the difficulty of factoring
|
|
large prime numbers.
|
|
|
|
== algoirthm ==
|
|
|
|
1) choose some p and q
|
|
* where p and q are very large primes
|
|
* n = p * q
|
|
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
|
|
|
|
=== encryption ===
|
|
|
|
`(plaintext value)^e mod N = ciphertext value`
|
|
|
|
=== decryption ===
|
|
|
|
`(ciphertext value)^d mod N = plaintext vlaue`
|
|
|
|
=== example ===
|
|
|
|
`p = 2; q = 7`
|
|
|
|
therefore,
|
|
|
|
`n = 14; T = 6`
|
|
|
|
Due to restrictions, choose e = 5
|
|
|
|
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`
|