Unit Iiimc
Unit Iiimc
Unit Iiimc
Principles of Public Key Cryptosystems – The RSA Algorithm – Key Management – Diffie
Hellman Key Exchange – Elliptic Curve Cryptography – Prime fields and binary fields,
Applications, Practical considerations. Cryptography in Embedded Hardware.
“Public-Key Cryptography”, shows that a public-key encryption scheme has six ingredients:
• Plaintext: the readable message /data fed into the algorithm as input.
• Encryption algorithm: performs various transformations on the plaintext.
• Public and private keys: a pair of keys selected so that if one is used for encryption, the
other is used for decryption. The exact transformations performed by the algorithm
depend on the public or private key that is provided as input.
• Ciphertext: the scrambled message produced as output. It depends on the plaintext and
the key. For a given message, two different keys will produce two different
ciphertexts.
• Decryption algorithm: accepts the ciphertext and matching key and produces the
original plaintext.
Consider the following analogy using padlocked boxes: traditional schemes involve the
sender putting a message in a box and locking it, sending that to the receiver, and
somehow securely also sending them the key to unlock the box. The radical advance
in public key schemes was to turn this around, the receiver sends an unlocked box (their
public key) to the sender, who puts the message in the box and locks it (easy - and
having locked it cannot get at the message), and sends the locked box to the receiver
who can unlock it (also easy), having the (private) key. An attacker would have to
pick the lock on the box (hard).
67
Symmetric vs Public-Key
68
“Public-Key Cryptosystems: Secrecy and Authentication” illustrates the essential elements
of a public-key encryption scheme.
Note that public-key schemes can be used for either secrecy or authentication, or both (as
shown here). There is some source A that produces a message in plaintext X The M
elements of X are letters in some finite alphabet. The message is intended for
destination B. B generates a related pair of keys: a public key, PUb, and a private
key, PRb. PRb is known only to B, whereas PUb is publicly available and therefore
accessible by A. With the message X and the encryption key PUb as input, A forms the
ciphertext Y = E(PUb, X) The intended receiver, in possession of the matching private
key, is able to invert the transformation: X = D(PRb, Y) An adversary, observing Y and
having access to PUb, but not having access to PRb or X, must attempt to recover X
and/or PRb. This provides confidentiality. Can also use a public-key encryption to provide
authentication: Y = E(PRa, X); X = D(PUa, Y) To provide both the authentication function
and confidentiality have a double use of the public-key scheme (as shown here): Z =
E(PUb, E(PRa, X)) X = D(PUa, D(PRb, Z)) In this case, separate key pairs are used
for each of these purposes. The receiver owns and creates secrecy keys, sender
owns and creates authentication keys.
69
Security of Public Key Schemes
Public key schemes are no more or less secure than private key schemes - in both cases
the size of the key determines the security. As with symmetric encryption, a public-key
encryption scheme is vulnerable to a brute-force attack. The countermeasure is the same:
Use large keys. However, there is a tradeoff to be considered. Public-key systems
depend on the use of some sort of invertible mathematical function. The complexity of
calculating these functions may not scale linearly with the number of bits in the key but
grow more rapidly than that. Thus, the key size must be large enough to make brute-force
attack impractical but small enough for practical encryption and decryption. In practice,
the key sizes that have been proposed do make brute-force attack impractical but
result in encryption/decryption speeds that are too slow for general-purpose use. Instead,
as was mentioned earlier, public-key encryption is currently confined to key management
and signature applications. Another form of attack is to find some way to compute the
private key given the public key. To date, it has not been mathematically proven that
this form of attack is infeasible for a particular public-key algorithm.
Note also that you can't compare key sizes - a 64-bit private key scheme has very roughly
similar security to a 512-bit RSA - both could be broken given sufficient resources.
But with public key schemes at least there is usually a firmer theoretical basis for
determining the security since its based on well-known and well studied number
theory problems.
70
3.2 RSA Algorithm:
RSA is the best known, and by far the most widely used general public key
encryption algorithm, and was first published by Rivest, Shamir & Adleman of MIT in
1978 [RIVE78]. The Rivest-Shamir-Adleman (RSA) scheme has since that time
reigned supreme as the most widely accepted and implemented general-purpose
approach to public-key encryption. It is based on exponentiation in a finite (Galois)
field over integers modulo a prime, using large integers (eg. 1024 bits). Its security is
due to the cost of factoring large numbers.
Introduced by Rivest, Shamir & Adleman of MIT in 1977
RSA algorithm:
The ingredients of RSA algorithm are as follows:
1. p, q, two prime numbers private, chosen
2. n= pq public, calculated
3. e, with gcd (e , ø(n))=1 , Where 1<e<ø(n) public, chosen
Plaintext: M=Cd
modN
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:
Key generation:
Users of RSA must:
o Determine two primes at random - p, q
o Select either e or d and compute the other
Primes p , q must not be easily derived from modulus n=p . q
o Means must be sufficiently large
Exponents e, d are inverses, so use inverse algorithm to compute the other
(Extended Euclid‟s algorithm)
RSA security:
Three approaches to attacking RSA:
o Brute force key search (trying all possible private keys)
o Mathematical attacks (factoring the product of two primes)
o Timing attacks (depends on running of decryption algorithm)
Factoring problem:
o Factor n into its two prime factors p and q. Calculate of ø(n) and find d
o Determine ø(n) directly and compute d
o Determine d directly, without first determining ø(n)
Have seen slow improvements over the years
o As of aug-99 best is 512 bit with GNFS
Biggest improvement comes from improved algorithm
o “quadratic sieve” to “generalized number field sieve”
Ensure p, q of similar size and matching other constraints
The threat to larger key sizes is twofold: the continuous increase in
73
computing power and the continuing refinement of factoring problems.
74
Timing attack:
Attacker can determine a private key by keeping track of how long a computer
takes to decipher the message.
o Attack may be from completely unexpected direction
o And it may be a ciphertext only attack
Exploit timing variations in operations using fast modular exponentiation algorithm
o Eg. Multiplying by small vs large number
If the observed time to execute the decryption algorithm is always slow
when the particular iteration is slow with a bit 1, then it is assumed to be 1.
If the observed time for the entire algorithm is fast, then this bit is assumed to be 0.
Countermeasures:
o Constant exponentiation time ensure that all exponentiations take the
same amount of time before returning a result.
o Randomdelay better performance can be achieved by adding a random
delay to the exponentiation algorithm to confuse the timing attack.
o Blinding multiply the ciphertext by random number before
performing exponentiation. This process prevents the attacker from
knowing what ciphertext bits are being processes inside the computer
and therefore prevents the bit by bit analysis essential to the timing
attack.
75
on the difficulty of computing discrete logarithms.
76
In the Diffie-Hellman key exchange algorithm, there are two publicly known numbers: a
prime number q and an integer a that is a primitive root of q. The prime q and primitive root a
can be common to all using some instance of the D-H scheme. Note that the primitive root a is
a number whose powers successively generate all the elements mod q. Users Alice and Bob
choose random secrets x's, and then "protect" them using exponentiation to create their public
y's. For an attacker monitoring the exchange of the y's to recover either of the x's, they'd need
to solve the discrete logarithm problem, which is hard.
The actual key exchange for either party consists of raising the others "public key' to
power of their private key. The resulting number (or as much of as is necessary) is used as the
key for a block cipher or other private key scheme. For an attacker to obtain the same value
they need at least one of the secret numbers, which means solving a discrete log, which is
computationally infeasible given large enough numbers. Note that if Alice and Bob subsequently
communicate, they will have the same key as before, unless they choose new public-keys.
The simplest, and original, implementation of the protocol uses the multiplicative group
of integers modulo p, where p is prime and g is primitive root mod p. Here is an
example of the protocol, with non-secret values and secret values:
77
1. Alice and Bob agree to use a prime number p=23 and base g=5.
2. Alice chooses a secret integer a=6, then sends Bob A = ga mod p
o A = 56 mod 23
o A = 15,625 mod 23
o A=8
6. Alice and Bob now share a secret: s = 2. This is because 6*15 is the same as
15*6. So somebody who had known both these private integers might also
have calculated s as follows:
o s = 56*15 mod
23 o s = 515*6
mod 23 o s = 590
mod 23
o s=
807,793,566,946,316,088,741,610,050,849,573,099,185,363,389,551,639,55
6,884,765,625 mod 23
o s=2
Both Alice and Bob have arrived at the same value, because (ga)b and (gb)a are equal
mod p. Note that only a, b and gab = gba mod p are kept secret. All the other values –
p, g, ga mod p, and gb mod p – are sent in the clear. Once Alice and Bob compute the
shared secret they can use it as an encryption key, known only to them, for sending
messages across the same open communications channel. Of course, much larger
values of a, b, and p would be needed to make this example secure, since it is easy to
78
try all the possible values of gab mod
23. There are only 23 possible integers as the result of mod 23. If p were a prime of at
least 300 digits, and a and b were at least 100 digits long, then even the best
algorithms known today could not find a given only g, p, gb mod p and ga mod p,
even using all of mankind's computing power. The problem is known as the discrete
logarithm problem. Note that g need not be large at all, and in practice is usually
either 2 or 5.
Both Alice and Bob are now in possession of the group element gab, which can serve
as the shared secret key. The values of (gb)a and (ga)b are the same because groups
are power associative.
80
4. The geometric interpretation of the preceding item also applies to two points, P and –
P, with the same x coordinate. The points are joined by a vertical line, which can be
viewed as also intersecting the curve at the infinity point. We therefore have P + (–P)
= O, consistent with item (2).
5. To double a point Q, draw the tangent line and find the other point of intersection S. Then Q
+Q
= 2Q = –S.
With the preceding list of rules, it can be shown that the set E(a, b) is an abelian group.
ECC Diffie-Hellman
ECC Encryption/Decryption
ECC Security
The security of ECC depends on how difficult it is to determine k given kP and P. This is
referred to as the elliptic curve logarithm problem. The fastest known technique for taking the
elliptic curve logarithm is known as the Pollard rho method. Compared to factoring integers or
polynomials, can use much smaller numbers for equivalent levels of security.
relies on elliptic curve logarithm problem
fastest method is “Pollard rho method”
compared to factoring, can use much smaller key sizes than with RSA etc
82
for equivalent key lengths computations are roughly equivalent
hence for similar security ECC offers significant computational advantages
PRIMALITY TESTING:
An integer p> 1 is a prime number if and only if its only divisors are + 1 and + p.
Eg. 2,3,5,7 are prime
4,6,8,9,10 are not prime
list of prime number less than 200 is:
o 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103
107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197
199
EXAMPLE:
83
FERMAT PRIMALITY TEST:
EXAMPLES:
84
EXAMPLE:
Factorin
g: The basic method of dividing an integer n by all primes p≤√𝑛 is too
much slow for most purposes.
It works well when n is the product of two primes that are very close
together. But if the two primes are randomly selected it won’t work
that much efficiently. There are some more modern methodologies
for factoring. They are as follows:
Factoring Algorithm:
85
Choosing of B values:
Note that the first form of the theorem requires that be relatively prime to p, but this form
does not.
EULER’S Theorem Euler’s theorem states that for every and that are relatively prime:
EULER’S Theorem
Euler’s theorem states that for every and that are relatively prime:
Which completes the proof? This is the same line of reasoning applied to the proof
of Fermat’s theorem.
PART-A
1. What is the purpose of the State array?
2. Write down the purpose of the S-Boxes in DES.
3. Define: Diffusion
4. What do you mean by differential cryptanalysis?
5. What is the difference between diffusion and confusion?
6. What is the difference between differential and linear cryptanalysis?
7. What is a meet-in-the-middle attack?
8. What primitive operations are used in Blowfish?
9. Perform encryption and decryption using RSA alg. For the following. P=7; q=11; e=17; M=8.
10. Define: Replay attack
11. List out the parameters of AES
12. Distinguish between differential and linear cryptanalysis
13. Write down the difference between the public key and
private key Cryptosystems
14. What is the difference between Rijndael and AES?
15. User A & B exchange the key using Diffie Hellman alg. Assume á=5 q=11 XA=2 XB=3. Find YA,YB, K.
16. Define short notes on triple DES.
17. What is the need of AES?
18. What is meant by Avalanche effect in DES?
19. State the significance of blinding in RSA.
20. What is an elliptic curve?
21. Define elliptic curve mathematical process.Apr/May 2023
22. Predict differences between Conventional Encryption and Public-Key Encryption.
Apr/May 2023
PART B&C
9. In a public-key system using RSA, you intercept the cipher text C = 10 sent to a user whose
public key is e = 5, n = 35. What is the plaintext M? Apr/May 2023
10. Illustrate the application of cryptography in Embedded Hardware. Apr/May 2023