1 This is ksba.info, produced by makeinfo version 5.2 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.3.4, last updated 15 March 2013, of 'The KSBA
12 Reference Manual', for Version 1.3.4.
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.3.4, last updated 15 March 2013, of 'The KSBA
29 Reference Manual', for Version 1.3.4 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 a small
232 helper program 'ksba-config' that knows about the path to the include
233 file and other configuration options. The options that need to be added
234 to the compiler invocation at compile time are output by the '--cflags'
235 option of 'ksba-config'. The following example shows how it can be used
238 gcc -c foo.c `ksba-config --cflags`
240 Adding the output of 'ksba-config --cflags' to the compiler's command
241 line will ensure that the compiler can find the 'ksba.h' header file.
243 A similar problem occurs when linking the program with the library.
244 Again, the compiler has to find the library files. For this to work,
245 the path to the library files has to be added to the library search path
246 (via the '-L' option). For this, the option '--libs' of 'ksba-config'
247 can be used. For convenience, this option also outputs all other
248 options that are required to link the program with the 'KSBA' libraries
249 (in particular, the '-lksba' option). The example shows how to link
250 'foo.o' with the 'KSBA' libraries to a program 'foo'.
252 gcc -o foo foo.o `ksba-config --libs`
254 Of course you can also combine both examples to a single command by
255 specifying both options to 'ksba-config':
257 gcc -o foo foo.c `ksba-config --cflags --libs`
260 File: ksba.info, Node: Certificate Handling, Next: CMS, Prev: Preparation, Up: Top
262 3 How to work with X.509 certificates.
263 **************************************
265 One of the most complex data formats are the X.509 certificates. KSBA
266 provides an easy to use interface to handle them.
268 -- Data type: ksba_cert_t
269 The 'ksba_cert_t' type is a handle for an X.509 certificate.
271 -- Data type: ksba_sexp_t
272 The 'ksba_sexp_t' type describes a canonically encoded S-expression
273 stored in a memory buffer. It is alias for 'unsigned char *'.
274 Note that a length argument is not required because the length of
275 such an S-expression is intrinsically available.
279 * Creating certificates:: How to create a certificate object.
280 * Retrieving attributes:: How to get the attributes of a certificate.
281 * Setting attributes:: How to set certificates attributes.
282 * User data:: How to associate other data with a certificate.
285 File: ksba.info, Node: Creating certificates, Next: Retrieving attributes, Up: Certificate Handling
287 3.1 How to create a certificate object
288 ======================================
290 This section explains how to create a certificate object, initialize it,
291 copy it and eventually destroy it.
293 -- Function: ksba_cert_t ksba_cert_new (void)
294 The function 'ksba_cert_new' creates a new certificate object and
295 returns a handle for it. The certificate object has initially one
298 The only reason why this function may fail is an out-of-memory
299 condition in which case 'NULL' is returned. You might then get the
300 actual error code using 'gpg_error_from_errno (errno)'.
302 -- Function: void ksba_cert_ref (ksba_cert_t CERT)
303 The function 'ksba_cert_ref' bumps the reference counter of the
304 certificate object up by one. Thus an extra 'ksba_cert_release' is
305 required to actually release the memory used for the object.
307 -- Function: void ksba_cert_release (ksba_cert_t CERT)
308 The function 'ksba_cert_release' reduces the number of references
309 to the certificate object with the handle CERT. If this was the
310 last reference, it will also destroy the object and releases all
311 associated resources. It is okay to pass 'NULL' to the function in
312 which case nothing happens.
314 -- Function: gpg_error_t ksba_cert_read_der (ksba_cert_t CERT,
315 ksba_reader_t READER)
317 Read the next certificate from the READER object and store it in
318 the certificate object CERT for future access. The certificate is
319 parsed and rejected if it has any syntactical or semantical error
320 (i.e. does not match the ASN.1 description).
322 The function returns '0' if the operation was successfully
323 performed. An error code is returned on failure.
325 -- Function: gpg_error_t ksba_cert_init_from_mem (ksba_cert_t CERT,
326 const void *BUFFER, size_t LENGTH)
328 Parse the BUFFER which should contain a DER encoded certificate of
329 LENGTH and initialize the certificate object CERT with it. This
330 function is intended as a convenience function to be used when a
331 certificate is already available in a internal memory buffer. This
332 avoids the extra code needed to setup the reader object. Note that
333 CERT must be a valid certificate object.
335 The function returns '0' if the operation was successfully
336 performed. An error code is returned on failure.
339 File: ksba.info, Node: Retrieving attributes, Next: Setting attributes, Prev: Creating certificates, Up: Certificate Handling
341 3.2 How to get the attributes of a certificate
342 ==============================================
344 The functions in this section allow accessing the attributes of a
345 certificate in a well defined manner. An error will be returned if the
346 certificate object has not yet been initialized by means of
347 'ksba_cert_read_der' or 'ksba_cert_init_from_mem'.
349 -- Function: const unsigned char * ksba_cert_get_image
350 (ksba_cert_t CERT, size_t *R_LENGTH)
352 This function returns a pointer to the DER encoded buffer with the
353 raw certificate. The length of that buffer gets stored at
354 R_LENGTH. This function is useful to export or store the raw
357 The function returns 'NULL' on error or a pointer to a buffer with
358 the raw certificate data. That pointer is only valid as long as
359 the certificate object CERT is valid and has not been
362 -- Function: gpg_error_t ksba_cert_hash (ksba_cert_t CERT, int WHAT,
363 void (*HASHER)(void *, const void *, size_t length),
366 This function feeds the data which is expected to be hashed into
367 the supplied function HASHER, where the first argument passed is
368 HASHER_ARG, the second the pointer to the data to be hashed and the
369 third the length of this data.
371 The function returns '0' on success or an error code when something
372 goes wrong. The HASHER function is not expected to return an
373 error; instead the caller should setup that function in a way to
374 convey encountered errors by means of the HASHER_ARG. Note that a
375 hash function is in general not expected to yield errors anyway.
377 -- Function: const char * ksba_cert_get_digest_algo (ksba_cert_t CERT)
379 Figure out the the digest algorithm used for the signature and
380 return its OID in dotted decimal format. This function is most
381 likely used to setup the hash context before calling
384 The function returns 'NULL' for an error; on success a constant
385 string with the OID is returned. This string is valid as long the
386 certificate object is valid.
388 -- Function: ksba_sexp_t ksba_cert_get_serial (ksba_cert_t CERT)
390 The function returns the serial number of the certificate CERT.
391 The serial number is an integer returned as an canonical encoded
392 S-expression with just one element. The caller must free the
393 returned value. The value 'NULL' is returned in case of error.
395 -- Function: char * ksba_cert_get_issuer (ksba_cert_t CERT, int IDX)
397 With IDX given as '0', this function returns the Distinguished Name
398 (DN) of the certificate issuer; this usually is the name of a
399 certification authority (CA). The format of the returned string is
400 in accordance with RFC-2253. 'NULL' is returned if the DN is not
401 available; This is a severe error and actually should have been
402 caught by the certificate reading function.
404 With IDX greater than zero, the function may be used to enumerate
405 alternate issuer names. The function returns 'NULL' when there are
406 no more alternate names. Only alternate names recognized by
407 'libksba' are returned, others are simply skipped. The format of
408 the returned name is either a RFC-2253 formated string which can be
409 detected by checking whether the first character is a letter or
410 digit. RFC-822 conformant email addresses are returned enclosed in
411 angle brackets; the opening angle bracket should be used to detect
412 this. Other formats are returned as an S-Expression in canonical
413 format, so a opening parenthesis should be used to detect this
414 encoding. The name may include binary null characters, thus strlen
415 may return a length shorter than actually used. The real length is
416 implicitly given by the structure of the S-expression, an extra
417 null is appended for safety reasons.
419 The caller must free the returned string using 'ksba_free' or
420 whatever function has been registered as a replacement.
422 -- Function: char * ksba_cert_get_subject (ksba_cert_t CERT, int IDX)
424 With IDX given as '0', this function returns the Distinguished Name
425 (DN) of the certificate's subject. The format of the returned
426 string is in accordance with RFC-2253. 'NULL' is returned if the
429 With IDX greater than zero, the function may be used to enumerate
430 alternate subject names. The function returns 'NULL' when there
431 are no more alternate names. Only alternate names recognized by
432 'libksba' are returned, others are simply skipped. The format of
433 the returned name is either a RFC-2253 formated string which can be
434 detected by checking whether the first character is a letter or
435 digit. RFC-2822 conform email addresses are returned enclosed in
436 angle brackets; the opening angle bracket should be used to detect
437 this. Other formats are returned as an S-Expression in canonical
438 format, so a opening parenthesis should be used to detect this
439 encoding, the name may include binary null characters, thus strlen
440 may return a length shorter than actually used. The real length is
441 implicitly given by the structure of the S-expression, an extra
442 null is appended for safety reasons.
444 The caller must free the returned string using 'ksba_free' or
445 whatever function has been registered as a replacement.
447 -- Data type: ksba_isotime_t
448 Due to problems with the C data type 'time_t', which will overflow
449 on most 32 bit machines in the year 2038, it was not advisable to
450 use this type for referencing times stored in certificates.
451 Instead, you should use the 'ksba_isotime_t' type, which can
452 represent any time since the year 0.
454 It is implemented as a buffer of 16 bytes and may be handled like a
455 standard string. It should be initialized to zero (i.e. the first
456 byte needs to be 0x00) if it does not hold a valid date. Date
457 values themselves are stored in ISO format and assumed to be
458 referenced from UTC. The string with the date value is always
459 guaranteed to be of length 15 and having a format like:
460 '"19610711T172059"'. Note that the 'T' is required by ISO rules.
462 A simple assignment of these data types is not a good idea. You
463 may use 'strcpy' or better a specialized function like:
466 copy_time (ksba_isotime_t d, const ksba_isotime_t s)
474 For reasons of documentation a special function should also be used
475 to compare such times:
478 cmp_time (const ksba_isotime_t a, const ksba_isotime_t b)
480 return strcmp (a, b);
483 -- Function: gpg_error_t ksba_cert_get_validity
484 (ksba_cert_t CERT, int WHAT, ksba_isotime_t TIMEBUF)
486 Return the validity dates from the certificate. If no value is
487 available an empty date object (i.e. a 'strlen' will be stored at
488 TIMEBUF, otherwise it will receive the date. On failure an error
491 To return the 'notBefore' date, the value '0' must be supplied for
492 WHAT; '1' yields the 'notAfter' value.
494 -- Function: ksba_sexp_t ksba_cert_get_public_key (ksba_cert_t CERT)
496 [This needs to get written - for now please see libksba/src/cert.c]
498 -- Function: ksba_sexp_t ksba_cert_get_sig_val (ksba_cert_t CERT)
500 [This needs to get written - for now please see libksba/src/cert.c]
502 -- Function: gpg_error_t ksba_cert_get_extension
503 (ksba_cert_t CERT, int IDX, char const **R_OID, int *R_CRIT, size_t *R_DEROFF, size_t *R_DERLEN)
505 [This needs to get written - for now please see libksba/src/cert.c]
507 -- Function: gpg_error_t ksba_cert_is_ca
508 (ksba_cert_t CERT, int *R_CA, int *R_PATHLEN)
510 Return information on the basicConstraint (2.5.19.19) of CERT. R_CA
511 receives true if this is a CA and only in that case R_PATHLEN is
512 set to the maximum certification path length or -1 if there is no
515 -- Function: gpg_error_t ksba_cert_get_key_usage
516 (ksba_cert_t CERT, unsigned int *R_FLAGS)
518 Get the key usage flags. The function returns 'GPG_ERR_NO_DATA' if
519 no key usage is specified. The usage flags are as shown in
520 RFC3280, section 4.2.1.3. The key usage flags are represented by a
521 bitmask, and you can test each bit using symbolic constants, which
522 tells you if that usage is set on the certificate. The constants
525 'KSBA_KEYUSAGE_DIGITAL_SIGNATURE'
526 Usable for digitalSignature.
527 'KSBA_KEYUSAGE_NON_REPUDIATION'
528 Usable for nonRepudiation.
529 'KSBA_KEYUSAGE_KEY_ENCIPHERMENT'
530 Usable for keyEncipherment.
531 'KSBA_KEYUSAGE_DATA_ENCIPHERMENT'
532 Usable for dataEncipherment.
533 'KSBA_KEYUSAGE_KEY_AGREEMENT'
534 Usable for for keyAgreement.
535 'KSBA_KEYUSAGE_KEY_CERT_SIGN'
536 Usable for keyCertSign.
537 'KSBA_KEYUSAGE_CRL_SIGN'
539 'KSBA_KEYUSAGE_ENCIPHER_ONLY'
540 Usable for encipherOnly.
541 'KSBA_KEYUSAGE_DECIPHER_ONLY'
542 Usable for decipherOnly.
544 These are the basic constraints on usage of a certificate. If you
545 need to get additional constraints, see
546 'ksba_cert_get_ext_key_usages'.
548 -- Function: gpg_error_t ksba_cert_get_ext_key_usages
549 (ksba_cert_t CERT, char **RESULT)
551 Return a string containing the extended usages for the certificate,
552 delimited by linefeeds.
554 -- Function: gpg_error_t ksba_cert_get_cert_policies
555 (ksba_cert_t CERT, char **R_POLICIES)
557 Return a string with the certificatePolicies delimited by
558 linefeeds. The return values may be extended to carry more
559 information per line, so the caller should only use the first
560 white-space delimited token per line. The function returns
561 'GPG_ERR_NO_DATA' when this extension is not used. Caller must
562 free the returned value.
564 -- Function: gpg_error_t ksba_cert_get_crl_dist_point
565 (ksba_cert_t CERT, int IDX, ksba_name_t *R_DISTPOINT, ksba_name_t *R_ISSUER, unsigned int *R_REASON)
567 Return the CRLDistPoints given in the certificate extension of
568 certificate CERT. IDX should be iterated starting from 0 until the
569 function returns 'GPG_ERR_EOF'. R_DISTPOINT returns a ksba_name_t
570 object with the distribution point name(s); the return value may be
571 'NULL' to indicate that this name is not available. R_ISSUER
572 returns the CRL issuer; if the returned value is 'NULL' the caller
573 should assume that the CRL issuer is the same as the certificate
574 issuer. R_REASON returns the reason for the CRL. This is a bit
575 encoded value with no bit set if no reason has been specified in
578 The caller may pass 'NULL' to any of the pointer arguments if he is
579 not interested in this value. The return values for R_DISTPOINT
580 and R_ISSUER must be released by the caller using
583 -- Function: gpg_error_t ksba_cert_get_subj_key_id
584 (ksba_cert_t CERT, int *R_CRIT, ksba_sexp_t *R_KEYID)
586 Return the subjectKeyIdentifier extension as a simple allocated
587 S-expression at the address of R_KEYID. 0 is returned on success,
588 'GPG_ERR_NO_DATA' if no such extension is available or any other
589 error code. If R_CRIT is not passed as 'NULL', the critical flag
590 of this is extension is stored at this address.
592 -- Function: gpg_error_t ksba_cert_get_auth_key_id
593 (ksba_cert_t CERT, ksba_sexp_t *R_KEYID, ksba_name_t *R_NAME, ksba_sexp_t *R_SERIAL)
595 Return the authorityKeyIdentifier in R_NAME and R_SERIAL or in
596 R_KEYID. 'GPG_ERR_NO_DATA' is returned if no
597 authorityKeyIdentifier has been found. This error code is also
598 returned if R_KEYID has been given as NULL and only an
599 authorityKeyIdentifier with the keyIdentifier method is available.
601 -- Function: gpg_error_t ksba_cert_get_authority_info_access
602 (ksba_cert_t CERT, int IDX, char **R_METHOD, ksba_name_t *R_LOCATION)
604 Return the authorityInfoAccess attributes. IDX should be iterated
605 starting from 0 until this function returns 'GPG_ERR_EOF'.
606 R_METHOD returns an allocated string with the OID of one item and
607 R_LOCATION returns the GeneralName for that OID. The returned
608 values for R_METHOD and R_LOCATION must be released by the caller
609 unless the function returned an error; the function will however
610 make sure that R_METHOD and R_LOCATION will point to 'NULL' if the
611 function returns an error.
613 See RFC-2459, section 4.2.2.1 for the definition of this attribute.
615 -- Function: gpg_error_t ksba_cert_get_subject_info_access
616 (ksba_cert_t CERT, int IDX, char **R_METHOD, ksba_name_t *R_LOCATION)
618 Return the subjectInfoAccess attributes. IDX should be iterated
619 starting from 0 until this function returns 'GPG_ERR_EOF'.
620 R_METHOD returns an allocated string with the OID of one item and
621 R_LOCATION returns the GeneralName for that OID. The returned
622 values for R_METHOD and R_LOCATION must be released by the caller
623 unless the function returned an error; the function will however
624 make sure that R_METHOD and R_LOCATION will point to 'NULL' if the
625 function returns an error.
627 See RFC-2459, section 4.2.2.2 for the definition of this attribute.
630 File: ksba.info, Node: Setting attributes, Next: User data, Prev: Retrieving attributes, Up: Certificate Handling
632 3.3 How to set certificate attributes
633 =====================================
635 [This needs to be written. For example code see newpg/sm/sign.c]
638 File: ksba.info, Node: User data, Prev: Setting attributes, Up: Certificate Handling
640 3.4 How to associate other data with a certificate.
641 ===================================================
643 Certificate objects play a central role in many applications and often
644 it is desirable to associate other data with the certificate to avoid
645 wrapping the certificate object into an own object. 'KSBA' provides a
646 mechanism for this by means of two functions:
648 -- Function: gpg_error_t ksba_cert_set_user_data
649 (ksba_cert_t CERT, const char *KEY, const void *DATA, size_t DATALEN)
651 Stores arbitrary data along with a certificate. The data is
652 expected in the buffer DATA of length DATALEN. It will be stored
653 under the string KEY. If data is already stored under this key it
654 will be replaced by the new data. Using 'NULL' for DATA will
655 effectively delete the data.
657 On error (i.e. out of memory) an already existing data object
658 stored under KEY may get deleted.
660 *Caution:* This function is definitely not thread safe because we
661 don't employ any locking mechanisms.
663 -- Function: gpg_error_t ksba_cert_get_user_data (ksba_cert_t CERT, const char *KEY,
664 void *BUFFER, size_t BUFFERLEN, size_t *DATALEN)
666 Return user data for certificate CERT stored under the string KEY.
667 The caller needs to provide a suitable large BUFFER and the usable
668 length of this buffer in BUFFERLEN. If DATALEN is not 'NULL', the
669 length of the data stored in BUFFER will be stored there.
671 If BUFFER is given as 'NULL', BUFFERLEN will be ignored and the
672 required length of the buffer will be returned at DATALEN.
674 On success 0 is returned. If no data is stored under the given
675 key, 'GPG_ERR_NOT_FOUND' is returned. If the provided buffer is
676 too short and BUFFER is not 'NULL', 'GPG_ERR_BUFFER_TOO_SHORT' will
680 File: ksba.info, Node: CMS, Next: CRLs, Prev: Certificate Handling, Up: Top
682 4 Mastering the Cryptographic Message Syntax
683 ********************************************
685 The CMS is also known under the name PKCS#7. Is is a cryptographic
686 framework for securing data transactions and storage, much like OpenPGP.
687 It is heavily based on X.509 semantics and for example used with the
688 email encryption protocol S/MIME.
696 File: ksba.info, Node: CMS Basics, Next: CMS Parser, Up: CMS
701 All operations with the CMS framework require the use of a so called CMS
702 object which is internally used to keep track of the current state and
703 to store some meta information.
705 -- Data type: ksba_cms_t
706 The 'ksba_cms_t' type is used for this CMS object.
707 -- Data type: ksba_stop_reason_t
708 The 'ksba_stop_reason_t' type is an enumeration used for
709 communication between the phases of a parsing or building process.
711 -- Function: ksba_cms_t ksba_cms_new (void)
713 This function creates a new CMS object. The only reason the
714 function may fail is an out-of-memory condition in which case
715 'NULL' is returned. It is safe for the caller to translate this to
716 the standard error code 'GPG_ERR_ENOMEM'. Any object created with
717 this function should be released after use by using
720 -- Function: void ksba_cms_release (ksba_cms_t CMS)
722 Release all resources associated with the CMS object. It is
723 perfectly okay to pass 'NULL' to this function in which case
726 -- Function: gpg_error_t ksba_cms_set_reader_writer
727 (ksba_cms_t CMS, ksba_reader_t R, ksba_writer_t W)
729 About all usages of the CMS framework require some input and output
730 data (great surprise!). To accomplish this in the most abstract
731 way, no direct output functions are used - instead special reader
732 and writer objects are used instead. Depending on the desired
733 operations either a reader, a writer or both must be given.
734 Associate a reader object with CMS by passing it as R and a writer
735 object by passing it as W. Note that no reference counting is
736 done,so make sure that those objects have a lifetime at least as
739 If you forget to set these objects, you will get an appropriate
740 error later when data is actually to be read or written. The
741 function returns zero on success or an error code when invalid
745 File: ksba.info, Node: CMS Parser, Prev: CMS Basics, Up: CMS
750 KSBA includes a versatile CMS parser for encryption (enveloped data) and
751 digital signing. The parser is capable of handling arbitrary amounts of
752 data without requiring much memory. Well, certain objects are build in
753 memory because it can be assumed that those objects are limited in size;
754 e.g. it does not make sense to use a video clip as the DN despite the
755 fact that the standard does not forbid it.
757 -- Function: gpg_error_t ksba_cms_parse
758 (ksba_cms_t CMS, ksba_stop_reason_t *R_STOPREASON)
760 This is the core function of the parser and commonly used in a
761 loop. The parsing process is divided into several phases to allow
762 the user to get information at the right time and prepare for
763 further processing. The caller has to act on certain stop reasons
764 which are returned by R_STOPREASON and set up things accordingly;
765 KSBA may introduce new stop reasons to let the caller know other
766 details; there is no need for the caller to act on every stop
767 reason; it should only do so for reasons that the caller
768 understands and which are mandatory. The function will return with
769 an error if the caller did not setup things correctly for certain
772 The use of this function is best explained by an example, leaving out
776 ksba_cms_parse (cms, &stopreason);
777 if (stopreason == KSBA_SR_BEGIN_DATA)
780 decrypt_session_key ();
781 setup_bulk_decryption ();
783 else if (stopreason == KSBA_SR_END_DATA)
788 while (stopreason != KSBA_SR_READY);
789 This function assumes that the parsed data is so called 'enveloped
792 As CMS provides a common framework for a variety of data formats, it
793 is probably very useful to check the type of that data very early. This
794 can be accomplished by hooking into the stop reason
795 'KSBA_SR_GOT_CONTENT' and retrieving the content using the following
798 -- Function: ksba_content_t ksba_cms_get_content_type
799 (ksba_cms_t CMS, int WHAT)
801 By using a value of '0' for WHAT this function returns the content
802 type of the outer container; using '1' does return the content type
803 of the enclosed object.
805 -- Data type: ksba_content_t
806 The 'ksba_content_t' type is an enumeration used to describe
807 the content of a CMS message. Here is a list of possible
811 No content type known (value '0')
814 The content is plain data, not further interpreted.
816 'KSBA_CT_SIGNED_DATA'
817 The content is an signed CMS object. This also includes
818 the case of a detached signature where no actual data is
819 included in the message.
821 'KSBA_CT_ENVELOPED_DATA'
822 The content is encrypted using a session key.
824 'KSBA_CT_DIGESTED_DATA'
827 'KSBA_CT_ENCRYPTED_DATA'
833 -- Function: const char * ksba_cms_get_content_oid
834 (ksba_cms_t CMS, int WHAT)
836 Return the object ID of CMS. This is a constant string valid as
837 long as the context is valid and no new parse is started. This
838 function is similar to 'ksba_cms_get_content_type' but returns the
839 OID actually used in the data. Depending on the value of WHAT
840 different values are returned: Using a value of '0' yields the OID
841 of the outer container, a value of '1' yields the OID of the inner
842 container if available and the value '2' returns the OID of the
843 algorithm used to encrypt the inner container.
846 File: ksba.info, Node: CRLs, Next: PKCS10, Prev: CMS, Up: Top
848 5 Certification Revocation Lists
849 ********************************
851 KSBA also comes with an API to process certification revocation lists.
852 The API is similar to the CMS one but returns the contents entry by
856 File: ksba.info, Node: PKCS10, Next: Utilities, Prev: CRLs, Up: Top
858 6 Certification Requests
859 ************************
861 When using decentral generated keys, it is necessary to send out special
862 formated messages so that a CA can generate the certificate.
865 File: ksba.info, Node: Utilities, Next: Error Handling, Prev: PKCS10, Up: Top
870 A few utility function and objects are available. Some of them must be
871 used to support some of the main functions.
875 * Names:: General Names object
876 * OIDs:: Object Identifier helpers
877 * DNs:: Distinguished Name helpers
880 File: ksba.info, Node: Names, Next: OIDs, Up: Utilities
882 7.1 General Names object
883 ========================
885 This is an object to handle some of the names used in X.509. We need
886 this object approach because those names may come as a set and there is
887 no other clean way to access them.
889 -- Data type: ksba_name_t
890 The 'ksba_name_t' type is an object to represent names sets.
892 -- Function: void ksba_name_release (ksba_name_t NAME)
894 This function releases the object NAME. Passing 'NULL' is allowed.
896 -- Function: const char * ksba_name_enum (ksba_name_t NAME, int IDX)
898 By iterating IDX up starting with 0, this function returns all
899 General Names stored in NAME. The format of the returned name is
900 either a RFC-2253 formated one which can be detected by checking
901 whether the first character is letter or a digit. RFC 2822
902 conformant email addresses are returned enclosed in angle brackets,
903 the opening angle bracket should be used to detect this. Other
904 formats are returned as an S-Expression in canonical format, so an
905 opening parenthesis may be used to detect this encoding, in this
906 case the name may include binary null characters, so strlen might
907 return a length shorter than actually used, the real length is
908 implicitly given by the structure of the S-Exp, an extra null is
909 appended for safety reasons. One common format return is a
910 Universal Resource Identifier which has the S-expression: '(uri
913 The returned string has the same lifetime as NAME.
915 -- Function: char * ksba_name_get_uri (ksba_name_t NAME, int IDX)
917 Convenience function to return names representing an URI. Caller
918 must free the returned value. Note that this function should not
919 be used to enumerate the names.
921 Here is an example on how you can use this function to enumerate
925 print_names (ksba_name_t name)
930 for (idx=0; (s = ksba_name_enum (name, idx)); idx++)
932 char *p = ksba_name_get_uri (name, idx);
942 File: ksba.info, Node: OIDs, Next: DNs, Prev: Names, Up: Utilities
944 7.2 Object Identifier helpers
945 =============================
947 [This needs to get written - for now please see libksba/src/oids.c]
950 File: ksba.info, Node: DNs, Prev: OIDs, Up: Utilities
952 7.3 Distinguished Name helpers
953 ==============================
955 These are helper functions for the so called distinguished names. They
956 are used for example as the issuer and subject name.
958 -- Function: gpg_error_t ksba_dn_teststr (const char *STRING, int SEQ,
959 size_t *RERROFF, size_t *RERRLEN)
961 Assuming that STRING contains an RFC-2253 encoded string, test
962 whether this string may be passed as a valid DN to libksba. On
963 success the functions returns '0'. On error the function returns
964 an error code and stores the offset of the erroneous part at
965 RERROFF. RERRLEN will then receive the length of the erroneous
968 This function is mostly useful to test whether a certain component
969 label is supported. SEQ should be passed as '0' for now. Any of
970 RERROFF and RERRLEN may be passed as NULL if the caller is not
971 interested at this value.
973 gpg_error_t ksba_dn_str2der (const char *string, void **rder, size_t
976 gpg_error_t ksba_dn_der2str (const void *der, size_t derlen, char
980 File: ksba.info, Node: Error Handling, Next: Component Labels, Prev: Utilities, Up: Top
985 Most functions in 'KSBA' will return an error if they fail. For this
986 reason, the application should always catch the error condition and take
987 appropriate measures, for example by releasing the resources and passing
988 the error up to the caller, or by displaying a descriptive message to
989 the user and canceling the operation.
991 Some error values do not indicate a system error or an error in the
992 operation, but the reasonable result of an operation. For example, if
993 you try to access optional attributes of a certificate that are not
994 present, you get an appropriate error message. Some error values have
995 specific meanings if returned by a specific function. Such cases are
996 described in the documentation of those functions.
998 All error codes are defined by the library 'libgpg-error'. See there
999 for ways to check the error values and print descriptive strings.
1000 Please be aware that you can't check directly against an error code but
1001 have to do it like this:
1004 if (gpg_err_code (err) == GPG_ERR_EOF)
1007 The only exception is that success (i.e. no error) is defined to be
1008 '0'; thus you may directly test for success like:
1014 File: ksba.info, Node: Component Labels, Next: Copying, Prev: Error Handling, Up: Top
1016 Appendix A Component Labels
1017 ***************************
1019 RFC-2253 defines the following table with string representations of name
1023 C countryName 2.5.4.6
1024 CN commonName 2.5.4.3
1025 DC domainComponent 0.9.2342.19200300.100.1.25
1026 L localityName 2.5.4.7
1027 O organizationName 2.5.4.10
1028 OU organizationalUnit 2.5.4.11
1029 ST stateOrProvince 2.5.4.8
1030 STREET streetAddress 2.5.4.9
1031 UID userid 0.9.2342.19200300.100.1.1
1034 They are used internally for converting a DN into its string
1035 representation; components not listed in this table will be represented
1038 For the other direction, i.e. creating a DN from the string
1039 representation, KSBA recognizes the following extra labels:
1042 ADDR postalAddress 2.5.4.16
1043 BC businessCategory 2.5.4.15
1044 D description 2.5.4.13
1045 EMAIL emailAddress 1.2.840.113549.1.9.1
1046 GN givenName 2.5.4.42
1047 POSTALCODE postalCode 2.5.4.17
1048 PSEUDO pseudonym 2.5.4.65
1049 SERIALNUMBER serialNumber 2.5.4.5
1055 File: ksba.info, Node: Copying, Next: Concept Index, Prev: Component Labels, Up: Top
1057 GNU General Public License
1058 **************************
1060 Version 3, 29 June 2007
1062 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
1064 Everyone is permitted to copy and distribute verbatim copies of this
1065 license document, but changing it is not allowed.
1070 The GNU General Public License is a free, copyleft license for software
1071 and other kinds of works.
1073 The licenses for most software and other practical works are designed
1074 to take away your freedom to share and change the works. By contrast,
1075 the GNU General Public License is intended to guarantee your freedom to
1076 share and change all versions of a program-to make sure it remains free
1077 software for all its users. We, the Free Software Foundation, use the
1078 GNU General Public License for most of our software; it applies also to
1079 any other work released this way by its authors. You can apply it to
1082 When we speak of free software, we are referring to freedom, not
1083 price. Our General Public Licenses are designed to make sure that you
1084 have the freedom to distribute copies of free software (and charge for
1085 them if you wish), that you receive source code or can get it if you
1086 want it, that you can change the software or use pieces of it in new
1087 free programs, and that you know you can do these things.
1089 To protect your rights, we need to prevent others from denying you
1090 these rights or asking you to surrender the rights. Therefore, you have
1091 certain responsibilities if you distribute copies of the software, or if
1092 you modify it: responsibilities to respect the freedom of others.
1094 For example, if you distribute copies of such a program, whether
1095 gratis or for a fee, you must pass on to the recipients the same
1096 freedoms that you received. You must make sure that they, too, receive
1097 or can get the source code. And you must show them these terms so they
1100 Developers that use the GNU GPL protect your rights with two steps:
1101 (1) assert copyright on the software, and (2) offer you this License
1102 giving you legal permission to copy, distribute and/or modify it.
1104 For the developers' and authors' protection, the GPL clearly explains
1105 that there is no warranty for this free software. For both users' and
1106 authors' sake, the GPL requires that modified versions be marked as
1107 changed, so that their problems will not be attributed erroneously to
1108 authors of previous versions.
1110 Some devices are designed to deny users access to install or run
1111 modified versions of the software inside them, although the manufacturer
1112 can do so. This is fundamentally incompatible with the aim of
1113 protecting users' freedom to change the software. The systematic
1114 pattern of such abuse occurs in the area of products for individuals to
1115 use, which is precisely where it is most unacceptable. Therefore, we
1116 have designed this version of the GPL to prohibit the practice for those
1117 products. If such problems arise substantially in other domains, we
1118 stand ready to extend this provision to those domains in future versions
1119 of the GPL, as needed to protect the freedom of users.
1121 Finally, every program is threatened constantly by software patents.
1122 States should not allow patents to restrict development and use of
1123 software on general-purpose computers, but in those that do, we wish to
1124 avoid the special danger that patents applied to a free program could
1125 make it effectively proprietary. To prevent this, the GPL assures that
1126 patents cannot be used to render the program non-free.
1128 The precise terms and conditions for copying, distribution and
1129 modification follow.
1131 TERMS AND CONDITIONS
1135 "This License" refers to version 3 of the GNU General Public
1138 "Copyright" also means copyright-like laws that apply to other
1139 kinds of works, such as semiconductor masks.
1141 "The Program" refers to any copyrightable work licensed under this
1142 License. Each licensee is addressed as "you". "Licensees" and
1143 "recipients" may be individuals or organizations.
1145 To "modify" a work means to copy from or adapt all or part of the
1146 work in a fashion requiring copyright permission, other than the
1147 making of an exact copy. The resulting work is called a "modified
1148 version" of the earlier work or a work "based on" the earlier work.
1150 A "covered work" means either the unmodified Program or a work
1151 based on the Program.
1153 To "propagate" a work means to do anything with it that, without
1154 permission, would make you directly or secondarily liable for
1155 infringement under applicable copyright law, except executing it on
1156 a computer or modifying a private copy. Propagation includes
1157 copying, distribution (with or without modification), making
1158 available to the public, and in some countries other activities as
1161 To "convey" a work means any kind of propagation that enables other
1162 parties to make or receive copies. Mere interaction with a user
1163 through a computer network, with no transfer of a copy, is not
1166 An interactive user interface displays "Appropriate Legal Notices"
1167 to the extent that it includes a convenient and prominently visible
1168 feature that (1) displays an appropriate copyright notice, and (2)
1169 tells the user that there is no warranty for the work (except to
1170 the extent that warranties are provided), that licensees may convey
1171 the work under this License, and how to view a copy of this
1172 License. If the interface presents a list of user commands or
1173 options, such as a menu, a prominent item in the list meets this
1178 The "source code" for a work means the preferred form of the work
1179 for making modifications to it. "Object code" means any non-source
1182 A "Standard Interface" means an interface that either is an
1183 official standard defined by a recognized standards body, or, in
1184 the case of interfaces specified for a particular programming
1185 language, one that is widely used among developers working in that
1188 The "System Libraries" of an executable work include anything,
1189 other than the work as a whole, that (a) is included in the normal
1190 form of packaging a Major Component, but which is not part of that
1191 Major Component, and (b) serves only to enable use of the work with
1192 that Major Component, or to implement a Standard Interface for
1193 which an implementation is available to the public in source code
1194 form. A "Major Component", in this context, means a major
1195 essential component (kernel, window system, and so on) of the
1196 specific operating system (if any) on which the executable work
1197 runs, or a compiler used to produce the work, or an object code
1198 interpreter used to run it.
1200 The "Corresponding Source" for a work in object code form means all
1201 the source code needed to generate, install, and (for an executable
1202 work) run the object code and to modify the work, including scripts
1203 to control those activities. However, it does not include the
1204 work's System Libraries, or general-purpose tools or generally
1205 available free programs which are used unmodified in performing
1206 those activities but which are not part of the work. For example,
1207 Corresponding Source includes interface definition files associated
1208 with source files for the work, and the source code for shared
1209 libraries and dynamically linked subprograms that the work is
1210 specifically designed to require, such as by intimate data
1211 communication or control flow between those subprograms and other
1214 The Corresponding Source need not include anything that users can
1215 regenerate automatically from other parts of the Corresponding
1218 The Corresponding Source for a work in source code form is that
1221 2. Basic Permissions.
1223 All rights granted under this License are granted for the term of
1224 copyright on the Program, and are irrevocable provided the stated
1225 conditions are met. This License explicitly affirms your unlimited
1226 permission to run the unmodified Program. The output from running
1227 a covered work is covered by this License only if the output, given
1228 its content, constitutes a covered work. This License acknowledges
1229 your rights of fair use or other equivalent, as provided by
1232 You may make, run and propagate covered works that you do not
1233 convey, without conditions so long as your license otherwise
1234 remains in force. You may convey covered works to others for the
1235 sole purpose of having them make modifications exclusively for you,
1236 or provide you with facilities for running those works, provided
1237 that you comply with the terms of this License in conveying all
1238 material for which you do not control copyright. Those thus making
1239 or running the covered works for you must do so exclusively on your
1240 behalf, under your direction and control, on terms that prohibit
1241 them from making any copies of your copyrighted material outside
1242 their relationship with you.
1244 Conveying under any other circumstances is permitted solely under
1245 the conditions stated below. Sublicensing is not allowed; section
1246 10 makes it unnecessary.
1248 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
1250 No covered work shall be deemed part of an effective technological
1251 measure under any applicable law fulfilling obligations under
1252 article 11 of the WIPO copyright treaty adopted on 20 December
1253 1996, or similar laws prohibiting or restricting circumvention of
1256 When you convey a covered work, you waive any legal power to forbid
1257 circumvention of technological measures to the extent such
1258 circumvention is effected by exercising rights under this License
1259 with respect to the covered work, and you disclaim any intention to
1260 limit operation or modification of the work as a means of
1261 enforcing, against the work's users, your or third parties' legal
1262 rights to forbid circumvention of technological measures.
1264 4. Conveying Verbatim Copies.
1266 You may convey verbatim copies of the Program's source code as you
1267 receive it, in any medium, provided that you conspicuously and
1268 appropriately publish on each copy an appropriate copyright notice;
1269 keep intact all notices stating that this License and any
1270 non-permissive terms added in accord with section 7 apply to the
1271 code; keep intact all notices of the absence of any warranty; and
1272 give all recipients a copy of this License along with the Program.
1274 You may charge any price or no price for each copy that you convey,
1275 and you may offer support or warranty protection for a fee.
1277 5. Conveying Modified Source Versions.
1279 You may convey a work based on the Program, or the modifications to
1280 produce it from the Program, in the form of source code under the
1281 terms of section 4, provided that you also meet all of these
1284 a. The work must carry prominent notices stating that you
1285 modified it, and giving a relevant date.
1287 b. The work must carry prominent notices stating that it is
1288 released under this License and any conditions added under
1289 section 7. This requirement modifies the requirement in
1290 section 4 to "keep intact all notices".
1292 c. You must license the entire work, as a whole, under this
1293 License to anyone who comes into possession of a copy. This
1294 License will therefore apply, along with any applicable
1295 section 7 additional terms, to the whole of the work, and all
1296 its parts, regardless of how they are packaged. This License
1297 gives no permission to license the work in any other way, but
1298 it does not invalidate such permission if you have separately
1301 d. If the work has interactive user interfaces, each must display
1302 Appropriate Legal Notices; however, if the Program has
1303 interactive interfaces that do not display Appropriate Legal
1304 Notices, your work need not make them do so.
1306 A compilation of a covered work with other separate and independent
1307 works, which are not by their nature extensions of the covered
1308 work, and which are not combined with it such as to form a larger
1309 program, in or on a volume of a storage or distribution medium, is
1310 called an "aggregate" if the compilation and its resulting
1311 copyright are not used to limit the access or legal rights of the
1312 compilation's users beyond what the individual works permit.
1313 Inclusion of a covered work in an aggregate does not cause this
1314 License to apply to the other parts of the aggregate.
1316 6. Conveying Non-Source Forms.
1318 You may convey a covered work in object code form under the terms
1319 of sections 4 and 5, provided that you also convey the
1320 machine-readable Corresponding Source under the terms of this
1321 License, in one of these ways:
1323 a. Convey the object code in, or embodied in, a physical product
1324 (including a physical distribution medium), accompanied by the
1325 Corresponding Source fixed on a durable physical medium
1326 customarily used for software interchange.
1328 b. Convey the object code in, or embodied in, a physical product
1329 (including a physical distribution medium), accompanied by a
1330 written offer, valid for at least three years and valid for as
1331 long as you offer spare parts or customer support for that
1332 product model, to give anyone who possesses the object code
1333 either (1) a copy of the Corresponding Source for all the
1334 software in the product that is covered by this License, on a
1335 durable physical medium customarily used for software
1336 interchange, for a price no more than your reasonable cost of
1337 physically performing this conveying of source, or (2) access
1338 to copy the Corresponding Source from a network server at no
1341 c. Convey individual copies of the object code with a copy of the
1342 written offer to provide the Corresponding Source. This
1343 alternative is allowed only occasionally and noncommercially,
1344 and only if you received the object code with such an offer,
1345 in accord with subsection 6b.
1347 d. Convey the object code by offering access from a designated
1348 place (gratis or for a charge), and offer equivalent access to
1349 the Corresponding Source in the same way through the same
1350 place at no further charge. You need not require recipients
1351 to copy the Corresponding Source along with the object code.
1352 If the place to copy the object code is a network server, the
1353 Corresponding Source may be on a different server (operated by
1354 you or a third party) that supports equivalent copying
1355 facilities, provided you maintain clear directions next to the
1356 object code saying where to find the Corresponding Source.
1357 Regardless of what server hosts the Corresponding Source, you
1358 remain obligated to ensure that it is available for as long as
1359 needed to satisfy these requirements.
1361 e. Convey the object code using peer-to-peer transmission,
1362 provided you inform other peers where the object code and
1363 Corresponding Source of the work are being offered to the
1364 general public at no charge under subsection 6d.
1366 A separable portion of the object code, whose source code is
1367 excluded from the Corresponding Source as a System Library, need
1368 not be included in conveying the object code work.
1370 A "User Product" is either (1) a "consumer product", which means
1371 any tangible personal property which is normally used for personal,
1372 family, or household purposes, or (2) anything designed or sold for
1373 incorporation into a dwelling. In determining whether a product is
1374 a consumer product, doubtful cases shall be resolved in favor of
1375 coverage. For a particular product received by a particular user,
1376 "normally used" refers to a typical or common use of that class of
1377 product, regardless of the status of the particular user or of the
1378 way in which the particular user actually uses, or expects or is
1379 expected to use, the product. A product is a consumer product
1380 regardless of whether the product has substantial commercial,
1381 industrial or non-consumer uses, unless such uses represent the
1382 only significant mode of use of the product.
1384 "Installation Information" for a User Product means any methods,
1385 procedures, authorization keys, or other information required to
1386 install and execute modified versions of a covered work in that
1387 User Product from a modified version of its Corresponding Source.
1388 The information must suffice to ensure that the continued
1389 functioning of the modified object code is in no case prevented or
1390 interfered with solely because modification has been made.
1392 If you convey an object code work under this section in, or with,
1393 or specifically for use in, a User Product, and the conveying
1394 occurs as part of a transaction in which the right of possession
1395 and use of the User Product is transferred to the recipient in
1396 perpetuity or for a fixed term (regardless of how the transaction
1397 is characterized), the Corresponding Source conveyed under this
1398 section must be accompanied by the Installation Information. But
1399 this requirement does not apply if neither you nor any third party
1400 retains the ability to install modified object code on the User
1401 Product (for example, the work has been installed in ROM).
1403 The requirement to provide Installation Information does not
1404 include a requirement to continue to provide support service,
1405 warranty, or updates for a work that has been modified or installed
1406 by the recipient, or for the User Product in which it has been
1407 modified or installed. Access to a network may be denied when the
1408 modification itself materially and adversely affects the operation
1409 of the network or violates the rules and protocols for
1410 communication across the network.
1412 Corresponding Source conveyed, and Installation Information
1413 provided, in accord with this section must be in a format that is
1414 publicly documented (and with an implementation available to the
1415 public in source code form), and must require no special password
1416 or key for unpacking, reading or copying.
1418 7. Additional Terms.
1420 "Additional permissions" are terms that supplement the terms of
1421 this License by making exceptions from one or more of its
1422 conditions. Additional permissions that are applicable to the
1423 entire Program shall be treated as though they were included in
1424 this License, to the extent that they are valid under applicable
1425 law. If additional permissions apply only to part of the Program,
1426 that part may be used separately under those permissions, but the
1427 entire Program remains governed by this License without regard to
1428 the additional permissions.
1430 When you convey a copy of a covered work, you may at your option
1431 remove any additional permissions from that copy, or from any part
1432 of it. (Additional permissions may be written to require their own
1433 removal in certain cases when you modify the work.) You may place
1434 additional permissions on material, added by you to a covered work,
1435 for which you have or can give appropriate copyright permission.
1437 Notwithstanding any other provision of this License, for material
1438 you add to a covered work, you may (if authorized by the copyright
1439 holders of that material) supplement the terms of this License with
1442 a. Disclaiming warranty or limiting liability differently from
1443 the terms of sections 15 and 16 of this License; or
1445 b. Requiring preservation of specified reasonable legal notices
1446 or author attributions in that material or in the Appropriate
1447 Legal Notices displayed by works containing it; or
1449 c. Prohibiting misrepresentation of the origin of that material,
1450 or requiring that modified versions of such material be marked
1451 in reasonable ways as different from the original version; or
1453 d. Limiting the use for publicity purposes of names of licensors
1454 or authors of the material; or
1456 e. Declining to grant rights under trademark law for use of some
1457 trade names, trademarks, or service marks; or
1459 f. Requiring indemnification of licensors and authors of that
1460 material by anyone who conveys the material (or modified
1461 versions of it) with contractual assumptions of liability to
1462 the recipient, for any liability that these contractual
1463 assumptions directly impose on those licensors and authors.
1465 All other non-permissive additional terms are considered "further
1466 restrictions" within the meaning of section 10. If the Program as
1467 you received it, or any part of it, contains a notice stating that
1468 it is governed by this License along with a term that is a further
1469 restriction, you may remove that term. If a license document
1470 contains a further restriction but permits relicensing or conveying
1471 under this License, you may add to a covered work material governed
1472 by the terms of that license document, provided that the further
1473 restriction does not survive such relicensing or conveying.
1475 If you add terms to a covered work in accord with this section, you
1476 must place, in the relevant source files, a statement of the
1477 additional terms that apply to those files, or a notice indicating
1478 where to find the applicable terms.
1480 Additional terms, permissive or non-permissive, may be stated in
1481 the form of a separately written license, or stated as exceptions;
1482 the above requirements apply either way.
1486 You may not propagate or modify a covered work except as expressly
1487 provided under this License. Any attempt otherwise to propagate or
1488 modify it is void, and will automatically terminate your rights
1489 under this License (including any patent licenses granted under the
1490 third paragraph of section 11).
1492 However, if you cease all violation of this License, then your
1493 license from a particular copyright holder is reinstated (a)
1494 provisionally, unless and until the copyright holder explicitly and
1495 finally terminates your license, and (b) permanently, if the
1496 copyright holder fails to notify you of the violation by some
1497 reasonable means prior to 60 days after the cessation.
1499 Moreover, your license from a particular copyright holder is
1500 reinstated permanently if the copyright holder notifies you of the
1501 violation by some reasonable means, this is the first time you have
1502 received notice of violation of this License (for any work) from
1503 that copyright holder, and you cure the violation prior to 30 days
1504 after your receipt of the notice.
1506 Termination of your rights under this section does not terminate
1507 the licenses of parties who have received copies or rights from you
1508 under this License. If your rights have been terminated and not
1509 permanently reinstated, you do not qualify to receive new licenses
1510 for the same material under section 10.
1512 9. Acceptance Not Required for Having Copies.
1514 You are not required to accept this License in order to receive or
1515 run a copy of the Program. Ancillary propagation of a covered work
1516 occurring solely as a consequence of using peer-to-peer
1517 transmission to receive a copy likewise does not require
1518 acceptance. However, nothing other than this License grants you
1519 permission to propagate or modify any covered work. These actions
1520 infringe copyright if you do not accept this License. Therefore,
1521 by modifying or propagating a covered work, you indicate your
1522 acceptance of this License to do so.
1524 10. Automatic Licensing of Downstream Recipients.
1526 Each time you convey a covered work, the recipient automatically
1527 receives a license from the original licensors, to run, modify and
1528 propagate that work, subject to this License. You are not
1529 responsible for enforcing compliance by third parties with this
1532 An "entity transaction" is a transaction transferring control of an
1533 organization, or substantially all assets of one, or subdividing an
1534 organization, or merging organizations. If propagation of a
1535 covered work results from an entity transaction, each party to that
1536 transaction who receives a copy of the work also receives whatever
1537 licenses to the work the party's predecessor in interest had or
1538 could give under the previous paragraph, plus a right to possession
1539 of the Corresponding Source of the work from the predecessor in
1540 interest, if the predecessor has it or can get it with reasonable
1543 You may not impose any further restrictions on the exercise of the
1544 rights granted or affirmed under this License. For example, you
1545 may not impose a license fee, royalty, or other charge for exercise
1546 of rights granted under this License, and you may not initiate
1547 litigation (including a cross-claim or counterclaim in a lawsuit)
1548 alleging that any patent claim is infringed by making, using,
1549 selling, offering for sale, or importing the Program or any portion
1554 A "contributor" is a copyright holder who authorizes use under this
1555 License of the Program or a work on which the Program is based.
1556 The work thus licensed is called the contributor's "contributor
1559 A contributor's "essential patent claims" are all patent claims
1560 owned or controlled by the contributor, whether already acquired or
1561 hereafter acquired, that would be infringed by some manner,
1562 permitted by this License, of making, using, or selling its
1563 contributor version, but do not include claims that would be
1564 infringed only as a consequence of further modification of the
1565 contributor version. For purposes of this definition, "control"
1566 includes the right to grant patent sublicenses in a manner
1567 consistent with the requirements of this License.
1569 Each contributor grants you a non-exclusive, worldwide,
1570 royalty-free patent license under the contributor's essential
1571 patent claims, to make, use, sell, offer for sale, import and
1572 otherwise run, modify and propagate the contents of its contributor
1575 In the following three paragraphs, a "patent license" is any
1576 express agreement or commitment, however denominated, not to
1577 enforce a patent (such as an express permission to practice a
1578 patent or covenant not to sue for patent infringement). To "grant"
1579 such a patent license to a party means to make such an agreement or
1580 commitment not to enforce a patent against the party.
1582 If you convey a covered work, knowingly relying on a patent
1583 license, and the Corresponding Source of the work is not available
1584 for anyone to copy, free of charge and under the terms of this
1585 License, through a publicly available network server or other
1586 readily accessible means, then you must either (1) cause the
1587 Corresponding Source to be so available, or (2) arrange to deprive
1588 yourself of the benefit of the patent license for this particular
1589 work, or (3) arrange, in a manner consistent with the requirements
1590 of this License, to extend the patent license to downstream
1591 recipients. "Knowingly relying" means you have actual knowledge
1592 that, but for the patent license, your conveying the covered work
1593 in a country, or your recipient's use of the covered work in a
1594 country, would infringe one or more identifiable patents in that
1595 country that you have reason to believe are valid.
1597 If, pursuant to or in connection with a single transaction or
1598 arrangement, you convey, or propagate by procuring conveyance of, a
1599 covered work, and grant a patent license to some of the parties
1600 receiving the covered work authorizing them to use, propagate,
1601 modify or convey a specific copy of the covered work, then the
1602 patent license you grant is automatically extended to all
1603 recipients of the covered work and works based on it.
1605 A patent license is "discriminatory" if it does not include within
1606 the scope of its coverage, prohibits the exercise of, or is
1607 conditioned on the non-exercise of one or more of the rights that
1608 are specifically granted under this License. You may not convey a
1609 covered work if you are a party to an arrangement with a third
1610 party that is in the business of distributing software, under which
1611 you make payment to the third party based on the extent of your
1612 activity of conveying the work, and under which the third party
1613 grants, to any of the parties who would receive the covered work
1614 from you, a discriminatory patent license (a) in connection with
1615 copies of the covered work conveyed by you (or copies made from
1616 those copies), or (b) primarily for and in connection with specific
1617 products or compilations that contain the covered work, unless you
1618 entered into that arrangement, or that patent license was granted,
1619 prior to 28 March 2007.
1621 Nothing in this License shall be construed as excluding or limiting
1622 any implied license or other defenses to infringement that may
1623 otherwise be available to you under applicable patent law.
1625 12. No Surrender of Others' Freedom.
1627 If conditions are imposed on you (whether by court order, agreement
1628 or otherwise) that contradict the conditions of this License, they
1629 do not excuse you from the conditions of this License. If you
1630 cannot convey a covered work so as to satisfy simultaneously your
1631 obligations under this License and any other pertinent obligations,
1632 then as a consequence you may not convey it at all. For example,
1633 if you agree to terms that obligate you to collect a royalty for
1634 further conveying from those to whom you convey the Program, the
1635 only way you could satisfy both those terms and this License would
1636 be to refrain entirely from conveying the Program.
1638 13. Use with the GNU Affero General Public License.
1640 Notwithstanding any other provision of this License, you have
1641 permission to link or combine any covered work with a work licensed
1642 under version 3 of the GNU Affero General Public License into a
1643 single combined work, and to convey the resulting work. The terms
1644 of this License will continue to apply to the part which is the
1645 covered work, but the special requirements of the GNU Affero
1646 General Public License, section 13, concerning interaction through
1647 a network will apply to the combination as such.
1649 14. Revised Versions of this License.
1651 The Free Software Foundation may publish revised and/or new
1652 versions of the GNU General Public License from time to time. Such
1653 new versions will be similar in spirit to the present version, but
1654 may differ in detail to address new problems or concerns.
1656 Each version is given a distinguishing version number. If the
1657 Program specifies that a certain numbered version of the GNU
1658 General Public License "or any later version" applies to it, you
1659 have the option of following the terms and conditions either of
1660 that numbered version or of any later version published by the Free
1661 Software Foundation. If the Program does not specify a version
1662 number of the GNU General Public License, you may choose any
1663 version ever published by the Free Software Foundation.
1665 If the Program specifies that a proxy can decide which future
1666 versions of the GNU General Public License can be used, that
1667 proxy's public statement of acceptance of a version permanently
1668 authorizes you to choose that version for the Program.
1670 Later license versions may give you additional or different
1671 permissions. However, no additional obligations are imposed on any
1672 author or copyright holder as a result of your choosing to follow a
1675 15. Disclaimer of Warranty.
1677 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
1678 APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE
1679 COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS"
1680 WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
1681 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
1682 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE
1683 RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
1684 SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
1685 NECESSARY SERVICING, REPAIR OR CORRECTION.
1687 16. Limitation of Liability.
1689 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
1690 WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES
1691 AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR
1692 DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
1693 CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
1694 THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
1695 BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
1696 PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
1697 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
1698 THE POSSIBILITY OF SUCH DAMAGES.
1700 17. Interpretation of Sections 15 and 16.
1702 If the disclaimer of warranty and limitation of liability provided
1703 above cannot be given local legal effect according to their terms,
1704 reviewing courts shall apply local law that most closely
1705 approximates an absolute waiver of all civil liability in
1706 connection with the Program, unless a warranty or assumption of
1707 liability accompanies a copy of the Program in return for a fee.
1709 END OF TERMS AND CONDITIONS
1711 How to Apply These Terms to Your New Programs
1712 =============================================
1714 If you develop a new program, and you want it to be of the greatest
1715 possible use to the public, the best way to achieve this is to make it
1716 free software which everyone can redistribute and change under these
1719 To do so, attach the following notices to the program. It is safest
1720 to attach them to the start of each source file to most effectively
1721 state the exclusion of warranty; and each file should have at least the
1722 "copyright" line and a pointer to where the full notice is found.
1724 ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES.
1725 Copyright (C) YEAR NAME OF AUTHOR
1727 This program is free software: you can redistribute it and/or modify
1728 it under the terms of the GNU General Public License as published by
1729 the Free Software Foundation, either version 3 of the License, or (at
1730 your option) any later version.
1732 This program is distributed in the hope that it will be useful, but
1733 WITHOUT ANY WARRANTY; without even the implied warranty of
1734 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1735 General Public License for more details.
1737 You should have received a copy of the GNU General Public License
1738 along with this program. If not, see <http://www.gnu.org/licenses/>.
1740 Also add information on how to contact you by electronic and paper mail.
1742 If the program does terminal interaction, make it output a short notice
1743 like this when it starts in an interactive mode:
1745 PROGRAM Copyright (C) YEAR NAME OF AUTHOR
1746 This program comes with ABSOLUTELY NO WARRANTY; for details
1747 type 'show w'. This is free software, and you are
1748 welcome to redistribute it under certain conditions;
1749 type 'show c' for details.
1751 The hypothetical commands 'show w' and 'show c' should show the
1752 appropriate parts of the General Public License. Of course, your
1753 program's commands might be different; for a GUI interface, you would
1756 You should also get your employer (if you work as a programmer) or
1757 school, if any, to sign a "copyright disclaimer" for the program, if
1758 necessary. For more information on this, and how to apply and follow
1759 the GNU GPL, see <http://www.gnu.org/licenses/>.
1761 The GNU General Public License does not permit incorporating your
1762 program into proprietary programs. If your program is a subroutine
1763 library, you may consider it more useful to permit linking proprietary
1764 applications with the library. If this is what you want to do, use the
1765 GNU Lesser General Public License instead of this License. But first,
1766 please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.
1769 File: ksba.info, Node: Concept Index, Next: Function and Data Index, Prev: Copying, Up: Top
1775 File: ksba.info, Node: Function and Data Index, Prev: Concept Index, Up: Top
1777 Function and Data Index
1778 ***********************
1783 * ksba_cert_get_authority_info_access: Retrieving attributes.
1785 * ksba_cert_get_auth_key_id: Retrieving attributes.
1787 * ksba_cert_get_cert_policies: Retrieving attributes.
1789 * ksba_cert_get_crl_dist_point: Retrieving attributes.
1791 * ksba_cert_get_digest_algo: Retrieving attributes.
1793 * ksba_cert_get_extension: Retrieving attributes.
1795 * ksba_cert_get_ext_key_usages: Retrieving attributes.
1797 * ksba_cert_get_image: Retrieving attributes.
1799 * ksba_cert_get_issuer: Retrieving attributes.
1801 * ksba_cert_get_key_usage: Retrieving attributes.
1803 * ksba_cert_get_public_key: Retrieving attributes.
1805 * ksba_cert_get_serial: Retrieving attributes.
1807 * ksba_cert_get_sig_val: Retrieving attributes.
1809 * ksba_cert_get_subject: Retrieving attributes.
1811 * ksba_cert_get_subject_info_access: Retrieving attributes.
1813 * ksba_cert_get_subj_key_id: Retrieving attributes.
1815 * ksba_cert_get_user_data: User data. (line 26)
1816 * ksba_cert_get_validity: Retrieving attributes.
1818 * ksba_cert_hash: Retrieving attributes.
1820 * ksba_cert_init_from_mem: Creating certificates.
1822 * ksba_cert_is_ca: Retrieving attributes.
1824 * ksba_cert_new: Creating certificates.
1826 * ksba_cert_read_der: Creating certificates.
1828 * ksba_cert_ref: Creating certificates.
1830 * ksba_cert_release: Creating certificates.
1832 * ksba_cert_set_user_data: User data. (line 11)
1833 * ksba_cert_t: Certificate Handling.
1835 * ksba_check_version: Version Check. (line 12)
1836 * ksba_cms_get_content_oid: CMS Parser. (line 89)
1837 * ksba_cms_get_content_type: CMS Parser. (line 54)
1838 * ksba_cms_new: CMS Basics. (line 16)
1839 * ksba_cms_parse: CMS Parser. (line 13)
1840 * ksba_cms_release: CMS Basics. (line 25)
1841 * ksba_cms_set_reader_writer: CMS Basics. (line 31)
1842 * ksba_cms_t: CMS Basics. (line 10)
1843 * ksba_content_t: CMS Parser. (line 61)
1844 * ksba_dn_teststr: DNs. (line 9)
1845 * ksba_isotime_t: Retrieving attributes.
1847 * ksba_name_enum: Names. (line 17)
1848 * ksba_name_get_uri: Names. (line 36)
1849 * ksba_name_release: Names. (line 13)
1850 * ksba_name_t: Names. (line 10)
1851 * ksba_sexp_t: Certificate Handling.
1853 * ksba_stop_reason_t: CMS Basics. (line 12)
1859 Node: Introduction
\7f2772
1860 Node: Getting Started
\7f3050
1861 Node: Features
\7f3916
1862 Node: Overview
\7f5007
1863 Node: Preparation
\7f5256
1865 Node: Version Check
\7f6335
1866 Node: Building the source
\7f7427
1867 Node: Certificate Handling
\7f9271
1868 Node: Creating certificates
\7f10252
1869 Node: Retrieving attributes
\7f12713
1870 Node: Setting attributes
\7f26390
1871 Node: User data
\7f26655
1873 Node: CMS Basics
\7f29024
1874 Node: CMS Parser
\7f31087
1876 Node: PKCS10
\7f35348
1877 Node: Utilities
\7f35609
1881 Node: Error Handling
\7f39660
1882 Node: Component Labels
\7f41015
1883 Node: Copying
\7f42578
1884 Node: Concept Index
\7f80105
1885 Node: Function and Data Index
\7f80233