1*ebfedea0SLionel Sambuc /* $NetBSD: hx509.h,v 1.1.1.2 2011/04/14 14:08:56 elric Exp $ */ 2*ebfedea0SLionel Sambuc 3*ebfedea0SLionel Sambuc /* 4*ebfedea0SLionel Sambuc * Copyright (c) 2004 - 2007 Kungliga Tekniska Högskolan 5*ebfedea0SLionel Sambuc * (Royal Institute of Technology, Stockholm, Sweden). 6*ebfedea0SLionel Sambuc * All rights reserved. 7*ebfedea0SLionel Sambuc * 8*ebfedea0SLionel Sambuc * Redistribution and use in source and binary forms, with or without 9*ebfedea0SLionel Sambuc * modification, are permitted provided that the following conditions 10*ebfedea0SLionel Sambuc * are met: 11*ebfedea0SLionel Sambuc * 12*ebfedea0SLionel Sambuc * 1. Redistributions of source code must retain the above copyright 13*ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer. 14*ebfedea0SLionel Sambuc * 15*ebfedea0SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright 16*ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer in the 17*ebfedea0SLionel Sambuc * documentation and/or other materials provided with the distribution. 18*ebfedea0SLionel Sambuc * 19*ebfedea0SLionel Sambuc * 3. Neither the name of the Institute nor the names of its contributors 20*ebfedea0SLionel Sambuc * may be used to endorse or promote products derived from this software 21*ebfedea0SLionel Sambuc * without specific prior written permission. 22*ebfedea0SLionel Sambuc * 23*ebfedea0SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 24*ebfedea0SLionel Sambuc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25*ebfedea0SLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26*ebfedea0SLionel Sambuc * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 27*ebfedea0SLionel Sambuc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28*ebfedea0SLionel Sambuc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29*ebfedea0SLionel Sambuc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30*ebfedea0SLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31*ebfedea0SLionel Sambuc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32*ebfedea0SLionel Sambuc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33*ebfedea0SLionel Sambuc * SUCH DAMAGE. 34*ebfedea0SLionel Sambuc */ 35*ebfedea0SLionel Sambuc 36*ebfedea0SLionel Sambuc /* Id */ 37*ebfedea0SLionel Sambuc 38*ebfedea0SLionel Sambuc #ifndef HEIMDAL_HX509_H 39*ebfedea0SLionel Sambuc #define HEIMDAL_HX509_H 1 40*ebfedea0SLionel Sambuc 41*ebfedea0SLionel Sambuc #include <krb5/rfc2459_asn1.h> 42*ebfedea0SLionel Sambuc #include <stdarg.h> 43*ebfedea0SLionel Sambuc #include <stdio.h> 44*ebfedea0SLionel Sambuc 45*ebfedea0SLionel Sambuc typedef struct hx509_cert_attribute_data *hx509_cert_attribute; 46*ebfedea0SLionel Sambuc typedef struct hx509_cert_data *hx509_cert; 47*ebfedea0SLionel Sambuc typedef struct hx509_certs_data *hx509_certs; 48*ebfedea0SLionel Sambuc typedef struct hx509_context_data *hx509_context; 49*ebfedea0SLionel Sambuc typedef struct hx509_crypto_data *hx509_crypto; 50*ebfedea0SLionel Sambuc typedef struct hx509_lock_data *hx509_lock; 51*ebfedea0SLionel Sambuc typedef struct hx509_name_data *hx509_name; 52*ebfedea0SLionel Sambuc typedef struct hx509_private_key *hx509_private_key; 53*ebfedea0SLionel Sambuc typedef struct hx509_private_key_ops hx509_private_key_ops; 54*ebfedea0SLionel Sambuc typedef struct hx509_validate_ctx_data *hx509_validate_ctx; 55*ebfedea0SLionel Sambuc typedef struct hx509_verify_ctx_data *hx509_verify_ctx; 56*ebfedea0SLionel Sambuc typedef struct hx509_revoke_ctx_data *hx509_revoke_ctx; 57*ebfedea0SLionel Sambuc typedef struct hx509_query_data hx509_query; 58*ebfedea0SLionel Sambuc typedef void * hx509_cursor; 59*ebfedea0SLionel Sambuc typedef struct hx509_request_data *hx509_request; 60*ebfedea0SLionel Sambuc typedef struct hx509_error_data *hx509_error; 61*ebfedea0SLionel Sambuc typedef struct hx509_peer_info *hx509_peer_info; 62*ebfedea0SLionel Sambuc typedef struct hx509_ca_tbs *hx509_ca_tbs; 63*ebfedea0SLionel Sambuc typedef struct hx509_env_data *hx509_env; 64*ebfedea0SLionel Sambuc typedef struct hx509_crl *hx509_crl; 65*ebfedea0SLionel Sambuc 66*ebfedea0SLionel Sambuc typedef void (*hx509_vprint_func)(void *, const char *, va_list); 67*ebfedea0SLionel Sambuc 68*ebfedea0SLionel Sambuc enum { 69*ebfedea0SLionel Sambuc HX509_VHN_F_ALLOW_NO_MATCH = 1 70*ebfedea0SLionel Sambuc }; 71*ebfedea0SLionel Sambuc 72*ebfedea0SLionel Sambuc enum { 73*ebfedea0SLionel Sambuc HX509_VALIDATE_F_VALIDATE = 1, 74*ebfedea0SLionel Sambuc HX509_VALIDATE_F_VERBOSE = 2 75*ebfedea0SLionel Sambuc }; 76*ebfedea0SLionel Sambuc 77*ebfedea0SLionel Sambuc enum { 78*ebfedea0SLionel Sambuc HX509_CRYPTO_PADDING_PKCS7 = 0, 79*ebfedea0SLionel Sambuc HX509_CRYPTO_PADDING_NONE = 1 80*ebfedea0SLionel Sambuc }; 81*ebfedea0SLionel Sambuc 82*ebfedea0SLionel Sambuc enum { 83*ebfedea0SLionel Sambuc HX509_KEY_FORMAT_GUESS = 0, 84*ebfedea0SLionel Sambuc HX509_KEY_FORMAT_DER = 1, 85*ebfedea0SLionel Sambuc HX509_KEY_FORMAT_WIN_BACKUPKEY = 2 86*ebfedea0SLionel Sambuc }; 87*ebfedea0SLionel Sambuc typedef uint32_t hx509_key_format_t; 88*ebfedea0SLionel Sambuc 89*ebfedea0SLionel Sambuc struct hx509_cert_attribute_data { 90*ebfedea0SLionel Sambuc heim_oid oid; 91*ebfedea0SLionel Sambuc heim_octet_string data; 92*ebfedea0SLionel Sambuc }; 93*ebfedea0SLionel Sambuc 94*ebfedea0SLionel Sambuc typedef enum { 95*ebfedea0SLionel Sambuc HX509_PROMPT_TYPE_PASSWORD = 0x1, /* password, hidden */ 96*ebfedea0SLionel Sambuc HX509_PROMPT_TYPE_QUESTION = 0x2, /* question, not hidden */ 97*ebfedea0SLionel Sambuc HX509_PROMPT_TYPE_INFO = 0x4 /* infomation, reply doesn't matter */ 98*ebfedea0SLionel Sambuc } hx509_prompt_type; 99*ebfedea0SLionel Sambuc 100*ebfedea0SLionel Sambuc typedef struct hx509_prompt { 101*ebfedea0SLionel Sambuc const char *prompt; 102*ebfedea0SLionel Sambuc hx509_prompt_type type; 103*ebfedea0SLionel Sambuc heim_octet_string reply; 104*ebfedea0SLionel Sambuc } hx509_prompt; 105*ebfedea0SLionel Sambuc 106*ebfedea0SLionel Sambuc typedef int (*hx509_prompter_fct)(void *, const hx509_prompt *); 107*ebfedea0SLionel Sambuc 108*ebfedea0SLionel Sambuc typedef struct hx509_octet_string_list { 109*ebfedea0SLionel Sambuc size_t len; 110*ebfedea0SLionel Sambuc heim_octet_string *val; 111*ebfedea0SLionel Sambuc } hx509_octet_string_list; 112*ebfedea0SLionel Sambuc 113*ebfedea0SLionel Sambuc typedef struct hx509_pem_header { 114*ebfedea0SLionel Sambuc struct hx509_pem_header *next; 115*ebfedea0SLionel Sambuc char *header; 116*ebfedea0SLionel Sambuc char *value; 117*ebfedea0SLionel Sambuc } hx509_pem_header; 118*ebfedea0SLionel Sambuc 119*ebfedea0SLionel Sambuc typedef int 120*ebfedea0SLionel Sambuc (*hx509_pem_read_func)(hx509_context, const char *, const hx509_pem_header *, 121*ebfedea0SLionel Sambuc const void *, size_t, void *ctx); 122*ebfedea0SLionel Sambuc 123*ebfedea0SLionel Sambuc /* 124*ebfedea0SLionel Sambuc * Options passed to hx509_query_match_option. 125*ebfedea0SLionel Sambuc */ 126*ebfedea0SLionel Sambuc typedef enum { 127*ebfedea0SLionel Sambuc HX509_QUERY_OPTION_PRIVATE_KEY = 1, 128*ebfedea0SLionel Sambuc HX509_QUERY_OPTION_KU_ENCIPHERMENT = 2, 129*ebfedea0SLionel Sambuc HX509_QUERY_OPTION_KU_DIGITALSIGNATURE = 3, 130*ebfedea0SLionel Sambuc HX509_QUERY_OPTION_KU_KEYCERTSIGN = 4, 131*ebfedea0SLionel Sambuc HX509_QUERY_OPTION_END = 0xffff 132*ebfedea0SLionel Sambuc } hx509_query_option; 133*ebfedea0SLionel Sambuc 134*ebfedea0SLionel Sambuc /* flags to hx509_certs_init */ 135*ebfedea0SLionel Sambuc #define HX509_CERTS_CREATE 0x01 136*ebfedea0SLionel Sambuc #define HX509_CERTS_UNPROTECT_ALL 0x02 137*ebfedea0SLionel Sambuc 138*ebfedea0SLionel Sambuc /* flags to hx509_set_error_string */ 139*ebfedea0SLionel Sambuc #define HX509_ERROR_APPEND 0x01 140*ebfedea0SLionel Sambuc 141*ebfedea0SLionel Sambuc /* flags to hx509_cms_unenvelope */ 142*ebfedea0SLionel Sambuc #define HX509_CMS_UE_DONT_REQUIRE_KU_ENCIPHERMENT 0x01 143*ebfedea0SLionel Sambuc #define HX509_CMS_UE_ALLOW_WEAK 0x02 144*ebfedea0SLionel Sambuc 145*ebfedea0SLionel Sambuc /* flags to hx509_cms_envelope_1 */ 146*ebfedea0SLionel Sambuc #define HX509_CMS_EV_NO_KU_CHECK 0x01 147*ebfedea0SLionel Sambuc #define HX509_CMS_EV_ALLOW_WEAK 0x02 148*ebfedea0SLionel Sambuc #define HX509_CMS_EV_ID_NAME 0x04 149*ebfedea0SLionel Sambuc 150*ebfedea0SLionel Sambuc /* flags to hx509_cms_verify_signed */ 151*ebfedea0SLionel Sambuc #define HX509_CMS_VS_ALLOW_DATA_OID_MISMATCH 0x01 152*ebfedea0SLionel Sambuc #define HX509_CMS_VS_NO_KU_CHECK 0x02 153*ebfedea0SLionel Sambuc #define HX509_CMS_VS_ALLOW_ZERO_SIGNER 0x04 154*ebfedea0SLionel Sambuc #define HX509_CMS_VS_NO_VALIDATE 0x08 155*ebfedea0SLionel Sambuc 156*ebfedea0SLionel Sambuc /* selectors passed to hx509_crypto_select and hx509_crypto_available */ 157*ebfedea0SLionel Sambuc #define HX509_SELECT_ALL 0 158*ebfedea0SLionel Sambuc #define HX509_SELECT_DIGEST 1 159*ebfedea0SLionel Sambuc #define HX509_SELECT_PUBLIC_SIG 2 160*ebfedea0SLionel Sambuc #define HX509_SELECT_PUBLIC_ENC 3 161*ebfedea0SLionel Sambuc #define HX509_SELECT_SECRET_ENC 4 162*ebfedea0SLionel Sambuc 163*ebfedea0SLionel Sambuc /* flags to hx509_ca_tbs_set_template */ 164*ebfedea0SLionel Sambuc #define HX509_CA_TEMPLATE_SUBJECT 1 165*ebfedea0SLionel Sambuc #define HX509_CA_TEMPLATE_SERIAL 2 166*ebfedea0SLionel Sambuc #define HX509_CA_TEMPLATE_NOTBEFORE 4 167*ebfedea0SLionel Sambuc #define HX509_CA_TEMPLATE_NOTAFTER 8 168*ebfedea0SLionel Sambuc #define HX509_CA_TEMPLATE_SPKI 16 169*ebfedea0SLionel Sambuc #define HX509_CA_TEMPLATE_KU 32 170*ebfedea0SLionel Sambuc #define HX509_CA_TEMPLATE_EKU 64 171*ebfedea0SLionel Sambuc 172*ebfedea0SLionel Sambuc /* flags hx509_cms_create_signed* */ 173*ebfedea0SLionel Sambuc #define HX509_CMS_SIGNATURE_DETACHED 0x01 174*ebfedea0SLionel Sambuc #define HX509_CMS_SIGNATURE_ID_NAME 0x02 175*ebfedea0SLionel Sambuc #define HX509_CMS_SIGNATURE_NO_SIGNER 0x04 176*ebfedea0SLionel Sambuc #define HX509_CMS_SIGNATURE_LEAF_ONLY 0x08 177*ebfedea0SLionel Sambuc #define HX509_CMS_SIGNATURE_NO_CERTS 0x10 178*ebfedea0SLionel Sambuc 179*ebfedea0SLionel Sambuc /* hx509_verify_hostname nametype */ 180*ebfedea0SLionel Sambuc typedef enum { 181*ebfedea0SLionel Sambuc HX509_HN_HOSTNAME = 0, 182*ebfedea0SLionel Sambuc HX509_HN_DNSSRV 183*ebfedea0SLionel Sambuc } hx509_hostname_type; 184*ebfedea0SLionel Sambuc 185*ebfedea0SLionel Sambuc #include <krb5/hx509-protos.h> 186*ebfedea0SLionel Sambuc #include <krb5/hx509_err.h> 187*ebfedea0SLionel Sambuc 188*ebfedea0SLionel Sambuc #endif /* HEIMDAL_HX509_H */ 189