]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/lib/libcrypto/man/EVP_EncryptInit.3
This commit was generated by cvs2svn to compensate for changes in r98944,
[FreeBSD/FreeBSD.git] / secure / lib / libcrypto / man / EVP_EncryptInit.3
1 .\" Automatically generated by Pod::Man version 1.15
2 .\" Thu May  9 13:17:49 2002
3 .\"
4 .\" Standard preamble:
5 .\" ======================================================================
6 .de Sh \" Subsection heading
7 .br
8 .if t .Sp
9 .ne 5
10 .PP
11 \fB\\$1\fR
12 .PP
13 ..
14 .de Sp \" Vertical space (when we can't use .PP)
15 .if t .sp .5v
16 .if n .sp
17 ..
18 .de Ip \" List item
19 .br
20 .ie \\n(.$>=3 .ne \\$3
21 .el .ne 3
22 .IP "\\$1" \\$2
23 ..
24 .de Vb \" Begin verbatim text
25 .ft CW
26 .nf
27 .ne \\$1
28 ..
29 .de Ve \" End verbatim text
30 .ft R
31
32 .fi
33 ..
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<>
40 .tr \(*W-|\(bv\*(Tr
41 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
42 .ie 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' ""
51 'br\}
52 .el\{\
53 .    ds -- \|\(em\|
54 .    ds PI \(*p
55 .    ds L" ``
56 .    ds R" ''
57 'br\}
58 .\"
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"
66 ..
67 .    nr % 0
68 .    rr F
69 .\}
70 .\"
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
75 .\"
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.
78 .bd 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
86 .\}
87 .if t \{\
88 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
89 .    ds #V .6m
90 .    ds #F 0
91 .    ds #[ \&
92 .    ds #] \&
93 .\}
94 .    \" simple accents for nroff and troff
95 .if n \{\
96 .    ds ' \&
97 .    ds ` \&
98 .    ds ^ \&
99 .    ds , \&
100 .    ds ~ ~
101 .    ds /
102 .\}
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'
110 .\}
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 \
126 \{\
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
136 .\}
137 .rm #[ #] #H #V #F C
138 .\" ======================================================================
139 .\"
140 .IX Title "EVP_ENCRYPTINIT 1"
141 .TH EVP_ENCRYPTINIT 1 "perl v5.6.1" "2000-11-13" "User Contributed Perl Documentation"
142 .UC
143 .SH "NAME"
144 EVP_EncryptInit, EVP_EncryptUpdate, EVP_EncryptFinal, EVP_DecryptInit,
145 EVP_DecryptUpdate, EVP_DecryptFinal, EVP_CipherInit, EVP_CipherUpdate,
146 EVP_CipherFinal, EVP_CIPHER_CTX_set_key_length, EVP_CIPHER_CTX_ctrl,
147 EVP_CIPHER_CTX_cleanup, EVP_get_cipherbyname, EVP_get_cipherbynid,
148 EVP_get_cipherbyobj, EVP_CIPHER_nid, EVP_CIPHER_block_size,
149 EVP_CIPHER_key_length, EVP_CIPHER_iv_length, EVP_CIPHER_flags,
150 EVP_CIPHER_mode, EVP_CIPHER_type, EVP_CIPHER_CTX_cipher, EVP_CIPHER_CTX_nid,
151 EVP_CIPHER_CTX_block_size, EVP_CIPHER_CTX_key_length, EVP_CIPHER_CTX_iv_length,
152 EVP_CIPHER_CTX_get_app_data, EVP_CIPHER_CTX_set_app_data, EVP_CIPHER_CTX_type,
153 EVP_CIPHER_CTX_flags, EVP_CIPHER_CTX_mode, EVP_CIPHER_param_to_asn1,
154 EVP_CIPHER_asn1_to_param \- \s-1EVP\s0 cipher routines
155 .SH "SYNOPSIS"
156 .IX Header "SYNOPSIS"
157 .Vb 1
158 \& #include <openssl/evp.h>
159 .Ve
160 .Vb 6
161 \& int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
162 \&         unsigned char *key, unsigned char *iv);
163 \& int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
164 \&         int *outl, unsigned char *in, int inl);
165 \& int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out,
166 \&         int *outl);
167 .Ve
168 .Vb 6
169 \& int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
170 \&         unsigned char *key, unsigned char *iv);
171 \& int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
172 \&         int *outl, unsigned char *in, int inl);
173 \& int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
174 \&         int *outl);
175 .Ve
176 .Vb 6
177 \& int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
178 \&         unsigned char *key, unsigned char *iv, int enc);
179 \& int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
180 \&         int *outl, unsigned char *in, int inl);
181 \& int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
182 \&         int *outl);
183 .Ve
184 .Vb 3
185 \& int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
186 \& int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
187 \& int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
188 .Ve
189 .Vb 3
190 \& const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
191 \& #define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
192 \& #define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
193 .Ve
194 .Vb 7
195 \& #define EVP_CIPHER_nid(e)              ((e)->nid)
196 \& #define EVP_CIPHER_block_size(e)       ((e)->block_size)
197 \& #define EVP_CIPHER_key_length(e)       ((e)->key_len)
198 \& #define EVP_CIPHER_iv_length(e)                ((e)->iv_len)
199 \& #define EVP_CIPHER_flags(e)            ((e)->flags)
200 \& #define EVP_CIPHER_mode(e)             ((e)->flags) & EVP_CIPH_MODE)
201 \& int EVP_CIPHER_type(const EVP_CIPHER *ctx);
202 .Ve
203 .Vb 10
204 \& #define EVP_CIPHER_CTX_cipher(e)       ((e)->cipher)
205 \& #define EVP_CIPHER_CTX_nid(e)          ((e)->cipher->nid)
206 \& #define EVP_CIPHER_CTX_block_size(e)   ((e)->cipher->block_size)
207 \& #define EVP_CIPHER_CTX_key_length(e)   ((e)->key_len)
208 \& #define EVP_CIPHER_CTX_iv_length(e)    ((e)->cipher->iv_len)
209 \& #define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data)
210 \& #define EVP_CIPHER_CTX_set_app_data(e,d) ((e)->app_data=(char *)(d))
211 \& #define EVP_CIPHER_CTX_type(c)         EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
212 \& #define EVP_CIPHER_CTX_flags(e)                ((e)->cipher->flags)
213 \& #define EVP_CIPHER_CTX_mode(e)         ((e)->cipher->flags & EVP_CIPH_MODE)
214 .Ve
215 .Vb 2
216 \& int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
217 \& int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
218 .Ve
219 .SH "DESCRIPTION"
220 .IX Header "DESCRIPTION"
221 The \s-1EVP\s0 cipher routines are a high level interface to certain
222 symmetric ciphers.
223 .PP
224 \&\fIEVP_EncryptInit()\fR initializes a cipher context \fBctx\fR for encryption
225 with cipher \fBtype\fR. \fBtype\fR is normally supplied by a function such
226 as \fIEVP_des_cbc()\fR . \fBkey\fR is the symmetric key to use and \fBiv\fR is the
227 \&\s-1IV\s0 to use (if necessary), the actual number of bytes used for the
228 key and \s-1IV\s0 depends on the cipher. It is possible to set all parameters
229 to \s-1NULL\s0 except \fBtype\fR in an initial call and supply the remaining
230 parameters in subsequent calls, all of which have \fBtype\fR set to \s-1NULL\s0.
231 This is done when the default cipher parameters are not appropriate.
232 .PP
233 \&\fIEVP_EncryptUpdate()\fR encrypts \fBinl\fR bytes from the buffer \fBin\fR and
234 writes the encrypted version to \fBout\fR. This function can be called
235 multiple times to encrypt successive blocks of data. The amount
236 of data written depends on the block alignment of the encrypted data:
237 as a result the amount of data written may be anything from zero bytes
238 to (inl + cipher_block_size \- 1) so \fBoutl\fR should contain sufficient
239 room.  The actual number of bytes written is placed in \fBoutl\fR.
240 .PP
241 \&\fIEVP_EncryptFinal()\fR encrypts the \*(L"final\*(R" data, that is any data that
242 remains in a partial block. It uses standard block padding (aka \s-1PKCS\s0
243 padding). The encrypted final data is written to \fBout\fR which should
244 have sufficient space for one cipher block. The number of bytes written
245 is placed in \fBoutl\fR. After this function is called the encryption operation
246 is finished and no further calls to \fIEVP_EncryptUpdate()\fR should be made.
247 .PP
248 \&\fIEVP_DecryptInit()\fR, \fIEVP_DecryptUpdate()\fR and \fIEVP_DecryptFinal()\fR are the
249 corresponding decryption operations. \fIEVP_DecryptFinal()\fR will return an
250 error code if the final block is not correctly formatted. The parameters
251 and restrictions are identical to the encryption operations except that
252 the decrypted data buffer \fBout\fR passed to \fIEVP_DecryptUpdate()\fR should
253 have sufficient room for (\fBinl\fR + cipher_block_size) bytes unless the
254 cipher block size is 1 in which case \fBinl\fR bytes is sufficient.
255 .PP
256 \&\fIEVP_CipherInit()\fR, \fIEVP_CipherUpdate()\fR and \fIEVP_CipherFinal()\fR are functions
257 that can be used for decryption or encryption. The operation performed
258 depends on the value of the \fBenc\fR parameter. It should be set to 1 for
259 encryption, 0 for decryption and \-1 to leave the value unchanged (the
260 actual value of 'enc' being supplied in a previous call).
261 .PP
262 \&\fIEVP_CIPHER_CTX_cleanup()\fR clears all information from a cipher context.
263 It should be called after all operations using a cipher are complete
264 so sensitive information does not remain in memory.
265 .PP
266 \&\fIEVP_get_cipherbyname()\fR, \fIEVP_get_cipherbynid()\fR and \fIEVP_get_cipherbyobj()\fR
267 return an \s-1EVP_CIPHER\s0 structure when passed a cipher name, a \s-1NID\s0 or an
268 \&\s-1ASN1_OBJECT\s0 structure.
269 .PP
270 \&\fIEVP_CIPHER_nid()\fR and \fIEVP_CIPHER_CTX_nid()\fR return the \s-1NID\s0 of a cipher when
271 passed an \fB\s-1EVP_CIPHER\s0\fR or \fB\s-1EVP_CIPHER_CTX\s0\fR structure.  The actual \s-1NID\s0
272 value is an internal value which may not have a corresponding \s-1OBJECT\s0
273 \&\s-1IDENTIFIER\s0.
274 .PP
275 \&\fIEVP_CIPHER_key_length()\fR and \fIEVP_CIPHER_CTX_key_length()\fR return the key
276 length of a cipher when passed an \fB\s-1EVP_CIPHER\s0\fR or \fB\s-1EVP_CIPHER_CTX\s0\fR
277 structure. The constant \fB\s-1EVP_MAX_KEY_LENGTH\s0\fR is the maximum key length
278 for all ciphers. Note: although \fIEVP_CIPHER_key_length()\fR is fixed for a
279 given cipher, the value of \fIEVP_CIPHER_CTX_key_length()\fR may be different
280 for variable key length ciphers.
281 .PP
282 \&\fIEVP_CIPHER_CTX_set_key_length()\fR sets the key length of the cipher ctx.
283 If the cipher is a fixed length cipher then attempting to set the key
284 length to any value other than the fixed value is an error.
285 .PP
286 \&\fIEVP_CIPHER_iv_length()\fR and \fIEVP_CIPHER_CTX_iv_length()\fR return the \s-1IV\s0
287 length of a cipher when passed an \fB\s-1EVP_CIPHER\s0\fR or \fB\s-1EVP_CIPHER_CTX\s0\fR.
288 It will return zero if the cipher does not use an \s-1IV\s0.  The constant
289 \&\fB\s-1EVP_MAX_IV_LENGTH\s0\fR is the maximum \s-1IV\s0 length for all ciphers.
290 .PP
291 \&\fIEVP_CIPHER_block_size()\fR and \fIEVP_CIPHER_CTX_block_size()\fR return the block
292 size of a cipher when passed an \fB\s-1EVP_CIPHER\s0\fR or \fB\s-1EVP_CIPHER_CTX\s0\fR
293 structure. The constant \fB\s-1EVP_MAX_IV_LENGTH\s0\fR is also the maximum block
294 length for all ciphers.
295 .PP
296 \&\fIEVP_CIPHER_type()\fR and \fIEVP_CIPHER_CTX_type()\fR return the type of the passed
297 cipher or context. This \*(L"type\*(R" is the actual \s-1NID\s0 of the cipher \s-1OBJECT\s0
298 \&\s-1IDENTIFIER\s0 as such it ignores the cipher parameters and 40 bit \s-1RC2\s0 and
299 128 bit \s-1RC2\s0 have the same \s-1NID\s0. If the cipher does not have an object
300 identifier or does not have \s-1ASN1\s0 support this function will return
301 \&\fBNID_undef\fR.
302 .PP
303 \&\fIEVP_CIPHER_CTX_cipher()\fR returns the \fB\s-1EVP_CIPHER\s0\fR structure when passed
304 an \fB\s-1EVP_CIPHER_CTX\s0\fR structure.
305 .PP
306 \&\fIEVP_CIPHER_mode()\fR and \fIEVP_CIPHER_CTX_mode()\fR return the block cipher mode:
307 \&\s-1EVP_CIPH_ECB_MODE\s0, \s-1EVP_CIPH_CBC_MODE\s0, \s-1EVP_CIPH_CFB_MODE\s0 or
308 \&\s-1EVP_CIPH_OFB_MODE\s0. If the cipher is a stream cipher then
309 \&\s-1EVP_CIPH_STREAM_CIPHER\s0 is returned.
310 .PP
311 \&\fIEVP_CIPHER_param_to_asn1()\fR sets the AlgorithmIdentifier \*(L"parameter\*(R" based
312 on the passed cipher. This will typically include any parameters and an
313 \&\s-1IV\s0. The cipher \s-1IV\s0 (if any) must be set when this call is made. This call
314 should be made before the cipher is actually \*(L"used\*(R" (before any
315 \&\fIEVP_EncryptUpdate()\fR, \fIEVP_DecryptUpdate()\fR calls for example). This function
316 may fail if the cipher does not have any \s-1ASN1\s0 support.
317 .PP
318 \&\fIEVP_CIPHER_asn1_to_param()\fR sets the cipher parameters based on an \s-1ASN1\s0
319 AlgorithmIdentifier \*(L"parameter\*(R". The precise effect depends on the cipher
320 In the case of \s-1RC2\s0, for example, it will set the \s-1IV\s0 and effective key length.
321 This function should be called after the base cipher type is set but before
322 the key is set. For example \fIEVP_CipherInit()\fR will be called with the \s-1IV\s0 and
323 key set to \s-1NULL\s0, \fIEVP_CIPHER_asn1_to_param()\fR will be called and finally
324 \&\fIEVP_CipherInit()\fR again with all parameters except the key set to \s-1NULL\s0. It is
325 possible for this function to fail if the cipher does not have any \s-1ASN1\s0 support
326 or the parameters cannot be set (for example the \s-1RC2\s0 effective key length
327 is not supported.
328 .PP
329 \&\fIEVP_CIPHER_CTX_ctrl()\fR allows various cipher specific parameters to be determined
330 and set. Currently only the \s-1RC2\s0 effective key length and the number of rounds of
331 \&\s-1RC5\s0 can be set.
332 .SH "RETURN VALUES"
333 .IX Header "RETURN VALUES"
334 \&\fIEVP_EncryptInit()\fR, \fIEVP_EncryptUpdate()\fR and \fIEVP_EncryptFinal()\fR return 1 for success
335 and 0 for failure.
336 .PP
337 \&\fIEVP_DecryptInit()\fR and \fIEVP_DecryptUpdate()\fR return 1 for success and 0 for failure.
338 \&\fIEVP_DecryptFinal()\fR returns 0 if the decrypt failed or 1 for success.
339 .PP
340 \&\fIEVP_CipherInit()\fR and \fIEVP_CipherUpdate()\fR return 1 for success and 0 for failure.
341 \&\fIEVP_CipherFinal()\fR returns 1 for a decryption failure or 1 for success.
342 .PP
343 \&\fIEVP_CIPHER_CTX_cleanup()\fR returns 1 for success and 0 for failure.
344 .PP
345 \&\fIEVP_get_cipherbyname()\fR, \fIEVP_get_cipherbynid()\fR and \fIEVP_get_cipherbyobj()\fR
346 return an \fB\s-1EVP_CIPHER\s0\fR structure or \s-1NULL\s0 on error.
347 .PP
348 \&\fIEVP_CIPHER_nid()\fR and \fIEVP_CIPHER_CTX_nid()\fR return a \s-1NID\s0.
349 .PP
350 \&\fIEVP_CIPHER_block_size()\fR and \fIEVP_CIPHER_CTX_block_size()\fR return the block
351 size.
352 .PP
353 \&\fIEVP_CIPHER_key_length()\fR and \fIEVP_CIPHER_CTX_key_length()\fR return the key
354 length.
355 .PP
356 \&\fIEVP_CIPHER_iv_length()\fR and \fIEVP_CIPHER_CTX_iv_length()\fR return the \s-1IV\s0
357 length or zero if the cipher does not use an \s-1IV\s0.
358 .PP
359 \&\fIEVP_CIPHER_type()\fR and \fIEVP_CIPHER_CTX_type()\fR return the \s-1NID\s0 of the cipher's
360 \&\s-1OBJECT\s0 \s-1IDENTIFIER\s0 or NID_undef if it has no defined \s-1OBJECT\s0 \s-1IDENTIFIER\s0.
361 .PP
362 \&\fIEVP_CIPHER_CTX_cipher()\fR returns an \fB\s-1EVP_CIPHER\s0\fR structure.
363 .PP
364 \&\fIEVP_CIPHER_param_to_asn1()\fR and \fIEVP_CIPHER_asn1_to_param()\fR return 1 for 
365 success or zero for failure.
366 .SH "CIPHER LISTING"
367 .IX Header "CIPHER LISTING"
368 All algorithms have a fixed key length unless otherwise stated.
369 .Ip "\fIEVP_enc_null()\fR" 4
370 .IX Item "EVP_enc_null()"
371 Null cipher: does nothing.
372 .Ip "EVP_des_cbc(void), EVP_des_ecb(void), EVP_des_cfb(void), EVP_des_ofb(void)" 4
373 .IX Item "EVP_des_cbc(void), EVP_des_ecb(void), EVP_des_cfb(void), EVP_des_ofb(void)"
374 \&\s-1DES\s0 in \s-1CBC\s0, \s-1ECB\s0, \s-1CFB\s0 and \s-1OFB\s0 modes respectively. 
375 .Ip "EVP_des_ede_cbc(void), \fIEVP_des_ede()\fR, EVP_des_ede_ofb(void),  EVP_des_ede_cfb(void)" 4
376 .IX Item "EVP_des_ede_cbc(void), EVP_des_ede(), EVP_des_ede_ofb(void),  EVP_des_ede_cfb(void)"
377 Two key triple \s-1DES\s0 in \s-1CBC\s0, \s-1ECB\s0, \s-1CFB\s0 and \s-1OFB\s0 modes respectively.
378 .Ip "EVP_des_ede3_cbc(void), \fIEVP_des_ede3()\fR, EVP_des_ede3_ofb(void),  EVP_des_ede3_cfb(void)" 4
379 .IX Item "EVP_des_ede3_cbc(void), EVP_des_ede3(), EVP_des_ede3_ofb(void),  EVP_des_ede3_cfb(void)"
380 Three key triple \s-1DES\s0 in \s-1CBC\s0, \s-1ECB\s0, \s-1CFB\s0 and \s-1OFB\s0 modes respectively.
381 .Ip "EVP_desx_cbc(void)" 4
382 .IX Item "EVP_desx_cbc(void)"
383 \&\s-1DESX\s0 algorithm in \s-1CBC\s0 mode.
384 .Ip "EVP_rc4(void)" 4
385 .IX Item "EVP_rc4(void)"
386 \&\s-1RC4\s0 stream cipher. This is a variable key length cipher with default key length 128 bits.
387 .Ip "EVP_rc4_40(void)" 4
388 .IX Item "EVP_rc4_40(void)"
389 \&\s-1RC4\s0 stream cipher with 40 bit key length. This is obsolete and new code should use \fIEVP_rc4()\fR
390 and the \fIEVP_CIPHER_CTX_set_key_length()\fR function.
391 .Ip "\fIEVP_idea_cbc()\fR EVP_idea_ecb(void), EVP_idea_cfb(void), EVP_idea_ofb(void), EVP_idea_cbc(void)" 4
392 .IX Item "EVP_idea_cbc() EVP_idea_ecb(void), EVP_idea_cfb(void), EVP_idea_ofb(void), EVP_idea_cbc(void)"
393 \&\s-1IDEA\s0 encryption algorithm in \s-1CBC\s0, \s-1ECB\s0, \s-1CFB\s0 and \s-1OFB\s0 modes respectively.
394 .Ip "EVP_rc2_cbc(void), EVP_rc2_ecb(void), EVP_rc2_cfb(void), EVP_rc2_ofb(void)" 4
395 .IX Item "EVP_rc2_cbc(void), EVP_rc2_ecb(void), EVP_rc2_cfb(void), EVP_rc2_ofb(void)"
396 \&\s-1RC2\s0 encryption algorithm in \s-1CBC\s0, \s-1ECB\s0, \s-1CFB\s0 and \s-1OFB\s0 modes respectively. This is a variable key
397 length cipher with an additional parameter called \*(L"effective key bits\*(R" or \*(L"effective key length\*(R".
398 By default both are set to 128 bits.
399 .Ip "EVP_rc2_40_cbc(void), EVP_rc2_64_cbc(void)" 4
400 .IX Item "EVP_rc2_40_cbc(void), EVP_rc2_64_cbc(void)"
401 \&\s-1RC2\s0 algorithm in \s-1CBC\s0 mode with a default key length and effective key length of 40 and 64 bits.
402 These are obsolete and new code should use \fIEVP_rc2_cbc()\fR, \fIEVP_CIPHER_CTX_set_key_length()\fR and
403 \&\fIEVP_CIPHER_CTX_ctrl()\fR to set the key length and effective key length.
404 .Ip "EVP_bf_cbc(void), EVP_bf_ecb(void), EVP_bf_cfb(void), EVP_bf_ofb(void);" 4
405 .IX Item "EVP_bf_cbc(void), EVP_bf_ecb(void), EVP_bf_cfb(void), EVP_bf_ofb(void);"
406 Blowfish encryption algorithm in \s-1CBC\s0, \s-1ECB\s0, \s-1CFB\s0 and \s-1OFB\s0 modes respectively. This is a variable key
407 length cipher.
408 .Ip "EVP_cast5_cbc(void), EVP_cast5_ecb(void), EVP_cast5_cfb(void), EVP_cast5_ofb(void)" 4
409 .IX Item "EVP_cast5_cbc(void), EVP_cast5_ecb(void), EVP_cast5_cfb(void), EVP_cast5_ofb(void)"
410 \&\s-1CAST\s0 encryption algorithm in \s-1CBC\s0, \s-1ECB\s0, \s-1CFB\s0 and \s-1OFB\s0 modes respectively. This is a variable key
411 length cipher.
412 .Ip "EVP_rc5_32_12_16_cbc(void), EVP_rc5_32_12_16_ecb(void), EVP_rc5_32_12_16_cfb(void), EVP_rc5_32_12_16_ofb(void)" 4
413 .IX Item "EVP_rc5_32_12_16_cbc(void), EVP_rc5_32_12_16_ecb(void), EVP_rc5_32_12_16_cfb(void), EVP_rc5_32_12_16_ofb(void)"
414 \&\s-1RC5\s0 encryption algorithm in \s-1CBC\s0, \s-1ECB\s0, \s-1CFB\s0 and \s-1OFB\s0 modes respectively. This is a variable key length
415 cipher with an additional \*(L"number of rounds\*(R" parameter. By default the key length is set to 128
416 bits and 12 rounds.
417 .SH "NOTES"
418 .IX Header "NOTES"
419 Where possible the \fB\s-1EVP\s0\fR interface to symmetric ciphers should be used in
420 preference to the low level interfaces. This is because the code then becomes
421 transparent to the cipher used and much more flexible.
422 .PP
423 \&\s-1PKCS\s0 padding works by adding \fBn\fR padding bytes of value \fBn\fR to make the total 
424 length of the encrypted data a multiple of the block size. Padding is always
425 added so if the data is already a multiple of the block size \fBn\fR will equal
426 the block size. For example if the block size is 8 and 11 bytes are to be
427 encrypted then 5 padding bytes of value 5 will be added.
428 .PP
429 When decrypting the final block is checked to see if it has the correct form.
430 .PP
431 Although the decryption operation can produce an error, it is not a strong
432 test that the input data or key is correct. A random block has better than
433 1 in 256 chance of being of the correct format and problems with the
434 input data earlier on will not produce a final decrypt error.
435 .PP
436 The functions \fIEVP_EncryptInit()\fR, \fIEVP_EncryptUpdate()\fR, \fIEVP_EncryptFinal()\fR,
437 \&\fIEVP_DecryptInit()\fR, \fIEVP_DecryptUpdate()\fR, \fIEVP_CipherInit()\fR and \fIEVP_CipherUpdate()\fR
438 and \fIEVP_CIPHER_CTX_cleanup()\fR did not return errors in OpenSSL version 0.9.5a or
439 earlier. Software only versions of encryption algorithms will never return
440 error codes for these functions, unless there is a programming error (for example
441 and attempt to set the key before the cipher is set in \fIEVP_EncryptInit()\fR ).
442 .SH "BUGS"
443 .IX Header "BUGS"
444 For \s-1RC5\s0 the number of rounds can currently only be set to 8, 12 or 16. This is
445 a limitation of the current \s-1RC5\s0 code rather than the \s-1EVP\s0 interface.
446 .PP
447 It should be possible to disable \s-1PKCS\s0 padding: currently it isn't.
448 .PP
449 \&\s-1EVP_MAX_KEY_LENGTH\s0 and \s-1EVP_MAX_IV_LENGTH\s0 only refer to the internal ciphers with
450 default key lengths. If custom ciphers exceed these values the results are
451 unpredictable. This is because it has become standard practice to define a 
452 generic key as a fixed unsigned char array containing \s-1EVP_MAX_KEY_LENGTH\s0 bytes.
453 .PP
454 The \s-1ASN1\s0 code is incomplete (and sometimes inaccurate) it has only been tested
455 for certain common S/MIME ciphers (\s-1RC2\s0, \s-1DES\s0, triple \s-1DES\s0) in \s-1CBC\s0 mode.
456 .SH "EXAMPLES"
457 .IX Header "EXAMPLES"
458 Get the number of rounds used in \s-1RC5:\s0
459 .PP
460 .Vb 2
461 \& int nrounds;
462 \& EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC5_ROUNDS, 0, &i);
463 .Ve
464 Get the \s-1RC2\s0 effective key length:
465 .PP
466 .Vb 2
467 \& int key_bits;
468 \& EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC2_KEY_BITS, 0, &i);
469 .Ve
470 Set the number of rounds used in \s-1RC5:\s0
471 .PP
472 .Vb 2
473 \& int nrounds;
474 \& EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC5_ROUNDS, i, NULL);
475 .Ve
476 Set the number of rounds used in \s-1RC2:\s0
477 .PP
478 .Vb 2
479 \& int nrounds;
480 \& EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC2_KEY_BITS, i, NULL);
481 .Ve
482 .SH "SEE ALSO"
483 .IX Header "SEE ALSO"
484 evp(3)
485 .SH "HISTORY"
486 .IX Header "HISTORY"