1blowfish(3)                         OpenSSL                        blowfish(3)
2
3
4

NAME

6       blowfish, BF_set_key, BF_encrypt, BF_decrypt, BF_ecb_encrypt,
7       BF_cbc_encrypt, BF_cfb64_encrypt, BF_ofb64_encrypt, BF_options - Blow‐
8       fish encryption
9

SYNOPSIS

11        #include <openssl/blowfish.h>
12
13        void BF_set_key(BF_KEY *key, int len, const unsigned char *data);
14
15        void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
16                BF_KEY *key, int enc);
17        void BF_cbc_encrypt(const unsigned char *in, unsigned char *out,
18                long length, BF_KEY *schedule, unsigned char *ivec, int enc);
19        void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out,
20                long length, BF_KEY *schedule, unsigned char *ivec, int *num,
21                int enc);
22        void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out,
23                long length, BF_KEY *schedule, unsigned char *ivec, int *num);
24        const char *BF_options(void);
25
26        void BF_encrypt(BF_LONG *data,const BF_KEY *key);
27        void BF_decrypt(BF_LONG *data,const BF_KEY *key);
28

DESCRIPTION

30       This library implements the Blowfish cipher, which was invented and
31       described by Counterpane (see http://www.counterpane.com/blowfish.html
32       ).
33
34       Blowfish is a block cipher that operates on 64 bit (8 byte) blocks of
35       data.  It uses a variable size key, but typically, 128 bit (16 byte)
36       keys are considered good for strong encryption.  Blowfish can be used
37       in the same modes as DES (see des_modes(7)).  Blowfish is currently one
38       of the faster block ciphers.  It is quite a bit faster than DES, and
39       much faster than IDEA or RC2.
40
41       Blowfish consists of a key setup phase and the actual encryption or
42       decryption phase.
43
44       BF_set_key() sets up the BF_KEY key using the len bytes long key at
45       data.
46
47       BF_ecb_encrypt() is the basic Blowfish encryption and decryption func‐
48       tion.  It encrypts or decrypts the first 64 bits of in using the key
49       key, putting the result in out.  enc decides if encryption (BF_ENCRYPT)
50       or decryption (BF_DECRYPT) shall be performed.  The vector pointed at
51       by in and out must be 64 bits in length, no less.  If they are larger,
52       everything after the first 64 bits is ignored.
53
54       The mode functions BF_cbc_encrypt(), BF_cfb64_encrypt() and
55       BF_ofb64_encrypt() all operate on variable length data.  They all take
56       an initialization vector ivec which needs to be passed along into the
57       next call of the same function for the same message.  ivec may be ini‐
58       tialized with anything, but the recipient needs to know what it was
59       initialized with, or it won't be able to decrypt.  Some programs and
60       protocols simplify this, like SSH, where ivec is simply initialized to
61       zero.  BF_cbc_encrypt() operates on data that is a multiple of 8 bytes
62       long, while BF_cfb64_encrypt() and BF_ofb64_encrypt() are used to
63       encrypt an variable number of bytes (the amount does not have to be an
64       exact multiple of 8).  The purpose of the latter two is to simulate
65       stream ciphers, and therefore, they need the parameter num, which is a
66       pointer to an integer where the current offset in ivec is stored
67       between calls.  This integer must be initialized to zero when ivec is
68       initialized.
69
70       BF_cbc_encrypt() is the Cipher Block Chaining function for Blowfish.
71       It encrypts or decrypts the 64 bits chunks of in using the key sched‐
72       ule, putting the result in out.  enc decides if encryption (BF_ENCRYPT)
73       or decryption (BF_DECRYPT) shall be performed.  ivec must point at an 8
74       byte long initialization vector.
75
76       BF_cfb64_encrypt() is the CFB mode for Blowfish with 64 bit feedback.
77       It encrypts or decrypts the bytes in in using the key schedule, putting
78       the result in out.  enc decides if encryption (BF_ENCRYPT) or decryp‐
79       tion (BF_DECRYPT) shall be performed.  ivec must point at an 8 byte
80       long initialization vector. num must point at an integer which must be
81       initially zero.
82
83       BF_ofb64_encrypt() is the OFB mode for Blowfish with 64 bit feedback.
84       It uses the same parameters as BF_cfb64_encrypt(), which must be ini‐
85       tialized the same way.
86
87       BF_encrypt() and BF_decrypt() are the lowest level functions for Blow‐
88       fish encryption.  They encrypt/decrypt the first 64 bits of the vector
89       pointed by data, using the key key.  These functions should not be used
90       unless you implement 'modes' of Blowfish.  The alternative is to use
91       BF_ecb_encrypt().  If you still want to use these functions, you should
92       be aware that they take each 32-bit chunk in host-byte order, which is
93       little-endian on little-endian platforms and big-endian on big-endian
94       ones.
95

RETURN VALUES

97       None of the functions presented here return any value.
98

NOTE

100       Applications should use the higher level functions EVP_EncryptInit(3)
101       etc. instead of calling the blowfish functions directly.
102

SEE ALSO

104       des_modes(7)
105

HISTORY

107       The Blowfish functions are available in all versions of SSLeay and
108       OpenSSL.
109
110
111
1120.9.8b                            2005-02-19                       blowfish(3)
Impressum