Deleted Added
full compact
EVP_EncryptInit.3 (206048) EVP_EncryptInit.3 (215698)
1.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.37
1.\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.07)
2.\"
3.\" Standard preamble:
4.\" ========================================================================
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
5.de Sp \" Vertical space (when we can't use .PP)
6.if t .sp .5v
7.if n .sp
8..
9.de Vb \" Begin verbatim text
10.ft CW
11.nf
12.ne \\$1
13..
14.de Ve \" End verbatim text
15.ft R
16.fi
17..
18.\" Set up some character translations and predefined strings. \*(-- will
19.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
20.\" double quote, and \*(R" will give a right double quote. \*(C+ will
21.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
22.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
23.\" nothing in troff, for use with C<>.
24.tr \(*W-
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
25.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26.ie n \{\
27. ds -- \(*W-
28. ds PI pi
29. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
31. ds L" ""
32. ds R" ""
33. ds C` ""
34. ds C' ""
35'br\}
36.el\{\
37. ds -- \|\(em\|
38. ds PI \(*p
39. ds L" ``
40. ds R" ''
41'br\}
42.\"
43.\" Escape single quotes in literal strings from groff's Unicode transform.
44.ie \n(.g .ds Aq \(aq
45.el .ds Aq '
46.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
47.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
48.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
49.\" entries marked with X<> in POD. Of course, you'll have to process the
50.\" output yourself in some meaningful fashion.
55.if \nF \{\
51.ie \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
52. de IX
53. tm Index:\\$1\t\\n%\t"\\$2"
54..
55. nr % 0
56. rr F
57.\}
58.el \{\
59. de IX
60..
61.\}
62.\"
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1

--- 48 unchanged lines hidden (view full) ---

124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "EVP_EncryptInit 3"
63.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
64.\" Fear. Run. Save yourself. No user-serviceable parts.
65. \" fudge factors for nroff and troff
66.if n \{\
67. ds #H 0
68. ds #V .8m
69. ds #F .3m
70. ds #[ \f1

--- 48 unchanged lines hidden (view full) ---

119. ds Th \o'LP'
120. ds ae ae
121. ds Ae AE
122.\}
123.rm #[ #] #H #V #F C
124.\" ========================================================================
125.\"
126.IX Title "EVP_EncryptInit 3"
132.TH EVP_EncryptInit 3 "2010-03-24" "0.9.8n" "OpenSSL"
127.TH EVP_EncryptInit 3 "2010-11-16" "0.9.8p" "OpenSSL"
128.\" For nroff, turn off justification. Always turn off hyphenation; it makes
129.\" way too many mistakes in technical documents.
130.if n .ad l
131.nh
133.SH "NAME"
134EVP_CIPHER_CTX_init, EVP_EncryptInit_ex, EVP_EncryptUpdate,
135EVP_EncryptFinal_ex, EVP_DecryptInit_ex, EVP_DecryptUpdate,
136EVP_DecryptFinal_ex, EVP_CipherInit_ex, EVP_CipherUpdate,
137EVP_CipherFinal_ex, EVP_CIPHER_CTX_set_key_length,
138EVP_CIPHER_CTX_ctrl, EVP_CIPHER_CTX_cleanup, EVP_EncryptInit,
139EVP_EncryptFinal, EVP_DecryptInit, EVP_DecryptFinal,
140EVP_CipherInit, EVP_CipherFinal, EVP_get_cipherbyname,

--- 4 unchanged lines hidden (view full) ---

145EVP_CIPHER_CTX_iv_length, EVP_CIPHER_CTX_get_app_data,
146EVP_CIPHER_CTX_set_app_data, EVP_CIPHER_CTX_type, EVP_CIPHER_CTX_flags,
147EVP_CIPHER_CTX_mode, EVP_CIPHER_param_to_asn1, EVP_CIPHER_asn1_to_param,
148EVP_CIPHER_CTX_set_padding \- EVP cipher routines
149.SH "SYNOPSIS"
150.IX Header "SYNOPSIS"
151.Vb 1
152\& #include <openssl/evp.h>
132.SH "NAME"
133EVP_CIPHER_CTX_init, EVP_EncryptInit_ex, EVP_EncryptUpdate,
134EVP_EncryptFinal_ex, EVP_DecryptInit_ex, EVP_DecryptUpdate,
135EVP_DecryptFinal_ex, EVP_CipherInit_ex, EVP_CipherUpdate,
136EVP_CipherFinal_ex, EVP_CIPHER_CTX_set_key_length,
137EVP_CIPHER_CTX_ctrl, EVP_CIPHER_CTX_cleanup, EVP_EncryptInit,
138EVP_EncryptFinal, EVP_DecryptInit, EVP_DecryptFinal,
139EVP_CipherInit, EVP_CipherFinal, EVP_get_cipherbyname,

--- 4 unchanged lines hidden (view full) ---

144EVP_CIPHER_CTX_iv_length, EVP_CIPHER_CTX_get_app_data,
145EVP_CIPHER_CTX_set_app_data, EVP_CIPHER_CTX_type, EVP_CIPHER_CTX_flags,
146EVP_CIPHER_CTX_mode, EVP_CIPHER_param_to_asn1, EVP_CIPHER_asn1_to_param,
147EVP_CIPHER_CTX_set_padding \- EVP cipher routines
148.SH "SYNOPSIS"
149.IX Header "SYNOPSIS"
150.Vb 1
151\& #include <openssl/evp.h>
153.Ve
154.PP
155.Vb 1
152\&
156\& void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);
153\& void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);
157.Ve
158.PP
159.Vb 6
154\&
160\& int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
161\& ENGINE *impl, unsigned char *key, unsigned char *iv);
162\& int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
163\& int *outl, unsigned char *in, int inl);
164\& int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out,
165\& int *outl);
155\& int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
156\& ENGINE *impl, unsigned char *key, unsigned char *iv);
157\& int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
158\& int *outl, unsigned char *in, int inl);
159\& int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out,
160\& int *outl);
166.Ve
167.PP
168.Vb 6
161\&
169\& int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
170\& ENGINE *impl, 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_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,
174\& int *outl);
162\& int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
163\& ENGINE *impl, unsigned char *key, unsigned char *iv);
164\& int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
165\& int *outl, unsigned char *in, int inl);
166\& int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,
167\& int *outl);
175.Ve
176.PP
177.Vb 6
168\&
178\& int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
179\& ENGINE *impl, unsigned char *key, unsigned char *iv, int enc);
180\& int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
181\& int *outl, unsigned char *in, int inl);
182\& int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,
183\& int *outl);
169\& int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
170\& ENGINE *impl, unsigned char *key, unsigned char *iv, int enc);
171\& int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
172\& int *outl, unsigned char *in, int inl);
173\& int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,
174\& int *outl);
184.Ve
185.PP
186.Vb 4
175\&
187\& int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
188\& unsigned char *key, unsigned char *iv);
189\& int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out,
190\& int *outl);
176\& int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
177\& unsigned char *key, unsigned char *iv);
178\& int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out,
179\& int *outl);
191.Ve
192.PP
193.Vb 4
180\&
194\& int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
195\& unsigned char *key, unsigned char *iv);
196\& int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
197\& int *outl);
181\& int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
182\& unsigned char *key, unsigned char *iv);
183\& int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
184\& int *outl);
198.Ve
199.PP
200.Vb 4
185\&
201\& int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
202\& unsigned char *key, unsigned char *iv, int enc);
203\& int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
204\& int *outl);
186\& int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
187\& unsigned char *key, unsigned char *iv, int enc);
188\& int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
189\& int *outl);
205.Ve
206.PP
207.Vb 4
190\&
208\& int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *x, int padding);
209\& int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
210\& int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
211\& int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
191\& int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *x, int padding);
192\& int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
193\& int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
194\& int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
212.Ve
213.PP
214.Vb 3
195\&
215\& const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
216\& #define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
217\& #define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
196\& const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
197\& #define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
198\& #define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
218.Ve
219.PP
220.Vb 7
221\& #define EVP_CIPHER_nid(e) ((e)->nid)
222\& #define EVP_CIPHER_block_size(e) ((e)->block_size)
223\& #define EVP_CIPHER_key_length(e) ((e)->key_len)
224\& #define EVP_CIPHER_iv_length(e) ((e)->iv_len)
225\& #define EVP_CIPHER_flags(e) ((e)->flags)
226\& #define EVP_CIPHER_mode(e) ((e)->flags) & EVP_CIPH_MODE)
199\&
200\& #define EVP_CIPHER_nid(e) ((e)\->nid)
201\& #define EVP_CIPHER_block_size(e) ((e)\->block_size)
202\& #define EVP_CIPHER_key_length(e) ((e)\->key_len)
203\& #define EVP_CIPHER_iv_length(e) ((e)\->iv_len)
204\& #define EVP_CIPHER_flags(e) ((e)\->flags)
205\& #define EVP_CIPHER_mode(e) ((e)\->flags) & EVP_CIPH_MODE)
227\& int EVP_CIPHER_type(const EVP_CIPHER *ctx);
206\& int EVP_CIPHER_type(const EVP_CIPHER *ctx);
228.Ve
229.PP
230.Vb 10
231\& #define EVP_CIPHER_CTX_cipher(e) ((e)->cipher)
232\& #define EVP_CIPHER_CTX_nid(e) ((e)->cipher->nid)
233\& #define EVP_CIPHER_CTX_block_size(e) ((e)->cipher->block_size)
234\& #define EVP_CIPHER_CTX_key_length(e) ((e)->key_len)
235\& #define EVP_CIPHER_CTX_iv_length(e) ((e)->cipher->iv_len)
236\& #define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data)
237\& #define EVP_CIPHER_CTX_set_app_data(e,d) ((e)->app_data=(char *)(d))
207\&
208\& #define EVP_CIPHER_CTX_cipher(e) ((e)\->cipher)
209\& #define EVP_CIPHER_CTX_nid(e) ((e)\->cipher\->nid)
210\& #define EVP_CIPHER_CTX_block_size(e) ((e)\->cipher\->block_size)
211\& #define EVP_CIPHER_CTX_key_length(e) ((e)\->key_len)
212\& #define EVP_CIPHER_CTX_iv_length(e) ((e)\->cipher\->iv_len)
213\& #define EVP_CIPHER_CTX_get_app_data(e) ((e)\->app_data)
214\& #define EVP_CIPHER_CTX_set_app_data(e,d) ((e)\->app_data=(char *)(d))
238\& #define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
215\& #define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
239\& #define EVP_CIPHER_CTX_flags(e) ((e)->cipher->flags)
240\& #define EVP_CIPHER_CTX_mode(e) ((e)->cipher->flags & EVP_CIPH_MODE)
241.Ve
242.PP
243.Vb 2
216\& #define EVP_CIPHER_CTX_flags(e) ((e)\->cipher\->flags)
217\& #define EVP_CIPHER_CTX_mode(e) ((e)\->cipher\->flags & EVP_CIPH_MODE)
218\&
244\& int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
245\& int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
246.Ve
247.SH "DESCRIPTION"
248.IX Header "DESCRIPTION"
249The \s-1EVP\s0 cipher routines are a high level interface to certain
250symmetric ciphers.
251.PP

--- 24 unchanged lines hidden (view full) ---

276It uses standard block padding (aka \s-1PKCS\s0 padding). The encrypted
277final data is written to \fBout\fR which should have sufficient space for
278one cipher block. The number of bytes written is placed in \fBoutl\fR. After
279this function is called the encryption operation is finished and no further
280calls to \fIEVP_EncryptUpdate()\fR should be made.
281.PP
282If padding is disabled then \fIEVP_EncryptFinal_ex()\fR will not encrypt any more
283data and it will return an error if any data remains in a partial block:
219\& int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
220\& int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
221.Ve
222.SH "DESCRIPTION"
223.IX Header "DESCRIPTION"
224The \s-1EVP\s0 cipher routines are a high level interface to certain
225symmetric ciphers.
226.PP

--- 24 unchanged lines hidden (view full) ---

251It uses standard block padding (aka \s-1PKCS\s0 padding). The encrypted
252final data is written to \fBout\fR which should have sufficient space for
253one cipher block. The number of bytes written is placed in \fBoutl\fR. After
254this function is called the encryption operation is finished and no further
255calls to \fIEVP_EncryptUpdate()\fR should be made.
256.PP
257If padding is disabled then \fIEVP_EncryptFinal_ex()\fR will not encrypt any more
258data and it will return an error if any data remains in a partial block:
284that is if the total data length is not a multiple of the block size.
259that is if the total data length is not a multiple of the block size.
285.PP
286\&\fIEVP_DecryptInit_ex()\fR, \fIEVP_DecryptUpdate()\fR and \fIEVP_DecryptFinal_ex()\fR are the
287corresponding decryption operations. \fIEVP_DecryptFinal()\fR will return an
288error code if padding is enabled and the final block is not correctly
289formatted. The parameters and restrictions are identical to the encryption
290operations except that if padding is enabled the decrypted data buffer \fBout\fR
291passed to \fIEVP_DecryptUpdate()\fR should have sufficient room for
292(\fBinl\fR + cipher_block_size) bytes unless the cipher block size is 1 in

--- 132 unchanged lines hidden (view full) ---

425.SH "CIPHER LISTING"
426.IX Header "CIPHER LISTING"
427All algorithms have a fixed key length unless otherwise stated.
428.IP "\fIEVP_enc_null()\fR" 4
429.IX Item "EVP_enc_null()"
430Null cipher: does nothing.
431.IP "EVP_des_cbc(void), EVP_des_ecb(void), EVP_des_cfb(void), EVP_des_ofb(void)" 4
432.IX Item "EVP_des_cbc(void), EVP_des_ecb(void), EVP_des_cfb(void), EVP_des_ofb(void)"
260.PP
261\&\fIEVP_DecryptInit_ex()\fR, \fIEVP_DecryptUpdate()\fR and \fIEVP_DecryptFinal_ex()\fR are the
262corresponding decryption operations. \fIEVP_DecryptFinal()\fR will return an
263error code if padding is enabled and the final block is not correctly
264formatted. The parameters and restrictions are identical to the encryption
265operations except that if padding is enabled the decrypted data buffer \fBout\fR
266passed to \fIEVP_DecryptUpdate()\fR should have sufficient room for
267(\fBinl\fR + cipher_block_size) bytes unless the cipher block size is 1 in

--- 132 unchanged lines hidden (view full) ---

400.SH "CIPHER LISTING"
401.IX Header "CIPHER LISTING"
402All algorithms have a fixed key length unless otherwise stated.
403.IP "\fIEVP_enc_null()\fR" 4
404.IX Item "EVP_enc_null()"
405Null cipher: does nothing.
406.IP "EVP_des_cbc(void), EVP_des_ecb(void), EVP_des_cfb(void), EVP_des_ofb(void)" 4
407.IX Item "EVP_des_cbc(void), EVP_des_ecb(void), EVP_des_cfb(void), EVP_des_ofb(void)"
433\&\s-1DES\s0 in \s-1CBC\s0, \s-1ECB\s0, \s-1CFB\s0 and \s-1OFB\s0 modes respectively.
408\&\s-1DES\s0 in \s-1CBC\s0, \s-1ECB\s0, \s-1CFB\s0 and \s-1OFB\s0 modes respectively.
434.IP "EVP_des_ede_cbc(void), \fIEVP_des_ede()\fR, EVP_des_ede_ofb(void), EVP_des_ede_cfb(void)" 4
435.IX Item "EVP_des_ede_cbc(void), EVP_des_ede(), EVP_des_ede_ofb(void), EVP_des_ede_cfb(void)"
436Two key triple \s-1DES\s0 in \s-1CBC\s0, \s-1ECB\s0, \s-1CFB\s0 and \s-1OFB\s0 modes respectively.
437.IP "EVP_des_ede3_cbc(void), \fIEVP_des_ede3()\fR, EVP_des_ede3_ofb(void), EVP_des_ede3_cfb(void)" 4
438.IX Item "EVP_des_ede3_cbc(void), EVP_des_ede3(), EVP_des_ede3_ofb(void), EVP_des_ede3_cfb(void)"
439Three key triple \s-1DES\s0 in \s-1CBC\s0, \s-1ECB\s0, \s-1CFB\s0 and \s-1OFB\s0 modes respectively.
440.IP "EVP_desx_cbc(void)" 4
441.IX Item "EVP_desx_cbc(void)"

--- 98 unchanged lines hidden (view full) ---

540.PP
541.Vb 2
542\& int key_bits;
543\& EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC2_KEY_BITS, key_bits, NULL);
544.Ve
545.PP
546Encrypt a string using blowfish:
547.PP
409.IP "EVP_des_ede_cbc(void), \fIEVP_des_ede()\fR, EVP_des_ede_ofb(void), EVP_des_ede_cfb(void)" 4
410.IX Item "EVP_des_ede_cbc(void), EVP_des_ede(), EVP_des_ede_ofb(void), EVP_des_ede_cfb(void)"
411Two key triple \s-1DES\s0 in \s-1CBC\s0, \s-1ECB\s0, \s-1CFB\s0 and \s-1OFB\s0 modes respectively.
412.IP "EVP_des_ede3_cbc(void), \fIEVP_des_ede3()\fR, EVP_des_ede3_ofb(void), EVP_des_ede3_cfb(void)" 4
413.IX Item "EVP_des_ede3_cbc(void), EVP_des_ede3(), EVP_des_ede3_ofb(void), EVP_des_ede3_cfb(void)"
414Three key triple \s-1DES\s0 in \s-1CBC\s0, \s-1ECB\s0, \s-1CFB\s0 and \s-1OFB\s0 modes respectively.
415.IP "EVP_desx_cbc(void)" 4
416.IX Item "EVP_desx_cbc(void)"

--- 98 unchanged lines hidden (view full) ---

515.PP
516.Vb 2
517\& int key_bits;
518\& EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC2_KEY_BITS, key_bits, NULL);
519.Ve
520.PP
521Encrypt a string using blowfish:
522.PP
548.Vb 14
523.Vb 10
549\& int do_crypt(char *outfile)
550\& {
551\& unsigned char outbuf[1024];
552\& int outlen, tmplen;
524\& int do_crypt(char *outfile)
525\& {
526\& unsigned char outbuf[1024];
527\& int outlen, tmplen;
553\& /* Bogus key and IV: we'd normally set these from
528\& /* Bogus key and IV: we\*(Aqd normally set these from
554\& * another source.
555\& */
556\& unsigned char key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
557\& unsigned char iv[] = {1,2,3,4,5,6,7,8};
558\& char intext[] = "Some Crypto Text";
559\& EVP_CIPHER_CTX ctx;
560\& FILE *out;
561\& EVP_CIPHER_CTX_init(&ctx);
562\& EVP_EncryptInit_ex(&ctx, EVP_bf_cbc(), NULL, key, iv);
529\& * another source.
530\& */
531\& unsigned char key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
532\& unsigned char iv[] = {1,2,3,4,5,6,7,8};
533\& char intext[] = "Some Crypto Text";
534\& EVP_CIPHER_CTX ctx;
535\& FILE *out;
536\& EVP_CIPHER_CTX_init(&ctx);
537\& EVP_EncryptInit_ex(&ctx, EVP_bf_cbc(), NULL, key, iv);
563.Ve
564.PP
565.Vb 25
538\&
566\& if(!EVP_EncryptUpdate(&ctx, outbuf, &outlen, intext, strlen(intext)))
567\& {
568\& /* Error */
569\& return 0;
570\& }
571\& /* Buffer passed to EVP_EncryptFinal() must be after data just
572\& * encrypted to avoid overwriting it.
573\& */

--- 15 unchanged lines hidden (view full) ---

589\& return 1;
590\& }
591.Ve
592.PP
593The ciphertext from the above example can be decrypted using the \fBopenssl\fR
594utility with the command line:
595.PP
596.Vb 1
539\& if(!EVP_EncryptUpdate(&ctx, outbuf, &outlen, intext, strlen(intext)))
540\& {
541\& /* Error */
542\& return 0;
543\& }
544\& /* Buffer passed to EVP_EncryptFinal() must be after data just
545\& * encrypted to avoid overwriting it.
546\& */

--- 15 unchanged lines hidden (view full) ---

562\& return 1;
563\& }
564.Ve
565.PP
566The ciphertext from the above example can be decrypted using the \fBopenssl\fR
567utility with the command line:
568.PP
569.Vb 1
597\& S<openssl bf -in cipher.bin -K 000102030405060708090A0B0C0D0E0F -iv 0102030405060708 -d>
570\& S<openssl bf \-in cipher.bin \-K 000102030405060708090A0B0C0D0E0F \-iv 0102030405060708 \-d>
598.Ve
599.PP
600General encryption, decryption function example using \s-1FILE\s0 I/O and \s-1RC2\s0 with an
60180 bit key:
602.PP
571.Ve
572.PP
573General encryption, decryption function example using \s-1FILE\s0 I/O and \s-1RC2\s0 with an
57480 bit key:
575.PP
603.Vb 16
576.Vb 10
604\& int do_crypt(FILE *in, FILE *out, int do_encrypt)
605\& {
606\& /* Allow enough space in output buffer for additional block */
607\& inbuf[1024], outbuf[1024 + EVP_MAX_BLOCK_LENGTH];
608\& int inlen, outlen;
577\& int do_crypt(FILE *in, FILE *out, int do_encrypt)
578\& {
579\& /* Allow enough space in output buffer for additional block */
580\& inbuf[1024], outbuf[1024 + EVP_MAX_BLOCK_LENGTH];
581\& int inlen, outlen;
609\& /* Bogus key and IV: we'd normally set these from
582\& /* Bogus key and IV: we\*(Aqd normally set these from
610\& * another source.
611\& */
612\& unsigned char key[] = "0123456789";
613\& unsigned char iv[] = "12345678";
583\& * another source.
584\& */
585\& unsigned char key[] = "0123456789";
586\& unsigned char iv[] = "12345678";
614\& /* Don't set key or IV because we will modify the parameters */
587\& /* Don\*(Aqt set key or IV because we will modify the parameters */
615\& EVP_CIPHER_CTX_init(&ctx);
616\& EVP_CipherInit_ex(&ctx, EVP_rc2(), NULL, NULL, NULL, do_encrypt);
617\& EVP_CIPHER_CTX_set_key_length(&ctx, 10);
618\& /* We finished modifying parameters so now we can set key and IV */
619\& EVP_CipherInit_ex(&ctx, NULL, NULL, key, iv, do_encrypt);
588\& EVP_CIPHER_CTX_init(&ctx);
589\& EVP_CipherInit_ex(&ctx, EVP_rc2(), NULL, NULL, NULL, do_encrypt);
590\& EVP_CIPHER_CTX_set_key_length(&ctx, 10);
591\& /* We finished modifying parameters so now we can set key and IV */
592\& EVP_CipherInit_ex(&ctx, NULL, NULL, key, iv, do_encrypt);
620.Ve
621.PP
622.Vb 19
593\&
623\& for(;;)
624\& {
625\& inlen = fread(inbuf, 1, 1024, in);
626\& if(inlen <= 0) break;
627\& if(!EVP_CipherUpdate(&ctx, outbuf, &outlen, inbuf, inlen))
628\& {
629\& /* Error */
630\& EVP_CIPHER_CTX_cleanup(&ctx);
631\& return 0;
632\& }
633\& fwrite(outbuf, 1, outlen, out);
634\& }
635\& if(!EVP_CipherFinal_ex(&ctx, outbuf, &outlen))
636\& {
637\& /* Error */
638\& EVP_CIPHER_CTX_cleanup(&ctx);
639\& return 0;
640\& }
641\& fwrite(outbuf, 1, outlen, out);
594\& for(;;)
595\& {
596\& inlen = fread(inbuf, 1, 1024, in);
597\& if(inlen <= 0) break;
598\& if(!EVP_CipherUpdate(&ctx, outbuf, &outlen, inbuf, inlen))
599\& {
600\& /* Error */
601\& EVP_CIPHER_CTX_cleanup(&ctx);
602\& return 0;
603\& }
604\& fwrite(outbuf, 1, outlen, out);
605\& }
606\& if(!EVP_CipherFinal_ex(&ctx, outbuf, &outlen))
607\& {
608\& /* Error */
609\& EVP_CIPHER_CTX_cleanup(&ctx);
610\& return 0;
611\& }
612\& fwrite(outbuf, 1, outlen, out);
642.Ve
643.PP
644.Vb 3
613\&
645\& EVP_CIPHER_CTX_cleanup(&ctx);
646\& return 1;
647\& }
648.Ve
649.SH "SEE ALSO"
650.IX Header "SEE ALSO"
651\&\fIevp\fR\|(3)
652.SH "HISTORY"
653.IX Header "HISTORY"
654\&\fIEVP_CIPHER_CTX_init()\fR, \fIEVP_EncryptInit_ex()\fR, \fIEVP_EncryptFinal_ex()\fR,
655\&\fIEVP_DecryptInit_ex()\fR, \fIEVP_DecryptFinal_ex()\fR, \fIEVP_CipherInit_ex()\fR,
656\&\fIEVP_CipherFinal_ex()\fR and \fIEVP_CIPHER_CTX_set_padding()\fR appeared in
657OpenSSL 0.9.7.
614\& EVP_CIPHER_CTX_cleanup(&ctx);
615\& return 1;
616\& }
617.Ve
618.SH "SEE ALSO"
619.IX Header "SEE ALSO"
620\&\fIevp\fR\|(3)
621.SH "HISTORY"
622.IX Header "HISTORY"
623\&\fIEVP_CIPHER_CTX_init()\fR, \fIEVP_EncryptInit_ex()\fR, \fIEVP_EncryptFinal_ex()\fR,
624\&\fIEVP_DecryptInit_ex()\fR, \fIEVP_DecryptFinal_ex()\fR, \fIEVP_CipherInit_ex()\fR,
625\&\fIEVP_CipherFinal_ex()\fR and \fIEVP_CIPHER_CTX_set_padding()\fR appeared in
626OpenSSL 0.9.7.