This repository has been archived by the owner on Jan 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* rsa 1 * yaml fixes * final yaml tweak --------- Co-authored-by: mud-ali <[email protected]>
- Loading branch information
1 parent
0ab1a14
commit 4a2ea46
Showing
5 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Intro To RSA I | ||
categories: | ||
- crypto | ||
value: 125 | ||
flag: camp{Y0u_Got_THE_fLAg_FRom_jUSt_numbeRS} | ||
description: |- | ||
I found this document that has some leftover numbers, can you do anything with them? | ||
(Note) For RSA you need the message represented as a number, which varies depending on usage. | ||
For this case, a hex string was created by linking the ascii values of the letters in hex | ||
together, and then converting the large hex number into base 10. | ||
hints: | ||
- What is RSA? | ||
- Why is it important to keep `p` and `q` secret? | ||
files: | ||
- src: ./info.txt | ||
dest: rsa1.txt | ||
authors: | ||
- Jack Crowley | ||
visible: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
p=9431879136934316587737007754051353666702170335843 | ||
q=486822630482432419113792900499540513680992433274933 | ||
n=p*q | ||
z=(p-1)*(q-1) | ||
e=65537 | ||
d=pow(e, -1, z) | ||
m = int("63616d707b5930755f476f745f5448455f664c41675f46526f6d5f6a5553745f6e756d626552537d", 16) | ||
print("Original message (m):", m) | ||
|
||
c = pow(m, e, n) | ||
print("Encrypted message (c):", c) | ||
|
||
m2 = pow(c, d, n) | ||
print("Decrypted message (m2):", m2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
flag = "camp{Y0u_Got_THE_fLAg_FRom_jUSt_numbeRS}" | ||
|
||
out = "".join([f"{ord(i):2x}" for i in flag]) | ||
|
||
print(out) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
p=9431879136934316587737007754051353666702170335843 | ||
q=486822630482432419113792900499540513680992433274933 | ||
e=65537 | ||
C=1794044813198073049655008313521471775955137563708224044636963525704637113279379918424880312944761851 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Intro To RSA 1 | ||
|
||
RSA is a popular type of asymmetric encryption algorithm used in cryptology. Public keys are used for encryption, and the private keys are used for decryption. | ||
|
||
In this case, we have the 2 private keys, `p` and `q`, as well as one of the public keys `e`, and the ciphertext `c`. | ||
|
||
To use decryption, you need private key exponent `d`, and to calculate this, you take the modular multiplicative inverse of `e`, and mod it by `(p-1)(q-1)`. | ||
|
||
Once you have `d`, the decryption is simple. All you need to do is take `c` or the cipher text, and raise it to the `d` power, modded by `p*q`. | ||
|
||
Once you do this, you will get the number as a integer in base 10. However, as noted in the challenge description, the message is turned into hex and then into an int, so to get the plaintext, you have to convert it into hex, and the convert it into text from there. |