COMP4690 Tutorial - PowerPoint PPT Presentation

About This Presentation
Title:

COMP4690 Tutorial

Description:

COMP4690 Tutorial Cryptography & Number Theory Outline DES Example Number Theory RSA Example Diffie-Hellman Example DES Some remarks DES works on bits DES works by ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 26
Provided by: eduh1221
Category:

less

Transcript and Presenter's Notes

Title: COMP4690 Tutorial


1
COMP4690 Tutorial
  • Cryptography
  • Number Theory

2
Outline
  • DES Example
  • Number Theory
  • RSA Example
  • Diffie-Hellman Example

3
DES
  • Some remarks
  • DES works on bits
  • DES works by encrypting groups of 64 bits, which
    is the same as 16 hexadecimal numbers
  • DES uses keys which are also apparently 64 bits
    long. However, every 8th key bit is ignored in
    the DES algorithm, so the effective key size is
    56 bits.
  • If the length of the message to be encrypted is
    not a multiple of 64 bits, it must be padded.
    E.g.
  • The plaintext message "Your lips are smoother
    than vaseline" is, in hexadecimal,
    "596F7572206C6970 732061726520736D
    6F6F746865722074 68616E2076617365 6C696E650D0A".
  • We then pad this message with some 0s on the end,
    to get a total of 80 hexadecimal digits
    "596F7572206C6970 732061726520736D
    6F6F746865722074 68616E2076617365
    6C696E650D0A0000".
  • Then apply DES.

4
Key generation example
  • Let K be the hexadecimal key K
    133457799BBCDFF1. This gives us as the binary key
  • K 0001 0011 0011 0100 0101 0111 0111 1001 1001
    1011 1011 1100 1101 1111 1111 0001
  • 16 subkeys (48-bit) will be generated from K.

5
Key generation example
  • Based on table PC-1 (Permuted Choice 1), we get
    the 56-bit permutation
  • K 1111000 0110011 0010101 0101111 0101010
    1011001 1001111 0001111
  • Next, split this key into left and right halves,
    C0 and D0, where each half has 28 bits.
  • C0 1111000 0110011 0010101 0101111 D0
    0101010 1011001 1001111 0001111

6
Key generation example
  • we now create sixteen blocks Cn and Dn, 1ltnlt16.
    Each pair of blocks Cn and Dn is formed from the
    previous pair Cn-1 and Dn-1, respectively, for n
    1, 2, ..., 16, using a schedule of left
    shifts".

Round number 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Bits rotated 1 1 2 2 2 2 2 2 1 2 2 2 2 2 2 1
7
Key generation example
  • C0 1111000011001100101010101111D0
    0101010101100110011110001111
  • C1 1110000110011001010101011111D1
    1010101011001100111100011110
  • C2 1100001100110010101010111111D2
    0101010110011001111000111101
  • C3 0000110011001010101011111111D3
    0101011001100111100011110101

8
Key generation example
  • We now form the subkeys Kn, for 1ltnlt16, by
    applying the table PC-2 (Permutation Choice Two)
    to each of the concatenated pairs CnDn.
  • For the first subkey, we have
  • C1D1 1110000 1100110 0101010 1011111 1010101
    0110011 0011110 0011110
  • After we apply the permutation PC-2
  • K1 000110 110000 001011 101111 111111 000111
    000001 110010

9
Modular Arithmetic
  • Two integers a and b are said to be congruent
    modulo n, if
  • (a mod n) (b mod n)
  • This is written as ab mod n
  • Define Zn as the set of nonnegative integers less
    than n Zn0,1,,(n-1)

10
Modular Arithmetic
  • Properties of modular arithmetic

11
Modular Arithmetic
  • Define Zp as the set of nonnegative integers less
    than a given prime number p Zp0,1,,(p-1)
  • Because p is prime, all of the nonzero integers
    in Zp are relatively prime to p.
  • There exists a multiplicative inverse for all of
    the nonzero integers in Zp
  • For each nonzero w in Zp, there exists a z in Zp
    such that w x z 1 mod p. z is called the
    multiplicative inverse of w. Or, z w-1.

12
Number Theory
  • Fermats Little Theorem
  • ap-1 1 mod p
  • where p is prime and gcd(a,p)1
  • E.g.
  • a 7, p 19
  • 724911 mod 19
  • 741217 mod 19
  • 784911 mod 19
  • 7161217 mod 19
  • ap-1718716x727x11771 mod 19

