## KryptoPhone uses RSA Encryption Algorithm

##### KryptoPhone uses RSA encryption algorithm to encrypt communications

###### RSA is a public-key encryption algorithm and a standard for encrypting sensitive data sent over an insecure network like the Internet.

RSA encryption algorithm was first introduced by Rivest, Shamir and Adleman at Massachusetts Institute of Technology in the year 1977. It is with reference to these three individuals that this method of encryption was named as RSA (Rivest-Shamir-Adleman).

RSA, a public-key cryptography, is an asymmetric encryption which uses two different but mathematically linked keys for encryption and decryption. In RSA encryption algorithm, a public-key is used for encryption and a private-key for decryption. The public-key could be shared with others but the private-key must always be kept secret.

RSA is one of the most popular and widely used encryption algorithm for encryption and digital signatures in the cyber-security world today.

The RSA algorithm can be used for both public key encryption and digital signatures. Its security is based on the difficulty of factoring large integers.

Person A send an encrypted message to Person B without any prior exchange of secret keys. Person A just uses B's public key to encrypt the message and B decrypts it using the private key, which only he knows. RSA can also be used to sign a message, so A can sign a message using their private key and B can verify it using A's public key.

######
RSA encryption algorithm process mainly consists of the below four phases:

** Key Generation:**
A user who wants to receive encrypted messages creates a public key which is shared and a private key which is kept secret. The keys are generated in a way that conceals their construction and makes it impossible to find private key when only the public key is known.

**Key Distribution:**
The intended recipient of the message shares his/her public key with the sender.

**Encryption:**
The confidential message intended to be sent to a recipient is encrypted using public key of the recipient.

**Decryption:**
The authorized recipient of the message decrypts the message using his private key.

#### RSA Encryption Algorithm - Operation

######
**Key Generation:**

Each entity shall select a positive integer *e* as its public exponent.

Each entity shall privately and randomly select two distinct odd primes *p* and *q* such that *(p-1)* and e have no common divisors, and *(q-1)* and *e* have no common divisors.

The public modulus n shall be the product of the private prime factors *p* and *q*:

* n = pq *.

The private exponent shall be a positive integer *d* such that *de-1* is divisible by both *p-1* and *q-1*.

RSA involves a public key and a private key. The public key can be known by everyone and is used for encrypting messages. The intention is that messages encrypted with the public key can only be decrypted in a reasonable amount of time using the private key. The public key is represented by the integers *n* and *e*; and, the private key, by the integer *d* (although *n* is also used during the decryption process; so, it might be considered a part of the private key, too). *m* represents the message.

**Key Distribution:**

Lets say Bob wants to send a secret message to Alice, then Bob must know Alice's public key to encrypt the message. Alice must use her private key to decrypt the message. To enable Bob to send his encrypted messages, Alice transmits her public key *(n, e)* to Bob via a reliable, but not necessarily secret route. Alice's private key *(d)*, is never distributed.

**Encryption:**

After Bob obtains Alice's public key, he can send a message *M* to Alice.

To do it, he first turns *M* (strictly speaking, the un-padded plaintext) into an integer *m* (strictly speaking, the padded plaintext), such that *0 ≤ m < n* by using an agreed-upon reversible protocol known as a padding scheme. He then computes the ciphertext *c*, using Alice's public key *e*, corresponding to

* c ≡ m*^{ e} ( mod n )

This can be done reasonably quickly, even for 500-bit numbers, using modular exponentiation. Bob then transmits *c* to Alice.

**Decryption:**

Alice can recover *m* from *c* by using her private key exponent *d* by computing

* c *^{d} ≡ ( m ^{e} ) ^{d} ≡ m ( mod n )

Given *m*, Alice can recover the original message *M* by reversing the padding scheme.

RSA encryption algorithm is considered to be secure to this point in time.

^{ e}( mod n )

^{d}≡ ( m

^{e})

^{d}≡ m ( mod n )