-
Alice and Bob agree on
$g = 7$ and$p = 97$ . -
Alice sent Bob the number
$53$ . -
Bob sent Alice the number
$82$ .
Figure out the shared secret agreed upon by Alice and Bob. This will be an integer. Show your work and show where in the process you would have failed if the integers were much larger.
Alice sent Bob
If we run the following script to calculate
for i in range(97):
print(7**i % 97)
we see that the
From there we can calulate the shared
- Bob's public key:
$e = 13$ and$n = 162991$ - Alice's encrypted message:
$[17645, 100861, ... , 128221]$
Figure out the encrypted message sent from Alice to Bob. how the message from Alice to Bob encoded? Why is this not secure by itself? Where would you have failed if the integers were much larger?
Plugging our
With that we can brute force the integer for
count = 0
e = 388 * 418 # Our p and q
while(1):
print("checking...", count)
if (13 * count) % e == 1:
print("d is", count)
break
count += 1
which yield our
From there we can use
decrypted = []
for integer in encrypted:
decrypted.append(hex(integer**124757 % 162991))
this yields a sequence of four digit hex numbers, meaning each 'token' corresponds to two ASCII values concatenated together, which is not a secure encoding without Bob's encryption layered on top of it.
With that I concatenated all of the hex numbers together, and I converted that string into ASCII plaintext using the following script
bytes.fromhex("4465617220426f622c20636865636b2074686973206f75742e2068747470733a2f2f7777772e7375727665696c6c616e636577617463682e696f2f20536565207
9612c20416c6963652e").decode('ascii')
which when printed reveals the following message: 'Dear Bob, check this out. https://www.surveillancewatch.io/ See ya, Alice.' The website itself is actually quite cool.