"Fossies" - the Fresh Open Source Software Archive

Member "libksba-1.6.0/src/ksba.h" (10 Jun 2021, 26994 Bytes) of package /linux/privat/libksba-1.6.0.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ksba.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.5.1_vs_1.6.0.

    1 /* ksba.h - X.509 library used by GnuPG
    2  * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2010, 2011
    3  *               2012, 2013, 2104, 2015, 2019, 2020, 2021 g10 Code GmbH
    4  *
    5  * This file is part of KSBA.
    6  *
    7  * KSBA is free software; you can redistribute it and/or modify
    8  * it under the terms of either
    9  *
   10  *   - the GNU Lesser General Public License as published by the Free
   11  *     Software Foundation; either version 3 of the License, or (at
   12  *     your option) any later version.
   13  *
   14  * or
   15  *
   16  *   - the GNU General Public License as published by the Free
   17  *     Software Foundation; either version 2 of the License, or (at
   18  *     your option) any later version.
   19  *
   20  * or both in parallel, as here.
   21  *
   22  * KSBA is distributed in the hope that it will be useful, but WITHOUT
   23  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   24  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
   25  * License for more details.
   26  *
   27  * You should have received a copies of the GNU General Public License
   28  * and the GNU Lesser General Public License along with this program;
   29  * if not, see <http://www.gnu.org/licenses/>.
   30  * SPDX-License-Identifier: LGPL-3.0-or-later OR GPL-2.0-or-later
   31  */
   32 
   33 #ifndef KSBA_H
   34 #define KSBA_H 1
   35 
   36 #include <gpg-error.h>
   37 #include <stdio.h>
   38 
   39 #ifdef __cplusplus
   40 extern "C" {
   41 #if 0
   42  }
   43 #endif
   44 #endif
   45 
   46 /* The version of this header should match the one of the library.  Do
   47  * not use this symbol in your application; use assuan_check_version
   48  * instead.  */
   49 #define KSBA_VERSION "1.6.0"
   50 
   51 /* The version number of this header.  It may be used to handle minor
   52  * API incompatibilities.  */
   53 #define KSBA_VERSION_NUMBER 0x010600
   54 
   55 
   56 
   57 /* Check for compiler features.  */
   58 #ifdef __GNUC__
   59 #define _KSBA_GCC_VERSION (__GNUC__ * 10000 \
   60                             + __GNUC_MINOR__ * 100 \
   61                             + __GNUC_PATCHLEVEL__)
   62 #if _KSBA_GCC_VERSION > 30100
   63 #define _KSBA_DEPRECATED    __attribute__ ((__deprecated__))
   64 #endif
   65 #endif /*__GNUC__*/
   66 
   67 #ifndef _KSBA_DEPRECATED
   68 #define _KSBA_DEPRECATED
   69 #endif
   70 
   71 
   72 #define KSBA_CLASS_UNIVERSAL   0
   73 #define KSBA_CLASS_APPLICATION 1
   74 #define KSBA_CLASS_CONTEXT     2
   75 #define KSBA_CLASS_PRIVATE     3
   76 #define KSBA_CLASS_ENCAPSULATE 0x80  /* Pseudo class.  */
   77 
   78 #define KSBA_TYPE_BOOLEAN           1
   79 #define KSBA_TYPE_INTEGER           2
   80 #define KSBA_TYPE_BIT_STRING        3
   81 #define KSBA_TYPE_OCTET_STRING      4
   82 #define KSBA_TYPE_NULL              5
   83 #define KSBA_TYPE_OBJECT_ID         6
   84 #define KSBA_TYPE_OBJECT_DESCRIPTOR 7
   85 #define KSBA_TYPE_EXTERNAL          8
   86 #define KSBA_TYPE_REAL              9
   87 #define KSBA_TYPE_ENUMERATED       10
   88 #define KSBA_TYPE_EMBEDDED_PDV     11
   89 #define KSBA_TYPE_UTF8_STRING      12
   90 #define KSBA_TYPE_RELATIVE_OID     13
   91 #define KSBA_TYPE_TIME             14
   92 #define KSBA_TYPE_SEQUENCE         16
   93 #define KSBA_TYPE_SET              17
   94 #define KSBA_TYPE_NUMERIC_STRING   18
   95 #define KSBA_TYPE_PRINTABLE_STRING 19
   96 #define KSBA_TYPE_TELETEX_STRING   20
   97 #define KSBA_TYPE_VIDEOTEX_STRING  21
   98 #define KSBA_TYPE_IA5_STRING       22
   99 #define KSBA_TYPE_UTC_TIME         23
  100 #define KSBA_TYPE_GENERALIZED_TIME 24
  101 #define KSBA_TYPE_GRAPHIC_STRING   25
  102 #define KSBA_TYPE_VISIBLE_STRING   26
  103 #define KSBA_TYPE_GENERAL_STRING   27
  104 #define KSBA_TYPE_UNIVERSAL_STRING 28
  105 #define KSBA_TYPE_CHARACTER_STRING 29
  106 #define KSBA_TYPE_BMP_STRING       30
  107 #define KSBA_TYPE_DATE             31
  108 #define KSBA_TYPE_TIME_OF_DAY      32
  109 #define KSBA_TYPE_DATE_TIME        33
  110 #define KSBA_TYPE_DURATION         34
  111 #define KSBA_TYPE_OID_IRI          35
  112 #define KSBA_TYPE_RELATIVE_OID_IRI 36
  113 
  114 
  115 
  116 typedef gpg_error_t KsbaError _KSBA_DEPRECATED;
  117 
  118 typedef enum
  119   {
  120     KSBA_CT_NONE = 0,
  121     KSBA_CT_DATA = 1,
  122     KSBA_CT_SIGNED_DATA = 2,
  123     KSBA_CT_ENVELOPED_DATA = 3,
  124     KSBA_CT_DIGESTED_DATA = 4,
  125     KSBA_CT_ENCRYPTED_DATA = 5,
  126     KSBA_CT_AUTH_DATA = 6,
  127     KSBA_CT_PKCS12 = 7,
  128     KSBA_CT_SPC_IND_DATA_CTX = 8,
  129     KSBA_CT_OPENPGP_KEYBLOCK = 9,
  130     KSBA_CT_AUTHENVELOPED_DATA = 10
  131   }
  132 ksba_content_type_t;
  133 typedef ksba_content_type_t KsbaContentType _KSBA_DEPRECATED;
  134 
  135 
  136 
  137 typedef enum
  138   {
  139     KSBA_SR_NONE = 0,     /* Never seen by libksba user. */
  140     KSBA_SR_RUNNING = 1,  /* Never seen by libksba user. */
  141     KSBA_SR_GOT_CONTENT = 2,
  142     KSBA_SR_NEED_HASH = 3,
  143     KSBA_SR_BEGIN_DATA = 4,
  144     KSBA_SR_END_DATA = 5,
  145     KSBA_SR_READY = 6,
  146     KSBA_SR_NEED_SIG = 7,
  147     KSBA_SR_DETACHED_DATA = 8,
  148     KSBA_SR_BEGIN_ITEMS = 9,
  149     KSBA_SR_GOT_ITEM = 10,
  150     KSBA_SR_END_ITEMS = 11
  151   }
  152 ksba_stop_reason_t;
  153 typedef ksba_stop_reason_t KsbaStopReason _KSBA_DEPRECATED;
  154 
  155 typedef enum
  156   {
  157     KSBA_CRLREASON_UNSPECIFIED = 1,
  158     KSBA_CRLREASON_KEY_COMPROMISE = 2,
  159     KSBA_CRLREASON_CA_COMPROMISE = 4,
  160     KSBA_CRLREASON_AFFILIATION_CHANGED = 8,
  161     KSBA_CRLREASON_SUPERSEDED = 16,
  162     KSBA_CRLREASON_CESSATION_OF_OPERATION = 32,
  163     KSBA_CRLREASON_CERTIFICATE_HOLD = 64,
  164     KSBA_CRLREASON_REMOVE_FROM_CRL = 256,
  165     KSBA_CRLREASON_PRIVILEGE_WITHDRAWN = 512,
  166     KSBA_CRLREASON_AA_COMPROMISE = 1024,
  167     KSBA_CRLREASON_OTHER = 32768
  168   }
  169 ksba_crl_reason_t;
  170 typedef ksba_crl_reason_t KsbaCRLReason _KSBA_DEPRECATED;
  171 
  172 typedef enum
  173   {
  174     KSBA_OCSP_RSPSTATUS_SUCCESS = 0,
  175     KSBA_OCSP_RSPSTATUS_MALFORMED = 1,
  176     KSBA_OCSP_RSPSTATUS_INTERNAL = 2,
  177     KSBA_OCSP_RSPSTATUS_TRYLATER = 3,
  178     KSBA_OCSP_RSPSTATUS_SIGREQUIRED = 5,
  179     KSBA_OCSP_RSPSTATUS_UNAUTHORIZED = 6,
  180     KSBA_OCSP_RSPSTATUS_REPLAYED = 253,
  181     KSBA_OCSP_RSPSTATUS_OTHER = 254,
  182     KSBA_OCSP_RSPSTATUS_NONE = 255
  183   }
  184 ksba_ocsp_response_status_t;
  185 
  186 typedef enum
  187   {
  188     KSBA_STATUS_NONE = 0,
  189     KSBA_STATUS_UNKNOWN = 1,
  190     KSBA_STATUS_GOOD = 2,
  191     KSBA_STATUS_REVOKED = 4
  192   }
  193 ksba_status_t;
  194 
  195 
  196 typedef enum
  197   {
  198     KSBA_KEYUSAGE_DIGITAL_SIGNATURE =  1,
  199     KSBA_KEYUSAGE_NON_REPUDIATION   =  2,
  200     KSBA_KEYUSAGE_KEY_ENCIPHERMENT  =  4,
  201     KSBA_KEYUSAGE_DATA_ENCIPHERMENT =  8,
  202     KSBA_KEYUSAGE_KEY_AGREEMENT     = 16,
  203     KSBA_KEYUSAGE_KEY_CERT_SIGN     = 32,
  204     KSBA_KEYUSAGE_CRL_SIGN          = 64,
  205     KSBA_KEYUSAGE_ENCIPHER_ONLY    = 128,
  206     KSBA_KEYUSAGE_DECIPHER_ONLY    = 256
  207   }
  208 ksba_key_usage_t;
  209 typedef ksba_key_usage_t KsbaKeyUsage _KSBA_DEPRECATED;
  210 
  211 /* ISO format, e.g. "19610711T172059", assumed to be UTC. */
  212 typedef char ksba_isotime_t[16];
  213 
  214 
  215 /* X.509 certificates are represented by this object.
  216    ksba_cert_new() creates such an object */
  217 struct ksba_cert_s;
  218 typedef struct ksba_cert_s *ksba_cert_t;
  219 typedef struct ksba_cert_s *KsbaCert _KSBA_DEPRECATED;
  220 
  221 /* CMS objects are controlled by this object.
  222    ksba_cms_new() creates it */
  223 struct ksba_cms_s;
  224 typedef struct ksba_cms_s *ksba_cms_t;
  225 typedef struct ksba_cms_s *KsbaCMS _KSBA_DEPRECATED;
  226 
  227 /* CRL objects are controlled by this object.
  228    ksba_crl_new() creates it */
  229 struct ksba_crl_s;
  230 typedef struct ksba_crl_s *ksba_crl_t;
  231 typedef struct ksba_crl_s *KsbaCRL _KSBA_DEPRECATED;
  232 
  233 /* OCSP objects are controlled by this object.
  234    ksba_ocsp_new() creates it. */
  235 struct ksba_ocsp_s;
  236 typedef struct ksba_ocsp_s *ksba_ocsp_t;
  237 
  238 /* PKCS-10 creation is controlled by this object.
  239    ksba_certreq_new() creates it */
  240 struct ksba_certreq_s;
  241 typedef struct ksba_certreq_s *ksba_certreq_t;
  242 typedef struct ksba_certreq_s *KsbaCertreq _KSBA_DEPRECATED;
  243 
  244 /* This is a reader object for various purposes
  245    see ksba_reader_new et al. */
  246 struct ksba_reader_s;
  247 typedef struct ksba_reader_s *ksba_reader_t;
  248 typedef struct ksba_reader_s *KsbaReader _KSBA_DEPRECATED;
  249 
  250 /* This is a writer object for various purposes
  251    see ksba_writer_new et al. */
  252 struct ksba_writer_s;
  253 typedef struct ksba_writer_s *ksba_writer_t;
  254 typedef struct ksba_writer_s *KsbaWriter _KSBA_DEPRECATED;
  255 
  256 /* This is an object to store an ASN.1 parse tree as
  257    create by ksba_asn_parse_file() */
  258 struct ksba_asn_tree_s;
  259 typedef struct ksba_asn_tree_s *ksba_asn_tree_t;
  260 typedef struct ksba_asn_tree_s *KsbaAsnTree _KSBA_DEPRECATED;
  261 
  262 /* This is an object to reference a General Name.  Such an object is
  263    returned by several functions. */
  264 struct ksba_name_s;
  265 typedef struct ksba_name_s *ksba_name_t;
  266 typedef struct ksba_name_s *KsbaName _KSBA_DEPRECATED;
  267 
  268 /* KsbaSexp is just an unsigned char * which should be used for
  269    documentation purpose.  The S-expressions returned by libksba are
  270    always in canonical representation with an extra 0 byte at the end,
  271    so that one can print the values in the debugger and at least see
  272    the first bytes */
  273 typedef unsigned char *ksba_sexp_t;
  274 typedef unsigned char *KsbaSexp _KSBA_DEPRECATED;
  275 typedef const unsigned char *ksba_const_sexp_t;
  276 typedef const unsigned char *KsbaConstSexp _KSBA_DEPRECATED;
  277 
  278 
  279 /* This is a generic object used by various functions.  */
  280 struct ksba_der_s;
  281 typedef struct ksba_der_s *ksba_der_t;
  282 
  283 
  284 /*-- cert.c --*/
  285 gpg_error_t ksba_cert_new (ksba_cert_t *acert);
  286 void        ksba_cert_ref (ksba_cert_t cert);
  287 void        ksba_cert_release (ksba_cert_t cert);
  288 gpg_error_t ksba_cert_set_user_data (ksba_cert_t cert, const char *key,
  289                                      const void *data, size_t datalen);
  290 gpg_error_t ksba_cert_get_user_data (ksba_cert_t cert, const char *key,
  291                                      void *buffer, size_t bufferlen,
  292                                      size_t *datalen);
  293 
  294 gpg_error_t ksba_cert_read_der (ksba_cert_t cert, ksba_reader_t reader);
  295 gpg_error_t ksba_cert_init_from_mem (ksba_cert_t cert,
  296                                      const void *buffer, size_t length);
  297 const unsigned char *ksba_cert_get_image (ksba_cert_t cert, size_t *r_length);
  298 gpg_error_t ksba_cert_hash (ksba_cert_t cert,
  299                             int what,
  300                             void (*hasher)(void *,
  301                                            const void *,
  302                                            size_t length),
  303                             void *hasher_arg);
  304 const char *ksba_cert_get_digest_algo (ksba_cert_t cert);
  305 ksba_sexp_t ksba_cert_get_serial (ksba_cert_t cert);
  306 char       *ksba_cert_get_issuer (ksba_cert_t cert, int idx);
  307 gpg_error_t ksba_cert_get_validity (ksba_cert_t cert, int what,
  308                                     ksba_isotime_t r_time);
  309 char       *ksba_cert_get_subject (ksba_cert_t cert, int idx);
  310 ksba_sexp_t ksba_cert_get_public_key (ksba_cert_t cert);
  311 ksba_sexp_t ksba_cert_get_sig_val (ksba_cert_t cert);
  312 
  313 gpg_error_t ksba_cert_get_extension (ksba_cert_t cert, int idx,
  314                                      char const **r_oid, int *r_crit,
  315                                      size_t *r_deroff, size_t *r_derlen);
  316 
  317 gpg_error_t ksba_cert_is_ca (ksba_cert_t cert, int *r_ca, int *r_pathlen);
  318 gpg_error_t ksba_cert_get_key_usage (ksba_cert_t cert, unsigned int *r_flags);
  319 gpg_error_t ksba_cert_get_cert_policies (ksba_cert_t cert, char **r_policies);
  320 gpg_error_t ksba_cert_get_ext_key_usages (ksba_cert_t cert, char **result);
  321 gpg_error_t ksba_cert_get_crl_dist_point (ksba_cert_t cert, int idx,
  322                                           ksba_name_t *r_distpoint,
  323                                           ksba_name_t *r_issuer,
  324                                           ksba_crl_reason_t *r_reason);
  325 gpg_error_t ksba_cert_get_auth_key_id (ksba_cert_t cert,
  326                                        ksba_sexp_t *r_keyid,
  327                                        ksba_name_t *r_name,
  328                                        ksba_sexp_t *r_serial);
  329 gpg_error_t ksba_cert_get_subj_key_id (ksba_cert_t cert,
  330                                        int *r_crit,
  331                                        ksba_sexp_t *r_keyid);
  332 gpg_error_t ksba_cert_get_authority_info_access (ksba_cert_t cert, int idx,
  333                                                  char **r_method,
  334                                                  ksba_name_t *r_location);
  335 gpg_error_t ksba_cert_get_subject_info_access (ksba_cert_t cert, int idx,
  336                                                char **r_method,
  337                                                ksba_name_t *r_location);
  338 
  339 
  340 /*-- cms.c --*/
  341 ksba_content_type_t ksba_cms_identify (ksba_reader_t reader);
  342 
  343 gpg_error_t ksba_cms_new (ksba_cms_t *r_cms);
  344 void        ksba_cms_release (ksba_cms_t cms);
  345 gpg_error_t ksba_cms_set_reader_writer (ksba_cms_t cms,
  346                                         ksba_reader_t r, ksba_writer_t w);
  347 
  348 gpg_error_t ksba_cms_parse (ksba_cms_t cms, ksba_stop_reason_t *r_stopreason);
  349 gpg_error_t ksba_cms_build (ksba_cms_t cms, ksba_stop_reason_t *r_stopreason);
  350 
  351 ksba_content_type_t ksba_cms_get_content_type (ksba_cms_t cms, int what);
  352 const char *ksba_cms_get_content_oid (ksba_cms_t cms, int what);
  353 gpg_error_t ksba_cms_get_content_enc_iv (ksba_cms_t cms, void *iv,
  354                                          size_t maxivlen, size_t *ivlen);
  355 const char *ksba_cms_get_digest_algo_list (ksba_cms_t cms, int idx);
  356 gpg_error_t ksba_cms_get_issuer_serial (ksba_cms_t cms, int idx,
  357                                         char **r_issuer,
  358                                         ksba_sexp_t *r_serial);
  359 const char *ksba_cms_get_digest_algo (ksba_cms_t cms, int idx);
  360 ksba_cert_t ksba_cms_get_cert (ksba_cms_t cms, int idx);
  361 gpg_error_t ksba_cms_get_message_digest (ksba_cms_t cms, int idx,
  362                                          char **r_digest, size_t *r_digest_len);
  363 gpg_error_t ksba_cms_get_signing_time (ksba_cms_t cms, int idx,
  364                                        ksba_isotime_t r_sigtime);
  365 gpg_error_t ksba_cms_get_sigattr_oids (ksba_cms_t cms, int idx,
  366                                        const char *reqoid, char **r_value);
  367 ksba_sexp_t ksba_cms_get_sig_val (ksba_cms_t cms, int idx);
  368 ksba_sexp_t ksba_cms_get_enc_val (ksba_cms_t cms, int idx);
  369 
  370 void ksba_cms_set_hash_function (ksba_cms_t cms,
  371                                  void (*hash_fnc)(void *, const void *, size_t),
  372                                  void *hash_fnc_arg);
  373 
  374 gpg_error_t ksba_cms_hash_signed_attrs (ksba_cms_t cms, int idx);
  375 
  376 
  377 gpg_error_t ksba_cms_set_content_type (ksba_cms_t cms, int what,
  378                                        ksba_content_type_t type);
  379 gpg_error_t ksba_cms_add_digest_algo (ksba_cms_t cms, const char *oid);
  380 gpg_error_t ksba_cms_add_signer (ksba_cms_t cms, ksba_cert_t cert);
  381 gpg_error_t ksba_cms_add_cert (ksba_cms_t cms, ksba_cert_t cert);
  382 gpg_error_t ksba_cms_add_smime_capability (ksba_cms_t cms, const char *oid,
  383                                            const unsigned char *der,
  384                                            size_t derlen);
  385 gpg_error_t ksba_cms_set_message_digest (ksba_cms_t cms, int idx,
  386                                          const unsigned char *digest,
  387                                          size_t digest_len);
  388 gpg_error_t ksba_cms_set_signing_time (ksba_cms_t cms, int idx,
  389                                        const ksba_isotime_t sigtime);
  390 gpg_error_t ksba_cms_set_sig_val (ksba_cms_t cms,
  391                                   int idx, ksba_const_sexp_t sigval);
  392 
  393 gpg_error_t ksba_cms_set_content_enc_algo (ksba_cms_t cms,
  394                                            const char *oid,
  395                                            const void *iv,
  396                                            size_t ivlen);
  397 gpg_error_t ksba_cms_add_recipient (ksba_cms_t cms, ksba_cert_t cert);
  398 gpg_error_t ksba_cms_set_enc_val (ksba_cms_t cms,
  399                                   int idx, ksba_const_sexp_t encval);
  400 
  401 
  402 /*-- crl.c --*/
  403 gpg_error_t ksba_crl_new (ksba_crl_t *r_crl);
  404 void        ksba_crl_release (ksba_crl_t crl);
  405 gpg_error_t ksba_crl_set_reader (ksba_crl_t crl, ksba_reader_t r);
  406 void        ksba_crl_set_hash_function (ksba_crl_t crl,
  407                                         void (*hash_fnc)(void *,
  408                                                          const void *, size_t),
  409                                         void *hash_fnc_arg);
  410 const char *ksba_crl_get_digest_algo (ksba_crl_t crl);
  411 gpg_error_t ksba_crl_get_issuer (ksba_crl_t crl, char **r_issuer);
  412 gpg_error_t ksba_crl_get_extension (ksba_crl_t crl, int idx,
  413                                     char const **oid, int *critical,
  414                                     unsigned char const **der, size_t *derlen);
  415 gpg_error_t ksba_crl_get_auth_key_id (ksba_crl_t crl,
  416                                       ksba_sexp_t *r_keyid,
  417                                       ksba_name_t *r_name,
  418                                       ksba_sexp_t *r_serial);
  419 gpg_error_t ksba_crl_get_crl_number (ksba_crl_t crl, ksba_sexp_t *number);
  420 gpg_error_t ksba_crl_get_update_times (ksba_crl_t crl,
  421                                        ksba_isotime_t this_update,
  422                                        ksba_isotime_t next_update);
  423 gpg_error_t ksba_crl_get_item (ksba_crl_t crl,
  424                                ksba_sexp_t *r_serial,
  425                                ksba_isotime_t r_revocation_date,
  426                                ksba_crl_reason_t *r_reason);
  427 ksba_sexp_t ksba_crl_get_sig_val (ksba_crl_t crl);
  428 gpg_error_t ksba_crl_parse (ksba_crl_t crl, ksba_stop_reason_t *r_stopreason);
  429 
  430 
  431 
  432 /*-- ocsp.c --*/
  433 gpg_error_t ksba_ocsp_new (ksba_ocsp_t *r_oscp);
  434 void ksba_ocsp_release (ksba_ocsp_t ocsp);
  435 gpg_error_t ksba_ocsp_set_digest_algo (ksba_ocsp_t ocsp, const char *oid);
  436 gpg_error_t ksba_ocsp_set_requestor (ksba_ocsp_t ocsp, ksba_cert_t cert);
  437 gpg_error_t ksba_ocsp_add_target (ksba_ocsp_t ocsp,
  438                                   ksba_cert_t cert, ksba_cert_t issuer_cert);
  439 size_t ksba_ocsp_set_nonce (ksba_ocsp_t ocsp,
  440                             unsigned char *nonce, size_t noncelen);
  441 
  442 gpg_error_t ksba_ocsp_prepare_request (ksba_ocsp_t ocsp);
  443 gpg_error_t ksba_ocsp_hash_request (ksba_ocsp_t ocsp,
  444                                     void (*hasher)(void *, const void *,
  445                                                    size_t length),
  446                                     void *hasher_arg);
  447 gpg_error_t ksba_ocsp_set_sig_val (ksba_ocsp_t ocsp,
  448                                    ksba_const_sexp_t sigval);
  449 gpg_error_t ksba_ocsp_add_cert (ksba_ocsp_t ocsp, ksba_cert_t cert);
  450 gpg_error_t ksba_ocsp_build_request (ksba_ocsp_t ocsp,
  451                                      unsigned char **r_buffer,
  452                                      size_t *r_buflen);
  453 
  454 gpg_error_t ksba_ocsp_parse_response (ksba_ocsp_t ocsp,
  455                                       const unsigned char *msg, size_t msglen,
  456                                       ksba_ocsp_response_status_t *resp_status);
  457 
  458 const char *ksba_ocsp_get_digest_algo (ksba_ocsp_t ocsp);
  459 gpg_error_t ksba_ocsp_hash_response (ksba_ocsp_t ocsp,
  460                                      const unsigned char *msg, size_t msglen,
  461                                      void (*hasher)(void *, const void *,
  462                                                     size_t length),
  463                                      void *hasher_arg);
  464 ksba_sexp_t ksba_ocsp_get_sig_val (ksba_ocsp_t ocsp,
  465                                    ksba_isotime_t produced_at);
  466 gpg_error_t ksba_ocsp_get_responder_id (ksba_ocsp_t ocsp,
  467                                         char **r_name,
  468                                         ksba_sexp_t *r_keyid);
  469 ksba_cert_t ksba_ocsp_get_cert (ksba_ocsp_t ocsp, int idx);
  470 gpg_error_t ksba_ocsp_get_status (ksba_ocsp_t ocsp, ksba_cert_t cert,
  471                                   ksba_status_t *r_status,
  472                                   ksba_isotime_t r_this_update,
  473                                   ksba_isotime_t r_next_update,
  474                                   ksba_isotime_t r_revocation_time,
  475                                   ksba_crl_reason_t *r_reason);
  476 gpg_error_t ksba_ocsp_get_extension (ksba_ocsp_t ocsp, ksba_cert_t cert,
  477                                      int idx,
  478                                      char const **r_oid, int *r_crit,
  479                                      unsigned char const **r_der,
  480                                      size_t *r_derlen);
  481 
  482 
  483 /*-- certreq.c --*/
  484 gpg_error_t ksba_certreq_new (ksba_certreq_t *r_cr);
  485 void        ksba_certreq_release (ksba_certreq_t cr);
  486 gpg_error_t ksba_certreq_set_writer (ksba_certreq_t cr, ksba_writer_t w);
  487 void         ksba_certreq_set_hash_function (
  488                                ksba_certreq_t cr,
  489                                void (*hash_fnc)(void *, const void *, size_t),
  490                                void *hash_fnc_arg);
  491 gpg_error_t ksba_certreq_add_subject (ksba_certreq_t cr, const char *name);
  492 gpg_error_t ksba_certreq_set_public_key (ksba_certreq_t cr,
  493                                          ksba_const_sexp_t key);
  494 gpg_error_t ksba_certreq_add_extension (ksba_certreq_t cr,
  495                                         const char *oid, int is_crit,
  496                                         const void *der,
  497                                         size_t derlen);
  498 gpg_error_t ksba_certreq_set_sig_val (ksba_certreq_t cr,
  499                                       ksba_const_sexp_t sigval);
  500 gpg_error_t ksba_certreq_build (ksba_certreq_t cr,
  501                                 ksba_stop_reason_t *r_stopreason);
  502 
  503 /* The functions below are used to switch to X.509 certificate creation.  */
  504 gpg_error_t ksba_certreq_set_serial (ksba_certreq_t cr, ksba_const_sexp_t sn);
  505 gpg_error_t ksba_certreq_set_issuer (ksba_certreq_t cr, const char *name);
  506 gpg_error_t ksba_certreq_set_validity (ksba_certreq_t cr, int what,
  507                                        const ksba_isotime_t timebuf);
  508 gpg_error_t ksba_certreq_set_siginfo (ksba_certreq_t cr,
  509                                       ksba_const_sexp_t siginfo);
  510 
  511 
  512 
  513 /*-- reader.c --*/
  514 gpg_error_t ksba_reader_new (ksba_reader_t *r_r);
  515 void        ksba_reader_release (ksba_reader_t r);
  516 gpg_error_t ksba_reader_set_release_notify (ksba_reader_t r,
  517                                             void (*notify)(void*,ksba_reader_t),
  518                                             void *notify_value);
  519 gpg_error_t ksba_reader_clear (ksba_reader_t r,
  520                                unsigned char **buffer, size_t *buflen);
  521 gpg_error_t ksba_reader_error (ksba_reader_t r);
  522 
  523 gpg_error_t ksba_reader_set_mem (ksba_reader_t r,
  524                                const void *buffer, size_t length);
  525 gpg_error_t ksba_reader_set_fd (ksba_reader_t r, int fd);
  526 gpg_error_t ksba_reader_set_file (ksba_reader_t r, FILE *fp);
  527 gpg_error_t ksba_reader_set_cb (ksba_reader_t r,
  528                               int (*cb)(void*,char *,size_t,size_t*),
  529                               void *cb_value );
  530 
  531 gpg_error_t ksba_reader_read (ksba_reader_t r,
  532                             char *buffer, size_t length, size_t *nread);
  533 gpg_error_t ksba_reader_unread (ksba_reader_t r, const void *buffer, size_t count);
  534 unsigned long ksba_reader_tell (ksba_reader_t r);
  535 
  536 /*-- writer.c --*/
  537 gpg_error_t ksba_writer_new (ksba_writer_t *r_w);
  538 void        ksba_writer_release (ksba_writer_t w);
  539 gpg_error_t ksba_writer_set_release_notify (ksba_writer_t w,
  540                                             void (*notify)(void*,ksba_writer_t),
  541                                             void *notify_value);
  542 int         ksba_writer_error (ksba_writer_t w);
  543 unsigned long ksba_writer_tell (ksba_writer_t w);
  544 gpg_error_t ksba_writer_set_fd (ksba_writer_t w, int fd);
  545 gpg_error_t ksba_writer_set_file (ksba_writer_t w, FILE *fp);
  546 gpg_error_t ksba_writer_set_cb (ksba_writer_t w,
  547                                 int (*cb)(void*,const void *,size_t),
  548                                 void *cb_value);
  549 gpg_error_t ksba_writer_set_mem (ksba_writer_t w, size_t initial_size);
  550 const void *ksba_writer_get_mem (ksba_writer_t w, size_t *nbytes);
  551 void *      ksba_writer_snatch_mem (ksba_writer_t w, size_t *nbytes);
  552 gpg_error_t ksba_writer_set_filter (ksba_writer_t w,
  553                                     gpg_error_t (*filter)(void*,
  554                                              const void *,size_t, size_t *,
  555                                              void *, size_t, size_t *),
  556                                     void *filter_arg);
  557 
  558 gpg_error_t ksba_writer_write (ksba_writer_t w, const void *buffer, size_t length);
  559 gpg_error_t ksba_writer_write_octet_string (ksba_writer_t w,
  560                                           const void *buffer, size_t length,
  561                                           int flush);
  562 
  563 /*-- asn1-parse.y --*/
  564 int ksba_asn_parse_file (const char *filename, ksba_asn_tree_t *result,
  565                          int debug);
  566 void ksba_asn_tree_release (ksba_asn_tree_t tree);
  567 
  568 /*-- asn1-func.c --*/
  569 void ksba_asn_tree_dump (ksba_asn_tree_t tree, const char *name, FILE *fp);
  570 gpg_error_t ksba_asn_create_tree (const char *mod_name, ksba_asn_tree_t *result);
  571 
  572 /*-- oid.c --*/
  573 char *ksba_oid_to_str (const char *buffer, size_t length);
  574 gpg_error_t ksba_oid_from_str (const char *string,
  575                                unsigned char **rbuf, size_t *rlength);
  576 
  577 /*-- dn.c --*/
  578 gpg_error_t ksba_dn_der2str (const void *der, size_t derlen, char **r_string);
  579 gpg_error_t ksba_dn_str2der (const char *string,
  580                              unsigned char **rder, size_t *rderlen);
  581 gpg_error_t ksba_dn_teststr (const char *string, int seq,
  582                              size_t *rerroff, size_t *rerrlen);
  583 
  584 
  585 /*-- name.c --*/
  586 gpg_error_t ksba_name_new (ksba_name_t *r_name);
  587 void        ksba_name_ref (ksba_name_t name);
  588 void        ksba_name_release (ksba_name_t name);
  589 const char *ksba_name_enum (ksba_name_t name, int idx);
  590 char       *ksba_name_get_uri (ksba_name_t name, int idx);
  591 
  592 
  593 /*-- der-builder.c --*/
  594 void ksba_der_release (ksba_der_t d);
  595 
  596 ksba_der_t ksba_der_builder_new (unsigned int nitems);
  597 void ksba_der_builder_reset (ksba_der_t d);
  598 
  599 void ksba_der_add_ptr (ksba_der_t d, int cls, int tag,
  600                        void *value, size_t valuelen);
  601 void ksba_der_add_val (ksba_der_t d, int cls, int tag,
  602                        const void *value, size_t valuelen);
  603 void ksba_der_add_int (ksba_der_t d, const void *value, size_t valuelen,
  604                        int force_positive);
  605 void ksba_der_add_oid (ksba_der_t d, const char *oidstr);
  606 void ksba_der_add_bts (ksba_der_t d, const void *value, size_t valuelen,
  607                        unsigned int unusedbits);
  608 void ksba_der_add_der (ksba_der_t d, const void *der, size_t derlen);
  609 void ksba_der_add_tag (ksba_der_t d, int cls, int tag);
  610 void ksba_der_add_end (ksba_der_t d);
  611 
  612 gpg_error_t ksba_der_builder_get (ksba_der_t d,
  613                                   unsigned char **r_obj, size_t *r_objlen);
  614 
  615 
  616 
  617 /*-- util.c --*/
  618 void ksba_set_malloc_hooks ( void *(*new_alloc_func)(size_t n),
  619                              void *(*new_realloc_func)(void *p, size_t n),
  620                              void (*new_free_func)(void*) );
  621 void ksba_set_hash_buffer_function ( gpg_error_t (*fnc)
  622                                      (void *arg, const char *oid,
  623                                       const void *buffer, size_t length,
  624                                       size_t resultsize,
  625                                       unsigned char *result,
  626                                       size_t *resultlen),
  627                                      void *fnc_arg);
  628 void *ksba_malloc (size_t n );
  629 void *ksba_calloc (size_t n, size_t m );
  630 void *ksba_realloc (void *p, size_t n);
  631 char *ksba_strdup (const char *p);
  632 void  ksba_free ( void *a );
  633 
  634 /*--version.c --*/
  635 const char *ksba_check_version (const char *req_version);
  636 
  637 #ifdef __cplusplus
  638 }
  639 #endif
  640 #endif /*KSBA_H*/