simplified internal function names.
[gnutls.git] / lib / auth / cert.h
blobc64bf2e260f394c436b60a04972c6a634c76e171
1 /*
2 * Copyright (C) 2002-2012 Free Software Foundation, Inc.
4 * Author: Nikos Mavrogiannopoulos
6 * This file is part of GnuTLS.
8 * The GnuTLS is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>
23 #ifndef AUTH_CERT_H
24 #define AUTH_CERT_H
25 #include "gnutls_auth.h"
26 #include <auth/dh_common.h>
27 #include <x509/x509_int.h>
28 #include <openpgp/openpgp_int.h>
29 #include <gnutls/abstract.h>
30 #include <gnutls/compat.h>
31 #include <gnutls_str_array.h>
33 typedef struct {
34 gnutls_pcert_st * cert_list; /* a certificate chain */
35 unsigned int cert_list_length; /* its length */
36 gnutls_str_array_t names; /* the names in the first certificate */
37 } certs_st;
39 /* This structure may be complex, but it's the only way to
40 * support a server that has multiple certificates
42 typedef struct gnutls_certificate_credentials_st
44 gnutls_dh_params_t dh_params;
45 gnutls_rsa_params_t rsa_params;
46 /* this callback is used to retrieve the DH or RSA
47 * parameters.
49 gnutls_params_function *params_func;
51 certs_st *certs;
52 unsigned ncerts; /* the number of certs */
54 gnutls_privkey_t *pkey;
55 /* private keys. It contains ncerts private
56 * keys. pkey[i] corresponds to certificate in
57 * cert_list[i][0].
60 #ifdef ENABLE_OPENPGP
61 /* OpenPGP specific stuff */
62 gnutls_openpgp_keyring_t keyring;
63 #endif
65 /* X509 specific stuff */
66 gnutls_x509_trust_list_t tlist;
67 unsigned int verify_flags; /* flags to be used at
68 * certificate verification.
70 unsigned int verify_depth;
71 unsigned int verify_bits;
73 /* holds a sequence of the
74 * RDNs of the CAs above.
75 * This is better than
76 * generating on every handshake.
78 gnutls_datum_t x509_rdn_sequence;
80 /* It's a mess here. However we need to keep the old 3 functions
81 * for compatibility */
82 gnutls_certificate_retrieve_function *get_cert_callback; /* deprecated */
83 gnutls_certificate_client_retrieve_function *client_get_cert_callback; /* deprecated */
84 gnutls_certificate_server_retrieve_function *server_get_cert_callback; /* deprecated */
85 gnutls_certificate_retrieve_function2 *get_cert_callback2;
87 gnutls_certificate_verify_function *verify_callback;
89 } certificate_credentials_st;
91 typedef struct rsa_info_st
93 gnutls_datum_t modulus;
94 gnutls_datum_t exponent;
95 } rsa_info_st;
97 /* This is the information we keep for the peer
98 * certificate.
100 typedef struct cert_auth_info_st
102 /* These (dh/rsa) are just copies from the credentials_t structure.
103 * They must be freed.
105 dh_info_st dh;
106 rsa_info_st rsa_export;
108 gnutls_datum_t *raw_certificate_list; /* holds the raw certificate of the
109 * peer.
111 unsigned int ncerts; /* holds the size of the list above */
113 gnutls_certificate_type_t cert_type;
114 #ifdef ENABLE_OPENPGP
115 int use_subkey;
116 uint8_t subkey_id[GNUTLS_OPENPGP_KEYID_SIZE];
117 #endif
118 } *cert_auth_info_t;
120 typedef struct cert_auth_info_st cert_auth_info_st;
122 void _gnutls_free_rsa_info (rsa_info_st * rsa);
124 /* AUTH X509 functions */
125 int _gnutls_gen_cert_server_crt (gnutls_session_t, gnutls_buffer_st *);
126 int _gnutls_gen_cert_client_crt (gnutls_session_t, gnutls_buffer_st *);
127 int _gnutls_gen_cert_client_cert_vrfy (gnutls_session_t, gnutls_buffer_st *);
128 int _gnutls_gen_cert_server_cert_req (gnutls_session_t, gnutls_buffer_st *);
129 int _gnutls_proc_cert_cert_req (gnutls_session_t, uint8_t *, size_t);
130 int _gnutls_proc_cert_client_cert_vrfy (gnutls_session_t, uint8_t *, size_t);
131 int _gnutls_proc_certificate (gnutls_session_t, uint8_t *, size_t);
132 int _gnutls_get_selected_cert (gnutls_session_t session,
133 gnutls_pcert_st ** apr_cert_list,
134 int *apr_cert_list_length,
135 gnutls_privkey_t * apr_pkey);
137 int _gnutls_server_select_cert (struct gnutls_session_int *,
138 gnutls_pk_algorithm_t*, size_t);
139 void _gnutls_selected_certs_deinit (gnutls_session_t session);
140 void _gnutls_selected_certs_set (gnutls_session_t session,
141 gnutls_pcert_st * certs, int ncerts,
142 gnutls_privkey_t key, int need_free);
144 gnutls_rsa_params_t _gnutls_certificate_get_rsa_params (gnutls_rsa_params_t
145 rsa_params,
146 gnutls_params_function
147 * func,
148 gnutls_session_t);
150 int _gnutls_get_auth_info_pcert (gnutls_pcert_st* gcert,
151 gnutls_certificate_type_t type,
152 cert_auth_info_t info);
154 int certificate_credential_append_crt_list (gnutls_certificate_credentials_t
155 res, gnutls_str_array_t names,
156 gnutls_pcert_st* crt, int nr);
157 int certificate_credentials_append_pkey (gnutls_certificate_credentials_t res,
158 gnutls_privkey_t pkey);
160 int _gnutls_selected_cert_supported_kx (struct gnutls_session_int *session,
161 gnutls_kx_algorithm_t * alg,
162 int *alg_size);
164 #endif