summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschwarze <>2021-12-09 15:11:48 +0000
committerschwarze <>2021-12-09 15:11:48 +0000
commitbc9c07cfafa32d8ca950bec3fbcfb549b72962ff (patch)
tree70b5f9dfdba9221ae9853166b4edaf6c5d58e9e8
parent5165d5492b21787880fe5f1c83625ebf368f5859 (diff)
downloadopenbsd-bc9c07cfafa32d8ca950bec3fbcfb549b72962ff.tar.gz
openbsd-bc9c07cfafa32d8ca950bec3fbcfb549b72962ff.tar.bz2
openbsd-bc9c07cfafa32d8ca950bec3fbcfb549b72962ff.zip
Add a section "NAMING CONVENTIONS".
There is no need to explain well-known acronyms that are widely used outside OpenSSL, too (like AES, ASN.1, CMS, ECDSA, PKCS...), but OpenSSL uses plenty of idiosyncratic naming elements that deserve to be explained (like d2i, ex, get0, ndef, sk, ...). Requested by jsing@; feedback and OK tb@.
-rw-r--r--src/lib/libcrypto/man/crypto.3321
1 files changed, 285 insertions, 36 deletions
diff --git a/src/lib/libcrypto/man/crypto.3 b/src/lib/libcrypto/man/crypto.3
index 6e98f643de..598eb30504 100644
--- a/src/lib/libcrypto/man/crypto.3
+++ b/src/lib/libcrypto/man/crypto.3
@@ -1,7 +1,24 @@
1.\" $OpenBSD: crypto.3,v 1.25 2020/06/24 17:00:38 schwarze Exp $ 1.\" $OpenBSD: crypto.3,v 1.26 2021/12/09 15:11:48 schwarze Exp $
2.\" OpenSSL a9c85cea Nov 11 09:33:55 2016 +0100 2.\" OpenSSL a9c85cea Nov 11 09:33:55 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> and 4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Ulf Moeller <ulf@openssl.org> and
5.\" Dr. Stephen Henson <steve@openssl.org>. 22.\" Dr. Stephen Henson <steve@openssl.org>.
6.\" Copyright (c) 2000, 2002 The OpenSSL Project. All rights reserved. 23.\" Copyright (c) 2000, 2002 The OpenSSL Project. All rights reserved.
7.\" 24.\"
@@ -49,7 +66,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 68.\"
52.Dd $Mdocdate: June 24 2020 $ 69.Dd $Mdocdate: December 9 2021 $
53.Dt CRYPTO 3 70.Dt CRYPTO 3
54.Os 71.Os
55.Sh NAME 72.Sh NAME
@@ -139,43 +156,275 @@ include
139.Xr lh_new 3 , 156.Xr lh_new 3 ,
140and 157and
141.Xr STACK_OF 3 . 158.Xr STACK_OF 3 .
159.Sh NAMING CONVENTIONS
160Elements used in the names of API functions include the following:
161.Bl -tag -width Ds
162.It add0
163See
164.Dq set0
165below.
166.It add1
167See
168.Dq set1
169below.
170.It BIO
171basic input and/or output abstraction:
172The function manipulates objects of the idiosyncratic OpenSSL
173.Vt BIO
174object type.
175See
176.Xr BIO_new 3 .
177.It bio
178The function uses a
179.Vt BIO
180object for input or output.
181In many cases, simpler variants of the function are available
182that operate directly on
183.In stdio.h
184.Vt FILE
185objects or directly in RAM, usually using byte arrays.
186.It BIO_f_
187filter BIO:
188The function returns a pointer to a static built-in object that,
189when passed to
190.Xr BIO_new 3 ,
191results in the creation of a BIO object that can write data to
192and/or read data from another
193.Vt BIO
194object.
195.It BIO_s_
196source and/or sink BIO:
197The function returns a pointer to a static built-in object that,
198when passed to
199.Xr BIO_new 3 ,
200results in the creation of a BIO object
201that can write data to an external destination
202and/or read data from an external source,
203for example a file descriptor or object, a memory buffer, or the network.
204.It BN
205big number:
206The function operates on
207.Vt BIGNUM
208objects representing integer numbers of variable, almost unlimited size.
209See
210.Xr BN_new 3 .
211.It cb
212callback:
213The function takes or returns a function pointer
214that is called by API functions from inside the library.
215The function pointed to may be defined by the application program.
216In some cases, API functions with
217.Dq cb
218in their name may return function pointers to internal functions
219defined inside the library that are not API functions.
220The element
221.Dq cb
222is also used in the names of some function pointer datatypes
223declared with
224.Sy typedef .
225In a small number of cases, the all caps form
226.Dq CB
227is used with the same meaning.
228.It CTX
229context:
230The function operates on a wrapper object around another object.
231The purposes and properties of such
232.Dq CTX
233wrapper objects vary wildly depending on the objects in question.
234A few function names use the lower case form
235.Dq ctx
236in the same sense.
237.It d2i
238DER to internal:
239The function decodes input conforming to ASN.1 basic encoding rules (BER)
240and either stores the result in an existing object
241or in a newly allocated object.
242The latter is usually preferable because
243creating a new object is more robust and less error prone.
244In spite of the name, the input usually does not need to conform to ASN.1
245distinguished encoding rules (DER), which are more restrictive than BER.
246.It EVP
247digital EnVeloPe library:
248See
249.Xr evp 3 .
250.It ex
251This name element is used for two completely unrelated purposes.
142.Pp 252.Pp
143Some of the newer functions follow a naming convention using the numbers 253extended version:
144.Sq 0 254The function is similar to an older function without the
145and 255.Dq ex
146.Sq 1 . 256in its name, but takes one or more additional arguments
147For example consider the names of these functions: 257in order to make it more versatile.
258In several cases, the older version is now deprecated.
148.Pp 259.Pp
149.Ft int 260extra data:
150.Fo X509_CRL_add0_revoked 261Some object types support storing additional, application-specific data
151.Fa "X509_CRL *crl" 262inside objects in addition to the data the object is designed to hold.
152.Fa "X509_REVOKED *rev" 263The function sets, retrieves, or prepares for using such extra data.
153.Fc 264Related function names usually contain
154.br 265.Dq ex_data
155.Ft int 266or
156.Fo X509_add1_trust_object 267.Dq ex_new_index .
157.Fa "X509 *x" 268See
158.Fa "ASN1_OBJECT *obj" 269.Xr CRYPTO_set_ex_data 3 .
159.Fc 270.It fp
271file pointer:
272The function takes a
273.Vt FILE *
274argument.
275Usually, the function is a variant of another function taking a
276.Vt BIO *
277argument instead.
278.It i2d
279internal to DER:
280The function encodes an object passed as an argument
281according to ASN.1 distinguished encoding rules (DER).
282There are a few rare excpetions of functions that have
283.Dq i2d
284in their name but produce output anyway
285that only conforms to ASN.1 basic encoding rules (BER) and not to DER.
286.It get0
287The function returns an internal pointer
288owned by the object passed as an argument.
289The returned pointer must not be freed by the calling code.
290It will be freed automatically
291when the object owning the pointer will be freed.
292.It get1
293The function returns a copy of a sub-object
294of an object passed as an argument.
295The caller is responsible for freeing the returned object
296when it is no longer needed.
160.Pp 297.Pp
161The 298If the object type is reference counted, usually the reference count
162.Sq 0 299is incremented instead of copying the object.
163version uses the supplied structure pointer directly in the parent and 300Consequently, modifying the returned object may still impact all
164it will be freed up when the parent is freed. 301objects containing references to it.
165In the above example 302The caller is responsible for freeing the returned object
166.Fa crl 303when it is no longer needed; for reference-counted objects still
167would be freed but 304referenced elsewhere, this will merely decrement the reference count.
168.Fa rev 305.It get
169would not. 306Functions containing
307.Dq get
308in their name without a following digit may behave in
309.Dq get0
310or, more rarely, in
311.Dq get1
312style.
313To find out which is the case, refer to the individual manual pages.
314.It lh
315linear hash:
316The function manipulates a dynamic hash table.
317See
318.Xr lh_new 3 .
319.It md
320message digest.
321Some function names use the all caps form
322.Dq MD
323in the same sense.
324.It meth
325The function manipulates an object holding a function table.
326Usually, such function tables allow the application program
327to implement additional cryptographic or I/O algorithms
328and to use them with the same high-level API functions as the
329algorithms provided by the library itself, or to replace the
330implementations of algorithms provided by the library with
331custom implementations provided by the application program.
332Some API functions use the name elements
333.Dq method
334or
335.Dq METHOD
336in the same sense.
337See also the
338.Dq cb
339entry in the present list.
340.It ndef
341indefinite length form:
342The function encodes according to ASN.1 basic encoding rules (BER)
343using the indefinite length form.
344Even if the function name also includes
345.Dq i2d ,
346the output does not conform to ASN.1 distinguished encoding rules (DER).
347See
348.Xr ASN1_item_ndef_i2d 3 .
349Some function names contain the all caps version
350.Dq NDEF
351with the same meaning.
352.It nid
353numerical identifier:
354A non-standard, LibreSSL-specific
355.Vt int
356number associated with an ASN.1 object identifier.
357In several cases, the all caps form
358.Dq NID
359is used in the same sense.
360See
361.Xr OBJ_nid2obj 3 .
362.It obj
363This name element and its all caps form
364.Dq OBJ
365usually refer to ASN.1 object identifiers represented by the
366.Vt ASN1_OBJECT
367data type.
368See
369.Xr ASN1_OBJECT_new 3 .
370.It PKEY
371In most cases, this name element and its lower case form
372.Dq pkey
373mean
374.Dq private key ,
375but for both forms, there are some cases where they mean
376.Dq public key
377instead.
378.It set0
379The function transfers ownership of a pointer passed as an argument
380to an object passed as another argument,
381by storing the pointer inside the object.
382The transferred pointer must not be freed by the calling code.
383It will be freed automatically
384when the object now owning the pointer will be freed.
385.It set1
386The function copies the content of one object passed as an argument
387into another object also passed as an argument.
388When the calling code no longer needs the copied object,
389it can free that object.
170.Pp 390.Pp
171The 391In some cases, if the object to be copied is reference counted,
172.Sq 1 392the function does not actually copy the object but merely increments
173function uses a copy of the supplied structure pointer (or in some cases 393its reference count and stores the pointer to it in the other object.
174increases its link count) in the parent and so both 394When the calling code no longer needs its original pointer to
175.Pf ( Fa x 395the now inner object, it can free the original pointer, thus
176and 396decrementing the reference count of the inner object
177.Fa obj 397and transferring ownership of the inner object to the outer object.
178above) should be freed up. 398The inner object will then be freed automatically
399when the outer object is freed later on.
400.It set
401Functions containing
402.Dq set
403in their name without a following digit may behave in
404.Dq set0
405or, more rarely, in
406.Dq set1
407style.
408To find out which is the case, refer to the individual manual pages.
409.It sk
410stack:
411The function manipulates a variable-sized array of pointers
412in the idiosyncratic style described in
413.Xr OPENSSL_sk_new 3 .
414.It TS
415X.509 time-stamp protocol:
416See
417.Xr TS_REQ_new 3 .
418.It up_ref
419The function increments the reference count of the argument by one.
420Only a minority of object types support reference counting.
421For those that do, if the reference count is greater than one,
422the corresponding
423.Dq free
424function reverses the effect of one call to the
425.Dq up_ref
426function rather than freeing the object.
427.El
179.Sh SEE ALSO 428.Sh SEE ALSO
180.Xr openssl 1 , 429.Xr openssl 1 ,
181.Xr ssl 3 430.Xr ssl 3