Data Security and Encryption (CSE348) 1. Lecture # 11 2.

Slides:



Advertisements
Similar presentations
1 Lect. 12: Number Theory. Contents Prime and Relative Prime Numbers Modular Arithmetic Fermat’s and Euler’s Theorem Extended Euclid’s Algorithm.
Advertisements

Mathematics of Cryptography Part II: Algebraic Structures
Cryptography and Network Security, Finite Fields From Third Edition by William Stallings Lecture slides by Mustafa Sakalli so much modified..
Cryptography and Network Security
Chapter 4 Finite Fields. Introduction of increasing importance in cryptography –AES, Elliptic Curve, IDEA, Public Key concern operations on “numbers”
Cryptography and Network Security Chapter 4 Fourth Edition by William Stallings.
Chapter 4 – Finite Fields. Introduction will now introduce finite fields of increasing importance in cryptography –AES, Elliptic Curve, IDEA, Public Key.
Cryptography and Network Security Chapter 4 Fifth Edition by William Stallings Lecture slides by Lawrie Brown.
Section 4.1: Primes, Factorization, and the Euclidean Algorithm Practice HW (not to hand in) From Barr Text p. 160 # 6, 7, 8, 11, 12, 13.
Number Theory and Cryptography
Chap. 4: Finite Fields Jen-Chang Liu, 2005 Adapted from lecture slides by Lawrie Brown.
CNS2010handout 8 :: introduction to number theory1 computer and network security matt barrie.
Cryptography and Network Security Chapter 4
Cryptography and Network Security Chapter 4 Fourth Edition by William Stallings.
Chapter 4 – Finite Fields Introduction  will now introduce finite fields  of increasing importance in cryptography AES, Elliptic Curve, IDEA, Public.
Cryptography and Network Security, Finite Fields From Third Edition by William Stallings Lecture slides by Mustafa Sakalli so much modified..
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
BY MISS FARAH ADIBAH ADNAN IMK
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
CSCI 1900 Discrete Structures
Great Theoretical Ideas in Computer Science.
Mathematics of Cryptography Part I: Modular Arithmetic
MATH 224 – Discrete Mathematics
Number Theory and Advanced Cryptography 1. Finite Fields and AES
Module :MA3036NI Cryptography and Number Theory Lecture Week 7
Mathematics of Cryptography Modular Arithmetic, Congruence,
FINITE FIELDS 7/30 陳柏誠.
CPSC 3730 Cryptography and Network Security
1 Cryptography and Network Security Third Edition by William Stallings Lecture slides by Lawrie Brown Chapter 4 – Finite Fields.
Information Security and Management 4. Finite Fields 8
Cryptography and Network Security Introduction to Finite Fields.
Prelude to Public-Key Cryptography Rocky K. C. Chang, February
CompSci 102 Discrete Math for Computer Science February 16, 2012 Prof. Rodger.
Modular Arithmetic with Applications to Cryptography Lecture 47 Section 10.4 Wed, Apr 13, 2005.
Chapter 4 – Finite Fields
Data Security and Encryption (CSE348) 1. Lecture # 12 2.
YSLInformation Security -- Public-Key Cryptography1 Prime and Relatively Prime Numbers Divisors: We say that b  0 divides a if a = mb for some m, where.
Fall 2002CS 395: Computer Security1 Chapters 4 and 8: The Mathematics Required for Public Key Cryptography In case you’re beginning to worry that this.
Information Security Lab. Dept. of Computer Engineering 87/121 PART I Symmetric Ciphers CHAPTER 4 Finite Fields 4.1 Groups, Rings, and Fields 4.2 Modular.
Foundations of Discrete Mathematics Chapter 4 By Dr. Dalia M. Gil, Ph.D.
Cryptography and Network Security Chapter 4. Introduction  will now introduce finite fields  of increasing importance in cryptography AES, Elliptic.
Module #9 – Number Theory 1/5/ Algorithms, The Integers and Matrices.
Greatest Common Divisors & Least Common Multiples  Definition 4 Let a and b be integers, not both zero. The largest integer d such that d|a and d|b is.
Lecture 3.1: Public Key Cryptography I CS 436/636/736 Spring 2015 Nitesh Saxena.
Cryptography and Network Security Chapter 4 Fifth Edition by William Stallings Lecture slides by Lawrie Brown.
Cryptography Lecture 14 Arpita Patra © Arpita Patra.
Ch04-Number Theory and Cryptography 1. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic.
Cryptography and Network Security Third Edition by William Stallings Lecture slides by Lawrie Brown.
Chapter 4 With Question/Answer Animations 1. Chapter Motivation Number theory is the part of mathematics devoted to the study of the integers and their.
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
Great Theoretical Ideas in Computer Science.
CSCE 715: Network Systems Security Chin-Tser Huang University of South Carolina.
Number-Theoretic Algorithms
Cryptography and Network Security Chapter 4
Chapter4: Finite Fields
Discrete Math II Howon Kim
MATH301- DISCRETE MATHEMATICS Copyright © Nahid Sultana Dr. Nahid Sultana Chapter 4: Number Theory and Cryptography.
Number Theory and Modular Arithmetic
Cryptography and Network Security Chapter 4
Cryptography and Network Security
Cryptography and Network Security Chapter 4
Cryptography and Network Security Chapter 4
Cryptography and Network Security Chapter 4
Cryptography Lecture 16.
Applied Cryptography II (Finite Fields)
Presentation transcript:

