Asymmetric Ciphers
Asymmetric Ciphers
Number Theory
A number of concepts from number theory are essential in the design of public-key cryptographic
algorithms.
Prime Numbers:
➔ An integer p > 1 is a prime number if and only if its only divisors are ± 1 and ±p.
Cryptography
➔ Prime numbers play a critical role in number theory and in the techniques discussed in
following chapters
Where,
▪ If P is the set of all prime numbers, then any positive integer a can be written
uniquely in the following form:
• The right-hand side is the product over all possible prime numbers p; for any
• The value of any given positive integer can be specified by simply listing all the
nonzero exponents in the foregoing formulation.
Cryptography
Given ,
Define 𝒌 = 𝒂𝒃. We know that the integer 𝒌 can be expressed as the product of
powers of primes:
It follows that
𝑘𝑝 = 𝑎𝑝 + 𝑏𝑝 for all 𝑝 ∈ 𝑃.
• Any integer of the form pn can be divided only by an integer that is of a lesser or
equal power of the same prime number, pj with j≤ n. Thus, we can say the
following.
Cryptography
Note: Determining the prime factors of a large number is no easy task, so the preceding
relationship does not directly lead to a practical method of calculating the greatest common
divisor
Fermat’s Theorem
• Also known as Fermat’s little theorem
• Given in 1640 by French mathematician Pierre de Fermat
Cryptography
Example:
Let a = 2 and P = 17
2 17 - 1 ≡ 1 (mod 17)
Try yourself:
Verify:
𝜙(4) = 2 𝜙(12) = 4 𝜙(15) = 8 𝜙(32) = 16
• The value 𝜙(1) is without meaning but is defined to have the value 1.
• Now suppose that we have two prime numbers p and q with p ≠q. Then we can show that,
for n = pq,
Cryptography
Euler’s Theorem
• Also known as the Fermat–Euler theorem or Euler's totient theorem ( Given in 1763 by
Euler)
• Euler’s theorem states that for every a and n that are relatively prime:
• As is the case for Fermat’s theorem, an alternative form of the theorem is also useful:
Miller-Rabin Algorithm
Also referred to in the literature as the Rabin-Miller algorithm, or the Rabin-Miller test, or
the Miller- Rabin test.
Due to Miller and Rabin
Typically used to test a large number for primality.
To see this, note that n - 1 is an even integer. Then, divide (n - 1) by 2 until the result is an odd
number q, for a total of k divisions. If n is expressed as a binary number, then the result is achieved
by shifting the number to the right until the rightmost digit is a 1, for a total of k shifts
If p is prime and a is a positive integer less than p, then a2 mod p = 1 if and only if either
Let p be a prime number greater than 2. We can then write p - 1 = 2kq with k > 0, q odd.
aq ≡ 1(mod p).
is congruent to -1 modulo p.
That is, there is some number j in the range (1≤ j≤k) such
that
mod p = -1 mod p = p - 1
or equivalently,
Cryptography
Algorithm
Note:
• It can be shown that given an odd number n that is not prime and a randomly chosen integer,
a with 1 < a < n - 1, the probability that TEST will return inconclusive (i.e., fail to detect
that n is not prime) is less than 1/4.
• Thus, if t different values of a are chosen, the probability that all of them will pass TEST
(return inconclusive) for n is less than (1/4) t.
Cryptography
• For example, for t = 10, the probability that a nonprime number will pass all ten tests is
less than 10-6.
• Thus, for a sufficiently large value of t, we can be confident that n is prime if Miller’s test
always returns inconclusive.
• This gives us a basis for determining whether an odd integer n is prime with a reasonable
degree of confidence.
• The procedure is as follows: Repeatedly invoke TEST (n) using randomly chosen values
for a. If, at any point, TEST returns composite, then n is determined to be nonprime. If
TEST continues to return inconclusive for t tests, then for a sufficiently large value of t,
assume that n is prime.
Cryptography
key, PRb.
• PR bis known only to B, whereas PUb is publicly available and
therefore accessible by A.
• With the message X and the encryption key PU b as input, A forms
the ciphertext
Y = [Y1, Y2, … , YN]:
Y = E(PUb, X)
X = D(PRb,Y)
Cryptography
• 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.
• It is assumed that the adversary does have knowledge of the encryption (E) and
decryption (D) algorithms. If the adversary is interested only in this particular
message, then the focus of effort is to recover X by generating a plaintext estimate
𝑿̂ . Often, however, the adversary is interested in being able to read future
messages as well, in which case an attempt is made to recover PRb by generating
an estimate
𝑷̂𝑹𝒃
Main Idea: Encryption by Sender’s private key and Decryption by Sender’s public key.
• In this case, A prepares a message to B and encrypts it using A’s private key before
transmitting it.
• B can decrypt the message using A’s public key.
• Because the message was encrypted using A’s private key, only A could have prepared
the message. Therefore, the entire encrypted message serves as a digital signature.
• In addition, it is impossible to alter the message without access to A’s private key, so the
message is authenticated both in terms of source and in terms of data integrity.
Main Idea: First encrypt using Sender’s private key and again encrypt the result by
Receiver’s public key similarly first decrypt by using Receiver’s private key and again
decrypt the result by Sender’s public key.
• In this case, we begin as before by encrypting a message, using the sender’s private
key. This provides the digital signature.
• Next, we encrypt again, using the receiver’s public key. The final ciphertext can be
decrypted only by the intended receiver, who alone has the matching private key.
Thus, confidentiality is provided.
• The disadvantage of this approach is that the public-key algorithm, which is complex,
must be exercised four times rather than two in each communication.
Cryptography
1. It is computationally easy for a party B to generate a pair (public key PUb, private key
PRb).
2. It is computationally easy for a sender A, knowing the public key and the message to be
encrypted, M, to generate the corresponding ciphertext:
C = E(PUb, M)
3. It is computationally easy for the receiver B to decrypt the resulting ciphertext using the
private key to recover the original message:
We can add a sixth requirement that, although useful, is not necessary for all public-key
applications:
6. The two keys can be applied in either order:
M = D[PUb, E(PRb, M)] = D[PRb, E(PUb, M)]
Algorithm
Alice generates a public/private key pair; Bob encrypts using Alice’s public key; and Alice
decrypts using her private key.
In this simple example, the plaintext is an alphanumeric string. Each plaintext symbol is
assigned a unique code of two decimal digits (e.g., a = 00, A = 26). A plaintext block
consists of four decimal digits, or two alphanumeric characters.
The example shows the use of these keys for a plaintext input of M = 88.
Following figures illustrates the sequence of events for the encryption of multiple blocks,
figure (b) gives a specific example. The circled numbers indicate the order in which
operations are performed.
Cryptography
The algorithm
Following figure summarizes the Diffie-Hellman key exchange algorithm. For this scheme,
there are two publicly known numbers: a prime number q and an integer a that is a primitive
root of q. Suppose the users A and B wish to create a shared key.
𝑲 = (𝒀𝑩)𝑿𝑨𝒎𝒐𝒅 𝒒
𝑲 = (𝒀𝑨)𝑿𝑩𝒎𝒐𝒅 𝒒
Cryptography
▪ The result is that the two sides have exchanged a secret value. Typically, this secret value is
used as shared symmetric secret key.
▪ Now consider an adversary who can observe the key exchange and wishes to determine the
secret key K.
⎯Because XA and XB are private, an adversary only has the following ingredients to
work with:
q, 𝑎, Y A, and YB.
⎯ Thus, the adversary is forced to take a discrete logarithm to determine thekey. For
example, to determine the private key of user B, an adversary must compute
⎯ The adversary can then calculate the key K in the same manner as user B calculates
it. That is, the adversary can calculate K as
NOTE: The security of the Diffie-Hellman key exchange lies in the fact that, while it is
relatively easy to calculate exponentials modulo a prime, it is very difficult to calculate
discrete logarithms. For large primes, the latter task is considered infeasible.
Cryptography
In this simple example, it would be possible by brute force to determine the secret key 160. In
particular, an attacker E can determine the common key by discovering a solution to the equation
3a mod 353 = 40 or the equation 3b mod 353 = 248. The brute-force approach is to calculate
powers of 3 modulo 353, stopping when the result equals either 40 or 248. The desired answer is
reached with the exponent value of 97, which provides 397 mod 353 = 40. With larger numbers,
the problem becomes impractical.
Man-in-the-Middle Attack
The Diffie-Helman Key Exchange protocol depicted in above figure is insecure against a
Man-in-the-middle attack.
Suppose Alice and Bob wish to exchange keys, and Darth is the adversary. The attack proceeds
as follows
1. Darth prepares for the attack by generating two random private keys XD1 and
XD2 and then computing the corresponding public keys YD1 and YD2.
⎯ 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.
❖ The key exchange protocol is vulnerable to such an attack because it does not
authenticate the participants. This vulnerability can be overcome with the use of digital
signatures and
public-key certificates.