"Fossies" - the Fresh Open Source Software Archive

Member "libksba-1.5.0/src/ksba.h" (18 Nov 2020, 26951 Bytes) of package /linux/privat/libksba-1.5.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.4.0_vs_1.5.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 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.5.0"
   50 
   51 /* The version number of this header.  It may be used to handle minor
   52  * API incompatibilities.  */
   53 #define KSBA_VERSION_NUMBER 0x010500
   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   }
  131 ksba_content_type_t;
  132 typedef ksba_content_type_t KsbaContentType _KSBA_DEPRECATED;
  133 
  134 
  135 
  136 typedef enum
  137   {
  138     KSBA_SR_NONE = 0,     /* Never seen by libksba user. */
  139     KSBA_SR_RUNNING = 1,  /* Never seen by libksba user. */
  140     KSBA_SR_GOT_CONTENT = 2,
  141     KSBA_SR_NEED_HASH = 3,
  142     KSBA_SR_BEGIN_DATA = 4,
  143     KSBA_SR_END_DATA = 5,
  144     KSBA_SR_READY = 6,
  145     KSBA_SR_NEED_SIG = 7,
  146     KSBA_SR_DETACHED_DATA = 8,
  147     KSBA_SR_BEGIN_ITEMS = 9,
  148     KSBA_SR_GOT_ITEM = 10,
  149     KSBA_SR_END_ITEMS = 11
  150   }
  151 ksba_stop_reason_t;
  152 typedef ksba_stop_reason_t KsbaStopReason _KSBA_DEPRECATED;
  153 
  154 typedef enum
  155   {
  156     KSBA_CRLREASON_UNSPECIFIED = 1,
  157     KSBA_CRLREASON_KEY_COMPROMISE = 2,
  158     KSBA_CRLREASON_CA_COMPROMISE = 4,
  159     KSBA_CRLREASON_AFFILIATION_CHANGED = 8,
  160     KSBA_CRLREASON_SUPERSEDED = 16,
  161     KSBA_CRLREASON_CESSATION_OF_OPERATION = 32,
  162     KSBA_CRLREASON_CERTIFICATE_HOLD = 64,
  163     KSBA_CRLREASON_REMOVE_FROM_CRL = 256,
  164     KSBA_CRLREASON_PRIVILEGE_WITHDRAWN = 512,
  165     KSBA_CRLREASON_AA_COMPROMISE = 1024,
  166     KSBA_CRLREASON_OTHER = 32768
  167   }
  168 ksba_crl_reason_t;
  169 typedef ksba_crl_reason_t KsbaCRLReason _KSBA_DEPRECATED;
  170 
  171 typedef enum
  172   {
  173     KSBA_OCSP_RSPSTATUS_SUCCESS = 0,
  174     KSBA_OCSP_RSPSTATUS_MALFORMED = 1,
  175     KSBA_OCSP_RSPSTATUS_INTERNAL = 2,
  176     KSBA_OCSP_RSPSTATUS_TRYLATER = 3,
  177     KSBA_OCSP_RSPSTATUS_SIGREQUIRED = 5,
  178     KSBA_OCSP_RSPSTATUS_UNAUTHORIZED = 6,
  179     KSBA_OCSP_RSPSTATUS_REPLAYED = 253,
  180     KSBA_OCSP_RSPSTATUS_OTHER = 254,
  181     KSBA_OCSP_RSPSTATUS_NONE = 255
  182   }
  183 ksba_ocsp_response_status_t;
  184 
  185 typedef enum
  186   {
  187     KSBA_STATUS_NONE = 0,
  188     KSBA_STATUS_UNKNOWN = 1,
  189     KSBA_STATUS_GOOD = 2,
  190     KSBA_STATUS_REVOKED = 4
  191   }
  192 ksba_status_t;
  193 
  194 
  195 typedef enum
  196   {
  197     KSBA_KEYUSAGE_DIGITAL_SIGNATURE =  1,
  198     KSBA_KEYUSAGE_NON_REPUDIATION   =  2,
  199     KSBA_KEYUSAGE_KEY_ENCIPHERMENT  =  4,
  200     KSBA_KEYUSAGE_DATA_ENCIPHERMENT =  8,
  201     KSBA_KEYUSAGE_KEY_AGREEMENT     = 16,
  202     KSBA_KEYUSAGE_KEY_CERT_SIGN     = 32,
  203     KSBA_KEYUSAGE_CRL_SIGN          = 64,
  204     KSBA_KEYUSAGE_ENCIPHER_ONLY    = 128,
  205     KSBA_KEYUSAGE_DECIPHER_ONLY    = 256
  206   }
  207 ksba_key_usage_t;
  208 typedef ksba_key_usage_t KsbaKeyUsage _KSBA_DEPRECATED;
  209 
  210 /* ISO format, e.g. "19610711T172059", assumed to be UTC. */
  211 typedef char ksba_isotime_t[16];
  212 
  213 
  214 /* X.509 certificates are represented by this object.
  215    ksba_cert_new() creates such an object */
  216 struct ksba_cert_s;
  217 typedef struct ksba_cert_s *ksba_cert_t;
  218 typedef struct ksba_cert_s *KsbaCert _KSBA_DEPRECATED;
  219 
  220 /* CMS objects are controlled by this object.
  221    ksba_cms_new() creates it */
  222 struct ksba_cms_s;
  223 typedef struct ksba_cms_s *ksba_cms_t;
  224 typedef struct ksba_cms_s *KsbaCMS _KSBA_DEPRECATED;
  225 
  226 /* CRL objects are controlled by this object.
  227    ksba_crl_new() creates it */
  228 struct ksba_crl_s;
  229 typedef struct ksba_crl_s *ksba_crl_t;
  230 typedef struct ksba_crl_s *KsbaCRL _KSBA_DEPRECATED;
  231 
  232 /* OCSP objects are controlled by this object.
  233    ksba_ocsp_new() creates it. */
  234 struct ksba_ocsp_s;
  235 typedef struct ksba_ocsp_s *ksba_ocsp_t;
  236 
  237 /* PKCS-10 creation is controlled by this object.
  238    ksba_certreq_new() creates it */
  239 struct ksba_certreq_s;
  240 typedef struct ksba_certreq_s *ksba_certreq_t;
  241 typedef struct ksba_certreq_s *KsbaCertreq _KSBA_DEPRECATED;
  242 
  243 /* This is a reader object for various purposes
  244    see ksba_reader_new et al. */
  245 struct ksba_reader_s;
  246 typedef struct ksba_reader_s *ksba_reader_t;
  247 typedef struct ksba_reader_s *KsbaReader _KSBA_DEPRECATED;
  248 
  249 /* This is a writer object for various purposes
  250    see ksba_writer_new et al. */
  251 struct ksba_writer_s;
  252 typedef struct ksba_writer_s *ksba_writer_t;
  253 typedef struct ksba_writer_s *KsbaWriter _KSBA_DEPRECATED;
  254 
  255 /* This is an object to store an ASN.1 parse tree as
  256    create by ksba_asn_parse_file() */
  257 struct ksba_asn_tree_s;
  258 typedef struct ksba_asn_tree_s *ksba_asn_tree_t;
  259 typedef struct ksba_asn_tree_s *KsbaAsnTree _KSBA_DEPRECATED;
  260 
  261 /* This is an object to reference a General Name.  Such an object is
  262    returned by several functions. */
  263 struct ksba_name_s;
  264 typedef struct ksba_name_s *ksba_name_t;
  265 typedef struct ksba_name_s *KsbaName _KSBA_DEPRECATED;
  266 
  267 /* KsbaSexp is just an unsigned char * which should be used for
  268    documentation purpose.  The S-expressions returned by libksba are
  269    always in canonical representation with an extra 0 byte at the end,
  270    so that one can print the values in the debugger and at least see
  271    the first bytes */
  272 typedef unsigned char *ksba_sexp_t;
  273 typedef unsigned char *KsbaSexp _KSBA_DEPRECATED;
  274 typedef const unsigned char *ksba_const_sexp_t;
  275 typedef const unsigned char *KsbaConstSexp _KSBA_DEPRECATED;
  276 
  277 
  278 /* This is a generic object used by various functions.  */
  279 struct ksba_der_s;
  280 typedef struct ksba_der_s *ksba_der_t;
  281 
  282 
  283 /*-- cert.c --*/
  284 gpg_error_t ksba_cert_new (ksba_cert_t *acert);
  285 void        ksba_cert_ref (ksba_cert_t cert);
  286 void        ksba_cert_release (ksba_cert_t cert);
  287 gpg_error_t ksba_cert_set_user_data (ksba_cert_t cert, const char *key,
  288                                      const void *data, size_t datalen);
  289 gpg_error_t ksba_cert_get_user_data (ksba_cert_t cert, const char *key,
  290                                      void *buffer, size_t bufferlen,
  291                                      size_t *datalen);
  292 
  293 gpg_error_t ksba_cert_read_der (ksba_cert_t cert, ksba_reader_t reader);
  294 gpg_error_t ksba_cert_init_from_mem (ksba_cert_t cert,
  295                                      const void *buffer, size_t length);
  296 const unsigned char *ksba_cert_get_image (ksba_cert_t cert, size_t *r_length);
  297 gpg_error_t ksba_cert_hash (ksba_cert_t cert,
  298                             int what,
  299                             void (*hasher)(void *,
  300                                            const void *,
  301                                            size_t length),
  302                             void *hasher_arg);
  303 const char *ksba_cert_get_digest_algo (ksba_cert_t cert);
  304 ksba_sexp_t ksba_cert_get_serial (ksba_cert_t cert);
  305 char       *ksba_cert_get_issuer (ksba_cert_t cert, int idx);
  306 gpg_error_t ksba_cert_get_validity (ksba_cert_t cert, int what,
  307                                     ksba_isotime_t r_time);
  308 char       *ksba_cert_get_subject (ksba_cert_t cert, int idx);
  309 ksba_sexp_t ksba_cert_get_public_key (ksba_cert_t cert);
  310 ksba_sexp_t ksba_cert_get_sig_val (ksba_cert_t cert);
  311 
  312 gpg_error_t ksba_cert_get_extension (ksba_cert_t cert, int idx,
  313                                      char const **r_oid, int *r_crit,
  314                                      size_t *r_deroff, size_t *r_derlen);
  315 
  316 gpg_error_t ksba_cert_is_ca (ksba_cert_t cert, int *r_ca, int *r_pathlen);
  317 gpg_error_t ksba_cert_get_key_usage (ksba_cert_t cert, unsigned int *r_flags);
  318 gpg_error_t ksba_cert_get_cert_policies (ksba_cert_t cert, char **r_policies);
  319 gpg_error_t ksba_cert_get_ext_key_usages (ksba_cert_t cert, char **result);
  320 gpg_error_t ksba_cert_get_crl_dist_point (ksba_cert_t cert, int idx,
  321                                           ksba_name_t *r_distpoint,
  322                                           ksba_name_t *r_issuer,
  323                                           ksba_crl_reason_t *r_reason);
  324 gpg_error_t ksba_cert_get_auth_key_id (ksba_cert_t cert,
  325                                        ksba_sexp_t *r_keyid,
  326                                        ksba_name_t *r_name,
  327                                        ksba_sexp_t *r_serial);
  328 gpg_error_t ksba_cert_get_subj_key_id (ksba_cert_t cert,
  329                                        int *r_crit,
  330                                        ksba_sexp_t *r_keyid);
  331 gpg_error_t ksba_cert_get_authority_info_access (ksba_cert_t cert, int idx,
  332                                                  char **r_method,
  333                                                  ksba_name_t *r_location);
  334 gpg_error_t ksba_cert_get_subject_info_access (ksba_cert_t cert, int idx,
  335                                                char **r_method,
  336                                                ksba_name_t *r_location);
  337 
  338 
  339 /*-- cms.c --*/
  340 ksba_content_type_t ksba_cms_identify (ksba_reader_t reader);
  341 
  342 gpg_error_t ksba_cms_new (ksba_cms_t *r_cms);
  343 void        ksba_cms_release (ksba_cms_t cms);
  344 gpg_error_t ksba_cms_set_reader_writer (ksba_cms_t cms,
  345                                         ksba_reader_t r, ksba_writer_t w);
  346 
  347 gpg_error_t ksba_cms_parse (ksba_cms_t cms, ksba_stop_reason_t *r_stopreason);
  348 gpg_error_t ksba_cms_build (ksba_cms_t cms, ksba_stop_reason_t *r_stopreason);
  349 
  350 ksba_content_type_t ksba_cms_get_content_type (ksba_cms_t cms, int what);
  351 const char *ksba_cms_get_content_oid (ksba_cms_t cms, int what);
  352 gpg_error_t ksba_cms_get_content_enc_iv (ksba_cms_t cms, void *iv,
  353                                          size_t maxivlen, size_t *ivlen);
  354 const char *ksba_cms_get_digest_algo_list (ksba_cms_t cms, int idx);
  355 gpg_error_t ksba_cms_get_issuer_serial (ksba_cms_t cms, int idx,
  356                                         char **r_issuer,
  357                                         ksba_sexp_t *r_serial);
  358 const char *ksba_cms_get_digest_algo (ksba_cms_t cms, int idx);
  359 ksba_cert_t ksba_cms_get_cert (ksba_cms_t cms, int idx);
  360 gpg_error_t ksba_cms_get_message_digest (ksba_cms_t cms, int idx,
  361                                          char **r_digest, size_t *r_digest_len);
  362 gpg_error_t ksba_cms_get_signing_time (ksba_cms_t cms, int idx,
  363                                        ksba_isotime_t r_sigtime);
  364 gpg_error_t ksba_cms_get_sigattr_oids (ksba_cms_t cms, int idx,
  365                                        const char *reqoid, char **r_value);
  366 ksba_sexp_t ksba_cms_get_sig_val (ksba_cms_t cms, int idx);
  367 ksba_sexp_t ksba_cms_get_enc_val (ksba_cms_t cms, int idx);
  368 
  369 void ksba_cms_set_hash_function (ksba_cms_t cms,
  370                                  void (*hash_fnc)(void *, const void *, size_t),
  371                                  void *hash_fnc_arg);
  372 
  373 gpg_error_t ksba_cms_hash_signed_attrs (ksba_cms_t cms, int idx);
  374 
  375 
  376 gpg_error_t ksba_cms_set_content_type (ksba_cms_t cms, int what,
  377                                        ksba_content_type_t type);
  378 gpg_error_t ksba_cms_add_digest_algo (ksba_cms_t cms, const char *oid);
  379 gpg_error_t ksba_cms_add_signer (ksba_cms_t cms, ksba_cert_t cert);
  380 gpg_error_t ksba_cms_add_cert (ksba_cms_t cms, ksba_cert_t cert);
  381 gpg_error_t ksba_cms_add_smime_capability (ksba_cms_t cms, const char *oid,
  382                                            const unsigned char *der,
  383                                            size_t derlen);
  384 gpg_error_t ksba_cms_set_message_digest (ksba_cms_t cms, int idx,
  385                                          const unsigned char *digest,
  386                                          size_t digest_len);
  387 gpg_error_t ksba_cms_set_signing_time (ksba_cms_t cms, int idx,
  388                                        const ksba_isotime_t sigtime);
  389 gpg_error_t ksba_cms_set_sig_val (ksba_cms_t cms,
  390                                   int idx, ksba_const_sexp_t sigval);
  391 
  392 gpg_error_t ksba_cms_set_content_enc_algo (ksba_cms_t cms,
  393                                            const char *oid,
  394                                            const void *iv,
  395                                            size_t ivlen);
  396 gpg_error_t ksba_cms_add_recipient (ksba_cms_t cms, ksba_cert_t cert);
  397 gpg_error_t ksba_cms_set_enc_val (ksba_cms_t cms,
  398                                   int idx, ksba_const_sexp_t encval);
  399 
  400 
  401 /*-- crl.c --*/
  402 gpg_error_t ksba_crl_new (ksba_crl_t *r_crl);
  403 void        ksba_crl_release (ksba_crl_t crl);
  404 gpg_error_t ksba_crl_set_reader (ksba_crl_t crl, ksba_reader_t r);
  405 void        ksba_crl_set_hash_function (ksba_crl_t crl,
  406                                         void (*hash_fnc)(void *,
  407                                                          const void *, size_t),
  408                                         void *hash_fnc_arg);
  409 const char *ksba_crl_get_digest_algo (ksba_crl_t crl);
  410 gpg_error_t ksba_crl_get_issuer (ksba_crl_t crl, char **r_issuer);
  411 gpg_error_t ksba_crl_get_extension (ksba_crl_t crl, int idx,
  412                                     char const **oid, int *critical,
  413                                     unsigned char const **der, size_t *derlen);
  414 gpg_error_t ksba_crl_get_auth_key_id (ksba_crl_t crl,
  415                                       ksba_sexp_t *r_keyid,
  416                                       ksba_name_t *r_name,
  417                                       ksba_sexp_t *r_serial);
  418 gpg_error_t ksba_crl_get_crl_number (ksba_crl_t crl, ksba_sexp_t *number);
  419 gpg_error_t ksba_crl_get_update_times (ksba_crl_t crl,
  420                                        ksba_isotime_t this_update,
  421                                        ksba_isotime_t next_update);
  422 gpg_error_t ksba_crl_get_item (ksba_crl_t crl,
  423                                ksba_sexp_t *r_serial,
  424                                ksba_isotime_t r_revocation_date,
  425                                ksba_crl_reason_t *r_reason);
  426 ksba_sexp_t ksba_crl_get_sig_val (ksba_crl_t crl);
  427 gpg_error_t ksba_crl_parse (ksba_crl_t crl, ksba_stop_reason_t *r_stopreason);
  428 
  429 
  430 
  431 /*-- ocsp.c --*/
  432 gpg_error_t ksba_ocsp_new (ksba_ocsp_t *r_oscp);
  433 void ksba_ocsp_release (ksba_ocsp_t ocsp);
  434 gpg_error_t ksba_ocsp_set_digest_algo (ksba_ocsp_t ocsp, const char *oid);
  435 gpg_error_t ksba_ocsp_set_requestor (ksba_ocsp_t ocsp, ksba_cert_t cert);
  436 gpg_error_t ksba_ocsp_add_target (ksba_ocsp_t ocsp,
  437                                   ksba_cert_t cert, ksba_cert_t issuer_cert);
  438 size_t ksba_ocsp_set_nonce (ksba_ocsp_t ocsp,
  439                             unsigned char *nonce, size_t noncelen);
  440 
  441 gpg_error_t ksba_ocsp_prepare_request (ksba_ocsp_t ocsp);
  442 gpg_error_t ksba_ocsp_hash_request (ksba_ocsp_t ocsp,
  443                                     void (*hasher)(void *, const void *,
  444                                                    size_t length),
  445                                     void *hasher_arg);
  446 gpg_error_t ksba_ocsp_set_sig_val (ksba_ocsp_t ocsp,
  447                                    ksba_const_sexp_t sigval);
  448 gpg_error_t ksba_ocsp_add_cert (ksba_ocsp_t ocsp, ksba_cert_t cert);
  449 gpg_error_t ksba_ocsp_build_request (ksba_ocsp_t ocsp,
  450                                      unsigned char **r_buffer,
  451                                      size_t *r_buflen);
  452 
  453 gpg_error_t ksba_ocsp_parse_response (ksba_ocsp_t ocsp,
  454                                       const unsigned char *msg, size_t msglen,
  455                                       ksba_ocsp_response_status_t *resp_status);
  456 
  457 const char *ksba_ocsp_get_digest_algo (ksba_ocsp_t ocsp);
  458 gpg_error_t ksba_ocsp_hash_response (ksba_ocsp_t ocsp,
  459                                      const unsigned char *msg, size_t msglen,
  460                                      void (*hasher)(void *, const void *,
  461                                                     size_t length),
  462                                      void *hasher_arg);
  463 ksba_sexp_t ksba_ocsp_get_sig_val (ksba_ocsp_t ocsp,
  464                                    ksba_isotime_t produced_at);
  465 gpg_error_t ksba_ocsp_get_responder_id (ksba_ocsp_t ocsp,
  466                                         char **r_name,
  467                                         ksba_sexp_t *r_keyid);
  468 ksba_cert_t ksba_ocsp_get_cert (ksba_ocsp_t ocsp, int idx);
  469 gpg_error_t ksba_ocsp_get_status (ksba_ocsp_t ocsp, ksba_cert_t cert,
  470                                   ksba_status_t *r_status,
  471                                   ksba_isotime_t r_this_update,
  472                                   ksba_isotime_t r_next_update,
  473                                   ksba_isotime_t r_revocation_time,
  474                                   ksba_crl_reason_t *r_reason);
  475 gpg_error_t ksba_ocsp_get_extension (ksba_ocsp_t ocsp, ksba_cert_t cert,
  476                                      int idx,
  477                                      char const **r_oid, int *r_crit,
  478                                      unsigned char const **r_der,
  479                                      size_t *r_derlen);
  480 
  481 
  482 /*-- certreq.c --*/
  483 gpg_error_t ksba_certreq_new (ksba_certreq_t *r_cr);
  484 void        ksba_certreq_release (ksba_certreq_t cr);
  485 gpg_error_t ksba_certreq_set_writer (ksba_certreq_t cr, ksba_writer_t w);
  486 void         ksba_certreq_set_hash_function (
  487                                ksba_certreq_t cr,
  488                                void (*hash_fnc)(void *, const void *, size_t),
  489                                void *hash_fnc_arg);
  490 gpg_error_t ksba_certreq_add_subject (ksba_certreq_t cr, const char *name);
  491 gpg_error_t ksba_certreq_set_public_key (ksba_certreq_t cr,
  492                                          ksba_const_sexp_t key);
  493 gpg_error_t ksba_certreq_add_extension (ksba_certreq_t cr,
  494                                         const char *oid, int is_crit,
  495                                         const void *der,
  496                                         size_t derlen);
  497 gpg_error_t ksba_certreq_set_sig_val (ksba_certreq_t cr,
  498                                       ksba_const_sexp_t sigval);
  499 gpg_error_t ksba_certreq_build (ksba_certreq_t cr,
  500                                 ksba_stop_reason_t *r_stopreason);
  501 
  502 /* The functions below are used to switch to X.509 certificate creation.  */
  503 gpg_error_t ksba_certreq_set_serial (ksba_certreq_t cr, ksba_const_sexp_t sn);
  504 gpg_error_t ksba_certreq_set_issuer (ksba_certreq_t cr, const char *name);
  505 gpg_error_t ksba_certreq_set_validity (ksba_certreq_t cr, int what,
  506                                        const ksba_isotime_t timebuf);
  507 gpg_error_t ksba_certreq_set_siginfo (ksba_certreq_t cr,
  508                                       ksba_const_sexp_t siginfo);
  509 
  510 
  511 
  512 /*-- reader.c --*/
  513 gpg_error_t ksba_reader_new (ksba_reader_t *r_r);
  514 void        ksba_reader_release (ksba_reader_t r);
  515 gpg_error_t ksba_reader_set_release_notify (ksba_reader_t r,
  516                                             void (*notify)(void*,ksba_reader_t),
  517                                             void *notify_value);
  518 gpg_error_t ksba_reader_clear (ksba_reader_t r,
  519                                unsigned char **buffer, size_t *buflen);
  520 gpg_error_t ksba_reader_error (ksba_reader_t r);
  521 
  522 gpg_error_t ksba_reader_set_mem (ksba_reader_t r,
  523                                const void *buffer, size_t length);
  524 gpg_error_t ksba_reader_set_fd (ksba_reader_t r, int fd);
  525 gpg_error_t ksba_reader_set_file (ksba_reader_t r, FILE *fp);
  526 gpg_error_t ksba_reader_set_cb (ksba_reader_t r,
  527                               int (*cb)(void*,char *,size_t,size_t*),
  528                               void *cb_value );
  529 
  530 gpg_error_t ksba_reader_read (ksba_reader_t r,
  531                             char *buffer, size_t length, size_t *nread);
  532 gpg_error_t ksba_reader_unread (ksba_reader_t r, const void *buffer, size_t count);
  533 unsigned long ksba_reader_tell (ksba_reader_t r);
  534 
  535 /*-- writer.c --*/
  536 gpg_error_t ksba_writer_new (ksba_writer_t *r_w);
  537 void        ksba_writer_release (ksba_writer_t w);
  538 gpg_error_t ksba_writer_set_release_notify (ksba_writer_t w,
  539                                             void (*notify)(void*,ksba_writer_t),
  540                                             void *notify_value);
  541 int         ksba_writer_error (ksba_writer_t w);
  542 unsigned long ksba_writer_tell (ksba_writer_t w);
  543 gpg_error_t ksba_writer_set_fd (ksba_writer_t w, int fd);
  544 gpg_error_t ksba_writer_set_file (ksba_writer_t w, FILE *fp);
  545 gpg_error_t ksba_writer_set_cb (ksba_writer_t w,
  546                                 int (*cb)(void*,const void *,size_t),
  547                                 void *cb_value);
  548 gpg_error_t ksba_writer_set_mem (ksba_writer_t w, size_t initial_size);
  549 const void *ksba_writer_get_mem (ksba_writer_t w, size_t *nbytes);
  550 void *      ksba_writer_snatch_mem (ksba_writer_t w, size_t *nbytes);
  551 gpg_error_t ksba_writer_set_filter (ksba_writer_t w,
  552                                     gpg_error_t (*filter)(void*,
  553                                              const void *,size_t, size_t *,
  554                                              void *, size_t, size_t *),
  555                                     void *filter_arg);
  556 
  557 gpg_error_t ksba_writer_write (ksba_writer_t w, const void *buffer, size_t length);
  558 gpg_error_t ksba_writer_write_octet_string (ksba_writer_t w,
  559                                           const void *buffer, size_t length,
  560                                           int flush);
  561 
  562 /*-- asn1-parse.y --*/
  563 int ksba_asn_parse_file (const char *filename, ksba_asn_tree_t *result,
  564                          int debug);
  565 void ksba_asn_tree_release (ksba_asn_tree_t tree);
  566 
  567 /*-- asn1-func.c --*/
  568 void ksba_asn_tree_dump (ksba_asn_tree_t tree, const char *name, FILE *fp);
  569 gpg_error_t ksba_asn_create_tree (const char *mod_name, ksba_asn_tree_t *result);
  570 
  571 /*-- oid.c --*/
  572 char *ksba_oid_to_str (const char *buffer, size_t length);
  573 gpg_error_t ksba_oid_from_str (const char *string,
  574                                unsigned char **rbuf, size_t *rlength);
  575 
  576 /*-- dn.c --*/
  577 gpg_error_t ksba_dn_der2str (const void *der, size_t derlen, char **r_string);
  578 gpg_error_t ksba_dn_str2der (const char *string,
  579                              unsigned char **rder, size_t *rderlen);
  580 gpg_error_t ksba_dn_teststr (const char *string, int seq,
  581                              size_t *rerroff, size_t *rerrlen);
  582 
  583 
  584 /*-- name.c --*/
  585 gpg_error_t ksba_name_new (ksba_name_t *r_name);
  586 void        ksba_name_ref (ksba_name_t name);
  587 void        ksba_name_release (ksba_name_t name);
  588 const char *ksba_name_enum (ksba_name_t name, int idx);
  589 char       *ksba_name_get_uri (ksba_name_t name, int idx);
  590 
  591 
  592 /*-- der-builder.c --*/
  593 void ksba_der_release (ksba_der_t d);
  594 
  595 ksba_der_t ksba_der_builder_new (unsigned int nitems);
  596 void ksba_der_builder_reset (ksba_der_t d);
  597 
  598 void ksba_der_add_ptr (ksba_der_t d, int cls, int tag,
  599                        void *value, size_t valuelen);
  600 void ksba_der_add_val (ksba_der_t d, int cls, int tag,
  601                        const void *value, size_t valuelen);
  602 void ksba_der_add_int (ksba_der_t d, const void *value, size_t valuelen,
  603                        int force_positive);
  604 void ksba_der_add_oid (ksba_der_t d, const char *oidstr);
  605 void ksba_der_add_bts (ksba_der_t d, const void *value, size_t valuelen,
  606                        unsigned int unusedbits);
  607 void ksba_der_add_der (ksba_der_t d, const void *der, size_t derlen);
  608 void ksba_der_add_tag (ksba_der_t d, int cls, int tag);
  609 void ksba_der_add_end (ksba_der_t d);
  610 
  611 gpg_error_t ksba_der_builder_get (ksba_der_t d,
  612                                   unsigned char **r_obj, size_t *r_objlen);
  613 
  614 
  615 
  616 /*-- util.c --*/
  617 void ksba_set_malloc_hooks ( void *(*new_alloc_func)(size_t n),
  618                              void *(*new_realloc_func)(void *p, size_t n),
  619                              void (*new_free_func)(void*) );
  620 void ksba_set_hash_buffer_function ( gpg_error_t (*fnc)
  621                                      (void *arg, const char *oid,
  622                                       const void *buffer, size_t length,
  623                                       size_t resultsize,
  624                                       unsigned char *result,
  625                                       size_t *resultlen),
  626                                      void *fnc_arg);
  627 void *ksba_malloc (size_t n );
  628 void *ksba_calloc (size_t n, size_t m );
  629 void *ksba_realloc (void *p, size_t n);
  630 char *ksba_strdup (const char *p);
  631 void  ksba_free ( void *a );
  632 
  633 /*--version.c --*/
  634 const char *ksba_check_version (const char *req_version);
  635 
  636 #ifdef __cplusplus
  637 }
  638 #endif
  639 #endif /*KSBA_H*/