blob: 1330464441bb8f4b09f20a0fbb36327138335a56 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
.Dd $Mdocdate: November 11 2015 $
.Dt CMS_COMPRESS 3
.Os
.Sh NAME
.Nm CMS_compress
.Nd create a CMS CompressedData structure
.Sh SYNOPSIS
.In openssl/cms.h
.Ft CMS_ContentInfo *
.Fo CMS_compress
.Fa "BIO *in"
.Fa "int comp_nid"
.Fa "unsigned int flags"
.Fc
.Sh DESCRIPTION
.Fn CMS_compress
creates and returns a CMS CompressedData structure.
.Fa comp_nid
is the compression algorithm to use or
.Dv NID_undef
to use the default algorithm (zlib compression).
.Fa in
is the content to be compressed.
.Fa flags
is an optional set of flags.
.Sh NOTES
The only currently supported compression algorithm is zlib using the NID
.Dv NID_zlib_compression .
.Pp
If zlib support is not compiled into OpenSSL then
.Fn CMS_compress
will return an error.
.Pp
If the
.Dv CMS_TEXT
flag is set, MIME headers for type
.Sy text/plain
are prepended to the data.
.Pp
Normally the supplied content is translated into MIME canonical format
(as required by the S/MIME specifications); if
.Dv CMS_BINARY
is set, no translation occurs.
This option should be used if the supplied data is in binary format;
otherwise the translation will corrupt it.
If
.Dv CMS_BINARY
is set then
.Dv CMS_TEXT
is ignored.
.Pp
If the
.Dv CMS_STREAM
flag is set a partial
.Vt CMS_ContentInfo
structure is returned suitable for streaming I/O: no data is read from
the
.Vt BIO
.Fa in .
.Pp
The compressed data is included in the
.Vt CMS_ContentInfo
structure, unless
.Dv CMS_DETACHED
is set, in which case it is omitted.
This is rarely used in practice and is not supported by
.Xr SMIME_write_CMS 3 .
.Sh NOTES
If the flag
.Dv CMS_STREAM
is set, the returned
.Vt CMS_ContentInfo
structure is
.Em not
complete and outputting its contents via a function that does not
properly finalize the
.Vt CMS_ContentInfo
structure will give unpredictable results.
.Pp
Several functions including
.Xr SMIME_write_CMS 3 ,
.Xr i2d_CMS_bio_stream 3 ,
.Xr PEM_write_bio_CMS_stream 3
finalize the structure.
Alternatively finalization can be performed by obtaining the streaming
ASN1
.Vt BIO
directly using
.Xr BIO_new_CMS 3 .
.Pp
Additional compression parameters such as the zlib compression level
cannot currently be set.
.Sh RETURN VALUES
.Fn CMS_compress
returns either a
.Vt CMS_ContentInfo
structure or
.Dv NULL
if an error occurred.
The error can be obtained from
.Xr ERR_get_error 3 .
.Sh SEE ALSO
.Xr CMS_uncompress 3 ,
.Xr ERR_get_error 3
.Sh HISTORY
.Fn CMS_compress
was added to OpenSSL 0.9.8.
The
.Dv CMS_STREAM
flag was first supported in OpenSSL 1.0.0.
|