CPE5021 Advanced Network Security --- Advanced Cryptography: RSA and its implementation --- Lecture 1.1 Last lecture we saw the data encryption standard.

Slides:



Advertisements
Similar presentations
RSA COSC 201 ST. MARY’S COLLEGE OF MARYLAND FALL 2012 RSA.
Advertisements

CS 483 – SD SECTION BY DR. DANIYAL ALGHAZZAWI (4) Information Security.
Public Key Cryptosystems - RSA Receiver Sender Eavesdroppe r p q p q p q p and q prime.
Data encryption with big prime numbers
22C:19 Discrete Structures Integers and Modular Arithmetic
Public Key Encryption Algorithm
22C:19 Discrete Math Integers and Modular Arithmetic Fall 2010 Sukumar Ghosh.
7. Asymmetric encryption-
Session 4 Asymmetric ciphers.
Dr. Lo’ai Tawalbeh Summer 2007 Chapter 9 – Public Key Cryptography and RSA Dr. Lo’ai Tawalbeh New York Institute of Technology (NYIT) Jordan’s Campus INCS.
and Factoring Integers (I)
Introduction to cryptography for authentication and identification systems --- FIT Lecture 2 & 3.
ECOMMERCE TECHNOLOGY FALL 2003 COPYRIGHT © 2003 MICHAEL I. SHAMOS Cryptography.
Cryptography Lecture 11: Oct 12. Cryptography AliceBob Cryptography is the study of methods for sending and receiving secret messages. adversary Goal:
WS Algorithmentheorie 03 – Randomized Algorithms (Public Key Cryptosystems) Prof. Dr. Th. Ottmann.
Cryptography & Number Theory
Cryptography1 CPSC 3730 Cryptography Chapter 9 Public Key Cryptography and RSA.
Cryptosystems, Hash Functions and Digital Signatures --- Lecture 4 ---
CSE 321 Discrete Structures Winter 2008 Lecture 8 Number Theory: Modular Arithmetic.
Theory I Algorithm Design and Analysis (9 – Randomized algorithms) Prof. Dr. Th. Ottmann.
Private-Key Cryptography traditional private/secret/single key cryptography uses one key shared by both sender and receiver if this key is disclosed communications.
WS Algorithmentheorie 03 – Randomized Algorithms (Public Key Cryptosystems) Prof. Dr. Th. Ottmann.
Dr.Saleem Al_Zoubi1 Cryptography and Network Security Third Edition by William Stallings Public Key Cryptography and RSA.
Public Key Algorithms 4/17/2017 M. Chatterjee.
1 Pertemuan 08 Public Key Cryptography Matakuliah: H0242 / Keamanan Jaringan Tahun: 2006 Versi: 1.
Public Key Cryptosystems & Digital Signatures --- New era of secure communications ---
“RSA”. RSA  by Rivest, Shamir & Adleman of MIT in 1977  best known & widely used public-key scheme  RSA is a block cipher, plain & cipher text are.
Codes, Ciphers, and Cryptography-RSA Encryption
Lecture 6: Public Key Cryptography
Asymmetric encryption. Asymmetric encryption, often called "public key" encryption, allows Alice to send Bob an encrypted message without a shared secret.
Public Key Model 8. Cryptography part 2.
 Introduction  Requirements for RSA  Ingredients for RSA  RSA Algorithm  RSA Example  Problems on RSA.
