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 -
8       Blowfish 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
48       function.  It encrypts or decrypts the first 64 bits of in using the
49       key key, putting the result in out.  enc decides if encryption
50       (BF_ENCRYPT) or decryption (BF_DECRYPT) shall be performed.  The vector
51       pointed at by in and out must be 64 bits in length, no less.  If they
52       are larger, 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
58       initialized 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
72       schedule, putting the result in out.  enc decides if encryption
73       (BF_ENCRYPT) or decryption (BF_DECRYPT) shall be performed.  ivec must
74       point at an 8 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
79       decryption (BF_DECRYPT) shall be performed.  ivec must point at an 8
80       byte long initialization vector. num must point at an integer which
81       must be 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
85       initialized the same way.
86
87       BF_encrypt() and BF_decrypt() are the lowest level functions for
88       Blowfish encryption.  They encrypt/decrypt the first 64 bits of the
89       vector pointed by data, using the key key.  These functions should not
90       be used unless you implement 'modes' of Blowfish.  The alternative is
91       to use BF_ecb_encrypt().  If you still want to use these functions, you
92       should be aware that they take each 32-bit chunk in host-byte order,
93       which is little-endian on little-endian platforms and big-endian on
94       big-endian 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
1121.0.2o                            2018-03-27                       blowfish(3)
Impressum