summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/PKCS7_encrypt.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/PKCS7_encrypt.3')
-rw-r--r--src/lib/libcrypto/man/PKCS7_encrypt.3113
1 files changed, 113 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/PKCS7_encrypt.3 b/src/lib/libcrypto/man/PKCS7_encrypt.3
new file mode 100644
index 0000000000..860a9181b8
--- /dev/null
+++ b/src/lib/libcrypto/man/PKCS7_encrypt.3
@@ -0,0 +1,113 @@
1.Dd $Mdocdate: November 3 2016 $
2.Dt PKCS7_ENCRYPT 3
3.Os
4.Sh NAME
5.Nm PKCS7_encrypt
6.Nd create a PKCS#7 envelopedData structure
7.Sh SYNOPSIS
8.In openssl/pkcs7.h
9.Ft PKCS7 *
10.Fo PKCS7_encrypt
11.Fa "STACK_OF(X509) *certs"
12.Fa "BIO *in"
13.Fa "const EVP_CIPHER *cipher"
14.Fa "int flags"
15.Fc
16.Sh DESCRIPTION
17.Fn PKCS7_encrypt
18creates and returns a PKCS#7 envelopedData structure.
19.Fa certs
20is a list of recipient certificates.
21.Fa in
22is the content to be encrypted.
23.Fa cipher
24is the symmetric cipher to use.
25.Fa flags
26is an optional set of flags.
27.Pp
28Only RSA keys are supported in PKCS#7 and envelopedData so the recipient
29certificates supplied to this function must all contain RSA public keys,
30though they do not have to be signed using the RSA algorithm.
31.Pp
32The algorithm passed in the
33.Fa cipher
34parameter must support ASN1 encoding of its parameters.
35.Pp
36Many browsers implement a "sign and encrypt" option which is simply an
37S/MIME envelopedData containing an S/MIME signed message.
38This can be readily produced by storing the S/MIME signed message in a
39memory
40.Vt BIO
41and passing it to
42.Fn PKCS7_encrypt .
43.Pp
44The following flags can be passed in the
45.Fa flags
46parameter.
47.Pp
48If the
49.Dv PKCS7_TEXT
50flag is set, MIME headers for type
51.Sy text/plain
52are prepended to the data.
53.Pp
54Normally the supplied content is translated into MIME canonical format
55(as required by the S/MIME specifications).
56If
57.Dv PKCS7_BINARY
58is set, no translation occurs.
59This option should be used if the supplied data is in binary format;
60otherwise, the translation will corrupt it.
61If
62.Dv PKCS7_BINARY
63is set, then
64.Dv PKCS7_TEXT
65is ignored.
66.Pp
67If the
68.Dv PKCS7_STREAM
69flag is set, a partial
70.Vt PKCS7
71structure is output suitable for streaming I/O: no data is read from
72.Fa in .
73.Pp
74If the flag
75.Dv PKCS7_STREAM
76is set, the returned
77.Vt PKCS7
78structure is
79.Sy not
80complete and outputting its contents via a function that does not
81properly finalize the
82.Vt PKCS7
83structure will give unpredictable results.
84.Pp
85Several functions including
86.Xr SMIME_write_PKCS7 3 ,
87.Xr i2d_PKCS7_bio_stream 3 ,
88and
89.Xr PEM_write_bio_PKCS7_stream 3
90finalize the structure.
91Alternatively finalization can be performed by obtaining the streaming
92ASN1
93.Vt BIO
94directly using
95.Xr BIO_new_PKCS7 3 .
96.Sh RETURN VALUES
97.Fn PKCS7_encrypt
98returns either a
99.Vt PKCS7
100structure or
101.Dv NULL
102if an error occurred.
103The error can be obtained from
104.Xr ERR_get_error 3 .
105.Sh SEE ALSO
106.Xr ERR_get_error 3 ,
107.Xr PKCS7_decrypt 3
108.Sh HISTORY
109.Xr PKCS7_decrypt 3
110was added to OpenSSL 0.9.5.
111The
112.Dv PKCS7_STREAM
113flag was first supported in OpenSSL 1.0.0.