Principles of Public Key Cryptosystems.
Consider Bob and Alice, two friends who want to communicate securely with one another.
Conventionally, with symmetric encryption, both Bob and Alice would have to have the same key and store it securely for secure end-to-end encryption and decryption.
With Assymetric Encryption however, Both Bob and Alice would have Public Keys in addition to their secret Private Keys. So in total, there would be 4 keys.
- Bob’s Public Key
- Bob’s Private Key
- Alice’s Public Key
- Alice’s Private Key
The RSA Algorithm
Given below are the steps taken to generate public and private keys for users using The RSA Algorithm.
- Select 2 different, preferably large prime numbers, and .
- Calculate as their product → .
- Calculate which is →
- Select an integer , such that it is relatively prime with .
- Calculate a number such that
- Public Key (PU) will thus be .
- Private Key (PK) will thus be .
How will these public and private keys be used?
Let’s assume that Alice has run the above algorithm and now has her public and private keys. Bob wants to send her a message, and has her public key.
Encryption - Done on Bob’s Side
Bob has Alice’s public key. is the message, and it’s length has to be less than . That’s why we try to choose large prime numbers for and , since is their product. is now the generate ciphertext that will travel through the Internet to Alice.
Decryption - Done on Alice’s Side
Alice has her own private key that she hasn’t shared with anyone. She receives the ciphertext .
We remember that and are multiplicative inverses of one another.
Diffie-Hellman Key Exchange
Analogical Explanation
The Algorithm
Given below is the algorithm for Diffie-Hellman Exchange.
- We begin with 2 Global Public Elements which are
- → any prime number,
- → primitive root of , and
- Now, we come to Alice for now. Alice selects her private key with the condition that
- Alice then chooses her public key which is calculated by:
- Bob does the same, he generates his private key with the same condition as Alice that,
- And he also calculates his private key by:
- Then Alice and Bob calculate their shared keys, which are