Professional Documents
Culture Documents
q
x y ≡ ( x m ) x y mod φ(N ) (mod N )
y q ymod φ ( N )
x ≡1 x ( mod N ) IF gcd ( x , N )=1
Q1(file đề)
Cách làm
Euler’s Theorem: If n ≥ 1 and GCD(a,n) = 1 then a^totient(n) ≡ 1(mod n)
totient(527) =480
526^959 mod 527 = ((526^480)^2 * 526^-1) mod 527
= (( (526^480)^2 mod 527 )*( 526^-1 mod 527)) mod 527
= (1*526) mod 527 = 526
- Trình bày như trên là có điểm còn cách tính 526^-1 mod 527 ( Phần
kiến thức tìm nghịch đảo modulo ) thì tham khảo cách tính tại video này
trên youtube:
https://www.youtube.com/watch?v=oFtVYP9sDxE
* Caeser Cipher
- Formula Decrypt : p = ( x-k ) mod 26
- Formula Encrypt : c = ( x+k ) mod 26
You agreed to use a Caesar cipher with a key of k=5 with a friend. While sitting in a
group, the friend hands you over a message that says "QNGWFWD". Decrypt the
message.
- The English alphabet:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
- Caesar cipher decrypt with a key k = 5:
Formula: p = ( x-k ) mod 26
* Permutation Cipher
* Vigenere
Decrypt the message (DTXSAOMP) using the Vigenere cipher with the
key LEMON.
Key = LEMON ===> m = 5
Encryption: Ci = (Pi + Ki mod m) mod 26
* Lưu ý: Nếu có thêm nguyên tố sau khi phân tích thì cứ tiếp tục nhân
thêm với (1 trừ 1/số nguyên tố đó) .
---> totient(8) = 8*(1-1/2) = 4
- Đề bài:
Using the same notations as in the lecture, e.g., p and q are the two
primes and e and d are the public key and the private key, respectively,
p=7, q=11, e=17. Using the phi(n) that you found in the previous question
and the Extended Euclidean algorithm yields d=53. What is the ciphertext
C when encrypting M=8?
- Cách làm:
p=7 , q=11 , e=17 , d=53 , M=8
---> n = 7*11 = 77
---> totient(77) = (p-1)*(q-1) = 6*10 = 60
- Formula of Extended Euclidean algorithm:
Encryption: C = M^e mod n
---> C = 8^17 mod 77
= (8^8 * 8^8 * 8) mod 77
= ((8^8 mod 77) * (8^8 mod 77) * (8 mod 77)) mod 77
= (71 * 71 * 8) mod 77
= 57
Using the same notations as in the lecture, e.g., p and q are the two
primes and e and d are the public key and the private key, respectively,
p=3, q=11, and e=7.The attacker performs a chosen-ciphertext attack
(CCA). It has a known ciphertext 14 and wants to retrieve the
corresponding plaintext. It computes c' = c * r^e mod n and chooses
the ciphertext 14 * 2187 mod 33 = 27 and retrieves the corresponding
plaintext, 15. What is the plaintext corresponding to the ciphertext 14?
- Cách làm
p=3 , q=11 , e=7 , C=14 , m’ = 15
n = p*q = 3*11 = 33
c’ = c*r^e mod n choose the ciphertext 14*2187 mod 33 = 27
---> r =√7 2187 = 3
m’ = m*r mod n ---> 15 = m*3 mod 33 --->m = 5
Alice and Bob uses Diffie-Hellman Key Exchange to share a key with a
common prime p=11 and a primitive root a=2. If Alice has a public key
Y_A=9, what is her private key X_A?
(This question builds on the previous question.) Alice and Bob uses
Diffie-Hellman Key Exchange to share a key with a common prime p=11
and a primitive root a=2. If Bob has a public key Y_B=3, what is the
secret key K shared with Alice?
- Câu này ban đầu sẽ giải như câu trên để tìm ra giá trị của X_A rồi sau
đó sẽ làm tiếp như bên dưới.
Y_B=3 , a=2 , p=11
- Use formula Diffie-Hellman Key Exchange:
K = Y_B^X_A mod p
K = 3^6 mod 11
---> K = 3
3 (3^6 mod 11 = 3 computed by Alice)
+ Dạng 2:
(This problem has the same setup as the previous question but asks a
different question.) There are 5 computers (hardware. Each computer
hosts 4 virtual machines (VM) with different addresses, and each VM
hosts 10 applications. How many key exchange sessions (in one session,
two logical parties share a key) are needed if the decentralized key
distribution is used so that all applications share a pair-wise keys?
- Cách làm:
+ Dạng 1:
- Suppose n is called as the number of all VM’s.
- Because there are 5 computers (hardware), each computer hosts 4
virtual machines (VM) with different addresses:
---> n = 5*4 = 20 (VM’s)
---> We need (n*(n-1))/2 keys for n VM’s = (20*19)/2 = 190 key
exchange sessions
+ Dạng 2:
- Suppose n is called as the number of all VM’s.
- Because there are 5 computers (hardware), each computer hosts 4
virtual machines (VM) with different addresses and each VM hosts 10
applications:
---> n = 5*4 * 10 = 200 (VM’s)
---> We need (n*(n-1))/2 keys for n VM’s = (200*199)/2 = 19900 key
exchange sessions