How can you ensure that the person receiving your message knows that you wrote it?
You've been asked out on a date, and you want to send a message telling them that you'd love to go, however a jealous lover isn't so happy about this.
When you send your message saying yes, your jealous lover intercepts the message and corrupts it so it now says no!
We can protect against these attacks by cryptographically signing the message.
Imagine you write a message $m$. You encrypt this message with your
friend's public key: $c = m^{e_{0}} \mod N_{0}$.
To sign this message, you calculate the hash of the message: $H(m)$ and "encrypt" this with
your private key: $S = H(m)^{d_{1}} \mod N_{1}$.
In real cryptosystems, it's best practice to use separate keys for encrypting and signing messages.Your friend can decrypt the message using
their private key: $m = c^{d_{0}} \mod N_{0}$. Using your public key they calculate $s = S^{e_{1}} \mod N_{1}$.
Now by computing $H(m)$ and comparing it to $s$:
assert H(m) == s
, they can ensure that the message you sent them, is the message that they received! As long as your private key is safe, no one else could have signed this message!
Sign the flag
crypto{Immut4ble_m3ssag1ng}
using your private key and the
SHA256
hash function.
The output of the hash function needs to be converted into a number that can be used with RSA math. Remember the helpful bytes_to_long()
function that can be imported from Crypto.Util.number
.Challenge files: -
private.key
You must be logged in to submit your flag.
-
So far we've been using the product of small primes for the modulus, but small primes aren't much good for RSA as they can be factorised using
modern methods.
What is a "small prime"? There was an
RSA Factoring Challenge with cash prizes given to teams who could factorise RSA moduli. This gave insight to the public into how long various key sizes would remain safe. Computers get faster, algorithms get better, so in cryptography it's always prudent to err on the side of caution.
These days, using primes that are at least 1024 bits long is recommended—multiplying two such 1024 primes gives you a modulus that is 2048 bits large. RSA with a 2048-bit modulus is called RSA-2048.
Some say that to really remain future-proof you should use RSA-4096 or even RSA-8192. However, there is a tradeoff here; it takes longer to generate large prime numbers, plus modular exponentiations are predictably slower with a large modulus.
Factorise the 150-bit number
510143758735509025530880200653196460532653147
into its two constituent primes. Give the smaller one as your answer.
Resources: -
How big an RSA key is considered secure today? -
primefac-fork
You must be logged in to submit your flag.
-
Here is my super-strong RSA implementation, because it's 1600 bits strong it should be unbreakable... at least I think so!
Challenge files: -
inferius.py -
output.txt
You must be logged in to submit your flag.
-
You must be logged in to submit your flag.
-
It was taking forever to get a 2048 bit prime, so I just generated one and used it twice.
If you're stuck, look again at the formula for Euler's totient.Challenge files: -
output.txt
You must be logged in to submit your flag.
-
Using one prime factor was definitely a bad idea so I'll try using over 30 instead.
If it's taking forever to factorise, read up on factorisation algorithms and make sure you're using one that's optimised for this scenario.Challenge files: -
output.txtResources: -
The Elliptic Curve Factorization Method
You must be logged in to submit your flag.
-
You must be logged in to submit your flag.
-
You must be logged in to submit your flag.
-
We have a supercomputer at work, so I've made sure my encryption is secure by picking massive numbers!
Challenge files: -
source.py -
output.txt
You must be logged in to submit your flag.
-
You must be logged in to submit your flag.
-
You must be logged in to submit your flag.
-
You must be logged in to submit your flag.
-
Finding large primes is slow, so I've devised an optimisation.
Challenge files: -
descent.py -
output.txt
You must be logged in to submit your flag.
-
I've found a super fast way to generate primes from my secret list.
Challenge files: -
marin.py -
output.txt
You must be logged in to submit your flag.
-
I need to produce millions of RSA keys quickly and the standard way just doesn't cut it. Here's yet another fast way to generate primes which has actually resisted years of review.
Challenge files: -
fast_primes.py -
key.pem -
ciphertext.txt
You must be logged in to submit your flag.
-
Here's a bunch of RSA public keys I gathered from people on the net together with messages that they sent.
As excerpt.py shows, everyone was using PKCS#1 OAEP to encrypt their own messages. It shouldn't be possible to decrypt them, but perhaps there are issues with some of the keys?
Challenge files: -
excerpt.py -
keys_and_messages.zipResources: -
The recent difficulties with RSA
You must be logged in to submit your flag.
-
It seems like my method to generate fast primes was not completely secure. I came up with a new approach to improve security, including a factorization backdoor in case I ever lose my private key. You'll definitely need some complex techniques to break this!
You may need to tweak the recursion limit (sys.setrecursionlimit(n)
in Python) in your programming language to get your solution working.Challenge files: -
complex_primes.py -
output.txtChallenge contributed by
joachim
You must be logged in to submit your flag.
-
Been cooking up my own padding scheme, now my encrypted flag is different everytime!
Connect at
socket.cryptohack.org 13386
Challenge files: -
13386.py
You must be logged in to submit your flag.
-
You must be logged in to submit your flag.
-
My boss has so many emails he's set up a server to just sign everything automatically. He also stores encrypted messages to himself for easy access. I wonder what he's been saying.
Connect at
socket.cryptohack.org 13374
Challenge files: -
13374.py
You must be logged in to submit your flag.
-
If you can prove you own CryptoHack.org, then you get access to one of our secrets.
Connect at
socket.cryptohack.org 13391
Challenge files: -
13391.py
You must be logged in to submit your flag.
-
Here's my token signing and verification server. I'm not sure it's doing signing properly, but I've implemented some safeguards to ensure it won't hand out admin tokens to just anyone.
Connect at
socket.cryptohack.org 13376
Challenge files: -
13376.py
You must be logged in to submit your flag.
-
If you want my flag, you better vote for Pedro! Can you sign your vote to the server as Alice?
Connect at
socket.cryptohack.org 13375
Challenge files: -
13375.py -
alice.key
You must be logged in to submit your flag.
-
Let's Decrypt was too easy, let's do it again!
Connect at
socket.cryptohack.org 13394
Challenge files: -
13394.pyChallenge contributed by
Robin_Jadoul and
Thunderlord
You must be logged in to submit your flag.
Level Up
You are now level Current level