Data Security and Encryption (CSE348) 1

Lecture # 11 2

Review – The AES selection process – The details of Rijndael – the AES cipher – Looked at the steps in each round – Out of four AES stages, last two are discussed MixColumns AddRoundKey – The key expansion – Implementation aspects 3

Chapter 4 Basic Concepts in Number Theory and Finite Fields 4

The next morning at daybreak, Star flew indoors, seemingly keen for a lesson. I said, "Tap eight." She did a brilliant exhibition, first tapping it in 4, 4, then giving me a hasty glance and doing it in 2, 2, 2, 2, before coming for her nut. It is astonishing that Star learned to count up to 8 with no difficulty, and of her own accord discovered that each number could be given with various different divisions, this leaving no doubt that she was consciously thinking each number. In fact, she did mental arithmetic, although unable, like humans, to name the numbers. But she learned to recognize their spoken names almost immediately and was able to remember the sounds of the names. Star is unique as a wild bird, who of her own free will pursued the science of numbers with keen interest and astonishing intelligence. — Living with Birds, Len Howard 5

Introduction Finite fields have become increasingly important in cryptography A number of cryptographic algorithms rely heavily on properties of finite fields Notably the Advanced Encryption Standard (AES) and elliptic curve cryptography 6

Introduction The main purpose of this chapter is to provide the reader with sufficient background on the concepts of finite fields to be able to understand the design of AES and other cryptographic algorithms that use finite fields some basic concepts from number theory that include divisibility, the Euclidian algorithm, and modular arithmetic 7

Introduction will now introduce finite fields of increasing importance in cryptography – AES, Elliptic Curve, IDEA, Public Key concern operations on “numbers” – where what constitutes a “number” and the type of operations varies considerably start with basic number theory concepts 8

Divisors say a non-zero number b divides a if for some m have a=mb ( a,b,m all integers) that is b divides into a with no remainder denote this b|a and say that b is a divisor of a eg. all of 1,2,3,4,6,8,12,24 divide9 24 eg. 13 | 182; –5 | 30; 17 | 289; –3 | 33; 17 | 0 9

Properties of Divisibility If a|1, then a = ±1. If a|b and b|a, then a = ±b. Any b /= 0 divides 0. If a | b and b | c, then a | c – e.g. 11 | 66 and 66 | 198 x 11 | 198 If b|g and b|h, then b|(mg + nh) for arbitrary integers m and n e.g. b = 7; g = 14; h = 63; m = 3; n = 2 hence 7|14 and 7|63 10

