Cryptography
Terminology
Secrecy ensures information flow between the sender
and receiver is unintelligible to outsiders-protects
information against threats based on eavesdropping
Authenticity allows receiver of messages to determine
the true identity of the sender-guards messages against
impersonation, substitution or spoofing
Integrity-enables the receiver to verify whether the
message has been tampered with by outsiders while in
transit via an insecure channel
Nonrepudiation-prevents the sender of a message from
claiming that they have not sent the message
Background Theory
Rational Numbers
Real number r is called rational if
Z, r = p / q where q!=0
All real numbers which are not rational are
called irrational
Every integer is a rational number
Every rational number is not an integer
Sum of any two rational numbers is a
rational number
Divisibility
Integer n is a divisible by an integer d, when
k Z, n = d * k
Notation: d | n (d divides n)
Synonymous statements:
n is a multiple of d
d is a factor of n
d is a divisor of n
d divides n
n is divisible by d
Divisibility- Properties
If n|a and n|b then n divides both (a+b) and (a-b) (set
of multiples of n is closed under addition)
Divisibility is transitive: for all integers a, b, c, if a
divides b and b divides c, then a divides c
For any nonzero b Z, if n|a, then n divides ab
For any nonzero b Z, |a| |b| if a|b
Any integer greater than 1 is divisible by a prime
number
If a | b and b | a, then |a| =|b|
Any integer can be uniquely represented in the
standard factored form:
n = p1e1 * p2e2 * * pkek, p1 < p2 < < pk, pi is a prime
number
Exercises
Prove or provide counterexample:
For integers a, b, c: (a | b) (a | bc)
For integers a, b, c: (a | (b + c)) (a | b a | c)
If 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * m = 151 * 150 *
149 * 148 * 147 * 146 * 145 * 144 * 143,
does 151 | m?
Show that an integer is divisible by 9 iff the
sum of its digits is divisible by 9. Prove the
same for divisibility by 3.
Show that an integer is divisible by 11 iff the
alternate sum of its digits is divisible by 11
Primes
A positive integer p greater than 1 is called prime if
the only positive factors of p are 1 and p.
A positive integer that is greater than 1 and is not
prime is called composite.
The fundamental theorem of arithmetic:
Every positive integer can be written uniquely as
the product of primes, where the prime factors are
written in order of increasing size.
14
Prime Factorisation
to factor a number n is to write it as a product of other
numbers: n=a b c
note that factoring a number is relatively hard compared
to multiplying the factors together to generate the
number
the prime factorisation of a number n is when its written
as a product of primes
eg. 91=713 ; 3600=243252
Primes
Examples:
15 =
35
48 =
22223 = 243
17 =
17
100 =
2255 = 2252
512 =
222222222 = 29
515 =
5103
28 =
227
16
22 31 51
b = 54 =
21 33 50
lcm(a, b) =
22 33 51 = 4275 = 540
17
21
lcm(4, 6) =
12
lcm(5, 10) =
10
18
19
22 31 51
b = 54 =
21 33 50
gcd(a, b) =
21 31 50 = 6
20
Euclid algorithm
Initialize r0=a and r1=b
E2: Compute the following sequence of equations
r0=q1r1 + r2
r1=q2r2 + r3
rn-3=qn-2rn-2 + rn-1
rn-2=qn-1rn-1 + rn
Until there is a step for which rn=0 while rn-10
E3:The greatest common divisor is equal to rn-1.
C implementation
long gcd(long a, long b)
{
long r0, r1, r2;
if (a==0 || b==0) return (0);
r0=a;
r1=b;
r2=r0%r1;
while(r2)
{ r0=r1;
r1=r2;
r2=r0%r1;
}
if (r1>0)
return (r1);
else
return (-r1);
}
24
Primes
Sieve of Eratosthenes-determines all primes smaller than N
Create an initial set of all numbers N N ={2,3,4, N-1}
S1:
smaller than N
S2:For all integers n<
S3:The final reduced set N N contains all primes smaller
than N
Mersenne Number
A Mersenne Number is an integer of the form
Mp = 2p - 1 where p is a prime
If a Mersenne Number is itself prime then it is called Mersenne
prime
The three smallest Mersenne primes are
M2 = 3, M3 = 7, M5 = 31.
While it is true that only Mersenne numbers Mp, where p = 2, 3,
5, could be prime, often Mp is not prime even for a prime
exponent p
The smallest counterexample is the Mersenne number
M11 = 211 1 = 2047 = 23 89, which is not prime, even though
11 is a prime number
The largest known prime number (243,112,609 1) is a Mersenne
prime