BF_ENCRYPT(3ossl)
π BF_ENCRYPT β Blowfish encryption (bestie edition) π
okay so this is the BF_ENCRYPT(3ossl) page from the OpenSSL manual, and we're gonna get through it together, no stress. it's giving "vintage crypto, still iconic, technically retired". let's go π«Ά
β¨ NAME β¨
BF_set_key, BF_encrypt, BF_decrypt, BF_ecb_encrypt, BF_cbc_encrypt, BF_cfb64_encrypt, BF_ofb64_encrypt, BF_options β Blowfish encryption. that's the whole vibe. π‘
β¨ SYNOPSIS β¨
first up, the include, literally just:
#include <openssl/blowfish.h>
π¨ heads up bestie: the following functions have been deprecated since OpenSSL 3.0, and you can hide them entirely by definingOPENSSL_API_COMPATwith a suitable version value β go peek atopenssl_user_macros(7)for the deets.
and here's the full lineup of signatures, verbatim, no cap:
void BF_set_key(BF_KEY *key, int len, const unsigned char *data);
void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
BF_KEY *key, int enc);
void BF_cbc_encrypt(const unsigned char *in, unsigned char *out,
long length, BF_KEY *schedule,
unsigned char *ivec, int enc);
void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out,
long length, BF_KEY *schedule,
unsigned char *ivec, int *num, int enc);
void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out,
long length, BF_KEY *schedule,
unsigned char *ivec, int *num);
const char *BF_options(void);
void BF_encrypt(BF_LONG *data, const BF_KEY *key);
void BF_decrypt(BF_LONG *data, const BF_KEY *key);
β¨ DESCRIPTION β¨
okay so first thing's first, and I need you to hear me on this one: all of the functions described on this page are deprecated. π every single one. if you're writing new code, the glow-up you want is EVP_EncryptInit_ex(3), EVP_EncryptUpdate(3) and EVP_EncryptFinal_ex(3) β or the equivalently named decrypt functions if you're going the other way. that's the main character path now. π
this library implements the Blowfish cipher, which was invented and described by Counterpane (see http://www.counterpane.com/blowfish.html). iconic origin story honestly.
Blowfish is a block cipher that operates on 64 bit (8 byte) blocks of data. it uses a variable size key, but typically, 128 bit (16 byte) keys are considered good for strong encryption. Blowfish can be used in the same modes as DES (see des_modes(7)). and ngl? Blowfish is currently one of the faster block ciphers. it's quite a bit faster than DES, and much faster than IDEA or RC2. she ate. π₯
Blowfish consists of a key setup phase and the actual encryption or decryption phase. two-step routine, very demure.
πΈ the functions, one by one πΈ
BF_set_key()β sets up theBF_KEYkey using thelenbytes long key atdata.BF_ecb_encrypt()β the basic Blowfish encryption and decryption function. it encrypts or decrypts the first 64 bits ofinusing the keykey, putting the result inout.encdecides if encryption (BF_ENCRYPT) or decryption (BF_DECRYPT) shall be performed. the vector pointed at byinandoutmust be 64 bits in length, no less. if they are larger, everything after the first 64 bits is ignored. π- the mode functions β
BF_cbc_encrypt(),BF_cfb64_encrypt()andBF_ofb64_encrypt()all operate on variable length data. they all take an initialization vectorivecwhich needs to be passed along into the next call of the same function for the same message.ivecmay be initialized with anything, but the recipient needs to know what it was initialized with, or it won't be able to decrypt. some programs and protocols simplify this, like SSH, whereivecis simply initialized to zero.BF_cbc_encrypt()operates on data that is a multiple of 8 bytes long, whileBF_cfb64_encrypt()andBF_ofb64_encrypt()are used to encrypt a variable number of bytes (the amount does not have to be an exact multiple of 8). the purpose of the latter two is to simulate stream ciphers, and therefore, they need the parameternum, which is a pointer to an integer where the current offset inivecis stored between calls. this integer must be initialized to zero whenivecis initialized. don't forget that part bestie, fr fr. BF_cbc_encrypt()β the Cipher Block Chaining function for Blowfish. it encrypts or decrypts the 64 bits chunks ofinusing the keyschedule, putting the result inout.encdecides if encryption (BF_ENCRYPT) or decryption (BF_DECRYPT) shall be performed.ivecmust point at an 8 byte long initialization vector.BF_cfb64_encrypt()β the CFB mode for Blowfish with 64 bit feedback. it encrypts or decrypts the bytes ininusing the keyschedule, putting the result inout.encdecides if encryption (BF_ENCRYPT) or decryption (BF_DECRYPT) shall be performed.ivecmust point at an 8 byte long initialization vector.nummust point at an integer which must be initially zero.BF_ofb64_encrypt()β the OFB mode for Blowfish with 64 bit feedback. it uses the same parameters asBF_cfb64_encrypt(), which must be initialized the same way.BF_encrypt()andBF_decrypt()β the lowest level functions for Blowfish encryption. they encrypt/decrypt the first 64 bits of the vector pointed bydata, using the keykey.
β οΈ lowkey a warning: these two should not be used unless you implement 'modes' of Blowfish. the alternative is to use BF_ecb_encrypt(). if you still want to use these functions, you should be aware that they take each 32-bit chunk in host-byte order, which is little-endian on little-endian platforms and big-endian on big-endian ones. so likeβ¦ know your platform, okay? π
β¨ RETURN VALUES β¨
none of the functions presented here return any value. not a single one. they just do their thing and go. silent, mysterious, iconic. π
β¨ NOTE β¨
applications should use the higher level functions EVP_EncryptInit(3) etc. instead of calling these functions directly. (yes, we're saying it again. it matters. π)
β¨ SEE ALSO β¨
β¨ HISTORY β¨
all of these functions were deprecated in OpenSSL 3.0. that's the whole story, periodt.
β¨ COPYRIGHT β¨
Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html.
and that's the page, bestie!! this was BF_ENCRYPT(3ossl) from OpenSSL 3.5.9, dated 2026-09-29. go forth, use EVP, and stay encrypted. mwah π
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms