Blowfish Algorithm in Cryptography
Blowfish is a symmetric, 64-bit block cipher with changeable length. As a "general-purpose algorithm," it was created by Bruce Schneier in 1993 as a quick, cost-free replacement for the venerable Data Encryption Standard (DES) and International Data Encryption Algorithm (IDEA) encryption techniques.
Blowfish is unpatented, substantially quicker than DES and IDEA, and freely accessible for all purposes. However, because of its short block size, which is seen as unsafe, it couldn't totally replace DES.
The security issue was addressed by Twofish, its successor, who used a higher block size of 128 bits. Even Nevertheless, many cipher suites and encryption solutions on the market today use the Blowfish algorithm since complete Blowfish encryption has never been cracked.
Blowfish features a 64-bit block size with keys that can be 32 bits long or 448 bits long. It features 16 iterations that resemble Feistel and each one operates on a 64-bit block that is partitioned into two 32-bit words. Blowfish uses a single encryption key to encode and decode data.
The two primary parts of the blowfish algorithm are as follows:
Data Encryption: A 16-round Feistel network is used to encrypt data, with each round including a key-dependent permutation and a key- and data-dependent replacement. The replacement approach is used in conjunction with large, key-dependent S-boxes to encrypt data in Blowfish. All encryption processes include add on 32-bit words and XORs, a sort of logic gate.
Key expansion and Sub keys: Maximum size 448-bit keys are expanded into several sub key arrays totaling 4,168 bytes throughout the key expansion procedure. The Blowfish algorithm, which makes extensive use of sub keys, depends on them. Before any encryption or decryption can occur, these sub keys are pre-calculated.
The P-array in Blowfish is made up of four 32-bit S-boxes with 256 entries each, along with 18 32-bit sub keys. Following is the calculation for the sub keys:
To produce all the sub keys and processes, Blowfish executes 521 times in total, using around 4 kilobytes (KB) of data.
Example of the Blowfish encryption and decryption technique
Assume Blowfish will be used to encrypt the message "Hi world". The procedures are as follows:
Benefits of Blowfish
Blowfish is one of the quickest and smallest block ciphers currently in use, converting data into cipher text using a symmetric encryption key. Blowfish is still commonly used over three decades after it was initially created because it provides the following benefits:
Drawbacks of blowfish
Using Blowfish for encryption has various drawbacks, such as the following:
Uses of blowfish
Blowfish is appropriate for a variety of uses, such as the following:
Many well-known products, including CryptoDisk, PasswordWallet, Access Manager, Symantec NetBackup, and SplashID, employ Blowfish. Blowfish is also widely used by e-commerce companies and social media platforms to secure user data.
A Java program that demonstrates Blowfish encryption below:
subkey 1: 8e846390 subkey 2: a295c40e subkey 3: b9a28336 subkey 4: 2446bf99 subkey 5: 0eb2313a subkey 6: 0ea9fd0d subkey 7: a295f380 subkey 8: cb78a054 subkey 9: ef9328fe subkey 10: 1fe6dfaa subkey 11: 14ef6fd7 subkey 12: 13dfc0b1 subkey 13: 6a1720af subkey 14: ee4a9c00 subkey 15: 953fdcad subkey 16: 9271c5ca subkey 17: 38addcc1 subkey 18: ae4f37c6 -----Encryption----- round 0: 77b3ba639cb0353b round 1: 0cc7d63fd5267e6d round 2: c799728ab5655509 round 3: 69612395e3dfcd13 round 4: f3f5b74b67d312af round 5: 52023d4efd5c4a46 round 6: 5b785180f097cece round 7: cc946d119000f1d4 round 8: 6af47a4b230745ef round 9: 9fb82cc57512a5e1 round 10: 1106c1ab8b574312 round 11: 7d7a616502d9011a round 12: 81e9ce71176d41ca round 13: 9727e50a6fa35271 round 14: eb761e34021839a7 round 15: 0599d9367907dbfe Cipher Text: d748ec383d3405f7
Here is a Java program that shows how to decode data:
subkey 1: 8e846390 subkey 2: a295c40e subkey 3: b9a28336 subkey 4: 2446bf99 subkey 5: 0eb2313a subkey 6: 0ea9fd0d subkey 7: a295f380 subkey 8: cb78a054 subkey 9: ef9328fe subkey 10: 1fe6dfaa subkey 11: 14ef6fd7 subkey 12: 13dfc0b1 subkey 13: 6a1720af subkey 14: ee4a9c00 subkey 15: 953fdcad subkey 16: 9271c5ca subkey 17: 38addcc1 subkey 18: ae4f37c6 -----Decryption----- round 17: 3ab5e5667907dbfe round 16: fdd297bb021839a7 round 15: 82529d676fa35271 round 14: ec939d1a176d41ca round 13: e14063bd02d9011a round 12: 66cd65508b574312 round 11: 37e82a387512a5e1 round 10: 8fe62e7e230745ef round 9: 1f04e6309000f1d4 round 8: 3624ea12f097cece round 7: c546e12ffd5c4a46 round 6: ed76301e67d312af round 5: bbd76433e3dfcd13 round 4: f160c1f4b5655509 round 3: 2512b60dd5267e6d round 2: 6f86e1389cb0353b Plain Text: 123456abcd132536
Benefits and Drawbacks of the Blowfish Algorithm
Uses for the Blowfish Algorithm