summaryrefslogtreecommitdiff
path: root/lib/libcrypto/man/crypto.3
blob: e63c1a78dfecb519daf5ae96debc7145e61f9dc6 (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
.\"	$OpenBSD: crypto.3,v 1.29 2023/05/01 07:37:45 tb Exp $
.\"	OpenSSL a9c85cea Nov 11 09:33:55 2016 +0100
.\"
.\" This file is a derived work.
.\" The changes are covered by the following Copyright and license:
.\"
.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.\" The original file was written by Ulf Moeller <ulf@openssl.org> and
.\" Dr. Stephen Henson <steve@openssl.org>.
.\" Copyright (c) 2000, 2002 The OpenSSL Project.  All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\"
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\"
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in
.\"    the documentation and/or other materials provided with the
.\"    distribution.
.\"
.\" 3. All advertising materials mentioning features or use of this
.\"    software must display the following acknowledgment:
.\"    "This product includes software developed by the OpenSSL Project
.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
.\"
.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
.\"    endorse or promote products derived from this software without
.\"    prior written permission. For written permission, please contact
.\"    openssl-core@openssl.org.
.\"
.\" 5. Products derived from this software may not be called "OpenSSL"
.\"    nor may "OpenSSL" appear in their names without prior written
.\"    permission of the OpenSSL Project.
.\"
.\" 6. Redistributions of any form whatsoever must retain the following
.\"    acknowledgment:
.\"    "This product includes software developed by the OpenSSL Project
.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd $Mdocdate: May 1 2023 $
.Dt CRYPTO 3
.Os
.Sh NAME
.Nm crypto
.Nd OpenSSL cryptographic library
.Sh DESCRIPTION
The OpenSSL crypto library implements a wide range of cryptographic
algorithms used in various Internet standards.
The services provided by this library are used by the OpenSSL
implementations of TLS and S/MIME, and they have also been used to
implement SSH, OpenPGP, and other cryptographic standards.
.Pp
.Sy Symmetric ciphers
including AES, Blowfish, CAST, ChaCha20, IDEA, DES, RC2, and RC4
are provided by the generic interface
.Xr EVP_EncryptInit 3 .
Low-level stand-alone interfaces include
.Xr AES_encrypt 3 ,
.Xr BF_set_key 3 ,
.Xr ChaCha 3 ,
.Xr DES_set_key 3 ,
and
.Xr RC4 3 .
.Pp
.Sy Public key cryptography and key agreement
are provided by
.Xr DH_new 3 ,
.Xr ECDH_compute_key 3 ,
.Xr X25519 3 ,
.Xr DSA_new 3 ,
.Xr ECDSA_SIG_new 3 ,
.Xr RSA_new 3 ,
and
.Xr EVP_PKEY_new 3 .
.Pp
.Sy Certificates
are handled by
.Xr X509_new 3
and
.Xr X509v3_add_ext 3 .
.Pp
.Sy Authentication codes and hash functions
offered include
.Xr EVP_DigestInit 3 ,
.Xr CMAC_Init 3 ,
.Xr HMAC 3 ,
.Xr MD4 3 ,
.Xr MD5 3 ,
.Xr RIPEMD160 3 ,
.Xr SHA1 3 ,
and
.Xr SHA256 3 .
.Pp
.Sy Input, output, and data encoding
facilities include
.Xr ASN1_TYPE_get 3 ,
.Xr BIO_new 3 ,
.Xr CMS_ContentInfo_new 3 ,
.Xr evp 3 ,
.Xr EVP_EncodeInit 3 ,
.Xr PEM_read 3 ,
.Xr PKCS7_encrypt 3 ,
.Xr PKCS7_sign 3 ,
.Xr PKCS12_create 3 ,
and
.Xr SMIME_write_PKCS7 3 .
.Pp
.Sy Auxiliary features include:
.Bl -dash -compact
.It
configuration file handling: see
.Xr OPENSSL_config 3
.It
error reporting: see
.Xr ERR 3
.It
.Xr OCSP_REQUEST_new 3
.It
.Xr UI_new 3
.El
.Pp
.Sy Internal utilities
include
.Xr BIO_f_buffer 3 ,
.Xr BN_new 3 ,
.Xr EC_GROUP_new 3 ,
.Xr lh_new 3 ,
and
.Xr STACK_OF 3 .
.Sh NAMING CONVENTIONS
Elements used in the names of API functions include the following:
.Bl -tag -width Ds
.It add0
See
.Dq set0
below.
.It add1
See
.Dq set1
below.
.It BIO
basic input and/or output abstraction:
The function manipulates objects of the idiosyncratic OpenSSL
.Vt BIO
object type.
See
.Xr BIO_new 3 .
.It bio
The function uses a
.Vt BIO
object for input or output.
In many cases, simpler variants of the function are available
that operate directly on
.In stdio.h
.Vt FILE
objects or directly in RAM, usually using byte arrays.
.It BIO_f_
filter BIO:
The function returns a pointer to a static built-in object that,
when passed to
.Xr BIO_new 3 ,
results in the creation of a BIO object that can write data to
and/or read data from another
.Vt BIO
object.
.It BIO_s_
source and/or sink BIO:
The function returns a pointer to a static built-in object that,
when passed to
.Xr BIO_new 3 ,
results in the creation of a BIO object
that can write data to an external destination
and/or read data from an external source,
for example a file descriptor or object, a memory buffer, or the network.
.It BN
big number:
The function operates on
.Vt BIGNUM
objects representing integer numbers of variable, almost unlimited size.
See
.Xr BN_new 3 .
.It cb
callback:
The function takes or returns a function pointer
that is called by API functions from inside the library.
The function pointed to may be defined by the application program.
In some cases, API functions with
.Dq cb
in their name may return function pointers to internal functions
defined inside the library that are not API functions.
The element
.Dq cb
is also used in the names of some function pointer datatypes
declared with
.Sy typedef .
In a small number of cases, the all caps form
.Dq CB
is used with the same meaning.
.It CTX
context:
The function operates on a wrapper object around another object.
The purposes and properties of such
.Dq CTX
wrapper objects vary wildly depending on the objects in question.
A few function names use the lower case form
.Dq ctx
in the same sense.
.It d2i
DER to internal:
The function decodes input conforming to ASN.1 basic encoding rules (BER)
and either stores the result in an existing object
or in a newly allocated object.
The latter is usually preferable because
creating a new object is more robust and less error prone.
In spite of the name, the input usually does not need to conform to ASN.1
distinguished encoding rules (DER), which are more restrictive than BER.
.It EVP
digital EnVeloPe library:
See
.Xr evp 3 .
.It ex
This name element is used for two completely unrelated purposes.
.Pp
extended version:
The function is similar to an older function without the
.Dq ex
in its name, but takes one or more additional arguments
in order to make it more versatile.
In several cases, the older version is now deprecated.
.Pp
extra data:
Some object types support storing additional, application-specific data
inside objects in addition to the data the object is designed to hold.
The function sets, retrieves, or prepares for using such extra data.
Related function names usually contain
.Dq ex_data
or
.Dq ex_new_index .
See
.Xr CRYPTO_set_ex_data 3 .
.It fp
file pointer:
The function takes a
.Vt FILE *
argument.
Usually, the function is a variant of another function taking a
.Vt BIO *
argument instead.
.It i2d
internal to DER:
The function encodes an object passed as an argument
according to ASN.1 distinguished encoding rules (DER).
There are a few rare exceptions of functions that have
.Dq i2d
in their name but produce output anyway
that only conforms to ASN.1 basic encoding rules (BER) and not to DER.
.It get0
The function returns an internal pointer
owned by the object passed as an argument.
The returned pointer must not be freed by the calling code.
It will be freed automatically
when the object owning the pointer will be freed.
.It get1
The function returns a copy of a sub-object
of an object passed as an argument.
The caller is responsible for freeing the returned object
when it is no longer needed.
.Pp
If the object type is reference counted, usually the reference count
is incremented instead of copying the object.
Consequently, modifying the returned object may still impact all
objects containing references to it.
The caller is responsible for freeing the returned object
when it is no longer needed; for reference-counted objects still
referenced elsewhere, this will merely decrement the reference count.
.It get
Functions containing
.Dq get
in their name without a following digit may behave in
.Dq get0
or, more rarely, in
.Dq get1
style.
To find out which is the case, refer to the individual manual pages.
.It lh
linear hash:
The function manipulates a dynamic hash table.
See
.Xr lh_new 3 .
.It md
message digest.
Some function names use the all caps form
.Dq MD
in the same sense.
.It meth
The function manipulates an object holding a function table.
Usually, such function tables allow the application program
to implement additional cryptographic or I/O algorithms
and to use them with the same high-level API functions as the
algorithms provided by the library itself, or to replace the
implementations of algorithms provided by the library with
custom implementations provided by the application program.
Some API functions use the name elements
.Dq method
or
.Dq METHOD
in the same sense.
See also the
.Dq cb
entry in the present list.
.It nid
numerical identifier:
A non-standard, LibreSSL-specific
.Vt int
number associated with an ASN.1 object identifier.
In several cases, the all caps form
.Dq NID
is used in the same sense.
See
.Xr OBJ_nid2obj 3 .
.It obj
This name element and its all caps form
.Dq OBJ
usually refer to ASN.1 object identifiers represented by the
.Vt ASN1_OBJECT
data type.
See
.Xr ASN1_OBJECT_new 3 .
.It PKEY
In most cases, this name element and its lower case form
.Dq pkey
mean
.Dq private key ,
but for both forms, there are some cases where they mean
.Dq public key
instead.
.It set0
The function transfers ownership of a pointer passed as an argument
to an object passed as another argument,
by storing the pointer inside the object.
The transferred pointer must not be freed by the calling code.
It will be freed automatically
when the object now owning the pointer will be freed.
.It set1
The function copies the content of one object passed as an argument
into another object also passed as an argument.
When the calling code no longer needs the copied object,
it can free that object.
.Pp
In some cases, if the object to be copied is reference counted,
the function does not actually copy the object but merely increments
its reference count and stores the pointer to it in the other object.
When the calling code no longer needs its original pointer to
the now inner object, it can free the original pointer, thus
decrementing the reference count of the inner object
and transferring ownership of the inner object to the outer object.
The inner object will then be freed automatically
when the outer object is freed later on.
.It set
Functions containing
.Dq set
in their name without a following digit may behave in
.Dq set0
or, more rarely, in
.Dq set1
style.
To find out which is the case, refer to the individual manual pages.
.It sk
stack:
The function manipulates a variable-sized array of pointers
in the idiosyncratic style described in
.Xr OPENSSL_sk_new 3 .
.It TS
X.509 time-stamp protocol:
See
.Xr TS_REQ_new 3 .
.It up_ref
The function increments the reference count of the argument by one.
Only a minority of object types support reference counting.
For those that do, if the reference count is greater than one,
the corresponding
.Dq free
function reverses the effect of one call to the
.Dq up_ref
function rather than freeing the object.
.El
.Sh SEE ALSO
.Xr openssl 1 ,
.Xr ssl 3