Docsity

Basics of Public Key Cryptography & RSA Algorithm: Prime Numbers & Number Theory, Thesis of Introduction to Software Engineering

Toggle sidebar
bg1
1
Public Key Cryptography and
RSA
Murat Kantarcioglu
Based on Prof. Ninghui Li’s Slides
2
Review: Number Theory
Basics
Definition An integer n > 1 is called a prime number
if its positive divisors are 1 and n.
Definition Any integer number n > 1 that is not prime
is called a composite number.
Theorem (Fundamental Theorem of Arithmetic)
Definition The greatest common divisor of a and b,
denoted by gcd(a, b), is the largest number that
divides both a and b.
Definition Two integers a > 0 and b > 0 are relatively
prime if gcd(a, b) = 1.
ek
k
ee pppn ...
2
21
1
=
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Basics of Public Key Cryptography & RSA Algorithm: Prime Numbers & Number Theory and more Thesis Introduction to Software Engineering in PDF only on Docsity!

Public Key Cryptography and

RSA

Murat Kantarcioglu

Based on Prof. Ninghui Li’s Slides

2

Review: Number Theory

Basics

Definition An integer n > 1 is called a prime number if its positive divisors are 1 and n.

Definition Any integer number n > 1 that is not prime is called a composite number.

Theorem (Fundamental Theorem of Arithmetic)

Definition The greatest common divisor of a and b,

denoted by gcd(a, b), is the largest number that divides both a and b.

Definition Two integers a > 0 and b > 0 are relatively prime if gcd(a, b) = 1.

ek k

e e

n p p ... p

2 1 2

1

3

Review: Extended Euclidian

Algorithm

Input: a, b

Output: (d,x,y) s.t. d=gcd(a,b) and ax + by = d

d=a; t=b; x=1; y=0; r=0; s=1; while (t>0) { q = d/t u=x-qr; v=y-qs; w=d-qt x=r; y=s; d=t r=u; s=v; t=w } return (d, x, y)

gcd(a,b)=gcd(d,t) ax + by = d ar + bs = t

Invariants:

How many times before this loop stops?^ Euclidian Algorithm

4

Review: Chinese Reminder

Theorem (CRT)

Let n 1 , n 2 , ,,, nk be integers s.t. gcd(ni, nj) = 1, i ≠ j.

There exists a unique solution modulo n = n 1 n 2 … nk The solution is given by

ρ(a1,a2,…,ak) = (Σ aimiyi ) mod n,

  • where mi = n / ni, and yi = mi-1^ mod ni

x ak n k

x a n

x a n

mod

mod

mod

2 2

1 1

Fall 2004/Lecture 13 7

Lecture Outline

• Why public key

cryptography?

• Overview of Public

Key Cryptography

• RSA

  • square & multiply

algorithm

  • RSA implementation

• Pohlig-Hellman

8

Limitation of Secret Key

(Symmetric) Cryptography

  • Secret key cryptography
    • symmetric encryption  confidentiality (privacy)
    • MAC (keyed hash)  authentication (integrity)
  • Sender and receiver must share the same key
    • needs secure channel for key distribution
    • impossible for two parties having no prior relationship
  • Other limitation of authentication scheme
    • cannot authenticate to multiple receivers
    • does not have non-repudiation

9

Public Key Cryptography

Overview

  • Proposed in Diffie and Hellman (1976) “New Directions in Cryptography” - public-key encryption schemes - public key distribution systems - Diffie-Hellman key agreement protocol - digital signature
  • Public-key encryption was proposed in 1970 by James Ellis - in a classified paper made public in 1997 by the British Governmental Communications Headquarters
  • Diffie-Hellman key agreement and concept of digital signature are still due to Diffie & Hellman

10

