Decrypting a blowfish cipher with three keys 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
key=5EBE2294ECD0E0F08EAB7690D2A6EE69
iv=26AE5CC854E36B6B
# Second QR
key=3FDD884B0F6491110CE7A27CD9C670E2
iv=2384D24993B7A941
# Third QR
key=5A1F31323B5F3E79DF1A1A2ABC89B85F
iv=B9B9F5320FDD8706


This is the file encoded in base64:

ewx68DgfNLMEabX/dl62gVO4zki0vaZHWv6E+WCK8i0BH/rsKtIIV0ZlB8Z+fCFWwPQ04ZAi5Np6
s9lG4KnxUyVSAW/E1ccQ9QcOVxTTwduGdZ5+/ypgRIDKbx9B3mE8cZu0KBQ5k+Y1TfhlqYLwzs9E
Xld9C3IMIrzBChFFoVmGEOZT/I/idBoE++ZDDlMGZMsZO37l2/Th/73y5qNn6Ezp1uuqAPoeZbAB
ZSOaGnkKYnMPcjqoJR47NP4L3j0Wt39nZtbvHjQfIAyefqliklsChbTEGeRavqJX8zOg1W5zi3Q/
qKWilBOT5eLhtH9WxOa7aY8gxjcPQWzzXhSUtlZeCXUt2DW+


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)
        sys.stdout.buffer.write(i)
        output = cipher.decrypt_cbc(i,k['iv'])

    open(out_name,'wb').write(b''.join(output))


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!
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 ....