Cryptography 12
RSA is a block cipher, the block size must be less than or equal .\(\log_{2}(n)+1\), if block size =i bits \(2^{i}<n<2^{i}+1\)
The encryption and decryption are on the following form
\(C = M^{e} mod(n)\)
\(M = C^{d} mod(n) = (M^{e})^d mod(n) = M^{ed} mod(n)\)
d is relatively prime to Q(n) and e also.
Now let us look at RSA ingredients
1- q and p two prime numbers
2- n=q*p
3- e by using gcd(Q(n),e)=1 1<e<Q(n)
4- d mod(Q(n)) = \(e^{-1}\)
Example:
1- Two prime numbers p=17 q=11
2- n=q*p= 17*11=187
3- Q(n) = (p-1)*(q-1)= 16*10=160
4- Select e such that e is relatively prime to Q(n)=160 and less than Q(n) ,,, We choose e=7
5- Determine d such that ed mod(Q(n)) = 1 ,,, d=23 (23*7 mod(160) =1)
Miller-Rabin Algorithm :
-------------------------
Choosing prime number :
1- Pick a long odd number n
2- Pick an integer number a a < n
3- Preform primality tests such as Miller-Rabin test with a as the following :
a- If a fail the test then n is not a prime and start picking an odd number again.
b- If n passes the test then n maybe a prime or not, so we continue with different a and preform test again.
c- If different a passes the test then we have high confidence that n is a prime number.
Choosing q and p:
1- q and p should be differ in length by only a few digits, in 1024 bit key (309+ decimal digits) both q and p should be on the order of magnitude of \(10^{75}\) to \(10^{100}\).
2- (q-1) and (p-1) should contain a large prime factor.
3- gcd((q-1),(p-1)) should be small.
Note: gcd stands for Greater common divisor http://en.wikipedia.org/wiki/Greatest_common_divisor
Note: If e < n and d < \( n^{1/4}\) then d can be easily determined.