You are on page 1of 8

In a RSA cryptosystem a particular A uses two prime numbers p = 13 and q =17 to

generate her public and private keys. If the public key of Ais 35. Then the private key of
A is ____________.

Note: This questions appeared as Numerical Answer Type.


(A) 11
(B) 13
(C) 16
(D) 17

Answer: (A)

Explanation: In an RSA cryptosystem, for public key:


GCD( ϕ(n) , e) = 1

And, for private key:

(e * d) mod ϕ(n) = 1

Where,

ϕ(n) = (p -1)*(q – 1) = (13 – 1)(17 – 1) =12*16 = 192


Such that 1 < e, d < ϕ(n)

Therefore, the private key is:


(35 * d) mod ϕ(n) = 1
d = 11

In a RSA cryptosystem a particular A uses two prime numbers p = 11 and q =7 to


generate her public and private keys. If the public key of A is 37. Then the private key
of A is also find M if C is 71

RSA Example
•p = 11, q = 7, n = 77, Φ(n) = 60

•e = 37, d = 13 (ed = 481; ed mod 60 = 1)

•Let M = 15. Then C ≡ (M power e) mod n


C ≡ (15 power 37) mod 77 = 71
•M ≡ (C power d ) mod n

M ≡ 7113(mod 77) = 15
A and B decide to use Diffie Hellman algorithm to share a key. They chose p=23 and g-5
as the public parameters. Their secret keys are 6 and 15 respectively. Compute the
secret key that they share

Ans:

g = public (prime) base, known to Alice, Bob, and Eve. g = 5

p = public (prime) modulus, known to Alice, Bob, and Eve. p = 23

a = Alice's private key, known only to Alice. a = 6

b = Bob's private key known only to Bob. b = 15

A = Alice's public key, known to Alice, Bob, and Eve. A = ga mod p = 8

B = Bob's public key, known to Alice, Bob, and Eve. B = gb mod p = 19

Alice computes s = Ba mod p

s = 196 mod 23 = 2

Bob computes s = Ab mod p

s = 815 mod 23 = 2

Alice and Bob now share a secret (the number 2).

1. In RSA system public key of a given user e=7 & n=187. [10]
 What is the private key of this user?
 If the intercepted CT=11 and sent to a user whose public key e=7 &
n=187. What is the PT?
 Elaborate various kinds of attacks on RSA algorithm?

•p = 17, q = 11, n = 187, Φ(n) = 160

•Let us choose e=7, since gcd (7,160)=1

