Implementation Tutorial on RSA

Similar documents
Public Key Cryptography

CPE 776:DATA SECURITY & CRYPTOGRAPHY. Some Number Theory and Classical Crypto Systems

The security of RSA (part 1) The security of RSA (part 1)

1 Recommended Reading 1. 2 Public Key/Private Key Cryptography Overview RSA Algorithm... 2

Math.3336: Discrete Mathematics. Mathematical Induction

RSA. Ramki Thurimella

Number theory (Chapter 4)

Attacks on RSA & Using Asymmetric Crypto

Solution to Midterm Examination

NET 311D INFORMATION SECURITY

YALE UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE

Cryptography. pieces from work by Gordon Royle

5199/IOC5063 Theory of Cryptology, 2014 Fall

Math 430 Midterm II Review Packet Spring 2018 SOLUTIONS TO PRACTICE PROBLEMS

Final Exam Math 105: Topics in Mathematics Cryptology, the Science of Secret Writing Rhodes College Tuesday, 30 April :30 11:00 a.m.

Homework 4 for Modular Arithmetic: The RSA Cipher

Definition: For a positive integer n, if 0<a<n and gcd(a,n)=1, a is relatively prime to n. Ahmet Burak Can Hacettepe University

Network Security Technology Spring, 2018 Tutorial 3, Week 4 (March 23) Due Date: March 30

Lemma 1.2. (1) If p is prime, then ϕ(p) = p 1. (2) If p q are two primes, then ϕ(pq) = (p 1)(q 1).

Public Key Algorithms

RSA RSA public key cryptosystem

Slides by Kent Seamons and Tim van der Horst Last Updated: Oct 1, 2013

Introduction to Modern Cryptography. Benny Chor

Chapter 8 Public-key Cryptography and Digital Signatures

RSA Algorithm. Factoring, EulerPhi, Breaking RSA. Çetin Kaya Koç Spring / 14

An Introduction to Cryptography

The RSA cryptosystem and primality tests

The Vigenère cipher is a stronger version of the Caesar cipher The encryption key is a word/sentence/random text ( and )

Security Issues in Cloud Computing Modern Cryptography II Asymmetric Cryptography

10 Modular Arithmetic and Cryptography

University of Regina Department of Mathematics & Statistics Final Examination (April 21, 2009)

Practice Assignment 2 Discussion 24/02/ /02/2018

Public-Key Cryptosystems CHAPTER 4

Implementation of the RSA algorithm and its cryptanalysis. Abstract. Introduction

basics of security/cryptography

Cryptography. P. Danziger. Transmit...Bob...

Encryption: The RSA Public Key Cipher

CIS 551 / TCOM 401 Computer and Network Security

Introduction to Public-Key Cryptosystems:

Candidates must show on each answer book the type of calculator used. Only calculators permitted under UEA Regulations may be used.

Theme : Cryptography. Instructor : Prof. C Pandu Rangan. Speaker : Arun Moorthy CS

CSc 466/566. Computer Security. 5 : Cryptography Basics

AN ALGEBRAIC PROOF OF RSA ENCRYPTION AND DECRYPTION

DM49-2. Obligatoriske Opgave

Discrete Mathematics GCD, LCM, RSA Algorithm

Cryptography IV: Asymmetric Ciphers

Math 412: Number Theory Lecture 13 Applications of

MATH3302 Cryptography Problem Set 2

COMP4109 : Applied Cryptography

Introduction. What is RSA. A Guide To RSA by Robert Yates. Topics

RSA ENCRYPTION USING THREE MERSENNE PRIMES

Written examination. Tuesday, August 18, 2015, 08:30 a.m.

Asymmetric Encryption

Lecture Notes. Advanced Discrete Structures COT S

Asymmetric Cryptography

Chapter 4 Asymmetric Cryptography

Cosc 412: Cryptography and complexity Lecture 7 (22/8/2018) Knapsacks and attacks

CRYPTOGRAPHY AND NUMBER THEORY

1 What are Physical Attacks. 2 Physical Attacks on RSA. Today:

Public-key Cryptography and elliptic curves

Overview. Background / Context. CSC 580 Cryptography and Computer Security. March 21, 2017

CPSC 467b: Cryptography and Computer Security

Iterated Encryption and Wiener s attack on RSA

Mathematical Foundations of Public-Key Cryptography

Ma/CS 6a Class 4: Primality Testing

CPSC 467b: Cryptography and Computer Security

10 Public Key Cryptography : RSA

Solutions to the Midterm Test (March 5, 2011)

Mathematics of Cryptography

Elliptic Curve Cryptography

CPSC 467b: Cryptography and Computer Security

CODING AND CRYPTOLOGY III CRYPTOLOGY EXERCISES. The questions with a * are extension questions, and will not be included in the assignment.

Notes 10: Public-key cryptography

Number Theory: Applications. Number Theory Applications. Hash Functions II. Hash Functions III. Pseudorandom Numbers

Lecture 1: Introduction to Public key cryptography

Public Key 9/17/2018. Symmetric Cryptography Review. Symmetric Cryptography: Shortcomings (1) Symmetric Cryptography: Analogy

Lecture V : Public Key Cryptography

Public Key Cryptography. All secret key algorithms & hash algorithms do the same thing but public key algorithms look very different from each other.

Cryptography. Lecture 2: Perfect Secrecy and its Limitations. Gil Segev

Security II: Cryptography exercises

CPSC 467b: Cryptography and Computer Security

Cryptography and Network Security Prof. D. Mukhopadhyay Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Question: Total Points: Score:

Cryptography CS 555. Topic 18: RSA Implementation and Security. CS555 Topic 18 1

Number Theory A focused introduction

Number Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory.

Lecture Notes, Week 6

Number Theory & Modern Cryptography

ECE 646 Lecture 5. Mathematical Background: Modular Arithmetic

Algorithmic Number Theory and Public-key Cryptography

Jay Daigle Occidental College Math 401: Cryptology

CPSC 467: Cryptography and Computer Security

ECE596C: Handout #11

Public Key Cryptography

Outline. Available public-key technologies. Diffie-Hellman protocol Digital Signature. Elliptic curves and the discrete logarithm problem

Tutorial on Quantum Computing. Vwani P. Roychowdhury. Lecture 1: Introduction

RSA Key Extraction via Low- Bandwidth Acoustic Cryptanalysis. Daniel Genkin, Adi Shamir, Eran Tromer

COMP424 Computer Security

Alternative Approaches: Bounded Storage Model

Review. CS311H: Discrete Mathematics. Number Theory. Computing GCDs. Insight Behind Euclid s Algorithm. Using this Theorem. Euclidian Algorithm

Transcription:

Implementation Tutorial on Maciek Adamczyk; m adamczyk@umail.ucsb.edu Marianne Magnussen; mariannemagnussen@umail.ucsb.edu Adamczyk and Magnussen Spring 2018 1 / 13

Overview Implementation Tutorial Introduction to Cryptography Public-Key Cryptography - An Example Implementation Adamczyk and Magnussen Spring 2018 2 / 13

Introduction Implementation Tutorial Cryptography: A technique for securing communication between two or more parties Encrypting - Making the information unreadable for other people Decrypting - Decoding unreadable information to its original form Different types of cryptography: Symmetric-key - same key for encryption and decryption Public-key - two different keys for encryption and decryption Adamczyk and Magnussen Spring 2018 3 / 13

Public-key Cryptography Encryption scheme that uses two mathematically related, but not identical, keys The public key: for encryption and may be freely distributed The private key: for decryption and is private Adamczyk and Magnussen Spring 2018 4 / 13

Implementation Tutorial Given a composite number, it is considered a hard problem to determine it s prime factors [2] The keys in are based on n = pq, where p and q are two large and random primes is a set of two algorithms: 1 Key Generation Generate the public and private key 2 Function Evaluation Process of transforming plaintext into ciphertext or vice versa Adamczyk and Magnussen Spring 2018 5 / 13