1 CIS 5371 Cryptography 8. Asymmetric encryption-.
The RSA Algorithm Rocky K. C. Chang, March
Prime Numbers Prime numbers only have divisors of 1 and self
Introduction to Modular Arithmetic and Public Key Cryptography.
RSA and its Mathematics Behind
Cryptography: RSA & DES Marcia Noel Ken Roe Jaime Buccheri.
Cryptography Dec 29. This Lecture In this last lecture for number theory, we will see probably the most important application of number theory in computer.
Public-Key Cryptography CS110 Fall Conventional Encryption.
Implementing RSA Encryption in Java
Introduction to Algorithms Second Edition by Cormen, Leiserson, Rivest & Stein Chapter 31.
Lecture 6 Public Key Cryptosystems & Digital Signatures --- New era of secure communications ---
Modular Arithmetic with Applications to Cryptography Lecture 47 Section 10.4 Wed, Apr 13, 2005.
Public-Key Encryption
Public Key Cryptography. symmetric key crypto requires sender, receiver know shared secret key Q: how to agree on key in first place (particularly if.
1 Public-Key Cryptography and Message Authentication.
Cryptography and Network Security Chapter 9 - Public-Key Cryptography
PUBLIC-KEY CRYPTOGRAPH IT 352 : Lecture 2- part3 Najwa AlGhamdi, MSc – 2012 /1433.
RSA and its Mathematics Behind July Topics  Modular Arithmetic  Greatest Common Divisor  Euler’s Identity  RSA algorithm  Security in RSA.
PUBLIC KEY CRYPTOGRAPHY ALGORITHM Concept and Example 1IT352 | Network Security |Najwa AlGhamdi.
Chapter 3 – Public Key Cryptography and RSA (A). Private-Key Cryptography traditional private/secret/single-key cryptography uses one key shared by both.
Public Key Cryptosystems RSA Diffie-Hellman Department of Computer Engineering Sharif University of Technology 3/8/2006.
Chapter 9 Public Key Cryptography and RSA. Private-Key Cryptography traditional private/secret/single key cryptography uses one key shared by both sender.
Public Key Algorithms Lesson Introduction ●Modular arithmetic ●RSA ●Diffie-Hellman.
Public Key Cryptosystem Introduced in 1976 by Diffie and Hellman [2] In PKC different keys are used for encryption and decryption 1978: First Two Implementations.
CS 4803 Fall 04 Public Key Algorithms. Modular Arithmetic n Public key algorithms are based on modular arithmetic. n Modular addition. n Modular multiplication.
Ch1 - Algorithms with numbers Basic arithmetic Basic arithmetic Addition Addition Multiplication Multiplication Division Division Modular arithmetic Modular.
Cryptography and Network Security Third Edition by William Stallings Lecture slides by Lawrie Brown.
Chapter 1 Algorithms with Numbers. Bases and Logs How many digits does it take to represent the number N >= 0 in base 2? With k digits the largest number.
Elgamal Public Key Encryption CSCI 5857: Encoding and Encryption.
RSA Cryptosystem Great Theoretical Ideas In Computer Science S. Rudich V. Adamchik CS Spring 2006 Lecture 8Feb. 09, 2006Carnegie Mellon University.
ECE454/599 Computer and Network Security Dr. Jinyuan (Stella) Sun Dept. of Electrical Engineering and Computer Science University of Tennessee Fall 2012.
Chapter 9 – Public Key Cryptography and RSA Every Egyptian received two names, which were known respectively as the true name and the good name, or the.
CSCE 715: Network Systems Security Chin-Tser Huang University of South Carolina.
CS/COE 1501 Recitation RSA Encryption/Decryption Extended Euclidean Algorithm Digital Signatures.
1 The RSA Algorithm Rocky K. C. Chang February 23, 2007.
Public Key Cryptosystem
RSA Preliminaries.
Public Key Cryptosystems - RSA
Presentation transcript:

CPE5021 Advanced Network Security --- Advanced Cryptography: RSA and its implementation --- Lecture 1.1 Last lecture we saw the data encryption standard. However this require that the secret keys need to be exchanged between the parties and a number of pairs of such keys has to be maintained by each user (How many are they if you communicate with n different people and there are m such people in the population and assume n <m). We want to look at another method which avoids knowing that many no of keys

Mathematical background Modular operations “remainder” 13 mod 5 = 3, 1 mod 7 = 1 20 mod 5 = 0, 32 mod 7 = 4 modular exponentiation 22 mod 3 = 1, 32 mod 3 = 0 22 mod 5 = 4, 102 mod 92 = 8 46 mod 10 = 6, 311 mod 10 = 7 Skip this slide CPE5021 - Advanced Nework Security

Mathematical background a is relatively prime to b if the largest integer that divides both a & b is 1 E.g: any m (<>0) is relatively prime to a prime number is 9 relatively prime to 10? Skip this slide CPE5021 - Advanced Nework Security

Mathematical background Let ø(n) denote the total numbers that are less than n and relatively prime to n If n is a prime number then ø(n) = n – 1 If p, q are prime numbers and n=p*q, then Ø(n) = Ø(p*q) = p*q – (p + q -1) = (p-1)*(q-1) - p & q are prime numbers => only multiples of p and q are not relatively prime to p*q - That is: there are (p + q – 1) multiples [0 is counted once] of p and q E.g: p = 3; q=7; {0, 3, 7, 6, 9, 12, 14, 15, 18} are not relatively prime to p*q Ø(n) = ø(p*q) = 12 ; {1,2,4,5,8,10,11,13,16,17,19,20} CPE5021 - Advanced Nework Security

Mathematical background y & n are integers and y mod ø(n) = 1, for any x < n, xy mod n = x (1) E.g: y=13 ; n=7; x = 4; ø(n) = 6; y mod ø(n) = 13 mod 6 = 1; xy = 413; xy mod n = 413 mod 7 = 4 = x mod n; CPE5021 - Advanced Nework Security

Mathematical background The multiplicative inverse of x with modulo n is y such that: (x*y) mod n = 1 (2). The above multiplicative inverse can be used to create a simple public key cipher: either x or y can be thought of as a secret key and the other is the public key. E.g: x=3; n=10; y=7; we have: (3*7) mod 10 = 1; M =5 ; 3*5 (mod 10) = 5 ; 5*7 (mod 10) = 5 = M (message) M =6 ; 3*6 (mod 10) = 8; 8*7 (mod 10) = 6 = M (message) CPE5021 - Advanced Nework Security

RSA (1) Bob: chooses 2 large prime numbers: p, q multiplies p and q: n = p*q finds out two numbers e & d such that (e * d) mod ø(n) = 1 [ similar to (2) ] Or (e * d) mod [(p-1)*(q-1)] = 1 public key (published in the phone book) 2 numbers: (e, n) encryption alg: modular exponentiation secret key: (d,n) Without going into the modulo operation theory, this is what happens and you can take for granted from me that this will work. The following slides explains through examples. CPE5021 - Advanced Nework Security

RSA (2) Alice has a message m to be sent to Bob: finds out Bob’s public encryption key (e, n) calculates me (mod n) -> c sends the ciphertext c to Bob CPE5021 - Advanced Nework Security

RSA (3) Bob: receives the ciphertext c from Alice uses his matching secret decryption key d to calculate cd (mod n) -> m CPE5021 - Advanced Nework Security

RSA Public Key Cryptosystem Public Key Directory (Yellow/White Pages) Bob: (e, n) public key: e & n Plain Text Cipher Text Cipher Text Plain Text Network c= m e mod n m= c d mod n Alice secret key: d Bob CPE5021 - Advanced Nework Security

RSA --- 1st small example (1) Bob: chooses 2 primes: p=5, q=11 multiplies p and q: n = p*q = 55 finds out two numbers e=3 & d=27 which satisfy (3 * 27) mod 40 = 1 Bob’s public key 2 numbers: (3, 55) encryption alg: modular exponentiation secret key: (27,55) CPE5021 - Advanced Nework Security

RSA --- 1st small example (2) Alice has a message m=13 to be sent to Bob: finds out Bob’s public encryption key (3, 55) calculates c: c = me (mod n) = 133 (mod 55) = 2197 (mod 55) = 52 sends the ciphertext c=52 to Bob CPE5021 - Advanced Nework Security

RSA --- 1st small example (3) Bob: receives the ciphertext c=52 from Alice uses his matching secret decryption key 27 to calculate m: m = 5227 (mod 55) = 13 (Alice’s message) CPE5021 - Advanced Nework Security

How does RSA work? n = p*q => Ø(n) = Ø(p*q) = (p-1)*(q-1) We choose d & e such that (e * d) mod ø(n) = = 1 ; similar to (2) for any m < n: mde = m mod n ; from (1) an RSA encryption consists of taking m and raising it to e; and decrypting the ciphertext by raising the result of the encrytion to d: We have (a*b) mod n = ((a mod n) * (b mod n)) mod n hence : (me mod n) d mod n = (me)d mod n = (med) mod n = m mod n = m [from (1)] The only restriction is that the message has to be less than n. Probably we can break the message into chunks so that the above requirement is met. CPE5021 - Advanced Nework Security

RSA Signature --- an eg (1) Bob: chooses 2 primes: p=5, q=11 multiplies p and q: n = p*q = 55 finds out two numbers e=3 & d=27 which satisfy (3 * 27) mod 40 = 1 Bob’s public key 2 numbers: (3, 55) encryption alg: modular exponentiation secret key: (27,55) CPE5021 - Advanced Nework Security

RSA Signature --- an eg (2) Bob has a document m=19 to sign: uses his secret key d=27 to calculate the digital signature of m=19: s = md (mod n) = 1927 (mod 55) = 24 appends 24 to 19. Now (m, s) = (19, 24) indicates that the doc is 19, and Bob’s signature on the doc is 24. CPE5021 - Advanced Nework Security

RSA Signature --- an eg. (3) Cathy, a verifier: receives a pair (m,s)=(19, 24) looks up the phone book and finds out Bob’s public key (e, n)=(3, 55) calculates t = se (mod n) = 243 (mod 55) = 19 checks whether t=m confirms that (19,24) is a genuinely signed document of Bob if t=m. CPE5021 - Advanced Nework Security

RSA Algorithm (1) General description of RSA algorithm Choose 2 large prime numbers: p, q; then multiplie p and q: n = p*q Find out two numbers e & d such that (e * d) mod [(p-1)*(q-1)] = 1 Encrypt a message M using e: Me (mod n) -> c Decrypt using d: cd (mod n) -> M Without going into the modulo operation theory, this is what happens and you can take for granted from me that this will work. The following slides explains through examples. CPE5021 - Advanced Nework Security

RSA Algorithm (2) 1. Choose 2 large prime numbers: p and q; 2. Calculate n = p*q; m = (p-1)*(q-1); 3. Find e such that gcd(e,m) = 1; 4. Find d such that : k*m + d*e = 1; 5. Encrypt a message M using e: Me (mod n) -> c Without going into the modulo operation theory, this is what happens and you can take for granted from me that this will work. The following slides explains through examples. CPE5021 - Advanced Nework Security

RSA – How to choose p and q Finding p and q which are prime and large enough is important. There is no guarantee that we can find p and q correctly. However, we can use Miller-Rabin test to test if an integer n is probably a prime number by: 1.Select a random number b from the set of integers [1, (n-1)] (pick n as large as you want). 2. Find q and the odd number k such that n – 1 = 2qk 3. Test if either of the following condition holds: (a) bk mod n = 1; or (b) if there exists i in [0, (q-1)] such that 4. If neither (a) nor (b) is satisfied, then n is composite; Else n is probably prime (Inconclusive) (The probability of n being a prime number after i inconclusive tests is (1 – (1/4)i)) * There are other ways to test if an integer is probably a prime number CPE5021 - Advanced Nework Security

Miller-Rabin test – E.g. Test if n = 15 is a prime number 1. Choose random b = 8 2. Solve (15 -1) = 2qk; => q =1 ;k=7; 3. (a) Is 87mod 15 = 1 ? NO (b) Does any i in [0, (q-1)] satisfy: i = 0 satisfies ; but from (a) is false; => n is composite. CPE5021 - Advanced Nework Security

Miller-Rabin test – E.g. Test if n = 13 is a prime number 1. Choose random b = 3 2. Solve (13 -1) = 2qk; => q =2 ;k=3; 3. (a) Is 33mod 13 = 1  27 mod 13 = 1? YES n is probably prime number CPE5021 - Advanced Nework Security

Miller-Rabin test – E.g. Test if n = 13 is a prime number 1. Choose random b = 2 2. Solve (13 -1) = 2qk; => q =2 ;k=3; 3. (a) Is 23mod 13 = 1?  8 mod 13 = 1? NO (b) Does any i in [0, (q-1)] satisfy: i = 0 i = 1; n is probably prime number with the probability of 75% CPE5021 - Advanced Nework Security

RSA – find e and d Find two numbers e and d such that (e * d) mod [(p-1)*(q-1)] = 1 First calculate e relatively prime to m: gcd(e,m) = 1 using Euclid’s algorithm int gcd(int e, int m) { if (m == 0) return e; else return gcd(m, e%m) ; } CPE5021 - Advanced Nework Security

RSA – find e and d (con’t) Then find d using extended Euclid’s algorithm (EEA). d*e mod m = 1 => 1 = d*e + k*m; where k is an integer. 1 = d*e + k*m  ax + by = 1; Note: We can also use a general EEA to find e and d at the same time. CPE5021 - Advanced Nework Security

Research for the implementation of RSA There are many free source codes implementing RSA in C, C++ and Java. (you can study the source codes but not copy them). Study the Euclidian algorithms and implement them if you need to. Implement the Miller Rabin test. Implement the random number generator. Find a way to convert a message into a number before you encrypt it and convert the encrypted number back to the text format (original message). CPE5021 - Advanced Nework Security