CCS U-Iii
CCS U-Iii
where p1 <p2 <…< pt are prime numbers and where each ai is a positive integer.
91 = 7 * 13
3600 = 24 * 32 * 52
11011 = 7 * 112 * 13
If P is the set of all prime numbers, then any positive integer a can be written
uniquely in the following form:
300 = 22 * 31 * 52
18 = 21 * 32
gcd(18, 300) = 21 * 31 * 50 = 6
Solution: Using Miller-Rabin Algorithm, we can test the number 341 as follows −
Step2: x = 2 (given)
Step3: S = xq mod p
=8
= 1 x 256 x 1 = 256
Now, = 256 ≠ 1
3.3 Factorization
The idea of "factoring" a number is important - finding numbers which divide
into it.
Taking this as far as can go, by factorising all the factors, we can eventually
write the number as a product of (powers of) primes - its prime factorisation.
Note also that factoring a number is relatively hard compared to multiplying
the factors together to generate the number.
To factor a number n is to write it as a product of other numbers: n=a x b x c
The prime factorization of a number n is when its written as a product of
primes eg. 91=7x13; 3600=24x32x52
Example
a = 7, p = 19
72 = 49≡ 11 (mod 19)
74 = 121 ≡ 7 (mod 19)
78 ≡ 49 ≡ 11 (mod 19)
716 ≡ 121 K 7 (mod 19)
ap-1 = 718 = 716 * 72 ≡ 7 * 11 ≡ 1 (mod 19
ap ≡ a(mod p)
3.6 EULER’S THEOREM
Euler’s theorem states that for every a and n that are relatively prime:
a ø(n)=1(mod n)
The above equation is true, if n is prime, because in that case ø(n)=(n-1) and
Fermat’s theorem holds. However it holds for any integer n. recall that ø(n)is the
number of positive integers less than n that are relatively prime to n. consider the set
of such integers, labeled as follows:
R={x1,x2….x ø(n)}
That is, each element xi of R is a unique positive integer less than n with
gcd(xi,n)=1.now multiply each element by a modulo n:
S={(ax1 mod n), (ax2 mod n),…. (ax ø(n) mod n)}
The set S is a permutation of R, by the following reasons:
1.Because a is relatively prime to n and xi is relatively prime to n,axi must also be
relatively prime to n. thus all the members of S are integers that are less than n and
that are relatively prime to n.
2. There are no duplicates in S. if axi mod n=axi mod n, then xi=xj
An alternative form of the theorem is also useful:
Problem 1
x ≡ 1 mod 5
x ≡ 2 mod 6
x ≡ 3 mod 7
a1=1
a2=2
a3=3
n1=5
n2=6
n3=7
M=n1n2n3
M=5*6*7=210
mi=M/ni
m1=210/5=42
m2=210/6=35
m3=210/7=30
miyi=1 mod ni
42y1=1 mod 5
y1=3 mod 5
35y2= 1 mod 6
y2=5 mod 6
30y3=1 mod 7
y3=4 mod 7
x=(a1m1y1+a2m2y2+ a3m3y3)mod M
=((1*42*3)+(2*35*5)+(3*30*4)) mod 210
=836 mod 210
=206
Problem 2
A bag has contained number of pens if you take out 3 pens at a time 2 pens are left.
If you take out 4 pens at a time 1 pen is left and if you take out 5 pens at a time 3
pens are left in the bag. What is the number of pens in the bag.
x ≡ 2 mod 3
x ≡ 1 mod 4
x ≡ 3 mod 5
a1=2
a2=1
a3=3
n1=3
n2=4
n3=5
M=n1n2n3
M=3*4*5=60
mi=M/ni
m1=60/3=20
m2=60/4=15
m3=60/5=12
miyi=1 mod ni
20y1=1 mod 3
y1=2 mod 3
15y2= 1 mod 4
y2=3 mod 4
12y3=1 mod 5
y3=3 mod 5
x=(a1m1y1+a2m2y2+ a3m3y3)mod M
=((2*20*2)+(1*15*3)+(3*12*3)) mod 60
=233 mod 60
=53
3.8 Exponentiation and Logarithm
Fast Exponentiation
The idea behind the square-and-multiply method
Figure 9.7 shows the process for calculating y = ax using the Algorithm
9.7 (for simplicity, the modulus is not shown). In this case, x = 22 = (10110)2
in binary. The exponent has five bits.
Demonstration of calculation of a22 using square-and-multiply method
Exhaustive Search
Order of an Element
Find the order of all elements in G = <Z10∗, ×>.
Solution
This group has only φ(10) = 4 elements: 1, 3, 7, 9. We can find the order of each
element by trial and error.
DISCRETE LOGARITHMS.
The idea of Discrete Logarithm Properties of G = <Zp*, ×> :
1. Its elements include all integers from 1 to p − 1.
2. It always has primitive roots.
x
3. It is cyclic. The elements can be created using g where x is an integer from 1
to φ(n) = p − 1.
4. The primitive roots can be thought as the base of logarithm.
For any integer b and a primitive root a of prime number p, we can find a
unique exponent i such that
b≡ ai (mod p) where 0 … i … (p - 1)
The exponent i is referred to as the discrete logarithm of b for the base a, mod p.
3.9 ASYMMETRIC KEY CIPHERS
Difficulties in Symmetric encryption
According to Diffie-Hellman
i) Key distribution is a serious issue.
ii) Symmetric encryption is not applicable for Digital signatures
Public key encryption scheme:
Asymmetric algorithms rely on one key for encryption and a different but related
key for decryption. Characteristics
i) It is computationally infeasible to determine the decryption key given
only knowledge of the cryptographic algorithm and the encryption key.
ii) Either of the two related keys can be used for encryption, with the other
used for decryption.
RSA Example
1. Select primes: p=17 & q=11
2. Compute n = pq =17×11=187
3. Compute ø(n)=(p–1)(q-1)=16×10=160
4. Select e : gcd(e,160)=1; choose e=7
5. Determine d: de=1 mod 160 and d < 160 Value is d=23 since 23×7=161
6. Publish public key KU={7,187}
7. Keep secret private key KR={23,17,11}
8. Given message M = 88 ( 88<187)
9. Encryption: C = 887 mod 187 = 11
887 mod 187 = [(884 mod 187) x (882 mod 187) x (881 mod 187)] mod 187
887 mod 187 = (88 x 77 x 132 ) mod 187= 894432 mod 187 = 11
■ Chosen ciphertext attacks: This type of attack exploits properties of the RSA
algorithm.
i)Brute force: This involves trying all The defense against the brute-force approach is the same
possible private keys. for RSA as for other cryptosystems, namely, use a large
key space.
ii)Mathematical attacks: There are To avoid values of n that may be factored more easily, the
several approaches, all equivalent in algorithm's inventors suggest the following constraints on
effort to factoring the product of two p and q:
primes. p and q should differ in length by only a few
The Factoring Problem digits. Thus, for a 1024-bit key (309 decimal digits),
Three approaches to attack RSA both p and q should be on the order of magnitude of
mathematically: 1075 to 10100.
Factor n into its two prime Both (p- 1) and (q- 1) should contain a large
factors. prime factor.
This enables calculation of gcd (p- 1, q - 1) should be small.
ᶲ(n) = (p- 1) x (q- 1), which, in
turn, enables determination of
d ≡ e - 1 (mod ᶲ(n)).
Determine ᶲ (n) directly, without first
determining p and q. Again, this
enables determination of
d ≡ e - 1 (mod ᶲ (n)).
Determine d directly, without first
determining ᶲ (n).
iii)Timing attacks: i)Constant exponentiation time: Ensure that
These depend on the running time of all exponentiations take the same amount of time
the decryption algorithm. A timing before returning a result.
attack is somewhat analogous to a ii)Random delay: Better performance could
burglar guessing the combination of a be achieved by adding a random delay to
safe by observing how long it takes the exponentiation algorithm to confuse the timing
for s o m e o n e t o t u r n t h e dial attack.
f r o m number to number. iii)Blinding: Multiply the cipher text by a
If modular exponentiation is random number before performing exponentiation.
accomplished bit by bit, with one This process prevents the attacker from knowing what
modular multiplication performed cipher text bits are being processed inside the
at each iteration and an additional computer and therefore prevents the bit-by-bit
modular analysis essential to the timing
iv)Chosen cipher text attacks: Optimal asymmetric encryption padding
This type of attack exploits properties of Message M to be encrypted is padded. A set of
the RSA algorithm. optional parameters P is passed through a hash
The basic RSA algorithm is vulnerable to function H.
a chosen cipher text attack (CCA). CCA The output is then padded with zeros to get the
is defined as an attack in which adversary desired length in the overall data block (DB).
chooses a number of cipher texts and is Next, a random seed is generated and passed
then given the corresponding plaintexts, through another hash function, called the mask
decrypted with the target's private key. generating function (MGF).
The resulting hash value is bit-by-bit XORed
3.11 Key Distribution & Management with DB to produce a masked DB.
use
There are actually two distinct aspects to the Theof
concatenation
public-key of the masked seed and the
cryptography:
masked DB forms the encoded message EM.
The distribution of public keys
The EM is then encrypted using RSA.
The use of public-key encryption to distribute secret keys
Distribution of Public Keys
There are four different schemes
Public announcement
Publicly available directory
Public-key authority
Public-key certificates
Public announcement
Any participant can send his or her public key to any other participant or
broadcast the key to the community.
Uncontrolled Public-Key Distribution
Limitations:
Anyone can forge such a public announcement. That is, some user could
pretend to be user A and send a public key to another participant or
broadcast such a public key.
Authentication is needed to avoid this problem.
Publicly Available Directory
A greater degree of security can be achieved by maintaining a publicly available
dynamic directory of public keys. Maintenance and distribution of the public
directory would have to be the responsibility of some trusted entity or
organization.
i)The authority maintains a directory with a {name, public key} entry for each
participant. ii)Each participant registers a public key with the directory authority.
iii) Participants could also access the directory electronically.
Limitations
An Adversary may impersonate by stealing the private key of public key
directory a n d falsely send the public key details.
An attacker may attack the records stored in the
directory.
Public key Authority
Stronger security for public-key distribution can be achieved by providing
tighter control over the distribution of public keys from the directory.
Each participant reliably knows a public key for the authority, with only the
authority knowing the corresponding private key.
iv)A returns N2 encrypted using B's public key, to assure B that its
correspondent is A.
The result is that the two sides have exchanged a secret value.
Ex : ὰ = 3 XA = 97 and XB = 233
A computes YA = 397 mod 353 = 40.
B computes YB = 3233 mod 353 = 248.
After they exchange public keys, each can compute the common secret key: A
computes K = (YB)XA mod 353 = 24897 mod 353 =160.
B computes K = (YA)XB mod 353 = 40233 mod 353 = 160.
Man-in-the-Middle Attack
Suppose Alice and Bob wish to exchange keys, and Darth is the adversary. The
attack proceeds as follows:
1. Alice sends an encrypted message M: E(K2, M).
2. Darth intercepts the encrypted message and decrypts it, to recover M.
3. Darth sends Bob E(K1, M) or E(K1, M'), where M' is any message. In the first
case, Darth simply wants to eavesdrop on the communication without altering it. In
the second case, Darth wants to modify the message going to Bob.
This vulnerability can be overcome with the use of digital signatures and public-key
Certificates.
3.13 Elliptic curve arithmetic
Elliptic Curves:
Y2+axy+by = x3+cx2+dx +e
Decryption : by Bob
Take the first point from Cm - KG
Multiply KG and private key of Bob : Product = nB KG Take the second
point from Cm and subtract the product from it Pm + KPB - nB KG
Substitute PB = nB * G Then Pm + K nB * G - nB KG = Pm
Advantages:
• Shorter key lengths
– Encryption, Decryption and Signature Verification speed up
– Storage and bandwidth savings