Properties of Divisibility If b|g and b|h, then b|(mg + nh) for arbitrary integers m and n e.g. b = 7; g = 14; h = 63; m = 3; n = 2 hence 7|14 and 7|63 then b|(mg + nh) 7/(3*14+2*63) 11

Division Algorithm if divide a by n get integer quotient q and integer remainder r such that: – a = qn + r where 0 <= r < n; q = floor(a/n) remainder r often referred to as a residue 12

Division Algorithm 13

Division Algorithm Figure 4.1a demonstrates that, given a and positive n It is always possible to find q and r that satisfy the preceding relationship Represent the integers on the number line a will fall somewhere on that line – positive a is shown, a similar demonstration can be made for negative a 14

Division Algorithm Starting at 0, proceed to n, 2n, up to qn such that qn a The distance from qn to a is r, and we have found the unique values of q and r For example: a = 11; n = 7; 11 = 1 x 7 + 4; r = 4 q = 1 a = –11; n = 7; –11 = (–2) x 7 + 3; r = 3 q = –2 Figure 4.1b provides another example 15

Greatest Common Divisor (GCD) One of the basic techniques of number theory is the Euclidean algorithm which is a simple procedure for determining the greatest common divisor of two positive integers Use the notation gcd(a,b) to mean the greatest common divisor of a and b 16

Greatest Common Divisor (GCD) Positive integer c is said to be the greatest common divisor of a and b if c is a divisor of a and of b and any divisor of a and b is a divisor of c We also define gcd(0, 0) = 0 State that two integers a and b are relatively prime if their only common positive integer factor is 1, i.e. GCD(a,b)=1 17

Greatest Common Divisor (GCD)  a common problem in number theory  GCD (a,b) of a and b is the largest integer that divides evenly into both a and b eg GCD(60,24) = 12  define gcd(0, 0) = 0  often want no common factors (except 1) define such numbers as relatively prime eg GCD(8,15) = 1 hence 8 & 15 are relatively prime 18

Example GCD(1970,1066) 1970 = 1 x gcd(1066, 904) 1066 = 1 x gcd(904, 162) 904 = 5 x gcd(162, 94) 162 = 1 x gcd(94, 68) 94 = 1 x gcd(68, 26) 68 = 2 x gcd(26, 16) 26 = 1 x gcd(16, 10) 16 = 1 x gcd(10, 6) 10 = 1 x gcd(6, 4) 6 = 1 x gcd(4, 2) 4 = 2 x gcd(2, 0) 19

Example GCD(1970,1066) Illustrate how we can compute successive instances of GCD(a,b) = GCD(b,a mod b). This MUST always terminate since will eventually get a mod b = 0 (ie no remainder left) Answer is then the last non-zero value. In this case GCD(1970, 1066)=2 20

GCD( , ) DividendDivisorQuotientRemainder a = b = q1 = 3 r1 = b = r1 = q2 = 1 r2 = r1 = r2 = q3 = 2 r3 = r2 = r3 = q4 = 31r4 = r3 = r4 = q5 = 2 r5 = r4 = r5 = q6 = 11r6 = r5 = r6 = q7 = 1 r7 = r6 = r7 = q8 = 1 r8 = 2516 r7 = r8 = 2516 q9 = 31r9 = 1078 r8 = 2516 r9 = 1078 q10 = 2r10 = 0 21

GCD( , ) This example shows how to find d = gcd(a, b) = gcd( , ), shown in tabular form In this example, we begin by dividing by , which gives 3 with a remainder of Next we take and divide it by The process continues until we get a remainder of 0, yielding a result of

Modular Arithmetic Given any positive integer n and any non-negative integer a If we divide a by n, we get an integer quotient q and an integer remainder r In modular arithmetic we are only interested in the remainder (or residue) after division by some modulus 23

