# Could Deep Learning be used to crack encryption?

Say you have a dataset with millions of rows and the attributes Plain Text, Key, and Output Ciphertext. Could Deep Learning, theoretically, be used to find patterns in the outputs that help decipher the ciphertext? Are there any other potential approaches?

Probably not. Modern encryption systems are designed around cryptographic random number generators, their output is designed to be statistically indistinguishable from true randomness. Machine learning is generally based on discovering statistical patterns in the data, and with truly random data there is none. Even for flawed crypto where there is some small pattern to be found, the large amount of randomness in the input will overwhelm any direct attempt to decrypt the ciphertext.

In addition, there is no heuristic you can use to tell if you are getting close to a correct decryption - a single bit out in a guess at a key for example will completely scramble the output (blame Hollywood for when it shows decryption on screen like some crossword puzzle where the correct letters drop into place). That all-or-nothingness rules out discovering algorithms via a machine learning process, even when you have the encryption key. The best you can do is brute-force all known algorithms. If you don't have the key, then you have to brute-force all possible keys too.

You could explore how difficult the problem is by attempting to guess the seed value used for a random number generator. Using the Mersenne Twister RNG (the standard one used in e.g. Python), then the input could be the bit pattern for 624 32-bit unsigned integers, and the output could be the 32 bits of the seed used to generate that series. The reason I suggest those specific numbers is because it is in fact possible to crack Mersenne Twister with that much data. However, I still think that ML approaches would be entirely the wrong tool to do so.

Another simple variant would be to see if you can teach a network to either produce or reverse a cryptographic hash. You could start with a known broken one such as MD5. Input and output could be 80 bits, which simplifies the architecture and pipeline enough that you could put together this test in a few hours. Even though MD5 is known to be compromised, I think there is zero chance you could teach a neural network to find any pattern.

One important detail: If you want to "crack" an encryption, you will not be able to use the key as a known value. Chances are though, that even if you provide the key to an ML process, it will be unable to learn how to decrypt.

As suggested in an earlier answer, it may be difficult for ML techniques to break the encryption directly.

But there are ways in which ML and neural network techniques can be used to break encryption (AES in particular because I have worked on it, but can be used for others too).

I am concentrating on AES encryption in embedded devices. When a device is encrypting (or decrypting) it usually leaks out information in the form of power or electromagnetic radiations. These are called 'Side channel leakages'. Research has shown that these leakages correlate to the secret key being used during the encryption (or decryption). And if there is correlation, ML/neural network techniques can be utilized to retrieve the secret key being used. Check these papers that have used ML/neural networks for retrieving (a part of) the secret key used during AES encryption: Ref2 Ref3

Research in this field is still on-going and there is still a lot to accomplish. But all is not lost and there is still hope in using deep learning to break cryptography or a part of it.