Trusted answers to developer questions

What is the Blowfish encryption algorithm?

Checkout some of our related courses
Kerberos for Beginners: Intro to Network Authentication Protocol
Intermediate

The Blowfish encryption algorithm is a symmetric block cipher designed to succeed in the DES algorithm that was slow and insecure. In this shot, we will study the steps in the Blowfish encryption algorithm.

Blowfish algorithm in diagrammatic form
Blowfish algorithm in diagrammatic form

The diagram above provides a high-level overview of how the Blowfish algorithm works. Let’s look at this step by step:

  1. Since Blowfish makes use of an SP network, the first step is to initiate the substitution box (Sbox) and permutation box (Pbox). The Pbox entries are shown as the Pi in the diagram above. There are a total of 18 Pbox entries.
  2. Next, we split our 64-bit plaintext into two equal blocks, L and R.
  3. Next, we enter an encryption loop that runs 16 times. The following steps take place in each loop:
    a. We XOR L with Pi, where i depends on the loop’s current iteration.
    b. We then XOR R with F, which is a function of L that makes use of the Sbox split into 4 blocks. The overview of the F function is shown in the image below.
    c. Finally, L and R are swapped before the loop enters its next iteration.
  4. After the loop finishes, L and R are swapped once more.
  5. Next, we make use of our last two unused Pbox entries by XORing R with P17 and L with P18.
  6. Finally, we combine L and R to retrieve the ciphertext.
Function F in diagrammatic form
Function F in diagrammatic form

Blowfish was a strong contender to succeed DES, but it had one main drawback: a small block size of 64. The creator of Blowfish, Bruce Schneier, improved on this flaw by coming up with the Twofish encryption algorithm, which had a block size of 128. Ultimately, the AES algorithm was selected as the new standard, but Schneier’s algorithms are still to be considered resilient and secure.

RELATED TAGS

algorithm
network security

CONTRIBUTOR

Anusheh Zohair Mustafeez
Copyright ©2024 Educative, Inc. All rights reserved
Did you find this helpful?