Modular Arithmetic and results with the same remainder are regarded as equivalent Two integers a and b are said to be congruent modulo n, if (a mod n) = (b mod n) 24

Modular Arithmetic define modulo operator “ a mod n” to be remainder when a is divided by n – where integer n is called the modulus b is called a residue of a mod n – since with integers can always write: a = qn + b – usually chose smallest positive remainder as residue ie. 0 <= b <= n-1 – process is known as modulo reduction eg. -12 mod 7 = -5 mod 7 = 2 mod 7 = 9 mod 7 a & b are congruent if: a mod n = b mod n – when divided by n, a & b have same remainder – eg. 100 = 34 mod 11 25

Modular Arithmetic Operations That the (mod n) operator maps all integers into the set of integers {0, 1,... (n – 1)}, denoted Z n This is referred to as the set of residues, or residue classes (mod n) We can perform arithmetic operations within the confines of this set, and this technique is known as modular arithmetic 26

Modular Arithmetic Operations Finding the smallest non-negative integer to which k is congruent modulo n is called reducing k modulo n Then some important properties of modular arithmetic which mean one can modulo reduce at any point and obtain an equivalent answer 27

Modular Arithmetic Operations can perform arithmetic with residues uses a finite number of values, and loops back from either end Z n = {0, 1,..., (n – 1)} modular arithmetic is when do addition & multiplication and modulo reduce answer can do reduction at any point, ie – a+b mod n = [a mod n + b mod n] mod n 28

Modular Arithmetic Operations 1.[(a mod n) + (b mod n)] mod n = (a + b) mod n 2.[(a mod n) – (b mod n)] mod n = (a – b) mod n 3.[(a mod n) x (b mod n)] mod n = (a x b) mod n e.g. [(11 mod 8) + (15 mod 8)] mod 8 = 10 mod 8 = ( ) mod 8 = 26 mod 8 = 2 [(11 mod 8) – (15 mod 8)] mod 8 = –4 mod 8 = (11 – 15) mod 8 = –4 mod 8 = 4 [(11 mod 8) x (15 mod 8)] mod 8 = 21 mod 8 = (11 x 15) mod 8 = 165 mod 8 = 5 29

Modulo 8 Addition Example

Modulo 8 Addition Example Example showing addition in GF(8), from Stallings Table 4.2a. Table 4.2 provides an illustration of modular addition and multiplication modulo 8 Looking at addition, the results are straightforward and there is a regular pattern to the matrix Both matrices are symmetric about the main diagonal, in conformance to the commutative property of addition and multiplication 31

Modulo 8 Addition Example As in ordinary addition, there is an additive inverse, or negative, to each integer in modular arithmetic In this case, the negative of an integer x is the integer y such that (x + y) mod 8 = 0 To find the additive inverse of an integer in the left-hand column 32

Modulo 8 Addition Example scan across the corresponding row of the matrix to find the value 0 the integer at the top of that column is the additive inverse; thus (2 + 6) mod 8 = 0 33

Modulo 8 Multiplication *

Modulo 8 Multiplication Continuing the example showing multiplication in GF(8), from Stallings Table 4.2b Both matrices are symmetric about the main diagonal, in conformance to the commutative property of addition and multiplication Similarly, the entries in the multiplication table are straightforward In ordinary arithmetic, there is a multiplicative inverse, or reciprocal, to each integer 35

Modulo 8 Multiplication In modular arithmetic mod 8, the multiplicative inverse of x is the integer y such that (x x y) mod 8 = 1 mod 8 Now, to find the multiplicative inverse of an integer from the multiplication table scan across the matrix in the row for that integer to find the value 1 36

Modulo 8 Multiplication The integer at the top of that column is the multiplicative inverse; thus (3 x 3) mod 8 = 1 That not all integers mod 8 have a multiplicative inverse; more about that later 37

Modular Arithmetic Properties 38