•Let us compute d: de=1 mod 160 , d=23 (in fact, 23x7=161 = 1 mod 160

•Public key = {7,187}

•Secret key = 23

Given message (plaintext) M= 88 (note that 88<187)

•Encryption: C = (88 power 7) mod 187 = 11


Given message (plaintext) CT= 11 (note that 11<187)

•Decryption: M = (11 power 33 ) mod 187 = 88

Question 9.3:

Full name: ying chen

ASCII code in decimal format:

121+105+110+103+99+104+101+110 = 853 mod 23 +1 =3

In a public-key system using RSA, you intercept the ciphertext C =10 sent to a user whose
public key is e=5, n=35. What is the plaintext M?

Solution:

We know that the ciphertext C = 10, and the public key PU = {e, n} = {5, 35}.

Based on Euler’s Totient function, (n) is defined as the number of positive integers less
than n and relatively prime to n [textbook: “Cryptography and Network Security”, page 240].
We could find that (n) = 24.

Now, we guess two prime numbers p and q. Let p be 5 and q be 7. All the following
conditions will be satisfied based on the guess:

(1) n = p*q = 5*7=35


(2) (n) = (p-1)(q-1)=(5-1)(7-1)=4*6=24
(3) gcd((n), e) = gcd(24, 5) =1, 1< e < (n)

We calculate d in the next step. Based on RSA key generation algorithm,

d ≡ e-1 mod (n) which is equivalent to

ed ≡ 1 mod (n)
or ed mod (n) =1. (chapter 9.1 page 269)

We have e = 5, (n) = 24. So, 5d mod 24 =1, and d = 5.

Now, we find the private key PR = {d, n} = {5, 35}.

Based on RSA decryption algorithm,

M = Cd mod n = 105 mod 35 = 5

We also can verify the correctness by the RSA encryption algorithm as the following:

C = Me mod n = 55 mod 35 = 10

Therefore, we conclude that the plaintext M is 5.

2 x 2 Example

We shall encrypt the plaintext message "short example" using the


keyword hill and a 2 x 2 matrix. The first step is to turn the
keyword into a matrix. If the keyword was longer than the 4
letters needed, we would only take the first 4 letters, and if it was The keyword written as
shorter, we would fill it up with the alphabet in order (much like a a matrix.
Mixed Alphabet).

With the keyword in a matrix, we need to convert this into a key


matrix. We do this by converting each letter into a number by its
position in the alphabet (starting at 0). So, A = 0, B = 1, C= 2, D =
The key matrix (each
3, etc. letter of the keyword is
converted to a number).
We now split the plaintext into digraphs, and write these as column vectors. That is, in the
first column vector we write the first plaintext letter at the top, and the second letter at the
bottom. Then we move to the next column vector, where the third plaintext letter goes at the
top, and the fourth at the bottom. This continues for the whole plaintext.

The plaintext "short example" split into column vectors.


Now we must convert the plaintext column vectors in the same way that we converted the
keyword into the key matrix. Each letter is replaced by its appropriate number.

The plaintext converted into numeric column vectors.


Now we must perform some matrix multiplication. We multiply the key matrix by each
column vector in turn. We shall go through the first of these in detail, then the rest shall be
presented in less detail. We write the key matrix first, followed by the column vector.

To perform matrix multiplication we "combine" the top row of the key matrix with the
column vector to get the top element of the resulting column vector. We then "combine" the
bottom row of the key matrix with the column vector to get the bottom element of the
resulting column vector. The way we "combine" the four numbers to get a single number is
that we multiply the first element of the key matrix row by the top element of the column
vector, and multiply the second element of the key matrix row by the bottom element of the
column vector. We then add together these two answers.

That is, we follow the rules given by the


algebraic method shown to the left.
The algebraic rules of matrix multiplication.

In our case we perform the two calculations


on the right. We then right these two
answers out in a column vector as shown
below. The calculations performed when doing a
matrix multiplication.

The shorthand for the matrix multiplication.

Next we have to take each of these numbers, in our resultant column vector, modulo 26
(remember that means divide by 26 and take the remainder).

Reducing the resultant column vector modulo 26.


Finally we have to convert these numbers back to letters, so 0 becomes "A" and 15 becomes
"P", and our first two letters of the ciphertext are "AP".

The whole calculation: converting to numbers; the matrix multiplication; reducing modulo 26;
converting back to letters.

Plain text = “short example”

Keyword = “hill” and a 2×2

matrix.

Steps:

To turn the keyword into a matrix, if the keyword was longer than the 4 letters needed, we
would only take the first 4 letters and if it was shorter, we would fill it up with the alphabet in
order.

 The keyword written as a matrix as

=[HLIL]

  With the keyword in a matrix, we need to convert this into a key matrix. We do this by
converting each letter into a number by its position in the alphabet (starting at 0), So, A = 0,
B = 1, C = 2, D = 3, etc.

=[711811]

 The key matrix (each letter of the keyword is converted to number)

 Now, we split the plain text into digraphs and write these as column vectors, that is the first
column vector we write the first plain text letter at the top and the second letter at the bottom.
Then we move to the next column vector, where the third plain text letter goes at the top and
the fourth at the bottom. This continues for the whole plain-text.
[sh][or][te][xa][mp][le]

 The plain text “short example” split into the column vectors.

 Now, we convert the plain text column vectors in the same way that we converted the
keyword into the key matrix. Each letter is replaced by its appropriate number.

[187][1417][194][230][1215][1104]

 The plain text converted into number column vectors.

 Next step is to perform matrix multiplication. We multiply the key matrix by each column
vector in turn. We write the key matrix first, followed by the column vector.

[711811][187] mod 26=[7×18+8×711×18+11×7] mod 26=[182275]mod 26=[015]


mod 26

Finally, we have to convert these numbers back to letters, so ‘o’ becomes ‘A’ and ‘15’
becomes ‘p’ and our first two letters of the ciphertext are AP

Thus,

[HLIL][SH]=[711811][187]=[182275]=[015] mod 26 =[AP]

Follow the same procedure for the next column vectors of plain text.

The final ciphertext is “A P A D J T F T W L F J”

Decryption:

P = [C] [K−1] mod 26

k−1 = 1|d| adj [k]

Key = k = [HLIL]

= [711811]=11×7−88

= - 11 mod 26

D = 15

We want 1D

i.e. d×d−1=1 mod 26


15∗xd−1=1 mod 26=7=adj[acbd]=[d−c−ba]=[11−11−87]=[1115187]mod 26= 7×[1
115187]=[7716512649]mod 26

⇒ k−1=[2512223]

⇒ P=[2512223][AP]=[2512223][015]= [25×0+22×151×0+23×15] [330345]= [187


] mod 26=[SH]

Follow the same procedure for the next column vectors of ciphertext.

So the final plaintext is short example

https://www.ques10.com/p/48148/to-encrypt-a-message-using-the-hill-cipher-1/

p=7 Q=19 RSA

https://www.practicalnetworking.net/series/cryptography/rsa-example/

P=23 Q=19 e=3 d=7 RSA

https://www.cemc.uwaterloo.ca/resources/real-world/RSA.pdf

You might also like