Disclaimer: I'm pretty new to cryptography and I don't have a strong mathematical background. I apologize in advance if I missed something blatantly obvious.

I participated in a security CTF this weekend and I was unable to solve one of the problems. It's been three days now and I still take a crack at it whenever I have some free time, it's driving me crazy. It just seemed so simple at first.

The title was "triple Schneier, no Rivest" and it gave an apparently encrypted file and three qr codes which contained this data:

# First QR
# Second QR
# Third QR

This is the file encoded in base64:


It's 264 bytes long, the IV in each key is 8 bytes long and each key is 16 bytes long. Plus the mention of Schneier in the title, I'd say it's a pretty safe bet we have a blowfish cipher.

I've tried decrypting the file with the first key, then with the second, and then with the third. I also tried different libraries/implementations of the algorithm.

I even wrote a python program to try all possible permutations of the three keys, but none gave me a plaintext.

I'm obviously missing something big.

Here's my last attempt at it, which I think condenses most of the other things I've tried:

for kr in key_permutations:
    out_name = ''.join( [ str(k['id']) for k in kr ] )
    output = [ first_input ]
    for k in kr:
        cipher = blowfish.Cipher(k['key'])
        i = b''.join(output)
        output = cipher.decrypt_cbc(i,k['iv'])


key_permutations is a list of 3-uples where each element is a dictionary with a key, its corresponding iv and an arbitrary ID. I'm using this blowfish library.

So I guess the questions are three:

  • Is there a way to make sure this is indeed a blowfish cipher?
  • What methods are available, given those 3 keys, to try and crack the code
  • What does Rivest have to do with Blowfish?

Thanks in advance!


1 Answer 1


The encryption is EDE with Blowfish CBC. To decode the cryptotext ct reverse the encrytion, ie do

CBC_Decrypt(key3, iv3, ct, t3)
CBC_Encrypt(key2, iv2, t3, t2)
CBC_Decrypt(key1, iv1, t2, pt)

After this the plaintext pt will start with:

El truco estaba en desencriptar utilizando el metodo 3DES pero con distintos algoritmos de encripcion. Aunque usualmente se utiliza 3 veces DES, es posible utilizar 3 algoritmos distintos con el metodo de 3DES ....

  • $\begingroup$ Amazing, thanks! I was not aware of 3DES and it never occured to me to use one of the keys for encryption instead of decryption. $\endgroup$
    – GnP
    Jun 22, 2016 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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