tls.h

Go to the documentation of this file.
00001 
00016 #ifndef TLS_H
00017 #define TLS_H
00018 
00019 struct tls_connection;
00020 
00021 struct tls_keys {
00022         const u8 *master_key;
00023         size_t master_key_len;
00024         const u8 *client_random;
00025         size_t client_random_len;
00026         const u8 *server_random;
00027         size_t server_random_len;
00028 
00029         /*
00030          * If TLS library does not provide access to master_key, but only to
00031          * EAP key block, this pointer can be set to point to the result of
00032          * PRF(master_secret, "client EAP encryption",
00033          * client_random + server_random).
00034          */
00035         const u8 *eap_tls_prf;
00036         size_t eap_tls_prf_len;
00037 };
00038 
00039 struct tls_config {
00040         const char *opensc_engine_path;
00041         const char *pkcs11_engine_path;
00042         const char *pkcs11_module_path;
00043 };
00044 
00084 struct tls_connection_params {
00085         const char *ca_cert;
00086         const u8 *ca_cert_blob;
00087         size_t ca_cert_blob_len;
00088         const char *ca_path;
00089         const char *subject_match;
00090         const char *altsubject_match;
00091         const char *client_cert;
00092         const u8 *client_cert_blob;
00093         size_t client_cert_blob_len;
00094         const char *private_key;
00095         const u8 *private_key_blob;
00096         size_t private_key_blob_len;
00097         const char *private_key_passwd;
00098         const char *dh_file;
00099         const u8 *dh_blob;
00100         size_t dh_blob_len;
00101 
00102         /* OpenSSL specific variables */
00103         int engine;
00104         const char *engine_id;
00105         const char *pin;
00106         const char *key_id;
00107 };
00108 
00109 
00123 void * tls_init(const struct tls_config *conf);
00124 
00136 void tls_deinit(void *tls_ctx);
00137 
00147 int tls_get_errors(void *tls_ctx);
00148 
00156 struct tls_connection * tls_connection_init(void *tls_ctx);
00157 
00166 void tls_connection_deinit(void *tls_ctx, struct tls_connection *conn);
00167 
00176 int tls_connection_established(void *tls_ctx, struct tls_connection *conn);
00177 
00191 int tls_connection_shutdown(void *tls_ctx, struct tls_connection *conn);
00192 
00193 enum {
00194         TLS_SET_PARAMS_ENGINE_PRV_VERIFY_FAILED = -3,
00195         TLS_SET_PARAMS_ENGINE_PRV_INIT_FAILED = -2
00196 };
00210 int tls_connection_set_params(void *tls_ctx, struct tls_connection *conn,
00211                               const struct tls_connection_params *params);
00212 
00222 int tls_global_ca_cert(void *tls_ctx, const char *ca_cert);
00223 
00233 int tls_global_set_verify(void *tls_ctx, int check_crl);
00234 
00244 int tls_connection_set_verify(void *tls_ctx, struct tls_connection *conn,
00245                               int verify_peer);
00246 
00255 int tls_global_client_cert(void *tls_ctx, const char *client_cert);
00256 
00267 int tls_global_private_key(void *tls_ctx, const char *private_key,
00268                            const char *private_key_passwd);
00269 
00279 int tls_connection_get_keys(void *tls_ctx, struct tls_connection *conn,
00280                             struct tls_keys *keys);
00281 
00309 u8 * tls_connection_handshake(void *tls_ctx, struct tls_connection *conn,
00310                               const u8 *in_data, size_t in_len,
00311                               size_t *out_len);
00312 
00326 u8 * tls_connection_server_handshake(void *tls_ctx,
00327                                      struct tls_connection *conn,
00328                                      const u8 *in_data, size_t in_len,
00329                                      size_t *out_len);
00330 
00346 int tls_connection_encrypt(void *tls_ctx, struct tls_connection *conn,
00347                            const u8 *in_data, size_t in_len,
00348                            u8 *out_data, size_t out_len);
00349 
00365 int tls_connection_decrypt(void *tls_ctx, struct tls_connection *conn,
00366                            const u8 *in_data, size_t in_len,
00367                            u8 *out_data, size_t out_len);
00368 
00377 int tls_connection_resumed(void *tls_ctx, struct tls_connection *conn);
00378 
00389 int tls_connection_set_master_key(void *tls_ctx, struct tls_connection *conn,
00390                                   const u8 *key, size_t key_len);
00391 
00403 int tls_connection_set_anon_dh(void *tls_ctx, struct tls_connection *conn);
00404 
00417 int tls_get_cipher(void *tls_ctx, struct tls_connection *conn,
00418                    char *buf, size_t buflen);
00419 
00431 int tls_connection_enable_workaround(void *tls_ctx,
00432                                      struct tls_connection *conn);
00433 
00445 int tls_connection_client_hello_ext(void *tls_ctx, struct tls_connection *conn,
00446                                     int ext_type, const u8 *data,
00447                                     size_t data_len);
00448 
00457 int tls_connection_get_failed(void *tls_ctx, struct tls_connection *conn);
00458 
00468 int tls_connection_get_read_alerts(void *tls_ctx, struct tls_connection *conn);
00469 
00479 int tls_connection_get_write_alerts(void *tls_ctx,
00480                                     struct tls_connection *conn);
00481 
00490 int tls_connection_get_keyblock_size(void *tls_ctx,
00491                                      struct tls_connection *conn);
00492 
00493 #endif /* TLS_H */
00494 

Generated on Sat May 6 21:13:39 2006 for wpa_supplicant by  doxygen 1.4.2