Merge branch 'master' of gitlab.com:shockrah/csnotes

This commit is contained in:
shockrah
2019-09-29 13:47:05 -07:00
112 changed files with 275 additions and 34 deletions

View File

@@ -0,0 +1,38 @@
# Asymmetric Key Encryption(Public/Private)
Think of a box that we put things inside of:(put simply)
* Private key: can open the box
* Public key: can lock the box
The idea works on the principle that public keys are public so anyone can lock a message down but only the owner/creator of that public key can open those locked messages with their private key.
## Public Keys
Can be used to open something if it was locked with a private key.
## Private Keys
If used to lock something the public key can be used to then open the box.
_The catch_: that message is also signed so we know exactly who the message is coming from.
## Both together
> Message => Lock(message, private key)
_Sign_ the message
> Signed Message => Lock(signed message, public key)
Lock the message like normal
Once the intended person has the package they:
* Open it with their private key
* Check the signature
* Find the public key for that signature
* Open the remaining layer with the public key
That last part only works because locking with a private key allows the public key to open the box afterwards.

View File

@@ -1,16 +0,0 @@
# Asymmetric Key Encryption(Public/Private)
Think of a box that we put things inside of:(put simply)
* Private key: can open the box
* Public key: can lock the box
Caveats:
Public keys contain a unique signature, which can be used to _sign_ a message. Even though everyone can open the message they also know who locked the box.
Imagine then, lock the box with private key(secure) and sign it with the public key(authorized).

40
312/notes/rsa.md Normal file
View File

@@ -0,0 +1,40 @@
# Procedure
Example using 3 values:
* p = 3
* q = 17
* e = 15
* m = 3
There are a few components which must be calculated before we can safely determine a cipher text:
`n = p * q` : note that `p` and `q` values should be primes in this case.
`O(n) = (p - 1) * (q - 1)` is used later to verify that we have a value `d` which is the inverse of `e`. _We call this the quotient function_.
## Encryption
To produce a cipher text `C` we take `m` and raise it to the power of `e`(from earlier) then take the modulor of it by `n`:
```
C = (m^e) % n
```
`m` is the desired message to encrypt.
The public and private keys are using the above cipher text functions whose unknown parameters are passed as follows
`PublicKey(e, n)`
`PrivateKey(d, n)`
## Decryption
The reverse of this is the following:
```
M = (c^d) % n
```