The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
RSA Algorithm.ppt
1. 1
RSA Public-Key Cryptography
The RSA Algorithm: It is a public key cryptography algorithm, which was proposed by Diffie and
Hellman. RSA can be used for key exchange, digital signatures and the encryption of small blocks of
data.
RSA is primarily used to encrypt the session key used for secret key encryption (message integrity)
or the message's hash value (digital signature).
RSA's mathematical hardness comes from the ease in calculating large numbers and the difficulty
in finding the prime factors of those large numbers.
To create an RSA public/private key pair, here are the basic steps:
1- Choose two prime numbers, p and q such that p q .
2- Calculate the modulus, n = p q.
3- Calcuate ( n ) = ( p – 1 )( q – 1 ).
4- Select integer e such that gcd (( n ), e) = 1 and 1 < e < ( n ). (* gcd is greater common divisor)
5- Calculate an integer d from the quotient de 1 (mod ( n )).
To encrypt a message, M, with the public key (e, n), create the ciphertext, C, using the equation:
C = Me mod n
The receiver then decrypts the ciphertext with the private key (d, n) using the equation:
M = Cd mod n
2. 2
RSA Public-Key Cryptography
The RSA Example
1. Select two prime numbers, p = 17 and q = 11.
2. Calculate n = p q = 17 × 11 = 187.
3. Calculate (n) = (p - 1)(q - 1) = 16 × 10 = 160.
4. Select e such that e is relatively prime to (n) = 160 and less than (n); we choose e = 7.
5. Determine d such that de 1 (mod 160) and d < 160.The correct value is d = 23, because 23 × 7 =
161 = (1 × 160) + 1.
The resulting keys are public key PU = {7, 187} and private key PR = {23, 187}.
Given a plaintext input of M = 88. For encryption, we need to calculate C = 887 mod 187.
we can do this as follows.
887 mod 187 = [(884 mod 187) * (882 mod 187) * (881 mod 187)] mod 187
881 mod 187 = 88
882 mod 187 = 7744 mod 187 = 77
884 mod 187 = 59,969,536 mod 187 = 132
887 mod 187 = (88 * 77 * 132) mod 187 = 894,432 mod 187 = 11
3. 3
RSA Public-Key Cryptography
For decryption, we calculate M = 1123 mod 187:
1123 mod 187 = [(111 mod 187) * (112 mod 187) * (114 mod 187) * (118 mod 187) * (118 mod 187)]
mod 187
111 mod 187 = 11
112 mod 187 = 121
114 mod 187 = 14,641 mod 187 = 55
118 mod 187 = 214,358,881 mod 187 = 33
1123 mod 187 = (11 * 121 * 55 * 33 * 33) mod 187 = 79,720,245 mod 187 = 88
In the preceding example shows, we can make use of a property of modular arithmetic:
[(a mod n) * (b mod n)] mod n = (a * b) mod n
As another example, suppose we wish to calculate x11 mod n for some integers x and n. Observe that
x11 = x1+2+8 = (x)(x2)(x8).
4. 4
Public-Key Cryptography
Applications for Public-Key Cryptosystems:
■ Encryption/decryption: The sender encrypts a message with the recipient’s public key, and the
recipient decrypts the message with the recipient’s private key.
■ Digital signature: The sender “signs” a message with its private key.
■ Key exchange: Two sides cooperate to exchange a session key.
The security of RSA:
Five possible approaches to attacking the RSA algorithm are
■ Brute force: This involves trying all possible private keys.
■ Mathematical attacks: There are several approaches, all equivalent in effort to factoring the
product of two primes.
■ Timing attacks: These depend on the running time of the decryption algorithm.
■ Hardware fault-based attack: This involves inducing hardware faults in the processor that is
generating digital signatures.
■ Chosen ciphertext attacks: This type of attack exploits properties of the RSA algorithm.