: Security Implementation Tutorial is considered a secure algorithm since no known attempts to break it have yet been successful The algorithm is hard to break because of the difficulty of factoring large numbers n = pq Security Level Modulus Size Strength 80 bits 1024 bits 86.76611925028119 112 bits 2048 bits 116.8838132958159 128 bits 3072 bits 138.7362808527251 192 bits 7680 bits 203.01873594417665 256 bits 15360 bits 269.38477262128384 Security strength of in relation with modulus Adamczyk and Magnussen Spring 2018 6 / 13

: Strengths and Weaknesses The keys work both ways - the other key will always be able to decrypt. [3] is hard to break but relatively easy to compute Multiplying the two primes is an easier process than doing the factorization A weak choice of p and q makes vulnerable to attacks Large primes does more secure but the device performance and calculation time rises with the length of those numbers Adamczyk and Magnussen Spring 2018 7 / 13

: Key Generation - Steps Generate a large integer n = pq, where p and q are two distinct and large primes Compute the Totient φ: φ(n) = (p 1)(q 1) φ(n) is used to calculate e The Public key is made by n and e In the range [3, φ(n)) choose a prime number e that has gcd = 1 with φ(n) Choosing e too small, may lead to security flaws The Private key is made by n and d Compute d by taking the multiplicative inverse of the Public Key. e d = 1mod(φ(n)) Adamczyk and Magnussen Spring 2018 8 / 13

: Function Evaluation - Steps Encrypting the message m F (m, e) = m e mod(n) = c Decrypting the cipher text c F (c, d) = c d mod(n) = m Adamczyk and Magnussen Spring 2018 9 / 13

: Simple Example [2] - Key Generation Choose two primes, p = 11 and q = 17: n = 11x17 = 187 This gives us: φ(187) = (p 1)(q 1) = 160 The Public key, (n, e): Select e = 3 gcd(3, φ(n)) = 1 3 is in the range [3, φ(n)) The Private key, (n, d): Finding d: Find inverse of e with φ(n). d = 3 1 mod160 = 107 Adamczyk and Magnussen Spring 2018 10 / 13

: Simple Example - Function Evaluation We can now choose our message, lets say we want to encrypt HI Convert letters to numbers: H = 8 and I = 9 m = 89 Encryption m e mod(n) = 89 3 mod187 = 166 = c Decryption c d mod(n) = 166 107 mod187 = 89 = m Different from a real world example: Would need much bigger primes Converting text to numeric format, easy with ascii Adamczyk and Magnussen Spring 2018 11 / 13

: Simple Example Code Simple implementation of example above in Python PS: This is just an example, you should never implement this by yourself unless you really know these things. Use a library. 1 msg = 89 #Message HI c o n v e r t e d to 89 2 p = 11 3 q = 17 4 e = 3 5 n = p q 6 p h i = ( p 1) (q 1) 7 8 d e f f i n d I n v e r s e ( a, p ) : 9 f o r i i n r a n g e ( 0, p ) : 10 i f ( a i % p == 1) : 11 r e t u r n i 12 r e t u r n F a l s e 13 14 d e f e n c r y p t (m) : 15 c = m e % n 16 p r i n t ( E n c r y p t e d Message :, c ) 17 r e t u r n c 18 19 d = f i n d I n v e r s e ( e, p h i ) #d = eˆ 1 mod( p h i ) 20 21 d e f d e c r y p t ( c ) : 22 dmsg = c d % n 23 p r i n t ( Decrypted Message :, dmsg ) 24 r e t u r n dmsg 25 26 p r i n t ( O r i g i n a l Message :, msg ) 27 c = e n c r y p t ( msg ) 28 d e c r y p t ( c ) Adamczyk and Magnussen Spring 2018 12 / 13

References Implementation Tutorial 1 https://sahandsaba.com/cryptography-rsa-part-1.html 2 http://doctrina.org/how--works-with-examples.html 3 http://www.ijstr.org/final-print/july2017/rsa-public-key- Cryptography-Algorithm-A-Review.pdf Adamczyk and Magnussen Spring 2018 13 / 13