13
Number Theory
  • An alternative form of Fermats Little Theorem
  • ap a mod p
  • where p is prime and a is any positive integer
  • E.g.
  • p5,a3,352433 mod 5
  • p5,a10,10510000010 mod 50

14
Number Theory
  • Eulers Totient Function ø(n)
  • The number of positive integers less than n and
    relatively prime to n
  • For prime number p,
  • ø(n) p 1
  • For n pq where p and q are two different prime
    numbers
  • ø(n) (p 1) (q 1)

15
Number Theory
  • Example ø(21)
  • From 1 to 21, totally 21 numbers
  • 21 3x7, 3 and 7 are prime
  • 3s multiples
  • 3, 6, 9, 12, 15, 18, 21
  • 7s multiples
  • 7, 14, 21
  • Other numbers are all relatively prime to 21
  • 21-7-31 (3-1)x(7-1)

16
Number Theory
  • Eulers Theorem
  • aø(n) 1 mod n
  • where gcd(a,n)1
  • E.g.
  • a3n10 ø(10)4
  • hence 34 81 1 mod 10
  • a2n11 ø(11)10
  • hence 210 1024 1 mod 11

17
Number Theory
  • The powers of an integer a, modulo n
  • a, a2, a3, (mod n)
  • If a and n are relatively prime, based on Eulers
    theorem, we have aø(n) 1 mod n
  • a, a2, a3, will have a repeated pattern
  • E.g., ø(5)4, 3ø(5)811 mod 5
  • 3, 4, 2, 1, 3, 4, 2, 1,
  • There may exist lots of m such that am 1 mod n
  • The least positive exponent m such that am 1
    mod n is referred to as
  • the order of a (mod n)
  • the exponent to which a belongs (mod n)
  • the length of the period generated by a

18
Number Theory
19
Number Theory
  • Primitive root
  • If a numbers order (mod n) is ø(n), this number
    is called a primitive root of n
  • Property of primitive root
  • If a is a primitive root of n, then its powers
    a,a2, a3,, aø(n) are distinct (mod n), and are
    all relatively prime to n.
  • In particular, for a prime number p, if a is a
    primitive root of p, then a,a2, a3,, ap-1 are
    distinct (mod p).
  • From the previous table, we can see that prime
    number 19s primitive roots are 2, 3, 10, 13, 14,
    and 15.

20
RSA Example
  • Select primes p17 q11
  • Compute n pq 1711187
  • Compute ø(n)(p1)(q-1)1610160
  • Select e gcd(e,160)1 choose e7
  • Determine d de1 mod 160 and d lt 160
  • d23 since 237161 101601
  • Publish public key KU7,187
  • Keep secret private key KR23,17,11

21
RSA Example
  • given message M 88
  • encryption
  • C 887 mod 187 11
  • decryption
  • M 1123 mod 187 88

22
RSA Example
  • Fast Modular Exponentiation
  • To calculate 887 mod 187
  • 881 mod 187 88
  • 882 mod 187 7744 mod 187 77
  • 884 mod 187 772 mod 187 132
  • 887 mod 187 88421 mod 187 132x77x88 mod 187
    894,432 mod 187 11
  • To calculate 1123 mod 187
  • 111 mod 187 11
  • 112 mod 187 121
  • 114 mod 187 14,641 mod 187 55
  • 118 mod 187 552 mod 187 33
  • 1116 mod 187 332 mod 187 154
  • 1123 mod 187 1116421 mod187 154x55x121x11
    mod 187 11,273,570 mod 187 88

23
Diffie-Hellman Key Exchange
24
Diffie-Hellman Key Exchange
  • users Alice Bob who wish to swap keys
  • agree on prime q7 and a5
  • select random secret keys
  • A chooses xA3, B chooses xB2
  • compute public keys
  • yA53 mod 7 6 (Alice)
  • yB52 mod 7 4 (Bob)
  • compute shared session key as
  • Alice KAB yBxA mod 7 43 mod 7 1
  • Bob KAB yAxB mod 7 62 mod 7 1

25
Diffie-Hellman Key Exchange
  • users Alice Bob who wish to swap keys
  • agree on prime q353 and a3
  • select random secret keys
  • A chooses xA97, B chooses xB233
  • compute public keys
  • yA397 mod 353 40 (Alice)
  • yB3233 mod 353 248 (Bob)
  • compute shared session key as
  • Alice KAB yBxA mod 353 24897 mod 353 160
  • Bob KAB yAxB mod 353 40233 mod 353 160
Write a Comment
User Comments (0)
About PowerShow.com