1e71b7053SJung-uk Kim=pod 2e71b7053SJung-uk Kim 3e71b7053SJung-uk Kim=head1 NAME 4e71b7053SJung-uk Kim 5e71b7053SJung-uk KimBF_set_key, BF_encrypt, BF_decrypt, BF_ecb_encrypt, BF_cbc_encrypt, 6e71b7053SJung-uk KimBF_cfb64_encrypt, BF_ofb64_encrypt, BF_options - Blowfish encryption 7e71b7053SJung-uk Kim 8e71b7053SJung-uk Kim=head1 SYNOPSIS 9e71b7053SJung-uk Kim 10e71b7053SJung-uk Kim #include <openssl/blowfish.h> 11e71b7053SJung-uk Kim 12*b077aed3SPierre ProncheryThe following functions have been deprecated since OpenSSL 3.0, and can be 13*b077aed3SPierre Proncheryhidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value, 14*b077aed3SPierre Proncherysee L<openssl_user_macros(7)>: 15*b077aed3SPierre Pronchery 16e71b7053SJung-uk Kim void BF_set_key(BF_KEY *key, int len, const unsigned char *data); 17e71b7053SJung-uk Kim 18e71b7053SJung-uk Kim void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, 19e71b7053SJung-uk Kim BF_KEY *key, int enc); 20e71b7053SJung-uk Kim void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, 21e71b7053SJung-uk Kim long length, BF_KEY *schedule, 22e71b7053SJung-uk Kim unsigned char *ivec, int enc); 23e71b7053SJung-uk Kim void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, 24e71b7053SJung-uk Kim long length, BF_KEY *schedule, 25e71b7053SJung-uk Kim unsigned char *ivec, int *num, int enc); 26e71b7053SJung-uk Kim void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, 27e71b7053SJung-uk Kim long length, BF_KEY *schedule, 28e71b7053SJung-uk Kim unsigned char *ivec, int *num); 29e71b7053SJung-uk Kim const char *BF_options(void); 30e71b7053SJung-uk Kim 31e71b7053SJung-uk Kim void BF_encrypt(BF_LONG *data, const BF_KEY *key); 32e71b7053SJung-uk Kim void BF_decrypt(BF_LONG *data, const BF_KEY *key); 33e71b7053SJung-uk Kim 34e71b7053SJung-uk Kim=head1 DESCRIPTION 35e71b7053SJung-uk Kim 36*b077aed3SPierre ProncheryAll of the functions described on this page are deprecated. Applications should 37*b077aed3SPierre Proncheryinstead use L<EVP_EncryptInit_ex(3)>, L<EVP_EncryptUpdate(3)> and 38*b077aed3SPierre ProncheryL<EVP_EncryptFinal_ex(3)> or the equivalently named decrypt functions. 39*b077aed3SPierre Pronchery 40e71b7053SJung-uk KimThis library implements the Blowfish cipher, which was invented and described 41e71b7053SJung-uk Kimby Counterpane (see http://www.counterpane.com/blowfish.html ). 42e71b7053SJung-uk Kim 43e71b7053SJung-uk KimBlowfish is a block cipher that operates on 64 bit (8 byte) blocks of data. 44e71b7053SJung-uk KimIt uses a variable size key, but typically, 128 bit (16 byte) keys are 45e71b7053SJung-uk Kimconsidered good for strong encryption. Blowfish can be used in the same 46e71b7053SJung-uk Kimmodes as DES (see L<des_modes(7)>). Blowfish is currently one 47e71b7053SJung-uk Kimof the faster block ciphers. It is quite a bit faster than DES, and much 48e71b7053SJung-uk Kimfaster than IDEA or RC2. 49e71b7053SJung-uk Kim 50e71b7053SJung-uk KimBlowfish consists of a key setup phase and the actual encryption or decryption 51e71b7053SJung-uk Kimphase. 52e71b7053SJung-uk Kim 53e71b7053SJung-uk KimBF_set_key() sets up the B<BF_KEY> B<key> using the B<len> bytes long key 54e71b7053SJung-uk Kimat B<data>. 55e71b7053SJung-uk Kim 56e71b7053SJung-uk KimBF_ecb_encrypt() is the basic Blowfish encryption and decryption function. 57e71b7053SJung-uk KimIt encrypts or decrypts the first 64 bits of B<in> using the key B<key>, 58e71b7053SJung-uk Kimputting the result in B<out>. B<enc> decides if encryption (B<BF_ENCRYPT>) 59e71b7053SJung-uk Kimor decryption (B<BF_DECRYPT>) shall be performed. The vector pointed at by 60e71b7053SJung-uk KimB<in> and B<out> must be 64 bits in length, no less. If they are larger, 61e71b7053SJung-uk Kimeverything after the first 64 bits is ignored. 62e71b7053SJung-uk Kim 63e71b7053SJung-uk KimThe mode functions BF_cbc_encrypt(), BF_cfb64_encrypt() and BF_ofb64_encrypt() 64e71b7053SJung-uk Kimall operate on variable length data. They all take an initialization vector 65e71b7053SJung-uk KimB<ivec> which needs to be passed along into the next call of the same function 66e71b7053SJung-uk Kimfor the same message. B<ivec> may be initialized with anything, but the 67e71b7053SJung-uk Kimrecipient needs to know what it was initialized with, or it won't be able 68e71b7053SJung-uk Kimto decrypt. Some programs and protocols simplify this, like SSH, where 69e71b7053SJung-uk KimB<ivec> is simply initialized to zero. 70e71b7053SJung-uk KimBF_cbc_encrypt() operates on data that is a multiple of 8 bytes long, while 7158f35182SJung-uk KimBF_cfb64_encrypt() and BF_ofb64_encrypt() are used to encrypt a variable 72e71b7053SJung-uk Kimnumber of bytes (the amount does not have to be an exact multiple of 8). The 73e71b7053SJung-uk Kimpurpose of the latter two is to simulate stream ciphers, and therefore, they 74e71b7053SJung-uk Kimneed the parameter B<num>, which is a pointer to an integer where the current 75e71b7053SJung-uk Kimoffset in B<ivec> is stored between calls. This integer must be initialized 76e71b7053SJung-uk Kimto zero when B<ivec> is initialized. 77e71b7053SJung-uk Kim 78e71b7053SJung-uk KimBF_cbc_encrypt() is the Cipher Block Chaining function for Blowfish. It 79e71b7053SJung-uk Kimencrypts or decrypts the 64 bits chunks of B<in> using the key B<schedule>, 80e71b7053SJung-uk Kimputting the result in B<out>. B<enc> decides if encryption (BF_ENCRYPT) or 81e71b7053SJung-uk Kimdecryption (BF_DECRYPT) shall be performed. B<ivec> must point at an 8 byte 82e71b7053SJung-uk Kimlong initialization vector. 83e71b7053SJung-uk Kim 84e71b7053SJung-uk KimBF_cfb64_encrypt() is the CFB mode for Blowfish with 64 bit feedback. 85e71b7053SJung-uk KimIt encrypts or decrypts the bytes in B<in> using the key B<schedule>, 86e71b7053SJung-uk Kimputting the result in B<out>. B<enc> decides if encryption (B<BF_ENCRYPT>) 87e71b7053SJung-uk Kimor decryption (B<BF_DECRYPT>) shall be performed. B<ivec> must point at an 88e71b7053SJung-uk Kim8 byte long initialization vector. B<num> must point at an integer which must 89e71b7053SJung-uk Kimbe initially zero. 90e71b7053SJung-uk Kim 91e71b7053SJung-uk KimBF_ofb64_encrypt() is the OFB mode for Blowfish with 64 bit feedback. 92e71b7053SJung-uk KimIt uses the same parameters as BF_cfb64_encrypt(), which must be initialized 93e71b7053SJung-uk Kimthe same way. 94e71b7053SJung-uk Kim 95e71b7053SJung-uk KimBF_encrypt() and BF_decrypt() are the lowest level functions for Blowfish 96e71b7053SJung-uk Kimencryption. They encrypt/decrypt the first 64 bits of the vector pointed by 97e71b7053SJung-uk KimB<data>, using the key B<key>. These functions should not be used unless you 98e71b7053SJung-uk Kimimplement 'modes' of Blowfish. The alternative is to use BF_ecb_encrypt(). 99e71b7053SJung-uk KimIf you still want to use these functions, you should be aware that they take 100e71b7053SJung-uk Kimeach 32-bit chunk in host-byte order, which is little-endian on little-endian 101e71b7053SJung-uk Kimplatforms and big-endian on big-endian ones. 102e71b7053SJung-uk Kim 103e71b7053SJung-uk Kim=head1 RETURN VALUES 104e71b7053SJung-uk Kim 105e71b7053SJung-uk KimNone of the functions presented here return any value. 106e71b7053SJung-uk Kim 107e71b7053SJung-uk Kim=head1 NOTE 108e71b7053SJung-uk Kim 109e71b7053SJung-uk KimApplications should use the higher level functions 110e71b7053SJung-uk KimL<EVP_EncryptInit(3)> etc. instead of calling these 111e71b7053SJung-uk Kimfunctions directly. 112e71b7053SJung-uk Kim 113e71b7053SJung-uk Kim=head1 SEE ALSO 114e71b7053SJung-uk Kim 115e71b7053SJung-uk KimL<EVP_EncryptInit(3)>, 116e71b7053SJung-uk KimL<des_modes(7)> 117e71b7053SJung-uk Kim 118*b077aed3SPierre Pronchery=head1 HISTORY 119*b077aed3SPierre Pronchery 120*b077aed3SPierre ProncheryAll of these functions were deprecated in OpenSSL 3.0. 121*b077aed3SPierre Pronchery 122e71b7053SJung-uk Kim=head1 COPYRIGHT 123e71b7053SJung-uk Kim 124*b077aed3SPierre ProncheryCopyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved. 125e71b7053SJung-uk Kim 126*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 127e71b7053SJung-uk Kimthis file except in compliance with the License. You can obtain a copy 128e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at 129e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>. 130e71b7053SJung-uk Kim 131e71b7053SJung-uk Kim=cut 132