vimwiki/tech/RSA.wiki

56 lines
1000 B
Plaintext
Raw Normal View History

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.
2022-03-29 16:45:01 +00:00
== algorithm ==
2022-01-31 19:30:01 +00:00
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
2022-03-23 16:15:01 +00:00
* where 1 < e < T
* where e and T are [[relative_prime]]s, or coprime
2022-03-23 17:00:01 +00:00
* where (e * d) mod T = 1
2022-01-31 19:30:01 +00:00
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 ===
2022-03-23 16:15:01 +00:00
`(plaintext value)^e mod n = ciphertext value`
2022-01-31 19:38:26 +00:00
=== decryption ===
2022-03-23 16:15:01 +00:00
`(ciphertext value)^d mod n = plaintext vlaue`
2022-01-31 19:38:26 +00:00
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`
2022-03-23 16:15:01 +00:00
For example then, choose 11 as d
2022-01-31 19:38:26 +00:00
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]]