Public Key Encryption

  • Public-key encryption
    • each party has a PAIR (K, K-1) of keys: K is the public key and K-1^ is the secret key, such that D K-1[ E K[M]] = M
    • Knowing the public-key and the cipher, it is computationally infeasible to compute the private key
    • Public-key crypto system is thus known to be asymmetric crypto systems
    • The public-key K may be made publicly available, e.g., in a publicly available directory
    • Many can encrypt, only one can decrypt

13

Trapdoor One-way

Functions

Definition:

A function f: {0,1}* → {0,1}* is a trapdoor one-way function iff f(x) is a one-way function; however, given some extra information it becomes feasible to compute f-1: given y, find x s.t. y = f(x)

14

RSA Algorithm

  • Invented in 1978 by Ron R ivest, Adi S hamir and Leonard A dleman - Published as R L Rivest, A Shamir, L Adleman, " On Digital Signatures and Public Key Cryptosystems ", Communications of the ACM, vol 21 no 2, pp120-126, Feb 1978
  • Security relies on the difficulty of factoring large composite numbers
  • Essentially the same algorithm was discovered in 1973 by Clifford Cocks, who works for the British intelligence

15

The Multiplicative Group Zpq*

• Let p and q be two large primes

• Denote their product n=pq.

• The multiplicative group Zn= Zpq contains

all integers in the range [1,pq-1] that are

relatively prime to both p and q

• The size of the group is

Φ(pq) = (p-1)(q-1)=n-(p+q)+

• For every x ∈ Zpq*, x(p-1)(q-1)^ ≡ 1

16

Exponentiation in Zpq*

• Motivation: We want to use exponentiation

for encryption

• Let e be an integer, 1<e<(p-1)(q-1)

• When is the function f(x)=xe, a one-to-one

function in Zpq*?

• If xe^ is one-to-one, then it is a permutation

in Zpq*.

19

RSA Description (cont.)

Encryption

Given a message M, 0 < M < n M ∈ Zn− {0} use public key (e, n)

compute C = Me^ mod n C ∈ Zn− {0}

Decryption

Given a ciphertext C, use private key (d) Compute

Cd^ mod n = (Me^ mod n)d^ mod n = Med^ mod n = M

20

RSA Example

  • p = 11, q = 7, n = 77, Φ(n) = 60
  • d = 13, e = 37 (ed = 481; ed mod 60 = 1)
  • Let M = 15. Then C ≡ Me^ mod n
    • C ≡ 1537 (mod 77) = 71
  • M ≡ Cd^ mod n
    • M ≡ 7113 (mod 77) = 15

21

Why does RSA work?

  • Need to show that (Me)d^ (mod n) = M, n = pq
  • We have shown that when M∈Zpq*, i.e., gcd(M, n) = 1, then Med^ ≡ M (mod n)
  • What if M∈Zpq−{0}−Zpq*, e.g., gcd(M, n) = p.
    • ed ≡ 1 (mod Φ(n)), so ed = kΦ(n) + 1, for some integer k.
    • Med^ mod p = (M mod p)ed^ mod p = 0 so Med^ ≡ M mod p
    • Med^ mod q = (Mk*Φ(n)^ mod q) (M mod q) = M mod q so Med^ ≡ M mod q
    • As p and q are distinct primes, it follows from the CRT that Med^ ≡ M mod pq

22

Square and Multiply Algorithm

for Exponentiation

• Computing (x)c^ mod n

  • Example: suppose that c=53=
  • x^53 =(x^26 )^2 ·x=(((x^3 )^2 )^2 ·x)^2 )^2 ·x =(((x^2 ·x)^2 )^2 ·x)^2 )^2 ·x

mod n

Alg: Square-and-multiply (x, n, c = ck-1 ck-2 … c 1 c 0 ) z= for i ← k-1 downto 0 { z ← z^2 mod n if ci = 1 then z ← (z  x) mod n } return z

25

RSA Implementation

• Select p and q prime

numbers

• In general, select

numbers, then test for

primality

• Many implementations

use the Rabin-Miller

test, (probabilistic test)

26

Next …

• Finding large prime

numbers

• Attacks on RSA

• Factoring