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