Home | History | Annotate | Line # | Download | only in hx509
      1  1.1  christos /*	$NetBSD: hx509-protos.h,v 1.2 2019/12/15 22:50:50 christos Exp $	*/
      2  1.1  christos 
      3  1.1  christos /* This is a generated file */
      4  1.1  christos #ifndef __hx509_protos_h__
      5  1.1  christos #define __hx509_protos_h__
      6  1.1  christos #ifndef DOXY
      7  1.1  christos 
      8  1.1  christos #include <stdarg.h>
      9  1.1  christos 
     10  1.1  christos #ifdef __cplusplus
     11  1.1  christos extern "C" {
     12  1.1  christos #endif
     13  1.1  christos 
     14  1.1  christos #ifndef HX509_LIB
     15  1.1  christos #ifndef HX509_LIB_FUNCTION
     16  1.1  christos #if defined(_WIN32)
     17  1.1  christos #define HX509_LIB_FUNCTION __declspec(dllimport)
     18  1.1  christos #define HX509_LIB_CALL __stdcall
     19  1.1  christos #define HX509_LIB_VARIABLE __declspec(dllimport)
     20  1.1  christos #else
     21  1.1  christos #define HX509_LIB_FUNCTION
     22  1.1  christos #define HX509_LIB_CALL
     23  1.1  christos #define HX509_LIB_VARIABLE
     24  1.1  christos #endif
     25  1.1  christos #endif
     26  1.1  christos #endif
     27  1.1  christos /**
     28  1.1  christos  * Print a bitstring using a hx509_vprint_func function. To print to
     29  1.1  christos  * stdout use hx509_print_stdout().
     30  1.1  christos  *
     31  1.1  christos  * @param b bit string to print.
     32  1.1  christos  * @param func hx509_vprint_func to print with.
     33  1.1  christos  * @param ctx context variable to hx509_vprint_func function.
     34  1.1  christos  *
     35  1.1  christos  * @ingroup hx509_print
     36  1.1  christos  */
     37  1.1  christos 
     38  1.1  christos void
     39  1.1  christos hx509_bitstring_print (
     40  1.1  christos 	const heim_bit_string */*b*/,
     41  1.1  christos 	hx509_vprint_func /*func*/,
     42  1.1  christos 	void */*ctx*/);
     43  1.1  christos 
     44  1.1  christos /**
     45  1.1  christos  * Sign a to-be-signed certificate object with a issuer certificate.
     46  1.1  christos  *
     47  1.1  christos  * The caller needs to at least have called the following functions on the
     48  1.1  christos  * to-be-signed certificate object:
     49  1.1  christos  * - hx509_ca_tbs_init()
     50  1.1  christos  * - hx509_ca_tbs_set_subject()
     51  1.1  christos  * - hx509_ca_tbs_set_spki()
     52  1.1  christos  *
     53  1.1  christos  * When done the to-be-signed certificate object should be freed with
     54  1.1  christos  * hx509_ca_tbs_free().
     55  1.1  christos  *
     56  1.1  christos  * When creating self-signed certificate use hx509_ca_sign_self() instead.
     57  1.1  christos  *
     58  1.1  christos  * @param context A hx509 context.
     59  1.1  christos  * @param tbs object to be signed.
     60  1.1  christos  * @param signer the CA certificate object to sign with (need private key).
     61  1.1  christos  * @param certificate return cerificate, free with hx509_cert_free().
     62  1.1  christos  *
     63  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
     64  1.1  christos  *
     65  1.1  christos  * @ingroup hx509_ca
     66  1.1  christos  */
     67  1.1  christos 
     68  1.1  christos int
     69  1.1  christos hx509_ca_sign (
     70  1.1  christos 	hx509_context /*context*/,
     71  1.1  christos 	hx509_ca_tbs /*tbs*/,
     72  1.1  christos 	hx509_cert /*signer*/,
     73  1.1  christos 	hx509_cert */*certificate*/);
     74  1.1  christos 
     75  1.1  christos /**
     76  1.1  christos  * Work just like hx509_ca_sign() but signs it-self.
     77  1.1  christos  *
     78  1.1  christos  * @param context A hx509 context.
     79  1.1  christos  * @param tbs object to be signed.
     80  1.1  christos  * @param signer private key to sign with.
     81  1.1  christos  * @param certificate return cerificate, free with hx509_cert_free().
     82  1.1  christos  *
     83  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
     84  1.1  christos  *
     85  1.1  christos  * @ingroup hx509_ca
     86  1.1  christos  */
     87  1.1  christos 
     88  1.1  christos int
     89  1.1  christos hx509_ca_sign_self (
     90  1.1  christos 	hx509_context /*context*/,
     91  1.1  christos 	hx509_ca_tbs /*tbs*/,
     92  1.1  christos 	hx509_private_key /*signer*/,
     93  1.1  christos 	hx509_cert */*certificate*/);
     94  1.1  christos 
     95  1.1  christos /**
     96  1.1  christos  * Add CRL distribution point URI to the to-be-signed certificate
     97  1.1  christos  * object.
     98  1.1  christos  *
     99  1.1  christos  * @param context A hx509 context.
    100  1.1  christos  * @param tbs object to be signed.
    101  1.1  christos  * @param uri uri to the CRL.
    102  1.1  christos  * @param issuername name of the issuer.
    103  1.1  christos  *
    104  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    105  1.1  christos  *
    106  1.1  christos  * @ingroup hx509_ca
    107  1.1  christos  */
    108  1.1  christos 
    109  1.1  christos int
    110  1.1  christos hx509_ca_tbs_add_crl_dp_uri (
    111  1.1  christos 	hx509_context /*context*/,
    112  1.1  christos 	hx509_ca_tbs /*tbs*/,
    113  1.1  christos 	const char */*uri*/,
    114  1.1  christos 	hx509_name /*issuername*/);
    115  1.1  christos 
    116  1.1  christos /**
    117  1.1  christos  * An an extended key usage to the to-be-signed certificate object.
    118  1.1  christos  * Duplicates will detected and not added.
    119  1.1  christos  *
    120  1.1  christos  * @param context A hx509 context.
    121  1.1  christos  * @param tbs object to be signed.
    122  1.1  christos  * @param oid extended key usage to add.
    123  1.1  christos  *
    124  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    125  1.1  christos  *
    126  1.1  christos  * @ingroup hx509_ca
    127  1.1  christos  */
    128  1.1  christos 
    129  1.1  christos int
    130  1.1  christos hx509_ca_tbs_add_eku (
    131  1.1  christos 	hx509_context /*context*/,
    132  1.1  christos 	hx509_ca_tbs /*tbs*/,
    133  1.1  christos 	const heim_oid */*oid*/);
    134  1.1  christos 
    135  1.1  christos /**
    136  1.1  christos  * Add a Subject Alternative Name hostname to to-be-signed certificate
    137  1.1  christos  * object. A domain match starts with ., an exact match does not.
    138  1.1  christos  *
    139  1.1  christos  * Example of a an domain match: .domain.se matches the hostname
    140  1.1  christos  * host.domain.se.
    141  1.1  christos  *
    142  1.1  christos  * @param context A hx509 context.
    143  1.1  christos  * @param tbs object to be signed.
    144  1.1  christos  * @param dnsname a hostame.
    145  1.1  christos  *
    146  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    147  1.1  christos  *
    148  1.1  christos  * @ingroup hx509_ca
    149  1.1  christos  */
    150  1.1  christos 
    151  1.1  christos int
    152  1.1  christos hx509_ca_tbs_add_san_hostname (
    153  1.1  christos 	hx509_context /*context*/,
    154  1.1  christos 	hx509_ca_tbs /*tbs*/,
    155  1.1  christos 	const char */*dnsname*/);
    156  1.1  christos 
    157  1.1  christos /**
    158  1.1  christos  * Add a Jabber/XMPP jid Subject Alternative Name to the to-be-signed
    159  1.1  christos  * certificate object. The jid is an UTF8 string.
    160  1.1  christos  *
    161  1.1  christos  * @param context A hx509 context.
    162  1.1  christos  * @param tbs object to be signed.
    163  1.1  christos  * @param jid string of an a jabber id in UTF8.
    164  1.1  christos  *
    165  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    166  1.1  christos  *
    167  1.1  christos  * @ingroup hx509_ca
    168  1.1  christos  */
    169  1.1  christos 
    170  1.1  christos int
    171  1.1  christos hx509_ca_tbs_add_san_jid (
    172  1.1  christos 	hx509_context /*context*/,
    173  1.1  christos 	hx509_ca_tbs /*tbs*/,
    174  1.1  christos 	const char */*jid*/);
    175  1.1  christos 
    176  1.1  christos /**
    177  1.1  christos  * Add Microsoft UPN Subject Alternative Name to the to-be-signed
    178  1.1  christos  * certificate object. The principal string is a UTF8 string.
    179  1.1  christos  *
    180  1.1  christos  * @param context A hx509 context.
    181  1.1  christos  * @param tbs object to be signed.
    182  1.1  christos  * @param principal Microsoft UPN string.
    183  1.1  christos  *
    184  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    185  1.1  christos  *
    186  1.1  christos  * @ingroup hx509_ca
    187  1.1  christos  */
    188  1.1  christos 
    189  1.1  christos int
    190  1.1  christos hx509_ca_tbs_add_san_ms_upn (
    191  1.1  christos 	hx509_context /*context*/,
    192  1.1  christos 	hx509_ca_tbs /*tbs*/,
    193  1.1  christos 	const char */*principal*/);
    194  1.1  christos 
    195  1.1  christos /**
    196  1.1  christos  * Add Subject Alternative Name otherName to the to-be-signed
    197  1.1  christos  * certificate object.
    198  1.1  christos  *
    199  1.1  christos  * @param context A hx509 context.
    200  1.1  christos  * @param tbs object to be signed.
    201  1.1  christos  * @param oid the oid of the OtherName.
    202  1.1  christos  * @param os data in the other name.
    203  1.1  christos  *
    204  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    205  1.1  christos  *
    206  1.1  christos  * @ingroup hx509_ca
    207  1.1  christos  */
    208  1.1  christos 
    209  1.1  christos int
    210  1.1  christos hx509_ca_tbs_add_san_otherName (
    211  1.1  christos 	hx509_context /*context*/,
    212  1.1  christos 	hx509_ca_tbs /*tbs*/,
    213  1.1  christos 	const heim_oid */*oid*/,
    214  1.1  christos 	const heim_octet_string */*os*/);
    215  1.1  christos 
    216  1.1  christos /**
    217  1.1  christos  * Add Kerberos Subject Alternative Name to the to-be-signed
    218  1.1  christos  * certificate object. The principal string is a UTF8 string.
    219  1.1  christos  *
    220  1.1  christos  * @param context A hx509 context.
    221  1.1  christos  * @param tbs object to be signed.
    222  1.1  christos  * @param principal Kerberos principal to add to the certificate.
    223  1.1  christos  *
    224  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    225  1.1  christos  *
    226  1.1  christos  * @ingroup hx509_ca
    227  1.1  christos  */
    228  1.1  christos 
    229  1.1  christos int
    230  1.1  christos hx509_ca_tbs_add_san_pkinit (
    231  1.1  christos 	hx509_context /*context*/,
    232  1.1  christos 	hx509_ca_tbs /*tbs*/,
    233  1.1  christos 	const char */*principal*/);
    234  1.1  christos 
    235  1.1  christos /**
    236  1.1  christos  * Add a Subject Alternative Name rfc822 (email address) to
    237  1.1  christos  * to-be-signed certificate object.
    238  1.1  christos  *
    239  1.1  christos  * @param context A hx509 context.
    240  1.1  christos  * @param tbs object to be signed.
    241  1.1  christos  * @param rfc822Name a string to a email address.
    242  1.1  christos  *
    243  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    244  1.1  christos  *
    245  1.1  christos  * @ingroup hx509_ca
    246  1.1  christos  */
    247  1.1  christos 
    248  1.1  christos int
    249  1.1  christos hx509_ca_tbs_add_san_rfc822name (
    250  1.1  christos 	hx509_context /*context*/,
    251  1.1  christos 	hx509_ca_tbs /*tbs*/,
    252  1.1  christos 	const char */*rfc822Name*/);
    253  1.1  christos 
    254  1.1  christos /**
    255  1.1  christos  * Free an To Be Signed object.
    256  1.1  christos  *
    257  1.1  christos  * @param tbs object to free.
    258  1.1  christos  *
    259  1.1  christos  * @ingroup hx509_ca
    260  1.1  christos  */
    261  1.1  christos 
    262  1.1  christos void
    263  1.1  christos hx509_ca_tbs_free (hx509_ca_tbs */*tbs*/);
    264  1.1  christos 
    265  1.1  christos /**
    266  1.1  christos  * Allocate an to-be-signed certificate object that will be converted
    267  1.1  christos  * into an certificate.
    268  1.1  christos  *
    269  1.1  christos  * @param context A hx509 context.
    270  1.1  christos  * @param tbs returned to-be-signed certicate object, free with
    271  1.1  christos  * hx509_ca_tbs_free().
    272  1.1  christos  *
    273  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    274  1.1  christos  *
    275  1.1  christos  * @ingroup hx509_ca
    276  1.1  christos  */
    277  1.1  christos 
    278  1.1  christos int
    279  1.1  christos hx509_ca_tbs_init (
    280  1.1  christos 	hx509_context /*context*/,
    281  1.1  christos 	hx509_ca_tbs */*tbs*/);
    282  1.1  christos 
    283  1.1  christos /**
    284  1.1  christos  * Make the to-be-signed certificate object a CA certificate. If the
    285  1.1  christos  * pathLenConstraint is negative path length constraint is used.
    286  1.1  christos  *
    287  1.1  christos  * @param context A hx509 context.
    288  1.1  christos  * @param tbs object to be signed.
    289  1.1  christos  * @param pathLenConstraint path length constraint, negative, no
    290  1.1  christos  * constraint.
    291  1.1  christos  *
    292  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    293  1.1  christos  *
    294  1.1  christos  * @ingroup hx509_ca
    295  1.1  christos  */
    296  1.1  christos 
    297  1.1  christos int
    298  1.1  christos hx509_ca_tbs_set_ca (
    299  1.1  christos 	hx509_context /*context*/,
    300  1.1  christos 	hx509_ca_tbs /*tbs*/,
    301  1.1  christos 	int /*pathLenConstraint*/);
    302  1.1  christos 
    303  1.1  christos /**
    304  1.1  christos  * Make the to-be-signed certificate object a windows domain controller certificate.
    305  1.1  christos  *
    306  1.1  christos  * @param context A hx509 context.
    307  1.1  christos  * @param tbs object to be signed.
    308  1.1  christos  *
    309  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    310  1.1  christos  *
    311  1.1  christos  * @ingroup hx509_ca
    312  1.1  christos  */
    313  1.1  christos 
    314  1.1  christos int
    315  1.1  christos hx509_ca_tbs_set_domaincontroller (
    316  1.1  christos 	hx509_context /*context*/,
    317  1.1  christos 	hx509_ca_tbs /*tbs*/);
    318  1.1  christos 
    319  1.1  christos /**
    320  1.1  christos  * Set the absolute time when the certificate is valid to.
    321  1.1  christos  *
    322  1.1  christos  * @param context A hx509 context.
    323  1.1  christos  * @param tbs object to be signed.
    324  1.1  christos  * @param t time when the certificate will expire
    325  1.1  christos  *
    326  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    327  1.1  christos  *
    328  1.1  christos  * @ingroup hx509_ca
    329  1.1  christos  */
    330  1.1  christos 
    331  1.1  christos int
    332  1.1  christos hx509_ca_tbs_set_notAfter (
    333  1.1  christos 	hx509_context /*context*/,
    334  1.1  christos 	hx509_ca_tbs /*tbs*/,
    335  1.1  christos 	time_t /*t*/);
    336  1.1  christos 
    337  1.1  christos /**
    338  1.1  christos  * Set the relative time when the certificiate is going to expire.
    339  1.1  christos  *
    340  1.1  christos  * @param context A hx509 context.
    341  1.1  christos  * @param tbs object to be signed.
    342  1.1  christos  * @param delta seconds to the certificate is going to expire.
    343  1.1  christos  *
    344  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    345  1.1  christos  *
    346  1.1  christos  * @ingroup hx509_ca
    347  1.1  christos  */
    348  1.1  christos 
    349  1.1  christos int
    350  1.1  christos hx509_ca_tbs_set_notAfter_lifetime (
    351  1.1  christos 	hx509_context /*context*/,
    352  1.1  christos 	hx509_ca_tbs /*tbs*/,
    353  1.1  christos 	time_t /*delta*/);
    354  1.1  christos 
    355  1.1  christos /**
    356  1.1  christos  * Set the absolute time when the certificate is valid from. If not
    357  1.1  christos  * set the current time will be used.
    358  1.1  christos  *
    359  1.1  christos  * @param context A hx509 context.
    360  1.1  christos  * @param tbs object to be signed.
    361  1.1  christos  * @param t time the certificated will start to be valid
    362  1.1  christos  *
    363  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    364  1.1  christos  *
    365  1.1  christos  * @ingroup hx509_ca
    366  1.1  christos  */
    367  1.1  christos 
    368  1.1  christos int
    369  1.1  christos hx509_ca_tbs_set_notBefore (
    370  1.1  christos 	hx509_context /*context*/,
    371  1.1  christos 	hx509_ca_tbs /*tbs*/,
    372  1.1  christos 	time_t /*t*/);
    373  1.1  christos 
    374  1.1  christos /**
    375  1.1  christos  * Make the to-be-signed certificate object a proxy certificate. If the
    376  1.1  christos  * pathLenConstraint is negative path length constraint is used.
    377  1.1  christos  *
    378  1.1  christos  * @param context A hx509 context.
    379  1.1  christos  * @param tbs object to be signed.
    380  1.1  christos  * @param pathLenConstraint path length constraint, negative, no
    381  1.1  christos  * constraint.
    382  1.1  christos  *
    383  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    384  1.1  christos  *
    385  1.1  christos  * @ingroup hx509_ca
    386  1.1  christos  */
    387  1.1  christos 
    388  1.1  christos int
    389  1.1  christos hx509_ca_tbs_set_proxy (
    390  1.1  christos 	hx509_context /*context*/,
    391  1.1  christos 	hx509_ca_tbs /*tbs*/,
    392  1.1  christos 	int /*pathLenConstraint*/);
    393  1.1  christos 
    394  1.1  christos /**
    395  1.1  christos  * Set the serial number to use for to-be-signed certificate object.
    396  1.1  christos  *
    397  1.1  christos  * @param context A hx509 context.
    398  1.1  christos  * @param tbs object to be signed.
    399  1.1  christos  * @param serialNumber serial number to use for the to-be-signed
    400  1.1  christos  * certificate object.
    401  1.1  christos  *
    402  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    403  1.1  christos  *
    404  1.1  christos  * @ingroup hx509_ca
    405  1.1  christos  */
    406  1.1  christos 
    407  1.1  christos int
    408  1.1  christos hx509_ca_tbs_set_serialnumber (
    409  1.1  christos 	hx509_context /*context*/,
    410  1.1  christos 	hx509_ca_tbs /*tbs*/,
    411  1.1  christos 	const heim_integer */*serialNumber*/);
    412  1.1  christos 
    413  1.1  christos /**
    414  1.1  christos  * Set signature algorithm on the to be signed certificate
    415  1.1  christos  *
    416  1.1  christos  * @param context A hx509 context.
    417  1.1  christos  * @param tbs object to be signed.
    418  1.1  christos  * @param sigalg signature algorithm to use
    419  1.1  christos  *
    420  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    421  1.1  christos  *
    422  1.1  christos  * @ingroup hx509_ca
    423  1.1  christos  */
    424  1.1  christos 
    425  1.1  christos int
    426  1.1  christos hx509_ca_tbs_set_signature_algorithm (
    427  1.1  christos 	hx509_context /*context*/,
    428  1.1  christos 	hx509_ca_tbs /*tbs*/,
    429  1.1  christos 	const AlgorithmIdentifier */*sigalg*/);
    430  1.1  christos 
    431  1.1  christos /**
    432  1.1  christos  * Set the subject public key info (SPKI) in the to-be-signed certificate
    433  1.1  christos  * object. SPKI is the public key and key related parameters in the
    434  1.1  christos  * certificate.
    435  1.1  christos  *
    436  1.1  christos  * @param context A hx509 context.
    437  1.1  christos  * @param tbs object to be signed.
    438  1.1  christos  * @param spki subject public key info to use for the to-be-signed certificate object.
    439  1.1  christos  *
    440  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    441  1.1  christos  *
    442  1.1  christos  * @ingroup hx509_ca
    443  1.1  christos  */
    444  1.1  christos 
    445  1.1  christos int
    446  1.1  christos hx509_ca_tbs_set_spki (
    447  1.1  christos 	hx509_context /*context*/,
    448  1.1  christos 	hx509_ca_tbs /*tbs*/,
    449  1.1  christos 	const SubjectPublicKeyInfo */*spki*/);
    450  1.1  christos 
    451  1.1  christos /**
    452  1.1  christos  * Set the subject name of a to-be-signed certificate object.
    453  1.1  christos  *
    454  1.1  christos  * @param context A hx509 context.
    455  1.1  christos  * @param tbs object to be signed.
    456  1.1  christos  * @param subject the name to set a subject.
    457  1.1  christos  *
    458  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    459  1.1  christos  *
    460  1.1  christos  * @ingroup hx509_ca
    461  1.1  christos  */
    462  1.1  christos 
    463  1.1  christos int
    464  1.1  christos hx509_ca_tbs_set_subject (
    465  1.1  christos 	hx509_context /*context*/,
    466  1.1  christos 	hx509_ca_tbs /*tbs*/,
    467  1.1  christos 	hx509_name /*subject*/);
    468  1.1  christos 
    469  1.1  christos /**
    470  1.1  christos  * Initialize the to-be-signed certificate object from a template certifiate.
    471  1.1  christos  *
    472  1.1  christos  * @param context A hx509 context.
    473  1.1  christos  * @param tbs object to be signed.
    474  1.1  christos  * @param flags bit field selecting what to copy from the template
    475  1.1  christos  * certifiate.
    476  1.1  christos  * @param cert template certificate.
    477  1.1  christos  *
    478  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    479  1.1  christos  *
    480  1.1  christos  * @ingroup hx509_ca
    481  1.1  christos  */
    482  1.1  christos 
    483  1.1  christos int
    484  1.1  christos hx509_ca_tbs_set_template (
    485  1.1  christos 	hx509_context /*context*/,
    486  1.1  christos 	hx509_ca_tbs /*tbs*/,
    487  1.1  christos 	int /*flags*/,
    488  1.1  christos 	hx509_cert /*cert*/);
    489  1.1  christos 
    490  1.1  christos /**
    491  1.1  christos  * Set the issuerUniqueID and subjectUniqueID
    492  1.1  christos  *
    493  1.1  christos  * These are only supposed to be used considered with version 2
    494  1.1  christos  * certificates, replaced by the two extensions SubjectKeyIdentifier
    495  1.1  christos  * and IssuerKeyIdentifier. This function is to allow application
    496  1.1  christos  * using legacy protocol to issue them.
    497  1.1  christos  *
    498  1.1  christos  * @param context A hx509 context.
    499  1.1  christos  * @param tbs object to be signed.
    500  1.1  christos  * @param issuerUniqueID to be set
    501  1.1  christos  * @param subjectUniqueID to be set
    502  1.1  christos  *
    503  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    504  1.1  christos  *
    505  1.1  christos  * @ingroup hx509_ca
    506  1.1  christos  */
    507  1.1  christos 
    508  1.1  christos int
    509  1.1  christos hx509_ca_tbs_set_unique (
    510  1.1  christos 	hx509_context /*context*/,
    511  1.1  christos 	hx509_ca_tbs /*tbs*/,
    512  1.1  christos 	const heim_bit_string */*subjectUniqueID*/,
    513  1.1  christos 	const heim_bit_string */*issuerUniqueID*/);
    514  1.1  christos 
    515  1.1  christos /**
    516  1.1  christos  * Expand the the subject name in the to-be-signed certificate object
    517  1.1  christos  * using hx509_name_expand().
    518  1.1  christos  *
    519  1.1  christos  * @param context A hx509 context.
    520  1.1  christos  * @param tbs object to be signed.
    521  1.1  christos  * @param env environment variable to expand variables in the subject
    522  1.1  christos  * name, see hx509_env_init().
    523  1.1  christos  *
    524  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    525  1.1  christos  *
    526  1.1  christos  * @ingroup hx509_ca
    527  1.1  christos  */
    528  1.1  christos 
    529  1.1  christos int
    530  1.1  christos hx509_ca_tbs_subject_expand (
    531  1.1  christos 	hx509_context /*context*/,
    532  1.1  christos 	hx509_ca_tbs /*tbs*/,
    533  1.1  christos 	hx509_env /*env*/);
    534  1.1  christos 
    535  1.1  christos /**
    536  1.1  christos  * Make of template units, use to build flags argument to
    537  1.1  christos  * hx509_ca_tbs_set_template() with parse_units().
    538  1.1  christos  *
    539  1.1  christos  * @return an units structure.
    540  1.1  christos  *
    541  1.1  christos  * @ingroup hx509_ca
    542  1.1  christos  */
    543  1.1  christos 
    544  1.1  christos const struct units *
    545  1.1  christos hx509_ca_tbs_template_units (void);
    546  1.1  christos 
    547  1.1  christos /**
    548  1.1  christos  * Encodes the hx509 certificate as a DER encode binary.
    549  1.1  christos  *
    550  1.1  christos  * @param context A hx509 context.
    551  1.1  christos  * @param c the certificate to encode.
    552  1.1  christos  * @param os the encode certificate, set to NULL, 0 on case of
    553  1.1  christos  * error. Free the os->data with hx509_xfree().
    554  1.1  christos  *
    555  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    556  1.1  christos  *
    557  1.1  christos  * @ingroup hx509_cert
    558  1.1  christos  */
    559  1.1  christos 
    560  1.1  christos int
    561  1.1  christos hx509_cert_binary (
    562  1.1  christos 	hx509_context /*context*/,
    563  1.1  christos 	hx509_cert /*c*/,
    564  1.1  christos 	heim_octet_string */*os*/);
    565  1.1  christos 
    566  1.1  christos /**
    567  1.1  christos  * Check the extended key usage on the hx509 certificate.
    568  1.1  christos  *
    569  1.1  christos  * @param context A hx509 context.
    570  1.1  christos  * @param cert A hx509 context.
    571  1.1  christos  * @param eku the EKU to check for
    572  1.1  christos  * @param allow_any_eku if the any EKU is set, allow that to be a
    573  1.1  christos  * substitute.
    574  1.1  christos  *
    575  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    576  1.1  christos  *
    577  1.1  christos  * @ingroup hx509_cert
    578  1.1  christos  */
    579  1.1  christos 
    580  1.1  christos int
    581  1.1  christos hx509_cert_check_eku (
    582  1.1  christos 	hx509_context /*context*/,
    583  1.1  christos 	hx509_cert /*cert*/,
    584  1.1  christos 	const heim_oid */*eku*/,
    585  1.1  christos 	int /*allow_any_eku*/);
    586  1.1  christos 
    587  1.1  christos /**
    588  1.1  christos  * Compare to hx509 certificate object, useful for sorting.
    589  1.1  christos  *
    590  1.1  christos  * @param p a hx509 certificate object.
    591  1.1  christos  * @param q a hx509 certificate object.
    592  1.1  christos  *
    593  1.1  christos  * @return 0 the objects are the same, returns > 0 is p is "larger"
    594  1.1  christos  * then q, < 0 if p is "smaller" then q.
    595  1.1  christos  *
    596  1.1  christos  * @ingroup hx509_cert
    597  1.1  christos  */
    598  1.1  christos 
    599  1.1  christos int
    600  1.1  christos hx509_cert_cmp (
    601  1.1  christos 	hx509_cert /*p*/,
    602  1.1  christos 	hx509_cert /*q*/);
    603  1.1  christos 
    604  1.1  christos /**
    605  1.1  christos  * Return a list of subjectAltNames specified by oid in the
    606  1.1  christos  * certificate. On error the
    607  1.1  christos  *
    608  1.1  christos  * The returned list of octet string should be freed with
    609  1.1  christos  * hx509_free_octet_string_list().
    610  1.1  christos  *
    611  1.1  christos  * @param context A hx509 context.
    612  1.1  christos  * @param cert a hx509 certificate object.
    613  1.1  christos  * @param oid an oid to for SubjectAltName.
    614  1.1  christos  * @param list list of matching SubjectAltName.
    615  1.1  christos  *
    616  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    617  1.1  christos  *
    618  1.1  christos  * @ingroup hx509_cert
    619  1.1  christos  */
    620  1.1  christos 
    621  1.1  christos int
    622  1.1  christos hx509_cert_find_subjectAltName_otherName (
    623  1.1  christos 	hx509_context /*context*/,
    624  1.1  christos 	hx509_cert /*cert*/,
    625  1.1  christos 	const heim_oid */*oid*/,
    626  1.1  christos 	hx509_octet_string_list */*list*/);
    627  1.1  christos 
    628  1.1  christos /**
    629  1.1  christos  * Free reference to the hx509 certificate object, if the refcounter
    630  1.1  christos  * reaches 0, the object if freed. Its allowed to pass in NULL.
    631  1.1  christos  *
    632  1.1  christos  * @param cert the cert to free.
    633  1.1  christos  *
    634  1.1  christos  * @ingroup hx509_cert
    635  1.1  christos  */
    636  1.1  christos 
    637  1.1  christos void
    638  1.1  christos hx509_cert_free (hx509_cert /*cert*/);
    639  1.1  christos 
    640  1.1  christos /**
    641  1.1  christos  * Get the SubjectPublicKeyInfo structure from the hx509 certificate.
    642  1.1  christos  *
    643  1.1  christos  * @param context a hx509 context.
    644  1.1  christos  * @param p a hx509 certificate object.
    645  1.1  christos  * @param spki SubjectPublicKeyInfo, should be freed with
    646  1.1  christos  * free_SubjectPublicKeyInfo().
    647  1.1  christos  *
    648  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    649  1.1  christos  *
    650  1.1  christos  * @ingroup hx509_cert
    651  1.1  christos  */
    652  1.1  christos 
    653  1.1  christos int
    654  1.1  christos hx509_cert_get_SPKI (
    655  1.1  christos 	hx509_context /*context*/,
    656  1.1  christos 	hx509_cert /*p*/,
    657  1.1  christos 	SubjectPublicKeyInfo */*spki*/);
    658  1.1  christos 
    659  1.1  christos /**
    660  1.1  christos  * Get the AlgorithmIdentifier from the hx509 certificate.
    661  1.1  christos  *
    662  1.1  christos  * @param context a hx509 context.
    663  1.1  christos  * @param p a hx509 certificate object.
    664  1.1  christos  * @param alg AlgorithmIdentifier, should be freed with
    665  1.1  christos  *            free_AlgorithmIdentifier(). The algorithmidentifier is
    666  1.1  christos  *            typicly rsaEncryption, or id-ecPublicKey, or some other
    667  1.1  christos  *            public key mechanism.
    668  1.1  christos  *
    669  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    670  1.1  christos  *
    671  1.1  christos  * @ingroup hx509_cert
    672  1.1  christos  */
    673  1.1  christos 
    674  1.1  christos int
    675  1.1  christos hx509_cert_get_SPKI_AlgorithmIdentifier (
    676  1.1  christos 	hx509_context /*context*/,
    677  1.1  christos 	hx509_cert /*p*/,
    678  1.1  christos 	AlgorithmIdentifier */*alg*/);
    679  1.1  christos 
    680  1.1  christos /**
    681  1.1  christos  * Get an external attribute for the certificate, examples are
    682  1.1  christos  * friendly name and id.
    683  1.1  christos  *
    684  1.1  christos  * @param cert hx509 certificate object to search
    685  1.1  christos  * @param oid an oid to search for.
    686  1.1  christos  *
    687  1.1  christos  * @return an hx509_cert_attribute, only valid as long as the
    688  1.1  christos  * certificate is referenced.
    689  1.1  christos  *
    690  1.1  christos  * @ingroup hx509_cert
    691  1.1  christos  */
    692  1.1  christos 
    693  1.1  christos hx509_cert_attribute
    694  1.1  christos hx509_cert_get_attribute (
    695  1.1  christos 	hx509_cert /*cert*/,
    696  1.1  christos 	const heim_oid */*oid*/);
    697  1.1  christos 
    698  1.1  christos /**
    699  1.1  christos  * Return the name of the base subject of the hx509 certificate. If
    700  1.1  christos  * the certiicate is a verified proxy certificate, the this function
    701  1.1  christos  * return the base certificate (root of the proxy chain). If the proxy
    702  1.1  christos  * certificate is not verified with the base certificate
    703  1.1  christos  * HX509_PROXY_CERTIFICATE_NOT_CANONICALIZED is returned.
    704  1.1  christos  *
    705  1.1  christos  * @param context a hx509 context.
    706  1.1  christos  * @param c a hx509 certificate object.
    707  1.1  christos  * @param name a pointer to a hx509 name, should be freed by
    708  1.1  christos  * hx509_name_free(). See also hx509_cert_get_subject().
    709  1.1  christos  *
    710  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    711  1.1  christos  *
    712  1.1  christos  * @ingroup hx509_cert
    713  1.1  christos  */
    714  1.1  christos 
    715  1.1  christos int
    716  1.1  christos hx509_cert_get_base_subject (
    717  1.1  christos 	hx509_context /*context*/,
    718  1.1  christos 	hx509_cert /*c*/,
    719  1.1  christos 	hx509_name */*name*/);
    720  1.1  christos 
    721  1.1  christos /**
    722  1.1  christos  * Get friendly name of the certificate.
    723  1.1  christos  *
    724  1.1  christos  * @param cert cert to get the friendly name from.
    725  1.1  christos  *
    726  1.1  christos  * @return an friendly name or NULL if there is. The friendly name is
    727  1.1  christos  * only valid as long as the certificate is referenced.
    728  1.1  christos  *
    729  1.1  christos  * @ingroup hx509_cert
    730  1.1  christos  */
    731  1.1  christos 
    732  1.1  christos const char *
    733  1.1  christos hx509_cert_get_friendly_name (hx509_cert /*cert*/);
    734  1.1  christos 
    735  1.1  christos /**
    736  1.1  christos  * Return the name of the issuer of the hx509 certificate.
    737  1.1  christos  *
    738  1.1  christos  * @param p a hx509 certificate object.
    739  1.1  christos  * @param name a pointer to a hx509 name, should be freed by
    740  1.1  christos  * hx509_name_free().
    741  1.1  christos  *
    742  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    743  1.1  christos  *
    744  1.1  christos  * @ingroup hx509_cert
    745  1.1  christos  */
    746  1.1  christos 
    747  1.1  christos int
    748  1.1  christos hx509_cert_get_issuer (
    749  1.1  christos 	hx509_cert /*p*/,
    750  1.1  christos 	hx509_name */*name*/);
    751  1.1  christos 
    752  1.1  christos /**
    753  1.1  christos  * Get a copy of the Issuer Unique ID
    754  1.1  christos  *
    755  1.1  christos  * @param context a hx509_context
    756  1.1  christos  * @param p a hx509 certificate
    757  1.1  christos  * @param issuer the issuer id returned, free with der_free_bit_string()
    758  1.1  christos  *
    759  1.1  christos  * @return An hx509 error code, see hx509_get_error_string(). The
    760  1.1  christos  * error code HX509_EXTENSION_NOT_FOUND is returned if the certificate
    761  1.1  christos  * doesn't have a issuerUniqueID
    762  1.1  christos  *
    763  1.1  christos  * @ingroup hx509_cert
    764  1.1  christos  */
    765  1.1  christos 
    766  1.1  christos int
    767  1.1  christos hx509_cert_get_issuer_unique_id (
    768  1.1  christos 	hx509_context /*context*/,
    769  1.1  christos 	hx509_cert /*p*/,
    770  1.1  christos 	heim_bit_string */*issuer*/);
    771  1.1  christos 
    772  1.1  christos /**
    773  1.1  christos  * Get notAfter time of the certificate.
    774  1.1  christos  *
    775  1.1  christos  * @param p a hx509 certificate object.
    776  1.1  christos  *
    777  1.1  christos  * @return return not after time.
    778  1.1  christos  *
    779  1.1  christos  * @ingroup hx509_cert
    780  1.1  christos  */
    781  1.1  christos 
    782  1.1  christos time_t
    783  1.1  christos hx509_cert_get_notAfter (hx509_cert /*p*/);
    784  1.1  christos 
    785  1.1  christos /**
    786  1.1  christos  * Get notBefore time of the certificate.
    787  1.1  christos  *
    788  1.1  christos  * @param p a hx509 certificate object.
    789  1.1  christos  *
    790  1.1  christos  * @return return not before time
    791  1.1  christos  *
    792  1.1  christos  * @ingroup hx509_cert
    793  1.1  christos  */
    794  1.1  christos 
    795  1.1  christos time_t
    796  1.1  christos hx509_cert_get_notBefore (hx509_cert /*p*/);
    797  1.1  christos 
    798  1.1  christos /**
    799  1.1  christos  * Get serial number of the certificate.
    800  1.1  christos  *
    801  1.1  christos  * @param p a hx509 certificate object.
    802  1.1  christos  * @param i serial number, should be freed ith der_free_heim_integer().
    803  1.1  christos  *
    804  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    805  1.1  christos  *
    806  1.1  christos  * @ingroup hx509_cert
    807  1.1  christos  */
    808  1.1  christos 
    809  1.1  christos int
    810  1.1  christos hx509_cert_get_serialnumber (
    811  1.1  christos 	hx509_cert /*p*/,
    812  1.1  christos 	heim_integer */*i*/);
    813  1.1  christos 
    814  1.1  christos /**
    815  1.1  christos  * Return the name of the subject of the hx509 certificate.
    816  1.1  christos  *
    817  1.1  christos  * @param p a hx509 certificate object.
    818  1.1  christos  * @param name a pointer to a hx509 name, should be freed by
    819  1.1  christos  * hx509_name_free(). See also hx509_cert_get_base_subject().
    820  1.1  christos  *
    821  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    822  1.1  christos  *
    823  1.1  christos  * @ingroup hx509_cert
    824  1.1  christos  */
    825  1.1  christos 
    826  1.1  christos int
    827  1.1  christos hx509_cert_get_subject (
    828  1.1  christos 	hx509_cert /*p*/,
    829  1.1  christos 	hx509_name */*name*/);
    830  1.1  christos 
    831  1.1  christos /**
    832  1.1  christos  * Get a copy of the Subect Unique ID
    833  1.1  christos  *
    834  1.1  christos  * @param context a hx509_context
    835  1.1  christos  * @param p a hx509 certificate
    836  1.1  christos  * @param subject the subject id returned, free with der_free_bit_string()
    837  1.1  christos  *
    838  1.1  christos  * @return An hx509 error code, see hx509_get_error_string(). The
    839  1.1  christos  * error code HX509_EXTENSION_NOT_FOUND is returned if the certificate
    840  1.1  christos  * doesn't have a subjectUniqueID
    841  1.1  christos  *
    842  1.1  christos  * @ingroup hx509_cert
    843  1.1  christos  */
    844  1.1  christos 
    845  1.1  christos int
    846  1.1  christos hx509_cert_get_subject_unique_id (
    847  1.1  christos 	hx509_context /*context*/,
    848  1.1  christos 	hx509_cert /*p*/,
    849  1.1  christos 	heim_bit_string */*subject*/);
    850  1.1  christos 
    851  1.1  christos int
    852  1.1  christos hx509_cert_have_private_key (hx509_cert /*p*/);
    853  1.1  christos 
    854  1.1  christos /**
    855  1.1  christos  * Allocate and init an hx509 certificate object from the decoded
    856  1.1  christos  * certificate `c.
    857  1.1  christos  *
    858  1.1  christos  * @param context A hx509 context.
    859  1.1  christos  * @param c
    860  1.1  christos  * @param error
    861  1.1  christos  *
    862  1.1  christos  * @return Returns an hx509 certificate
    863  1.1  christos  *
    864  1.1  christos  * @ingroup hx509_cert
    865  1.1  christos  */
    866  1.1  christos 
    867  1.1  christos hx509_cert
    868  1.1  christos hx509_cert_init (
    869  1.1  christos 	hx509_context /*context*/,
    870  1.1  christos 	const Certificate */*c*/,
    871  1.1  christos 	heim_error_t */*error*/);
    872  1.1  christos 
    873  1.1  christos /**
    874  1.1  christos  * Just like hx509_cert_init(), but instead of a decode certificate
    875  1.1  christos  * takes an pointer and length to a memory region that contains a
    876  1.1  christos  * DER/BER encoded certificate.
    877  1.1  christos  *
    878  1.1  christos  * If the memory region doesn't contain just the certificate and
    879  1.1  christos  * nothing more the function will fail with
    880  1.1  christos  * HX509_EXTRA_DATA_AFTER_STRUCTURE.
    881  1.1  christos  *
    882  1.1  christos  * @param context A hx509 context.
    883  1.1  christos  * @param ptr pointer to memory region containing encoded certificate.
    884  1.1  christos  * @param len length of memory region.
    885  1.1  christos  * @param error possibly returns an error
    886  1.1  christos  *
    887  1.1  christos  * @return An hx509 certificate
    888  1.1  christos  *
    889  1.1  christos  * @ingroup hx509_cert
    890  1.1  christos  */
    891  1.1  christos 
    892  1.1  christos hx509_cert
    893  1.1  christos hx509_cert_init_data (
    894  1.1  christos 	hx509_context /*context*/,
    895  1.1  christos 	const void */*ptr*/,
    896  1.1  christos 	size_t /*len*/,
    897  1.1  christos 	heim_error_t */*error*/);
    898  1.1  christos 
    899  1.1  christos /**
    900  1.1  christos  * Print certificate usage for a certificate to a string.
    901  1.1  christos  *
    902  1.1  christos  * @param context A hx509 context.
    903  1.1  christos  * @param c a certificate print the keyusage for.
    904  1.1  christos  * @param s the return string with the keysage printed in to, free
    905  1.1  christos  * with hx509_xfree().
    906  1.1  christos  *
    907  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    908  1.1  christos  *
    909  1.1  christos  * @ingroup hx509_print
    910  1.1  christos  */
    911  1.1  christos 
    912  1.1  christos int
    913  1.1  christos hx509_cert_keyusage_print (
    914  1.1  christos 	hx509_context /*context*/,
    915  1.1  christos 	hx509_cert /*c*/,
    916  1.1  christos 	char **/*s*/);
    917  1.1  christos 
    918  1.1  christos int
    919  1.1  christos hx509_cert_public_encrypt (
    920  1.1  christos 	hx509_context /*context*/,
    921  1.1  christos 	const heim_octet_string */*cleartext*/,
    922  1.1  christos 	const hx509_cert /*p*/,
    923  1.1  christos 	heim_oid */*encryption_oid*/,
    924  1.1  christos 	heim_octet_string */*ciphertext*/);
    925  1.1  christos 
    926  1.1  christos /**
    927  1.1  christos  * Add a reference to a hx509 certificate object.
    928  1.1  christos  *
    929  1.1  christos  * @param cert a pointer to an hx509 certificate object.
    930  1.1  christos  *
    931  1.1  christos  * @return the same object as is passed in.
    932  1.1  christos  *
    933  1.1  christos  * @ingroup hx509_cert
    934  1.1  christos  */
    935  1.1  christos 
    936  1.1  christos hx509_cert
    937  1.1  christos hx509_cert_ref (hx509_cert /*cert*/);
    938  1.1  christos 
    939  1.1  christos /**
    940  1.1  christos  * Set the friendly name on the certificate.
    941  1.1  christos  *
    942  1.1  christos  * @param cert The certificate to set the friendly name on
    943  1.1  christos  * @param name Friendly name.
    944  1.1  christos  *
    945  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
    946  1.1  christos  *
    947  1.1  christos  * @ingroup hx509_cert
    948  1.1  christos  */
    949  1.1  christos 
    950  1.1  christos int
    951  1.1  christos hx509_cert_set_friendly_name (
    952  1.1  christos 	hx509_cert /*cert*/,
    953  1.1  christos 	const char */*name*/);
    954  1.1  christos 
    955  1.1  christos /**
    956  1.1  christos  * Add a certificate to the certificiate store.
    957  1.1  christos  *
    958  1.1  christos  * The receiving keyset certs will either increase reference counter
    959  1.1  christos  * of the cert or make a deep copy, either way, the caller needs to
    960  1.1  christos  * free the cert itself.
    961  1.1  christos  *
    962  1.1  christos  * @param context a hx509 context.
    963  1.1  christos  * @param certs certificate store to add the certificate to.
    964  1.1  christos  * @param cert certificate to add.
    965  1.1  christos  *
    966  1.1  christos  * @return Returns an hx509 error code.
    967  1.1  christos  *
    968  1.1  christos  * @ingroup hx509_keyset
    969  1.1  christos  */
    970  1.1  christos 
    971  1.1  christos int
    972  1.1  christos hx509_certs_add (
    973  1.1  christos 	hx509_context /*context*/,
    974  1.1  christos 	hx509_certs /*certs*/,
    975  1.1  christos 	hx509_cert /*cert*/);
    976  1.1  christos 
    977  1.1  christos /**
    978  1.1  christos  * Same a hx509_certs_merge() but use a lock and name to describe the
    979  1.1  christos  * from source.
    980  1.1  christos  *
    981  1.1  christos  * @param context a hx509 context.
    982  1.1  christos  * @param to the store to merge into.
    983  1.1  christos  * @param lock a lock that unlocks the certificates store, use NULL to
    984  1.1  christos  * select no password/certifictes/prompt lock (see @ref page_lock).
    985  1.1  christos  * @param name name of the source store
    986  1.1  christos  *
    987  1.1  christos  * @return Returns an hx509 error code.
    988  1.1  christos  *
    989  1.1  christos  * @ingroup hx509_keyset
    990  1.1  christos  */
    991  1.1  christos 
    992  1.1  christos int
    993  1.1  christos hx509_certs_append (
    994  1.1  christos 	hx509_context /*context*/,
    995  1.1  christos 	hx509_certs /*to*/,
    996  1.1  christos 	hx509_lock /*lock*/,
    997  1.1  christos 	const char */*name*/);
    998  1.1  christos 
    999  1.1  christos /**
   1000  1.1  christos  * End the iteration over certificates.
   1001  1.1  christos  *
   1002  1.1  christos  * @param context a hx509 context.
   1003  1.1  christos  * @param certs certificate store to iterate over.
   1004  1.1  christos  * @param cursor cursor that will keep track of progress, freed.
   1005  1.1  christos  *
   1006  1.1  christos  * @return Returns an hx509 error code.
   1007  1.1  christos  *
   1008  1.1  christos  * @ingroup hx509_keyset
   1009  1.1  christos  */
   1010  1.1  christos 
   1011  1.1  christos int
   1012  1.1  christos hx509_certs_end_seq (
   1013  1.1  christos 	hx509_context /*context*/,
   1014  1.1  christos 	hx509_certs /*certs*/,
   1015  1.1  christos 	hx509_cursor /*cursor*/);
   1016  1.1  christos 
   1017  1.1  christos /**
   1018  1.1  christos  * Filter certificate matching the query.
   1019  1.1  christos  *
   1020  1.1  christos  * @param context a hx509 context.
   1021  1.1  christos  * @param certs certificate store to search.
   1022  1.1  christos  * @param q query allocated with @ref hx509_query functions.
   1023  1.1  christos  * @param result the filtered certificate store, caller must free with
   1024  1.1  christos  *        hx509_certs_free().
   1025  1.1  christos  *
   1026  1.1  christos  * @return Returns an hx509 error code.
   1027  1.1  christos  *
   1028  1.1  christos  * @ingroup hx509_keyset
   1029  1.1  christos  */
   1030  1.1  christos 
   1031  1.1  christos int
   1032  1.1  christos hx509_certs_filter (
   1033  1.1  christos 	hx509_context /*context*/,
   1034  1.1  christos 	hx509_certs /*certs*/,
   1035  1.1  christos 	const hx509_query */*q*/,
   1036  1.1  christos 	hx509_certs */*result*/);
   1037  1.1  christos 
   1038  1.1  christos /**
   1039  1.1  christos  * Find a certificate matching the query.
   1040  1.1  christos  *
   1041  1.1  christos  * @param context a hx509 context.
   1042  1.1  christos  * @param certs certificate store to search.
   1043  1.1  christos  * @param q query allocated with @ref hx509_query functions.
   1044  1.1  christos  * @param r return certificate (or NULL on error), should be freed
   1045  1.1  christos  * with hx509_cert_free().
   1046  1.1  christos  *
   1047  1.1  christos  * @return Returns an hx509 error code.
   1048  1.1  christos  *
   1049  1.1  christos  * @ingroup hx509_keyset
   1050  1.1  christos  */
   1051  1.1  christos 
   1052  1.1  christos int
   1053  1.1  christos hx509_certs_find (
   1054  1.1  christos 	hx509_context /*context*/,
   1055  1.1  christos 	hx509_certs /*certs*/,
   1056  1.1  christos 	const hx509_query */*q*/,
   1057  1.1  christos 	hx509_cert */*r*/);
   1058  1.1  christos 
   1059  1.1  christos /**
   1060  1.1  christos  * Free a certificate store.
   1061  1.1  christos  *
   1062  1.1  christos  * @param certs certificate store to free.
   1063  1.1  christos  *
   1064  1.1  christos  * @ingroup hx509_keyset
   1065  1.1  christos  */
   1066  1.1  christos 
   1067  1.1  christos void
   1068  1.1  christos hx509_certs_free (hx509_certs */*certs*/);
   1069  1.1  christos 
   1070  1.1  christos /**
   1071  1.1  christos  * Print some info about the certificate store.
   1072  1.1  christos  *
   1073  1.1  christos  * @param context a hx509 context.
   1074  1.1  christos  * @param certs certificate store to print information about.
   1075  1.1  christos  * @param func function that will get each line of the information, if
   1076  1.1  christos  * NULL is used the data is printed on a FILE descriptor that should
   1077  1.1  christos  * be passed in ctx, if ctx also is NULL, stdout is used.
   1078  1.1  christos  * @param ctx parameter to func.
   1079  1.1  christos  *
   1080  1.1  christos  * @return Returns an hx509 error code.
   1081  1.1  christos  *
   1082  1.1  christos  * @ingroup hx509_keyset
   1083  1.1  christos  */
   1084  1.1  christos 
   1085  1.1  christos int
   1086  1.1  christos hx509_certs_info (
   1087  1.1  christos 	hx509_context /*context*/,
   1088  1.1  christos 	hx509_certs /*certs*/,
   1089  1.1  christos 	int (*/*func*/)(void *, const char *),
   1090  1.1  christos 	void */*ctx*/);
   1091  1.1  christos 
   1092  1.1  christos /**
   1093  1.1  christos  * Open or creates a new hx509 certificate store.
   1094  1.1  christos  *
   1095  1.1  christos  * @param context A hx509 context
   1096  1.1  christos  * @param name name of the store, format is TYPE:type-specific-string,
   1097  1.1  christos  * if NULL is used the MEMORY store is used.
   1098  1.1  christos  * @param flags list of flags:
   1099  1.1  christos  * - HX509_CERTS_CREATE create a new keystore of the specific TYPE.
   1100  1.1  christos  * - HX509_CERTS_UNPROTECT_ALL fails if any private key failed to be extracted.
   1101  1.1  christos  * @param lock a lock that unlocks the certificates store, use NULL to
   1102  1.1  christos  * select no password/certifictes/prompt lock (see @ref page_lock).
   1103  1.1  christos  * @param certs return pointer, free with hx509_certs_free().
   1104  1.1  christos  *
   1105  1.1  christos  * @return Returns an hx509 error code.
   1106  1.1  christos  *
   1107  1.1  christos  * @ingroup hx509_keyset
   1108  1.1  christos  */
   1109  1.1  christos 
   1110  1.1  christos int
   1111  1.1  christos hx509_certs_init (
   1112  1.1  christos 	hx509_context /*context*/,
   1113  1.1  christos 	const char */*name*/,
   1114  1.1  christos 	int /*flags*/,
   1115  1.1  christos 	hx509_lock /*lock*/,
   1116  1.1  christos 	hx509_certs */*certs*/);
   1117  1.1  christos 
   1118  1.1  christos /**
   1119  1.1  christos  * Iterate over all certificates in a keystore and call a block
   1120  1.1  christos  * for each of them.
   1121  1.1  christos  *
   1122  1.1  christos  * @param context a hx509 context.
   1123  1.1  christos  * @param certs certificate store to iterate over.
   1124  1.1  christos  * @param func block to call for each certificate. The function
   1125  1.1  christos  * should return non-zero to abort the iteration, that value is passed
   1126  1.1  christos  * back to the caller of hx509_certs_iter().
   1127  1.1  christos  *
   1128  1.1  christos  * @return Returns an hx509 error code.
   1129  1.1  christos  *
   1130  1.1  christos  * @ingroup hx509_keyset
   1131  1.1  christos  */
   1132  1.1  christos 
   1133  1.1  christos #ifdef __BLOCKS__
   1134  1.1  christos int
   1135  1.1  christos hx509_certs_iter (
   1136  1.1  christos 	hx509_context /*context*/,
   1137  1.1  christos 	hx509_certs /*certs*/,
   1138  1.1  christos 	int (^func)(hx509_cert));
   1139  1.1  christos #endif /* __BLOCKS__ */
   1140  1.1  christos 
   1141  1.1  christos /**
   1142  1.1  christos  * Iterate over all certificates in a keystore and call a function
   1143  1.1  christos  * for each of them.
   1144  1.1  christos  *
   1145  1.1  christos  * @param context a hx509 context.
   1146  1.1  christos  * @param certs certificate store to iterate over.
   1147  1.1  christos  * @param func function to call for each certificate. The function
   1148  1.1  christos  * should return non-zero to abort the iteration, that value is passed
   1149  1.1  christos  * back to the caller of hx509_certs_iter_f().
   1150  1.1  christos  * @param ctx context variable that will passed to the function.
   1151  1.1  christos  *
   1152  1.1  christos  * @return Returns an hx509 error code.
   1153  1.1  christos  *
   1154  1.1  christos  * @ingroup hx509_keyset
   1155  1.1  christos  */
   1156  1.1  christos 
   1157  1.1  christos int
   1158  1.1  christos hx509_certs_iter_f (
   1159  1.1  christos 	hx509_context /*context*/,
   1160  1.1  christos 	hx509_certs /*certs*/,
   1161  1.1  christos 	int (*/*func*/)(hx509_context, void *, hx509_cert),
   1162  1.1  christos 	void */*ctx*/);
   1163  1.1  christos 
   1164  1.1  christos /**
   1165  1.1  christos  * Merge a certificate store into another. The from store is keep
   1166  1.1  christos  * intact.
   1167  1.1  christos  *
   1168  1.1  christos  * @param context a hx509 context.
   1169  1.1  christos  * @param to the store to merge into.
   1170  1.1  christos  * @param from the store to copy the object from.
   1171  1.1  christos  *
   1172  1.1  christos  * @return Returns an hx509 error code.
   1173  1.1  christos  *
   1174  1.1  christos  * @ingroup hx509_keyset
   1175  1.1  christos  */
   1176  1.1  christos 
   1177  1.1  christos int
   1178  1.1  christos hx509_certs_merge (
   1179  1.1  christos 	hx509_context /*context*/,
   1180  1.1  christos 	hx509_certs /*to*/,
   1181  1.1  christos 	hx509_certs /*from*/);
   1182  1.1  christos 
   1183  1.1  christos /**
   1184  1.1  christos  * Get next ceritificate from the certificate keystore pointed out by
   1185  1.1  christos  * cursor.
   1186  1.1  christos  *
   1187  1.1  christos  * @param context a hx509 context.
   1188  1.1  christos  * @param certs certificate store to iterate over.
   1189  1.1  christos  * @param cursor cursor that keeps track of progress.
   1190  1.1  christos  * @param cert return certificate next in store, NULL if the store
   1191  1.1  christos  * contains no more certificates. Free with hx509_cert_free().
   1192  1.1  christos  *
   1193  1.1  christos  * @return Returns an hx509 error code.
   1194  1.1  christos  *
   1195  1.1  christos  * @ingroup hx509_keyset
   1196  1.1  christos  */
   1197  1.1  christos 
   1198  1.1  christos int
   1199  1.1  christos hx509_certs_next_cert (
   1200  1.1  christos 	hx509_context /*context*/,
   1201  1.1  christos 	hx509_certs /*certs*/,
   1202  1.1  christos 	hx509_cursor /*cursor*/,
   1203  1.1  christos 	hx509_cert */*cert*/);
   1204  1.1  christos 
   1205  1.1  christos hx509_certs
   1206  1.1  christos hx509_certs_ref (hx509_certs /*certs*/);
   1207  1.1  christos 
   1208  1.1  christos /**
   1209  1.1  christos  * Start the integration
   1210  1.1  christos  *
   1211  1.1  christos  * @param context a hx509 context.
   1212  1.1  christos  * @param certs certificate store to iterate over
   1213  1.1  christos  * @param cursor cursor that will keep track of progress, free with
   1214  1.1  christos  * hx509_certs_end_seq().
   1215  1.1  christos  *
   1216  1.1  christos  * @return Returns an hx509 error code. HX509_UNSUPPORTED_OPERATION is
   1217  1.1  christos  * returned if the certificate store doesn't support the iteration
   1218  1.1  christos  * operation.
   1219  1.1  christos  *
   1220  1.1  christos  * @ingroup hx509_keyset
   1221  1.1  christos  */
   1222  1.1  christos 
   1223  1.1  christos int
   1224  1.1  christos hx509_certs_start_seq (
   1225  1.1  christos 	hx509_context /*context*/,
   1226  1.1  christos 	hx509_certs /*certs*/,
   1227  1.1  christos 	hx509_cursor */*cursor*/);
   1228  1.1  christos 
   1229  1.1  christos /**
   1230  1.1  christos  * Write the certificate store to stable storage.
   1231  1.1  christos  *
   1232  1.1  christos  * @param context A hx509 context.
   1233  1.1  christos  * @param certs a certificate store to store.
   1234  1.1  christos  * @param flags currently unused, use 0.
   1235  1.1  christos  * @param lock a lock that unlocks the certificates store, use NULL to
   1236  1.1  christos  * select no password/certifictes/prompt lock (see @ref page_lock).
   1237  1.1  christos  *
   1238  1.1  christos  * @return Returns an hx509 error code. HX509_UNSUPPORTED_OPERATION if
   1239  1.1  christos  * the certificate store doesn't support the store operation.
   1240  1.1  christos  *
   1241  1.1  christos  * @ingroup hx509_keyset
   1242  1.1  christos  */
   1243  1.1  christos 
   1244  1.1  christos int
   1245  1.1  christos hx509_certs_store (
   1246  1.1  christos 	hx509_context /*context*/,
   1247  1.1  christos 	hx509_certs /*certs*/,
   1248  1.1  christos 	int /*flags*/,
   1249  1.1  christos 	hx509_lock /*lock*/);
   1250  1.1  christos 
   1251  1.1  christos /**
   1252  1.1  christos  * Function to use to hx509_certs_iter_f() as a function argument, the
   1253  1.1  christos  * ctx variable to hx509_certs_iter_f() should be a FILE file descriptor.
   1254  1.1  christos  *
   1255  1.1  christos  * @param context a hx509 context.
   1256  1.1  christos  * @param ctx used by hx509_certs_iter_f().
   1257  1.1  christos  * @param c a certificate
   1258  1.1  christos  *
   1259  1.1  christos  * @return Returns an hx509 error code.
   1260  1.1  christos  *
   1261  1.1  christos  * @ingroup hx509_keyset
   1262  1.1  christos  */
   1263  1.1  christos 
   1264  1.1  christos int
   1265  1.1  christos hx509_ci_print_names (
   1266  1.1  christos 	hx509_context /*context*/,
   1267  1.1  christos 	void */*ctx*/,
   1268  1.1  christos 	hx509_cert /*c*/);
   1269  1.1  christos 
   1270  1.1  christos /**
   1271  1.1  christos  * Resets the error strings the hx509 context.
   1272  1.1  christos  *
   1273  1.1  christos  * @param context A hx509 context.
   1274  1.1  christos  *
   1275  1.1  christos  * @ingroup hx509_error
   1276  1.1  christos  */
   1277  1.1  christos 
   1278  1.1  christos void
   1279  1.1  christos hx509_clear_error_string (hx509_context /*context*/);
   1280  1.1  christos 
   1281  1.1  christos int
   1282  1.1  christos hx509_cms_create_signed (
   1283  1.1  christos 	hx509_context /*context*/,
   1284  1.1  christos 	int /*flags*/,
   1285  1.1  christos 	const heim_oid */*eContentType*/,
   1286  1.1  christos 	const void */*data*/,
   1287  1.1  christos 	size_t /*length*/,
   1288  1.1  christos 	const AlgorithmIdentifier */*digest_alg*/,
   1289  1.1  christos 	hx509_certs /*certs*/,
   1290  1.1  christos 	hx509_peer_info /*peer*/,
   1291  1.1  christos 	hx509_certs /*anchors*/,
   1292  1.1  christos 	hx509_certs /*pool*/,
   1293  1.1  christos 	heim_octet_string */*signed_data*/);
   1294  1.1  christos 
   1295  1.1  christos /**
   1296  1.1  christos  * Decode SignedData and verify that the signature is correct.
   1297  1.1  christos  *
   1298  1.1  christos  * @param context A hx509 context.
   1299  1.1  christos  * @param flags
   1300  1.1  christos  * @param eContentType the type of the data.
   1301  1.1  christos  * @param data data to sign
   1302  1.1  christos  * @param length length of the data that data point to.
   1303  1.1  christos  * @param digest_alg digest algorithm to use, use NULL to get the
   1304  1.1  christos  * default or the peer determined algorithm.
   1305  1.1  christos  * @param cert certificate to use for sign the data.
   1306  1.1  christos  * @param peer info about the peer the message to send the message to,
   1307  1.1  christos  * like what digest algorithm to use.
   1308  1.1  christos  * @param anchors trust anchors that the client will use, used to
   1309  1.1  christos  * polulate the certificates included in the message
   1310  1.1  christos  * @param pool certificates to use in try to build the path to the
   1311  1.1  christos  * trust anchors.
   1312  1.1  christos  * @param signed_data the output of the function, free with
   1313  1.1  christos  * der_free_octet_string().
   1314  1.1  christos  *
   1315  1.1  christos  * @return Returns an hx509 error code.
   1316  1.1  christos  *
   1317  1.1  christos  * @ingroup hx509_cms
   1318  1.1  christos  */
   1319  1.1  christos 
   1320  1.1  christos int
   1321  1.1  christos hx509_cms_create_signed_1 (
   1322  1.1  christos 	hx509_context /*context*/,
   1323  1.1  christos 	int /*flags*/,
   1324  1.1  christos 	const heim_oid */*eContentType*/,
   1325  1.1  christos 	const void */*data*/,
   1326  1.1  christos 	size_t /*length*/,
   1327  1.1  christos 	const AlgorithmIdentifier */*digest_alg*/,
   1328  1.1  christos 	hx509_cert /*cert*/,
   1329  1.1  christos 	hx509_peer_info /*peer*/,
   1330  1.1  christos 	hx509_certs /*anchors*/,
   1331  1.1  christos 	hx509_certs /*pool*/,
   1332  1.1  christos 	heim_octet_string */*signed_data*/);
   1333  1.1  christos 
   1334  1.1  christos /**
   1335  1.1  christos      * Use HX509_CMS_SIGNATURE_NO_SIGNER to create no sigInfo (no
   1336  1.1  christos      * signatures).
   1337  1.1  christos  */
   1338  1.1  christos 
   1339  1.1  christos int
   1340  1.1  christos hx509_cms_decrypt_encrypted (
   1341  1.1  christos 	hx509_context /*context*/,
   1342  1.1  christos 	hx509_lock /*lock*/,
   1343  1.1  christos 	const void */*data*/,
   1344  1.1  christos 	size_t /*length*/,
   1345  1.1  christos 	heim_oid */*contentType*/,
   1346  1.1  christos 	heim_octet_string */*content*/);
   1347  1.1  christos 
   1348  1.1  christos /**
   1349  1.1  christos  * Encrypt end encode EnvelopedData.
   1350  1.1  christos  *
   1351  1.1  christos  * Encrypt and encode EnvelopedData. The data is encrypted with a
   1352  1.1  christos  * random key and the the random key is encrypted with the
   1353  1.1  christos  * certificates private key. This limits what private key type can be
   1354  1.1  christos  * used to RSA.
   1355  1.1  christos  *
   1356  1.1  christos  * @param context A hx509 context.
   1357  1.1  christos  * @param flags flags to control the behavior.
   1358  1.1  christos  *    - HX509_CMS_EV_NO_KU_CHECK - Don't check KU on certificate
   1359  1.1  christos  *    - HX509_CMS_EV_ALLOW_WEAK - Allow weak crytpo
   1360  1.1  christos  *    - HX509_CMS_EV_ID_NAME - prefer issuer name and serial number
   1361  1.1  christos  * @param cert Certificate to encrypt the EnvelopedData encryption key
   1362  1.1  christos  * with.
   1363  1.1  christos  * @param data pointer the data to encrypt.
   1364  1.1  christos  * @param length length of the data that data point to.
   1365  1.1  christos  * @param encryption_type Encryption cipher to use for the bulk data,
   1366  1.1  christos  * use NULL to get default.
   1367  1.1  christos  * @param contentType type of the data that is encrypted
   1368  1.1  christos  * @param content the output of the function,
   1369  1.1  christos  * free with der_free_octet_string().
   1370  1.1  christos  *
   1371  1.1  christos  * @return an hx509 error code.
   1372  1.1  christos  *
   1373  1.1  christos  * @ingroup hx509_cms
   1374  1.1  christos  */
   1375  1.1  christos 
   1376  1.1  christos int
   1377  1.1  christos hx509_cms_envelope_1 (
   1378  1.1  christos 	hx509_context /*context*/,
   1379  1.1  christos 	int /*flags*/,
   1380  1.1  christos 	hx509_cert /*cert*/,
   1381  1.1  christos 	const void */*data*/,
   1382  1.1  christos 	size_t /*length*/,
   1383  1.1  christos 	const heim_oid */*encryption_type*/,
   1384  1.1  christos 	const heim_oid */*contentType*/,
   1385  1.1  christos 	heim_octet_string */*content*/);
   1386  1.1  christos 
   1387  1.1  christos /**
   1388  1.1  christos  * Decode and unencrypt EnvelopedData.
   1389  1.1  christos  *
   1390  1.1  christos  * Extract data and parameteres from from the EnvelopedData. Also
   1391  1.1  christos  * supports using detached EnvelopedData.
   1392  1.1  christos  *
   1393  1.1  christos  * @param context A hx509 context.
   1394  1.1  christos  * @param certs Certificate that can decrypt the EnvelopedData
   1395  1.1  christos  * encryption key.
   1396  1.1  christos  * @param flags HX509_CMS_UE flags to control the behavior.
   1397  1.1  christos  * @param data pointer the structure the contains the DER/BER encoded
   1398  1.1  christos  * EnvelopedData stucture.
   1399  1.1  christos  * @param length length of the data that data point to.
   1400  1.1  christos  * @param encryptedContent in case of detached signature, this
   1401  1.1  christos  * contains the actual encrypted data, othersize its should be NULL.
   1402  1.1  christos  * @param time_now set the current time, if zero the library uses now as the date.
   1403  1.1  christos  * @param contentType output type oid, should be freed with der_free_oid().
   1404  1.1  christos  * @param content the data, free with der_free_octet_string().
   1405  1.1  christos  *
   1406  1.1  christos  * @return an hx509 error code.
   1407  1.1  christos  *
   1408  1.1  christos  * @ingroup hx509_cms
   1409  1.1  christos  */
   1410  1.1  christos 
   1411  1.1  christos int
   1412  1.1  christos hx509_cms_unenvelope (
   1413  1.1  christos 	hx509_context /*context*/,
   1414  1.1  christos 	hx509_certs /*certs*/,
   1415  1.1  christos 	int /*flags*/,
   1416  1.1  christos 	const void */*data*/,
   1417  1.1  christos 	size_t /*length*/,
   1418  1.1  christos 	const heim_octet_string */*encryptedContent*/,
   1419  1.1  christos 	time_t /*time_now*/,
   1420  1.1  christos 	heim_oid */*contentType*/,
   1421  1.1  christos 	heim_octet_string */*content*/);
   1422  1.1  christos 
   1423  1.1  christos /**
   1424  1.1  christos  * Decode an ContentInfo and unwrap data and oid it.
   1425  1.1  christos  *
   1426  1.1  christos  * @param in the encoded buffer.
   1427  1.1  christos  * @param oid type of the content.
   1428  1.1  christos  * @param out data to be wrapped.
   1429  1.1  christos  * @param have_data since the data is optional, this flags show dthe
   1430  1.1  christos  * diffrence between no data and the zero length data.
   1431  1.1  christos  *
   1432  1.1  christos  * @return Returns an hx509 error code.
   1433  1.1  christos  *
   1434  1.1  christos  * @ingroup hx509_cms
   1435  1.1  christos  */
   1436  1.1  christos 
   1437  1.1  christos int
   1438  1.1  christos hx509_cms_unwrap_ContentInfo (
   1439  1.1  christos 	const heim_octet_string */*in*/,
   1440  1.1  christos 	heim_oid */*oid*/,
   1441  1.1  christos 	heim_octet_string */*out*/,
   1442  1.1  christos 	int */*have_data*/);
   1443  1.1  christos 
   1444  1.1  christos /**
   1445  1.1  christos  * Decode SignedData and verify that the signature is correct.
   1446  1.1  christos  *
   1447  1.1  christos  * @param context A hx509 context.
   1448  1.1  christos  * @param ctx a hx509 verify context.
   1449  1.1  christos  * @param flags to control the behaivor of the function.
   1450  1.1  christos  *    - HX509_CMS_VS_NO_KU_CHECK - Don't check KeyUsage
   1451  1.1  christos  *    - HX509_CMS_VS_ALLOW_DATA_OID_MISMATCH - allow oid mismatch
   1452  1.1  christos  *    - HX509_CMS_VS_ALLOW_ZERO_SIGNER - no signer, see below.
   1453  1.1  christos  * @param data pointer to CMS SignedData encoded data.
   1454  1.1  christos  * @param length length of the data that data point to.
   1455  1.1  christos  * @param signedContent external data used for signature.
   1456  1.1  christos  * @param pool certificate pool to build certificates paths.
   1457  1.1  christos  * @param contentType free with der_free_oid().
   1458  1.1  christos  * @param content the output of the function, free with
   1459  1.1  christos  * der_free_octet_string().
   1460  1.1  christos  * @param signer_certs list of the cerficates used to sign this
   1461  1.1  christos  * request, free with hx509_certs_free().
   1462  1.1  christos  *
   1463  1.1  christos  * @return an hx509 error code.
   1464  1.1  christos  *
   1465  1.1  christos  * @ingroup hx509_cms
   1466  1.1  christos  */
   1467  1.1  christos 
   1468  1.1  christos int
   1469  1.1  christos hx509_cms_verify_signed (
   1470  1.1  christos 	hx509_context /*context*/,
   1471  1.1  christos 	hx509_verify_ctx /*ctx*/,
   1472  1.1  christos 	unsigned int /*flags*/,
   1473  1.1  christos 	const void */*data*/,
   1474  1.1  christos 	size_t /*length*/,
   1475  1.1  christos 	const heim_octet_string */*signedContent*/,
   1476  1.1  christos 	hx509_certs /*pool*/,
   1477  1.1  christos 	heim_oid */*contentType*/,
   1478  1.1  christos 	heim_octet_string */*content*/,
   1479  1.1  christos 	hx509_certs */*signer_certs*/);
   1480  1.1  christos 
   1481  1.1  christos /**
   1482  1.1  christos  * Wrap data and oid in a ContentInfo and encode it.
   1483  1.1  christos  *
   1484  1.1  christos  * @param oid type of the content.
   1485  1.1  christos  * @param buf data to be wrapped. If a NULL pointer is passed in, the
   1486  1.1  christos  * optional content field in the ContentInfo is not going be filled
   1487  1.1  christos  * in.
   1488  1.1  christos  * @param res the encoded buffer, the result should be freed with
   1489  1.1  christos  * der_free_octet_string().
   1490  1.1  christos  *
   1491  1.1  christos  * @return Returns an hx509 error code.
   1492  1.1  christos  *
   1493  1.1  christos  * @ingroup hx509_cms
   1494  1.1  christos  */
   1495  1.1  christos 
   1496  1.1  christos int
   1497  1.1  christos hx509_cms_wrap_ContentInfo (
   1498  1.1  christos 	const heim_oid */*oid*/,
   1499  1.1  christos 	const heim_octet_string */*buf*/,
   1500  1.1  christos 	heim_octet_string */*res*/);
   1501  1.1  christos 
   1502  1.1  christos /**
   1503  1.1  christos  * Free the context allocated by hx509_context_init().
   1504  1.1  christos  *
   1505  1.1  christos  * @param context context to be freed.
   1506  1.1  christos  *
   1507  1.1  christos  * @ingroup hx509
   1508  1.1  christos  */
   1509  1.1  christos 
   1510  1.1  christos void
   1511  1.1  christos hx509_context_free (hx509_context */*context*/);
   1512  1.1  christos 
   1513  1.1  christos /**
   1514  1.1  christos  * Creates a hx509 context that most functions in the library
   1515  1.1  christos  * uses. The context is only allowed to be used by one thread at each
   1516  1.1  christos  * moment. Free the context with hx509_context_free().
   1517  1.1  christos  *
   1518  1.1  christos  * @param context Returns a pointer to new hx509 context.
   1519  1.1  christos  *
   1520  1.1  christos  * @return Returns an hx509 error code.
   1521  1.1  christos  *
   1522  1.1  christos  * @ingroup hx509
   1523  1.1  christos  */
   1524  1.1  christos 
   1525  1.1  christos int
   1526  1.1  christos hx509_context_init (hx509_context */*context*/);
   1527  1.1  christos 
   1528  1.1  christos /**
   1529  1.1  christos  * Selects if the hx509_revoke_verify() function is going to require
   1530  1.1  christos  * the existans of a revokation method (OCSP, CRL) or not. Note that
   1531  1.1  christos  * hx509_verify_path(), hx509_cms_verify_signed(), and other function
   1532  1.1  christos  * call hx509_revoke_verify().
   1533  1.1  christos  *
   1534  1.1  christos  * @param context hx509 context to change the flag for.
   1535  1.1  christos  * @param flag zero, revokation method required, non zero missing
   1536  1.1  christos  * revokation method ok
   1537  1.1  christos  *
   1538  1.1  christos  * @ingroup hx509_verify
   1539  1.1  christos  */
   1540  1.1  christos 
   1541  1.1  christos void
   1542  1.1  christos hx509_context_set_missing_revoke (
   1543  1.1  christos 	hx509_context /*context*/,
   1544  1.1  christos 	int /*flag*/);
   1545  1.1  christos 
   1546  1.1  christos /**
   1547  1.1  christos  * Add revoked certificate to an CRL context.
   1548  1.1  christos  *
   1549  1.1  christos  * @param context a hx509 context.
   1550  1.1  christos  * @param crl the CRL to add the revoked certificate to.
   1551  1.1  christos  * @param certs keyset of certificate to revoke.
   1552  1.1  christos  *
   1553  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   1554  1.1  christos  *
   1555  1.1  christos  * @ingroup hx509_verify
   1556  1.1  christos  */
   1557  1.1  christos 
   1558  1.1  christos int
   1559  1.1  christos hx509_crl_add_revoked_certs (
   1560  1.1  christos 	hx509_context /*context*/,
   1561  1.1  christos 	hx509_crl /*crl*/,
   1562  1.1  christos 	hx509_certs /*certs*/);
   1563  1.1  christos 
   1564  1.1  christos /**
   1565  1.1  christos  * Create a CRL context. Use hx509_crl_free() to free the CRL context.
   1566  1.1  christos  *
   1567  1.1  christos  * @param context a hx509 context.
   1568  1.1  christos  * @param crl return pointer to a newly allocated CRL context.
   1569  1.1  christos  *
   1570  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   1571  1.1  christos  *
   1572  1.1  christos  * @ingroup hx509_verify
   1573  1.1  christos  */
   1574  1.1  christos 
   1575  1.1  christos int
   1576  1.1  christos hx509_crl_alloc (
   1577  1.1  christos 	hx509_context /*context*/,
   1578  1.1  christos 	hx509_crl */*crl*/);
   1579  1.1  christos 
   1580  1.1  christos /**
   1581  1.1  christos  * Free a CRL context.
   1582  1.1  christos  *
   1583  1.1  christos  * @param context a hx509 context.
   1584  1.1  christos  * @param crl a CRL context to free.
   1585  1.1  christos  *
   1586  1.1  christos  * @ingroup hx509_verify
   1587  1.1  christos  */
   1588  1.1  christos 
   1589  1.1  christos void
   1590  1.1  christos hx509_crl_free (
   1591  1.1  christos 	hx509_context /*context*/,
   1592  1.1  christos 	hx509_crl */*crl*/);
   1593  1.1  christos 
   1594  1.1  christos /**
   1595  1.1  christos  * Set the lifetime of a CRL context.
   1596  1.1  christos  *
   1597  1.1  christos  * @param context a hx509 context.
   1598  1.1  christos  * @param crl a CRL context
   1599  1.1  christos  * @param delta delta time the certificate is valid, library adds the
   1600  1.1  christos  * current time to this.
   1601  1.1  christos  *
   1602  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   1603  1.1  christos  *
   1604  1.1  christos  * @ingroup hx509_verify
   1605  1.1  christos  */
   1606  1.1  christos 
   1607  1.1  christos int
   1608  1.1  christos hx509_crl_lifetime (
   1609  1.1  christos 	hx509_context /*context*/,
   1610  1.1  christos 	hx509_crl /*crl*/,
   1611  1.1  christos 	int /*delta*/);
   1612  1.1  christos 
   1613  1.1  christos /**
   1614  1.1  christos  * Sign a CRL and return an encode certificate.
   1615  1.1  christos  *
   1616  1.1  christos  * @param context a hx509 context.
   1617  1.1  christos  * @param signer certificate to sign the CRL with
   1618  1.1  christos  * @param crl the CRL to sign
   1619  1.1  christos  * @param os return the signed and encoded CRL, free with
   1620  1.1  christos  * free_heim_octet_string()
   1621  1.1  christos  *
   1622  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   1623  1.1  christos  *
   1624  1.1  christos  * @ingroup hx509_verify
   1625  1.1  christos  */
   1626  1.1  christos 
   1627  1.1  christos int
   1628  1.1  christos hx509_crl_sign (
   1629  1.1  christos 	hx509_context /*context*/,
   1630  1.1  christos 	hx509_cert /*signer*/,
   1631  1.1  christos 	hx509_crl /*crl*/,
   1632  1.1  christos 	heim_octet_string */*os*/);
   1633  1.1  christos 
   1634  1.1  christos const AlgorithmIdentifier *
   1635  1.1  christos hx509_crypto_aes128_cbc (void);
   1636  1.1  christos 
   1637  1.1  christos const AlgorithmIdentifier *
   1638  1.1  christos hx509_crypto_aes256_cbc (void);
   1639  1.1  christos 
   1640  1.1  christos void
   1641  1.1  christos hx509_crypto_allow_weak (hx509_crypto /*crypto*/);
   1642  1.1  christos 
   1643  1.1  christos int
   1644  1.1  christos hx509_crypto_available (
   1645  1.1  christos 	hx509_context /*context*/,
   1646  1.1  christos 	int /*type*/,
   1647  1.1  christos 	hx509_cert /*source*/,
   1648  1.1  christos 	AlgorithmIdentifier **/*val*/,
   1649  1.1  christos 	unsigned int */*plen*/);
   1650  1.1  christos 
   1651  1.1  christos int
   1652  1.1  christos hx509_crypto_decrypt (
   1653  1.1  christos 	hx509_crypto /*crypto*/,
   1654  1.1  christos 	const void */*data*/,
   1655  1.1  christos 	const size_t /*length*/,
   1656  1.1  christos 	heim_octet_string */*ivec*/,
   1657  1.1  christos 	heim_octet_string */*clear*/);
   1658  1.1  christos 
   1659  1.1  christos const AlgorithmIdentifier *
   1660  1.1  christos hx509_crypto_des_rsdi_ede3_cbc (void);
   1661  1.1  christos 
   1662  1.1  christos void
   1663  1.1  christos hx509_crypto_destroy (hx509_crypto /*crypto*/);
   1664  1.1  christos 
   1665  1.1  christos int
   1666  1.1  christos hx509_crypto_encrypt (
   1667  1.1  christos 	hx509_crypto /*crypto*/,
   1668  1.1  christos 	const void */*data*/,
   1669  1.1  christos 	const size_t /*length*/,
   1670  1.1  christos 	const heim_octet_string */*ivec*/,
   1671  1.1  christos 	heim_octet_string **/*ciphertext*/);
   1672  1.1  christos 
   1673  1.1  christos const heim_oid *
   1674  1.1  christos hx509_crypto_enctype_by_name (const char */*name*/);
   1675  1.1  christos 
   1676  1.1  christos void
   1677  1.1  christos hx509_crypto_free_algs (
   1678  1.1  christos 	AlgorithmIdentifier */*val*/,
   1679  1.1  christos 	unsigned int /*len*/);
   1680  1.1  christos 
   1681  1.1  christos int
   1682  1.1  christos hx509_crypto_get_params (
   1683  1.1  christos 	hx509_context /*context*/,
   1684  1.1  christos 	hx509_crypto /*crypto*/,
   1685  1.1  christos 	const heim_octet_string */*ivec*/,
   1686  1.1  christos 	heim_octet_string */*param*/);
   1687  1.1  christos 
   1688  1.1  christos int
   1689  1.1  christos hx509_crypto_init (
   1690  1.1  christos 	hx509_context /*context*/,
   1691  1.1  christos 	const char */*provider*/,
   1692  1.1  christos 	const heim_oid */*enctype*/,
   1693  1.1  christos 	hx509_crypto */*crypto*/);
   1694  1.1  christos 
   1695  1.1  christos const char *
   1696  1.1  christos hx509_crypto_provider (hx509_crypto /*crypto*/);
   1697  1.1  christos 
   1698  1.1  christos int
   1699  1.1  christos hx509_crypto_random_iv (
   1700  1.1  christos 	hx509_crypto /*crypto*/,
   1701  1.1  christos 	heim_octet_string */*ivec*/);
   1702  1.1  christos 
   1703  1.1  christos int
   1704  1.1  christos hx509_crypto_select (
   1705  1.1  christos 	const hx509_context /*context*/,
   1706  1.1  christos 	int /*type*/,
   1707  1.1  christos 	const hx509_private_key /*source*/,
   1708  1.1  christos 	hx509_peer_info /*peer*/,
   1709  1.1  christos 	AlgorithmIdentifier */*selected*/);
   1710  1.1  christos 
   1711  1.1  christos int
   1712  1.1  christos hx509_crypto_set_key_data (
   1713  1.1  christos 	hx509_crypto /*crypto*/,
   1714  1.1  christos 	const void */*data*/,
   1715  1.1  christos 	size_t /*length*/);
   1716  1.1  christos 
   1717  1.1  christos int
   1718  1.1  christos hx509_crypto_set_key_name (
   1719  1.1  christos 	hx509_crypto /*crypto*/,
   1720  1.1  christos 	const char */*name*/);
   1721  1.1  christos 
   1722  1.1  christos void
   1723  1.1  christos hx509_crypto_set_padding (
   1724  1.1  christos 	hx509_crypto /*crypto*/,
   1725  1.1  christos 	int /*padding_type*/);
   1726  1.1  christos 
   1727  1.1  christos int
   1728  1.1  christos hx509_crypto_set_params (
   1729  1.1  christos 	hx509_context /*context*/,
   1730  1.1  christos 	hx509_crypto /*crypto*/,
   1731  1.1  christos 	const heim_octet_string */*param*/,
   1732  1.1  christos 	heim_octet_string */*ivec*/);
   1733  1.1  christos 
   1734  1.1  christos int
   1735  1.1  christos hx509_crypto_set_random_key (
   1736  1.1  christos 	hx509_crypto /*crypto*/,
   1737  1.1  christos 	heim_octet_string */*key*/);
   1738  1.1  christos 
   1739  1.1  christos /**
   1740  1.1  christos  * Add a new key/value pair to the hx509_env.
   1741  1.1  christos  *
   1742  1.1  christos  * @param context A hx509 context.
   1743  1.1  christos  * @param env environment to add the environment variable too.
   1744  1.1  christos  * @param key key to add
   1745  1.1  christos  * @param value value to add
   1746  1.1  christos  *
   1747  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   1748  1.1  christos  *
   1749  1.1  christos  * @ingroup hx509_env
   1750  1.1  christos  */
   1751  1.1  christos 
   1752  1.1  christos int
   1753  1.1  christos hx509_env_add (
   1754  1.1  christos 	hx509_context /*context*/,
   1755  1.1  christos 	hx509_env */*env*/,
   1756  1.1  christos 	const char */*key*/,
   1757  1.1  christos 	const char */*value*/);
   1758  1.1  christos 
   1759  1.1  christos /**
   1760  1.1  christos  * Add a new key/binding pair to the hx509_env.
   1761  1.1  christos  *
   1762  1.1  christos  * @param context A hx509 context.
   1763  1.1  christos  * @param env environment to add the environment variable too.
   1764  1.1  christos  * @param key key to add
   1765  1.1  christos  * @param list binding list to add
   1766  1.1  christos  *
   1767  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   1768  1.1  christos  *
   1769  1.1  christos  * @ingroup hx509_env
   1770  1.1  christos  */
   1771  1.1  christos 
   1772  1.1  christos int
   1773  1.1  christos hx509_env_add_binding (
   1774  1.1  christos 	hx509_context /*context*/,
   1775  1.1  christos 	hx509_env */*env*/,
   1776  1.1  christos 	const char */*key*/,
   1777  1.1  christos 	hx509_env /*list*/);
   1778  1.1  christos 
   1779  1.1  christos /**
   1780  1.1  christos  * Search the hx509_env for a key.
   1781  1.1  christos  *
   1782  1.1  christos  * @param context A hx509 context.
   1783  1.1  christos  * @param env environment to add the environment variable too.
   1784  1.1  christos  * @param key key to search for.
   1785  1.1  christos  *
   1786  1.1  christos  * @return the value if the key is found, NULL otherwise.
   1787  1.1  christos  *
   1788  1.1  christos  * @ingroup hx509_env
   1789  1.1  christos  */
   1790  1.1  christos 
   1791  1.1  christos const char *
   1792  1.1  christos hx509_env_find (
   1793  1.1  christos 	hx509_context /*context*/,
   1794  1.1  christos 	hx509_env /*env*/,
   1795  1.1  christos 	const char */*key*/);
   1796  1.1  christos 
   1797  1.1  christos /**
   1798  1.1  christos  * Search the hx509_env for a binding.
   1799  1.1  christos  *
   1800  1.1  christos  * @param context A hx509 context.
   1801  1.1  christos  * @param env environment to add the environment variable too.
   1802  1.1  christos  * @param key key to search for.
   1803  1.1  christos  *
   1804  1.1  christos  * @return the binding if the key is found, NULL if not found.
   1805  1.1  christos  *
   1806  1.1  christos  * @ingroup hx509_env
   1807  1.1  christos  */
   1808  1.1  christos 
   1809  1.1  christos hx509_env
   1810  1.1  christos hx509_env_find_binding (
   1811  1.1  christos 	hx509_context /*context*/,
   1812  1.1  christos 	hx509_env /*env*/,
   1813  1.1  christos 	const char */*key*/);
   1814  1.1  christos 
   1815  1.1  christos /**
   1816  1.1  christos  * Free an hx509_env environment context.
   1817  1.1  christos  *
   1818  1.1  christos  * @param env the environment to free.
   1819  1.1  christos  *
   1820  1.1  christos  * @ingroup hx509_env
   1821  1.1  christos  */
   1822  1.1  christos 
   1823  1.1  christos void
   1824  1.1  christos hx509_env_free (hx509_env */*env*/);
   1825  1.1  christos 
   1826  1.1  christos /**
   1827  1.1  christos  * Search the hx509_env for a length based key.
   1828  1.1  christos  *
   1829  1.1  christos  * @param context A hx509 context.
   1830  1.1  christos  * @param env environment to add the environment variable too.
   1831  1.1  christos  * @param key key to search for.
   1832  1.1  christos  * @param len length of key.
   1833  1.1  christos  *
   1834  1.1  christos  * @return the value if the key is found, NULL otherwise.
   1835  1.1  christos  *
   1836  1.1  christos  * @ingroup hx509_env
   1837  1.1  christos  */
   1838  1.1  christos 
   1839  1.1  christos const char *
   1840  1.1  christos hx509_env_lfind (
   1841  1.1  christos 	hx509_context /*context*/,
   1842  1.1  christos 	hx509_env /*env*/,
   1843  1.1  christos 	const char */*key*/,
   1844  1.1  christos 	size_t /*len*/);
   1845  1.1  christos 
   1846  1.1  christos /**
   1847  1.1  christos  * Print error message and fatally exit from error code
   1848  1.1  christos  *
   1849  1.1  christos  * @param context A hx509 context.
   1850  1.1  christos  * @param exit_code exit() code from process.
   1851  1.1  christos  * @param error_code Error code for the reason to exit.
   1852  1.1  christos  * @param fmt format string with the exit message.
   1853  1.1  christos  * @param ... argument to format string.
   1854  1.1  christos  *
   1855  1.1  christos  * @ingroup hx509_error
   1856  1.1  christos  */
   1857  1.1  christos 
   1858  1.1  christos void
   1859  1.1  christos hx509_err (
   1860  1.1  christos 	hx509_context /*context*/,
   1861  1.1  christos 	int /*exit_code*/,
   1862  1.1  christos 	int /*error_code*/,
   1863  1.1  christos 	const char */*fmt*/,
   1864  1.1  christos 	...);
   1865  1.1  christos 
   1866  1.1  christos hx509_private_key_ops *
   1867  1.1  christos hx509_find_private_alg (const heim_oid */*oid*/);
   1868  1.1  christos 
   1869  1.1  christos /**
   1870  1.1  christos  * Free error string returned by hx509_get_error_string().
   1871  1.1  christos  *
   1872  1.1  christos  * @param str error string to free.
   1873  1.1  christos  *
   1874  1.1  christos  * @ingroup hx509_error
   1875  1.1  christos  */
   1876  1.1  christos 
   1877  1.1  christos void
   1878  1.1  christos hx509_free_error_string (char */*str*/);
   1879  1.1  christos 
   1880  1.1  christos /**
   1881  1.1  christos  * Free a list of octet strings returned by another hx509 library
   1882  1.1  christos  * function.
   1883  1.1  christos  *
   1884  1.1  christos  * @param list list to be freed.
   1885  1.1  christos  *
   1886  1.1  christos  * @ingroup hx509_misc
   1887  1.1  christos  */
   1888  1.1  christos 
   1889  1.1  christos void
   1890  1.1  christos hx509_free_octet_string_list (hx509_octet_string_list */*list*/);
   1891  1.1  christos 
   1892  1.1  christos /**
   1893  1.1  christos  * Unparse the hx509 name in name into a string.
   1894  1.1  christos  *
   1895  1.1  christos  * @param name the name to print
   1896  1.1  christos  * @param str an allocated string returns the name in string form
   1897  1.1  christos  *
   1898  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   1899  1.1  christos  *
   1900  1.1  christos  * @ingroup hx509_name
   1901  1.1  christos  */
   1902  1.1  christos 
   1903  1.1  christos int
   1904  1.1  christos hx509_general_name_unparse (
   1905  1.1  christos 	GeneralName */*name*/,
   1906  1.1  christos 	char **/*str*/);
   1907  1.1  christos 
   1908  1.1  christos /**
   1909  1.1  christos  * Get an error string from context associated with error_code.
   1910  1.1  christos  *
   1911  1.1  christos  * @param context A hx509 context.
   1912  1.1  christos  * @param error_code Get error message for this error code.
   1913  1.1  christos  *
   1914  1.1  christos  * @return error string, free with hx509_free_error_string().
   1915  1.1  christos  *
   1916  1.1  christos  * @ingroup hx509_error
   1917  1.1  christos  */
   1918  1.1  christos 
   1919  1.1  christos char *
   1920  1.1  christos hx509_get_error_string (
   1921  1.1  christos 	hx509_context /*context*/,
   1922  1.1  christos 	int /*error_code*/);
   1923  1.1  christos 
   1924  1.1  christos /**
   1925  1.1  christos  * Get one random certificate from the certificate store.
   1926  1.1  christos  *
   1927  1.1  christos  * @param context a hx509 context.
   1928  1.1  christos  * @param certs a certificate store to get the certificate from.
   1929  1.1  christos  * @param c return certificate, should be freed with hx509_cert_free().
   1930  1.1  christos  *
   1931  1.1  christos  * @return Returns an hx509 error code.
   1932  1.1  christos  *
   1933  1.1  christos  * @ingroup hx509_keyset
   1934  1.1  christos  */
   1935  1.1  christos 
   1936  1.1  christos int
   1937  1.1  christos hx509_get_one_cert (
   1938  1.1  christos 	hx509_context /*context*/,
   1939  1.1  christos 	hx509_certs /*certs*/,
   1940  1.1  christos 	hx509_cert */*c*/);
   1941  1.1  christos 
   1942  1.1  christos int
   1943  1.1  christos hx509_lock_add_cert (
   1944  1.1  christos 	hx509_context /*context*/,
   1945  1.1  christos 	hx509_lock /*lock*/,
   1946  1.1  christos 	hx509_cert /*cert*/);
   1947  1.1  christos 
   1948  1.1  christos int
   1949  1.1  christos hx509_lock_add_certs (
   1950  1.1  christos 	hx509_context /*context*/,
   1951  1.1  christos 	hx509_lock /*lock*/,
   1952  1.1  christos 	hx509_certs /*certs*/);
   1953  1.1  christos 
   1954  1.1  christos int
   1955  1.1  christos hx509_lock_add_password (
   1956  1.1  christos 	hx509_lock /*lock*/,
   1957  1.1  christos 	const char */*password*/);
   1958  1.1  christos 
   1959  1.1  christos int
   1960  1.1  christos hx509_lock_command_string (
   1961  1.1  christos 	hx509_lock /*lock*/,
   1962  1.1  christos 	const char */*string*/);
   1963  1.1  christos 
   1964  1.1  christos void
   1965  1.1  christos hx509_lock_free (hx509_lock /*lock*/);
   1966  1.1  christos 
   1967  1.1  christos /**
   1968  1.1  christos  * @page page_lock Locking and unlocking certificates and encrypted data.
   1969  1.1  christos  *
   1970  1.1  christos  * See the library functions here: @ref hx509_lock
   1971  1.1  christos  */
   1972  1.1  christos 
   1973  1.1  christos int
   1974  1.1  christos hx509_lock_init (
   1975  1.1  christos 	hx509_context /*context*/,
   1976  1.1  christos 	hx509_lock */*lock*/);
   1977  1.1  christos 
   1978  1.1  christos int
   1979  1.1  christos hx509_lock_prompt (
   1980  1.1  christos 	hx509_lock /*lock*/,
   1981  1.1  christos 	hx509_prompt */*prompt*/);
   1982  1.1  christos 
   1983  1.1  christos void
   1984  1.1  christos hx509_lock_reset_certs (
   1985  1.1  christos 	hx509_context /*context*/,
   1986  1.1  christos 	hx509_lock /*lock*/);
   1987  1.1  christos 
   1988  1.1  christos void
   1989  1.1  christos hx509_lock_reset_passwords (hx509_lock /*lock*/);
   1990  1.1  christos 
   1991  1.1  christos void
   1992  1.1  christos hx509_lock_reset_promper (hx509_lock /*lock*/);
   1993  1.1  christos 
   1994  1.1  christos int
   1995  1.1  christos hx509_lock_set_prompter (
   1996  1.1  christos 	hx509_lock /*lock*/,
   1997  1.1  christos 	hx509_prompter_fct /*prompt*/,
   1998  1.1  christos 	void */*data*/);
   1999  1.1  christos 
   2000  1.1  christos /**
   2001  1.1  christos  * Convert a hx509_name object to DER encoded name.
   2002  1.1  christos  *
   2003  1.1  christos  * @param name name to concert
   2004  1.1  christos  * @param os data to a DER encoded name, free the resulting octet
   2005  1.1  christos  * string with hx509_xfree(os->data).
   2006  1.1  christos  *
   2007  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2008  1.1  christos  *
   2009  1.1  christos  * @ingroup hx509_name
   2010  1.1  christos  */
   2011  1.1  christos 
   2012  1.1  christos int
   2013  1.1  christos hx509_name_binary (
   2014  1.1  christos 	const hx509_name /*name*/,
   2015  1.1  christos 	heim_octet_string */*os*/);
   2016  1.1  christos 
   2017  1.1  christos /**
   2018  1.1  christos  * Compare to hx509 name object, useful for sorting.
   2019  1.1  christos  *
   2020  1.1  christos  * @param n1 a hx509 name object.
   2021  1.1  christos  * @param n2 a hx509 name object.
   2022  1.1  christos  *
   2023  1.1  christos  * @return 0 the objects are the same, returns > 0 is n2 is "larger"
   2024  1.1  christos  * then n2, < 0 if n1 is "smaller" then n2.
   2025  1.1  christos  *
   2026  1.1  christos  * @ingroup hx509_name
   2027  1.1  christos  */
   2028  1.1  christos 
   2029  1.1  christos int
   2030  1.1  christos hx509_name_cmp (
   2031  1.1  christos 	hx509_name /*n1*/,
   2032  1.1  christos 	hx509_name /*n2*/);
   2033  1.1  christos 
   2034  1.1  christos /**
   2035  1.1  christos  * Copy a hx509 name object.
   2036  1.1  christos  *
   2037  1.1  christos  * @param context A hx509 cotext.
   2038  1.1  christos  * @param from the name to copy from
   2039  1.1  christos  * @param to the name to copy to
   2040  1.1  christos  *
   2041  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2042  1.1  christos  *
   2043  1.1  christos  * @ingroup hx509_name
   2044  1.1  christos  */
   2045  1.1  christos 
   2046  1.1  christos int
   2047  1.1  christos hx509_name_copy (
   2048  1.1  christos 	hx509_context /*context*/,
   2049  1.1  christos 	const hx509_name /*from*/,
   2050  1.1  christos 	hx509_name */*to*/);
   2051  1.1  christos 
   2052  1.1  christos /**
   2053  1.1  christos  * Expands variables in the name using env. Variables are on the form
   2054  1.1  christos  * ${name}. Useful when dealing with certificate templates.
   2055  1.1  christos  *
   2056  1.1  christos  * @param context A hx509 cotext.
   2057  1.1  christos  * @param name the name to expand.
   2058  1.1  christos  * @param env environment variable to expand.
   2059  1.1  christos  *
   2060  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2061  1.1  christos  *
   2062  1.1  christos  * @ingroup hx509_name
   2063  1.1  christos  */
   2064  1.1  christos 
   2065  1.1  christos int
   2066  1.1  christos hx509_name_expand (
   2067  1.1  christos 	hx509_context /*context*/,
   2068  1.1  christos 	hx509_name /*name*/,
   2069  1.1  christos 	hx509_env /*env*/);
   2070  1.1  christos 
   2071  1.1  christos /**
   2072  1.1  christos  * Free a hx509 name object, upond return *name will be NULL.
   2073  1.1  christos  *
   2074  1.1  christos  * @param name a hx509 name object to be freed.
   2075  1.1  christos  *
   2076  1.1  christos  * @ingroup hx509_name
   2077  1.1  christos  */
   2078  1.1  christos 
   2079  1.1  christos void
   2080  1.1  christos hx509_name_free (hx509_name */*name*/);
   2081  1.1  christos 
   2082  1.1  christos /**
   2083  1.1  christos  * Unparse the hx509 name in name into a string.
   2084  1.1  christos  *
   2085  1.1  christos  * @param name the name to check if its empty/null.
   2086  1.1  christos  *
   2087  1.1  christos  * @return non zero if the name is empty/null.
   2088  1.1  christos  *
   2089  1.1  christos  * @ingroup hx509_name
   2090  1.1  christos  */
   2091  1.1  christos 
   2092  1.1  christos int
   2093  1.1  christos hx509_name_is_null_p (const hx509_name /*name*/);
   2094  1.1  christos 
   2095  1.1  christos int
   2096  1.1  christos hx509_name_normalize (
   2097  1.1  christos 	hx509_context /*context*/,
   2098  1.1  christos 	hx509_name /*name*/);
   2099  1.1  christos 
   2100  1.1  christos /**
   2101  1.1  christos  * Convert a hx509_name into a Name.
   2102  1.1  christos  *
   2103  1.1  christos  * @param from the name to copy from
   2104  1.1  christos  * @param to the name to copy to
   2105  1.1  christos  *
   2106  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2107  1.1  christos  *
   2108  1.1  christos  * @ingroup hx509_name
   2109  1.1  christos  */
   2110  1.1  christos 
   2111  1.1  christos int
   2112  1.1  christos hx509_name_to_Name (
   2113  1.1  christos 	const hx509_name /*from*/,
   2114  1.1  christos 	Name */*to*/);
   2115  1.1  christos 
   2116  1.1  christos /**
   2117  1.1  christos  * Convert the hx509 name object into a printable string.
   2118  1.1  christos  * The resulting string should be freed with free().
   2119  1.1  christos  *
   2120  1.1  christos  * @param name name to print
   2121  1.1  christos  * @param str the string to return
   2122  1.1  christos  *
   2123  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2124  1.1  christos  *
   2125  1.1  christos  * @ingroup hx509_name
   2126  1.1  christos  */
   2127  1.1  christos 
   2128  1.1  christos int
   2129  1.1  christos hx509_name_to_string (
   2130  1.1  christos 	const hx509_name /*name*/,
   2131  1.1  christos 	char **/*str*/);
   2132  1.1  christos 
   2133  1.1  christos /**
   2134  1.1  christos  * Create an OCSP request for a set of certificates.
   2135  1.1  christos  *
   2136  1.1  christos  * @param context a hx509 context
   2137  1.1  christos  * @param reqcerts list of certificates to request ocsp data for
   2138  1.1  christos  * @param pool certificate pool to use when signing
   2139  1.1  christos  * @param signer certificate to use to sign the request
   2140  1.1  christos  * @param digest the signing algorithm in the request, if NULL use the
   2141  1.1  christos  * default signature algorithm,
   2142  1.1  christos  * @param request the encoded request, free with free_heim_octet_string().
   2143  1.1  christos  * @param nonce nonce in the request, free with free_heim_octet_string().
   2144  1.1  christos  *
   2145  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2146  1.1  christos  *
   2147  1.1  christos  * @ingroup hx509_revoke
   2148  1.1  christos  */
   2149  1.1  christos 
   2150  1.1  christos int
   2151  1.1  christos hx509_ocsp_request (
   2152  1.1  christos 	hx509_context /*context*/,
   2153  1.1  christos 	hx509_certs /*reqcerts*/,
   2154  1.1  christos 	hx509_certs /*pool*/,
   2155  1.1  christos 	hx509_cert /*signer*/,
   2156  1.1  christos 	const AlgorithmIdentifier */*digest*/,
   2157  1.1  christos 	heim_octet_string */*request*/,
   2158  1.1  christos 	heim_octet_string */*nonce*/);
   2159  1.1  christos 
   2160  1.1  christos /**
   2161  1.1  christos  * Verify that the certificate is part of the OCSP reply and it's not
   2162  1.1  christos  * expired. Doesn't verify signature the OCSP reply or it's done by a
   2163  1.1  christos  * authorized sender, that is assumed to be already done.
   2164  1.1  christos  *
   2165  1.1  christos  * @param context a hx509 context
   2166  1.1  christos  * @param now the time right now, if 0, use the current time.
   2167  1.1  christos  * @param cert the certificate to verify
   2168  1.1  christos  * @param flags flags control the behavior
   2169  1.1  christos  * @param data pointer to the encode ocsp reply
   2170  1.1  christos  * @param length the length of the encode ocsp reply
   2171  1.1  christos  * @param expiration return the time the OCSP will expire and need to
   2172  1.1  christos  * be rechecked.
   2173  1.1  christos  *
   2174  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2175  1.1  christos  *
   2176  1.1  christos  * @ingroup hx509_verify
   2177  1.1  christos  */
   2178  1.1  christos 
   2179  1.1  christos int
   2180  1.1  christos hx509_ocsp_verify (
   2181  1.1  christos 	hx509_context /*context*/,
   2182  1.1  christos 	time_t /*now*/,
   2183  1.1  christos 	hx509_cert /*cert*/,
   2184  1.1  christos 	int /*flags*/,
   2185  1.1  christos 	const void */*data*/,
   2186  1.1  christos 	size_t /*length*/,
   2187  1.1  christos 	time_t */*expiration*/);
   2188  1.1  christos 
   2189  1.1  christos /**
   2190  1.1  christos  * Print a oid using a hx509_vprint_func function. To print to stdout
   2191  1.1  christos  * use hx509_print_stdout().
   2192  1.1  christos  *
   2193  1.1  christos  * @param oid oid to print
   2194  1.1  christos  * @param func hx509_vprint_func to print with.
   2195  1.1  christos  * @param ctx context variable to hx509_vprint_func function.
   2196  1.1  christos  *
   2197  1.1  christos  * @ingroup hx509_print
   2198  1.1  christos  */
   2199  1.1  christos 
   2200  1.1  christos void
   2201  1.1  christos hx509_oid_print (
   2202  1.1  christos 	const heim_oid */*oid*/,
   2203  1.1  christos 	hx509_vprint_func /*func*/,
   2204  1.1  christos 	void */*ctx*/);
   2205  1.1  christos 
   2206  1.1  christos /**
   2207  1.1  christos  * Print a oid to a string.
   2208  1.1  christos  *
   2209  1.1  christos  * @param oid oid to print
   2210  1.1  christos  * @param str allocated string, free with hx509_xfree().
   2211  1.1  christos  *
   2212  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2213  1.1  christos  *
   2214  1.1  christos  * @ingroup hx509_print
   2215  1.1  christos  */
   2216  1.1  christos 
   2217  1.1  christos int
   2218  1.1  christos hx509_oid_sprint (
   2219  1.1  christos 	const heim_oid */*oid*/,
   2220  1.1  christos 	char **/*str*/);
   2221  1.1  christos 
   2222  1.1  christos /**
   2223  1.1  christos  * Parse a string into a hx509 name object.
   2224  1.1  christos  *
   2225  1.1  christos  * @param context A hx509 context.
   2226  1.1  christos  * @param str a string to parse.
   2227  1.1  christos  * @param name the resulting object, NULL in case of error.
   2228  1.1  christos  *
   2229  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2230  1.1  christos  *
   2231  1.1  christos  * @ingroup hx509_name
   2232  1.1  christos  */
   2233  1.1  christos 
   2234  1.1  christos int
   2235  1.1  christos hx509_parse_name (
   2236  1.1  christos 	hx509_context /*context*/,
   2237  1.1  christos 	const char */*str*/,
   2238  1.1  christos 	hx509_name */*name*/);
   2239  1.1  christos 
   2240  1.1  christos int
   2241  1.1  christos hx509_parse_private_key (
   2242  1.1  christos 	hx509_context /*context*/,
   2243  1.1  christos 	const AlgorithmIdentifier */*keyai*/,
   2244  1.1  christos 	const void */*data*/,
   2245  1.1  christos 	size_t /*len*/,
   2246  1.1  christos 	hx509_key_format_t /*format*/,
   2247  1.1  christos 	hx509_private_key */*private_key*/);
   2248  1.1  christos 
   2249  1.1  christos /**
   2250  1.1  christos  * Add an additional algorithm that the peer supports.
   2251  1.1  christos  *
   2252  1.1  christos  * @param context A hx509 context.
   2253  1.1  christos  * @param peer the peer to set the new algorithms for
   2254  1.1  christos  * @param val an AlgorithmsIdentier to add
   2255  1.1  christos  *
   2256  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2257  1.1  christos  *
   2258  1.1  christos  * @ingroup hx509_peer
   2259  1.1  christos  */
   2260  1.1  christos 
   2261  1.1  christos int
   2262  1.1  christos hx509_peer_info_add_cms_alg (
   2263  1.1  christos 	hx509_context /*context*/,
   2264  1.1  christos 	hx509_peer_info /*peer*/,
   2265  1.1  christos 	const AlgorithmIdentifier */*val*/);
   2266  1.1  christos 
   2267  1.1  christos /**
   2268  1.1  christos  * Allocate a new peer info structure an init it to default values.
   2269  1.1  christos  *
   2270  1.1  christos  * @param context A hx509 context.
   2271  1.1  christos  * @param peer return an allocated peer, free with hx509_peer_info_free().
   2272  1.1  christos  *
   2273  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2274  1.1  christos  *
   2275  1.1  christos  * @ingroup hx509_peer
   2276  1.1  christos  */
   2277  1.1  christos 
   2278  1.1  christos int
   2279  1.1  christos hx509_peer_info_alloc (
   2280  1.1  christos 	hx509_context /*context*/,
   2281  1.1  christos 	hx509_peer_info */*peer*/);
   2282  1.1  christos 
   2283  1.1  christos /**
   2284  1.1  christos  * Free a peer info structure.
   2285  1.1  christos  *
   2286  1.1  christos  * @param peer peer info to be freed.
   2287  1.1  christos  *
   2288  1.1  christos  * @ingroup hx509_peer
   2289  1.1  christos  */
   2290  1.1  christos 
   2291  1.1  christos void
   2292  1.1  christos hx509_peer_info_free (hx509_peer_info /*peer*/);
   2293  1.1  christos 
   2294  1.1  christos /**
   2295  1.1  christos  * Set the certificate that remote peer is using.
   2296  1.1  christos  *
   2297  1.1  christos  * @param peer peer info to update
   2298  1.1  christos  * @param cert cerificate of the remote peer.
   2299  1.1  christos  *
   2300  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2301  1.1  christos  *
   2302  1.1  christos  * @ingroup hx509_peer
   2303  1.1  christos  */
   2304  1.1  christos 
   2305  1.1  christos int
   2306  1.1  christos hx509_peer_info_set_cert (
   2307  1.1  christos 	hx509_peer_info /*peer*/,
   2308  1.1  christos 	hx509_cert /*cert*/);
   2309  1.1  christos 
   2310  1.1  christos /**
   2311  1.1  christos  * Set the algorithms that the peer supports.
   2312  1.1  christos  *
   2313  1.1  christos  * @param context A hx509 context.
   2314  1.1  christos  * @param peer the peer to set the new algorithms for
   2315  1.1  christos  * @param val array of supported AlgorithmsIdentiers
   2316  1.1  christos  * @param len length of array val.
   2317  1.1  christos  *
   2318  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2319  1.1  christos  *
   2320  1.1  christos  * @ingroup hx509_peer
   2321  1.1  christos  */
   2322  1.1  christos 
   2323  1.1  christos int
   2324  1.1  christos hx509_peer_info_set_cms_algs (
   2325  1.1  christos 	hx509_context /*context*/,
   2326  1.1  christos 	hx509_peer_info /*peer*/,
   2327  1.1  christos 	const AlgorithmIdentifier */*val*/,
   2328  1.1  christos 	size_t /*len*/);
   2329  1.1  christos 
   2330  1.1  christos int
   2331  1.1  christos hx509_pem_add_header (
   2332  1.1  christos 	hx509_pem_header **/*headers*/,
   2333  1.1  christos 	const char */*header*/,
   2334  1.1  christos 	const char */*value*/);
   2335  1.1  christos 
   2336  1.1  christos const char *
   2337  1.1  christos hx509_pem_find_header (
   2338  1.1  christos 	const hx509_pem_header */*h*/,
   2339  1.1  christos 	const char */*header*/);
   2340  1.1  christos 
   2341  1.1  christos void
   2342  1.1  christos hx509_pem_free_header (hx509_pem_header */*headers*/);
   2343  1.1  christos 
   2344  1.1  christos int
   2345  1.1  christos hx509_pem_read (
   2346  1.1  christos 	hx509_context /*context*/,
   2347  1.1  christos 	FILE */*f*/,
   2348  1.1  christos 	hx509_pem_read_func /*func*/,
   2349  1.1  christos 	void */*ctx*/);
   2350  1.1  christos 
   2351  1.1  christos int
   2352  1.1  christos hx509_pem_write (
   2353  1.1  christos 	hx509_context /*context*/,
   2354  1.1  christos 	const char */*type*/,
   2355  1.1  christos 	hx509_pem_header */*headers*/,
   2356  1.1  christos 	FILE */*f*/,
   2357  1.1  christos 	const void */*data*/,
   2358  1.1  christos 	size_t /*size*/);
   2359  1.1  christos 
   2360  1.1  christos /**
   2361  1.1  christos  * Print a simple representation of a certificate
   2362  1.1  christos  *
   2363  1.1  christos  * @param context A hx509 context, can be NULL
   2364  1.1  christos  * @param cert certificate to print
   2365  1.1  christos  * @param out the stdio output stream, if NULL, stdout is used
   2366  1.1  christos  *
   2367  1.1  christos  * @return An hx509 error code
   2368  1.1  christos  *
   2369  1.1  christos  * @ingroup hx509_cert
   2370  1.1  christos  */
   2371  1.1  christos 
   2372  1.1  christos int
   2373  1.1  christos hx509_print_cert (
   2374  1.1  christos 	hx509_context /*context*/,
   2375  1.1  christos 	hx509_cert /*cert*/,
   2376  1.1  christos 	FILE */*out*/);
   2377  1.1  christos 
   2378  1.1  christos /**
   2379  1.1  christos  * Helper function to print on stdout for:
   2380  1.1  christos  * - hx509_oid_print(),
   2381  1.1  christos  * - hx509_bitstring_print(),
   2382  1.1  christos  * - hx509_validate_ctx_set_print().
   2383  1.1  christos  *
   2384  1.1  christos  * @param ctx the context to the print function. If the ctx is NULL,
   2385  1.1  christos  * stdout is used.
   2386  1.1  christos  * @param fmt the printing format.
   2387  1.1  christos  * @param va the argumet list.
   2388  1.1  christos  *
   2389  1.1  christos  * @ingroup hx509_print
   2390  1.1  christos  */
   2391  1.1  christos 
   2392  1.1  christos void
   2393  1.1  christos hx509_print_stdout (
   2394  1.1  christos 	void */*ctx*/,
   2395  1.1  christos 	const char */*fmt*/,
   2396  1.1  christos 	va_list /*va*/);
   2397  1.1  christos 
   2398  1.1  christos int
   2399  1.1  christos hx509_private_key2SPKI (
   2400  1.1  christos 	hx509_context /*context*/,
   2401  1.1  christos 	hx509_private_key /*private_key*/,
   2402  1.1  christos 	SubjectPublicKeyInfo */*spki*/);
   2403  1.1  christos 
   2404  1.1  christos void
   2405  1.1  christos hx509_private_key_assign_rsa (
   2406  1.1  christos 	hx509_private_key /*key*/,
   2407  1.1  christos 	void */*ptr*/);
   2408  1.1  christos 
   2409  1.1  christos int
   2410  1.1  christos hx509_private_key_free (hx509_private_key */*key*/);
   2411  1.1  christos 
   2412  1.1  christos int
   2413  1.1  christos hx509_private_key_init (
   2414  1.1  christos 	hx509_private_key */*key*/,
   2415  1.1  christos 	hx509_private_key_ops */*ops*/,
   2416  1.1  christos 	void */*keydata*/);
   2417  1.1  christos 
   2418  1.1  christos int
   2419  1.1  christos hx509_private_key_private_decrypt (
   2420  1.1  christos 	hx509_context /*context*/,
   2421  1.1  christos 	const heim_octet_string */*ciphertext*/,
   2422  1.1  christos 	const heim_oid */*encryption_oid*/,
   2423  1.1  christos 	hx509_private_key /*p*/,
   2424  1.1  christos 	heim_octet_string */*cleartext*/);
   2425  1.1  christos 
   2426  1.1  christos int
   2427  1.1  christos hx509_prompt_hidden (hx509_prompt_type /*type*/);
   2428  1.1  christos 
   2429  1.1  christos /**
   2430  1.1  christos  * Allocate an query controller. Free using hx509_query_free().
   2431  1.1  christos  *
   2432  1.1  christos  * @param context A hx509 context.
   2433  1.1  christos  * @param q return pointer to a hx509_query.
   2434  1.1  christos  *
   2435  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2436  1.1  christos  *
   2437  1.1  christos  * @ingroup hx509_cert
   2438  1.1  christos  */
   2439  1.1  christos 
   2440  1.1  christos int
   2441  1.1  christos hx509_query_alloc (
   2442  1.1  christos 	hx509_context /*context*/,
   2443  1.1  christos 	hx509_query **/*q*/);
   2444  1.1  christos 
   2445  1.1  christos /**
   2446  1.1  christos  * Free the query controller.
   2447  1.1  christos  *
   2448  1.1  christos  * @param context A hx509 context.
   2449  1.1  christos  * @param q a pointer to the query controller.
   2450  1.1  christos  *
   2451  1.1  christos  * @ingroup hx509_cert
   2452  1.1  christos  */
   2453  1.1  christos 
   2454  1.1  christos void
   2455  1.1  christos hx509_query_free (
   2456  1.1  christos 	hx509_context /*context*/,
   2457  1.1  christos 	hx509_query */*q*/);
   2458  1.1  christos 
   2459  1.1  christos /**
   2460  1.1  christos  * Set the query controller to match using a specific match function.
   2461  1.1  christos  *
   2462  1.1  christos  * @param q a hx509 query controller.
   2463  1.1  christos  * @param func function to use for matching, if the argument is NULL,
   2464  1.1  christos  * the match function is removed.
   2465  1.1  christos  * @param ctx context passed to the function.
   2466  1.1  christos  *
   2467  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2468  1.1  christos  *
   2469  1.1  christos  * @ingroup hx509_cert
   2470  1.1  christos  */
   2471  1.1  christos 
   2472  1.1  christos int
   2473  1.1  christos hx509_query_match_cmp_func (
   2474  1.1  christos 	hx509_query */*q*/,
   2475  1.1  christos 	int (*/*func*/)(hx509_context, hx509_cert, void *),
   2476  1.1  christos 	void */*ctx*/);
   2477  1.1  christos 
   2478  1.1  christos /**
   2479  1.1  christos  * Set the query controller to require an one specific EKU (extended
   2480  1.1  christos  * key usage). Any previous EKU matching is overwitten. If NULL is
   2481  1.1  christos  * passed in as the eku, the EKU requirement is reset.
   2482  1.1  christos  *
   2483  1.1  christos  * @param q a hx509 query controller.
   2484  1.1  christos  * @param eku an EKU to match on.
   2485  1.1  christos  *
   2486  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2487  1.1  christos  *
   2488  1.1  christos  * @ingroup hx509_cert
   2489  1.1  christos  */
   2490  1.1  christos 
   2491  1.1  christos int
   2492  1.1  christos hx509_query_match_eku (
   2493  1.1  christos 	hx509_query */*q*/,
   2494  1.1  christos 	const heim_oid */*eku*/);
   2495  1.1  christos 
   2496  1.1  christos int
   2497  1.1  christos hx509_query_match_expr (
   2498  1.1  christos 	hx509_context /*context*/,
   2499  1.1  christos 	hx509_query */*q*/,
   2500  1.1  christos 	const char */*expr*/);
   2501  1.1  christos 
   2502  1.1  christos /**
   2503  1.1  christos  * Set the query controller to match on a friendly name
   2504  1.1  christos  *
   2505  1.1  christos  * @param q a hx509 query controller.
   2506  1.1  christos  * @param name a friendly name to match on
   2507  1.1  christos  *
   2508  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2509  1.1  christos  *
   2510  1.1  christos  * @ingroup hx509_cert
   2511  1.1  christos  */
   2512  1.1  christos 
   2513  1.1  christos int
   2514  1.1  christos hx509_query_match_friendly_name (
   2515  1.1  christos 	hx509_query */*q*/,
   2516  1.1  christos 	const char */*name*/);
   2517  1.1  christos 
   2518  1.1  christos /**
   2519  1.1  christos  * Set the issuer and serial number of match in the query
   2520  1.1  christos  * controller. The function make copies of the isser and serial number.
   2521  1.1  christos  *
   2522  1.1  christos  * @param q a hx509 query controller
   2523  1.1  christos  * @param issuer issuer to search for
   2524  1.1  christos  * @param serialNumber the serialNumber of the issuer.
   2525  1.1  christos  *
   2526  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2527  1.1  christos  *
   2528  1.1  christos  * @ingroup hx509_cert
   2529  1.1  christos  */
   2530  1.1  christos 
   2531  1.1  christos int
   2532  1.1  christos hx509_query_match_issuer_serial (
   2533  1.1  christos 	hx509_query */*q*/,
   2534  1.1  christos 	const Name */*issuer*/,
   2535  1.1  christos 	const heim_integer */*serialNumber*/);
   2536  1.1  christos 
   2537  1.1  christos /**
   2538  1.1  christos  * Set match options for the hx509 query controller.
   2539  1.1  christos  *
   2540  1.1  christos  * @param q query controller.
   2541  1.1  christos  * @param option options to control the query controller.
   2542  1.1  christos  *
   2543  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2544  1.1  christos  *
   2545  1.1  christos  * @ingroup hx509_cert
   2546  1.1  christos  */
   2547  1.1  christos 
   2548  1.1  christos void
   2549  1.1  christos hx509_query_match_option (
   2550  1.1  christos 	hx509_query */*q*/,
   2551  1.1  christos 	hx509_query_option /*option*/);
   2552  1.1  christos 
   2553  1.1  christos /**
   2554  1.1  christos  * Set a statistic file for the query statistics.
   2555  1.1  christos  *
   2556  1.1  christos  * @param context A hx509 context.
   2557  1.1  christos  * @param fn statistics file name
   2558  1.1  christos  *
   2559  1.1  christos  * @ingroup hx509_cert
   2560  1.1  christos  */
   2561  1.1  christos 
   2562  1.1  christos void
   2563  1.1  christos hx509_query_statistic_file (
   2564  1.1  christos 	hx509_context /*context*/,
   2565  1.1  christos 	const char */*fn*/);
   2566  1.1  christos 
   2567  1.1  christos /**
   2568  1.1  christos  * Unparse the statistics file and print the result on a FILE descriptor.
   2569  1.1  christos  *
   2570  1.1  christos  * @param context A hx509 context.
   2571  1.1  christos  * @param printtype tyep to print
   2572  1.1  christos  * @param out the FILE to write the data on.
   2573  1.1  christos  *
   2574  1.1  christos  * @ingroup hx509_cert
   2575  1.1  christos  */
   2576  1.1  christos 
   2577  1.1  christos void
   2578  1.1  christos hx509_query_unparse_stats (
   2579  1.1  christos 	hx509_context /*context*/,
   2580  1.1  christos 	int /*printtype*/,
   2581  1.1  christos 	FILE */*out*/);
   2582  1.1  christos 
   2583  1.1  christos void
   2584  1.1  christos hx509_request_free (hx509_request */*req*/);
   2585  1.1  christos 
   2586  1.1  christos int
   2587  1.1  christos hx509_request_get_SubjectPublicKeyInfo (
   2588  1.1  christos 	hx509_context /*context*/,
   2589  1.1  christos 	hx509_request /*req*/,
   2590  1.1  christos 	SubjectPublicKeyInfo */*key*/);
   2591  1.1  christos 
   2592  1.1  christos int
   2593  1.1  christos hx509_request_get_name (
   2594  1.1  christos 	hx509_context /*context*/,
   2595  1.1  christos 	hx509_request /*req*/,
   2596  1.1  christos 	hx509_name */*name*/);
   2597  1.1  christos 
   2598  1.1  christos int
   2599  1.1  christos hx509_request_init (
   2600  1.1  christos 	hx509_context /*context*/,
   2601  1.1  christos 	hx509_request */*req*/);
   2602  1.1  christos 
   2603  1.1  christos int
   2604  1.1  christos hx509_request_set_SubjectPublicKeyInfo (
   2605  1.1  christos 	hx509_context /*context*/,
   2606  1.1  christos 	hx509_request /*req*/,
   2607  1.1  christos 	const SubjectPublicKeyInfo */*key*/);
   2608  1.1  christos 
   2609  1.1  christos int
   2610  1.1  christos hx509_request_set_name (
   2611  1.1  christos 	hx509_context /*context*/,
   2612  1.1  christos 	hx509_request /*req*/,
   2613  1.1  christos 	hx509_name /*name*/);
   2614  1.1  christos 
   2615  1.1  christos /**
   2616  1.1  christos  * Add a CRL file to the revokation context.
   2617  1.1  christos  *
   2618  1.1  christos  * @param context hx509 context
   2619  1.1  christos  * @param ctx hx509 revokation context
   2620  1.1  christos  * @param path path to file that is going to be added to the context.
   2621  1.1  christos  *
   2622  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2623  1.1  christos  *
   2624  1.1  christos  * @ingroup hx509_revoke
   2625  1.1  christos  */
   2626  1.1  christos 
   2627  1.1  christos int
   2628  1.1  christos hx509_revoke_add_crl (
   2629  1.1  christos 	hx509_context /*context*/,
   2630  1.1  christos 	hx509_revoke_ctx /*ctx*/,
   2631  1.1  christos 	const char */*path*/);
   2632  1.1  christos 
   2633  1.1  christos /**
   2634  1.1  christos  * Add a OCSP file to the revokation context.
   2635  1.1  christos  *
   2636  1.1  christos  * @param context hx509 context
   2637  1.1  christos  * @param ctx hx509 revokation context
   2638  1.1  christos  * @param path path to file that is going to be added to the context.
   2639  1.1  christos  *
   2640  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2641  1.1  christos  *
   2642  1.1  christos  * @ingroup hx509_revoke
   2643  1.1  christos  */
   2644  1.1  christos 
   2645  1.1  christos int
   2646  1.1  christos hx509_revoke_add_ocsp (
   2647  1.1  christos 	hx509_context /*context*/,
   2648  1.1  christos 	hx509_revoke_ctx /*ctx*/,
   2649  1.1  christos 	const char */*path*/);
   2650  1.1  christos 
   2651  1.1  christos /**
   2652  1.1  christos  * Free a hx509 revokation context.
   2653  1.1  christos  *
   2654  1.1  christos  * @param ctx context to be freed
   2655  1.1  christos  *
   2656  1.1  christos  * @ingroup hx509_revoke
   2657  1.1  christos  */
   2658  1.1  christos 
   2659  1.1  christos void
   2660  1.1  christos hx509_revoke_free (hx509_revoke_ctx */*ctx*/);
   2661  1.1  christos 
   2662  1.1  christos /**
   2663  1.1  christos  * Allocate a revokation context. Free with hx509_revoke_free().
   2664  1.1  christos  *
   2665  1.1  christos  * @param context A hx509 context.
   2666  1.1  christos  * @param ctx returns a newly allocated revokation context.
   2667  1.1  christos  *
   2668  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2669  1.1  christos  *
   2670  1.1  christos  * @ingroup hx509_revoke
   2671  1.1  christos  */
   2672  1.1  christos 
   2673  1.1  christos int
   2674  1.1  christos hx509_revoke_init (
   2675  1.1  christos 	hx509_context /*context*/,
   2676  1.1  christos 	hx509_revoke_ctx */*ctx*/);
   2677  1.1  christos 
   2678  1.1  christos /**
   2679  1.1  christos  * Print the OCSP reply stored in a file.
   2680  1.1  christos  *
   2681  1.1  christos  * @param context a hx509 context
   2682  1.1  christos  * @param path path to a file with a OCSP reply
   2683  1.1  christos  * @param out the out FILE descriptor to print the reply on
   2684  1.1  christos  *
   2685  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2686  1.1  christos  *
   2687  1.1  christos  * @ingroup hx509_revoke
   2688  1.1  christos  */
   2689  1.1  christos 
   2690  1.1  christos int
   2691  1.1  christos hx509_revoke_ocsp_print (
   2692  1.1  christos 	hx509_context /*context*/,
   2693  1.1  christos 	const char */*path*/,
   2694  1.1  christos 	FILE */*out*/);
   2695  1.1  christos 
   2696  1.1  christos int
   2697  1.1  christos hx509_revoke_print (
   2698  1.1  christos 	hx509_context /*context*/,
   2699  1.1  christos 	hx509_revoke_ctx /*ctx*/,
   2700  1.1  christos 	FILE */*out*/);
   2701  1.1  christos 
   2702  1.1  christos /**
   2703  1.1  christos  * Check that a certificate is not expired according to a revokation
   2704  1.1  christos  * context. Also need the parent certificte to the check OCSP
   2705  1.1  christos  * parent identifier.
   2706  1.1  christos  *
   2707  1.1  christos  * @param context hx509 context
   2708  1.1  christos  * @param ctx hx509 revokation context
   2709  1.1  christos  * @param certs
   2710  1.1  christos  * @param now
   2711  1.1  christos  * @param cert
   2712  1.1  christos  * @param parent_cert
   2713  1.1  christos  *
   2714  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2715  1.1  christos  *
   2716  1.1  christos  * @ingroup hx509_revoke
   2717  1.1  christos  */
   2718  1.1  christos 
   2719  1.1  christos int
   2720  1.1  christos hx509_revoke_verify (
   2721  1.1  christos 	hx509_context /*context*/,
   2722  1.1  christos 	hx509_revoke_ctx /*ctx*/,
   2723  1.1  christos 	hx509_certs /*certs*/,
   2724  1.1  christos 	time_t /*now*/,
   2725  1.1  christos 	hx509_cert /*cert*/,
   2726  1.1  christos 	hx509_cert /*parent_cert*/);
   2727  1.1  christos 
   2728  1.1  christos /**
   2729  1.1  christos  * See hx509_set_error_stringv().
   2730  1.1  christos  *
   2731  1.1  christos  * @param context A hx509 context.
   2732  1.1  christos  * @param flags
   2733  1.1  christos  * - HX509_ERROR_APPEND appends the error string to the old messages
   2734  1.1  christos      (code is updated).
   2735  1.1  christos  * @param code error code related to error message
   2736  1.1  christos  * @param fmt error message format
   2737  1.1  christos  * @param ... arguments to error message format
   2738  1.1  christos  *
   2739  1.1  christos  * @ingroup hx509_error
   2740  1.1  christos  */
   2741  1.1  christos 
   2742  1.1  christos void
   2743  1.1  christos hx509_set_error_string (
   2744  1.1  christos 	hx509_context /*context*/,
   2745  1.1  christos 	int /*flags*/,
   2746  1.1  christos 	int /*code*/,
   2747  1.1  christos 	const char */*fmt*/,
   2748  1.1  christos 	...);
   2749  1.1  christos 
   2750  1.1  christos /**
   2751  1.1  christos  * Add an error message to the hx509 context.
   2752  1.1  christos  *
   2753  1.1  christos  * @param context A hx509 context.
   2754  1.1  christos  * @param flags
   2755  1.1  christos  * - HX509_ERROR_APPEND appends the error string to the old messages
   2756  1.1  christos      (code is updated).
   2757  1.1  christos  * @param code error code related to error message
   2758  1.1  christos  * @param fmt error message format
   2759  1.1  christos  * @param ap arguments to error message format
   2760  1.1  christos  *
   2761  1.1  christos  * @ingroup hx509_error
   2762  1.1  christos  */
   2763  1.1  christos 
   2764  1.1  christos void
   2765  1.1  christos hx509_set_error_stringv (
   2766  1.1  christos 	hx509_context /*context*/,
   2767  1.1  christos 	int /*flags*/,
   2768  1.1  christos 	int /*code*/,
   2769  1.1  christos 	const char */*fmt*/,
   2770  1.1  christos 	va_list /*ap*/);
   2771  1.1  christos 
   2772  1.1  christos const AlgorithmIdentifier *
   2773  1.1  christos hx509_signature_ecPublicKey (void);
   2774  1.1  christos 
   2775  1.1  christos const AlgorithmIdentifier *
   2776  1.1  christos hx509_signature_ecdsa_with_sha256 (void);
   2777  1.1  christos 
   2778  1.1  christos const AlgorithmIdentifier *
   2779  1.1  christos hx509_signature_md5 (void);
   2780  1.1  christos 
   2781  1.1  christos const AlgorithmIdentifier *
   2782  1.1  christos hx509_signature_rsa (void);
   2783  1.1  christos 
   2784  1.1  christos const AlgorithmIdentifier *
   2785  1.1  christos hx509_signature_rsa_pkcs1_x509 (void);
   2786  1.1  christos 
   2787  1.1  christos const AlgorithmIdentifier *
   2788  1.1  christos hx509_signature_rsa_with_md5 (void);
   2789  1.1  christos 
   2790  1.1  christos const AlgorithmIdentifier *
   2791  1.1  christos hx509_signature_rsa_with_sha1 (void);
   2792  1.1  christos 
   2793  1.1  christos const AlgorithmIdentifier *
   2794  1.1  christos hx509_signature_rsa_with_sha256 (void);
   2795  1.1  christos 
   2796  1.1  christos const AlgorithmIdentifier *
   2797  1.1  christos hx509_signature_rsa_with_sha384 (void);
   2798  1.1  christos 
   2799  1.1  christos const AlgorithmIdentifier *
   2800  1.1  christos hx509_signature_rsa_with_sha512 (void);
   2801  1.1  christos 
   2802  1.1  christos const AlgorithmIdentifier *
   2803  1.1  christos hx509_signature_sha1 (void);
   2804  1.1  christos 
   2805  1.1  christos const AlgorithmIdentifier *
   2806  1.1  christos hx509_signature_sha256 (void);
   2807  1.1  christos 
   2808  1.1  christos const AlgorithmIdentifier *
   2809  1.1  christos hx509_signature_sha384 (void);
   2810  1.1  christos 
   2811  1.1  christos const AlgorithmIdentifier *
   2812  1.1  christos hx509_signature_sha512 (void);
   2813  1.1  christos 
   2814  1.1  christos /**
   2815  1.1  christos  * Convert a DER encoded name info a string.
   2816  1.1  christos  *
   2817  1.1  christos  * @param data data to a DER/BER encoded name
   2818  1.1  christos  * @param length length of data
   2819  1.1  christos  * @param str the resulting string, is NULL on failure.
   2820  1.1  christos  *
   2821  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2822  1.1  christos  *
   2823  1.1  christos  * @ingroup hx509_name
   2824  1.1  christos  */
   2825  1.1  christos 
   2826  1.1  christos int
   2827  1.1  christos hx509_unparse_der_name (
   2828  1.1  christos 	const void */*data*/,
   2829  1.1  christos 	size_t /*length*/,
   2830  1.1  christos 	char **/*str*/);
   2831  1.1  christos 
   2832  1.1  christos /**
   2833  1.1  christos  * Validate/Print the status of the certificate.
   2834  1.1  christos  *
   2835  1.1  christos  * @param context A hx509 context.
   2836  1.1  christos  * @param ctx A hx509 validation context.
   2837  1.1  christos  * @param cert the cerificate to validate/print.
   2838  1.1  christos 
   2839  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2840  1.1  christos  *
   2841  1.1  christos  * @ingroup hx509_print
   2842  1.1  christos  */
   2843  1.1  christos 
   2844  1.1  christos int
   2845  1.1  christos hx509_validate_cert (
   2846  1.1  christos 	hx509_context /*context*/,
   2847  1.1  christos 	hx509_validate_ctx /*ctx*/,
   2848  1.1  christos 	hx509_cert /*cert*/);
   2849  1.1  christos 
   2850  1.1  christos /**
   2851  1.1  christos  * Add flags to control the behaivor of the hx509_validate_cert()
   2852  1.1  christos  * function.
   2853  1.1  christos  *
   2854  1.1  christos  * @param ctx A hx509 validation context.
   2855  1.1  christos  * @param flags flags to add to the validation context.
   2856  1.1  christos  *
   2857  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2858  1.1  christos  *
   2859  1.1  christos  * @ingroup hx509_print
   2860  1.1  christos  */
   2861  1.1  christos 
   2862  1.1  christos void
   2863  1.1  christos hx509_validate_ctx_add_flags (
   2864  1.1  christos 	hx509_validate_ctx /*ctx*/,
   2865  1.1  christos 	int /*flags*/);
   2866  1.1  christos 
   2867  1.1  christos /**
   2868  1.1  christos  * Free an hx509 validate context.
   2869  1.1  christos  *
   2870  1.1  christos  * @param ctx the hx509 validate context to free.
   2871  1.1  christos  *
   2872  1.1  christos  * @ingroup hx509_print
   2873  1.1  christos  */
   2874  1.1  christos 
   2875  1.1  christos void
   2876  1.1  christos hx509_validate_ctx_free (hx509_validate_ctx /*ctx*/);
   2877  1.1  christos 
   2878  1.1  christos /**
   2879  1.1  christos  * Allocate a hx509 validation/printing context.
   2880  1.1  christos  *
   2881  1.1  christos  * @param context A hx509 context.
   2882  1.1  christos  * @param ctx a new allocated hx509 validation context, free with
   2883  1.1  christos  * hx509_validate_ctx_free().
   2884  1.1  christos 
   2885  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2886  1.1  christos  *
   2887  1.1  christos  * @ingroup hx509_print
   2888  1.1  christos  */
   2889  1.1  christos 
   2890  1.1  christos int
   2891  1.1  christos hx509_validate_ctx_init (
   2892  1.1  christos 	hx509_context /*context*/,
   2893  1.1  christos 	hx509_validate_ctx */*ctx*/);
   2894  1.1  christos 
   2895  1.1  christos /**
   2896  1.1  christos  * Set the printing functions for the validation context.
   2897  1.1  christos  *
   2898  1.1  christos  * @param ctx a hx509 valication context.
   2899  1.1  christos  * @param func the printing function to usea.
   2900  1.1  christos  * @param c the context variable to the printing function.
   2901  1.1  christos  *
   2902  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2903  1.1  christos  *
   2904  1.1  christos  * @ingroup hx509_print
   2905  1.1  christos  */
   2906  1.1  christos 
   2907  1.1  christos void
   2908  1.1  christos hx509_validate_ctx_set_print (
   2909  1.1  christos 	hx509_validate_ctx /*ctx*/,
   2910  1.1  christos 	hx509_vprint_func /*func*/,
   2911  1.1  christos 	void */*c*/);
   2912  1.1  christos 
   2913  1.1  christos /**
   2914  1.1  christos  * Set the trust anchors in the verification context, makes an
   2915  1.1  christos  * reference to the keyset, so the consumer can free the keyset
   2916  1.1  christos  * independent of the destruction of the verification context (ctx).
   2917  1.1  christos  * If there already is a keyset attached, it's released.
   2918  1.1  christos  *
   2919  1.1  christos  * @param ctx a verification context
   2920  1.1  christos  * @param set a keyset containing the trust anchors.
   2921  1.1  christos  *
   2922  1.1  christos  * @ingroup hx509_verify
   2923  1.1  christos  */
   2924  1.1  christos 
   2925  1.1  christos void
   2926  1.1  christos hx509_verify_attach_anchors (
   2927  1.1  christos 	hx509_verify_ctx /*ctx*/,
   2928  1.1  christos 	hx509_certs /*set*/);
   2929  1.1  christos 
   2930  1.1  christos /**
   2931  1.1  christos  * Attach an revocation context to the verfication context, , makes an
   2932  1.1  christos  * reference to the revoke context, so the consumer can free the
   2933  1.1  christos  * revoke context independent of the destruction of the verification
   2934  1.1  christos  * context. If there is no revoke context, the verification process is
   2935  1.1  christos  * NOT going to check any verification status.
   2936  1.1  christos  *
   2937  1.1  christos  * @param ctx a verification context.
   2938  1.1  christos  * @param revoke_ctx a revoke context.
   2939  1.1  christos  *
   2940  1.1  christos  * @ingroup hx509_verify
   2941  1.1  christos  */
   2942  1.1  christos 
   2943  1.1  christos void
   2944  1.1  christos hx509_verify_attach_revoke (
   2945  1.1  christos 	hx509_verify_ctx /*ctx*/,
   2946  1.1  christos 	hx509_revoke_ctx /*revoke_ctx*/);
   2947  1.1  christos 
   2948  1.1  christos void
   2949  1.1  christos hx509_verify_ctx_f_allow_best_before_signature_algs (
   2950  1.1  christos 	hx509_context /*ctx*/,
   2951  1.1  christos 	int /*boolean*/);
   2952  1.1  christos 
   2953  1.1  christos /**
   2954  1.1  christos  * Allow using the operating system builtin trust anchors if no other
   2955  1.1  christos  * trust anchors are configured.
   2956  1.1  christos  *
   2957  1.1  christos  * @param ctx a verification context
   2958  1.1  christos  * @param boolean if non zero, useing the operating systems builtin
   2959  1.1  christos  * trust anchors.
   2960  1.1  christos  *
   2961  1.1  christos  *
   2962  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2963  1.1  christos  *
   2964  1.1  christos  * @ingroup hx509_cert
   2965  1.1  christos  */
   2966  1.1  christos 
   2967  1.1  christos void
   2968  1.1  christos hx509_verify_ctx_f_allow_default_trustanchors (
   2969  1.1  christos 	hx509_verify_ctx /*ctx*/,
   2970  1.1  christos 	int /*boolean*/);
   2971  1.1  christos 
   2972  1.1  christos /**
   2973  1.1  christos  * Free an hx509 verification context.
   2974  1.1  christos  *
   2975  1.1  christos  * @param ctx the context to be freed.
   2976  1.1  christos  *
   2977  1.1  christos  * @ingroup hx509_verify
   2978  1.1  christos  */
   2979  1.1  christos 
   2980  1.1  christos void
   2981  1.1  christos hx509_verify_destroy_ctx (hx509_verify_ctx /*ctx*/);
   2982  1.1  christos 
   2983  1.1  christos /**
   2984  1.1  christos  * Verify that the certificate is allowed to be used for the hostname
   2985  1.1  christos  * and address.
   2986  1.1  christos  *
   2987  1.1  christos  * @param context A hx509 context.
   2988  1.1  christos  * @param cert the certificate to match with
   2989  1.1  christos  * @param flags Flags to modify the behavior:
   2990  1.1  christos  * - HX509_VHN_F_ALLOW_NO_MATCH no match is ok
   2991  1.1  christos  * @param type type of hostname:
   2992  1.1  christos  * - HX509_HN_HOSTNAME for plain hostname.
   2993  1.1  christos  * - HX509_HN_DNSSRV for DNS SRV names.
   2994  1.1  christos  * @param hostname the hostname to check
   2995  1.1  christos  * @param sa address of the host
   2996  1.1  christos  * @param sa_size length of address
   2997  1.1  christos  *
   2998  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   2999  1.1  christos  *
   3000  1.1  christos  * @ingroup hx509_cert
   3001  1.1  christos  */
   3002  1.1  christos 
   3003  1.1  christos int
   3004  1.1  christos hx509_verify_hostname (
   3005  1.1  christos 	hx509_context /*context*/,
   3006  1.1  christos 	const hx509_cert /*cert*/,
   3007  1.1  christos 	int /*flags*/,
   3008  1.1  christos 	hx509_hostname_type /*type*/,
   3009  1.1  christos 	const char */*hostname*/,
   3010  1.1  christos 	const struct sockaddr */*sa*/,
   3011  1.1  christos 	int /*sa_size*/);
   3012  1.1  christos 
   3013  1.1  christos /**
   3014  1.1  christos  * Allocate an verification context that is used fo control the
   3015  1.1  christos  * verification process.
   3016  1.1  christos  *
   3017  1.1  christos  * @param context A hx509 context.
   3018  1.1  christos  * @param ctx returns a pointer to a hx509_verify_ctx object.
   3019  1.1  christos  *
   3020  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   3021  1.1  christos  *
   3022  1.1  christos  * @ingroup hx509_verify
   3023  1.1  christos  */
   3024  1.1  christos 
   3025  1.1  christos int
   3026  1.1  christos hx509_verify_init_ctx (
   3027  1.1  christos 	hx509_context /*context*/,
   3028  1.1  christos 	hx509_verify_ctx */*ctx*/);
   3029  1.1  christos 
   3030  1.1  christos /**
   3031  1.1  christos  * Build and verify the path for the certificate to the trust anchor
   3032  1.1  christos  * specified in the verify context. The path is constructed from the
   3033  1.1  christos  * certificate, the pool and the trust anchors.
   3034  1.1  christos  *
   3035  1.1  christos  * @param context A hx509 context.
   3036  1.1  christos  * @param ctx A hx509 verification context.
   3037  1.1  christos  * @param cert the certificate to build the path from.
   3038  1.1  christos  * @param pool A keyset of certificates to build the chain from.
   3039  1.1  christos  *
   3040  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   3041  1.1  christos  *
   3042  1.1  christos  * @ingroup hx509_verify
   3043  1.1  christos  */
   3044  1.1  christos 
   3045  1.1  christos int
   3046  1.1  christos hx509_verify_path (
   3047  1.1  christos 	hx509_context /*context*/,
   3048  1.1  christos 	hx509_verify_ctx /*ctx*/,
   3049  1.1  christos 	hx509_cert /*cert*/,
   3050  1.1  christos 	hx509_certs /*pool*/);
   3051  1.1  christos 
   3052  1.1  christos /**
   3053  1.1  christos  * Set the maximum depth of the certificate chain that the path
   3054  1.1  christos  * builder is going to try.
   3055  1.1  christos  *
   3056  1.1  christos  * @param ctx a verification context
   3057  1.1  christos  * @param max_depth maxium depth of the certificate chain, include
   3058  1.1  christos  * trust anchor.
   3059  1.1  christos  *
   3060  1.1  christos  * @ingroup hx509_verify
   3061  1.1  christos  */
   3062  1.1  christos 
   3063  1.1  christos void
   3064  1.1  christos hx509_verify_set_max_depth (
   3065  1.1  christos 	hx509_verify_ctx /*ctx*/,
   3066  1.1  christos 	unsigned int /*max_depth*/);
   3067  1.1  christos 
   3068  1.1  christos /**
   3069  1.1  christos  * Allow or deny the use of proxy certificates
   3070  1.1  christos  *
   3071  1.1  christos  * @param ctx a verification context
   3072  1.1  christos  * @param boolean if non zero, allow proxy certificates.
   3073  1.1  christos  *
   3074  1.1  christos  * @ingroup hx509_verify
   3075  1.1  christos  */
   3076  1.1  christos 
   3077  1.1  christos void
   3078  1.1  christos hx509_verify_set_proxy_certificate (
   3079  1.1  christos 	hx509_verify_ctx /*ctx*/,
   3080  1.1  christos 	int /*boolean*/);
   3081  1.1  christos 
   3082  1.1  christos /**
   3083  1.1  christos  * Select strict RFC3280 verification of certificiates. This means
   3084  1.1  christos  * checking key usage on CA certificates, this will make version 1
   3085  1.1  christos  * certificiates unuseable.
   3086  1.1  christos  *
   3087  1.1  christos  * @param ctx a verification context
   3088  1.1  christos  * @param boolean if non zero, use strict verification.
   3089  1.1  christos  *
   3090  1.1  christos  * @ingroup hx509_verify
   3091  1.1  christos  */
   3092  1.1  christos 
   3093  1.1  christos void
   3094  1.1  christos hx509_verify_set_strict_rfc3280_verification (
   3095  1.1  christos 	hx509_verify_ctx /*ctx*/,
   3096  1.1  christos 	int /*boolean*/);
   3097  1.1  christos 
   3098  1.1  christos /**
   3099  1.1  christos  * Set the clock time the the verification process is going to
   3100  1.1  christos  * use. Used to check certificate in the past and future time. If not
   3101  1.1  christos  * set the current time will be used.
   3102  1.1  christos  *
   3103  1.1  christos  * @param ctx a verification context.
   3104  1.1  christos  * @param t the time the verifiation is using.
   3105  1.1  christos  *
   3106  1.1  christos  *
   3107  1.1  christos  * @ingroup hx509_verify
   3108  1.1  christos  */
   3109  1.1  christos 
   3110  1.1  christos void
   3111  1.1  christos hx509_verify_set_time (
   3112  1.1  christos 	hx509_verify_ctx /*ctx*/,
   3113  1.1  christos 	time_t /*t*/);
   3114  1.1  christos 
   3115  1.1  christos /**
   3116  1.1  christos  * Verify a signature made using the private key of an certificate.
   3117  1.1  christos  *
   3118  1.1  christos  * @param context A hx509 context.
   3119  1.1  christos  * @param signer the certificate that made the signature.
   3120  1.1  christos  * @param alg algorthm that was used to sign the data.
   3121  1.1  christos  * @param data the data that was signed.
   3122  1.1  christos  * @param sig the sigature to verify.
   3123  1.1  christos  *
   3124  1.1  christos  * @return An hx509 error code, see hx509_get_error_string().
   3125  1.1  christos  *
   3126  1.1  christos  * @ingroup hx509_crypto
   3127  1.1  christos  */
   3128  1.1  christos 
   3129  1.1  christos int
   3130  1.1  christos hx509_verify_signature (
   3131  1.1  christos 	hx509_context /*context*/,
   3132  1.1  christos 	const hx509_cert /*signer*/,
   3133  1.1  christos 	const AlgorithmIdentifier */*alg*/,
   3134  1.1  christos 	const heim_octet_string */*data*/,
   3135  1.1  christos 	const heim_octet_string */*sig*/);
   3136  1.1  christos 
   3137  1.1  christos /**
   3138  1.1  christos  * Free a data element allocated in the library.
   3139  1.1  christos  *
   3140  1.1  christos  * @param ptr data to be freed.
   3141  1.1  christos  *
   3142  1.1  christos  * @ingroup hx509_misc
   3143  1.1  christos  */
   3144  1.1  christos 
   3145  1.1  christos void
   3146  1.1  christos hx509_xfree (void */*ptr*/);
   3147  1.1  christos 
   3148  1.1  christos int
   3149  1.1  christos yywrap (void);
   3150  1.1  christos 
   3151  1.1  christos #ifdef __cplusplus
   3152  1.1  christos }
   3153  1.1  christos #endif
   3154  1.1  christos 
   3155  1.1  christos #endif /* DOXY */
   3156  1.1  christos #endif /* __hx509_protos_h__ */
   3157