Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is for a challenge at


  • The algorithm is AES (Rijndael)
  • Blocksize: 128
  • Keysize: 256
  • You only need to find the first 6 bytes of the key, the rest are 0’s, so: [?,?,?,?,?,?,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
  • All bytes in the key has an integer value between 0 and 16.
  • The initialization vector is (base64 encoded): "DkBbcmQo1QH+ed1wTyBynA=="
  • The text is just plain ASCII english

The encrypted text (base64 encoded):

[base 64 block follows]

Can I crack an AES string if I have all these parameters? If so, how should I do it?

share|improve this question
Only 16 million keys to try so you can use brute force. Guess a key, decode, see if it's text (e.g. high bits zero). – otus Jul 16 '14 at 14:50
Just write a loop, try to decrypt, if it decrypted successfully, you have the correct key. – Matthew Jul 16 '14 at 14:59
@Matthew ... and verify that the result is correct by doing statistical analysis. Remember that AES decryption with incorrect keys just gets you a bunch of incorrect plaintext bytes. – Polynomial Jul 16 '14 at 19:38
Just asking -- is this a public challenge? If so, can you provide a link to it? – Dmitry Yanushkevich Jul 17 '14 at 7:12
@owlstead: Finally I got it. SHA1 is 20d96d3da31c20171d210acb2186b763b7973f30. There is a small lie in the challenge text. – Neil Slater Jul 18 '14 at 15:27
up vote 5 down vote accepted

Since there are only $16^6 \approx 16.8$ million keys, you can try them all and decrypt the message with each. In general you would have to know something about the plaintext to identify which of those decrypted candidates is the correct one.

In this case it is known that the message is English ASCII, so the top bit of each plaintext byte will be 0. The chance of an $n$-byte message succeeding that test by chance is $2^{-n}$, so with more than 24 bytes of data (as you have) it is likely you will find a unique key that decrypts it into ASCII. The padding could include a 1 bit, so you might want to ignore the last block until you've found the key.

Remember to try different modes of operation if the first doesn't work – there is an IV, so it isn't ECB. If the ciphertext length was not a multiple of the block size, it would likely be CTR mode, but yours is.

share|improve this answer
Actually, reading the challenge again, there are technically $17^6$ possible keys if you take "between 0 and 16" to include both ends or $15^6$ if you take it to include neither. Just a factor of two difference, so either is doable just fine. – otus Sep 6 '14 at 7:23

Yes It is crack-able. I did it. Using a programming language I developed a tool to crack this challenge and retrieved the original message. It took about ~2 hours to crack only on an Intel Core 2 Quad Core CPU I don't remember if I dedicated all the resources to the cracking process.

My algorithm was simple:

1. #1: Generate the 6 bytes AES Key and pad it with 0 x 250 2. Decrypt the message and look for the world Congratulations 3. If found print message and quit if not go to #1

Note: I don't think you're allowed to post the challenge online because this violates their copy rights.

share|improve this answer
Re: copyright, quotes are generally fair use, although the one here is a bit excessive in length. I'll trim it a bit. – otus Sep 6 '14 at 7:26
"pad it with 0 x 250" that part makes no sense considering AES only supports 256 bit/32 byte keys, not 256 byte keys. Perhaps you were using an implementation that ignores additional 0 bytes, so only 0 x 26 were used. – CodesInChaos Sep 6 '14 at 23:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.