Modular Arithmetic Properties If we perform modular arithmetic within Z n, the properties shown in Table 4.3 hold for integers in Z n We show in the next section that this implies that Z n is a commutative ring with a multiplicative identity element That unlike ordinary arithmetic, the following statement is true only with the attached condition: 39

Modular Arithmetic Properties if (a x b) = (a x c) (mod n) then b = c (mod n) if a is relatively prime to n In general, an integer has a multiplicative inverse in Z n if that integer is relatively prime to n Table 4.2 c in the text shows that the integers 1, 3, 5, and 7 have a multiplicative inverse in Z 8 but 2, 4, and 6 do not 40

Euclidean Algorithm An algorithm credited to Euclid for easily finding the greatest common divisor of two integers This algorithm has significance subsequently in this chapter The Euclidean algorithm is an efficient way to find the GCD(a,b) and is derived from the observation that if a & b have a common factor d (ie. a=m.d & b=n.d) 41

Euclidean Algorithm Then d is also a factor in any difference between them, vis: a-p.b = (m.d)-p.(n.d) = d.(m-p.n) Euclid's Algorithm keeps computing successive differences until it vanishes, at which point the greatest common divisor has been reached Some pseudo-code from the text for this algorithm is shown 42

Euclidean Algorithm an efficient way to find the GCD(a,b) uses theorem that: – GCD(a,b) = GCD(b, a mod b) Euclidean Algorithm to compute GCD(a,b) is: Euclid(a,b) if (b=0) then return a; else return Euclid(b, a mod b); 43

Extended Euclidean Algorithm An extension to the Euclidean algorithm That will be important for later computations in the area of finite fields and in encryption algorithms such as RSA For given integers a and b, the extended Euclidean algorithm not only calculate the greatest common divisor d but also two additional integers x and y that satisfy the following equation: ax + by = d = gcd(a, b) 44

Extended Euclidean Algorithm It should be clear that x and y will have opposite signs Can extend the Euclidean algorithm to determine x, y, d, given a and b We again go through the sequence of divisions indicated in Equation Set (4.3) and we assume that at each step i, we can find integers x and y that satisfy r = ax + by 45

Extended Euclidean Algorithm In each row, we calculate a new remainder r, based on the remainders of the previous two rows We know from the original Euclidean algorithm that the process ends with a remainder of zero and that the greatest common divisor of a and b is d = gcd(a, b) = r n But we also have determined that d = r n = axn + byn. 46

Extended Euclidean Algorithm calculates not only GCD but x & y: ax + by = d = gcd(a, b) useful for later crypto computations follow sequence of divisions for GCD but assume at each step i, can find x &y: r = ax + by at end find GCD value and also x & y if GCD(a,b)=1 these values are inverses 47

Finding Inverses An important problem is to find multiplicative inverses in such finite fields Can show that such inverses always exist, & can extend the Euclidean algorithm to find them as shown See text for discussion as to why this works 48

Finding Inverses EXTENDED EUCLID(m, b) 1. (A1, A2, A3)=(1, 0, m); (B1, B2, B3)=(0, 1, b) 2. if B3 = 0 return A3 = gcd(m, b); no inverse 3. if B3 = 1 return B3 = gcd(m, b); B2 = b –1 mod m 4. Q = A3 div B3 5. (T1, T2, T3)=(A1 – Q B1, A2 – Q B2, A3 – Q B3) 6. (A1, A2, A3)=(B1, B2, B3) 7. (B1, B2, B3)=(T1, T2, T3) 8. goto 2 49

Inverse of 550 in GF(1759) Example showing how to find the inverse of 550 in GF(1759), adapted from Stallings Table 4.4 In this example, let us use a = 1759 and b = 550 and solve for 1759x + 550y = gcd(1759, 550) The results are shown in Table 4.4. Thus, we have 1759 x (–111) x 355 = – = 1 50

Inverse of 550 in GF(1759) 51

Summary – Number Theory – divisibility & GCD – modular arithmetic with integers – Euclid’s algorithm for GCD & Inverse 52