Suppose I have to use 64-bit keys for encryption (e.g. to comply with export restrictions). For this question, assume this key is truly random, and the encryption algorithm is Blowfish.

Blowfish key schedule expands this 8-byte key into 4168 bytes of state (P-array and S-boxes). Will it slow down bruteforce attacks if I run this expansion a huge number of rounds?

REPEAT rounds
   state := ExpandKey(state, key)

(Basically, the scheme is similar to bcrypt if you throw away salt and instead of encrypting a constant to derive a key, use the final state for actual encryption.)

Are there any other practical attacks on such schemes faster than brute force?

  • $\begingroup$ Why not use directly bcrypt(cost, IV, key), with an initialization vector (which you should have anyways) as salt? $\endgroup$ Commented Aug 27, 2012 at 18:52
  • $\begingroup$ I could, of course, stretch the key into a longer one with bcrypt, however this would violate the condition of the original problem -- using 64-bit encryption key :) I can restate the question: is using the state of bcrypt(cost, salt, password) directly for encryption of data (instead of encrypting "OrpheanBeholderScryDoubt" 64 times and then using the result as the key for new state) acceptable? $\endgroup$
    – dchest
    Commented Aug 27, 2012 at 19:16
  • $\begingroup$ Oh, I think that's what you suggested, actually, right? $\endgroup$
    – dchest
    Commented Aug 27, 2012 at 19:22
  • $\begingroup$ This is known as "EksBlowfish" (mentioned in the bcrypt specification) and I suppose it is at least as secure as normal Blowfish, and as hard to brute-force (in a known-plaintext attack on some part of the message) as a bcrypt output. $\endgroup$ Commented Aug 27, 2012 at 19:23
  • $\begingroup$ Actually I suggested using the output of bcrypt as the new blowfish key, but using EksBlowfish directly makes more sense, I think. $\endgroup$ Commented Aug 27, 2012 at 19:24

1 Answer 1


Something similar as what you suggest is already known as "Expensive key schedule Blowfish", or "EksBlowfish". It is the encryption algorithm in the core of Bcrypt (a slow hash function designed for password hashing).

It also incorporates a salt, and its setup function is like this (retyped from the paper):

EksBlowfishSetup(cost, salt, key):
   state ← initState()
   state ← ExpandKey(state, salt, key)
      state ← ExpandKey(state, 0, salt)  
      state ← ExpandKey(state, 0, key)
   return state

InitState() is the same as in Blowfish: It fills the P- and S-boxes with digits of $\pi$. ExpandKey(state, 0, ...) also works just like the key expansion function of Blowfish - it XORs the P-boxes with (a repeated version of) the key, then encrypts a zero stream in CBC-mode with Blowfish (using the existing state), replacing the boxes with the results after each block is encrypted. The version with a salt parameter simply uses this salt (repeated) as the original value to encrypt.

The actual encryption of EksBlowfish works just like normal Blowfish encryption. In Bcrypt, this is then used to encrypt (64 times in ECB-mode) the 3-block ASCII-string OrpheanBeholderScryDoubt to produce the bcrypt hash, but you can use EksBlowfish also separately.

It can't get worse than "normal" Blowfish, and will get as hard to bruteforce as a bcrypted password with same cost factor. I suppose you could use a constant salt, but using some random (but not secret) salt delivered with the message looks better (and avoids precomputation). If your performance is critical, you should of course not change the salt with every SSL packet.

There is another problem with Blowfish: It only has 64-bit blocks, and as such can't get more secure than any 64-bit block cipher. Repeating blocks will occur likely after $2^{32}$ blocks (i.e. 32 GB), which might be enough or not, depending on your application. And repeated blocks give points of attack.

You might consider instead using a 128-bit block cipher like AES, and derive your key with bcrypt from the "short" 64-bit key.

  • 1
    $\begingroup$ Correction: 2^32 * 8-byte blocks would be 32 GB (can't edit your post, because edits under 6 characters are not allowed for some reason.) $\endgroup$
    – dchest
    Commented Aug 27, 2012 at 23:33
  • $\begingroup$ @dchest: You are right - looks like I calculated with bits instead of bytes here. Thanks. $\endgroup$ Commented Aug 28, 2012 at 11:19

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.