CNS- Notes Unit-3 PDF
CNS- Notes Unit-3 PDF
Asymmetric Encryption
Mathematics of Asymmetric Key Cryptography, Asymmetric Key Cryptography
Example 1
Find the number of primes less than 1,000,000.
The approximation gives the range 72,383 to 78,543.
The actual number of primes is 78,498.
Checking for Primeness
Given a number n, how can we determine if n is a prime? The answer is that we need to see if the number is
divisible by all primes less than
Example 1:
Is 97 a prime?
The floor of π(97) = 9. The primes less than 9 are 2, 3, 5, and 7. We need to see if 97 is divisible by any of
these numbers. It is not, so 97 is a prime.
Example 2:
Is 301 a prime?
The floor of π(301) = 17. We need to check 2, 3, 5, 7, 11, 13, and 17. The numbers 2, 3, and 5 do not divide
301, but 7 does. Therefore 301 is not a prime.
Example 1:
Find the result of 610 mod 11.
We have 610 mod 11 = 1. This is the first version of Fermat’s little theorem where p = 11.
Example 2
Find the result of 312 mod 11.
Here the exponent (12) and the modulus (11) are not the same. With substitution this can be solved using
Fermat’s little theorem.
Multiplicative Inverses
a−1 mod p = a p − 2 mod p
Example
The answers to multiplicative inverses modulo a prime can be found without using the extended Euclidean
algorithm:
Example:
How to calculate multiplicative inverse of 5 modulo 23 that is 5-1 mod 23?
Solution:
1. 5-1 mod 23 = 523-2 mod 23 (Ref: a-1 mod p= ap-2 mod p)
2. 523-2 mod 23 = 521 mod 23
3. Calculate following to solve 521 mod 23:
51 mod 23 = 5
52 mod 23=25 mod 23=2
54 mod 23= (52)2 mod 23= (2)2 mod 23=4
58 mod 23= (54)2 mod 23 (4)2 mod 23=16
516 mod 23= (58)2 mod 23 (16)2 mod23=256 mod 23=3
Now binary equivalence of 21 is 10101, so multiply 51 , 54 and 516 values, leave 52 and 58 because these are
0’s in binary form.
521 mod 23 = (516 x 54 x 51 ) mod 23=(3x4x5) mod 23=60 mod 23= 14 mod 23.
Finally 5-1 mod 23 = 521 mod 23 = 14 mod 23
Example 2:
Find the result of 624 mod 35.
Solution
We have 624 mod 35 = 6 ϕ (35) mod 35 = 1.
Example :
Find 34 mod 10 ?
Solution
Example 3:
Find the result of 2062 mod 77.
Solution
If we let k = 1 on the second version,
we have f(77)= f(7)x f(11)=6x10=60
2062 mod 77 = (20 mod 77) (2060+1 mod 77) mod 77=
(20 mod 77) (20f(77) + 1 mod 77) mod 77
= (20)(20) mod 77 = 15.
Multiplicative Inverses
Euler’s theorem can be used to find multiplicative inverses modulo a composite.
Example:
The answers to multiplicative inverses modulo a composite can be found without using the extended
Euclidean algorithm if we know the factorization of the composite:
Primitive Root :
If the Group G=<Zn*,x> has any primitive root, the number of primitive roots is
ϕ(ϕ (n))
Example: Find the Number of primitive roots of 25
ϕ (25)=20
Find the primitive root of 761
ϕ (ϕ (761))= ϕ (760)
= ϕ (23x5x19) = ϕ (23)x ϕ (5)x ϕ (19)
=(23 - 22)x 4x18=4x4x18
=288
Solution:
We follow the four steps.
1. M = 3 × 5 × 7 = 105
2. M1 = 105 / 3 = 35, M2 = 105 / 5 = 21, M3 = 105 / 7 = 15
3. The inverses are M −1 −1 −1
1 = 2, M 2 = 1, M 3= 1
4. x = (2 × 35 × 2 + 3 × 21 × 1 + 2 × 15 × 1) mod 105 = 23 mod 105
Example 2:
Find an integer that has a remainder of 3 when divided by 7 and 13, but is divisible by 12.
Solution
This is a CRT problem. We can form three equations and solve them to find the value of x.
Example 3
Assume we need to calculate z = x + y where x = 123 and y = 334, but our system accepts only numbers less
than 100.
Now three equations can be solved using the Chinese remainder theorem to find z. One of the acceptable
answers is z = 457.
QUADRATIC CONGRUENCE
Quadratic Congruence is a congruence of the equation of the form a2x2 + a1x + a0 ≡ 0 (mod n).
We limit our discussion to quadratic equations in which
a2 = 1 and a1 = 0, that is equation of the form.
x2 ≡ a (mod n)
There are two ways:
1. Quadratic Congruence Modulo a Prime
2. Quadratic Congruence Modulo a Composite
Quadratic Congruence Modulo a Prime
In this, we consider the modulus is a prime number. That is the form. x2 ≡ a (mod p)
Where p is a prime and ‘a’ is an integer.
Example 1: Solve the x2 ≡ 3 (mod 11)
Solution: 3 congruent to modulo 11 are 3,14,25 (25 is 5x5 or (-5)x(-5))
The given equation has two solutions:
x2 ≡ 25 (mod 11)
x ≡ 5 (mod 11) and x ≡ -5 (mod 11),
But -5 ≡ 6 (mod 11)
So, the solutions are 5 and 6
Check the result: substitute x=5
52 ≡ 25 =3 (mod 11)
substitute x=6
62 ≡ 36 =3 (mod 11)
Example 2: Solve the y2 ≡ 10 (mod 13)
Solution: The number 10 congruent to 13 are 10,23,36 (36 is 6x6 or (-6)x(-6))
The given equation has two solutions:
x ≡ 6 (mod 13) and x ≡ -6 (mod 13),
But -6 ≡ 7 (mod 13)
So, the solutions are 6 and 7
Check the result: substitute x=6
62 ≡ 36 ≡ 10 (mod 13)
substitute x=7
7 ≡ 49 ≡ 10 (mod 13)
Quadratic Congruence Modulo a Composite
Quadratic Congruence Modulo a Composite can be solved by set of Quadratic Congruence Modulo a Prime.
Decomposition of congruence modulo a composite:
The Trust Problem: Ensuring the integrity of received data and verifying the identity of the source of that
data can be very important. Means in the symmetric key cryptography system, receiver doesn‟t know whether
the message is coming for particular sender.
➢ This public key cryptosystem uses two keys as pair for encryption of plain text and
Decryption of cipher text.
➢ These two keys are names as “Public key” and “Private key”. The private key is kept
secret where as public key is distributed widely.
➢ A message or text data which is encrypted with the public key can be decrypted only
with the corresponding private-key
This two key system very useful in the areas of confidentiality (secure) and authentication
The intended receiver, in possession of the matching private key, is able to invert the
transformation:
Public key cryptography for proving Authentication:
The above diagrams show the use of public-key encryption to provide authentication:
➢ 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.
➢ 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.
It is, however, possible to provide both the authentication function and confidentiality by a double use of
the public-key scheme (above figure):
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.
Public-Key Cryptanalysis
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.
RSA Algorithm
➢ It is the most common public key algorithm.
➢ This RSA name is get from its inventors first letter (Rivest (R), Shamir (S) and Adleman (A))
in the year 1977.
➢ The RSA scheme is a block cipher in which the plaintext & ciphertext are integers between
0 and n-1 for some n.
➢ A typical size for n is 1024 bits or 309 decimal digits. That is, n is less than 21024
Example:
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.
Elliptic Curve Cryptography
➢ Elliptical curve cryptography (ECC) is a public key encryption technique based on elliptic curve
theory that can be used to create faster, smaller, and more efficient cryptographic keys. ECC
generates keys through the properties of the elliptic curve equation instead of the traditional
method of generation as the product of very large prime numbers
➢ An elliptic curve is defined by an equation in two variables with coefficients. For
cryptography, the variables and coefficients are restricted to elements in a finite field, which
results in the definition of a finite abelian group.
EIGamal Algorithm:-
Thus, functions as a one-time key, used to encrypt and decrypt the message.
For example, let us start with the prime field GF(19); that is, q = 19. It has
primitive roots {2, 3, 10, 13, 14, 15 }. We choose α = 10.
Alice generates a key pair as follows:
RABIN CRYPTOSYSTEM
Rabin Cryptosystem is an public-key cryptosystem invented by Michael Rabin, is a variation of the RSA.
RSA is based on the exponentiation congruence; Robin is based on quadratic congruence.
The public key in the Rabin is n, private key is the tuple(p,q). Everyone can encrypt a message using n, only
Bob can decrypt the message using p and q.
Decryption of the message is infeasible It uses asymmetric key encryption for communicating between two
parties and encrypting the message.
The security of Rabin cryptosystem is related to the difficulty of factorization. It has the advantage over the
others that the problem on which it banks has proved to be hard as integer factorization.
It has the disadvantage also, that each output of the Rabin function can be generated by any of four possible
inputs. if each output is a cipher text, extra complexity is required on decryption to identify which of the
four possible inputs was the true plaintext.
The Rabin cryptosystem is not deterministic: Decryption creates four equally probable plain texts
Example:
1. Bob selects p=23 and q=7, note both are congruent to 3 mod 4
2.Bob calculates n=pxq=161
3. Bob announces n publickly; he keeps p and q private
4. Allice want to send plain text P=24. Note that 161and 24 are relatively prime; 24 is in Z161*
She calculates C=242 mod 161 =93 mod 161, and sends the ciphertext 93 to Bob
5. Bob receives 93 and calculates four values:
a. a1=+(93(23+1)/4 mod 23=1 mod 23
b. a2=-(93(23+1)/4 mod 23=22 mod 23
c. b1=+(93(7+1)/4 mod 7=4 mod 7
d. b2=-(93(7+1)/4 mod 7=3 mod 7
6. Bob takes four possible answers, (a1,b1), (a1,b2), (a2,b1),(a2,b2) and uses Chinese Remainder Theorem to
find 4 possible plain texts: 116,24,137 and 45.
Case 1:
By using (a1=1,b1=4) combinations with modulo (p=23,q=7), Let X is plain text:
X = 1 mod 23
X= 4 mod 7
By using Chinese Remainder Theorem:
M=23x7=161, M1=M/23=161/23=7, M2=M/7=161/7=23
M1-1=7-1 mod 23 = 723-2 mod 23 = 721 mod 23=10
M2-1=23-1 mod 7 = 237-2 mod 7 = 235 mod 7=4
X= (a1 x M1xM -1 -1
1 +a2xM2xM 2) mod M
=( 1 x 7 x 10 + 4 x 23 x 4) mod 161 = 438 mod 161=116
Case 2:
By using (a1=1,b2=3) combinations with modulo (p=23,q=7), Let X is plain text:
X = 1 mod 23
X= 3 mod 7
By using Chinese Remainder Theorem:
M=23x7=161, M1=M/23=161/23=7, M2=M/7=161/7=23
M1-1=7-1 mod 23 = 723-2 mod 23 = 721 mod 23=10
M2-1=23-1 mod 7 = 237-2 mod 7 = 235 mod 7=4
X= (a1 x M1xM -1 -1
1 +a2xM2xM 2) mod M
=( 1 x 7 x 10 + 3 x 23 x 4) mod 161 = 346 mod 161=24
Case 3:
By using (a2=22,b1=4) combinations with modulo (p=23,q=7), Let X is plain text:
X = 22 mod 23
X= 4 mod 7
By using Chinese Remainder Theorem:
M=23x7=161, M1=M/23=161/23=7, M2=M/7=161/7=23
M1-1=7-1 mod 23 = 723-2 mod 23 = 721 mod 23=10
M2-1=23-1 mod 7 = 237-2 mod 7 = 235 mod 7=4
X= (a1 x M1xM -1 -1
1 +a2xM2xM 2) mod M
=( 22 x 7 x 10 + 4 x 23 x 4) mod 161 = (1540+368) mod 161=137
Case 4:
By using (a2=22,b2=3) combinations with modulo (p=23,q=7), Let X is plain text:
X = 22 mod 23
X= 4 mod 7
By using Chinese Remainder Theorem:
M=23x7=161, M1=M/23=161/23=7, M2=M/7=161/7=23
M1 =7 mod 23 = 7 mod 23 = 721 mod 23=10
-1 -1 23-2