Initial import from FreeBSD RELENG_4:
[dragonfly.git] / secure / lib / libcrypto / man / blowfish.3
1.\" Automatically generated by Pod::Man version 1.15
2.\" Wed Feb 19 16:43:01 2003
4.\" Standard preamble:
5.\" ====================================================================== Sh \" Subsection heading
8.if t .Sp 5
13.. Sp \" Vertical space (when we can't use .PP)
15.if t .sp .5v
16.if n .sp
17.. Ip \" List item \\n(.$>=3 .ne \\$3
21.el .ne 3
22.IP "\\$1" \\$2
23.. Vb \" Begin verbatim text
25.ft CW \\$1
28.. Ve \" End verbatim text
30.ft R
34.\" Set up some character translations and predefined strings. \*(-- will
35.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
36.\" double quote, and \*(R" will give a right double quote. | will give a
37.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used
38.\" to do unbreakable dashes and therefore won't be available. \*(C` and
39.\" \*(C' expand to `' in nroff, nothing in troff, for use with C<> \(*W-|\(bv\*(Tr
41.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' n \{\
43. ds -- \(*W-
44. ds PI pi
45. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
46. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
47. ds L" ""
48. ds R" ""
49. ds C` ""
50. ds C' ""
53. ds -- \|\(em\|
54. ds PI \(*p
55. ds L" ``
56. ds R" ''
59.\" If the F register is turned on, we'll generate index entries on stderr
60.\" for titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and
61.\" index entries marked with X<> in POD. Of course, you'll have to process
62.\" the output yourself in some meaningful fashion.
63.if \nF \{\
64. de IX
65. tm Index:\\$1\t\\n%\t"\\$2"
67. nr % 0
68. rr F
71.\" For nroff, turn off justification. Always turn off hyphenation; it
72.\" makes way too many mistakes in technical documents.
73.hy 0
74.if n .na
76.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
77.\" Fear. Run. Save yourself. No user-serviceable parts. B 3
79. \" fudge factors for nroff and troff
80.if n \{\
81. ds #H 0
82. ds #V .8m
83. ds #F .3m
84. ds #[ \f1
85. ds #] \fP
87.if t \{\
88. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
89. ds #V .6m
90. ds #F 0
91. ds #[ \&
92. ds #] \&
94. \" simple accents for nroff and troff
95.if n \{\
96. ds ' \&
97. ds ` \&
98. ds ^ \&
99. ds , \&
100. ds ~ ~
101. ds /
103.if t \{\
104. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
105. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
106. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
107. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
108. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
109. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
111. \" troff and (daisy-wheel) nroff accents
112.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
113.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
114.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
115.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
116.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
117.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
118.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
119.ds ae a\h'-(\w'a'u*4/10)'e
120.ds Ae A\h'-(\w'A'u*4/10)'E
121. \" corrections for vroff
122.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
123.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
124. \" for low resolution devices (crt and lpr)
125.if \n(.H>23 .if \n(.V>19 \
127. ds : e
128. ds 8 ss
129. ds o a
130. ds d- d\h'-1'\(ga
131. ds D- D\h'-1'\(hy
132. ds th \o'bp'
133. ds Th \o'LP'
134. ds ae ae
135. ds Ae AE
137.rm #[ #] #H #V #F C
138.\" ======================================================================
140.IX Title "blowfish 3"
141.TH blowfish 3 "0.9.7a" "2003-02-19" "OpenSSL"
143.SH "NAME"
144blowfish, BF_set_key, BF_encrypt, BF_decrypt, BF_ecb_encrypt, BF_cbc_encrypt,
145BF_cfb64_encrypt, BF_ofb64_encrypt, BF_options \- Blowfish encryption
147.IX Header "SYNOPSIS"
148.Vb 1
149\& #include <openssl/blowfish.h>
151.Vb 1
152\& void BF_set_key(BF_KEY *key, int len, const unsigned char *data);
154.Vb 10
155\& void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
156\& BF_KEY *key, int enc);
157\& void BF_cbc_encrypt(const unsigned char *in, unsigned char *out,
158\& long length, BF_KEY *schedule, unsigned char *ivec, int enc);
159\& void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out,
160\& long length, BF_KEY *schedule, unsigned char *ivec, int *num,
161\& int enc);
162\& void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out,
163\& long length, BF_KEY *schedule, unsigned char *ivec, int *num);
164\& const char *BF_options(void);
166.Vb 2
167\& void BF_encrypt(BF_LONG *data,const BF_KEY *key);
168\& void BF_decrypt(BF_LONG *data,const BF_KEY *key);
172This library implements the Blowfish cipher, which was invented and described
173by Counterpane (see ).
175Blowfish is a block cipher that operates on 64 bit (8 byte) blocks of data.
176It uses a variable size key, but typically, 128 bit (16 byte) keys are
177a considered good for strong encryption. Blowfish can be used in the same
178modes as \s-1DES\s0 (see des_modes(7)). Blowfish is currently one
179of the faster block ciphers. It is quite a bit faster than \s-1DES\s0, and much
180faster than \s-1IDEA\s0 or \s-1RC2\s0.
182Blowfish consists of a key setup phase and the actual encryption or decryption
185\&\fIBF_set_key()\fR sets up the \fB\s-1BF_KEY\s0\fR \fBkey\fR using the \fBlen\fR bytes long key
186at \fBdata\fR.
188\&\fIBF_ecb_encrypt()\fR is the basic Blowfish encryption and decryption function.
189It encrypts or decrypts the first 64 bits of \fBin\fR using the key \fBkey\fR,
190putting the result in \fBout\fR. \fBenc\fR decides if encryption (\fB\s-1BF_ENCRYPT\s0\fR)
191or decryption (\fB\s-1BF_DECRYPT\s0\fR) shall be performed. The vector pointed at by
192\&\fBin\fR and \fBout\fR must be 64 bits in length, no less. If they are larger,
193everything after the first 64 bits is ignored.
195The mode functions \fIBF_cbc_encrypt()\fR, \fIBF_cfb64_encrypt()\fR and \fIBF_ofb64_encrypt()\fR
196all operate on variable length data. They all take an initialization vector
197\&\fBivec\fR which needs to be passed along into the next call of the same function
198for the same message. \fBivec\fR may be initialized with anything, but the
199recipient needs to know what it was initialized with, or it won't be able
200to decrypt. Some programs and protocols simplify this, like \s-1SSH\s0, where
201\&\fBivec\fR is simply initialized to zero.
202\&\fIBF_cbc_encrypt()\fR operates on data that is a multiple of 8 bytes long, while
203\&\fIBF_cfb64_encrypt()\fR and \fIBF_ofb64_encrypt()\fR are used to encrypt an variable
204number of bytes (the amount does not have to be an exact multiple of 8). The
205purpose of the latter two is to simulate stream ciphers, and therefore, they
206need the parameter \fBnum\fR, which is a pointer to an integer where the current
207offset in \fBivec\fR is stored between calls. This integer must be initialized
208to zero when \fBivec\fR is initialized.
210\&\fIBF_cbc_encrypt()\fR is the Cipher Block Chaining function for Blowfish. It
211encrypts or decrypts the 64 bits chunks of \fBin\fR using the key \fBschedule\fR,
212putting the result in \fBout\fR. \fBenc\fR decides if encryption (\s-1BF_ENCRYPT\s0) or
213decryption (\s-1BF_DECRYPT\s0) shall be performed. \fBivec\fR must point at an 8 byte
214long initialization vector.
216\&\fIBF_cfb64_encrypt()\fR is the \s-1CFB\s0 mode for Blowfish with 64 bit feedback.
217It encrypts or decrypts the bytes in \fBin\fR using the key \fBschedule\fR,
218putting the result in \fBout\fR. \fBenc\fR decides if encryption (\fB\s-1BF_ENCRYPT\s0\fR)
219or decryption (\fB\s-1BF_DECRYPT\s0\fR) shall be performed. \fBivec\fR must point at an
2208 byte long initialization vector. \fBnum\fR must point at an integer which must
221be initially zero.
223\&\fIBF_ofb64_encrypt()\fR is the \s-1OFB\s0 mode for Blowfish with 64 bit feedback.
224It uses the same parameters as \fIBF_cfb64_encrypt()\fR, which must be initialized
225the same way.
227\&\fIBF_encrypt()\fR and \fIBF_decrypt()\fR are the lowest level functions for Blowfish
228encryption. They encrypt/decrypt the first 64 bits of the vector pointed by
229\&\fBdata\fR, using the key \fBkey\fR. These functions should not be used unless you
230implement 'modes' of Blowfish. The alternative is to use \fIBF_ecb_encrypt()\fR.
231If you still want to use these functions, you should be aware that they take
232each 32\-bit chunk in host-byte order, which is little-endian on little-endian
233platforms and big-endian on big-endian ones.
236None of the functions presented here return any value.
237.SH "NOTE"
238.IX Header "NOTE"
239Applications should use the higher level functions
240EVP_EncryptInit(3) etc. instead of calling the
241blowfish functions directly.
243.IX Header "SEE ALSO"
246.IX Header "HISTORY"
247The Blowfish functions are available in all versions of SSLeay and OpenSSL.