Debian Codegraph @

upstream/debian-unstable/man3/PKCS7_encrypt.3ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "PKCS7_ENCRYPT 3SSL"
58 .TH PKCS7_ENCRYPT 3SSL 2026-04-07 3.6.2 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 PKCS7_encrypt_ex, PKCS7_encrypt
65 \&\- create a PKCS#7 envelopedData structure
66 .SH SYNOPSIS
67 .IX Header "SYNOPSIS"
68 .Vb 1
69 \& #include <openssl/pkcs7.h>
70 \&
71 \& PKCS7 *PKCS7_encrypt_ex(STACK_OF(X509) *certs, BIO *in,
72 \& const EVP_CIPHER *cipher, int flags,
73 \& OSSL_LIB_CTX *libctx, const char *propq);
74 \& PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,
75 \& int flags);
76 .Ve
77 .SH DESCRIPTION
78 .IX Header "DESCRIPTION"
79 \&\fBPKCS7_encrypt_ex()\fR creates and returns a PKCS#7 envelopedData structure.
80 \&\fIcerts\fR is a list of recipient certificates. \fIin\fR is the content to be
81 encrypted. \fIcipher\fR is the symmetric cipher to use. \fIflags\fR is an optional set
82 of flags. The library context \fIlibctx\fR and the property query \fIpropq\fR are used
83 when retrieving algorithms from providers.
84 .PP
85 Only RSA keys are supported in PKCS#7 and envelopedData so the recipient
86 certificates supplied to this function must all contain RSA public keys, though
87 they do not have to be signed using the RSA algorithm.
88 .PP
89 \&\fBEVP_des_ede3_cbc()\fR (triple DES) is the algorithm of choice for S/MIME use
90 because most clients will support it.
91 .PP
92 Some old "export grade" clients may only support weak encryption using 40 or 64
93 bit RC2. These can be used by passing \fBEVP_rc2_40_cbc()\fR and \fBEVP_rc2_64_cbc()\fR
94 respectively.
95 .PP
96 The algorithm passed in the \fBcipher\fR parameter must support ASN1 encoding of
97 its parameters.
98 .PP
99 Many browsers implement a "sign and encrypt" option which is simply an S/MIME
100 envelopedData containing an S/MIME signed message. This can be readily produced
101 by storing the S/MIME signed message in a memory BIO and passing it to
102 \&\fBPKCS7_encrypt()\fR.
103 .PP
104 The following flags can be passed in the \fBflags\fR parameter.
105 .PP
106 If the \fBPKCS7_TEXT\fR flag is set MIME headers for type \fBtext/plain\fR are
107 prepended to the data.
108 .PP
109 Normally the supplied content is translated into MIME canonical format (as
110 required by the S/MIME specifications) if \fBPKCS7_BINARY\fR is set no translation
111 occurs. This option should be used if the supplied data is in binary format
112 otherwise the translation will corrupt it. If \fBPKCS7_BINARY\fR is set then
113 \&\fBPKCS7_TEXT\fR is ignored.
114 .PP
115 If the \fBPKCS7_STREAM\fR flag is set a partial \fBPKCS7\fR structure is output
116 suitable for streaming I/O: no data is read from the BIO \fBin\fR.
117 .PP
118 If the flag \fBPKCS7_STREAM\fR is set the returned \fBPKCS7\fR structure is \fBnot\fR
119 complete and outputting its contents via a function that does not
120 properly finalize the \fBPKCS7\fR structure will give unpredictable
121 results.
122 .PP
123 Several functions including \fBSMIME_write_PKCS7()\fR, \fBi2d_PKCS7_bio_stream()\fR,
124 \&\fBPEM_write_bio_PKCS7_stream()\fR finalize the structure. Alternatively finalization
125 can be performed by obtaining the streaming ASN1 \fBBIO\fR directly using
126 \&\fBBIO_new_PKCS7()\fR.
127 .PP
128 \&\fBPKCS7_encrypt()\fR is similar to \fBPKCS7_encrypt_ex()\fR but uses default
129 values of NULL for the library context \fIlibctx\fR and the property query \fIpropq\fR.
130 .SH "RETURN VALUES"
131 .IX Header "RETURN VALUES"
132 \&\fBPKCS7_encrypt_ex()\fR and \fBPKCS7_encrypt()\fR return either a PKCS7 structure
133 or NULL if an error occurred. The error can be obtained from \fBERR_get_error\fR\|(3).
134 .SH "SEE ALSO"
135 .IX Header "SEE ALSO"
136 \&\fBERR_get_error\fR\|(3), \fBPKCS7_decrypt\fR\|(3)
137 .SH HISTORY
138 .IX Header "HISTORY"
139 The function \fBPKCS7_encrypt_ex()\fR was added in OpenSSL 3.0.
140 .PP
141 The \fBPKCS7_STREAM\fR flag was added in OpenSSL 1.0.0.
142 .SH COPYRIGHT
143 .IX Header "COPYRIGHT"
144 Copyright 2002\-2020 The OpenSSL Project Authors. All Rights Reserved.
145 .PP
146 Licensed under the Apache License 2.0 (the "License"). You may not use
147 this file except in compliance with the License. You can obtain a copy
148 in the file LICENSE in the source distribution or at
149 <https://www.openssl.org/source/license.html>.