summaryrefslogtreecommitdiffhomepage
path: root/09-insufficient-key-size.py
diff options
context:
space:
mode:
Diffstat (limited to '09-insufficient-key-size.py')
-rw-r--r--09-insufficient-key-size.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/09-insufficient-key-size.py b/09-insufficient-key-size.py
new file mode 100644
index 0000000..b313986
--- /dev/null
+++ b/09-insufficient-key-size.py
@@ -0,0 +1,17 @@
+from utils import mod_inv
+
+# Read modulus and exponent from public-key with openssl:
+# openssl rsa -RSAPublicKey_in -in 09-unsufficient-key-size.key -text
+e = 65537
+modulus = int("70:18:f7:17:fc:66:65:15:0c:14:88:54:f6:4c:49".replace(":", ""), 16)
+
+# factorize modulus with WolframAlpha:
+# https://www.wolframalpha.com/input/?i=factor+582043602765817436229812959722228809
+p, q = 662700133751480051, 878291059745115859
+assert p * q == modulus
+
+phi = (p - 1) * (q - 1)
+d = mod_inv(e, phi)
+
+solution = hex(d)[2:]
+print(solution)