1 This is ksba.info, produced by makeinfo version 6.8 from ksba.texi.
3 INFO-DIR-SECTION GNU libraries
5 * libksba: (ksba). An X.509 Library.
8 This file documents the KSBA library to access X.509 and CMS data
11 This is edition 1.6.5, last updated 14 November 2023, of 'The KSBA
12 Reference Manual', for Version 1.6.5.
14 Copyright (C) 2002, 2003, 2004 g10 Code GmbH
16 Permission is granted to copy, distribute and/or modify this document
17 under the terms of the GNU General Public License as published by the
18 Free Software Foundation; either version 3 of the License, or (at your
19 option) any later version. The text of the license can be found in the
20 section entitled "Copying".
23 File: ksba.info, Node: Top, Next: Introduction, Up: (dir)
28 This is edition 1.6.5, last updated 14 November 2023, of 'The KSBA
29 Reference Manual', for Version 1.6.5 of the KSBA library.
31 Copyright (C) 2002, 2003, 2004 g10 Code GmbH
33 Permission is granted to copy, distribute and/or modify this document
34 under the terms of the GNU General Public License as published by the
35 Free Software Foundation; either version 3 of the License, or (at your
36 option) any later version. The text of the license can be found in the
37 section entitled "Copying".
41 * Introduction:: How to use this manual.
42 * Preparation:: What you should do before using the library.
43 * Certificate Handling:: How to work with X.509 certificates.
44 * CMS:: How to work with CMS (PKCS#7) messages.
45 * CRLs:: How to work with Certificate Revocation Lists.
46 * PKCS10:: How to request certificates.
47 * Utilities:: Various utility functions.
48 * Error Handling:: Error numbers and their meanings.
52 * Component Labels:: Labels used in string representations.
53 * Copying:: The GNU General Public License says how you
54 can copy and share this manual.
58 * Concept Index:: Index of concepts and programs.
59 * Function and Data Index:: Index of functions, variables and data types.
61 -- The Detailed Node Listing --
72 * Building the source::
76 * Creating certificates:: How to create a certificate object.
77 * Retrieving attributes:: How to get the attributes of a certificate.
78 * Setting attributes:: How to set certificates attributes.
79 * User data:: How to associate other data with a certificate.
81 Mastering the Cryptographic Message Syntax
88 File: ksba.info, Node: Introduction, Next: Preparation, Prev: Top, Up: Top
93 KSBA is a library to make the task of working with X.509 certificates,
94 CMS data and related data more easy.
103 File: ksba.info, Node: Getting Started, Next: Features, Up: Introduction
108 This manual documents the 'KSBA' library programming interface. All
109 functions and data types provided by the library are explained.
111 The reader is assumed to possess basic knowledge about the
112 implemented protocols.
114 This manual can be used in several ways. If read from the beginning
115 to the end, it gives a good introduction into the library and how it can
116 be used in an application. Forward references are included where
117 necessary. Later on, the manual can be used as a reference manual to
118 get just the information needed about any particular interface of the
119 library. Experienced programmers might want to start looking at the
120 examples at the end of the manual, and then only read up those parts of
121 the interface which are unclear.
124 File: ksba.info, Node: Features, Next: Overview, Prev: Getting Started, Up: Introduction
129 'KSBA' has a couple of advantages over other libraries doing a similar
130 job, and over open coding the protocols in your application directly.
133 Anybody can use, modify, and redistribute it under the terms of the
134 GNU General Public License (*note Copying::).
136 It hides the low level stuff
137 'KSBA' a high level interface to the implemented protocols and
138 presents the data in a consistent way. There is no more need to
139 worry about all the nasty details of the protocols. The API gives
140 the C programmer a more usual way of interacting with the data.
142 It copes with the version details
143 X.509 protocols tend to have many different versions and dialects.
144 Applications must usually cope with all of this and it has to be
145 coded over and over again. 'KSBA' hides this by providing just one
146 API which does the Right Thing. Support for new versions and
147 features of the protocols will be added over time.
150 File: ksba.info, Node: Overview, Prev: Features, Up: Introduction
155 The 'KSBA' library is thread-safe as long as objects described by one
156 context are only used by one thread at a time. No initialization is
160 File: ksba.info, Node: Preparation, Next: Certificate Handling, Prev: Introduction, Up: Top
165 To use 'KSBA', you have to perform some changes to your sources and the
166 build system. The necessary changes are small and explained in the
167 following sections. At the end of this chapter, it is described how the
168 library is initialized, and how the requirements of the library are
175 * Building the source::
178 File: ksba.info, Node: Header, Next: Version Check, Up: Preparation
183 All interfaces (data types and functions) of the library are defined in
184 the header file 'ksba.h'. You must include this in all programs using
185 the library, either directly or through some other header file, like
190 The name space of 'KSBA' is 'ksba_*' for function names, 'ksba*' for
191 data types and 'KSBA_*' for other symbols. In addition the same name
192 prefixes with one prepended underscore are reserved for internal use and
193 should never be used by an application.
196 File: ksba.info, Node: Version Check, Next: Building the source, Prev: Header, Up: Preparation
201 It is often desirable to check that the version of 'KSBA' used is indeed
202 one which fits all requirements. Even with binary compatibility, new
203 features may have been introduced but through peculiarities of the
204 runtime linker an old version gets actually used. So you better check
205 that the version is as expected right after program startup.
207 -- Function: const char * ksba_check_version (const char *REQ_VERSION)
209 Check that the the version of the library is at minimum the one
210 given as a string in REQ_VERSION and return the actual version
211 string of the library; return 'NULL' if the condition is not met.
212 If 'NULL' is passed to this function, no check is done and only the
213 version string is returned. It is a pretty good idea to run this
214 function as soon as possible, because it may also initializes some
215 subsystems. In a multi-threaded environment if should be called
216 before any more threads are created.
219 File: ksba.info, Node: Building the source, Prev: Version Check, Up: Preparation
221 2.3 Building the source
222 =======================
224 If you want to compile a source file including the 'ksba.h' header file,
225 you must make sure that the compiler can find it in the directory
226 hierarchy. This is accomplished by adding the path to the directory in
227 which the header file is located to the compiler's include file search
228 path (via the '-I' option).
230 However, the path to the include file is determined at the time the
231 source is configured. To solve this problem, 'KSBA' ships with
232 'ksba.pc' file, that knows about the path to the include file and other
233 configuration options. The options that need to be added to the
234 compiler invocation at compile time are output by the '--cflags' option
235 of 'pkg-config ksba'. The following example shows how it can be used at
238 gcc -c foo.c `pkg-config --cflags ksba`
240 Adding the output of 'pkg-config --cflags ksba' to the compiler's
241 command line will ensure that the compiler can find the 'ksba.h' header
244 A similar problem occurs when linking the program with the library.
245 Again, the compiler has to find the library files. For this to work,
246 the path to the library files has to be added to the library search path
247 (via the '-L' option). For this, the option '--libs' of 'pkg-config
248 ksba' can be used. For convenience, this option also outputs all other
249 options that are required to link the program with the 'KSBA' libraries
250 (in particular, the '-lksba' option). The example shows how to link
251 'foo.o' with the 'KSBA' libraries to a program 'foo'.
253 gcc -o foo foo.o `pkg-config --libs ksba`
255 Of course you can also combine both examples to a single command by
256 specifying both options to 'pkg-config ksba':
258 gcc -o foo foo.c `pkg-config --cflags --libs ksba`
261 File: ksba.info, Node: Certificate Handling, Next: CMS, Prev: Preparation, Up: Top
263 3 How to work with X.509 certificates.
264 **************************************
266 One of the most complex data formats are the X.509 certificates. KSBA
267 provides an easy to use interface to handle them.
269 -- Data type: ksba_cert_t
270 The 'ksba_cert_t' type is a handle for an X.509 certificate.
272 -- Data type: ksba_sexp_t
273 The 'ksba_sexp_t' type describes a canonically encoded S-expression
274 stored in a memory buffer. It is alias for 'unsigned char *'.
275 Note that a length argument is not required because the length of
276 such an S-expression is intrinsically available.
280 * Creating certificates:: How to create a certificate object.
281 * Retrieving attributes:: How to get the attributes of a certificate.
282 * Setting attributes:: How to set certificates attributes.
283 * User data:: How to associate other data with a certificate.
286 File: ksba.info, Node: Creating certificates, Next: Retrieving attributes, Up: Certificate Handling
288 3.1 How to create a certificate object
289 ======================================
291 This section explains how to create a certificate object, initialize it,
292 copy it and eventually destroy it.
294 -- Function: ksba_cert_t ksba_cert_new (void)
295 The function 'ksba_cert_new' creates a new certificate object and
296 returns a handle for it. The certificate object has initially one
299 The only reason why this function may fail is an out-of-memory
300 condition in which case 'NULL' is returned. You might then get the
301 actual error code using 'gpg_error_from_errno (errno)'.
303 -- Function: void ksba_cert_ref (ksba_cert_t CERT)
304 The function 'ksba_cert_ref' bumps the reference counter of the
305 certificate object up by one. Thus an extra 'ksba_cert_release' is
306 required to actually release the memory used for the object.
308 -- Function: void ksba_cert_release (ksba_cert_t CERT)
309 The function 'ksba_cert_release' reduces the number of references
310 to the certificate object with the handle CERT. If this was the
311 last reference, it will also destroy the object and releases all
312 associated resources. It is okay to pass 'NULL' to the function in
313 which case nothing happens.
315 -- Function: gpg_error_t ksba_cert_read_der (ksba_cert_t CERT,
316 ksba_reader_t READER)
318 Read the next certificate from the READER object and store it in
319 the certificate object CERT for future access. The certificate is
320 parsed and rejected if it has any syntactical or semantical error
321 (i.e., does not match the ASN.1 description).
323 The function returns '0' if the operation was successfully
324 performed. An error code is returned on failure.
326 -- Function: gpg_error_t ksba_cert_init_from_mem (ksba_cert_t CERT,
327 const void *BUFFER, size_t LENGTH)
329 Parse the BUFFER which should contain a DER encoded certificate of
330 LENGTH and initialize the certificate object CERT with it. This
331 function is intended as a convenience function to be used when a
332 certificate is already available in a internal memory buffer. This
333 avoids the extra code needed to setup the reader object. Note that
334 CERT must be a valid certificate object.
336 The function returns '0' if the operation was successfully
337 performed. An error code is returned on failure.
340 File: ksba.info, Node: Retrieving attributes, Next: Setting attributes, Prev: Creating certificates, Up: Certificate Handling
342 3.2 How to get the attributes of a certificate
343 ==============================================
345 The functions in this section allow accessing the attributes of a
346 certificate in a well defined manner. An error will be returned if the
347 certificate object has not yet been initialized by means of
348 'ksba_cert_read_der' or 'ksba_cert_init_from_mem'.
350 -- Function: const unsigned char * ksba_cert_get_image
351 (ksba_cert_t CERT, size_t *R_LENGTH)
353 This function returns a pointer to the DER encoded buffer with the
354 raw certificate. The length of that buffer gets stored at
355 R_LENGTH. This function is useful to export or store the raw
358 The function returns 'NULL' on error or a pointer to a buffer with
359 the raw certificate data. That pointer is only valid as long as
360 the certificate object CERT is valid and has not been
363 -- Function: gpg_error_t ksba_cert_hash (ksba_cert_t CERT, int WHAT,
364 void (*HASHER)(void *, const void *, size_t length),
367 This function feeds the data which is expected to be hashed into
368 the supplied function HASHER, where the first argument passed is
369 HASHER_ARG, the second the pointer to the data to be hashed and the
370 third the length of this data.
372 The function returns '0' on success or an error code when something
373 goes wrong. The HASHER function is not expected to return an
374 error; instead the caller should setup that function in a way to
375 convey encountered errors by means of the HASHER_ARG. Note that a
376 hash function is in general not expected to yield errors anyway.
378 -- Function: const char * ksba_cert_get_digest_algo (ksba_cert_t CERT)
380 Figure out the the digest algorithm used for the signature and
381 return its OID in dotted decimal format. This function is most
382 likely used to setup the hash context before calling
383 'ksba_cert_hash'. For some certificate types the returned OID has
386 '1.2.840.113549.1.1.10'
387 This indicates the RSASSA-PSS algorithm. The digest algorithm
388 needs to be extracted from the S-expression returned by
389 'ksba_cert_get_sig_val'.
392 This is the Ed25519 algorithm which does not use a separate
393 digest algorithm. See RFC-8410.
396 This is the Ed448 algorithm which does not use a separate
397 digest algorithm. See RFC-8410.
399 The function returns 'NULL' for an error; on success a constant
400 string with the OID is returned. This string is valid as long the
401 certificate object is valid.
403 -- Function: ksba_sexp_t ksba_cert_get_serial (ksba_cert_t CERT)
405 The function returns the serial number of the certificate CERT.
406 The serial number is an integer returned as an canonical encoded
407 S-expression with just one element. The caller must free the
408 returned value. The value 'NULL' is returned in case of error.
410 -- Function: char * ksba_cert_get_issuer (ksba_cert_t CERT, int IDX)
412 With IDX given as '0', this function returns the Distinguished Name
413 (DN) of the certificate issuer; this usually is the name of a
414 certification authority (CA). The format of the returned string is
415 in accordance with RFC-2253. 'NULL' is returned if the DN is not
416 available; This is a severe error and actually should have been
417 caught by the certificate reading function.
419 With IDX greater than zero, the function may be used to enumerate
420 alternate issuer names. The function returns 'NULL' when there are
421 no more alternate names. Only alternate names recognized by
422 'libksba' are returned, others are simply skipped. The format of
423 the returned name is either a RFC-2253 formated string which can be
424 detected by checking whether the first character is a letter or
425 digit. RFC-822 conformant email addresses are returned enclosed in
426 angle brackets; the opening angle bracket should be used to detect
427 this. Other formats are returned as an S-Expression in canonical
428 format, so a opening parenthesis should be used to detect this
429 encoding. The name may include binary null characters, thus strlen
430 may return a length shorter than actually used. The real length is
431 implicitly given by the structure of the S-expression, an extra
432 null is appended for safety reasons.
434 The caller must free the returned string using 'ksba_free' or
435 whatever function has been registered as a replacement.
437 -- Function: char * ksba_cert_get_subject (ksba_cert_t CERT, int IDX)
439 With IDX given as '0', this function returns the Distinguished Name
440 (DN) of the certificate's subject. The format of the returned
441 string is in accordance with RFC-2253. 'NULL' is returned if the
444 With IDX greater than zero, the function may be used to enumerate
445 alternate subject names. The function returns 'NULL' when there
446 are no more alternate names. Only alternate names recognized by
447 'libksba' are returned, others are simply skipped. The format of
448 the returned name is either a RFC-2253 formated string which can be
449 detected by checking whether the first character is a letter or
450 digit. RFC-2822 conform email addresses are returned enclosed in
451 angle brackets; the opening angle bracket should be used to detect
452 this. Other formats are returned as an S-Expression in canonical
453 format, so a opening parenthesis should be used to detect this
454 encoding, the name may include binary null characters, thus strlen
455 may return a length shorter than actually used. The real length is
456 implicitly given by the structure of the S-expression, an extra
457 null is appended for safety reasons.
459 The caller must free the returned string using 'ksba_free' or
460 whatever function has been registered as a replacement.
462 -- Data type: ksba_isotime_t
463 Due to problems with the C data type 'time_t', which will overflow
464 on most 32 bit machines in the year 2038, it was not advisable to
465 use this type for referencing times stored in certificates.
466 Instead, you should use the 'ksba_isotime_t' type, which can
467 represent any time since the year 0.
469 It is implemented as a buffer of 16 bytes and may be handled like a
470 standard string. It should be initialized to zero (i.e., the first
471 byte needs to be 0x00) if it does not hold a valid date. Date
472 values themselves are stored in ISO format and assumed to be
473 referenced from UTC. The string with the date value is always
474 guaranteed to be of length 15 and having a format like:
475 '"19610711T172059"'. Note that the 'T' is required by ISO rules.
477 A simple assignment of these data types is not a good idea. You
478 may use 'strcpy' or better a specialized function like:
481 copy_time (ksba_isotime_t d, const ksba_isotime_t s)
489 For reasons of documentation a special function should also be used
490 to compare such times:
493 cmp_time (const ksba_isotime_t a, const ksba_isotime_t b)
495 return strcmp (a, b);
498 -- Function: gpg_error_t ksba_cert_get_validity
499 (ksba_cert_t CERT, int WHAT, ksba_isotime_t TIMEBUF)
501 Return the validity dates from the certificate. If no value is
502 available an empty date object (i.e., a 'strlen' will be stored at
503 TIMEBUF, otherwise it will receive the date. On failure an error
506 To return the 'notBefore' date, the value '0' must be supplied for
507 WHAT; '1' yields the 'notAfter' value.
509 -- Function: ksba_sexp_t ksba_cert_get_public_key (ksba_cert_t CERT)
511 [This needs to get written - for now please see libksba/src/cert.c]
513 -- Function: ksba_sexp_t ksba_cert_get_sig_val (ksba_cert_t CERT)
515 [This needs to get written - for now please see libksba/src/cert.c]
517 -- Function: gpg_error_t ksba_cert_get_extension
518 (ksba_cert_t CERT, int IDX, char const **R_OID, int *R_CRIT, size_t *R_DEROFF, size_t *R_DERLEN)
520 [This needs to get written - for now please see libksba/src/cert.c]
522 -- Function: gpg_error_t ksba_cert_is_ca
523 (ksba_cert_t CERT, int *R_CA, int *R_PATHLEN)
525 Return information on the basicConstraint (2.5.19.19) of CERT. R_CA
526 receives true if this is a CA and only in that case R_PATHLEN is
527 set to the maximum certification path length or -1 if there is no
530 -- Function: gpg_error_t ksba_cert_get_key_usage
531 (ksba_cert_t CERT, unsigned int *R_FLAGS)
533 Get the key usage flags. The function returns 'GPG_ERR_NO_DATA' if
534 no key usage is specified. The usage flags are as shown in
535 RFC3280, section 4.2.1.3. The key usage flags are represented by a
536 bitmask, and you can test each bit using symbolic constants, which
537 tells you if that usage is set on the certificate. The constants
540 'KSBA_KEYUSAGE_DIGITAL_SIGNATURE'
541 Usable for digitalSignature.
542 'KSBA_KEYUSAGE_NON_REPUDIATION'
543 Usable for nonRepudiation.
544 'KSBA_KEYUSAGE_KEY_ENCIPHERMENT'
545 Usable for keyEncipherment.
546 'KSBA_KEYUSAGE_DATA_ENCIPHERMENT'
547 Usable for dataEncipherment.
548 'KSBA_KEYUSAGE_KEY_AGREEMENT'
549 Usable for for keyAgreement.
550 'KSBA_KEYUSAGE_KEY_CERT_SIGN'
551 Usable for keyCertSign.
552 'KSBA_KEYUSAGE_CRL_SIGN'
554 'KSBA_KEYUSAGE_ENCIPHER_ONLY'
555 Usable for encipherOnly.
556 'KSBA_KEYUSAGE_DECIPHER_ONLY'
557 Usable for decipherOnly.
559 These are the basic constraints on usage of a certificate. If you
560 need to get additional constraints, see
561 'ksba_cert_get_ext_key_usages'.
563 -- Function: gpg_error_t ksba_cert_get_ext_key_usages
564 (ksba_cert_t CERT, char **RESULT)
566 Return a string containing the extended usages for the certificate,
567 delimited by linefeeds.
569 -- Function: gpg_error_t ksba_cert_get_cert_policies
570 (ksba_cert_t CERT, char **R_POLICIES)
572 Return a string with the certificatePolicies delimited by
573 linefeeds. The return values may be extended to carry more
574 information per line, so the caller should only use the first
575 white-space delimited token per line. The function returns
576 'GPG_ERR_NO_DATA' when this extension is not used. Caller must
577 free the returned value.
579 -- Function: gpg_error_t ksba_cert_get_crl_dist_point
580 (ksba_cert_t CERT, int IDX, ksba_name_t *R_DISTPOINT, ksba_name_t *R_ISSUER, unsigned int *R_REASON)
582 Return the CRLDistPoints given in the certificate extension of
583 certificate CERT. IDX should be iterated starting from 0 until the
584 function returns 'GPG_ERR_EOF'. R_DISTPOINT returns a ksba_name_t
585 object with the distribution point name(s); the return value may be
586 'NULL' to indicate that this name is not available. R_ISSUER
587 returns the CRL issuer; if the returned value is 'NULL' the caller
588 should assume that the CRL issuer is the same as the certificate
589 issuer. R_REASON returns the reason for the CRL. This is a bit
590 encoded value with no bit set if no reason has been specified in
593 The caller may pass 'NULL' to any of the pointer arguments if he is
594 not interested in this value. The return values for R_DISTPOINT
595 and R_ISSUER must be released by the caller using
598 -- Function: gpg_error_t ksba_cert_get_subj_key_id
599 (ksba_cert_t CERT, int *R_CRIT, ksba_sexp_t *R_KEYID)
601 Return the subjectKeyIdentifier extension as a simple allocated
602 S-expression at the address of R_KEYID. 0 is returned on success,
603 'GPG_ERR_NO_DATA' if no such extension is available or any other
604 error code. If R_CRIT is not passed as 'NULL', the critical flag
605 of this is extension is stored at this address.
607 -- Function: gpg_error_t ksba_cert_get_auth_key_id
608 (ksba_cert_t CERT, ksba_sexp_t *R_KEYID, ksba_name_t *R_NAME, ksba_sexp_t *R_SERIAL)
610 Return the authorityKeyIdentifier in R_NAME and R_SERIAL or in
611 R_KEYID. 'GPG_ERR_NO_DATA' is returned if no
612 authorityKeyIdentifier has been found. This error code is also
613 returned if R_KEYID has been given as NULL and only an
614 authorityKeyIdentifier with the keyIdentifier method is available.
616 -- Function: gpg_error_t ksba_cert_get_authority_info_access
617 (ksba_cert_t CERT, int IDX, char **R_METHOD, ksba_name_t *R_LOCATION)
619 Return the authorityInfoAccess attributes. IDX should be iterated
620 starting from 0 until this function returns 'GPG_ERR_EOF'.
621 R_METHOD returns an allocated string with the OID of one item and
622 R_LOCATION returns the GeneralName for that OID. The returned
623 values for R_METHOD and R_LOCATION must be released by the caller
624 unless the function returned an error; the function will however
625 make sure that R_METHOD and R_LOCATION will point to 'NULL' if the
626 function returns an error.
628 See RFC-2459, section 4.2.2.1 for the definition of this attribute.
630 -- Function: gpg_error_t ksba_cert_get_subject_info_access
631 (ksba_cert_t CERT, int IDX, char **R_METHOD, ksba_name_t *R_LOCATION)
633 Return the subjectInfoAccess attributes. IDX should be iterated
634 starting from 0 until this function returns 'GPG_ERR_EOF'.
635 R_METHOD returns an allocated string with the OID of one item and
636 R_LOCATION returns the GeneralName for that OID. The returned
637 values for R_METHOD and R_LOCATION must be released by the caller
638 unless the function returned an error; the function will however
639 make sure that R_METHOD and R_LOCATION will point to 'NULL' if the
640 function returns an error.
642 See RFC-2459, section 4.2.2.2 for the definition of this attribute.
645 File: ksba.info, Node: Setting attributes, Next: User data, Prev: Retrieving attributes, Up: Certificate Handling
647 3.3 How to set certificate attributes
648 =====================================
650 [This needs to be written. For example code see newpg/sm/sign.c]
653 File: ksba.info, Node: User data, Prev: Setting attributes, Up: Certificate Handling
655 3.4 How to associate other data with a certificate.
656 ===================================================
658 Certificate objects play a central role in many applications and often
659 it is desirable to associate other data with the certificate to avoid
660 wrapping the certificate object into an own object. 'KSBA' provides a
661 mechanism for this by means of two functions:
663 -- Function: gpg_error_t ksba_cert_set_user_data
664 (ksba_cert_t CERT, const char *KEY, const void *DATA, size_t DATALEN)
666 Stores arbitrary data along with a certificate. The data is
667 expected in the buffer DATA of length DATALEN. It will be stored
668 under the string KEY. If data is already stored under this key it
669 will be replaced by the new data. Using 'NULL' for DATA will
670 effectively delete the data.
672 On error (i.e., out of memory) an already existing data object
673 stored under KEY may get deleted.
675 *Caution:* This function is definitely not thread safe because we
676 don't employ any locking mechanisms.
678 -- Function: gpg_error_t ksba_cert_get_user_data (ksba_cert_t CERT,
679 const char *KEY, void *BUFFER, size_t BUFFERLEN,
682 Return user data for certificate CERT stored under the string KEY.
683 The caller needs to provide a suitable large BUFFER and the usable
684 length of this buffer in BUFFERLEN. If DATALEN is not 'NULL', the
685 length of the data stored in BUFFER will be stored there.
687 If BUFFER is given as 'NULL', BUFFERLEN will be ignored and the
688 required length of the buffer will be returned at DATALEN.
690 On success 0 is returned. If no data is stored under the given
691 key, 'GPG_ERR_NOT_FOUND' is returned. If the provided buffer is
692 too short and BUFFER is not 'NULL', 'GPG_ERR_BUFFER_TOO_SHORT' will
696 File: ksba.info, Node: CMS, Next: CRLs, Prev: Certificate Handling, Up: Top
698 4 Mastering the Cryptographic Message Syntax
699 ********************************************
701 The CMS is also known under the name PKCS#7. Is is a cryptographic
702 framework for securing data transactions and storage, much like OpenPGP.
703 It is heavily based on X.509 semantics and for example used with the
704 email encryption protocol S/MIME.
712 File: ksba.info, Node: CMS Basics, Next: CMS Parser, Up: CMS
717 All operations with the CMS framework require the use of a so called CMS
718 object which is internally used to keep track of the current state and
719 to store some meta information.
721 -- Data type: ksba_cms_t
722 The 'ksba_cms_t' type is used for this CMS object.
723 -- Data type: ksba_stop_reason_t
724 The 'ksba_stop_reason_t' type is an enumeration used for
725 communication between the phases of a parsing or building process.
727 -- Function: ksba_cms_t ksba_cms_new (void)
729 This function creates a new CMS object. The only reason the
730 function may fail is an out-of-memory condition in which case
731 'NULL' is returned. It is safe for the caller to translate this to
732 the standard error code 'GPG_ERR_ENOMEM'. Any object created with
733 this function should be released after use by using
736 -- Function: void ksba_cms_release (ksba_cms_t CMS)
738 Release all resources associated with the CMS object. It is
739 perfectly okay to pass 'NULL' to this function in which case
742 -- Function: gpg_error_t ksba_cms_set_reader_writer
743 (ksba_cms_t CMS, ksba_reader_t R, ksba_writer_t W)
745 About all usages of the CMS framework require some input and output
746 data (great surprise!). To accomplish this in the most abstract
747 way, no direct output functions are used - instead special reader
748 and writer objects are used instead. Depending on the desired
749 operations either a reader, a writer or both must be given.
750 Associate a reader object with CMS by passing it as R and a writer
751 object by passing it as W. Note that no reference counting is
752 done,so make sure that those objects have a lifetime at least as
755 If you forget to set these objects, you will get an appropriate
756 error later when data is actually to be read or written. The
757 function returns zero on success or an error code when invalid
761 File: ksba.info, Node: CMS Parser, Prev: CMS Basics, Up: CMS
766 KSBA includes a versatile CMS parser for encryption (enveloped data) and
767 digital signing. The parser is capable of handling arbitrary amounts of
768 data without requiring much memory. Well, certain objects are build in
769 memory because it can be assumed that those objects are limited in size;
770 e.g., it does not make sense to use a video clip as the DN despite the
771 fact that the standard does not forbid it.
773 -- Function: gpg_error_t ksba_cms_parse
774 (ksba_cms_t CMS, ksba_stop_reason_t *R_STOPREASON)
776 This is the core function of the parser and commonly used in a
777 loop. The parsing process is divided into several phases to allow
778 the user to get information at the right time and prepare for
779 further processing. The caller has to act on certain stop reasons
780 which are returned by R_STOPREASON and set up things accordingly;
781 KSBA may introduce new stop reasons to let the caller know other
782 details; there is no need for the caller to act on every stop
783 reason; it should only do so for reasons that the caller
784 understands and which are mandatory. The function will return with
785 an error if the caller did not setup things correctly for certain
788 The use of this function is best explained by an example, leaving out
792 ksba_cms_parse (cms, &stopreason);
793 if (stopreason == KSBA_SR_BEGIN_DATA)
796 decrypt_session_key ();
797 setup_bulk_decryption ();
799 else if (stopreason == KSBA_SR_END_DATA)
804 while (stopreason != KSBA_SR_READY);
805 This function assumes that the parsed data is so called 'enveloped
808 As CMS provides a common framework for a variety of data formats, it
809 is probably very useful to check the type of that data very early. This
810 can be accomplished by hooking into the stop reason
811 'KSBA_SR_GOT_CONTENT' and retrieving the content using the following
814 -- Function: ksba_content_t ksba_cms_get_content_type
815 (ksba_cms_t CMS, int WHAT)
817 By using a value of '0' for WHAT this function returns the content
818 type of the outer container; using '1' does return the content type
819 of the enclosed object.
821 -- Data type: ksba_content_t
822 The 'ksba_content_t' type is an enumeration used to describe
823 the content of a CMS message. Here is a list of possible
827 No content type known (value '0')
830 The content is plain data, not further interpreted.
832 'KSBA_CT_SIGNED_DATA'
833 The content is an signed CMS object. This also includes
834 the case of a detached signature where no actual data is
835 included in the message.
837 'KSBA_CT_ENVELOPED_DATA'
838 The content is encrypted using a session key.
840 'KSBA_CT_DIGESTED_DATA'
843 'KSBA_CT_ENCRYPTED_DATA'
849 -- Function: const char * ksba_cms_get_content_oid
850 (ksba_cms_t CMS, int WHAT)
852 Return the object ID of CMS. This is a constant string valid as
853 long as the context is valid and no new parse is started. This
854 function is similar to 'ksba_cms_get_content_type' but returns the
855 OID actually used in the data. Depending on the value of WHAT
856 different values are returned: Using a value of '0' yields the OID
857 of the outer container, a value of '1' yields the OID of the inner
858 container if available and the value '2' returns the OID of the
859 algorithm used to encrypt the inner container.
862 File: ksba.info, Node: CRLs, Next: PKCS10, Prev: CMS, Up: Top
864 5 Certification Revocation Lists
865 ********************************
867 KSBA also comes with an API to process certification revocation lists.
868 The API is similar to the CMS one but returns the contents entry by
872 File: ksba.info, Node: PKCS10, Next: Utilities, Prev: CRLs, Up: Top
874 6 Certification Requests
875 ************************
877 When using decentral generated keys, it is necessary to send out special
878 formated messages so that a CA can generate the certificate.
881 File: ksba.info, Node: Utilities, Next: Error Handling, Prev: PKCS10, Up: Top
886 A few utility function and objects are available. Some of them must be
887 used to support some of the main functions.
891 * Names:: General Names object
892 * OIDs:: Object Identifier helpers
893 * DNs:: Distinguished Name helpers
896 File: ksba.info, Node: Names, Next: OIDs, Up: Utilities
898 7.1 General Names object
899 ========================
901 This is an object to handle some of the names used in X.509. We need
902 this object approach because those names may come as a set and there is
903 no other clean way to access them.
905 -- Data type: ksba_name_t
906 The 'ksba_name_t' type is an object to represent names sets.
908 -- Function: void ksba_name_release (ksba_name_t NAME)
910 This function releases the object NAME. Passing 'NULL' is allowed.
912 -- Function: const char * ksba_name_enum (ksba_name_t NAME, int IDX)
914 By iterating IDX up starting with 0, this function returns all
915 General Names stored in NAME. The format of the returned name is
916 either a RFC-2253 formated one which can be detected by checking
917 whether the first character is letter or a digit. RFC 2822
918 conformant email addresses are returned enclosed in angle brackets,
919 the opening angle bracket should be used to detect this. Other
920 formats are returned as an S-Expression in canonical format, so an
921 opening parenthesis may be used to detect this encoding, in this
922 case the name may include binary null characters, so strlen might
923 return a length shorter than actually used, the real length is
924 implicitly given by the structure of the S-Exp, an extra null is
925 appended for safety reasons. One common format return is a
926 Universal Resource Identifier which has the S-expression: '(uri
929 The returned string has the same lifetime as NAME.
931 -- Function: char * ksba_name_get_uri (ksba_name_t NAME, int IDX)
933 Convenience function to return names representing an URI. Caller
934 must free the returned value. Note that this function should not
935 be used to enumerate the names.
937 Here is an example on how you can use this function to enumerate
941 print_names (ksba_name_t name)
946 for (idx=0; (s = ksba_name_enum (name, idx)); idx++)
948 char *p = ksba_name_get_uri (name, idx);
958 File: ksba.info, Node: OIDs, Next: DNs, Prev: Names, Up: Utilities
960 7.2 Object Identifier helpers
961 =============================
963 [This needs to get written - for now please see libksba/src/oids.c]
966 File: ksba.info, Node: DNs, Prev: OIDs, Up: Utilities
968 7.3 Distinguished Name helpers
969 ==============================
971 These are helper functions for the so called distinguished names. They
972 are used for example as the issuer and subject name.
974 -- Function: gpg_error_t ksba_dn_teststr (const char *STRING, int SEQ,
975 size_t *RERROFF, size_t *RERRLEN)
977 Assuming that STRING contains an RFC-2253 encoded string, test
978 whether this string may be passed as a valid DN to libksba. On
979 success the functions returns '0'. On error the function returns
980 an error code and stores the offset of the erroneous part at
981 RERROFF. RERRLEN will then receive the length of the erroneous
984 This function is mostly useful to test whether a certain component
985 label is supported. SEQ should be passed as '0' for now. Any of
986 RERROFF and RERRLEN may be passed as NULL if the caller is not
987 interested at this value.
989 gpg_error_t ksba_dn_str2der (const char *string, void **rder, size_t
992 gpg_error_t ksba_dn_der2str (const void *der, size_t derlen, char
996 File: ksba.info, Node: Error Handling, Next: Component Labels, Prev: Utilities, Up: Top
1001 Most functions in 'KSBA' will return an error if they fail. For this
1002 reason, the application should always catch the error condition and take
1003 appropriate measures, for example by releasing the resources and passing
1004 the error up to the caller, or by displaying a descriptive message to
1005 the user and canceling the operation.
1007 Some error values do not indicate a system error or an error in the
1008 operation, but the reasonable result of an operation. For example, if
1009 you try to access optional attributes of a certificate that are not
1010 present, you get an appropriate error message. Some error values have
1011 specific meanings if returned by a specific function. Such cases are
1012 described in the documentation of those functions.
1014 All error codes are defined by the library 'libgpg-error'. See there
1015 for ways to check the error values and print descriptive strings.
1016 Please be aware that you can't check directly against an error code but
1017 have to do it like this:
1020 if (gpg_err_code (err) == GPG_ERR_EOF)
1023 The only exception is that success (i.e., no error) is defined to be
1024 '0'; thus you may directly test for success like:
1030 File: ksba.info, Node: Component Labels, Next: Copying, Prev: Error Handling, Up: Top
1032 Appendix A Component Labels
1033 ***************************
1035 RFC-2253 defines the following table with string representations of name
1039 C countryName 2.5.4.6
1040 CN commonName 2.5.4.3
1041 DC domainComponent 0.9.2342.19200300.100.1.25
1042 L localityName 2.5.4.7
1043 O organizationName 2.5.4.10
1044 OU organizationalUnit 2.5.4.11
1045 ST stateOrProvince 2.5.4.8
1046 STREET streetAddress 2.5.4.9
1047 UID userid 0.9.2342.19200300.100.1.1
1050 They are used internally for converting a DN into its string
1051 representation; components not listed in this table will be represented
1054 For the other direction, i.e., creating a DN from the string
1055 representation, KSBA recognizes the following extra labels:
1058 ADDR postalAddress 2.5.4.16
1059 BC businessCategory 2.5.4.15
1060 D description 2.5.4.13
1061 EMAIL emailAddress 1.2.840.113549.1.9.1
1062 GN givenName 2.5.4.42
1063 POSTALCODE postalCode 2.5.4.17
1064 PSEUDO pseudonym 2.5.4.65
1065 SERIALNUMBER serialNumber 2.5.4.5
1071 File: ksba.info, Node: Copying, Next: Concept Index, Prev: Component Labels, Up: Top
1073 GNU General Public License
1074 **************************
1076 Version 3, 29 June 2007
1078 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
1080 Everyone is permitted to copy and distribute verbatim copies of this
1081 license document, but changing it is not allowed.
1086 The GNU General Public License is a free, copyleft license for software
1087 and other kinds of works.
1089 The licenses for most software and other practical works are designed
1090 to take away your freedom to share and change the works. By contrast,
1091 the GNU General Public License is intended to guarantee your freedom to
1092 share and change all versions of a program-to make sure it remains free
1093 software for all its users. We, the Free Software Foundation, use the
1094 GNU General Public License for most of our software; it applies also to
1095 any other work released this way by its authors. You can apply it to
1098 When we speak of free software, we are referring to freedom, not
1099 price. Our General Public Licenses are designed to make sure that you
1100 have the freedom to distribute copies of free software (and charge for
1101 them if you wish), that you receive source code or can get it if you
1102 want it, that you can change the software or use pieces of it in new
1103 free programs, and that you know you can do these things.
1105 To protect your rights, we need to prevent others from denying you
1106 these rights or asking you to surrender the rights. Therefore, you have
1107 certain responsibilities if you distribute copies of the software, or if
1108 you modify it: responsibilities to respect the freedom of others.
1110 For example, if you distribute copies of such a program, whether
1111 gratis or for a fee, you must pass on to the recipients the same
1112 freedoms that you received. You must make sure that they, too, receive
1113 or can get the source code. And you must show them these terms so they
1116 Developers that use the GNU GPL protect your rights with two steps:
1117 (1) assert copyright on the software, and (2) offer you this License
1118 giving you legal permission to copy, distribute and/or modify it.
1120 For the developers' and authors' protection, the GPL clearly explains
1121 that there is no warranty for this free software. For both users' and
1122 authors' sake, the GPL requires that modified versions be marked as
1123 changed, so that their problems will not be attributed erroneously to
1124 authors of previous versions.
1126 Some devices are designed to deny users access to install or run
1127 modified versions of the software inside them, although the manufacturer
1128 can do so. This is fundamentally incompatible with the aim of
1129 protecting users' freedom to change the software. The systematic
1130 pattern of such abuse occurs in the area of products for individuals to
1131 use, which is precisely where it is most unacceptable. Therefore, we
1132 have designed this version of the GPL to prohibit the practice for those
1133 products. If such problems arise substantially in other domains, we
1134 stand ready to extend this provision to those domains in future versions
1135 of the GPL, as needed to protect the freedom of users.
1137 Finally, every program is threatened constantly by software patents.
1138 States should not allow patents to restrict development and use of
1139 software on general-purpose computers, but in those that do, we wish to
1140 avoid the special danger that patents applied to a free program could
1141 make it effectively proprietary. To prevent this, the GPL assures that
1142 patents cannot be used to render the program non-free.
1144 The precise terms and conditions for copying, distribution and
1145 modification follow.
1147 TERMS AND CONDITIONS
1151 "This License" refers to version 3 of the GNU General Public
1154 "Copyright" also means copyright-like laws that apply to other
1155 kinds of works, such as semiconductor masks.
1157 "The Program" refers to any copyrightable work licensed under this
1158 License. Each licensee is addressed as "you". "Licensees" and
1159 "recipients" may be individuals or organizations.
1161 To "modify" a work means to copy from or adapt all or part of the
1162 work in a fashion requiring copyright permission, other than the
1163 making of an exact copy. The resulting work is called a "modified
1164 version" of the earlier work or a work "based on" the earlier work.
1166 A "covered work" means either the unmodified Program or a work
1167 based on the Program.
1169 To "propagate" a work means to do anything with it that, without
1170 permission, would make you directly or secondarily liable for
1171 infringement under applicable copyright law, except executing it on
1172 a computer or modifying a private copy. Propagation includes
1173 copying, distribution (with or without modification), making
1174 available to the public, and in some countries other activities as
1177 To "convey" a work means any kind of propagation that enables other
1178 parties to make or receive copies. Mere interaction with a user
1179 through a computer network, with no transfer of a copy, is not
1182 An interactive user interface displays "Appropriate Legal Notices"
1183 to the extent that it includes a convenient and prominently visible
1184 feature that (1) displays an appropriate copyright notice, and (2)
1185 tells the user that there is no warranty for the work (except to
1186 the extent that warranties are provided), that licensees may convey
1187 the work under this License, and how to view a copy of this
1188 License. If the interface presents a list of user commands or
1189 options, such as a menu, a prominent item in the list meets this
1194 The "source code" for a work means the preferred form of the work
1195 for making modifications to it. "Object code" means any non-source
1198 A "Standard Interface" means an interface that either is an
1199 official standard defined by a recognized standards body, or, in
1200 the case of interfaces specified for a particular programming
1201 language, one that is widely used among developers working in that
1204 The "System Libraries" of an executable work include anything,
1205 other than the work as a whole, that (a) is included in the normal
1206 form of packaging a Major Component, but which is not part of that
1207 Major Component, and (b) serves only to enable use of the work with
1208 that Major Component, or to implement a Standard Interface for
1209 which an implementation is available to the public in source code
1210 form. A "Major Component", in this context, means a major
1211 essential component (kernel, window system, and so on) of the
1212 specific operating system (if any) on which the executable work
1213 runs, or a compiler used to produce the work, or an object code
1214 interpreter used to run it.
1216 The "Corresponding Source" for a work in object code form means all
1217 the source code needed to generate, install, and (for an executable
1218 work) run the object code and to modify the work, including scripts
1219 to control those activities. However, it does not include the
1220 work's System Libraries, or general-purpose tools or generally
1221 available free programs which are used unmodified in performing
1222 those activities but which are not part of the work. For example,
1223 Corresponding Source includes interface definition files associated
1224 with source files for the work, and the source code for shared
1225 libraries and dynamically linked subprograms that the work is
1226 specifically designed to require, such as by intimate data
1227 communication or control flow between those subprograms and other
1230 The Corresponding Source need not include anything that users can
1231 regenerate automatically from other parts of the Corresponding
1234 The Corresponding Source for a work in source code form is that
1237 2. Basic Permissions.
1239 All rights granted under this License are granted for the term of
1240 copyright on the Program, and are irrevocable provided the stated
1241 conditions are met. This License explicitly affirms your unlimited
1242 permission to run the unmodified Program. The output from running
1243 a covered work is covered by this License only if the output, given
1244 its content, constitutes a covered work. This License acknowledges
1245 your rights of fair use or other equivalent, as provided by
1248 You may make, run and propagate covered works that you do not
1249 convey, without conditions so long as your license otherwise
1250 remains in force. You may convey covered works to others for the
1251 sole purpose of having them make modifications exclusively for you,
1252 or provide you with facilities for running those works, provided
1253 that you comply with the terms of this License in conveying all
1254 material for which you do not control copyright. Those thus making
1255 or running the covered works for you must do so exclusively on your
1256 behalf, under your direction and control, on terms that prohibit
1257 them from making any copies of your copyrighted material outside
1258 their relationship with you.
1260 Conveying under any other circumstances is permitted solely under
1261 the conditions stated below. Sublicensing is not allowed; section
1262 10 makes it unnecessary.
1264 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
1266 No covered work shall be deemed part of an effective technological
1267 measure under any applicable law fulfilling obligations under
1268 article 11 of the WIPO copyright treaty adopted on 20 December
1269 1996, or similar laws prohibiting or restricting circumvention of
1272 When you convey a covered work, you waive any legal power to forbid
1273 circumvention of technological measures to the extent such
1274 circumvention is effected by exercising rights under this License
1275 with respect to the covered work, and you disclaim any intention to
1276 limit operation or modification of the work as a means of
1277 enforcing, against the work's users, your or third parties' legal
1278 rights to forbid circumvention of technological measures.
1280 4. Conveying Verbatim Copies.
1282 You may convey verbatim copies of the Program's source code as you
1283 receive it, in any medium, provided that you conspicuously and
1284 appropriately publish on each copy an appropriate copyright notice;
1285 keep intact all notices stating that this License and any
1286 non-permissive terms added in accord with section 7 apply to the
1287 code; keep intact all notices of the absence of any warranty; and
1288 give all recipients a copy of this License along with the Program.
1290 You may charge any price or no price for each copy that you convey,
1291 and you may offer support or warranty protection for a fee.
1293 5. Conveying Modified Source Versions.
1295 You may convey a work based on the Program, or the modifications to
1296 produce it from the Program, in the form of source code under the
1297 terms of section 4, provided that you also meet all of these
1300 a. The work must carry prominent notices stating that you
1301 modified it, and giving a relevant date.
1303 b. The work must carry prominent notices stating that it is
1304 released under this License and any conditions added under
1305 section 7. This requirement modifies the requirement in
1306 section 4 to "keep intact all notices".
1308 c. You must license the entire work, as a whole, under this
1309 License to anyone who comes into possession of a copy. This
1310 License will therefore apply, along with any applicable
1311 section 7 additional terms, to the whole of the work, and all
1312 its parts, regardless of how they are packaged. This License
1313 gives no permission to license the work in any other way, but
1314 it does not invalidate such permission if you have separately
1317 d. If the work has interactive user interfaces, each must display
1318 Appropriate Legal Notices; however, if the Program has
1319 interactive interfaces that do not display Appropriate Legal
1320 Notices, your work need not make them do so.
1322 A compilation of a covered work with other separate and independent
1323 works, which are not by their nature extensions of the covered
1324 work, and which are not combined with it such as to form a larger
1325 program, in or on a volume of a storage or distribution medium, is
1326 called an "aggregate" if the compilation and its resulting
1327 copyright are not used to limit the access or legal rights of the
1328 compilation's users beyond what the individual works permit.
1329 Inclusion of a covered work in an aggregate does not cause this
1330 License to apply to the other parts of the aggregate.
1332 6. Conveying Non-Source Forms.
1334 You may convey a covered work in object code form under the terms
1335 of sections 4 and 5, provided that you also convey the
1336 machine-readable Corresponding Source under the terms of this
1337 License, in one of these ways:
1339 a. Convey the object code in, or embodied in, a physical product
1340 (including a physical distribution medium), accompanied by the
1341 Corresponding Source fixed on a durable physical medium
1342 customarily used for software interchange.
1344 b. Convey the object code in, or embodied in, a physical product
1345 (including a physical distribution medium), accompanied by a
1346 written offer, valid for at least three years and valid for as
1347 long as you offer spare parts or customer support for that
1348 product model, to give anyone who possesses the object code
1349 either (1) a copy of the Corresponding Source for all the
1350 software in the product that is covered by this License, on a
1351 durable physical medium customarily used for software
1352 interchange, for a price no more than your reasonable cost of
1353 physically performing this conveying of source, or (2) access
1354 to copy the Corresponding Source from a network server at no
1357 c. Convey individual copies of the object code with a copy of the
1358 written offer to provide the Corresponding Source. This
1359 alternative is allowed only occasionally and noncommercially,
1360 and only if you received the object code with such an offer,
1361 in accord with subsection 6b.
1363 d. Convey the object code by offering access from a designated
1364 place (gratis or for a charge), and offer equivalent access to
1365 the Corresponding Source in the same way through the same
1366 place at no further charge. You need not require recipients
1367 to copy the Corresponding Source along with the object code.
1368 If the place to copy the object code is a network server, the
1369 Corresponding Source may be on a different server (operated by
1370 you or a third party) that supports equivalent copying
1371 facilities, provided you maintain clear directions next to the
1372 object code saying where to find the Corresponding Source.
1373 Regardless of what server hosts the Corresponding Source, you
1374 remain obligated to ensure that it is available for as long as
1375 needed to satisfy these requirements.
1377 e. Convey the object code using peer-to-peer transmission,
1378 provided you inform other peers where the object code and
1379 Corresponding Source of the work are being offered to the
1380 general public at no charge under subsection 6d.
1382 A separable portion of the object code, whose source code is
1383 excluded from the Corresponding Source as a System Library, need
1384 not be included in conveying the object code work.
1386 A "User Product" is either (1) a "consumer product", which means
1387 any tangible personal property which is normally used for personal,
1388 family, or household purposes, or (2) anything designed or sold for
1389 incorporation into a dwelling. In determining whether a product is
1390 a consumer product, doubtful cases shall be resolved in favor of
1391 coverage. For a particular product received by a particular user,
1392 "normally used" refers to a typical or common use of that class of
1393 product, regardless of the status of the particular user or of the
1394 way in which the particular user actually uses, or expects or is
1395 expected to use, the product. A product is a consumer product
1396 regardless of whether the product has substantial commercial,
1397 industrial or non-consumer uses, unless such uses represent the
1398 only significant mode of use of the product.
1400 "Installation Information" for a User Product means any methods,
1401 procedures, authorization keys, or other information required to
1402 install and execute modified versions of a covered work in that
1403 User Product from a modified version of its Corresponding Source.
1404 The information must suffice to ensure that the continued
1405 functioning of the modified object code is in no case prevented or
1406 interfered with solely because modification has been made.
1408 If you convey an object code work under this section in, or with,
1409 or specifically for use in, a User Product, and the conveying
1410 occurs as part of a transaction in which the right of possession
1411 and use of the User Product is transferred to the recipient in
1412 perpetuity or for a fixed term (regardless of how the transaction
1413 is characterized), the Corresponding Source conveyed under this
1414 section must be accompanied by the Installation Information. But
1415 this requirement does not apply if neither you nor any third party
1416 retains the ability to install modified object code on the User
1417 Product (for example, the work has been installed in ROM).
1419 The requirement to provide Installation Information does not
1420 include a requirement to continue to provide support service,
1421 warranty, or updates for a work that has been modified or installed
1422 by the recipient, or for the User Product in which it has been
1423 modified or installed. Access to a network may be denied when the
1424 modification itself materially and adversely affects the operation
1425 of the network or violates the rules and protocols for
1426 communication across the network.
1428 Corresponding Source conveyed, and Installation Information
1429 provided, in accord with this section must be in a format that is
1430 publicly documented (and with an implementation available to the
1431 public in source code form), and must require no special password
1432 or key for unpacking, reading or copying.
1434 7. Additional Terms.
1436 "Additional permissions" are terms that supplement the terms of
1437 this License by making exceptions from one or more of its
1438 conditions. Additional permissions that are applicable to the
1439 entire Program shall be treated as though they were included in
1440 this License, to the extent that they are valid under applicable
1441 law. If additional permissions apply only to part of the Program,
1442 that part may be used separately under those permissions, but the
1443 entire Program remains governed by this License without regard to
1444 the additional permissions.
1446 When you convey a copy of a covered work, you may at your option
1447 remove any additional permissions from that copy, or from any part
1448 of it. (Additional permissions may be written to require their own
1449 removal in certain cases when you modify the work.) You may place
1450 additional permissions on material, added by you to a covered work,
1451 for which you have or can give appropriate copyright permission.
1453 Notwithstanding any other provision of this License, for material
1454 you add to a covered work, you may (if authorized by the copyright
1455 holders of that material) supplement the terms of this License with
1458 a. Disclaiming warranty or limiting liability differently from
1459 the terms of sections 15 and 16 of this License; or
1461 b. Requiring preservation of specified reasonable legal notices
1462 or author attributions in that material or in the Appropriate
1463 Legal Notices displayed by works containing it; or
1465 c. Prohibiting misrepresentation of the origin of that material,
1466 or requiring that modified versions of such material be marked
1467 in reasonable ways as different from the original version; or
1469 d. Limiting the use for publicity purposes of names of licensors
1470 or authors of the material; or
1472 e. Declining to grant rights under trademark law for use of some
1473 trade names, trademarks, or service marks; or
1475 f. Requiring indemnification of licensors and authors of that
1476 material by anyone who conveys the material (or modified
1477 versions of it) with contractual assumptions of liability to
1478 the recipient, for any liability that these contractual
1479 assumptions directly impose on those licensors and authors.
1481 All other non-permissive additional terms are considered "further
1482 restrictions" within the meaning of section 10. If the Program as
1483 you received it, or any part of it, contains a notice stating that
1484 it is governed by this License along with a term that is a further
1485 restriction, you may remove that term. If a license document
1486 contains a further restriction but permits relicensing or conveying
1487 under this License, you may add to a covered work material governed
1488 by the terms of that license document, provided that the further
1489 restriction does not survive such relicensing or conveying.
1491 If you add terms to a covered work in accord with this section, you
1492 must place, in the relevant source files, a statement of the
1493 additional terms that apply to those files, or a notice indicating
1494 where to find the applicable terms.
1496 Additional terms, permissive or non-permissive, may be stated in
1497 the form of a separately written license, or stated as exceptions;
1498 the above requirements apply either way.
1502 You may not propagate or modify a covered work except as expressly
1503 provided under this License. Any attempt otherwise to propagate or
1504 modify it is void, and will automatically terminate your rights
1505 under this License (including any patent licenses granted under the
1506 third paragraph of section 11).
1508 However, if you cease all violation of this License, then your
1509 license from a particular copyright holder is reinstated (a)
1510 provisionally, unless and until the copyright holder explicitly and
1511 finally terminates your license, and (b) permanently, if the
1512 copyright holder fails to notify you of the violation by some
1513 reasonable means prior to 60 days after the cessation.
1515 Moreover, your license from a particular copyright holder is
1516 reinstated permanently if the copyright holder notifies you of the
1517 violation by some reasonable means, this is the first time you have
1518 received notice of violation of this License (for any work) from
1519 that copyright holder, and you cure the violation prior to 30 days
1520 after your receipt of the notice.
1522 Termination of your rights under this section does not terminate
1523 the licenses of parties who have received copies or rights from you
1524 under this License. If your rights have been terminated and not
1525 permanently reinstated, you do not qualify to receive new licenses
1526 for the same material under section 10.
1528 9. Acceptance Not Required for Having Copies.
1530 You are not required to accept this License in order to receive or
1531 run a copy of the Program. Ancillary propagation of a covered work
1532 occurring solely as a consequence of using peer-to-peer
1533 transmission to receive a copy likewise does not require
1534 acceptance. However, nothing other than this License grants you
1535 permission to propagate or modify any covered work. These actions
1536 infringe copyright if you do not accept this License. Therefore,
1537 by modifying or propagating a covered work, you indicate your
1538 acceptance of this License to do so.
1540 10. Automatic Licensing of Downstream Recipients.
1542 Each time you convey a covered work, the recipient automatically
1543 receives a license from the original licensors, to run, modify and
1544 propagate that work, subject to this License. You are not
1545 responsible for enforcing compliance by third parties with this
1548 An "entity transaction" is a transaction transferring control of an
1549 organization, or substantially all assets of one, or subdividing an
1550 organization, or merging organizations. If propagation of a
1551 covered work results from an entity transaction, each party to that
1552 transaction who receives a copy of the work also receives whatever
1553 licenses to the work the party's predecessor in interest had or
1554 could give under the previous paragraph, plus a right to possession
1555 of the Corresponding Source of the work from the predecessor in
1556 interest, if the predecessor has it or can get it with reasonable
1559 You may not impose any further restrictions on the exercise of the
1560 rights granted or affirmed under this License. For example, you
1561 may not impose a license fee, royalty, or other charge for exercise
1562 of rights granted under this License, and you may not initiate
1563 litigation (including a cross-claim or counterclaim in a lawsuit)
1564 alleging that any patent claim is infringed by making, using,
1565 selling, offering for sale, or importing the Program or any portion
1570 A "contributor" is a copyright holder who authorizes use under this
1571 License of the Program or a work on which the Program is based.
1572 The work thus licensed is called the contributor's "contributor
1575 A contributor's "essential patent claims" are all patent claims
1576 owned or controlled by the contributor, whether already acquired or
1577 hereafter acquired, that would be infringed by some manner,
1578 permitted by this License, of making, using, or selling its
1579 contributor version, but do not include claims that would be
1580 infringed only as a consequence of further modification of the
1581 contributor version. For purposes of this definition, "control"
1582 includes the right to grant patent sublicenses in a manner
1583 consistent with the requirements of this License.
1585 Each contributor grants you a non-exclusive, worldwide,
1586 royalty-free patent license under the contributor's essential
1587 patent claims, to make, use, sell, offer for sale, import and
1588 otherwise run, modify and propagate the contents of its contributor
1591 In the following three paragraphs, a "patent license" is any
1592 express agreement or commitment, however denominated, not to
1593 enforce a patent (such as an express permission to practice a
1594 patent or covenant not to sue for patent infringement). To "grant"
1595 such a patent license to a party means to make such an agreement or
1596 commitment not to enforce a patent against the party.
1598 If you convey a covered work, knowingly relying on a patent
1599 license, and the Corresponding Source of the work is not available
1600 for anyone to copy, free of charge and under the terms of this
1601 License, through a publicly available network server or other
1602 readily accessible means, then you must either (1) cause the
1603 Corresponding Source to be so available, or (2) arrange to deprive
1604 yourself of the benefit of the patent license for this particular
1605 work, or (3) arrange, in a manner consistent with the requirements
1606 of this License, to extend the patent license to downstream
1607 recipients. "Knowingly relying" means you have actual knowledge
1608 that, but for the patent license, your conveying the covered work
1609 in a country, or your recipient's use of the covered work in a
1610 country, would infringe one or more identifiable patents in that
1611 country that you have reason to believe are valid.
1613 If, pursuant to or in connection with a single transaction or
1614 arrangement, you convey, or propagate by procuring conveyance of, a
1615 covered work, and grant a patent license to some of the parties
1616 receiving the covered work authorizing them to use, propagate,
1617 modify or convey a specific copy of the covered work, then the
1618 patent license you grant is automatically extended to all
1619 recipients of the covered work and works based on it.
1621 A patent license is "discriminatory" if it does not include within
1622 the scope of its coverage, prohibits the exercise of, or is
1623 conditioned on the non-exercise of one or more of the rights that
1624 are specifically granted under this License. You may not convey a
1625 covered work if you are a party to an arrangement with a third
1626 party that is in the business of distributing software, under which
1627 you make payment to the third party based on the extent of your
1628 activity of conveying the work, and under which the third party
1629 grants, to any of the parties who would receive the covered work
1630 from you, a discriminatory patent license (a) in connection with
1631 copies of the covered work conveyed by you (or copies made from
1632 those copies), or (b) primarily for and in connection with specific
1633 products or compilations that contain the covered work, unless you
1634 entered into that arrangement, or that patent license was granted,
1635 prior to 28 March 2007.
1637 Nothing in this License shall be construed as excluding or limiting
1638 any implied license or other defenses to infringement that may
1639 otherwise be available to you under applicable patent law.
1641 12. No Surrender of Others' Freedom.
1643 If conditions are imposed on you (whether by court order, agreement
1644 or otherwise) that contradict the conditions of this License, they
1645 do not excuse you from the conditions of this License. If you
1646 cannot convey a covered work so as to satisfy simultaneously your
1647 obligations under this License and any other pertinent obligations,
1648 then as a consequence you may not convey it at all. For example,
1649 if you agree to terms that obligate you to collect a royalty for
1650 further conveying from those to whom you convey the Program, the
1651 only way you could satisfy both those terms and this License would
1652 be to refrain entirely from conveying the Program.
1654 13. Use with the GNU Affero General Public License.
1656 Notwithstanding any other provision of this License, you have
1657 permission to link or combine any covered work with a work licensed
1658 under version 3 of the GNU Affero General Public License into a
1659 single combined work, and to convey the resulting work. The terms
1660 of this License will continue to apply to the part which is the
1661 covered work, but the special requirements of the GNU Affero
1662 General Public License, section 13, concerning interaction through
1663 a network will apply to the combination as such.
1665 14. Revised Versions of this License.
1667 The Free Software Foundation may publish revised and/or new
1668 versions of the GNU General Public License from time to time. Such
1669 new versions will be similar in spirit to the present version, but
1670 may differ in detail to address new problems or concerns.
1672 Each version is given a distinguishing version number. If the
1673 Program specifies that a certain numbered version of the GNU
1674 General Public License "or any later version" applies to it, you
1675 have the option of following the terms and conditions either of
1676 that numbered version or of any later version published by the Free
1677 Software Foundation. If the Program does not specify a version
1678 number of the GNU General Public License, you may choose any
1679 version ever published by the Free Software Foundation.
1681 If the Program specifies that a proxy can decide which future
1682 versions of the GNU General Public License can be used, that
1683 proxy's public statement of acceptance of a version permanently
1684 authorizes you to choose that version for the Program.
1686 Later license versions may give you additional or different
1687 permissions. However, no additional obligations are imposed on any
1688 author or copyright holder as a result of your choosing to follow a
1691 15. Disclaimer of Warranty.
1693 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
1694 APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE
1695 COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS"
1696 WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
1697 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
1698 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE
1699 RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
1700 SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
1701 NECESSARY SERVICING, REPAIR OR CORRECTION.
1703 16. Limitation of Liability.
1705 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
1706 WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES
1707 AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR
1708 DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
1709 CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
1710 THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
1711 BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
1712 PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
1713 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
1714 THE POSSIBILITY OF SUCH DAMAGES.
1716 17. Interpretation of Sections 15 and 16.
1718 If the disclaimer of warranty and limitation of liability provided
1719 above cannot be given local legal effect according to their terms,
1720 reviewing courts shall apply local law that most closely
1721 approximates an absolute waiver of all civil liability in
1722 connection with the Program, unless a warranty or assumption of
1723 liability accompanies a copy of the Program in return for a fee.
1725 END OF TERMS AND CONDITIONS
1727 How to Apply These Terms to Your New Programs
1728 =============================================
1730 If you develop a new program, and you want it to be of the greatest
1731 possible use to the public, the best way to achieve this is to make it
1732 free software which everyone can redistribute and change under these
1735 To do so, attach the following notices to the program. It is safest
1736 to attach them to the start of each source file to most effectively
1737 state the exclusion of warranty; and each file should have at least the
1738 "copyright" line and a pointer to where the full notice is found.
1740 ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES.
1741 Copyright (C) YEAR NAME OF AUTHOR
1743 This program is free software: you can redistribute it and/or modify
1744 it under the terms of the GNU General Public License as published by
1745 the Free Software Foundation, either version 3 of the License, or (at
1746 your option) any later version.
1748 This program is distributed in the hope that it will be useful, but
1749 WITHOUT ANY WARRANTY; without even the implied warranty of
1750 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1751 General Public License for more details.
1753 You should have received a copy of the GNU General Public License
1754 along with this program. If not, see <http://www.gnu.org/licenses/>.
1756 Also add information on how to contact you by electronic and paper mail.
1758 If the program does terminal interaction, make it output a short notice
1759 like this when it starts in an interactive mode:
1761 PROGRAM Copyright (C) YEAR NAME OF AUTHOR
1762 This program comes with ABSOLUTELY NO WARRANTY; for details
1763 type 'show w'. This is free software, and you are
1764 welcome to redistribute it under certain conditions;
1765 type 'show c' for details.
1767 The hypothetical commands 'show w' and 'show c' should show the
1768 appropriate parts of the General Public License. Of course, your
1769 program's commands might be different; for a GUI interface, you would
1772 You should also get your employer (if you work as a programmer) or
1773 school, if any, to sign a "copyright disclaimer" for the program, if
1774 necessary. For more information on this, and how to apply and follow
1775 the GNU GPL, see <http://www.gnu.org/licenses/>.
1777 The GNU General Public License does not permit incorporating your
1778 program into proprietary programs. If your program is a subroutine
1779 library, you may consider it more useful to permit linking proprietary
1780 applications with the library. If this is what you want to do, use the
1781 GNU Lesser General Public License instead of this License. But first,
1782 please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.
1785 File: ksba.info, Node: Concept Index, Next: Function and Data Index, Prev: Copying, Up: Top
1791 File: ksba.info, Node: Function and Data Index, Prev: Concept Index, Up: Top
1793 Function and Data Index
1794 ***********************
1799 * ksba_cert_get_authority_info_access: Retrieving attributes.
1801 * ksba_cert_get_auth_key_id: Retrieving attributes.
1803 * ksba_cert_get_cert_policies: Retrieving attributes.
1805 * ksba_cert_get_crl_dist_point: Retrieving attributes.
1807 * ksba_cert_get_digest_algo: Retrieving attributes.
1809 * ksba_cert_get_extension: Retrieving attributes.
1811 * ksba_cert_get_ext_key_usages: Retrieving attributes.
1813 * ksba_cert_get_image: Retrieving attributes.
1815 * ksba_cert_get_issuer: Retrieving attributes.
1817 * ksba_cert_get_key_usage: Retrieving attributes.
1819 * ksba_cert_get_public_key: Retrieving attributes.
1821 * ksba_cert_get_serial: Retrieving attributes.
1823 * ksba_cert_get_sig_val: Retrieving attributes.
1825 * ksba_cert_get_subject: Retrieving attributes.
1827 * ksba_cert_get_subject_info_access: Retrieving attributes.
1829 * ksba_cert_get_subj_key_id: Retrieving attributes.
1831 * ksba_cert_get_user_data: User data. (line 26)
1832 * ksba_cert_get_validity: Retrieving attributes.
1834 * ksba_cert_hash: Retrieving attributes.
1836 * ksba_cert_init_from_mem: Creating certificates.
1838 * ksba_cert_is_ca: Retrieving attributes.
1840 * ksba_cert_new: Creating certificates.
1842 * ksba_cert_read_der: Creating certificates.
1844 * ksba_cert_ref: Creating certificates.
1846 * ksba_cert_release: Creating certificates.
1848 * ksba_cert_set_user_data: User data. (line 11)
1849 * ksba_cert_t: Certificate Handling.
1851 * ksba_check_version: Version Check. (line 12)
1852 * ksba_cms_get_content_oid: CMS Parser. (line 89)
1853 * ksba_cms_get_content_type: CMS Parser. (line 54)
1854 * ksba_cms_new: CMS Basics. (line 16)
1855 * ksba_cms_parse: CMS Parser. (line 13)
1856 * ksba_cms_release: CMS Basics. (line 25)
1857 * ksba_cms_set_reader_writer: CMS Basics. (line 31)
1858 * ksba_cms_t: CMS Basics. (line 10)
1859 * ksba_content_t: CMS Parser. (line 61)
1860 * ksba_dn_teststr: DNs. (line 9)
1861 * ksba_isotime_t: Retrieving attributes.
1863 * ksba_name_enum: Names. (line 17)
1864 * ksba_name_get_uri: Names. (line 36)
1865 * ksba_name_release: Names. (line 13)
1866 * ksba_name_t: Names. (line 10)
1867 * ksba_sexp_t: Certificate Handling.
1869 * ksba_stop_reason_t: CMS Basics. (line 12)
1875 Node: Introduction
\7f2778
1876 Node: Getting Started
\7f3056
1877 Node: Features
\7f3922
1878 Node: Overview
\7f5013
1879 Node: Preparation
\7f5262
1881 Node: Version Check
\7f6341
1882 Node: Building the source
\7f7433
1883 Node: Certificate Handling
\7f9284
1884 Node: Creating certificates
\7f10265
1885 Node: Retrieving attributes
\7f12726
1886 Node: Setting attributes
\7f26944
1887 Node: User data
\7f27209
1889 Node: CMS Basics
\7f29588
1890 Node: CMS Parser
\7f31651
1892 Node: PKCS10
\7f35912
1893 Node: Utilities
\7f36173
1897 Node: Error Handling
\7f40224
1898 Node: Component Labels
\7f41579
1899 Node: Copying
\7f43142
1900 Node: Concept Index
\7f80669
1901 Node: Function and Data Index
\7f80797