Doing is Learning, and Learning is Doing: Some Cybersecurity Brain Food?

In this modern day, doing is learning and learning is doing. This is especially the case for Cybersecurity. The days of studying books of…

Doing is Learning, and Learning is Doing: Some Cybersecurity Brain Food?

In this modern day, doing is learning and learning is doing. This is especially the case for Cybersecurity. The days of studying books of theory are quickly passing. We now often to learn new things is just to do them, and in the process of doing them, you learn. But, once you have learnt a bit, you go back and read the books … it’s re-enforcement learning. Problem solving will be one of the key attributes of the jobs of the future, and it is good to exercise your brain in learning new things, even though you might not know some of the core fundamentals.

I appreciate this can be seen as putting the cart before the horse, but the feedback you receive by following steps and getting a solution is worth a great deal in the learning process, and can — hopefully — trigger an interest that just book learning might not be able to achieve. For me CTFs (Capture The Flags) are great places to learn about new things, and should be integrated into the computer science curriculum as formal teaching methods.

Computer Science … is a doing thing, and it is most fun when you strive to get a solution, and it magically appears. Unfortunately our school syllabus often still puts the horse in front of the cart, and which switches many kids off. Why learn how to use PowerPoint, when you can actually send secret messages by creating ciphers for them? Our dull curriculum is often still focused on boring old book work, that ages as quickly as it can be taught.

If you want to do some puzzles, there are over 100 here, but I’ll define a more challenging one for professionals below. I promise it is actually a simple method, that can be implemented in a few lines of Python code.

A crypto puzzle

So let me set you three puzzles, which get more difficult to compute (I will put the answers at the bottom, but don’t peak until you have solved them), and perhaps you can learn a bit about RSA:

1. RSA Encryption parameters. Public key: [e,N].
e: 65537
N: 708769425720649412121389478490003879
Cipher: 406445816792408507530052467049668006
We are using 60 bit primes
Can you find the value of the message?
2. RSA Encryption parameters. Public key: [e,N].
e: 65537
N: 701788284504146239521998937428641214033688556483
Cipher: 588219914434746072067326360817896048473173358888
We are using 80 bit primes
Can you find the value of the message?
3. RSA Encryption parameters. Public key: [e,N].
e: 65537
N: 84113448262306037245795162581438109282800502998311432131989804756396522611609
Cipher: 40040098099012047157837547620424958357031230204610940627159040373938326064976
We are using 128 bit primes
Can you find the value of the message?

If you follow the steps given in the next section, you should be able to get solutions. And if you want a background on the RSA method, here it is:

Example

Here is an example:

Encryption parameters
e: 65537
N: 1034776851837418228051242693253376923
Cipher: 582984697800119976959378162843817868
We are using 60 bit primes

Now we have to crack N by finding the primes that make up the value.

If we use this [link], we get:

Factors
-------
1,034,776,851,837,418,228,051,242,693,253,376,923 = 1,086,027,579,223,696,553 x 952,809,000,096,560,291

p=1,086,027,579,223,696,553 q=952,809,000,096,560,291

Now we work out PHI, which is equal to (p−1)×(q−1):

>>>p=1086027579223696553
>>>q=952809000096560291
>>> print (p-1)*(q-1)
1034776851837418226012406113933120080

Now we find e^{−1} (mod PHI) (and where (d×e) (mod PHI)=1), such as using [here]:

Inverse of  65537  mod  1034776851837418226012406113933120080
Result: 568411228254986589811047501435713

This is the decryption key. Finally we decrypt with Message=Cipher^d (mod N):

>>> d=568411228254986589811047501435713
>>> cipher=582984697800119976959378162843817868
>>> N=1034776851837418228051242693253376923
>>> print pow(cipher,d,N)
345

The message is 345

Finally, let’s check the answer. So we can re-cipher with the encryption key and we use Cipher= M^e mod N:

>>> m=345
>>> e=65537
>>> N=1034776851837418228051242693253376923
>>> print pow(m,e,N)
582984697800119976959378162843817868

This is the same as the cipher, so the encryption and decryption keys have worked. Thus the encryption key is [65537, 1034776851837418228051242693253376923] and the decryption key is [568411228254986589811047501435713, 1034776851837418228051242693253376923]

Answers

Remember don’t peek …

No peeking until you have solved them …

  1. Answer is: 529

Just checking M^e mod N… 406445816792408507530052467049668006

2. Answer is: 1143

Just checking M^e mod N… 588219914434746072067326360817896048473173358888

3. Answer is: 150

Just checking M^e mod N… 40040098099012047157837547620424958357031230204610940627159040373938326064976