gnutls code cleanup

symbol refactoring
This commit is contained in:
lv-426
2008-08-11 03:40:22 +00:00
parent 41886bcf92
commit 1c893a971f
129 changed files with 3935 additions and 6783 deletions
+1 -1
View File
@@ -1648,7 +1648,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
#if HTTPS_SUPPORT
if (connection->daemon->options & MHD_USE_SSL)
{
ret = gnutls_record_send (connection->tls_session,
ret = MHD_gnutls_record_send (connection->tls_session,
&connection->response->
data[connection->
response_write_position -
+17 -7
View File
@@ -55,7 +55,7 @@ int MHD_connection_handle_idle (struct MHD_Connection *connection);
static void
MHD_tls_connection_close (struct MHD_Connection *connection)
{
gnutls_bye (connection->tls_session, GNUTLS_SHUT_WR);
MHD_gnutls_bye (connection->tls_session, GNUTLS_SHUT_WR);
connection->tls_session->internals.read_eof = 1;
SHUTDOWN (connection->socket_fd, SHUT_RDWR);
@@ -129,7 +129,7 @@ MHD_get_session_info (struct MHD_Connection *con, enum MHD_InfoType infoType)
static ssize_t
MHDS_con_read (struct MHD_Connection *connection)
{
ssize_t size = gnutls_record_recv (connection->tls_session,
ssize_t size = MHD_gnutls_record_recv (connection->tls_session,
&connection->read_buffer[connection->
read_buffer_offset],
connection->read_buffer_size);
@@ -139,7 +139,7 @@ MHDS_con_read (struct MHD_Connection *connection)
static ssize_t
MHDS_con_write (struct MHD_Connection *connection)
{
ssize_t sent = gnutls_record_send (connection->tls_session,
ssize_t sent = MHD_gnutls_record_send (connection->tls_session,
&connection->write_buffer[connection->
write_buffer_send_offset],
connection->write_buffer_append_offset
@@ -147,6 +147,16 @@ MHDS_con_write (struct MHD_Connection *connection)
return sent;
}
/**
* This function was created to handle per-connection processing that
* has to happen even if the socket cannot be read or written to. All
* implementations (multithreaded, external select, internal select)
* call this function.
*
* @param connection being handled
* @return MHD_YES if we should continue to process the
* connection (not dead yet), MHD_NO if it died
*/
int
MHD_tls_connection_handle_idle (struct MHD_Connection *connection)
{
@@ -236,7 +246,7 @@ MHD_tls_connection_handle_read (struct MHD_Connection *connection)
if (connection->state == MHD_TLS_CONNECTION_INIT ||
connection->state == MHD_TLS_HELLO_REQUEST)
{
ret = gnutls_handshake (connection->tls_session);
ret = MHD_gnutls_handshake (connection->tls_session);
if (ret == 0)
{
/* set connection state to enable HTTP processing */
@@ -274,10 +284,10 @@ MHD_tls_connection_handle_read (struct MHD_Connection *connection)
case GNUTLS_ALERT:
/*
* this call of _gnutls_recv_int expects 0 bytes read.
* this call of mhd_gtls_recv_int expects 0 bytes read.
* done to decrypt alert message
*/
_gnutls_recv_int (connection->tls_session, GNUTLS_ALERT,
mhd_gtls_recv_int (connection->tls_session, GNUTLS_ALERT,
GNUTLS_HANDSHAKE_FINISHED, 0, 0);
/* CLOSE_NOTIFY */
@@ -294,7 +304,7 @@ MHD_tls_connection_handle_read (struct MHD_Connection *connection)
#if HAVE_MESSAGES
MHD_DLOG (connection->daemon,
"Received TLS alert: %s\n",
gnutls_alert_get_name ((int) connection->tls_session->
MHD_gnutls_alert_get_name ((int) connection->tls_session->
internals.last_alert));
#endif
return MHD_YES;
+27 -25
View File
@@ -88,7 +88,7 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon)
CLOSE (daemon->socket_fd);
return -1;
}
return gnutls_certificate_set_x509_key_file (daemon->x509_cred,
return MHD_gnutls_certificate_set_x509_key_file (daemon->x509_cred,
daemon->https_cert_path,
daemon->https_key_path,
GNUTLS_X509_FMT_PEM);
@@ -101,7 +101,7 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon)
cert.data = (unsigned char *) daemon->https_mem_cert;
cert.size = strlen (daemon->https_mem_cert);
return gnutls_certificate_set_x509_key_mem (daemon->x509_cred, &cert,
return MHD_gnutls_certificate_set_x509_key_mem (daemon->x509_cred, &cert,
&key, GNUTLS_X509_FMT_PEM);
}
else
@@ -122,16 +122,16 @@ MHD_TLS_init (struct MHD_Daemon *daemon)
switch (daemon->cred_type)
{
case MHD_GNUTLS_CRD_ANON:
ret = gnutls_anon_allocate_server_credentials (&daemon->anon_cred);
ret += gnutls_dh_params_init (&daemon->dh_params);
ret = MHD_gnutls_anon_allocate_server_credentials (&daemon->anon_cred);
ret += MHD_gnutls_dh_params_init (&daemon->dh_params);
if (ret != 0) {
return GNUTLS_E_MEMORY_ERROR;
}
gnutls_dh_params_generate2 (daemon->dh_params, 1024);
gnutls_anon_set_server_dh_params (daemon->anon_cred, daemon->dh_params);
MHD_gnutls_dh_params_generate2 (daemon->dh_params, 1024);
MHD_gnutls_anon_set_server_dh_params (daemon->anon_cred, daemon->dh_params);
break;
case MHD_GNUTLS_CRD_CERTIFICATE:
ret = gnutls_certificate_allocate_credentials (&daemon->x509_cred) ;
ret = MHD_gnutls_certificate_allocate_credentials (&daemon->x509_cred) ;
if (ret != 0) {
return GNUTLS_E_MEMORY_ERROR;
}
@@ -150,7 +150,7 @@ MHD_TLS_init (struct MHD_Daemon *daemon)
}
inline static int
_set_priority (priority_st * st, const int *list)
_set_priority (mhd_gtls_priority_st * st, const int *list)
{
int num = 0, i;
@@ -322,23 +322,23 @@ MHD_TLS_init_connection (void *data)
/* initialize connection state */
con->state = MHD_TLS_CONNECTION_INIT;
gnutls_init (&con->tls_session, GNUTLS_SERVER);
MHD_gnutls_init (&con->tls_session, GNUTLS_SERVER);
/* sets cipher priorities */
gnutls_priority_set (con->tls_session, con->daemon->priority_cache);
MHD_gnutls_priority_set (con->tls_session, con->daemon->priority_cache);
switch (con->daemon->cred_type)
{
/* set needed credentials for certificate authentication. */
case MHD_GNUTLS_CRD_CERTIFICATE:
gnutls_credentials_set (con->tls_session, MHD_GNUTLS_CRD_CERTIFICATE,
MHD_gnutls_credentials_set (con->tls_session, MHD_GNUTLS_CRD_CERTIFICATE,
con->daemon->x509_cred);
break;
case MHD_GNUTLS_CRD_ANON:
/* set needed credentials for anonymous authentication. */
gnutls_credentials_set (con->tls_session, MHD_GNUTLS_CRD_ANON,
MHD_gnutls_credentials_set (con->tls_session, MHD_GNUTLS_CRD_ANON,
con->daemon->anon_cred);
gnutls_dh_set_prime_bits (con->tls_session, 1024);
MHD_gnutls_dh_set_prime_bits (con->tls_session, 1024);
break;
default:
@@ -351,11 +351,11 @@ MHD_TLS_init_connection (void *data)
}
/* TODO avoid gnutls blocking recv / write calls
gnutls_transport_set_pull_function(tls_session, &recv);
gnutls_transport_set_push_function(tls_session, &send);
MHD_gnutls_transport_set_pull_function(tls_session, &recv);
MHD_gnutls_transport_set_push_function(tls_session, &send);
*/
gnutls_transport_set_ptr (con->tls_session,
MHD_gnutls_transport_set_ptr (con->tls_session,
(gnutls_transport_ptr_t) ((void *) con->
socket_fd));
@@ -580,7 +580,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
#if HTTPS_SUPPORT
if (pos->tls_session != 0)
{
gnutls_deinit (pos->tls_session);
MHD_gnutls_deinit (pos->tls_session);
}
#endif
free (pos->addr);
@@ -839,6 +839,7 @@ MHD_start_daemon_va (unsigned int options,
if ((options & MHD_USE_IPv6) != 0)
{
memset (&servaddr6, 0, sizeof (struct sockaddr_in6));
/* todo impl IPv6 address setting */
servaddr6.sin6_family = AF_INET6;
servaddr6.sin6_port = htons (port);
servaddr = (struct sockaddr *) &servaddr6;
@@ -847,6 +848,7 @@ MHD_start_daemon_va (unsigned int options,
else
{
memset (&servaddr4, 0, sizeof (struct sockaddr_in));
inet_pton (AF_INET, ip, &servaddr4.sin_addr);
servaddr4.sin_family = AF_INET;
servaddr4.sin_port = htons (port);
servaddr = (struct sockaddr *) &servaddr4;
@@ -899,10 +901,10 @@ MHD_start_daemon_va (unsigned int options,
{
/* lock gnutls_global mutex since it uses reference counting */
pthread_mutex_lock (&gnutls_init_mutex);
gnutls_global_init ();
MHD_gnutls_global_init ();
pthread_mutex_unlock (&gnutls_init_mutex);
/* set default priorities */
gnutls_priority_init (&retVal->priority_cache, "", NULL);
MHD_tls_set_default_priority (&retVal->priority_cache, "", NULL);
retVal->cred_type = MHD_GNUTLS_CRD_CERTIFICATE;
}
#endif
@@ -1119,10 +1121,10 @@ MHD_start_daemon (unsigned int options,
{
/* lock gnutls_global mutex since it uses reference counting */
pthread_mutex_lock (&gnutls_init_mutex);
gnutls_global_init ();
MHD_gnutls_global_init ();
pthread_mutex_unlock (&gnutls_init_mutex);
/* set default priorities */
gnutls_priority_init (&retVal->priority_cache, "", NULL);
MHD_tls_set_default_priority (&retVal->priority_cache, "", NULL);
retVal->cred_type = MHD_GNUTLS_CRD_CERTIFICATE;
}
#endif
@@ -1320,16 +1322,16 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
#if HTTPS_SUPPORT
if (daemon->options & MHD_USE_SSL)
{
gnutls_priority_deinit (daemon->priority_cache);
MHD_gnutls_priority_deinit (daemon->priority_cache);
if (daemon->x509_cred)
gnutls_certificate_free_credentials (daemon->x509_cred);
MHD_gnutls_certificate_free_credentials (daemon->x509_cred);
if (daemon->anon_cred)
gnutls_anon_free_server_credentials (daemon->anon_cred);
MHD_gnutls_anon_free_server_credentials (daemon->anon_cred);
/* lock gnutls_global mutex since it uses reference counting */
pthread_mutex_lock (&gnutls_init_mutex);
gnutls_global_deinit ();
MHD_gnutls_global_deinit ();
pthread_mutex_unlock (&gnutls_init_mutex);
}
#endif
+7 -7
View File
@@ -40,7 +40,7 @@
#define gnutls_openpgp_key_status gnutls_openpgp_key_status_t
#define gnutls_certificate_request gnutls_certificate_request_t
#define gnutls_certificate_status gnutls_certificate_status_t
#define gnutls_session gnutls_session_t
#define gnutls_session mhd_gtls_session_t
#define gnutls_alert_level gnutls_alert_level_t
#define gnutls_alert_description gnutls_alert_description_t
#define gnutls_x509_subject_alt_name gnutls_x509_subject_alt_name_t
@@ -56,13 +56,13 @@
#define gnutls_pkcs12_bag_type gnutls_pkcs12_bag_type_t
#define gnutls_pkcs12_bag gnutls_pkcs12_bag_t
#define gnutls_pkcs12 gnutls_pkcs12_t
#define gnutls_certificate_credentials gnutls_certificate_credentials_t
#define gnutls_anon_server_credentials gnutls_anon_server_credentials_t
#define gnutls_anon_client_credentials gnutls_anon_client_credentials_t
#define gnutls_certificate_credentials mhd_gtls_cert_credentials_t
#define gnutls_anon_server_credentials mhd_gtls_anon_server_credentials_t
#define gnutls_anon_client_credentials mhd_gtls_anon_client_credentials_t
#define gnutls_srp_client_credentials gnutls_srp_client_credentials_t
#define gnutls_srp_server_credentials gnutls_srp_server_credentials_t
#define gnutls_dh_params gnutls_dh_params_t
#define gnutls_rsa_params gnutls_rsa_params_t
#define gnutls_dh_params mhd_gtls_dh_params_t
#define gnutls_rsa_params mhd_gtls_rsa_params_t
#define gnutls_params_type gnutls_params_type_t
#define gnutls_credentials_type gnutls_credentials_type_t
#define gnutls_certificate_type gnutls_certificate_type_t
@@ -78,7 +78,7 @@
#define gnutls_openpgp_key_fmt_t gnutls_openpgp_crt_fmt_t
#define GNUTLS_OPENPGP_KEY GNUTLS_OPENPGP_CERT
#define GNUTLS_OPENPGP_KEY_FINGERPRINT GNUTLS_OPENPGP_CERT_FINGERPRINT
#define gnutls_openpgp_send_key gnutls_openpgp_send_cert
#define gnutls_openpgp_send_key MHD_gtls_openpgp_send_cert
#define gnutls_openpgp_key_status_t gnutls_openpgp_crt_status_t
#define gnutls_openpgp_key_t gnutls_openpgp_crt_t
#define gnutls_openpgp_key_init gnutls_openpgp_crt_init
+19 -19
View File
@@ -47,7 +47,7 @@ extern "C"
} gnutls_openpgp_crt_fmt_t;
/**
* gnutls_openpgp_recv_key_func - Callback prototype to get OpenPGP keys
* mhd_gtls_openpgp_recv_key_func - Callback prototype to get OpenPGP keys
* @session: a TLS session
* @keyfpr: key fingerprint
* @keyfpr_length: length of key fingerprint
@@ -59,32 +59,32 @@ extern "C"
* gnutls_openpgp_set_recv_key_function().
*
*/
typedef int (*gnutls_openpgp_recv_key_func) (gnutls_session_t session,
typedef int (*mhd_gtls_openpgp_recv_key_func) (mhd_gtls_session_t session,
const unsigned char *keyfpr,
unsigned int keyfpr_length,
gnutls_datum_t * key);
void gnutls_openpgp_set_recv_key_function (gnutls_session_t session,
gnutls_openpgp_recv_key_func
void gnutls_openpgp_set_recv_key_function (mhd_gtls_session_t session,
mhd_gtls_openpgp_recv_key_func
func);
int
gnutls_certificate_set_openpgp_key_file (gnutls_certificate_credentials_t
gnutls_certificate_set_openpgp_key_file (mhd_gtls_cert_credentials_t
res, const char *CERTFILE,
const char *KEYFILE, gnutls_openpgp_crt_fmt_t);
int gnutls_certificate_set_openpgp_key_mem (gnutls_certificate_credentials_t
int gnutls_certificate_set_openpgp_key_mem (mhd_gtls_cert_credentials_t
res,
const gnutls_datum_t * CERT,
const gnutls_datum_t * KEY, gnutls_openpgp_crt_fmt_t);
int
gnutls_certificate_set_openpgp_keyring_mem
(gnutls_certificate_credentials_t c, const unsigned char *data,
(mhd_gtls_cert_credentials_t c, const unsigned char *data,
size_t dlen, gnutls_openpgp_crt_fmt_t);
int
gnutls_certificate_set_openpgp_keyring_file
(gnutls_certificate_credentials_t c, const char *file, gnutls_openpgp_crt_fmt_t);
(mhd_gtls_cert_credentials_t c, const char *file, gnutls_openpgp_crt_fmt_t);
/* TLS/IA stuff
*/
@@ -99,7 +99,7 @@ extern "C"
/* TLS/IA credential
*/
typedef int (*gnutls_ia_avp_func) (gnutls_session_t session, void *ptr,
typedef int (*gnutls_ia_avp_func) (mhd_gtls_session_t session, void *ptr,
const char *last, size_t lastlen,
char **next, size_t * nextlen);
@@ -142,35 +142,35 @@ extern "C"
cred);
/* TLS/IA handshake. */
extern int gnutls_ia_handshake_p (gnutls_session_t session);
extern int gnutls_ia_handshake_p (mhd_gtls_session_t session);
extern int gnutls_ia_handshake (gnutls_session_t session);
extern int gnutls_ia_handshake (mhd_gtls_session_t session);
/* TLS/IA low level interface. */
extern int
gnutls_ia_permute_inner_secret (gnutls_session_t session,
gnutls_ia_permute_inner_secret (mhd_gtls_session_t session,
size_t session_keys_size,
const char *session_keys);
extern int gnutls_ia_endphase_send (gnutls_session_t session,
extern int gnutls_ia_endphase_send (mhd_gtls_session_t session,
int final_p);
extern int gnutls_ia_verify_endphase (gnutls_session_t session,
extern int gnutls_ia_verify_endphase (mhd_gtls_session_t session,
const char *checksum);
extern ssize_t gnutls_ia_send (gnutls_session_t session,
extern ssize_t gnutls_ia_send (mhd_gtls_session_t session,
const char *data, size_t sizeofdata);
extern ssize_t gnutls_ia_recv (gnutls_session_t session,
extern ssize_t gnutls_ia_recv (mhd_gtls_session_t session,
char *data, size_t sizeofdata);
/* Utility stuff. */
extern int gnutls_ia_generate_challenge (gnutls_session_t session,
extern int gnutls_ia_generate_challenge (mhd_gtls_session_t session,
size_t buffer_size,
char *buffer);
extern void gnutls_ia_extract_inner_secret (gnutls_session_t session,
extern void gnutls_ia_extract_inner_secret (mhd_gtls_session_t session,
char *buffer);
/* Define whether inner phases are wanted. */
extern void gnutls_ia_enable (gnutls_session_t session,
extern void gnutls_ia_enable (mhd_gtls_session_t session,
int allow_skip_on_resume);
int gnutls_global_init_extra (void);
+573 -666
View File
@@ -42,21 +42,8 @@ extern "C"
#define LIBGNUTLS_VERSION "2.2.3"
#define LIBGNUTLS_VERSION_MAJOR 2
#define LIBGNUTLS_VERSION_MINOR 2
#define LIBGNUTLS_VERSION_PATCH 3
#define LIBGNUTLS_VERSION_NUMBER 0x020203
/* Get size_t. */
#include <stddef.h>
/* Get ssize_t. */
#ifndef HAVE_SSIZE_T
# define HAVE_SSIZE_T
#include <sys/types.h>
#endif
/* Get time_t. */
#include <time.h>
#include <compat.h>
#define GNUTLS_CIPHER_RIJNDAEL_128_CBC GNUTLS_CIPHER_AES_128_CBC
@@ -64,6 +51,10 @@ extern "C"
#define GNUTLS_CIPHER_RIJNDAEL_CBC GNUTLS_CIPHER_AES_128_CBC
#define GNUTLS_CIPHER_ARCFOUR GNUTLS_CIPHER_ARCFOUR_128
#define GNUTLS_MAX_SESSION_ID 32
#define TLS_MASTER_SIZE 48
#define TLS_RANDOM_SIZE 32
#include "microhttpd.h"
typedef enum
@@ -72,11 +63,6 @@ extern "C"
GNUTLS_PARAMS_DH
} gnutls_params_type_t;
/* TODO clean
#define GNUTLS_MAC_SHA GNUTLS_MAC_SHA1
#define GNUTLS_DIG_SHA GNUTLS_DIG_SHA1
*/
/* exported for other gnutls headers. This is the maximum number of
* algorithms (ciphers, kx or macs).
*/
@@ -148,11 +134,11 @@ extern "C"
*/
typedef enum
{
GNUTLS_CERT_INVALID = 2, /* will be set if the certificate
* was not verified.
*/
GNUTLS_CERT_REVOKED = 32, /* in X.509 this will be set only if CRLs are checked
*/
GNUTLS_CERT_INVALID = 2, /* will be set if the certificate
* was not verified.
*/
GNUTLS_CERT_REVOKED = 32, /* in X.509 this will be set only if CRLs are checked
*/
/* Those are extra information about the verification
* process. Will be set only if the certificate was
@@ -187,10 +173,6 @@ extern "C"
GNUTLS_X509_FMT_PEM
} gnutls_x509_crt_fmt_t;
const char *gnutls_pk_algorithm_get_name (gnutls_pk_algorithm_t algorithm);
#define GNUTLS_SIGN_RSA_SHA GNUTLS_SIGN_RSA_SHA1
#define GNUTLS_SIGN_DSA_SHA GNUTLS_SIGN_DSA_SHA1
typedef enum
{
GNUTLS_SIGN_UNKNOWN = 0,
@@ -204,25 +186,22 @@ extern "C"
GNUTLS_SIGN_RSA_SHA512
} gnutls_sign_algorithm_t;
const char *gnutls_sign_algorithm_get_name (gnutls_sign_algorithm_t
algorithm);
/* If you want to change this, then also change the define in
* gnutls_int.h, and recompile.
*/
typedef void * gnutls_transport_ptr_t;
typedef void *gnutls_transport_ptr_t;
struct gnutls_session_int;
typedef struct gnutls_session_int * gnutls_session_t;
struct MHD_gtls_session_int;
typedef struct MHD_gtls_session_int * mhd_gtls_session_t;
struct gnutls_dh_params_int;
typedef struct gnutls_dh_params_int *gnutls_dh_params_t;
struct MHD_gtls_dh_params_int;
typedef struct MHD_gtls_dh_params_int * mhd_gtls_dh_params_t;
struct gnutls_x509_privkey_int; /* XXX ugly. */
typedef struct gnutls_x509_privkey_int *gnutls_rsa_params_t; /* XXX ugly. */
struct MHD_gtls_x509_privkey_int; /* XXX ugly. */
typedef struct MHD_gtls_x509_privkey_int * mhd_gtls_rsa_params_t; /* XXX ugly. */
struct gnutls_priority_st;
typedef struct gnutls_priority_st * gnutls_priority_t;
struct MHD_gtls_priority_st;
typedef struct MHD_gtls_priority_st *gnutls_priority_t;
typedef struct
{
@@ -236,387 +215,330 @@ extern "C"
gnutls_params_type_t type;
union params
{
gnutls_dh_params_t dh;
gnutls_rsa_params_t rsa_export;
mhd_gtls_dh_params_t dh;
mhd_gtls_rsa_params_t rsa_export;
} params;
int deinit;
} gnutls_params_st;
typedef int gnutls_params_function (gnutls_session_t, gnutls_params_type_t,
gnutls_params_st *);
typedef int gnutls_params_function (mhd_gtls_session_t, gnutls_params_type_t,
gnutls_params_st *);
/* internal functions */
int MHD_gnutls_global_init (void);
void MHD_gnutls_global_deinit (void);
int gnutls_init (gnutls_session_t * session,
gnutls_connection_end_t con_end);
void gnutls_deinit (gnutls_session_t session);
#define _gnutls_deinit(x) gnutls_deinit(x)
int MHD_gnutls_init (mhd_gtls_session_t * session,
gnutls_connection_end_t con_end);
void MHD_gnutls_deinit (mhd_gtls_session_t session);
int gnutls_bye (gnutls_session_t session, gnutls_close_request_t how);
int MHD_gnutls_bye (mhd_gtls_session_t session, gnutls_close_request_t how);
int MHD_gnutls_handshake (mhd_gtls_session_t session);
int MHD_gnutls_rehandshake (mhd_gtls_session_t session);
gnutls_alert_description_t gnutls_alert_get (mhd_gtls_session_t session);
int MHD_gnutls_alert_send (mhd_gtls_session_t session,
gnutls_alert_level_t level,
gnutls_alert_description_t desc);
int MHD_gnutls_alert_send_appropriate (mhd_gtls_session_t session, int err);
const char * MHD_gnutls_alert_get_name (gnutls_alert_description_t alert);
int gnutls_handshake (gnutls_session_t session);
int gnutls_rehandshake (gnutls_session_t session);
// gnutls_cipher_algorithm_t gnutls_cipher_get (mhd_gtls_session_t session);
// gnutls_kx_algorithm_t gnutls_kx_get (mhd_gtls_session_t session);
// gnutls_mac_algorithm_t gnutls_mac_get (mhd_gtls_session_t session);
// gnutls_compression_method_t gnutls_compression_get (mhd_gtls_session_t
// session);
// gnutls_certificate_type_t gnutls_certificate_type_get (mhd_gtls_session_t
// session);
gnutls_alert_description_t gnutls_alert_get (gnutls_session_t session);
int gnutls_alert_send (gnutls_session_t session,
gnutls_alert_level_t level,
gnutls_alert_description_t desc);
int gnutls_alert_send_appropriate (gnutls_session_t session, int err);
const char *gnutls_alert_get_name (gnutls_alert_description_t alert);
/* get information on the current session */
gnutls_cipher_algorithm_t gnutls_cipher_get (gnutls_session_t session);
gnutls_kx_algorithm_t gnutls_kx_get (gnutls_session_t session);
gnutls_mac_algorithm_t gnutls_mac_get (gnutls_session_t session);
gnutls_compression_method_t gnutls_compression_get (gnutls_session_t
session);
gnutls_certificate_type_t gnutls_certificate_type_get (gnutls_session_t
session);
size_t gnutls_cipher_get_key_size (gnutls_cipher_algorithm_t algorithm);
size_t gnutls_mac_get_key_size (gnutls_mac_algorithm_t algorithm);
size_t MHD_gnutls_cipher_get_key_size (gnutls_cipher_algorithm_t algorithm);
size_t MHD_gnutls_mac_get_key_size (gnutls_mac_algorithm_t algorithm);
/* the name of the specified algorithms */
const char *gnutls_cipher_get_name (gnutls_cipher_algorithm_t algorithm);
const char *gnutls_mac_get_name (gnutls_mac_algorithm_t algorithm);
const char *gnutls_compression_get_name (gnutls_compression_method_t
algorithm);
const char *gnutls_kx_get_name (gnutls_kx_algorithm_t algorithm);
const char *gnutls_certificate_type_get_name (gnutls_certificate_type_t
type);
gnutls_mac_algorithm_t gnutls_mac_get_id (const char* name);
gnutls_compression_method_t gnutls_compression_get_id (const char* name);
gnutls_cipher_algorithm_t gnutls_cipher_get_id (const char* name);
gnutls_kx_algorithm_t gnutls_kx_get_id (const char* name);
gnutls_protocol_t gnutls_protocol_get_id (const char* name);
gnutls_certificate_type_t gnutls_certificate_type_get_id (const char* name);
const char * MHD_gnutls_cipher_get_name (gnutls_cipher_algorithm_t algorithm);
const char * MHD_gnutls_mac_get_name (gnutls_mac_algorithm_t algorithm);
const char * MHD_gnutls_compression_get_name (gnutls_compression_method_t
algorithm);
const char * MHD_gnutls_kx_get_name (gnutls_kx_algorithm_t algorithm);
const char * MHD_gnutls_certificate_type_get_name (gnutls_certificate_type_t
type);
gnutls_mac_algorithm_t MHD_gtls_mac_get_id (const char *name);
gnutls_compression_method_t MHD_gtls_compression_get_id (const char *name);
gnutls_cipher_algorithm_t MHD_gtls_cipher_get_id (const char *name);
gnutls_kx_algorithm_t MHD_gtls_kx_get_id (const char *name);
gnutls_protocol_t MHD_gtls_protocol_get_id (const char *name);
gnutls_certificate_type_t MHD_gtls_certificate_type_get_id (const char *name);
/* list supported algorithms */
const gnutls_cipher_algorithm_t *gnutls_cipher_list (void);
const gnutls_mac_algorithm_t *gnutls_mac_list (void);
const gnutls_compression_method_t *gnutls_compression_list (void);
const gnutls_protocol_t *gnutls_protocol_list (void);
const gnutls_certificate_type_t *gnutls_certificate_type_list (void);
const gnutls_kx_algorithm_t *gnutls_kx_list (void);
const char *gnutls_cipher_suite_info (size_t i,
char *id,
gnutls_kx_algorithm_t *kx,
gnutls_cipher_algorithm_t *cipher,
gnutls_mac_algorithm_t *mac,
gnutls_protocol_t *version);
const gnutls_cipher_algorithm_t * MHD_gtls_cipher_list (void);
const gnutls_mac_algorithm_t * MHD_gtls_mac_list (void);
const gnutls_compression_method_t * MHD_gtls_compression_list (void);
const gnutls_protocol_t * MHD_gtls_protocol_list (void);
const gnutls_certificate_type_t * MHD_gtls_certificate_type_list (void);
const gnutls_kx_algorithm_t * MHD_gtls_kx_list (void);
/* error functions */
int gnutls_error_is_fatal (int error);
int gnutls_error_to_alert (int err, int *level);
int MHD_gtls_error_is_fatal (int error);
int MHD_gtls_error_to_alert (int err, int *level);
void MHD_gtls_perror (int error);
const char * MHD_gtls_strerror (int error);
void gnutls_perror (int error);
const char *gnutls_strerror (int error);
void MHD_gtls_handshake_set_private_extensions (mhd_gtls_session_t session,
int allow);
gnutls_handshake_description_t
MHD_gtls_handshake_get_last_out (mhd_gtls_session_t session);
gnutls_handshake_description_t
MHD_gtls_handshake_get_last_in (mhd_gtls_session_t session);
/* Semi-internal functions.
/*
* Record layer functions.
*/
void gnutls_handshake_set_private_extensions (gnutls_session_t session,
int allow);
gnutls_handshake_description_t
gnutls_handshake_get_last_out (gnutls_session_t session);
gnutls_handshake_description_t
gnutls_handshake_get_last_in (gnutls_session_t session);
ssize_t MHD_gnutls_record_send (mhd_gtls_session_t session, const void *data,
size_t sizeofdata);
ssize_t MHD_gnutls_record_recv (mhd_gtls_session_t session, void *data,
size_t sizeofdata);
/* Record layer functions.
/* provides extra compatibility */
void MHD_gtls_record_disable_padding (mhd_gtls_session_t session);
size_t MHD_gtls_record_check_pending (mhd_gtls_session_t session);
int MHD_gnutls_record_get_direction (mhd_gtls_session_t session);
size_t MHD_gnutls_record_get_max_size (mhd_gtls_session_t session);
ssize_t MHD_gnutls_record_set_max_size (mhd_gtls_session_t session, size_t size);
int MHD_gnutls_prf (mhd_gtls_session_t session,
size_t label_size, const char *label,
int server_random_first,
size_t extra_size, const char *extra,
size_t outsize, char *out);
int MHD_gnutls_prf_raw (mhd_gtls_session_t session,
size_t label_size, const char *label,
size_t seed_size, const char *seed,
size_t outsize, char *out);
/*
* TLS Extensions
*/
ssize_t gnutls_record_send (gnutls_session_t session, const void *data,
size_t sizeofdata);
ssize_t gnutls_record_recv (gnutls_session_t session, void *data,
size_t sizeofdata);
#define gnutls_read gnutls_record_recv
#define gnutls_write gnutls_record_send
void gnutls_session_enable_compatibility_mode (gnutls_session_t session);
void gnutls_record_disable_padding (gnutls_session_t session);
int gnutls_record_get_direction (gnutls_session_t session);
size_t gnutls_record_get_max_size (gnutls_session_t session);
ssize_t gnutls_record_set_max_size (gnutls_session_t session, size_t size);
size_t gnutls_record_check_pending (gnutls_session_t session);
int gnutls_prf (gnutls_session_t session,
size_t label_size, const char *label,
int server_random_first,
size_t extra_size, const char *extra,
size_t outsize, char *out);
int gnutls_prf_raw (gnutls_session_t session,
size_t label_size, const char *label,
size_t seed_size, const char *seed,
size_t outsize, char *out);
/* TLS Extensions */
typedef enum
{
GNUTLS_NAME_DNS = 1
} gnutls_server_name_type_t;
int gnutls_server_name_set (gnutls_session_t session,
gnutls_server_name_type_t type,
const void *name, size_t name_length);
int MHD_gnutls_server_name_set (mhd_gtls_session_t session,
gnutls_server_name_type_t type,
const void *name, size_t name_length);
int gnutls_server_name_get (gnutls_session_t session,
void *data, size_t * data_length,
unsigned int *type, unsigned int indx);
int MHD_gnutls_server_name_get (mhd_gtls_session_t session,
void *data, size_t * data_length,
unsigned int *type, unsigned int indx);
/* Opaque PRF Input
* http://tools.ietf.org/id/draft-rescorla-tls-opaque-prf-input-00.txt
*/
void
gnutls_oprfi_enable_client (gnutls_session_t session,
size_t len,
unsigned char *data);
MHD_gtls_oprfi_enable_client (mhd_gtls_session_t session,
size_t len, unsigned char *data);
typedef int (*gnutls_oprfi_callback_func) (gnutls_session_t session,
void *userdata,
size_t oprfi_len,
const unsigned char *in_oprfi,
unsigned char *out_oprfi);
typedef int (*gnutls_oprfi_callback_func) (mhd_gtls_session_t session,
void *userdata,
size_t oprfi_len,
const unsigned char *in_oprfi,
unsigned char *out_oprfi);
void
gnutls_oprfi_enable_server (gnutls_session_t session,
gnutls_oprfi_callback_func cb,
void *userdata);
MHD_gtls_oprfi_enable_server (mhd_gtls_session_t session,
gnutls_oprfi_callback_func cb,
void *userdata);
/* Supplemental data, RFC 4680. */
typedef enum
{
GNUTLS_SUPPLEMENTAL_USER_MAPPING_DATA = 0
} gnutls_supplemental_data_format_type_t;
{
GNUTLS_SUPPLEMENTAL_USER_MAPPING_DATA = 0
} gnutls_supplemental_data_format_type_t;
const char *gnutls_supplemental_get_name
(gnutls_supplemental_data_format_type_t type);
const char * MHD_gtls_supplemental_get_name
(gnutls_supplemental_data_format_type_t type);
/* functions to set priority of cipher suites
*/
int gnutls_cipher_set_priority (gnutls_session_t session, const int *list);
int gnutls_mac_set_priority (gnutls_session_t session, const int *list);
int gnutls_compression_set_priority (gnutls_session_t session,
const int *list);
int gnutls_kx_set_priority (gnutls_session_t session, const int *list);
int gnutls_protocol_set_priority (gnutls_session_t session,
const int *list);
int gnutls_certificate_type_set_priority (gnutls_session_t session,
const int *list);
int MHD_gnutls_cipher_set_priority (mhd_gtls_session_t session, const int *list);
int MHD_gnutls_mac_set_priority (mhd_gtls_session_t session, const int *list);
int MHD_gnutls_compression_set_priority (mhd_gtls_session_t session,
const int *list);
int MHD_gnutls_kx_set_priority (mhd_gtls_session_t session, const int *list);
int MHD_gnutls_protocol_set_priority (mhd_gtls_session_t session,
const int *list);
int MHD_gnutls_certificate_type_set_priority (mhd_gtls_session_t session,
const int *list);
/* if you just want some defaults, use the following.
*/
int gnutls_priority_init( gnutls_priority_t * , const char *priority, const char** err_pos);
void gnutls_priority_deinit( gnutls_priority_t);
int MHD_tls_set_default_priority (gnutls_priority_t *, const char *priority,
const char **err_pos);
void MHD_gnutls_priority_deinit (gnutls_priority_t);
int gnutls_priority_set(gnutls_session_t session, gnutls_priority_t);
int gnutls_priority_set_direct(gnutls_session_t session, const char *priority, const char** err_pos);
/* for compatibility
*/
int gnutls_set_default_priority (gnutls_session_t session);
int gnutls_set_default_export_priority (gnutls_session_t session);
/* Returns the name of a cipher suite */
const char *gnutls_cipher_suite_get_name (gnutls_kx_algorithm_t
kx_algorithm,
gnutls_cipher_algorithm_t
cipher_algorithm,
gnutls_mac_algorithm_t
mac_algorithm);
int MHD_gnutls_priority_set (mhd_gtls_session_t session, gnutls_priority_t);
int MHD_gnutls_priority_set_direct (mhd_gtls_session_t session,
const char *priority, const char **err_pos);
/* get the currently used protocol version */
gnutls_protocol_t gnutls_protocol_get_version (gnutls_session_t session);
gnutls_protocol_t MHD_gnutls_protocol_get_version (mhd_gtls_session_t session);
const char *gnutls_protocol_get_name (gnutls_protocol_t version);
const char * MHD_gnutls_protocol_get_name (gnutls_protocol_t version);
/* get/set session
/*
* get/set session
*/
int gnutls_session_set_data (gnutls_session_t session,
const void *session_data,
size_t session_data_size);
int gnutls_session_get_data (gnutls_session_t session, void *session_data,
size_t * session_data_size);
int gnutls_session_get_data2 (gnutls_session_t session,
gnutls_datum_t * data);
// int gnutls_session_set_data (mhd_gtls_session_t session,
// const void *session_data,
// size_t session_data_size);
// int gnutls_session_get_data (mhd_gtls_session_t session, void *session_data,
// size_t * session_data_size);
// int gnutls_session_get_data2 (mhd_gtls_session_t session,
// gnutls_datum_t * data);
/* returns the session ID */
#define GNUTLS_MAX_SESSION_ID 32
int gnutls_session_get_id (gnutls_session_t session, void *session_id,
size_t * session_id_size);
int MHD_gtls_session_get_id (mhd_gtls_session_t session, void *session_id,
size_t * session_id_size);
/* returns security values.
* Do not use them unless you know what you're doing.
*/
#define TLS_MASTER_SIZE 48
#define TLS_RANDOM_SIZE 32
const void *gnutls_session_get_server_random (gnutls_session_t session);
const void *gnutls_session_get_client_random (gnutls_session_t session);
const void *gnutls_session_get_master_secret (gnutls_session_t session);
const void * MHD_gtls_session_get_server_random (mhd_gtls_session_t session);
const void * MHD_gtls_session_get_client_random (mhd_gtls_session_t session);
const void * MHD_gtls_session_get_master_secret (mhd_gtls_session_t session);
/* checks if this session is a resumed one
int MHD_gtls_session_is_resumed (mhd_gtls_session_t session);
typedef int (*gnutls_handshake_post_client_hello_func) (mhd_gtls_session_t);
void MHD_gnutls_handshake_set_post_client_hello_function (mhd_gtls_session_t,
gnutls_handshake_post_client_hello_func);
void MHD_gnutls_handshake_set_max_packet_length (mhd_gtls_session_t session,
size_t max);
/*
* Functions for setting/clearing credentials
*/
int gnutls_session_is_resumed (gnutls_session_t session);
void MHD_gnutls_credentials_clear (mhd_gtls_session_t session);
typedef int (*gnutls_db_store_func) (void *, gnutls_datum_t key,
gnutls_datum_t data);
typedef int (*gnutls_db_remove_func) (void *, gnutls_datum_t key);
typedef gnutls_datum_t (*gnutls_db_retr_func) (void *, gnutls_datum_t key);
void gnutls_db_set_cache_expiration (gnutls_session_t session, int seconds);
void gnutls_db_remove_session (gnutls_session_t session);
void gnutls_db_set_retrieve_function (gnutls_session_t session,
gnutls_db_retr_func retr_func);
void gnutls_db_set_remove_function (gnutls_session_t session,
gnutls_db_remove_func rem_func);
void gnutls_db_set_store_function (gnutls_session_t session,
gnutls_db_store_func store_func);
void gnutls_db_set_ptr (gnutls_session_t session, void *ptr);
void *gnutls_db_get_ptr (gnutls_session_t session);
int gnutls_db_check_entry (gnutls_session_t session,
gnutls_datum_t session_entry);
typedef int (*gnutls_handshake_post_client_hello_func)(gnutls_session_t);
void gnutls_handshake_set_post_client_hello_function(gnutls_session_t,
gnutls_handshake_post_client_hello_func);
void gnutls_handshake_set_max_packet_length (gnutls_session_t session,
size_t max);
/* Functions for setting/clearing credentials
/*
* cred is a structure defined by the kx algorithm
*/
void gnutls_credentials_clear (gnutls_session_t session);
int MHD_gnutls_credentials_set (mhd_gtls_session_t session,
gnutls_credentials_type_t type, void *cred);
/* cred is a structure defined by the kx algorithm
*/
int gnutls_credentials_set (gnutls_session_t session,
gnutls_credentials_type_t type, void *cred);
#define gnutls_cred_set gnutls_credentials_set
/* Credential structures - used in MHD_gnutls_credentials_set(); */
struct mhd_gtls_certificate_credentials_st;
typedef struct mhd_gtls_certificate_credentials_st
* mhd_gtls_cert_credentials_t;
typedef mhd_gtls_cert_credentials_t
mhd_gtls_cert_server_credentials;
typedef mhd_gtls_cert_credentials_t
mhd_gtls_cert_client_credentials;
/* Credential structures - used in gnutls_credentials_set(); */
typedef struct mhd_gtls_anon_server_credentials_st
* mhd_gtls_anon_server_credentials_t;
typedef struct mhd_gtls_anon_client_credentials_st
* mhd_gtls_anon_client_credentials_t;
struct gnutls_certificate_credentials_st;
typedef struct gnutls_certificate_credentials_st
*gnutls_certificate_credentials_t;
typedef gnutls_certificate_credentials_t
gnutls_certificate_server_credentials;
typedef gnutls_certificate_credentials_t
gnutls_certificate_client_credentials;
void MHD_gnutls_anon_free_server_credentials (mhd_gtls_anon_server_credentials_t
sc);
int
MHD_gnutls_anon_allocate_server_credentials (mhd_gtls_anon_server_credentials_t
* sc);
typedef struct gnutls_anon_server_credentials_st
*gnutls_anon_server_credentials_t;
typedef struct gnutls_anon_client_credentials_st
*gnutls_anon_client_credentials_t;
void gnutls_anon_free_server_credentials (gnutls_anon_server_credentials_t sc);
int gnutls_anon_allocate_server_credentials (gnutls_anon_server_credentials_t * sc);
void gnutls_anon_set_server_dh_params (gnutls_anon_server_credentials_t res,
gnutls_dh_params_t dh_params);
void MHD_gnutls_anon_set_server_dh_params (mhd_gtls_anon_server_credentials_t res,
mhd_gtls_dh_params_t dh_params);
void
gnutls_anon_set_server_params_function (gnutls_anon_server_credentials_t
res,
gnutls_params_function * func);
MHD_gnutls_anon_set_server_params_function (mhd_gtls_anon_server_credentials_t
res,
gnutls_params_function * func);
void gnutls_anon_free_client_credentials (gnutls_anon_client_credentials_t
sc);
void MHD_gnutls_anon_free_client_credentials (mhd_gtls_anon_client_credentials_t
sc);
int
gnutls_anon_allocate_client_credentials (gnutls_anon_client_credentials_t
* sc);
MHD_gnutls_anon_allocate_client_credentials (mhd_gtls_anon_client_credentials_t
* sc);
/* CERTFILE is an x509 certificate in PEM form.
* KEYFILE is a pkcs-1 private key in PEM form (for RSA keys).
*/
void gnutls_certificate_free_credentials (gnutls_certificate_credentials_t
sc);
void MHD_gnutls_certificate_free_credentials (mhd_gtls_cert_credentials_t
sc);
int
gnutls_certificate_allocate_credentials (gnutls_certificate_credentials_t
* res);
MHD_gnutls_certificate_allocate_credentials (mhd_gtls_cert_credentials_t
* res);
void gnutls_certificate_free_keys (gnutls_certificate_credentials_t sc);
void gnutls_certificate_free_cas (gnutls_certificate_credentials_t sc);
void gnutls_certificate_free_ca_names (gnutls_certificate_credentials_t sc);
void gnutls_certificate_free_crls (gnutls_certificate_credentials_t sc);
void MHD_gnutls_certificate_free_keys (mhd_gtls_cert_credentials_t sc);
void MHD_gnutls_certificate_free_cas (mhd_gtls_cert_credentials_t sc);
void MHD_gnutls_certificate_free_ca_names (mhd_gtls_cert_credentials_t sc);
void MHD_gnutls_certificate_free_crls (mhd_gtls_cert_credentials_t sc);
void gnutls_certificate_set_dh_params (gnutls_certificate_credentials_t res,
gnutls_dh_params_t dh_params);
void MHD_gnutls_certificate_set_dh_params (mhd_gtls_cert_credentials_t res,
mhd_gtls_dh_params_t dh_params);
void
gnutls_certificate_set_rsa_export_params (gnutls_certificate_credentials_t
res,
gnutls_rsa_params_t rsa_params);
void gnutls_certificate_set_verify_flags (gnutls_certificate_credentials_t
res, unsigned int flags);
void gnutls_certificate_set_verify_limits (gnutls_certificate_credentials_t
res, unsigned int max_bits,
unsigned int max_depth);
MHD_gnutls_certificate_set_rsa_export_params (mhd_gtls_cert_credentials_t
res,
mhd_gtls_rsa_params_t rsa_params);
void MHD_gnutls_certificate_set_verify_flags (mhd_gtls_cert_credentials_t
res, unsigned int flags);
void MHD_gnutls_certificate_set_verify_limits (mhd_gtls_cert_credentials_t
res, unsigned int max_bits,
unsigned int max_depth);
int gnutls_certificate_set_x509_trust_file (gnutls_certificate_credentials_t
res, const char *CAFILE,
gnutls_x509_crt_fmt_t type);
int gnutls_certificate_set_x509_trust_mem (gnutls_certificate_credentials_t
res, const gnutls_datum_t * CA,
gnutls_x509_crt_fmt_t type);
int MHD_gnutls_certificate_set_x509_trust_file (mhd_gtls_cert_credentials_t
res, const char *CAFILE,
gnutls_x509_crt_fmt_t type);
int MHD_gnutls_certificate_set_x509_trust_mem (mhd_gtls_cert_credentials_t
res, const gnutls_datum_t * CA,
gnutls_x509_crt_fmt_t type);
int gnutls_certificate_set_x509_crl_file (gnutls_certificate_credentials_t
res, const char *crlfile,
gnutls_x509_crt_fmt_t type);
int gnutls_certificate_set_x509_crl_mem (gnutls_certificate_credentials_t
res, const gnutls_datum_t * CRL,
gnutls_x509_crt_fmt_t type);
int MHD_gnutls_certificate_set_x509_crl_file (mhd_gtls_cert_credentials_t
res, const char *crlfile,
gnutls_x509_crt_fmt_t type);
int MHD_gnutls_certificate_set_x509_crl_mem (mhd_gtls_cert_credentials_t
res, const gnutls_datum_t * CRL,
gnutls_x509_crt_fmt_t type);
int gnutls_certificate_set_x509_key_file (gnutls_certificate_credentials_t
res, const char *CERTFILE,
const char *KEYFILE,
gnutls_x509_crt_fmt_t type);
int gnutls_certificate_set_x509_key_mem (gnutls_certificate_credentials_t
res, const gnutls_datum_t * CERT,
const gnutls_datum_t * KEY,
gnutls_x509_crt_fmt_t type);
/*
* CERTFILE is an x509 certificate in PEM form.
* KEYFILE is a pkcs-1 private key in PEM form (for RSA keys).
*/
int MHD_gnutls_certificate_set_x509_key_file (mhd_gtls_cert_credentials_t
res, const char *CERTFILE,
const char *KEYFILE,
gnutls_x509_crt_fmt_t type);
int MHD_gnutls_certificate_set_x509_key_mem (mhd_gtls_cert_credentials_t
res, const gnutls_datum_t * CERT,
const gnutls_datum_t * KEY,
gnutls_x509_crt_fmt_t type);
void gnutls_certificate_send_x509_rdn_sequence (gnutls_session_t session,
int status);
void MHD_gnutls_certificate_send_x509_rdn_sequence (mhd_gtls_session_t session,
int status);
extern int
gnutls_certificate_set_x509_simple_pkcs12_file
(gnutls_certificate_credentials_t res, const char *pkcs12file,
gnutls_x509_crt_fmt_t type, const char *password);
/* New functions to allow setting already parsed X.509 stuff.
/*
* New functions to allow setting already parsed X.509 stuff.
*/
struct gnutls_x509_privkey_int;
typedef struct gnutls_x509_privkey_int *gnutls_x509_privkey_t;
struct MHD_gtls_x509_privkey_int;
typedef struct MHD_gtls_x509_privkey_int *gnutls_x509_privkey_t;
struct gnutls_x509_crl_int;
typedef struct gnutls_x509_crl_int *gnutls_x509_crl_t;
struct gnutls_x509_crt_int;
typedef struct gnutls_x509_crt_int * gnutls_x509_crt_t;
typedef struct gnutls_x509_crt_int *gnutls_x509_crt_t;
int gnutls_certificate_set_x509_key (gnutls_certificate_credentials_t res,
gnutls_x509_crt_t * cert_list,
int cert_list_size,
gnutls_x509_privkey_t key);
int gnutls_certificate_set_x509_trust (gnutls_certificate_credentials_t res,
gnutls_x509_crt_t * ca_list,
int ca_list_size);
int gnutls_certificate_set_x509_crl (gnutls_certificate_credentials_t res,
gnutls_x509_crl_t * crl_list,
int crl_list_size);
// int gnutls_certificate_set_x509_key (mhd_gtls_cert_credentials_t res,
// gnutls_x509_crt_t * cert_list,
// int cert_list_size,
// gnutls_x509_privkey_t key);
// int gnutls_certificate_set_x509_trust (mhd_gtls_cert_credentials_t res,
// gnutls_x509_crt_t * ca_list,
// int ca_list_size);
// int gnutls_certificate_set_x509_crl (mhd_gtls_cert_credentials_t res,
// gnutls_x509_crl_t * crl_list,
// int crl_list_size);
/* global state functions
*/
int gnutls_global_init (void);
void gnutls_global_deinit (void);
typedef void *(*gnutls_alloc_function) (size_t);
typedef void *(*gnutls_calloc_function) (size_t, size_t);
@@ -625,13 +547,13 @@ extern "C"
typedef void *(*gnutls_realloc_function) (void *, size_t);
extern void
gnutls_global_set_mem_functions (gnutls_alloc_function gt_alloc_func,
gnutls_alloc_function
gt_secure_alloc_func,
gnutls_is_secure_function
gt_is_secure_func,
gnutls_realloc_function gt_realloc_func,
gnutls_free_function gt_free_func);
MHD_gtls_global_set_mem_functions (gnutls_alloc_function gt_alloc_func,
gnutls_alloc_function
gt_secure_alloc_func,
gnutls_is_secure_function
gt_is_secure_func,
gnutls_realloc_function gt_realloc_func,
gnutls_free_function gt_free_func);
/* For use in callbacks */
extern gnutls_alloc_function gnutls_malloc;
@@ -643,235 +565,225 @@ extern "C"
extern char *(*gnutls_strdup) (const char *);
typedef void (*gnutls_log_func) (int, const char *);
void gnutls_global_set_log_function (gnutls_log_func log_func);
void gnutls_global_set_log_level (int level);
void MHD_gtls_global_set_log_function (gnutls_log_func log_func);
void MHD_gtls_global_set_log_level (int level);
/* Diffie Hellman parameter handling.
/*
* Diffie Hellman parameter handling.
*/
int gnutls_dh_params_init (gnutls_dh_params_t * dh_params);
void gnutls_dh_params_deinit (gnutls_dh_params_t dh_params);
int gnutls_dh_params_import_raw (gnutls_dh_params_t dh_params,
const gnutls_datum_t * prime,
const gnutls_datum_t * generator);
int gnutls_dh_params_import_pkcs3 (gnutls_dh_params_t params,
const gnutls_datum_t * pkcs3_params,
gnutls_x509_crt_fmt_t format);
int gnutls_dh_params_generate2 (gnutls_dh_params_t params,
unsigned int bits);
int gnutls_dh_params_export_pkcs3 (gnutls_dh_params_t params,
gnutls_x509_crt_fmt_t format,
unsigned char *params_data,
size_t * params_data_size);
int gnutls_dh_params_export_raw (gnutls_dh_params_t params,
gnutls_datum_t * prime,
gnutls_datum_t * generator,
unsigned int *bits);
int gnutls_dh_params_cpy (gnutls_dh_params_t dst, gnutls_dh_params_t src);
int MHD_gnutls_dh_params_init (mhd_gtls_dh_params_t * dh_params);
void MHD_gnutls_dh_params_deinit (mhd_gtls_dh_params_t dh_params);
int MHD_gnutls_dh_params_generate2 (mhd_gtls_dh_params_t params,
unsigned int bits);
// int MHD_gnutls_dh_params_import_raw (mhd_gtls_dh_params_t dh_params,
// const gnutls_datum_t * prime,
// const gnutls_datum_t * generator);
// int MHD_gnutls_dh_params_export_raw (mhd_gtls_dh_params_t params,
// gnutls_datum_t * prime,
// gnutls_datum_t * generator,
// unsigned int *bits);
// int gnutls_dh_params_import_pkcs3 (mhd_gtls_dh_params_t params,
// const gnutls_datum_t * pkcs3_params,
// gnutls_x509_crt_fmt_t format);
// int gnutls_dh_params_export_pkcs3 (mhd_gtls_dh_params_t params,
// gnutls_x509_crt_fmt_t format,
// unsigned char *params_data,
// size_t * params_data_size);
/* RSA params
/* RSA params */
int MHD_gnutls_rsa_params_init (mhd_gtls_rsa_params_t * rsa_params);
void MHD_gnutls_rsa_params_deinit (mhd_gtls_rsa_params_t rsa_params);
int MHD_gnutls_rsa_params_generate2 (mhd_gtls_rsa_params_t params,
unsigned int bits);
// int gnutls_rsa_params_import_raw (mhd_gtls_rsa_params_t rsa_params,
// const gnutls_datum_t * m,
// const gnutls_datum_t * e,
// const gnutls_datum_t * d,
// const gnutls_datum_t * p,
// const gnutls_datum_t * q,
// const gnutls_datum_t * u);
// int gnutls_rsa_params_export_raw (mhd_gtls_rsa_params_t params,
// gnutls_datum_t * m, gnutls_datum_t * e,
// gnutls_datum_t * d, gnutls_datum_t * p,
// gnutls_datum_t * q, gnutls_datum_t * u,
// unsigned int *bits);
/*
* Session stuff
*/
int gnutls_rsa_params_init (gnutls_rsa_params_t * rsa_params);
void gnutls_rsa_params_deinit (gnutls_rsa_params_t rsa_params);
int gnutls_rsa_params_cpy (gnutls_rsa_params_t dst,
gnutls_rsa_params_t src);
int gnutls_rsa_params_import_raw (gnutls_rsa_params_t rsa_params,
const gnutls_datum_t * m,
const gnutls_datum_t * e,
const gnutls_datum_t * d,
const gnutls_datum_t * p,
const gnutls_datum_t * q,
const gnutls_datum_t * u);
int gnutls_rsa_params_generate2 (gnutls_rsa_params_t params,
unsigned int bits);
int gnutls_rsa_params_export_raw (gnutls_rsa_params_t params,
gnutls_datum_t * m, gnutls_datum_t * e,
gnutls_datum_t * d, gnutls_datum_t * p,
gnutls_datum_t * q, gnutls_datum_t * u,
unsigned int *bits);
int gnutls_rsa_params_export_pkcs1 (gnutls_rsa_params_t params,
gnutls_x509_crt_fmt_t format,
unsigned char *params_data,
size_t * params_data_size);
int gnutls_rsa_params_import_pkcs1 (gnutls_rsa_params_t params,
const gnutls_datum_t * pkcs1_params,
gnutls_x509_crt_fmt_t format);
typedef ssize_t (* mhd_gtls_pull_func) (gnutls_transport_ptr_t, void *,
size_t);
typedef ssize_t (* mhd_gtls_push_func) (gnutls_transport_ptr_t, const void *,
size_t);
void MHD_gnutls_transport_set_ptr (mhd_gtls_session_t session,
gnutls_transport_ptr_t ptr);
void MHD_gnutls_transport_set_ptr2 (mhd_gtls_session_t session,
gnutls_transport_ptr_t recv_ptr,
gnutls_transport_ptr_t send_ptr);
/* Session stuff
void MHD_gnutls_transport_set_lowat (mhd_gtls_session_t session, int num);
void MHD_gnutls_transport_set_push_function (mhd_gtls_session_t session,
mhd_gtls_push_func push_func);
void MHD_gnutls_transport_set_pull_function (mhd_gtls_session_t session,
mhd_gtls_pull_func pull_func);
void MHD_gnutls_transport_set_errno (mhd_gtls_session_t session, int err);
void MHD_gnutls_transport_set_global_errno (int err);
/*
* session specific
*/
typedef ssize_t (*gnutls_pull_func) (gnutls_transport_ptr_t, void *,
size_t);
typedef ssize_t (*gnutls_push_func) (gnutls_transport_ptr_t, const void *,
size_t);
void gnutls_transport_set_ptr (gnutls_session_t session,
gnutls_transport_ptr_t ptr);
void gnutls_transport_set_ptr2 (gnutls_session_t session,
gnutls_transport_ptr_t recv_ptr,
gnutls_transport_ptr_t send_ptr);
void MHD_gnutls_session_set_ptr (mhd_gtls_session_t session, void *ptr);
void * MHD_gtls_session_get_ptr (mhd_gtls_session_t session);
gnutls_transport_ptr_t gnutls_transport_get_ptr (gnutls_session_t session);
void gnutls_transport_get_ptr2 (gnutls_session_t session,
gnutls_transport_ptr_t * recv_ptr,
gnutls_transport_ptr_t * send_ptr);
void MHD_gtls_openpgp_send_cert (mhd_gtls_session_t session,
gnutls_openpgp_crt_status_t status);
void gnutls_transport_set_lowat (gnutls_session_t session, int num);
void gnutls_transport_set_push_function (gnutls_session_t session,
gnutls_push_func push_func);
void gnutls_transport_set_pull_function (gnutls_session_t session,
gnutls_pull_func pull_func);
void gnutls_transport_set_errno (gnutls_session_t session, int err);
void gnutls_transport_set_global_errno (int err);
/* session specific
/*
* this function returns the hash of the given data.
*/
void gnutls_session_set_ptr (gnutls_session_t session, void *ptr);
void *gnutls_session_get_ptr (gnutls_session_t session);
int MHD_gnutls_fingerprint (gnutls_digest_algorithm_t algo,
const gnutls_datum_t * data, void *result,
size_t * result_size);
void gnutls_openpgp_send_cert (gnutls_session_t session,
gnutls_openpgp_crt_status_t status);
/* fingerprint
* Actually this function returns the hash of the given data.
/*
* SRP
*/
int gnutls_fingerprint (gnutls_digest_algorithm_t algo,
const gnutls_datum_t * data, void *result,
size_t * result_size);
// typedef struct gnutls_srp_server_credentials_st
// *gnutls_srp_server_credentials_t;
// typedef struct gnutls_srp_client_credentials_st
// *gnutls_srp_client_credentials_t;
//
// void gnutls_srp_free_client_credentials (gnutls_srp_client_credentials_t
// sc);
// int gnutls_srp_allocate_client_credentials (gnutls_srp_client_credentials_t
// * sc);
// int gnutls_srp_set_client_credentials (gnutls_srp_client_credentials_t res,
// const char *username,
// const char *password);
//
// void gnutls_srp_free_server_credentials (gnutls_srp_server_credentials_t
// sc);
// int gnutls_srp_allocate_server_credentials (gnutls_srp_server_credentials_t
// * sc);
// int gnutls_srp_set_server_credentials_file (gnutls_srp_server_credentials_t
// res, const char *password_file,
// const char *password_conf_file);
//
// const char *gnutls_srp_server_get_username (mhd_gtls_session_t session);
//
// extern int gnutls_srp_verifier (const char *username,
// const char *password,
// const gnutls_datum_t * salt,
// const gnutls_datum_t * generator,
// const gnutls_datum_t * prime,
// gnutls_datum_t * res);
//
///* The static parameters defined in draft-ietf-tls-srp-05
// * Those should be used as input to gnutls_srp_verifier().
// */
// extern const gnutls_datum_t gnutls_srp_2048_group_prime;
// extern const gnutls_datum_t gnutls_srp_2048_group_generator;
//
// extern const gnutls_datum_t gnutls_srp_1536_group_prime;
// extern const gnutls_datum_t gnutls_srp_1536_group_generator;
//
// extern const gnutls_datum_t gnutls_srp_1024_group_prime;
// extern const gnutls_datum_t gnutls_srp_1024_group_generator;
//
// typedef int gnutls_srp_server_credentials_function (mhd_gtls_session_t,
// const char *username,
// gnutls_datum_t * salt,
// gnutls_datum_t *
// verifier,
// gnutls_datum_t *
// generator,
// gnutls_datum_t * prime);
// void
// gnutls_srp_set_server_credentials_function
// (gnutls_srp_server_credentials_t cred,
// gnutls_srp_server_credentials_function * func);
//
// typedef int gnutls_srp_client_credentials_function (mhd_gtls_session_t,
// char **, char **);
// void
// gnutls_srp_set_client_credentials_function
// (gnutls_srp_client_credentials_t cred,
// gnutls_srp_client_credentials_function * func);
//
// int gnutls_srp_base64_encode (const gnutls_datum_t * data, char *result,
// size_t * result_size);
// int gnutls_srp_base64_encode_alloc (const gnutls_datum_t * data,
// gnutls_datum_t * result);
//
// int gnutls_srp_base64_decode (const gnutls_datum_t * b64_data, char *result,
// size_t * result_size);
// int gnutls_srp_base64_decode_alloc (const gnutls_datum_t * b64_data,
// gnutls_datum_t * result);
/* SRP
/*
* PSK stuff
*/
typedef struct gnutls_srp_server_credentials_st
*gnutls_srp_server_credentials_t;
typedef struct gnutls_srp_client_credentials_st
*gnutls_srp_client_credentials_t;
void gnutls_srp_free_client_credentials (gnutls_srp_client_credentials_t
sc);
int gnutls_srp_allocate_client_credentials (gnutls_srp_client_credentials_t
* sc);
int gnutls_srp_set_client_credentials (gnutls_srp_client_credentials_t res,
const char *username, const char *password);
void gnutls_srp_free_server_credentials (gnutls_srp_server_credentials_t
sc);
int gnutls_srp_allocate_server_credentials (gnutls_srp_server_credentials_t
* sc);
int gnutls_srp_set_server_credentials_file (gnutls_srp_server_credentials_t
res, const char *password_file,
const char *password_conf_file);
const char *gnutls_srp_server_get_username (gnutls_session_t session);
extern int gnutls_srp_verifier (const char *username,
const char *password,
const gnutls_datum_t * salt,
const gnutls_datum_t * generator,
const gnutls_datum_t * prime,
gnutls_datum_t * res);
/* The static parameters defined in draft-ietf-tls-srp-05
* Those should be used as input to gnutls_srp_verifier().
*/
extern const gnutls_datum_t gnutls_srp_2048_group_prime;
extern const gnutls_datum_t gnutls_srp_2048_group_generator;
extern const gnutls_datum_t gnutls_srp_1536_group_prime;
extern const gnutls_datum_t gnutls_srp_1536_group_generator;
extern const gnutls_datum_t gnutls_srp_1024_group_prime;
extern const gnutls_datum_t gnutls_srp_1024_group_generator;
typedef int gnutls_srp_server_credentials_function (gnutls_session_t,
const char *username,
gnutls_datum_t * salt,
gnutls_datum_t *
verifier,
gnutls_datum_t *
generator,
gnutls_datum_t * prime);
void
gnutls_srp_set_server_credentials_function
(gnutls_srp_server_credentials_t cred,
gnutls_srp_server_credentials_function * func);
typedef int gnutls_srp_client_credentials_function (gnutls_session_t,
char **, char **);
void
gnutls_srp_set_client_credentials_function
(gnutls_srp_client_credentials_t cred,
gnutls_srp_client_credentials_function * func);
int gnutls_srp_base64_encode (const gnutls_datum_t * data, char *result,
size_t * result_size);
int gnutls_srp_base64_encode_alloc (const gnutls_datum_t * data,
gnutls_datum_t * result);
int gnutls_srp_base64_decode (const gnutls_datum_t * b64_data, char *result,
size_t * result_size);
int gnutls_srp_base64_decode_alloc (const gnutls_datum_t * b64_data,
gnutls_datum_t * result);
/* PSK stuff */
typedef struct gnutls_psk_server_credentials_st
*gnutls_psk_server_credentials_t;
typedef struct gnutls_psk_client_credentials_st
*gnutls_psk_client_credentials_t;
typedef enum gnutls_psk_key_flags
{
GNUTLS_PSK_KEY_RAW = 0,
GNUTLS_PSK_KEY_HEX
} gnutls_psk_key_flags;
void gnutls_psk_free_client_credentials (gnutls_psk_client_credentials_t
sc);
int gnutls_psk_allocate_client_credentials (gnutls_psk_client_credentials_t
* sc);
int gnutls_psk_set_client_credentials (gnutls_psk_client_credentials_t res,
const char *username,
const gnutls_datum_t * key,
gnutls_psk_key_flags format);
void gnutls_psk_free_server_credentials (gnutls_psk_server_credentials_t
sc);
int gnutls_psk_allocate_server_credentials (gnutls_psk_server_credentials_t
* sc);
int gnutls_psk_set_server_credentials_file (gnutls_psk_server_credentials_t
res, const char *password_file);
const char *gnutls_psk_server_get_username (gnutls_session_t session);
typedef int gnutls_psk_server_credentials_function (gnutls_session_t,
const char *username,
gnutls_datum_t * key);
void
gnutls_psk_set_server_credentials_function
(gnutls_psk_server_credentials_t cred,
gnutls_psk_server_credentials_function * func);
typedef int gnutls_psk_client_credentials_function (gnutls_session_t,
char **username,
gnutls_datum_t * key);
void
gnutls_psk_set_client_credentials_function
(gnutls_psk_client_credentials_t cred,
gnutls_psk_client_credentials_function * func);
int gnutls_hex_encode (const gnutls_datum_t * data, char *result,
size_t * result_size);
int gnutls_hex_decode (const gnutls_datum_t * hex_data, char *result,
size_t * result_size);
void gnutls_psk_set_server_dh_params (gnutls_psk_server_credentials_t res,
gnutls_dh_params_t dh_params);
void gnutls_psk_set_server_params_function (gnutls_psk_server_credentials_t
res,
gnutls_params_function * func);
// typedef struct gnutls_psk_server_credentials_st
// *gnutls_psk_server_credentials_t;
// typedef struct gnutls_psk_client_credentials_st
// *gnutls_psk_client_credentials_t;
//
// typedef enum gnutls_psk_key_flags
// {
// GNUTLS_PSK_KEY_RAW = 0,
// GNUTLS_PSK_KEY_HEX
// } gnutls_psk_key_flags;
//
// void gnutls_psk_free_client_credentials (gnutls_psk_client_credentials_t
// sc);
// int gnutls_psk_allocate_client_credentials (gnutls_psk_client_credentials_t
// * sc);
// int gnutls_psk_set_client_credentials (gnutls_psk_client_credentials_t res,
// const char *username,
// const gnutls_datum_t * key,
// gnutls_psk_key_flags format);
//
// void gnutls_psk_free_server_credentials (gnutls_psk_server_credentials_t
// sc);
// int gnutls_psk_allocate_server_credentials (gnutls_psk_server_credentials_t
// * sc);
// int gnutls_psk_set_server_credentials_file (gnutls_psk_server_credentials_t
// res, const char *password_file);
//
// const char *gnutls_psk_server_get_username (mhd_gtls_session_t session);
//
// typedef int gnutls_psk_server_credentials_function (mhd_gtls_session_t,
// const char *username,
// gnutls_datum_t * key);
// void
// gnutls_psk_set_server_credentials_function
// (gnutls_psk_server_credentials_t cred,
// gnutls_psk_server_credentials_function * func);
//
// typedef int gnutls_psk_client_credentials_function (mhd_gtls_session_t,
// char **username,
// gnutls_datum_t * key);
// void
// gnutls_psk_set_client_credentials_function
// (gnutls_psk_client_credentials_t cred,
// gnutls_psk_client_credentials_function * func);
//
// int gnutls_hex_encode (const gnutls_datum_t * data, char *result,
// size_t * result_size);
// int gnutls_hex_decode (const gnutls_datum_t * hex_data, char *result,
// size_t * result_size);
//
// void gnutls_psk_set_server_dh_params (gnutls_psk_server_credentials_t res,
// mhd_gtls_dh_params_t dh_params);
//
// void gnutls_psk_set_server_params_function (gnutls_psk_server_credentials_t
// res,
// gnutls_params_function * func);
typedef enum gnutls_x509_subject_alt_name_t
{
@@ -901,7 +813,7 @@ extern "C"
gnutls_x509_crt_t *x509;
gnutls_openpgp_crt_t pgp;
} cert;
unsigned int ncerts; /* one for pgp keys */
unsigned int ncerts; /* one for pgp keys */
union key
{
@@ -909,118 +821,122 @@ extern "C"
gnutls_openpgp_privkey_t pgp;
} key;
unsigned int deinit_all; /* if non zero all keys will be deinited */
unsigned int deinit_all; /* if non zero all keys will be deinited */
} gnutls_retr_st;
typedef int gnutls_certificate_client_retrieve_function (gnutls_session_t,
const
gnutls_datum_t *
req_ca_rdn,
int nreqs,
const
gnutls_pk_algorithm_t
* pk_algos,
int
pk_algos_length,
gnutls_retr_st *);
typedef int gnutls_certificate_server_retrieve_function (gnutls_session_t,
gnutls_retr_st *);
typedef int gnutls_certificate_client_retrieve_function (mhd_gtls_session_t,
const
gnutls_datum_t *
req_ca_rdn,
int nreqs,
const
gnutls_pk_algorithm_t
* pk_algos,
int
pk_algos_length,
gnutls_retr_st *);
typedef int gnutls_certificate_server_retrieve_function (mhd_gtls_session_t,
gnutls_retr_st *);
/* Functions that allow auth_info_t structures handling
/*
* Functions that allow auth_info_t structures handling
*/
gnutls_credentials_type_t gnutls_auth_get_type (gnutls_session_t session);
gnutls_credentials_type_t MHD_gtls_auth_get_type (mhd_gtls_session_t session);
gnutls_credentials_type_t
gnutls_auth_server_get_type (gnutls_session_t session);
MHD_gtls_auth_server_get_type (mhd_gtls_session_t session);
gnutls_credentials_type_t
gnutls_auth_client_get_type (gnutls_session_t session);
MHD_gtls_auth_client_get_type (mhd_gtls_session_t session);
/* DH */
/*
* DH
*/
void MHD_gnutls_dh_set_prime_bits (mhd_gtls_session_t session, unsigned int bits);
int MHD_gnutls_dh_get_secret_bits (mhd_gtls_session_t session);
int MHD_gnutls_dh_get_peers_public_bits (mhd_gtls_session_t session);
int MHD_gnutls_dh_get_prime_bits (mhd_gtls_session_t session);
void gnutls_dh_set_prime_bits (gnutls_session_t session, unsigned int bits);
int gnutls_dh_get_secret_bits (gnutls_session_t session);
int gnutls_dh_get_peers_public_bits (gnutls_session_t session);
int gnutls_dh_get_prime_bits (gnutls_session_t session);
int MHD_gnutls_dh_get_group (mhd_gtls_session_t session, gnutls_datum_t * raw_gen,
gnutls_datum_t * raw_prime);
int MHD_gnutls_dh_get_pubkey (mhd_gtls_session_t session,
gnutls_datum_t * raw_key);
int gnutls_dh_get_group (gnutls_session_t session, gnutls_datum_t * raw_gen,
gnutls_datum_t * raw_prime);
int gnutls_dh_get_pubkey (gnutls_session_t session,
gnutls_datum_t * raw_key);
/* RSA */
int gnutls_rsa_export_get_pubkey (gnutls_session_t session,
gnutls_datum_t * exponent,
gnutls_datum_t * modulus);
int gnutls_rsa_export_get_modulus_bits (gnutls_session_t session);
/* X509PKI */
/*
* RSA
*/
int MHD_gtls_rsa_export_get_pubkey (mhd_gtls_session_t session,
gnutls_datum_t * exponent,
gnutls_datum_t * modulus);
int MHD_gtls_rsa_export_get_modulus_bits (mhd_gtls_session_t session);
/* External signing callback. Experimental. */
typedef int (*gnutls_sign_func) (gnutls_session_t session,
void *userdata,
gnutls_certificate_type_t cert_type,
const gnutls_datum_t * cert,
const gnutls_datum_t * hash,
gnutls_datum_t * signature);
typedef int (*gnutls_sign_func) (mhd_gtls_session_t session,
void *userdata,
gnutls_certificate_type_t cert_type,
const gnutls_datum_t * cert,
const gnutls_datum_t * hash,
gnutls_datum_t * signature);
void gnutls_sign_callback_set (gnutls_session_t session,
gnutls_sign_func sign_func,
void *userdata);
gnutls_sign_func
gnutls_sign_callback_get (gnutls_session_t session,
void **userdata);
void MHD_gtls_sign_callback_set (mhd_gtls_session_t session,
gnutls_sign_func sign_func, void *userdata);
gnutls_sign_func
MHD_gtls_sign_callback_get (mhd_gtls_session_t session, void **userdata);
/* These are set on the credentials structure.
*/
void gnutls_certificate_client_set_retrieve_function
(gnutls_certificate_credentials_t cred,
void MHD_gtls_certificate_client_set_retrieve_function
(mhd_gtls_cert_credentials_t cred,
gnutls_certificate_client_retrieve_function * func);
void gnutls_certificate_server_set_retrieve_function
(gnutls_certificate_credentials_t cred,
void MHD_gtls_certificate_server_set_retrieve_function
(mhd_gtls_cert_credentials_t cred,
gnutls_certificate_server_retrieve_function * func);
void gnutls_certificate_server_set_request (gnutls_session_t session,
gnutls_certificate_request_t
req);
void MHD_gtls_certificate_server_set_request (mhd_gtls_session_t session,
gnutls_certificate_request_t
req);
/* get data from the session
*/
const gnutls_datum_t *gnutls_certificate_get_peers (gnutls_session_t
session,
unsigned int
*list_size);
const gnutls_datum_t *gnutls_certificate_get_ours (gnutls_session_t
session);
/* get data from the session */
const gnutls_datum_t * MHD_gtls_certificate_get_peers (mhd_gtls_session_t
session,
unsigned int
*list_size);
const gnutls_datum_t * MHD_gtls_certificate_get_ours (mhd_gtls_session_t
session);
time_t gnutls_certificate_activation_time_peers (gnutls_session_t session);
time_t gnutls_certificate_expiration_time_peers (gnutls_session_t session);
time_t MHD_gtls_certificate_activation_time_peers (mhd_gtls_session_t session);
time_t MHD_gtls_certificate_expiration_time_peers (mhd_gtls_session_t session);
int gnutls_certificate_client_get_request_status (gnutls_session_t session);
int gnutls_certificate_verify_peers2 (gnutls_session_t session,
unsigned int *status);
int MHD_gtls_certificate_client_get_request_status (mhd_gtls_session_t session);
int MHD_gtls_certificate_verify_peers2 (mhd_gtls_session_t session,
unsigned int *status);
/* this is obsolete (?). */
int gnutls_certificate_verify_peers (gnutls_session_t session);
int MHD_gtls_certificate_verify_peers (mhd_gtls_session_t session);
int gnutls_pem_base64_encode (const char *msg, const gnutls_datum_t * data,
char *result, size_t * result_size);
int gnutls_pem_base64_decode (const char *header,
const gnutls_datum_t * b64_data,
unsigned char *result, size_t * result_size);
int MHD_gtls_pem_base64_encode (const char *msg, const gnutls_datum_t * data,
char *result, size_t * result_size);
int MHD_gtls_pem_base64_decode (const char *header,
const gnutls_datum_t * b64_data,
unsigned char *result, size_t * result_size);
int gnutls_pem_base64_encode_alloc (const char *msg,
const gnutls_datum_t * data,
gnutls_datum_t * result);
int gnutls_pem_base64_decode_alloc (const char *header,
const gnutls_datum_t * b64_data,
gnutls_datum_t * result);
int MHD_gtls_pem_base64_encode_alloc (const char *msg,
const gnutls_datum_t * data,
gnutls_datum_t * result);
int MHD_gtls_pem_base64_decode_alloc (const char *header,
const gnutls_datum_t * b64_data,
gnutls_datum_t * result);
int gnutls_global_init (void);
// void
// gnutls_certificate_set_params_function (mhd_gtls_cert_credentials_t
// res,
// gnutls_params_function * func);
// void gnutls_anon_set_params_function (mhd_gtls_anon_server_credentials_t res,
// gnutls_params_function * func);
// void gnutls_psk_set_params_function (gnutls_psk_server_credentials_t res,
// gnutls_params_function * func);
/* key_usage will be an OR of the following values:
*/
/* key_usage will be an OR of the following values: */
/* when the key is to be used for signing: */
#define GNUTLS_KEY_DIGITAL_SIGNATURE 128
#define GNUTLS_KEY_NON_REPUDIATION 64
@@ -1033,51 +949,42 @@ extern "C"
#define GNUTLS_KEY_ENCIPHER_ONLY 1
#define GNUTLS_KEY_DECIPHER_ONLY 32768
void
gnutls_certificate_set_params_function (gnutls_certificate_credentials_t res,
gnutls_params_function * func);
void gnutls_anon_set_params_function (gnutls_anon_server_credentials_t res,
gnutls_params_function * func);
void gnutls_psk_set_params_function (gnutls_psk_server_credentials_t res,
gnutls_params_function * func);
/* Gnutls error codes. The mapping to a TLS alert is also shown in
* comments.
/*
* Error codes. TLS alert mapping shown in comments.
*/
#define GNUTLS_E_SUCCESS 0
#define GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM -3
#define GNUTLS_E_UNKNOWN_CIPHER_TYPE -6
#define GNUTLS_E_LARGE_PACKET -7
#define GNUTLS_E_UNSUPPORTED_VERSION_PACKET -8 /* GNUTLS_A_PROTOCOL_VERSION */
#define GNUTLS_E_UNEXPECTED_PACKET_LENGTH -9 /* GNUTLS_A_RECORD_OVERFLOW */
#define GNUTLS_E_UNSUPPORTED_VERSION_PACKET -8 /* GNUTLS_A_PROTOCOL_VERSION */
#define GNUTLS_E_UNEXPECTED_PACKET_LENGTH -9 /* GNUTLS_A_RECORD_OVERFLOW */
#define GNUTLS_E_INVALID_SESSION -10
#define GNUTLS_E_FATAL_ALERT_RECEIVED -12
#define GNUTLS_E_UNEXPECTED_PACKET -15 /* GNUTLS_A_UNEXPECTED_MESSAGE */
#define GNUTLS_E_UNEXPECTED_PACKET -15 /* GNUTLS_A_UNEXPECTED_MESSAGE */
#define GNUTLS_E_WARNING_ALERT_RECEIVED -16
#define GNUTLS_E_ERROR_IN_FINISHED_PACKET -18
#define GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET -19
#define GNUTLS_E_UNKNOWN_CIPHER_SUITE -21 /* GNUTLS_A_HANDSHAKE_FAILURE */
#define GNUTLS_E_UNKNOWN_CIPHER_SUITE -21 /* GNUTLS_A_HANDSHAKE_FAILURE */
#define GNUTLS_E_UNWANTED_ALGORITHM -22
#define GNUTLS_E_MPI_SCAN_FAILED -23
#define GNUTLS_E_DECRYPTION_FAILED -24 /* GNUTLS_A_DECRYPTION_FAILED, GNUTLS_A_BAD_RECORD_MAC */
#define GNUTLS_E_DECRYPTION_FAILED -24 /* GNUTLS_A_DECRYPTION_FAILED, GNUTLS_A_BAD_RECORD_MAC */
#define GNUTLS_E_MEMORY_ERROR -25
#define GNUTLS_E_DECOMPRESSION_FAILED -26 /* GNUTLS_A_DECOMPRESSION_FAILURE */
#define GNUTLS_E_DECOMPRESSION_FAILED -26 /* GNUTLS_A_DECOMPRESSION_FAILURE */
#define GNUTLS_E_COMPRESSION_FAILED -27
#define GNUTLS_E_AGAIN -28
#define GNUTLS_E_EXPIRED -29
#define GNUTLS_E_DB_ERROR -30
#define GNUTLS_E_SRP_PWD_ERROR -31
#define GNUTLS_E_INSUFFICIENT_CREDENTIALS -32
#define GNUTLS_E_INSUFICIENT_CREDENTIALS GNUTLS_E_INSUFFICIENT_CREDENTIALS /* for backwards compatibility only */
#define GNUTLS_E_INSUFICIENT_CREDENTIALS GNUTLS_E_INSUFFICIENT_CREDENTIALS /* for backwards compatibility only */
#define GNUTLS_E_INSUFFICIENT_CRED GNUTLS_E_INSUFFICIENT_CREDENTIALS
#define GNUTLS_E_INSUFICIENT_CRED GNUTLS_E_INSUFFICIENT_CREDENTIALS /* for backwards compatibility only */
#define GNUTLS_E_INSUFICIENT_CRED GNUTLS_E_INSUFFICIENT_CREDENTIALS /* for backwards compatibility only */
#define GNUTLS_E_HASH_FAILED -33
#define GNUTLS_E_BASE64_DECODING_ERROR -34
#define GNUTLS_E_MPI_PRINT_FAILED -35
#define GNUTLS_E_REHANDSHAKE -37 /* GNUTLS_A_NO_RENEGOTIATION */
#define GNUTLS_E_REHANDSHAKE -37 /* GNUTLS_A_NO_RENEGOTIATION */
#define GNUTLS_E_GOT_APPLICATION_DATA -38
#define GNUTLS_E_RECORD_LIMIT_REACHED -39
#define GNUTLS_E_ENCRYPTION_FAILED -40
@@ -1087,13 +994,13 @@ extern "C"
#define GNUTLS_E_PK_SIGN_FAILED -46
#define GNUTLS_E_X509_UNSUPPORTED_CRITICAL_EXTENSION -47
#define GNUTLS_E_KEY_USAGE_VIOLATION -48
#define GNUTLS_E_NO_CERTIFICATE_FOUND -49 /* GNUTLS_A_BAD_CERTIFICATE */
#define GNUTLS_E_NO_CERTIFICATE_FOUND -49 /* GNUTLS_A_BAD_CERTIFICATE */
#define GNUTLS_E_INVALID_REQUEST -50
#define GNUTLS_E_SHORT_MEMORY_BUFFER -51
#define GNUTLS_E_INTERRUPTED -52
#define GNUTLS_E_PUSH_ERROR -53
#define GNUTLS_E_PULL_ERROR -54
#define GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER -55 /* GNUTLS_A_ILLEGAL_PARAMETER */
#define GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER -55 /* GNUTLS_A_ILLEGAL_PARAMETER */
#define GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE -56
#define GNUTLS_E_PKCS1_WRONG_PAD -57
#define GNUTLS_E_RECEIVED_ILLEGAL_EXTENSION -58
@@ -1144,7 +1051,7 @@ extern "C"
#define GNUTLS_E_CERTIFICATE_ERROR -43
#define GNUTLS_E_X509_CERTIFICATE_ERROR GNUTLS_E_CERTIFICATE_ERROR
#define GNUTLS_E_CERTIFICATE_KEY_MISMATCH -60
#define GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE -61 /* GNUTLS_A_UNSUPPORTED_CERTIFICATE */
#define GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE -61 /* GNUTLS_A_UNSUPPORTED_CERTIFICATE */
#define GNUTLS_E_X509_UNKNOWN_SAN -62
#define GNUTLS_E_OPENPGP_FINGERPRINT_UNSUPPORTED -94
#define GNUTLS_E_X509_UNSUPPORTED_ATTRIBUTE -95
@@ -1152,7 +1059,7 @@ extern "C"
#define GNUTLS_E_UNKNOWN_PKCS_CONTENT_TYPE -97
#define GNUTLS_E_UNKNOWN_PKCS_BAG_TYPE -98
#define GNUTLS_E_INVALID_PASSWORD -99
#define GNUTLS_E_MAC_VERIFY_FAILED -100 /* for PKCS #12 MAC */
#define GNUTLS_E_MAC_VERIFY_FAILED -100 /* for PKCS #12 MAC */
#define GNUTLS_E_CONSTRAINT_ERROR -101
#define GNUTLS_E_WARNING_IA_IPHF_RECEIVED -102
@@ -1163,7 +1070,7 @@ extern "C"
#define GNUTLS_E_UNKNOWN_ALGORITHM -105
#define GNUTLS_E_BASE64_ENCODING_ERROR -201
#define GNUTLS_E_INCOMPATIBLE_GCRYPT_LIBRARY -202 /* obsolete */
#define GNUTLS_E_INCOMPATIBLE_GCRYPT_LIBRARY -202 /* obsolete */
#define GNUTLS_E_INCOMPATIBLE_CRYPTO_LIBRARY -202
#define GNUTLS_E_INCOMPATIBLE_LIBTASN1_LIBRARY -203
@@ -1183,4 +1090,4 @@ extern "C"
}
#endif
#endif /* GNUTLS_H */
#endif /* GNUTLS_H */
-449
View File
@@ -1,449 +0,0 @@
/*
* Copyright (C) 2001,2002 Paul Sheer
*
* This file is part of GNUTLS.
*
* GNUTLS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GNUTLS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
SOAP:
Academics always want to implement hash tables (i.e. dictionaries),
singly or doubly linked lists, and queues, because ... well ... they
know how.
These datatypes are nonsense for the following reasons:
hash tables: Hash tables are a mapping of some
string to some data, where that data is going to
be accessed COMPLETELY RANDOMLY. This is what it
is for. However it is extremely rare to have a
large number of data elements which really are
being accessed in a completely random way.
lists: appending and searching through lists is always
slow because these operations search all the way
through the list.
queues: whats the difference between a queue and a list?
very little really.
The system implemented here is a doubly linked list with previous
search index that can be appended or prepended with no overhead,
implemented entirely in macros. It is hence as versatile as a
doubly/singly linked list or queue and blazingly fast. Hence doing
sequential searches where the next search result is likely to be
closely indexed to the previous (usual case), is efficient.
Of course this doesn't mean you should use this as a hash table
where you REALLY need a hash table.
*/
/********** example usage **********/
/*
#include "list.h"
extern void free (void *x);
extern char *strdup (char *s);
// consider a list of elements containing an `int' and a `char *'
LIST_TYPE_DECLARE (names, char *s; int i;);
// for sorting, to compare elements
static int cm (names **a, names **b)
{
return strcmp ((*a)->s, (*b)->s);
}
// to free the contents of an element
static void free_item (names *a)
{
free (a->s);
a->s = 0; // say
a->i = 0; // say
}
int main (int argc, char **argv)
{
// you can separate these into LIST_TYPE_DECLARE(), LIST_DECLARE() and linit() if needed.
LIST_DECLARE_INIT (l, names, free_item);
names *j;
lappend (l);
l.tail->s = strdup ("hello");
l.tail->i = 1;
lappend (l);
l.tail->s = strdup ("there");
l.tail->i = 2;
lappend (l);
l.tail->s = strdup ("my");
l.tail->i = 3;
lappend (l);
l.tail->s = strdup ("name");
l.tail->i = 4;
lappend (l);
l.tail->s = strdup ("is");
l.tail->i = 5;
lappend (l);
l.tail->s = strdup ("fred");
l.tail->i = 6;
printf ("%ld\n\n", lcount (l));
lloopforward (l, j, printf ("%d %s\n", j->i, j->s));
printf ("\n");
lsort (l, cm);
lloopforward (l, j, printf ("%d %s\n", j->i, j->s));
lloopreverse (l, j, if (j->i <= 3) ldeleteinc (l, j););
printf ("\n");
lloopforward (l, j, printf ("%d %s\n", j->i, j->s));
ldeleteall (l);
printf ("\n");
lloopforward (l, j, printf ("%d %s\n", j->i, j->s));
return 0;
}
*/
#ifndef _LIST_H
#define _LIST_H
/* the `search' member points to the last found.
this speeds up repeated searches on the same list-item,
the consecutive list-item, or the pre-consecutive list-item.
this obviates the need for a hash table for 99% of
cercumstances the time */
struct list
{
long length;
long item_size;
struct list_item
{
struct list_item *next;
struct list_item *prev;
char data[1];
} *head, *tail, *search;
void (*free_func) (struct list_item *);
};
/* declare a list of type `x', also called `x' having members `typelist' */
#define LIST_TYPE_DECLARE(type,typelist) \
typedef struct type { \
struct type *next; \
struct type *prev; \
typelist \
} type
#define LIST_DECLARE(l,type) \
struct { \
long length; \
long item_size; \
type *head, *tail, *search; \
void (*free_func) (type *); \
} l
#define LIST_DECLARE_INIT(l,type,free) \
struct { \
long length; \
long item_size; \
type *head, *tail, *search; \
void (*free_func) (type *); \
} l = {0, sizeof (type), 0, 0, 0, (void (*) (type *)) free}
#define linit(l,type,free) \
{ \
memset (&(l), 0, sizeof (l)); \
(l).item_size = sizeof (type); \
(l).free_func = free; \
}
/* returns a pointer to the data of an item */
#define ldata(i) ((void *) &((i)->data[0]))
/* returns a pointer to the list head */
#define lhead(l) ((l).head)
/* returns a pointer to the list tail */
#define ltail(l) ((l).tail)
#define lnewsearch(l) \
(l).search = 0;
/* adds to the beginning of the list */
#define lprepend(l) \
{ \
struct list_item *__t; \
__t = (struct list_item *) malloc ((l).item_size); \
memset (__t, 0, (l).item_size); \
__t->next = (l).head; \
if (__t->next) \
__t->next->prev = __t; \
__t->prev = 0; \
if (!(l).tail) \
(l).tail = __t; \
(l).head = __t; \
length++; \
}
/* adds to the end of the list */
#define lappend(l) \
{ \
struct list_item *__t; \
__t = (struct list_item *) malloc ((l).item_size); \
memset (__t, 0, (l).item_size); \
__t->prev = (struct list_item *) (l).tail; \
if (__t->prev) \
__t->prev->next = __t; \
__t->next = 0; \
if (!(l).head) \
(l).head = (void *) __t; \
(l).tail = (void *) __t; \
(l).length++; \
}
/* you should free these manually */
#define lunlink(l,e) \
{ \
struct list_item *__t; \
(l).search = 0; \
__t = (void *) e; \
if ((void *) (l).head == (void *) __t) \
(l).head = (l).head->next; \
if ((void *) (l).tail == (void *) __t) \
(l).tail = (l).tail->prev; \
if (__t->next) \
__t->next->prev = __t->prev; \
if (__t->prev) \
__t->prev->next = __t->next; \
(l).length--; \
}
/* deletes list entry at point e, and increments e to the following list entry */
#define ldeleteinc(l,e) \
{ \
struct list_item *__t; \
(l).search = 0; \
__t = (void *) e; \
if ((void *) (l).head == (void *) __t) \
(l).head = (l).head->next; \
if ((void *) (l).tail == (void *) __t) \
(l).tail = (l).tail->prev; \
if (__t->next) \
__t->next->prev = __t->prev; \
if (__t->prev) \
__t->prev->next = __t->next; \
__t = __t->next; \
if ((l).free_func) \
(*(l).free_func) ((void *) e); \
free (e); \
e = (void *) __t; \
(l).length--; \
}
/* deletes list entry at point e, and deccrements e to the preceding list emtry */
#define ldeletedec(l,e) \
{ \
struct list_item *__t; \
(l).search = 0; \
__t = (void *) e; \
if ((void *) (l).head == (void *) __t) \
(l).head = (l).head->next; \
if ((void *) (l).tail == (void *) __t) \
(l).tail = (l).tail->prev; \
if (__t->next) \
__t->next->prev = __t->prev; \
if (__t->prev) \
__t->prev->next = __t->next; \
__t = __t->prev; \
if ((l).free_func) \
(*(l).free_func) ((void *) e); \
free (e); \
e = (void *) __t; \
(l).length--; \
}
/* p and q must be consecutive and neither must be zero */
#define linsert(l,p,q) \
{ \
struct list_item *__t; \
__t = (struct list_item *) malloc ((l).item_size); \
memset (__t, 0, (l).item_size); \
__t->prev = (void *) p; \
__t->next = (void *) q; \
q->prev = (void *) __t; \
p->next = (void *) __t; \
(l).length++; \
}
/* p and q must be consecutive and neither must be zero */
#define ldeleteall(l) \
{ \
(l).search = 0; \
while ((l).head) { \
struct list_item *__p; \
__p = (struct list_item *) (l).head; \
lunlink(l, __p); \
if ((l).free_func) \
(*(l).free_func) ((void *) __p); \
free (__p); \
} \
}
#define lloopstart(l,i) \
for (i = (void *) (l).head; i;) { \
struct list_item *__tl; \
__tl = (void *) i->next; \
#define lloopend(l,i) \
i = (void *) __tl; \
} \
#define lloopforward(l,i,op) \
{ \
for (i = (void *) (l).head; i;) { \
struct list_item *__t; \
__t = (void *) i->next; \
op; \
i = (void *) __t; \
} \
}
#define lloopreverse(l,i,op) \
{ \
for (i = (void *) (l).tail; i;) { \
struct list_item *__t; \
__t = (void *) i->prev; \
op; \
i = (void *) __t; \
} \
}
#define lindex(l,i,n) \
{ \
int __k; \
for (__k = 0, i = (void *) (l).head; i && __k != n; i = i->next, __k++); \
}
#define lsearchforward(l,i,op) \
{ \
int __found = 0; \
if (!__found) \
if ((i = (void *) (l).search)) { \
if (op) { \
__found = 1; \
(l).search = (void *) i; \
} \
if (!__found) \
if ((i = (void *) (l).search->next)) \
if (op) { \
__found = 1; \
(l).search = (void *) i; \
} \
if (!__found) \
if ((i = (void *) (l).search->prev)) \
if (op) { \
__found = 1; \
(l).search = (void *) i; \
} \
} \
if (!__found) \
for (i = (void *) (l).head; i; i = i->next) \
if (op) { \
__found = 1; \
(l).search = (void *) i; \
break; \
} \
}
#define lsearchreverse(l,i,op) \
{ \
int __found = 0; \
if (!__found) \
if ((i = (void *) (l).search)) { \
if (op) { \
__found = 1; \
(l).search = (void *) i; \
} \
if (!__found) \
if ((i = (void *) (l).search->prev)) \
if (op) { \
__found = 1; \
(l).search = (void *) i; \
} \
if (!__found) \
if ((i = (void *) (l).search->next)) \
if (op) { \
__found = 1; \
(l).search = (void *) i; \
} \
} \
if (!__found) \
for (i = (void *) (l).tail; i; i = i->prev) \
if (op) { \
__found = 1; \
(l).search = (void *) i; \
break; \
} \
}
#define lcount(l) ((l).length)
/* sort with comparison function see qsort(3) */
#define larray(l,a) \
{ \
long __i; \
struct list_item *__p; \
a = (void *) malloc (((l).length + 1) * sizeof (void *)); \
for (__i = 0, __p = (void *) (l).head; __p; __p = __p->next, __i++) \
a[__i] = (void *) __p; \
a[__i] = 0; \
} \
/* sort with comparison function see qsort(3) */
#define llist(l,a) \
{ \
struct list_item *__p; \
(l).head = (void *) a[0]; \
(l).search = 0; \
__p = (void *) a[0]; \
__p->prev = 0; \
for (__j = 1; a[__j]; __j++, __p = __p->next) { \
__p->next = (void *) a[__j]; \
__p->next->prev = __p; \
} \
(l).tail = (void *) __p; \
__p->next = 0; \
} \
/* sort with comparison function see qsort(3) */
#define lsort(l,compare) \
{ \
void **__t; \
long __j; \
larray (l,__t); \
qsort (__t, (l).length, sizeof (void *), (int (*) (const void *, const void *)) compare); \
llist (l,__t); \
free (__t); \
} \
#endif /* _LIST_H */
+1 -1
View File
@@ -42,7 +42,7 @@
* may use GnuPG for that purpose, or any other external PGP application.
-*/
int
_gnutls_openpgp_verify_key (const gnutls_certificate_credentials_t cred,
_gnutls_openpgp_verify_key (const mhd_gtls_cert_credentials_t cred,
const gnutls_datum_t * cert_list,
int cert_list_length, unsigned int *status)
{
+2 -2
View File
@@ -100,8 +100,8 @@ gnutls_openpgp_keyring_check_id (gnutls_openpgp_keyring_t ring,
cdk_pkt_pubkey_t pk;
uint32_t id[2];
id[0] = _gnutls_read_uint32 (keyid);
id[1] = _gnutls_read_uint32 (&keyid[4]);
id[0] = mhd_gtls_read_uint32 (keyid);
id[1] = mhd_gtls_read_uint32 (&keyid[4]);
if (!cdk_keydb_get_pk (ring->db, id, &pk))
{
+1 -1
View File
@@ -43,7 +43,7 @@ static int _gnutls_init_extra = 0;
* This function initializes the global state of gnutls-extra library
* to defaults. Returns zero on success.
*
* Note that gnutls_global_init() has to be called before this
* Note that MHD_gnutls_global_init() has to be called before this
* function. If this function is not called then the gnutls-extra
* library will not be usable.
*
+3 -3
View File
@@ -25,14 +25,14 @@
#include <auth_cert.h>
typedef int (*OPENPGP_VERIFY_KEY_FUNC) (const
gnutls_certificate_credentials_t,
mhd_gtls_cert_credentials_t,
const gnutls_datum_t *, int,
unsigned int *);
typedef time_t (*OPENPGP_KEY_CREATION_TIME_FUNC) (const gnutls_datum_t *);
typedef time_t (*OPENPGP_KEY_EXPIRATION_TIME_FUNC) (const gnutls_datum_t *);
typedef int (*OPENPGP_KEY_REQUEST) (gnutls_session_t, gnutls_datum_t *,
const gnutls_certificate_credentials_t,
typedef int (*OPENPGP_KEY_REQUEST) (mhd_gtls_session_t, gnutls_datum_t *,
const mhd_gtls_cert_credentials_t,
opaque *, int);
typedef int (*OPENPGP_FINGERPRINT) (const gnutls_datum_t *,
+47 -47
View File
@@ -71,7 +71,7 @@ static const char challenge_label[] = "inner application challenge";
this return E_AGAIN and E_INTERRUPTED, call this function again
with data==NULL&&sizeofdata=0NULL until it returns successfully. */
static ssize_t
_gnutls_send_inner_application (gnutls_session_t session,
_gnutls_send_inner_application (mhd_gtls_session_t session,
gnutls_ia_apptype_t msg_type,
const char *data, size_t sizeofdata)
{
@@ -90,11 +90,11 @@ _gnutls_send_inner_application (gnutls_session_t session,
}
*(unsigned char *) p = (unsigned char) (msg_type & 0xFF);
_gnutls_write_uint24 (sizeofdata, p + 1);
mhd_gtls_write_uint24 (sizeofdata, p + 1);
memcpy (p + 4, data, sizeofdata);
}
len = _gnutls_send_int (session, GNUTLS_INNER_APPLICATION, -1, p, plen);
len = mhd_gtls_send_int (session, GNUTLS_INNER_APPLICATION, -1, p, plen);
if (p)
gnutls_free (p);
@@ -106,14 +106,14 @@ _gnutls_send_inner_application (gnutls_session_t session,
*MSG_TYPE, and the data in DATA of max SIZEOFDATA size. Return the
number of bytes read, or an error code. */
static ssize_t
_gnutls_recv_inner_application (gnutls_session_t session,
_gnutls_recv_inner_application (mhd_gtls_session_t session,
gnutls_ia_apptype_t * msg_type,
opaque * data, size_t sizeofdata)
{
ssize_t len;
opaque pkt[4];
len = _gnutls_recv_int (session, GNUTLS_INNER_APPLICATION, -1, pkt, 4);
len = mhd_gtls_recv_int (session, GNUTLS_INNER_APPLICATION, -1, pkt, 4);
if (len != 4)
{
gnutls_assert ();
@@ -121,7 +121,7 @@ _gnutls_recv_inner_application (gnutls_session_t session,
}
*msg_type = pkt[0];
len = _gnutls_read_uint24 (&pkt[1]);
len = mhd_gtls_read_uint24 (&pkt[1]);
if (*msg_type != GNUTLS_IA_APPLICATION_PAYLOAD && len != CHECKSUM_SIZE)
{
@@ -140,7 +140,7 @@ _gnutls_recv_inner_application (gnutls_session_t session,
{
int tmplen = len;
len = _gnutls_recv_int (session, GNUTLS_INNER_APPLICATION, -1,
len = mhd_gtls_recv_int (session, GNUTLS_INNER_APPLICATION, -1,
data, tmplen);
if (len != tmplen)
{
@@ -159,7 +159,7 @@ _gnutls_recv_inner_application (gnutls_session_t session,
respectively). LABEL and LABEL_SIZE is used as the label. The
result is placed in pre-allocated OUT of OUTSIZE length. */
static int
_gnutls_ia_prf (gnutls_session_t session,
_gnutls_ia_prf (mhd_gtls_session_t session,
size_t label_size,
const char *label,
size_t extra_size,
@@ -181,7 +181,7 @@ _gnutls_ia_prf (gnutls_session_t session,
TLS_RANDOM_SIZE);
memcpy (seed + 2 * TLS_RANDOM_SIZE, extra, extra_size);
ret = _gnutls_PRF (session, session->security_parameters.inner_secret,
ret = mhd_gtls_PRF (session, session->security_parameters.inner_secret,
TLS_MASTER_SIZE,
label, label_size, seed, seedsize, outsize, out);
@@ -192,7 +192,7 @@ _gnutls_ia_prf (gnutls_session_t session,
/**
* gnutls_ia_permute_inner_secret:
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
* @session_keys_size: Size of generated session keys (0 if none).
* @session_keys: Generated session keys, used to permute inner secret
* (NULL if none).
@@ -205,7 +205,7 @@ _gnutls_ia_prf (gnutls_session_t session,
* Return value: Return zero on success, or a negative error code.
**/
int
gnutls_ia_permute_inner_secret (gnutls_session_t session,
gnutls_ia_permute_inner_secret (mhd_gtls_session_t session,
size_t session_keys_size,
const char *session_keys)
{
@@ -220,7 +220,7 @@ gnutls_ia_permute_inner_secret (gnutls_session_t session,
/**
* gnutls_ia_generate_challenge:
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
* @buffer_size: size of output buffer.
* @buffer: pre-allocated buffer to contain @buffer_size bytes of output.
*
@@ -230,7 +230,7 @@ gnutls_ia_permute_inner_secret (gnutls_session_t session,
* Return value: Returns 0 on success, or an negative error code.
**/
int
gnutls_ia_generate_challenge (gnutls_session_t session,
gnutls_ia_generate_challenge (mhd_gtls_session_t session,
size_t buffer_size, char *buffer)
{
return _gnutls_ia_prf (session,
@@ -240,7 +240,7 @@ gnutls_ia_generate_challenge (gnutls_session_t session,
/**
* gnutls_ia_extract_inner_secret:
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
* @buffer: pre-allocated buffer to hold 48 bytes of inner secret.
*
* Copy the 48 bytes large inner secret into the specified buffer
@@ -255,14 +255,14 @@ gnutls_ia_generate_challenge (gnutls_session_t session,
* key from the inner secret.
**/
void
gnutls_ia_extract_inner_secret (gnutls_session_t session, char *buffer)
gnutls_ia_extract_inner_secret (mhd_gtls_session_t session, char *buffer)
{
memcpy (buffer, session->security_parameters.inner_secret, TLS_MASTER_SIZE);
}
/**
* gnutls_ia_endphase_send:
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
* @final_p: Set iff this should signal the final phase.
*
* Send a TLS/IA end phase message.
@@ -276,7 +276,7 @@ gnutls_ia_extract_inner_secret (gnutls_session_t session, char *buffer)
* Return value: Return 0 on success, or an error code.
**/
int
gnutls_ia_endphase_send (gnutls_session_t session, int final_p)
gnutls_ia_endphase_send (mhd_gtls_session_t session, int final_p)
{
opaque local_checksum[CHECKSUM_SIZE];
int client = session->security_parameters.entity == GNUTLS_CLIENT;
@@ -286,7 +286,7 @@ gnutls_ia_endphase_send (gnutls_session_t session, int final_p)
ssize_t len;
int ret;
ret = _gnutls_PRF (session, session->security_parameters.inner_secret,
ret = mhd_gtls_PRF (session, session->security_parameters.inner_secret,
TLS_MASTER_SIZE, label, size_of_label - 1,
/* XXX specification unclear on seed. */
"", 0, CHECKSUM_SIZE, local_checksum);
@@ -300,7 +300,7 @@ gnutls_ia_endphase_send (gnutls_session_t session, int final_p)
/* XXX Instead of calling this function over and over...?
* while (len == GNUTLS_E_AGAIN || len == GNUTLS_E_INTERRUPTED)
* len = _gnutls_io_write_flush(session);
* len = mhd_gtls_io_write_flush(session);
*/
if (len < 0)
@@ -314,7 +314,7 @@ gnutls_ia_endphase_send (gnutls_session_t session, int final_p)
/**
* gnutls_ia_verify_endphase:
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
* @checksum: 12-byte checksum data, received from gnutls_ia_recv().
*
* Verify TLS/IA end phase checksum data. If verification fails, the
@@ -330,7 +330,7 @@ gnutls_ia_endphase_send (gnutls_session_t session, int final_p)
* %GNUTLS_E_IA_VERIFY_FAILED is returned.
**/
int
gnutls_ia_verify_endphase (gnutls_session_t session, const char *checksum)
gnutls_ia_verify_endphase (mhd_gtls_session_t session, const char *checksum)
{
char local_checksum[CHECKSUM_SIZE];
int client = session->security_parameters.entity == GNUTLS_CLIENT;
@@ -339,7 +339,7 @@ gnutls_ia_verify_endphase (gnutls_session_t session, const char *checksum)
sizeof (client_finished_label);
int ret;
ret = _gnutls_PRF (session, session->security_parameters.inner_secret,
ret = mhd_gtls_PRF (session, session->security_parameters.inner_secret,
TLS_MASTER_SIZE,
label, size_of_label - 1,
"", 0, CHECKSUM_SIZE, local_checksum);
@@ -351,7 +351,7 @@ gnutls_ia_verify_endphase (gnutls_session_t session, const char *checksum)
if (memcmp (local_checksum, checksum, CHECKSUM_SIZE) != 0)
{
ret = gnutls_alert_send (session, GNUTLS_AL_FATAL,
ret = MHD_gnutls_alert_send (session, GNUTLS_AL_FATAL,
GNUTLS_A_INNER_APPLICATION_VERIFICATION);
if (ret < 0)
{
@@ -367,7 +367,7 @@ gnutls_ia_verify_endphase (gnutls_session_t session, const char *checksum)
/**
* gnutls_ia_send: Send peer the specified TLS/IA data.
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
* @data: contains the data to send
* @sizeofdata: is the length of the data
*
@@ -393,7 +393,7 @@ gnutls_ia_verify_endphase (gnutls_session_t session, const char *checksum)
* Returns the number of bytes sent, or a negative error code.
**/
ssize_t
gnutls_ia_send (gnutls_session_t session, const char *data, size_t sizeofdata)
gnutls_ia_send (mhd_gtls_session_t session, const char *data, size_t sizeofdata)
{
ssize_t len;
@@ -406,7 +406,7 @@ gnutls_ia_send (gnutls_session_t session, const char *data, size_t sizeofdata)
/**
* gnutls_ia_recv - read data from the TLS/IA protocol
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
* @data: the buffer that the data will be read into, must hold >= 12 bytes.
* @sizeofdata: the number of requested bytes, must be >= 12.
*
@@ -433,7 +433,7 @@ gnutls_ia_send (gnutls_session_t session, const char *data, size_t sizeofdata)
* application phase finished message has been sent by the server.
**/
ssize_t
gnutls_ia_recv (gnutls_session_t session, char *data, size_t sizeofdata)
gnutls_ia_recv (mhd_gtls_session_t session, char *data, size_t sizeofdata)
{
gnutls_ia_apptype_t msg_type;
ssize_t len;
@@ -453,7 +453,7 @@ gnutls_ia_recv (gnutls_session_t session, char *data, size_t sizeofdata)
though. */
int
_gnutls_ia_client_handshake (gnutls_session_t session)
_gnutls_ia_client_handshake (mhd_gtls_session_t session)
{
char *buf = NULL;
size_t buflen = 0;
@@ -461,7 +461,7 @@ _gnutls_ia_client_handshake (gnutls_session_t session)
ssize_t len;
int ret;
const struct gnutls_ia_client_credentials_st *cred =
_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_IA, NULL);
mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_IA, NULL);
if (cred == NULL)
return GNUTLS_E_INTERNAL_ERROR;
@@ -476,7 +476,7 @@ _gnutls_ia_client_handshake (gnutls_session_t session)
if (ret)
{
int tmpret;
tmpret = gnutls_alert_send (session, GNUTLS_AL_FATAL,
tmpret = MHD_gnutls_alert_send (session, GNUTLS_AL_FATAL,
GNUTLS_A_INNER_APPLICATION_FAILURE);
if (tmpret < 0)
gnutls_assert ();
@@ -522,14 +522,14 @@ _gnutls_ia_client_handshake (gnutls_session_t session)
}
int
_gnutls_ia_server_handshake (gnutls_session_t session)
_gnutls_ia_server_handshake (mhd_gtls_session_t session)
{
gnutls_ia_apptype_t msg_type;
ssize_t len;
char buf[1024];
int ret;
const struct gnutls_ia_server_credentials_st *cred =
_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_IA, NULL);
mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_IA, NULL);
if (cred == NULL)
return GNUTLS_E_INTERNAL_ERROR;
@@ -563,7 +563,7 @@ _gnutls_ia_server_handshake (gnutls_session_t session)
if (ret < 0)
{
int tmpret;
tmpret = gnutls_alert_send (session, GNUTLS_AL_FATAL,
tmpret = MHD_gnutls_alert_send (session, GNUTLS_AL_FATAL,
GNUTLS_A_INNER_APPLICATION_FAILURE);
if (tmpret < 0)
gnutls_assert ();
@@ -594,18 +594,18 @@ _gnutls_ia_server_handshake (gnutls_session_t session)
/**
* gnutls_ia_handshake_p:
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
*
* Predicate to be used after gnutls_handshake() to decide whether to
* Predicate to be used after MHD_gnutls_handshake() to decide whether to
* invoke gnutls_ia_handshake(). Usable by both clients and servers.
*
* Return value: non-zero if TLS/IA handshake is expected, zero
* otherwise.
**/
int
gnutls_ia_handshake_p (gnutls_session_t session)
gnutls_ia_handshake_p (mhd_gtls_session_t session)
{
tls_ext_st *ext = &session->security_parameters.extensions;
mhd_gtls_ext_st *ext = &session->security_parameters.extensions;
/* Either local side or peer doesn't do TLS/IA: don't do IA */
@@ -614,7 +614,7 @@ gnutls_ia_handshake_p (gnutls_session_t session)
/* Not resuming or we don't allow skipping on resumption locally: do IA */
if (!ext->gnutls_ia_allowskip || !gnutls_session_is_resumed (session))
if (!ext->gnutls_ia_allowskip || !MHD_gtls_session_is_resumed (session))
return 1;
/* If we're resuming and we and the peer both allow skipping on resumption:
@@ -626,15 +626,15 @@ gnutls_ia_handshake_p (gnutls_session_t session)
/**
* gnutls_ia_handshake:
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
*
* Perform a TLS/IA handshake. This should be called after
* gnutls_handshake() iff gnutls_ia_handshake_p().
* MHD_gnutls_handshake() iff gnutls_ia_handshake_p().
*
* Return 0 on success, or an error code.
**/
int
gnutls_ia_handshake (gnutls_session_t session)
gnutls_ia_handshake (mhd_gtls_session_t session)
{
int ret;
@@ -696,11 +696,11 @@ gnutls_ia_free_client_credentials (gnutls_ia_client_credentials_t sc)
* server, and to get a new AVP to send to the server.
*
* The callback's function form is:
* int (*avp_func) (gnutls_session_t session, void *ptr,
* int (*avp_func) (mhd_gtls_session_t session, void *ptr,
* const char *last, size_t lastlen,
* char **next, size_t *nextlen);
*
* The @session parameter is the #gnutls_session_t structure
* The @session parameter is the #mhd_gtls_session_t structure
* corresponding to the current session. The @ptr parameter is the
* application hook pointer, set through
* gnutls_ia_set_client_avp_ptr(). The AVP received from the server
@@ -802,11 +802,11 @@ gnutls_ia_free_server_credentials (gnutls_ia_server_credentials_t sc)
* Set the TLS/IA AVP callback handler used for the session.
*
* The callback's function form is:
* int (*avp_func) (gnutls_session_t session, void *ptr,
* int (*avp_func) (mhd_gtls_session_t session, void *ptr,
* const char *last, size_t lastlen,
* char **next, size_t *nextlen);
*
* The @session parameter is the #gnutls_session_t structure
* The @session parameter is the #mhd_gtls_session_t structure
* corresponding to the current session. The @ptr parameter is the
* application hook pointer, set through
* gnutls_ia_set_server_avp_ptr(). The AVP received from the client
@@ -873,7 +873,7 @@ gnutls_ia_get_server_avp_ptr (gnutls_ia_server_credentials_t cred)
/**
* gnutls_ia_enable - Indicate willingness for TLS/IA application phases
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
* @allow_skip_on_resume: non-zero if local party allows to skip the
* TLS/IA application phases for a resumed session.
*
@@ -897,7 +897,7 @@ gnutls_ia_get_server_avp_ptr (gnutls_ia_server_credentials_t cred)
* functions.
**/
void
gnutls_ia_enable (gnutls_session_t session, int allow_skip_on_resume)
gnutls_ia_enable (mhd_gtls_session_t session, int allow_skip_on_resume)
{
session->security_parameters.extensions.gnutls_ia_enable = 1;
session->security_parameters.extensions.gnutls_ia_allowskip =
+23 -23
View File
@@ -36,7 +36,7 @@
#define OPENPGP_NAME_SIZE 256
#define datum_append(x, y, z) _gnutls_datum_append_m (x, y, z, gnutls_realloc)
#define datum_append(x, y, z) mhd_gtls_datum_append_m (x, y, z, gnutls_realloc)
static void
release_mpi_array (mpi_t * arr, size_t n)
@@ -46,7 +46,7 @@ release_mpi_array (mpi_t * arr, size_t n)
while (arr && n--)
{
x = *arr;
_gnutls_mpi_release (&x);
mhd_gtls_mpi_release (&x);
*arr = NULL;
arr++;
}
@@ -137,7 +137,7 @@ openpgp_pk_to_gnutls_cert (gnutls_cert * cert, cdk_pkt_pubkey_t pk)
{
nbytes = sizeof (buf) / sizeof (buf[0]);
cdk_pk_get_mpi (pk, i, buf, nbytes, &nbytes, NULL);
rc = _gnutls_mpi_scan_pgp (&cert->params[i], buf, &nbytes);
rc = mhd_gtls_mpi_scan_pgp (&cert->params[i], buf, &nbytes);
if (rc)
{
rc = GNUTLS_E_MPI_SCAN_FAILED;
@@ -221,7 +221,7 @@ _gnutls_openpgp_raw_privkey_to_gkey (gnutls_privkey * pkey,
{
nbytes = sizeof (buf) / sizeof (buf[0]);
cdk_pk_get_mpi (sk->pk, i, buf, nbytes, &nbytes, NULL);
rc = _gnutls_mpi_scan_pgp (&pkey->params[i], buf, &nbytes);
rc = mhd_gtls_mpi_scan_pgp (&pkey->params[i], buf, &nbytes);
if (rc)
{
rc = GNUTLS_E_MPI_SCAN_FAILED;
@@ -235,7 +235,7 @@ _gnutls_openpgp_raw_privkey_to_gkey (gnutls_privkey * pkey,
{
nbytes = sizeof (buf) / sizeof (buf[0]);
cdk_sk_get_mpi (sk, j, buf, nbytes, &nbytes, NULL);
rc = _gnutls_mpi_scan_pgp (&pkey->params[i], buf, &nbytes);
rc = mhd_gtls_mpi_scan_pgp (&pkey->params[i], buf, &nbytes);
if (rc)
{
rc = GNUTLS_E_MPI_SCAN_FAILED;
@@ -298,19 +298,19 @@ _gnutls_openpgp_raw_key_to_gcert (gnutls_cert * cert,
}
/**
* gnutls_certificate_set_openpgp_key - Used to set keys in a gnutls_certificate_credentials_t structure
* @res: is an #gnutls_certificate_credentials_t structure.
* gnutls_certificate_set_openpgp_key - Used to set keys in a mhd_gtls_cert_credentials_t structure
* @res: is an #mhd_gtls_cert_credentials_t structure.
* @key: contains an openpgp public key
* @pkey: is an openpgp private key
*
* This function sets a certificate/private key pair in the
* gnutls_certificate_credentials_t structure. This function may be called
* mhd_gtls_cert_credentials_t structure. This function may be called
* more than once (in case multiple keys/certificates exist for the
* server).
*
**/
int
gnutls_certificate_set_openpgp_key (gnutls_certificate_credentials_t
gnutls_certificate_set_openpgp_key (mhd_gtls_cert_credentials_t
res, gnutls_openpgp_crt_t crt,
gnutls_openpgp_privkey_t pkey)
{
@@ -318,7 +318,7 @@ gnutls_certificate_set_openpgp_key (gnutls_certificate_credentials_t
/* this should be first */
res->pkey = gnutls_realloc_fast (res->pkey,
res->pkey = mhd_gtls_realloc_fast (res->pkey,
(res->ncerts + 1) *
sizeof (gnutls_privkey));
if (res->pkey == NULL)
@@ -334,7 +334,7 @@ gnutls_certificate_set_openpgp_key (gnutls_certificate_credentials_t
return ret;
}
res->cert_list = gnutls_realloc_fast (res->cert_list,
res->cert_list = mhd_gtls_realloc_fast (res->cert_list,
(1 +
res->ncerts) *
sizeof (gnutls_cert *));
@@ -344,7 +344,7 @@ gnutls_certificate_set_openpgp_key (gnutls_certificate_credentials_t
return GNUTLS_E_MEMORY_ERROR;
}
res->cert_list_length = gnutls_realloc_fast (res->cert_list_length,
res->cert_list_length = mhd_gtls_realloc_fast (res->cert_list_length,
(1 +
res->ncerts) * sizeof (int));
if (res->cert_list_length == NULL)
@@ -489,7 +489,7 @@ stream_to_datum (cdk_stream_t inp, gnutls_datum_t * raw)
* should only contain one key which should not be encrypted.
**/
int
gnutls_certificate_set_openpgp_key_mem (gnutls_certificate_credentials_t
gnutls_certificate_set_openpgp_key_mem (mhd_gtls_cert_credentials_t
res, const gnutls_datum_t * icert,
const gnutls_datum_t * ikey,
gnutls_openpgp_crt_fmt_t format)
@@ -551,7 +551,7 @@ gnutls_certificate_set_openpgp_key_mem (gnutls_certificate_credentials_t
* should only contain one key which should not be encrypted.
**/
int
gnutls_certificate_set_openpgp_key_file (gnutls_certificate_credentials_t
gnutls_certificate_set_openpgp_key_file (mhd_gtls_cert_credentials_t
res, const char *certfile,
const char *keyfile,
gnutls_openpgp_crt_fmt_t format)
@@ -652,7 +652,7 @@ gnutls_openpgp_count_key_names (const gnutls_datum_t * cert)
*
**/
int
gnutls_certificate_set_openpgp_keyring_file (gnutls_certificate_credentials_t
gnutls_certificate_set_openpgp_keyring_file (mhd_gtls_cert_credentials_t
c, const char *file,
gnutls_openpgp_crt_fmt_t format)
{
@@ -696,7 +696,7 @@ gnutls_certificate_set_openpgp_keyring_file (gnutls_certificate_credentials_t
*
**/
int
gnutls_certificate_set_openpgp_keyring_mem (gnutls_certificate_credentials_t
gnutls_certificate_set_openpgp_keyring_mem (mhd_gtls_cert_credentials_t
c, const opaque * data,
size_t dlen,
gnutls_openpgp_crt_fmt_t format)
@@ -749,7 +749,7 @@ gnutls_certificate_set_openpgp_keyring_mem (gnutls_certificate_credentials_t
/*-
* _gnutls_openpgp_request_key - Receives a key from a database, key server etc
* @ret - a pointer to gnutls_datum_t structure.
* @cred - a gnutls_certificate_credentials_t structure.
* @cred - a mhd_gtls_cert_credentials_t structure.
* @key_fingerprint - The keyFingerprint
* @key_fingerprint_size - the size of the fingerprint
*
@@ -758,8 +758,8 @@ gnutls_certificate_set_openpgp_keyring_mem (gnutls_certificate_credentials_t
*
-*/
int
_gnutls_openpgp_request_key (gnutls_session_t session, gnutls_datum_t * ret,
const gnutls_certificate_credentials_t cred,
_gnutls_openpgp_request_key (mhd_gtls_session_t session, gnutls_datum_t * ret,
const mhd_gtls_cert_credentials_t cred,
opaque * key_fpr, int key_fpr_size)
{
int rc = 0;
@@ -836,8 +836,8 @@ error:
*
**/
void
gnutls_openpgp_set_recv_key_function (gnutls_session_t session,
gnutls_openpgp_recv_key_func func)
gnutls_openpgp_set_recv_key_function (mhd_gtls_session_t session,
mhd_gtls_openpgp_recv_key_func func)
{
session->internals.openpgp_recv_key_func = func;
}
@@ -870,7 +870,7 @@ _gnutls_openpgp_privkey_to_gkey (gnutls_privkey * dest,
cleanup:
for (i = 0; i < src->pkey.params_size; i++)
_gnutls_mpi_release (&dest->params[i]);
mhd_gtls_mpi_release (&dest->params[i]);
return ret;
}
@@ -954,7 +954,7 @@ gnutls_openpgp_privkey_sign_hash (gnutls_openpgp_privkey_t key,
return GNUTLS_E_INVALID_REQUEST;
}
result = _gnutls_sign (key->pkey.pk_algorithm, key->pkey.params,
result = mhd_gtls_sign (key->pkey.pk_algorithm, key->pkey.params,
key->pkey.params_size, hash, signature);
if (result < 0)
{
+6 -6
View File
@@ -31,17 +31,17 @@ typedef enum
}key_attr_t;
int
gnutls_certificate_set_openpgp_key_file (gnutls_certificate_credentials_t
gnutls_certificate_set_openpgp_key_file (mhd_gtls_cert_credentials_t
res, const char *CERTFILE,
const char *KEYFILE, gnutls_openpgp_crt_fmt_t);
int gnutls_openpgp_count_key_names (const gnutls_datum_t * cert);
int gnutls_certificate_set_openpgp_keyring_file
(gnutls_certificate_credentials_t c, const char *file, gnutls_openpgp_crt_fmt_t);
(mhd_gtls_cert_credentials_t c, const char *file, gnutls_openpgp_crt_fmt_t);
int
gnutls_certificate_set_openpgp_keyring_mem (gnutls_certificate_credentials_t
gnutls_certificate_set_openpgp_keyring_mem (mhd_gtls_cert_credentials_t
c, const opaque * data,
size_t dlen, gnutls_openpgp_crt_fmt_t);
@@ -63,12 +63,12 @@ _gnutls_openpgp_raw_privkey_to_gkey (gnutls_privkey * pkey,
gnutls_openpgp_crt_fmt_t format);
int
_gnutls_openpgp_request_key (gnutls_session_t,
_gnutls_openpgp_request_key (mhd_gtls_session_t,
gnutls_datum_t * ret,
const gnutls_certificate_credentials_t cred,
const mhd_gtls_cert_credentials_t cred,
opaque * key_fpr, int key_fpr_size);
int _gnutls_openpgp_verify_key (const gnutls_certificate_credentials_t,
int _gnutls_openpgp_verify_key (const mhd_gtls_cert_credentials_t,
const gnutls_datum_t * cert_list,
int cert_list_length, unsigned int *status);
int _gnutls_openpgp_fingerprint (const gnutls_datum_t * cert,
+1 -1
View File
@@ -117,7 +117,7 @@ int gnutls_openpgp_crt_verify_self(gnutls_openpgp_crt_t key,
/* certificate authentication stuff.
*/
int gnutls_certificate_set_openpgp_key(gnutls_certificate_credentials_t
int gnutls_certificate_set_openpgp_key(mhd_gtls_cert_credentials_t
res,
gnutls_openpgp_crt_t key,
gnutls_openpgp_privkey_t pkey);
+1 -1
View File
@@ -64,7 +64,7 @@ gnutls_openpgp_privkey_deinit (gnutls_openpgp_privkey_t key)
if (!key)
return;
_gnutls_gkey_deinit (&key->pkey);
mhd_gtls_gkey_deinit (&key->pkey);
gnutls_free (key);
}
+123 -123
View File
@@ -37,8 +37,8 @@
#include <tests.h>
extern gnutls_srp_client_credentials_t srp_cred;
extern gnutls_anon_client_credentials_t anon_cred;
extern gnutls_certificate_credentials_t xcred;
extern mhd_gtls_anon_client_credentials_t anon_cred;
extern mhd_gtls_cert_credentials_t xcred;
extern int verbose;
@@ -54,13 +54,13 @@ static int sfree = 0;
static int handshake_output = 0;
int
do_handshake (gnutls_session_t session)
do_handshake (mhd_gtls_session_t session)
{
int ret, alert;
do
{
ret = gnutls_handshake (session);
ret = MHD_gnutls_handshake (session);
}
while (ret == GNUTLS_E_INTERRUPTED || ret == GNUTLS_E_AGAIN);
@@ -74,7 +74,7 @@ do_handshake (gnutls_session_t session)
alert = gnutls_alert_get (session);
printf ("\n");
printf ("*** Received alert [%d]: %s\n",
alert, gnutls_alert_get_name (alert));
alert, MHD_gnutls_alert_get_name (alert));
}
}
@@ -98,7 +98,7 @@ do_handshake (gnutls_session_t session)
gnutls_session_get_data (session, session_data, &session_data_size);
session_id_size = sizeof (session_id);
gnutls_session_get_id (session, session_id, &session_id_size);
MHD_gtls_session_get_id (session, session_id, &session_id_size);
return TEST_SUCCEED;
}
@@ -118,43 +118,43 @@ static const int mac_priority[16] =
{ MHD_GNUTLS_MAC_SHA1, MHD_GNUTLS_MAC_MD5, 0 };
static const int cert_type_priority[16] = { MHD_GNUTLS_CRT_X509, 0 };
#define ADD_ALL_CIPHERS(session) gnutls_cipher_set_priority(session, cipher_priority)
#define ADD_ALL_COMP(session) gnutls_compression_set_priority(session, comp_priority)
#define ADD_ALL_MACS(session) gnutls_mac_set_priority(session, mac_priority)
#define ADD_ALL_KX(session) gnutls_kx_set_priority(session, kx_priority)
#define ADD_ALL_PROTOCOLS(session) gnutls_protocol_set_priority(session, protocol_priority)
#define ADD_ALL_CERTTYPES(session) gnutls_certificate_type_set_priority(session, cert_type_priority)
#define ADD_ALL_CIPHERS(session) MHD_gnutls_cipher_set_priority(session, cipher_priority)
#define ADD_ALL_COMP(session) MHD_gnutls_compression_set_priority(session, comp_priority)
#define ADD_ALL_MACS(session) MHD_gnutls_mac_set_priority(session, mac_priority)
#define ADD_ALL_KX(session) MHD_gnutls_kx_set_priority(session, kx_priority)
#define ADD_ALL_PROTOCOLS(session) MHD_gnutls_protocol_set_priority(session, protocol_priority)
#define ADD_ALL_CERTTYPES(session) MHD_gnutls_certificate_type_set_priority(session, cert_type_priority)
static void
ADD_KX (gnutls_session_t session, int kx)
ADD_KX (mhd_gtls_session_t session, int kx)
{
static int _kx_priority[] = { 0, 0 };
_kx_priority[0] = kx;
gnutls_kx_set_priority (session, _kx_priority);
MHD_gnutls_kx_set_priority (session, _kx_priority);
}
static void
ADD_KX2 (gnutls_session_t session, int kx1, int kx2)
ADD_KX2 (mhd_gtls_session_t session, int kx1, int kx2)
{
static int _kx_priority[] = { 0, 0, 0 };
_kx_priority[0] = kx1;
_kx_priority[1] = kx2;
gnutls_kx_set_priority (session, _kx_priority);
MHD_gnutls_kx_set_priority (session, _kx_priority);
}
static void
ADD_CIPHER (gnutls_session_t session, int cipher)
ADD_CIPHER (mhd_gtls_session_t session, int cipher)
{
static int _cipher_priority[] = { 0, 0 };
_cipher_priority[0] = cipher;
gnutls_cipher_set_priority (session, _cipher_priority);
MHD_gnutls_cipher_set_priority (session, _cipher_priority);
}
static void
ADD_CIPHER4 (gnutls_session_t session, int cipher1, int cipher2, int cipher3,
ADD_CIPHER4 (mhd_gtls_session_t session, int cipher1, int cipher2, int cipher3,
int cipher4)
{
static int _cipher_priority[] = { 0, 0, 0, 0, 0 };
@@ -163,61 +163,61 @@ ADD_CIPHER4 (gnutls_session_t session, int cipher1, int cipher2, int cipher3,
_cipher_priority[2] = cipher3;
_cipher_priority[3] = cipher4;
gnutls_cipher_set_priority (session, _cipher_priority);
MHD_gnutls_cipher_set_priority (session, _cipher_priority);
}
static void
ADD_MAC (gnutls_session_t session, int mac)
ADD_MAC (mhd_gtls_session_t session, int mac)
{
static int _mac_priority[] = { 0, 0 };
_mac_priority[0] = mac;
gnutls_mac_set_priority (session, _mac_priority);
MHD_gnutls_mac_set_priority (session, _mac_priority);
}
static void
ADD_COMP (gnutls_session_t session, int c)
ADD_COMP (mhd_gtls_session_t session, int c)
{
static int _comp_priority[] = { 0, 0 };
_comp_priority[0] = c;
gnutls_compression_set_priority (session, _comp_priority);
MHD_gnutls_compression_set_priority (session, _comp_priority);
}
static void
ADD_CERTTYPE (gnutls_session_t session, int ctype)
ADD_CERTTYPE (mhd_gtls_session_t session, int ctype)
{
static int _ct_priority[] = { 0, 0 };
_ct_priority[0] = ctype;
gnutls_certificate_type_set_priority (session, _ct_priority);
MHD_gnutls_certificate_type_set_priority (session, _ct_priority);
}
static void
ADD_PROTOCOL (gnutls_session_t session, int protocol)
ADD_PROTOCOL (mhd_gtls_session_t session, int protocol)
{
static int _proto_priority[] = { 0, 0 };
_proto_priority[0] = protocol;
gnutls_protocol_set_priority (session, _proto_priority);
MHD_gnutls_protocol_set_priority (session, _proto_priority);
}
static void
ADD_PROTOCOL3 (gnutls_session_t session, int p1, int p2, int p3)
ADD_PROTOCOL3 (mhd_gtls_session_t session, int p1, int p2, int p3)
{
static int _proto_priority[] = { 0, 0, 0, 0 };
_proto_priority[0] = p1;
_proto_priority[1] = p2;
_proto_priority[2] = p3;
gnutls_protocol_set_priority (session, _proto_priority);
MHD_gnutls_protocol_set_priority (session, _proto_priority);
}
#ifdef ENABLE_SRP
static int srp_detected;
int
_test_srp_username_callback (gnutls_session_t session,
_test_srp_username_callback (mhd_gtls_session_t session,
char **username, char **password)
{
srp_detected = 1;
@@ -226,7 +226,7 @@ _test_srp_username_callback (gnutls_session_t session,
}
test_code_t
test_srp (gnutls_session_t session)
test_srp (mhd_gtls_session_t session)
{
int ret;
@@ -242,7 +242,7 @@ test_srp (gnutls_session_t session)
gnutls_srp_set_client_credentials_function (srp_cred,
_test_srp_username_callback);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_SRP, srp_cred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_SRP, srp_cred);
ret = do_handshake (session);
@@ -256,7 +256,7 @@ test_srp (gnutls_session_t session)
#endif
test_code_t
test_server (gnutls_session_t session)
test_server (mhd_gtls_session_t session)
{
int ret, i = 0;
char buf[5 * 1024];
@@ -275,14 +275,14 @@ test_server (gnutls_session_t session)
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
if (ret != TEST_SUCCEED)
return TEST_FAILED;
gnutls_record_send (session, snd_buf, sizeof (snd_buf) - 1);
ret = gnutls_record_recv (session, buf, sizeof (buf) - 1);
MHD_gnutls_record_send (session, snd_buf, sizeof (snd_buf) - 1);
ret = MHD_gnutls_record_recv (session, buf, sizeof (buf) - 1);
if (ret < 0)
return TEST_FAILED;
@@ -313,7 +313,7 @@ static gnutls_datum_t exp = { NULL, 0 }, mod =
NULL, 0};
test_code_t
test_export (gnutls_session_t session)
test_export (mhd_gtls_session_t session)
{
int ret;
@@ -324,21 +324,21 @@ test_export (gnutls_session_t session)
ADD_KX (session, MHD_GNUTLS_KX_RSA_EXPORT);
ADD_CIPHER (session, MHD_GNUTLS_CIPHER_ARCFOUR_40);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
if (ret == TEST_SUCCEED)
{
export_true = 1;
gnutls_rsa_export_get_pubkey (session, &exp, &mod);
MHD_gtls_rsa_export_get_pubkey (session, &exp, &mod);
}
return ret;
}
test_code_t
test_export_info (gnutls_session_t session)
test_export_info (mhd_gtls_session_t session)
{
int ret2, ret;
gnutls_datum_t exp2, mod2;
@@ -354,13 +354,13 @@ test_export_info (gnutls_session_t session)
ADD_KX (session, MHD_GNUTLS_KX_RSA_EXPORT);
ADD_CIPHER (session, MHD_GNUTLS_CIPHER_ARCFOUR_40);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
if (ret == TEST_SUCCEED)
{
ret2 = gnutls_rsa_export_get_pubkey (session, &exp2, &mod2);
ret2 = MHD_gtls_rsa_export_get_pubkey (session, &exp2, &mod2);
if (ret2 >= 0)
{
printf ("\n");
@@ -390,7 +390,7 @@ test_export_info (gnutls_session_t session)
static gnutls_datum_t pubkey = { NULL, 0 };
test_code_t
test_dhe (gnutls_session_t session)
test_dhe (mhd_gtls_session_t session)
{
int ret;
@@ -401,17 +401,17 @@ test_dhe (gnutls_session_t session)
ADD_ALL_MACS (session);
ADD_KX2 (session, MHD_GNUTLS_KX_DHE_RSA, MHD_GNUTLS_KX_DHE_DSS);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
gnutls_dh_get_pubkey (session, &pubkey);
MHD_gnutls_dh_get_pubkey (session, &pubkey);
return ret;
}
test_code_t
test_dhe_group (gnutls_session_t session)
test_dhe_group (mhd_gtls_session_t session)
{
int ret, ret2;
gnutls_datum_t gen, prime, pubkey2;
@@ -427,11 +427,11 @@ test_dhe_group (gnutls_session_t session)
ADD_ALL_MACS (session);
ADD_KX2 (session, MHD_GNUTLS_KX_DHE_RSA, MHD_GNUTLS_KX_DHE_DSS);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
ret2 = gnutls_dh_get_group (session, &gen, &prime);
ret2 = MHD_gnutls_dh_get_group (session, &gen, &prime);
if (ret2 >= 0)
{
printf ("\n");
@@ -444,7 +444,7 @@ test_dhe_group (gnutls_session_t session)
if (print)
printf (" Prime [%d bits]: %s\n", prime.size * 8, print);
gnutls_dh_get_pubkey (session, &pubkey2);
MHD_gnutls_dh_get_pubkey (session, &pubkey2);
print = raw_to_string (pubkey2.data, pubkey2.size);
if (print)
printf (" Pubkey [%d bits]: %s\n", pubkey2.size * 8, print);
@@ -459,7 +459,7 @@ test_dhe_group (gnutls_session_t session)
}
test_code_t
test_ssl3 (gnutls_session_t session)
test_ssl3 (mhd_gtls_session_t session)
{
int ret;
ADD_ALL_CIPHERS (session);
@@ -468,7 +468,7 @@ test_ssl3 (gnutls_session_t session)
ADD_PROTOCOL (session, MHD_GNUTLS_SSL3);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
if (ret == TEST_SUCCEED)
@@ -485,7 +485,7 @@ got_alarm (int k)
}
test_code_t
test_bye (gnutls_session_t session)
test_bye (mhd_gtls_session_t session)
{
int ret;
char data[20];
@@ -501,13 +501,13 @@ test_bye (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
if (ret == TEST_FAILED)
return ret;
ret = gnutls_bye (session, GNUTLS_SHUT_WR);
ret = MHD_gnutls_bye (session, GNUTLS_SHUT_WR);
if (ret < 0)
return TEST_FAILED;
@@ -521,7 +521,7 @@ test_bye (gnutls_session_t session)
do
{
ret = gnutls_record_recv (session, data, sizeof (data));
ret = MHD_gnutls_record_recv (session, data, sizeof (data));
}
while (ret > 0);
@@ -544,7 +544,7 @@ test_bye (gnutls_session_t session)
test_code_t
test_aes (gnutls_session_t session)
test_aes (mhd_gtls_session_t session)
{
int ret;
ADD_CIPHER (session, MHD_GNUTLS_CIPHER_AES_128_CBC);
@@ -553,7 +553,7 @@ test_aes (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
return ret;
@@ -561,7 +561,7 @@ test_aes (gnutls_session_t session)
#ifdef ENABLE_CAMELLIA
test_code_t
test_camellia (gnutls_session_t session)
test_camellia (mhd_gtls_session_t session)
{
int ret;
ADD_CIPHER (session, MHD_GNUTLS_CIPHER_CAMELLIA_128_CBC);
@@ -570,7 +570,7 @@ test_camellia (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
return ret;
@@ -578,7 +578,7 @@ test_camellia (gnutls_session_t session)
#endif
test_code_t
test_openpgp1 (gnutls_session_t session)
test_openpgp1 (mhd_gtls_session_t session)
{
int ret;
ADD_ALL_CIPHERS (session);
@@ -587,7 +587,7 @@ test_openpgp1 (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
if (ret == TEST_FAILED)
@@ -600,7 +600,7 @@ test_openpgp1 (gnutls_session_t session)
}
test_code_t
test_unknown_ciphersuites (gnutls_session_t session)
test_unknown_ciphersuites (mhd_gtls_session_t session)
{
int ret;
#ifdef ENABLE_CAMELLIA
@@ -616,14 +616,14 @@ test_unknown_ciphersuites (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
return ret;
}
test_code_t
test_md5 (gnutls_session_t session)
test_md5 (mhd_gtls_session_t session)
{
int ret;
ADD_ALL_CIPHERS (session);
@@ -632,7 +632,7 @@ test_md5 (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_MAC (session, MHD_GNUTLS_MAC_MD5);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
return ret;
@@ -640,7 +640,7 @@ test_md5 (gnutls_session_t session)
#ifdef HAVE_LIBZ
test_code_t
test_zlib (gnutls_session_t session)
test_zlib (mhd_gtls_session_t session)
{
int ret;
ADD_ALL_CIPHERS (session);
@@ -649,7 +649,7 @@ test_zlib (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
return ret;
@@ -657,10 +657,10 @@ test_zlib (gnutls_session_t session)
#endif
test_code_t
test_lzo (gnutls_session_t session)
test_lzo (mhd_gtls_session_t session)
{
int ret;
gnutls_handshake_set_private_extensions (session, 1);
MHD_gtls_handshake_set_private_extensions (session, 1);
ADD_ALL_CIPHERS (session);
ADD_COMP (session, MHD_GNUTLS_COMP_LZO);
@@ -668,7 +668,7 @@ test_lzo (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
@@ -676,7 +676,7 @@ test_lzo (gnutls_session_t session)
}
test_code_t
test_sha (gnutls_session_t session)
test_sha (mhd_gtls_session_t session)
{
int ret;
ADD_ALL_CIPHERS (session);
@@ -685,14 +685,14 @@ test_sha (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_MAC (session, MHD_GNUTLS_MAC_SHA1);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
return ret;
}
test_code_t
test_3des (gnutls_session_t session)
test_3des (mhd_gtls_session_t session)
{
int ret;
ADD_CIPHER (session, MHD_GNUTLS_CIPHER_3DES_CBC);
@@ -701,14 +701,14 @@ test_3des (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
return ret;
}
test_code_t
test_arcfour (gnutls_session_t session)
test_arcfour (mhd_gtls_session_t session)
{
int ret;
ADD_CIPHER (session, MHD_GNUTLS_CIPHER_ARCFOUR_128);
@@ -717,14 +717,14 @@ test_arcfour (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
return ret;
}
test_code_t
test_arcfour_40 (gnutls_session_t session)
test_arcfour_40 (mhd_gtls_session_t session)
{
int ret;
ADD_CIPHER (session, MHD_GNUTLS_CIPHER_ARCFOUR_40);
@@ -733,14 +733,14 @@ test_arcfour_40 (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
return ret;
}
test_code_t
test_tls1 (gnutls_session_t session)
test_tls1 (mhd_gtls_session_t session)
{
int ret;
ADD_ALL_CIPHERS (session);
@@ -749,7 +749,7 @@ test_tls1 (gnutls_session_t session)
ADD_PROTOCOL (session, GNUTLS_TLS1);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
if (ret == TEST_SUCCEED)
@@ -760,7 +760,7 @@ test_tls1 (gnutls_session_t session)
}
test_code_t
test_tls1_1 (gnutls_session_t session)
test_tls1_1 (mhd_gtls_session_t session)
{
int ret;
ADD_ALL_CIPHERS (session);
@@ -769,7 +769,7 @@ test_tls1_1 (gnutls_session_t session)
ADD_PROTOCOL (session, MHD_GNUTLS_TLS1_1);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
if (ret == TEST_SUCCEED)
@@ -780,7 +780,7 @@ test_tls1_1 (gnutls_session_t session)
}
test_code_t
test_tls1_1_fallback (gnutls_session_t session)
test_tls1_1_fallback (mhd_gtls_session_t session)
{
int ret;
if (tls1_1_ok)
@@ -792,15 +792,15 @@ test_tls1_1_fallback (gnutls_session_t session)
ADD_PROTOCOL3 (session, MHD_GNUTLS_TLS1_1, GNUTLS_TLS1, MHD_GNUTLS_SSL3);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
if (ret != TEST_SUCCEED)
return TEST_FAILED;
if (gnutls_protocol_get_version (session) == GNUTLS_TLS1)
if (MHD_gnutls_protocol_get_version (session) == GNUTLS_TLS1)
return TEST_SUCCEED;
else if (gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
else if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
return TEST_UNSURE;
return TEST_FAILED;
@@ -811,7 +811,7 @@ test_tls1_1_fallback (gnutls_session_t session)
* but the previous SSL 3.0 test succeeded then disable TLS 1.0.
*/
test_code_t
test_tls_disable (gnutls_session_t session)
test_tls_disable (mhd_gtls_session_t session)
{
int ret;
if (tls1_ok != 0)
@@ -823,7 +823,7 @@ test_tls_disable (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
if (ret == TEST_FAILED)
@@ -840,7 +840,7 @@ test_tls_disable (gnutls_session_t session)
}
test_code_t
test_rsa_pms (gnutls_session_t session)
test_rsa_pms (mhd_gtls_session_t session)
{
int ret;
@@ -855,19 +855,19 @@ test_rsa_pms (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_ALL_MACS (session);
ADD_KX (session, MHD_GNUTLS_KX_RSA);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
if (ret == TEST_FAILED)
return TEST_FAILED;
if (gnutls_protocol_get_version (session) == GNUTLS_TLS1)
if (MHD_gnutls_protocol_get_version (session) == GNUTLS_TLS1)
return TEST_SUCCEED;
return TEST_UNSURE;
}
test_code_t
test_max_record_size (gnutls_session_t session)
test_max_record_size (mhd_gtls_session_t session)
{
int ret;
ADD_ALL_CIPHERS (session);
@@ -876,14 +876,14 @@ test_max_record_size (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
gnutls_record_set_max_size (session, 512);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_record_set_max_size (session, 512);
ret = do_handshake (session);
if (ret == TEST_FAILED)
return ret;
ret = gnutls_record_get_max_size (session);
ret = MHD_gnutls_record_get_max_size (session);
if (ret == 512)
return TEST_SUCCEED;
@@ -891,7 +891,7 @@ test_max_record_size (gnutls_session_t session)
}
test_code_t
test_hello_extension (gnutls_session_t session)
test_hello_extension (mhd_gtls_session_t session)
{
int ret;
ADD_ALL_CIPHERS (session);
@@ -900,19 +900,19 @@ test_hello_extension (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
gnutls_record_set_max_size (session, 512);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_record_set_max_size (session, 512);
ret = do_handshake (session);
return ret;
}
void _gnutls_record_set_default_version (gnutls_session_t session,
void _gnutls_record_set_default_version (mhd_gtls_session_t session,
unsigned char major,
unsigned char minor);
test_code_t
test_version_rollback (gnutls_session_t session)
test_version_rollback (mhd_gtls_session_t session)
{
int ret;
if (tls1_ok == 0)
@@ -931,7 +931,7 @@ test_version_rollback (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
_gnutls_record_set_default_version (session, 3, 0);
ret = do_handshake (session);
@@ -939,7 +939,7 @@ test_version_rollback (gnutls_session_t session)
return ret;
if (tls1_ok != 0
&& gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
&& MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
return TEST_FAILED;
return TEST_SUCCEED;
@@ -950,7 +950,7 @@ test_version_rollback (gnutls_session_t session)
* message.
*/
test_code_t
test_version_oob (gnutls_session_t session)
test_version_oob (mhd_gtls_session_t session)
{
int ret;
/* here we enable both SSL 3.0 and TLS 1.0
@@ -962,18 +962,18 @@ test_version_oob (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
_gnutls_record_set_default_version (session, 5, 5);
ret = do_handshake (session);
return ret;
}
void _gnutls_rsa_pms_set_version (gnutls_session_t session,
void _gnutls_rsa_pms_set_version (mhd_gtls_session_t session,
unsigned char major, unsigned char minor);
test_code_t
test_rsa_pms_version_check (gnutls_session_t session)
test_rsa_pms_version_check (mhd_gtls_session_t session)
{
int ret;
/* here we use an arbitary version in the RSA PMS
@@ -987,7 +987,7 @@ test_rsa_pms_version_check (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
_gnutls_rsa_pms_set_version (session, 5, 5); /* use SSL 5.5 version */
ret = do_handshake (session);
@@ -997,7 +997,7 @@ test_rsa_pms_version_check (gnutls_session_t session)
#ifdef ENABLE_ANON
test_code_t
test_anonymous (gnutls_session_t session)
test_anonymous (mhd_gtls_session_t session)
{
int ret;
@@ -1007,19 +1007,19 @@ test_anonymous (gnutls_session_t session)
ADD_ALL_PROTOCOLS (session);
ADD_ALL_MACS (session);
ADD_KX (session, MHD_GNUTLS_KX_ANON_DH);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_ANON, anon_cred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_ANON, anon_cred);
ret = do_handshake (session);
if (ret == TEST_SUCCEED)
gnutls_dh_get_pubkey (session, &pubkey);
MHD_gnutls_dh_get_pubkey (session, &pubkey);
return ret;
}
#endif
test_code_t
test_session_resume2 (gnutls_session_t session)
test_session_resume2 (mhd_gtls_session_t session)
{
int ret;
char tmp_session_id[32];
@@ -1035,8 +1035,8 @@ test_session_resume2 (gnutls_session_t session)
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_ANON, anon_cred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_ANON, anon_cred);
gnutls_session_set_data (session, session_data, session_data_size);
@@ -1050,12 +1050,12 @@ test_session_resume2 (gnutls_session_t session)
/* check if we actually resumed the previous session */
session_id_size = sizeof (session_id);
gnutls_session_get_id (session, session_id, &session_id_size);
MHD_gtls_session_get_id (session, session_id, &session_id_size);
if (session_id_size == 0)
return TEST_FAILED;
if (gnutls_session_is_resumed (session))
if (MHD_gtls_session_is_resumed (session))
return TEST_SUCCEED;
if (tmp_session_id_size == session_id_size &&
@@ -1068,7 +1068,7 @@ test_session_resume2 (gnutls_session_t session)
extern char *hostname;
test_code_t
test_certificate (gnutls_session_t session)
test_certificate (mhd_gtls_session_t session)
{
int ret;
@@ -1082,7 +1082,7 @@ test_certificate (gnutls_session_t session)
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
ret = do_handshake (session);
if (ret == TEST_FAILED)
@@ -1097,7 +1097,7 @@ test_certificate (gnutls_session_t session)
/* A callback function to be used at the certificate selection time.
*/
static int
cert_callback (gnutls_session_t session,
cert_callback (mhd_gtls_session_t session,
const gnutls_datum_t * req_ca_rdn, int nreqs,
const gnutls_pk_algorithm_t * sign_algos,
int sign_algos_length, gnutls_retr_st * st)
@@ -1137,7 +1137,7 @@ cert_callback (gnutls_session_t session,
* if the server sends a certificate request packet.
*/
test_code_t
test_server_cas (gnutls_session_t session)
test_server_cas (mhd_gtls_session_t session)
{
int ret;
@@ -1151,11 +1151,11 @@ test_server_cas (gnutls_session_t session)
ADD_ALL_MACS (session);
ADD_ALL_KX (session);
gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
gnutls_certificate_client_set_retrieve_function (xcred, cert_callback);
MHD_gnutls_credentials_set (session, MHD_GNUTLS_CRD_CERTIFICATE, xcred);
MHD_gtls_certificate_client_set_retrieve_function (xcred, cert_callback);
ret = do_handshake (session);
gnutls_certificate_client_set_retrieve_function (xcred, NULL);
MHD_gtls_certificate_client_set_retrieve_function (xcred, NULL);
if (ret == TEST_FAILED)
return ret;
+34 -34
View File
@@ -3,40 +3,40 @@ typedef enum
TEST_SUCCEED, TEST_FAILED, TEST_UNSURE, TEST_IGNORE
} test_code_t;
test_code_t test_srp (gnutls_session_t state);
test_code_t test_server (gnutls_session_t state);
test_code_t test_export (gnutls_session_t state);
test_code_t test_export_info (gnutls_session_t state);
test_code_t test_hello_extension (gnutls_session_t state);
test_code_t test_dhe (gnutls_session_t state);
test_code_t test_dhe_group (gnutls_session_t state);
test_code_t test_ssl3 (gnutls_session_t state);
test_code_t test_aes (gnutls_session_t state);
test_code_t test_srp (mhd_gtls_session_t state);
test_code_t test_server (mhd_gtls_session_t state);
test_code_t test_export (mhd_gtls_session_t state);
test_code_t test_export_info (mhd_gtls_session_t state);
test_code_t test_hello_extension (mhd_gtls_session_t state);
test_code_t test_dhe (mhd_gtls_session_t state);
test_code_t test_dhe_group (mhd_gtls_session_t state);
test_code_t test_ssl3 (mhd_gtls_session_t state);
test_code_t test_aes (mhd_gtls_session_t state);
#ifdef ENABLE_CAMELLIA
test_code_t test_camellia (gnutls_session_t state);
test_code_t test_camellia (mhd_gtls_session_t state);
#endif
test_code_t test_md5 (gnutls_session_t state);
test_code_t test_sha (gnutls_session_t state);
test_code_t test_3des (gnutls_session_t state);
test_code_t test_arcfour (gnutls_session_t state);
test_code_t test_arcfour_40 (gnutls_session_t state);
test_code_t test_tls1 (gnutls_session_t state);
test_code_t test_tls1_1 (gnutls_session_t state);
test_code_t test_tls1_1_fallback (gnutls_session_t state);
test_code_t test_tls_disable (gnutls_session_t state);
test_code_t test_rsa_pms (gnutls_session_t state);
test_code_t test_max_record_size (gnutls_session_t state);
test_code_t test_version_rollback (gnutls_session_t state);
test_code_t test_anonymous (gnutls_session_t state);
test_code_t test_unknown_ciphersuites (gnutls_session_t state);
test_code_t test_openpgp1 (gnutls_session_t state);
test_code_t test_bye (gnutls_session_t state);
test_code_t test_certificate (gnutls_session_t state);
test_code_t test_server_cas (gnutls_session_t state);
test_code_t test_session_resume2 (gnutls_session_t state);
test_code_t test_rsa_pms_version_check (gnutls_session_t session);
test_code_t test_version_oob (gnutls_session_t session);
test_code_t test_zlib (gnutls_session_t session);
test_code_t test_lzo (gnutls_session_t session);
int _test_srp_username_callback (gnutls_session_t session,
test_code_t test_md5 (mhd_gtls_session_t state);
test_code_t test_sha (mhd_gtls_session_t state);
test_code_t test_3des (mhd_gtls_session_t state);
test_code_t test_arcfour (mhd_gtls_session_t state);
test_code_t test_arcfour_40 (mhd_gtls_session_t state);
test_code_t test_tls1 (mhd_gtls_session_t state);
test_code_t test_tls1_1 (mhd_gtls_session_t state);
test_code_t test_tls1_1_fallback (mhd_gtls_session_t state);
test_code_t test_tls_disable (mhd_gtls_session_t state);
test_code_t test_rsa_pms (mhd_gtls_session_t state);
test_code_t test_max_record_size (mhd_gtls_session_t state);
test_code_t test_version_rollback (mhd_gtls_session_t state);
test_code_t test_anonymous (mhd_gtls_session_t state);
test_code_t test_unknown_ciphersuites (mhd_gtls_session_t state);
test_code_t test_openpgp1 (mhd_gtls_session_t state);
test_code_t test_bye (mhd_gtls_session_t state);
test_code_t test_certificate (mhd_gtls_session_t state);
test_code_t test_server_cas (mhd_gtls_session_t state);
test_code_t test_session_resume2 (mhd_gtls_session_t state);
test_code_t test_rsa_pms_version_check (mhd_gtls_session_t session);
test_code_t test_version_oob (mhd_gtls_session_t session);
test_code_t test_zlib (mhd_gtls_session_t session);
test_code_t test_lzo (mhd_gtls_session_t session);
int _test_srp_username_callback (mhd_gtls_session_t session,
char **username, char **password);
+28 -28
View File
@@ -40,38 +40,38 @@
#include <gnutls_state.h>
#include <auth_dh_common.h>
static int gen_anon_server_kx (gnutls_session_t, opaque **);
static int proc_anon_client_kx (gnutls_session_t, opaque *, size_t);
static int proc_anon_server_kx (gnutls_session_t, opaque *, size_t);
static int gen_anon_server_kx (mhd_gtls_session_t, opaque **);
static int proc_anon_client_kx (mhd_gtls_session_t, opaque *, size_t);
static int mhd_gtls_proc_anon_server_kx (mhd_gtls_session_t, opaque *, size_t);
const mod_auth_st anon_auth_struct = {
const mhd_gtls_mod_auth_st anon_auth_struct = {
"ANON",
NULL,
NULL,
gen_anon_server_kx,
_gnutls_gen_dh_common_client_kx, /* this can be shared */
mhd_gtls_gen_dh_common_client_kx, /* this can be shared */
NULL,
NULL,
NULL,
NULL, /* certificate */
proc_anon_server_kx,
mhd_gtls_proc_anon_server_kx,
proc_anon_client_kx,
NULL,
NULL
};
static int
gen_anon_server_kx (gnutls_session_t session, opaque ** data)
gen_anon_server_kx (mhd_gtls_session_t session, opaque ** data)
{
mpi_t g, p;
const mpi_t *mpis;
int ret;
gnutls_dh_params_t dh_params;
gnutls_anon_server_credentials_t cred;
mhd_gtls_dh_params_t dh_params;
mhd_gtls_anon_server_credentials_t cred;
cred = (gnutls_anon_server_credentials_t)
_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_ANON, NULL);
cred = (mhd_gtls_anon_server_credentials_t)
mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_ANON, NULL);
if (cred == NULL)
{
gnutls_assert ();
@@ -79,8 +79,8 @@ gen_anon_server_kx (gnutls_session_t session, opaque ** data)
}
dh_params =
_gnutls_get_dh_params (cred->dh_params, cred->params_func, session);
mpis = _gnutls_dh_params_to_mpi (dh_params);
mhd_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
mpis = mhd_gtls_dh_params_to_mpi (dh_params);
if (mpis == NULL)
{
gnutls_assert ();
@@ -91,16 +91,16 @@ gen_anon_server_kx (gnutls_session_t session, opaque ** data)
g = mpis[1];
if ((ret =
_gnutls_auth_info_set (session, MHD_GNUTLS_CRD_ANON,
mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_ANON,
sizeof (anon_auth_info_st), 1)) < 0)
{
gnutls_assert ();
return ret;
}
_gnutls_dh_set_group (session, g, p);
mhd_gtls_dh_set_group (session, g, p);
ret = _gnutls_dh_common_print_server_kx (session, g, p, data, 0);
ret = mhd_gtls_dh_common_print_server_kx (session, g, p, data, 0);
if (ret < 0)
{
gnutls_assert ();
@@ -111,20 +111,20 @@ gen_anon_server_kx (gnutls_session_t session, opaque ** data)
static int
proc_anon_client_kx (gnutls_session_t session, opaque * data,
proc_anon_client_kx (mhd_gtls_session_t session, opaque * data,
size_t _data_size)
{
gnutls_anon_server_credentials_t cred;
mhd_gtls_anon_server_credentials_t cred;
int bits;
int ret;
mpi_t p, g;
gnutls_dh_params_t dh_params;
mhd_gtls_dh_params_t dh_params;
const mpi_t *mpis;
bits = _gnutls_dh_get_allowed_prime_bits (session);
bits = mhd_gtls_dh_get_allowed_prime_bits (session);
cred = (gnutls_anon_server_credentials_t)
_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_ANON, NULL);
cred = (mhd_gtls_anon_server_credentials_t)
mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_ANON, NULL);
if (cred == NULL)
{
gnutls_assert ();
@@ -132,8 +132,8 @@ proc_anon_client_kx (gnutls_session_t session, opaque * data,
}
dh_params =
_gnutls_get_dh_params (cred->dh_params, cred->params_func, session);
mpis = _gnutls_dh_params_to_mpi (dh_params);
mhd_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
mpis = mhd_gtls_dh_params_to_mpi (dh_params);
if (mpis == NULL)
{
gnutls_assert ();
@@ -143,14 +143,14 @@ proc_anon_client_kx (gnutls_session_t session, opaque * data,
p = mpis[0];
g = mpis[1];
ret = _gnutls_proc_dh_common_client_kx (session, data, _data_size, g, p);
ret = mhd_gtls_proc_dh_common_client_kx (session, data, _data_size, g, p);
return ret;
}
int
proc_anon_server_kx (gnutls_session_t session, opaque * data,
mhd_gtls_proc_anon_server_kx (mhd_gtls_session_t session, opaque * data,
size_t _data_size)
{
@@ -158,14 +158,14 @@ proc_anon_server_kx (gnutls_session_t session, opaque * data,
/* set auth_info */
if ((ret =
_gnutls_auth_info_set (session, MHD_GNUTLS_CRD_ANON,
mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_ANON,
sizeof (anon_auth_info_st), 1)) < 0)
{
gnutls_assert ();
return ret;
}
ret = _gnutls_proc_dh_common_server_kx (session, data, _data_size, 0);
ret = mhd_gtls_proc_dh_common_server_kx (session, data, _data_size, 0);
if (ret < 0)
{
gnutls_assert ();
+8 -8
View File
@@ -26,23 +26,23 @@
#include <gnutls_auth.h>
#include <auth_dh_common.h>
typedef struct gnutls_anon_server_credentials_st
typedef struct mhd_gtls_anon_server_credentials_st
{
gnutls_dh_params_t dh_params;
mhd_gtls_dh_params_t dh_params;
/* this callback is used to retrieve the DH or RSA
* parameters.
*/
gnutls_params_function *params_func;
} anon_server_credentials_st;
} mhd_anon_server_credentials_st;
typedef struct gnutls_anon_client_credentials_st
typedef struct mhd_gtls_anon_client_credentials_st
{
int dummy;
} anon_client_credentials_st;
} mhd_anon_client_credentials_st;
typedef struct anon_auth_info_st
typedef struct mhd_gtls_anon_auth_info_st
{
dh_info_st dh;
} *anon_auth_info_t;
} * mhd_anon_auth_info_t;
typedef struct anon_auth_info_st anon_auth_info_st;
typedef struct mhd_gtls_anon_auth_info_st anon_auth_info_st;
+96 -96
View File
@@ -187,7 +187,7 @@ _gnutls_cert_get_issuer_dn (gnutls_cert * cert, gnutls_datum_t * odn)
* CAs and sign algorithms supported by the peer server.
*/
static int
_find_x509_cert (const gnutls_certificate_credentials_t cred,
_find_x509_cert (const mhd_gtls_cert_credentials_t cred,
opaque * _data, size_t _data_size,
const gnutls_pk_algorithm_t * pk_algos,
int pk_algos_length, int *indx)
@@ -205,7 +205,7 @@ _find_x509_cert (const gnutls_certificate_credentials_t cred,
{
DECR_LENGTH_RET (data_size, 2, 0);
size = _gnutls_read_uint16 (data);
size = mhd_gtls_read_uint16 (data);
DECR_LENGTH_RET (data_size, size, 0);
data += 2;
@@ -258,7 +258,7 @@ _find_x509_cert (const gnutls_certificate_credentials_t cred,
/* Locates the most appropriate openpgp cert
*/
static int
_find_openpgp_cert (const gnutls_certificate_credentials_t cred,
_find_openpgp_cert (const mhd_gtls_cert_credentials_t cred,
gnutls_pk_algorithm_t * pk_algos,
int pk_algos_length, int *indx)
{
@@ -294,7 +294,7 @@ _find_openpgp_cert (const gnutls_certificate_credentials_t cred,
* certificate request packet.
*/
static int
get_issuers_num (gnutls_session_t session, opaque * data, ssize_t data_size)
get_issuers_num (mhd_gtls_session_t session, opaque * data, ssize_t data_size)
{
int issuers_dn_len = 0, result;
unsigned size;
@@ -314,7 +314,7 @@ get_issuers_num (gnutls_session_t session, opaque * data, ssize_t data_size)
*/
result = GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
DECR_LENGTH_COM (data_size, 2, goto error);
size = _gnutls_read_uint16 (data);
size = mhd_gtls_read_uint16 (data);
result = GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
DECR_LENGTH_COM (data_size, size, goto error);
@@ -343,7 +343,7 @@ error:
* packet.
*/
static int
get_issuers (gnutls_session_t session,
get_issuers (mhd_gtls_session_t session,
gnutls_datum_t * issuers_dn, int issuers_len,
opaque * data, size_t data_size)
{
@@ -367,7 +367,7 @@ get_issuers (gnutls_session_t session,
*/
data_size -= 2;
size = _gnutls_read_uint16 (data);
size = mhd_gtls_read_uint16 (data);
data += 2;
@@ -384,7 +384,7 @@ get_issuers (gnutls_session_t session,
/* Calls the client get callback.
*/
static int
call_get_cert_callback (gnutls_session_t session,
call_get_cert_callback (mhd_gtls_session_t session,
gnutls_datum_t * issuers_dn,
int issuers_dn_length,
gnutls_pk_algorithm_t * pk_algos, int pk_algos_length)
@@ -395,10 +395,10 @@ call_get_cert_callback (gnutls_session_t session,
gnutls_retr_st st;
int ret;
gnutls_certificate_type_t type = gnutls_certificate_type_get (session);
gnutls_certificate_credentials_t cred;
mhd_gtls_cert_credentials_t cred;
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
cred = (mhd_gtls_cert_credentials_t)
mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
@@ -457,7 +457,7 @@ call_get_cert_callback (gnutls_session_t session,
}
_gnutls_selected_certs_set (session, local_certs,
mhd_gtls_selected_certs_set (session, local_certs,
(local_certs != NULL) ? st.ncerts : 0,
local_key, 1);
@@ -504,20 +504,20 @@ cleanup:
* algorithm (only in automatic mode).
*/
static int
_select_client_cert (gnutls_session_t session,
_select_client_cert (mhd_gtls_session_t session,
opaque * _data, size_t _data_size,
gnutls_pk_algorithm_t * pk_algos, int pk_algos_length)
{
int result;
int indx = -1;
gnutls_certificate_credentials_t cred;
mhd_gtls_cert_credentials_t cred;
opaque *data = _data;
ssize_t data_size = _data_size;
int issuers_dn_length;
gnutls_datum_t *issuers_dn = NULL;
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
cred = (mhd_gtls_cert_credentials_t)
mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
@@ -590,14 +590,14 @@ _select_client_cert (gnutls_session_t session,
if (indx >= 0)
{
_gnutls_selected_certs_set (session,
mhd_gtls_selected_certs_set (session,
&cred->cert_list[indx][0],
cred->cert_list_length[indx],
&cred->pkey[indx], 0);
}
else
{
_gnutls_selected_certs_set (session, NULL, 0, NULL, 0);
mhd_gtls_selected_certs_set (session, NULL, 0, NULL, 0);
}
result = 0;
@@ -613,7 +613,7 @@ cleanup:
*/
int
_gnutls_gen_x509_crt (gnutls_session_t session, opaque ** data)
_gnutls_gen_x509_crt (mhd_gtls_session_t session, opaque ** data)
{
int ret, i;
opaque *pdata;
@@ -624,7 +624,7 @@ _gnutls_gen_x509_crt (gnutls_session_t session, opaque ** data)
/* find the appropriate certificate
*/
if ((ret =
_gnutls_get_selected_cert (session, &apr_cert_list,
mhd_gtls_get_selected_cert (session, &apr_cert_list,
&apr_cert_list_length, &apr_pkey)) < 0)
{
gnutls_assert ();
@@ -656,11 +656,11 @@ _gnutls_gen_x509_crt (gnutls_session_t session, opaque ** data)
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
_gnutls_write_uint24 (ret - 3, pdata);
mhd_gtls_write_uint24 (ret - 3, pdata);
pdata += 3;
for (i = 0; i < apr_cert_list_length; i++)
{
_gnutls_write_datum24 (pdata, apr_cert_list[i].raw);
mhd_gtls_write_datum24 (pdata, apr_cert_list[i].raw);
pdata += (3 + apr_cert_list[i].raw.size);
}
@@ -671,7 +671,7 @@ enum PGPKeyDescriptorType
{ PGP_KEY_FINGERPRINT, PGP_KEY };
int
_gnutls_gen_openpgp_certificate (gnutls_session_t session, opaque ** data)
_gnutls_gen_openpgp_certificate (mhd_gtls_session_t session, opaque ** data)
{
int ret;
opaque *pdata;
@@ -681,7 +681,7 @@ _gnutls_gen_openpgp_certificate (gnutls_session_t session, opaque ** data)
/* find the appropriate certificate */
if ((ret =
_gnutls_get_selected_cert (session, &apr_cert_list,
mhd_gtls_get_selected_cert (session, &apr_cert_list,
&apr_cert_list_length, &apr_pkey)) < 0)
{
gnutls_assert ();
@@ -702,7 +702,7 @@ _gnutls_gen_openpgp_certificate (gnutls_session_t session, opaque ** data)
return GNUTLS_E_MEMORY_ERROR;
}
_gnutls_write_uint24 (ret - 3, pdata);
mhd_gtls_write_uint24 (ret - 3, pdata);
pdata += 3;
*pdata = PGP_KEY; /* whole key */
@@ -710,17 +710,17 @@ _gnutls_gen_openpgp_certificate (gnutls_session_t session, opaque ** data)
if (apr_cert_list_length > 0)
{
_gnutls_write_datum24 (pdata, apr_cert_list[0].raw);
mhd_gtls_write_datum24 (pdata, apr_cert_list[0].raw);
pdata += (3 + apr_cert_list[0].raw.size);
}
else /* empty - no certificate */
_gnutls_write_uint24 (0, pdata);
mhd_gtls_write_uint24 (0, pdata);
return ret;
}
int
_gnutls_gen_openpgp_certificate_fpr (gnutls_session_t session, opaque ** data)
_gnutls_gen_openpgp_certificate_fpr (mhd_gtls_session_t session, opaque ** data)
{
int ret, packet_size;
size_t fpr_size;
@@ -731,7 +731,7 @@ _gnutls_gen_openpgp_certificate_fpr (gnutls_session_t session, opaque ** data)
/* find the appropriate certificate */
if ((ret =
_gnutls_get_selected_cert (session, &apr_cert_list,
mhd_gtls_get_selected_cert (session, &apr_cert_list,
&apr_cert_list_length, &apr_pkey)) < 0)
{
gnutls_assert ();
@@ -756,7 +756,7 @@ _gnutls_gen_openpgp_certificate_fpr (gnutls_session_t session, opaque ** data)
return GNUTLS_E_MEMORY_ERROR;
}
_gnutls_write_uint24 (packet_size - 3, pdata);
mhd_gtls_write_uint24 (packet_size - 3, pdata);
pdata += 3;
*pdata = PGP_KEY_FINGERPRINT; /* key fingerprint */
@@ -787,12 +787,12 @@ _gnutls_gen_openpgp_certificate_fpr (gnutls_session_t session, opaque ** data)
int
_gnutls_gen_cert_client_certificate (gnutls_session_t session, opaque ** data)
mhd_gtls_gen_cert_client_certificate (mhd_gtls_session_t session, opaque ** data)
{
switch (session->security_parameters.cert_type)
{
case MHD_GNUTLS_CRT_OPENPGP:
if (_gnutls_openpgp_send_fingerprint (session) == 0)
if (mhd_gtls_openpgp_send_fingerprint (session) == 0)
return _gnutls_gen_openpgp_certificate (session, data);
else
return _gnutls_gen_openpgp_certificate_fpr (session, data);
@@ -807,7 +807,7 @@ _gnutls_gen_cert_client_certificate (gnutls_session_t session, opaque ** data)
}
int
_gnutls_gen_cert_server_certificate (gnutls_session_t session, opaque ** data)
mhd_gtls_gen_cert_server_certificate (mhd_gtls_session_t session, opaque ** data)
{
switch (session->security_parameters.cert_type)
{
@@ -824,23 +824,23 @@ _gnutls_gen_cert_server_certificate (gnutls_session_t session, opaque ** data)
/* Process server certificate
*/
#define CLEAR_CERTS for(x=0;x<peer_certificate_list_size;x++) _gnutls_gcert_deinit(&peer_certificate_list[x])
#define CLEAR_CERTS for(x=0;x<peer_certificate_list_size;x++) mhd_gtls_gcert_deinit(&peer_certificate_list[x])
int
_gnutls_proc_x509_server_certificate (gnutls_session_t session,
_gnutls_proc_x509_server_certificate (mhd_gtls_session_t session,
opaque * data, size_t data_size)
{
int size, len, ret;
opaque *p = data;
cert_auth_info_t info;
gnutls_certificate_credentials_t cred;
mhd_gtls_cert_credentials_t cred;
ssize_t dsize = data_size;
int i, j, x;
gnutls_cert *peer_certificate_list;
int peer_certificate_list_size = 0;
gnutls_datum_t tmp;
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
cred = (mhd_gtls_cert_credentials_t)
mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
@@ -849,14 +849,14 @@ _gnutls_proc_x509_server_certificate (gnutls_session_t session,
if ((ret =
_gnutls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
sizeof (cert_auth_info_st), 1)) < 0)
{
gnutls_assert ();
return ret;
}
info = _gnutls_get_auth_info (session);
info = mhd_gtls_get_auth_info (session);
if (data == NULL || data_size == 0)
{
@@ -866,7 +866,7 @@ _gnutls_proc_x509_server_certificate (gnutls_session_t session,
}
DECR_LEN (dsize, 3);
size = _gnutls_read_uint24 (p);
size = mhd_gtls_read_uint24 (p);
p += 3;
/* some implementations send 0B 00 00 06 00 00 03 00 00 00
@@ -883,7 +883,7 @@ _gnutls_proc_x509_server_certificate (gnutls_session_t session,
while (i > 0)
{
DECR_LEN (dsize, 3);
len = _gnutls_read_uint24 (p);
len = mhd_gtls_read_uint24 (p);
p += 3;
DECR_LEN (dsize, len);
peer_certificate_list_size++;
@@ -921,14 +921,14 @@ _gnutls_proc_x509_server_certificate (gnutls_session_t session,
for (j = 0; j < peer_certificate_list_size; j++)
{
len = _gnutls_read_uint24 (p);
len = mhd_gtls_read_uint24 (p);
p += 3;
tmp.size = len;
tmp.data = p;
if ((ret =
_gnutls_x509_raw_cert_to_gcert (&peer_certificate_list
mhd_gtls_x509_raw_cert_to_gcert (&peer_certificate_list
[j], &tmp,
CERT_ONLY_EXTENSIONS)) < 0)
{
@@ -966,23 +966,23 @@ cleanup:
}
#define CLEAR_CERTS for(x=0;x<peer_certificate_list_size;x++) _gnutls_gcert_deinit(&peer_certificate_list[x])
#define CLEAR_CERTS for(x=0;x<peer_certificate_list_size;x++) mhd_gtls_gcert_deinit(&peer_certificate_list[x])
int
_gnutls_proc_openpgp_server_certificate (gnutls_session_t session,
_gnutls_proc_openpgp_server_certificate (mhd_gtls_session_t session,
opaque * data, size_t data_size)
{
int size, ret, len;
opaque *p = data;
cert_auth_info_t info;
gnutls_certificate_credentials_t cred;
mhd_gtls_cert_credentials_t cred;
ssize_t dsize = data_size;
int i, x;
gnutls_cert *peer_certificate_list = NULL;
int peer_certificate_list_size = 0;
gnutls_datum_t tmp, akey = { NULL, 0 };
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
cred = (mhd_gtls_cert_credentials_t)
mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
@@ -990,14 +990,14 @@ _gnutls_proc_openpgp_server_certificate (gnutls_session_t session,
}
if ((ret =
_gnutls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
sizeof (cert_auth_info_st), 1)) < 0)
{
gnutls_assert ();
return ret;
}
info = _gnutls_get_auth_info (session);
info = mhd_gtls_get_auth_info (session);
if (data == NULL || data_size == 0)
{
@@ -1006,7 +1006,7 @@ _gnutls_proc_openpgp_server_certificate (gnutls_session_t session,
}
DECR_LEN (dsize, 3);
size = _gnutls_read_uint24 (p);
size = mhd_gtls_read_uint24 (p);
p += 3;
if (size == 0)
@@ -1060,7 +1060,7 @@ _gnutls_proc_openpgp_server_certificate (gnutls_session_t session,
/* Read the actual certificate */
DECR_LEN (dsize, 3);
len = _gnutls_read_uint24 (p);
len = mhd_gtls_read_uint24 (p);
p += 3;
if (len == 0)
@@ -1147,7 +1147,7 @@ cleanup:
}
int
_gnutls_proc_cert_server_certificate (gnutls_session_t session,
mhd_gtls_proc_cert_server_certificate (mhd_gtls_session_t session,
opaque * data, size_t data_size)
{
switch (session->security_parameters.cert_type)
@@ -1185,21 +1185,21 @@ _gnutls_check_supported_sign_algo (CertificateSigType algo)
}
int
_gnutls_proc_cert_cert_req (gnutls_session_t session, opaque * data,
mhd_gtls_proc_cert_cert_req (mhd_gtls_session_t session, opaque * data,
size_t data_size)
{
int size, ret;
opaque *p;
gnutls_certificate_credentials_t cred;
mhd_gtls_cert_credentials_t cred;
cert_auth_info_t info;
ssize_t dsize;
int i, j;
gnutls_pk_algorithm_t pk_algos[MAX_SIGN_ALGOS];
int pk_algos_length;
gnutls_protocol_t ver = gnutls_protocol_get_version (session);
gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session);
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
cred = (mhd_gtls_cert_credentials_t)
mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
@@ -1207,14 +1207,14 @@ _gnutls_proc_cert_cert_req (gnutls_session_t session, opaque * data,
}
if ((ret =
_gnutls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
sizeof (cert_auth_info_st), 0)) < 0)
{
gnutls_assert ();
return ret;
}
info = _gnutls_get_auth_info (session);
info = mhd_gtls_get_auth_info (session);
p = data;
dsize = data_size;
@@ -1259,7 +1259,7 @@ _gnutls_proc_cert_cert_req (gnutls_session_t session, opaque * data,
/* read the certificate authorities */
DECR_LEN (dsize, 2);
size = _gnutls_read_uint16 (p);
size = mhd_gtls_read_uint16 (p);
p += 2;
if (session->security_parameters.cert_type == MHD_GNUTLS_CRT_OPENPGP
@@ -1290,7 +1290,7 @@ _gnutls_proc_cert_cert_req (gnutls_session_t session, opaque * data,
}
int
_gnutls_gen_cert_client_cert_vrfy (gnutls_session_t session, opaque ** data)
mhd_gtls_gen_cert_client_cert_vrfy (mhd_gtls_session_t session, opaque ** data)
{
int ret;
gnutls_cert *apr_cert_list;
@@ -1302,7 +1302,7 @@ _gnutls_gen_cert_client_cert_vrfy (gnutls_session_t session, opaque ** data)
/* find the appropriate certificate */
if ((ret =
_gnutls_get_selected_cert (session, &apr_cert_list,
mhd_gtls_get_selected_cert (session, &apr_cert_list,
&apr_cert_list_length, &apr_pkey)) < 0)
{
gnutls_assert ();
@@ -1312,7 +1312,7 @@ _gnutls_gen_cert_client_cert_vrfy (gnutls_session_t session, opaque ** data)
if (apr_cert_list_length > 0)
{
if ((ret =
_gnutls_tls_sign_hdata (session,
mhd_gtls_tls_sign_hdata (session,
&apr_cert_list[0],
apr_pkey, &signature)) < 0)
{
@@ -1332,7 +1332,7 @@ _gnutls_gen_cert_client_cert_vrfy (gnutls_session_t session, opaque ** data)
return GNUTLS_E_MEMORY_ERROR;
}
size = signature.size;
_gnutls_write_uint16 (size, *data);
mhd_gtls_write_uint16 (size, *data);
memcpy (&(*data)[2], signature.data, size);
@@ -1342,14 +1342,14 @@ _gnutls_gen_cert_client_cert_vrfy (gnutls_session_t session, opaque ** data)
}
int
_gnutls_proc_cert_client_cert_vrfy (gnutls_session_t session,
mhd_gtls_proc_cert_client_cert_vrfy (mhd_gtls_session_t session,
opaque * data, size_t data_size)
{
int size, ret;
ssize_t dsize = data_size;
opaque *pdata = data;
gnutls_datum_t sig;
cert_auth_info_t info = _gnutls_get_auth_info (session);
cert_auth_info_t info = mhd_gtls_get_auth_info (session);
gnutls_cert peer_cert;
if (info == NULL || info->ncerts == 0)
@@ -1360,7 +1360,7 @@ _gnutls_proc_cert_client_cert_vrfy (gnutls_session_t session,
}
DECR_LEN (dsize, 2);
size = _gnutls_read_uint16 (pdata);
size = mhd_gtls_read_uint16 (pdata);
pdata += 2;
DECR_LEN (dsize, size);
@@ -1368,7 +1368,7 @@ _gnutls_proc_cert_client_cert_vrfy (gnutls_session_t session,
sig.data = pdata;
sig.size = size;
ret = _gnutls_raw_cert_to_gcert (&peer_cert,
ret = mhd_gtls_raw_cert_to_gcert (&peer_cert,
session->security_parameters.cert_type,
&info->raw_certificate_list[0],
CERT_NO_COPY);
@@ -1379,33 +1379,33 @@ _gnutls_proc_cert_client_cert_vrfy (gnutls_session_t session,
return ret;
}
if ((ret = _gnutls_verify_sig_hdata (session, &peer_cert, &sig)) < 0)
if ((ret = mhd_gtls_verify_sig_hdata (session, &peer_cert, &sig)) < 0)
{
gnutls_assert ();
_gnutls_gcert_deinit (&peer_cert);
mhd_gtls_gcert_deinit (&peer_cert);
return ret;
}
_gnutls_gcert_deinit (&peer_cert);
mhd_gtls_gcert_deinit (&peer_cert);
return 0;
}
#define CERTTYPE_SIZE 3
int
_gnutls_gen_cert_server_cert_req (gnutls_session_t session, opaque ** data)
mhd_gtls_gen_cert_server_cert_req (mhd_gtls_session_t session, opaque ** data)
{
gnutls_certificate_credentials_t cred;
mhd_gtls_cert_credentials_t cred;
int size;
opaque *pdata;
gnutls_protocol_t ver = gnutls_protocol_get_version (session);
gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session);
/* Now we need to generate the RDN sequence. This is
* already in the CERTIFICATE_CRED structure, to improve
* performance.
*/
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
cred = (mhd_gtls_cert_credentials_t)
mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
@@ -1449,12 +1449,12 @@ _gnutls_gen_cert_server_cert_req (gnutls_session_t session, opaque ** data)
if (session->security_parameters.cert_type == MHD_GNUTLS_CRT_X509 &&
session->internals.ignore_rdn_sequence == 0)
{
_gnutls_write_datum16 (pdata, cred->x509_rdn_sequence);
mhd_gtls_write_datum16 (pdata, cred->x509_rdn_sequence);
/* pdata += cred->x509_rdn_sequence.size + 2; */
}
else
{
_gnutls_write_uint16 (0, pdata);
mhd_gtls_write_uint16 (0, pdata);
/* pdata+=2; */
}
@@ -1470,7 +1470,7 @@ _gnutls_gen_cert_server_cert_req (gnutls_session_t session, opaque ** data)
*
*/
int
_gnutls_get_selected_cert (gnutls_session_t session,
mhd_gtls_get_selected_cert (mhd_gtls_session_t session,
gnutls_cert ** apr_cert_list,
int *apr_cert_list_length,
gnutls_privkey ** apr_pkey)
@@ -1530,7 +1530,7 @@ alloc_and_load_x509_certs (gnutls_x509_crt_t * certs, unsigned ncerts)
for (i = 0; i < ncerts; i++)
{
ret = _gnutls_x509_crt_to_gcert (&local_certs[i], certs[i], 0);
ret = mhd_gtls_x509_crt_to_gcert (&local_certs[i], certs[i], 0);
if (ret < 0)
break;
}
@@ -1540,7 +1540,7 @@ alloc_and_load_x509_certs (gnutls_x509_crt_t * certs, unsigned ncerts)
gnutls_assert ();
for (j = 0; j < i; j++)
{
_gnutls_gcert_deinit (&local_certs[j]);
mhd_gtls_gcert_deinit (&local_certs[j]);
}
gnutls_free (local_certs);
return NULL;
@@ -1613,7 +1613,7 @@ alloc_and_load_pgp_certs (gnutls_openpgp_crt_t cert)
if (ret < 0)
{
gnutls_assert ();
_gnutls_gcert_deinit (local_certs);
mhd_gtls_gcert_deinit (local_certs);
gnutls_free (local_certs);
return NULL;
}
@@ -1658,7 +1658,7 @@ alloc_and_load_pgp_key (const gnutls_openpgp_privkey_t key)
void
_gnutls_selected_certs_deinit (gnutls_session_t session)
mhd_gtls_selected_certs_deinit (mhd_gtls_session_t session)
{
if (session->internals.selected_need_free != 0)
{
@@ -1666,13 +1666,13 @@ _gnutls_selected_certs_deinit (gnutls_session_t session)
for (i = 0; i < session->internals.selected_cert_list_length; i++)
{
_gnutls_gcert_deinit (&session->internals.selected_cert_list[i]);
mhd_gtls_gcert_deinit (&session->internals.selected_cert_list[i]);
}
gnutls_free (session->internals.selected_cert_list);
session->internals.selected_cert_list = NULL;
session->internals.selected_cert_list_length = 0;
_gnutls_gkey_deinit (session->internals.selected_key);
mhd_gtls_gkey_deinit (session->internals.selected_key);
if (session->internals.selected_key)
{
gnutls_free (session->internals.selected_key);
@@ -1684,11 +1684,11 @@ _gnutls_selected_certs_deinit (gnutls_session_t session)
}
void
_gnutls_selected_certs_set (gnutls_session_t session,
mhd_gtls_selected_certs_set (mhd_gtls_session_t session,
gnutls_cert * certs, int ncerts,
gnutls_privkey * key, int need_free)
{
_gnutls_selected_certs_deinit (session);
mhd_gtls_selected_certs_deinit (session);
session->internals.selected_cert_list = certs;
session->internals.selected_cert_list_length = ncerts;
@@ -1709,15 +1709,15 @@ _gnutls_selected_certs_set (gnutls_session_t session,
*
*/
int
_gnutls_server_select_cert (gnutls_session_t session,
mhd_gtls_server_select_cert (mhd_gtls_session_t session,
gnutls_pk_algorithm_t requested_algo)
{
unsigned i;
int idx, ret;
gnutls_certificate_credentials_t cred;
mhd_gtls_cert_credentials_t cred;
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
cred = (mhd_gtls_cert_credentials_t)
mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
@@ -1759,7 +1759,7 @@ _gnutls_server_select_cert (gnutls_session_t session,
*/
if (idx >= 0 && ret == 0)
{
_gnutls_selected_certs_set (session,
mhd_gtls_selected_certs_set (session,
&cred->cert_list[idx][0],
cred->cert_list_length[idx],
&cred->pkey[idx], 0);
@@ -1771,10 +1771,10 @@ _gnutls_server_select_cert (gnutls_session_t session,
return ret;
}
/* Frees the rsa_info_st structure.
/* Frees the mhd_gtls_rsa_info_st structure.
*/
void
_gnutls_free_rsa_info (rsa_info_st * rsa)
mhd_gtls_free_rsa_info (rsa_info_st * rsa)
{
_gnutls_free_datum (&rsa->modulus);
_gnutls_free_datum (&rsa->exponent);
+21 -21
View File
@@ -35,10 +35,10 @@
* support a server that has multiple certificates
*/
typedef struct gnutls_certificate_credentials_st
typedef struct mhd_gtls_certificate_credentials_st
{
gnutls_dh_params_t dh_params;
gnutls_rsa_params_t rsa_params;
mhd_gtls_dh_params_t dh_params;
mhd_gtls_rsa_params_t rsa_params;
/* this callback is used to retrieve the DH or RSA
* parameters.
*/
@@ -100,13 +100,13 @@ typedef struct gnutls_certificate_credentials_st
gnutls_certificate_server_retrieve_function *server_get_cert_callback;
} certificate_credentials_st;
typedef struct rsa_info_st
typedef struct mhd_gtls_rsa_info_st
{
gnutls_datum_t modulus;
gnutls_datum_t exponent;
} rsa_info_st;
typedef struct cert_auth_info_st
typedef struct mhd_gtls_cert_auth_info_st
{
int certificate_requested; /* if the peer requested certificate
* this is non zero;
@@ -124,36 +124,36 @@ typedef struct cert_auth_info_st
unsigned int ncerts; /* holds the size of the list above */
} *cert_auth_info_t;
typedef struct cert_auth_info_st cert_auth_info_st;
typedef struct mhd_gtls_cert_auth_info_st cert_auth_info_st;
void _gnutls_free_rsa_info (rsa_info_st * rsa);
void mhd_gtls_free_rsa_info (rsa_info_st * rsa);
/* AUTH X509 functions */
int _gnutls_gen_cert_server_certificate (gnutls_session_t, opaque **);
int _gnutls_gen_cert_client_certificate (gnutls_session_t, opaque **);
int _gnutls_gen_cert_client_cert_vrfy (gnutls_session_t, opaque **);
int _gnutls_gen_cert_server_cert_req (gnutls_session_t, opaque **);
int _gnutls_proc_cert_cert_req (gnutls_session_t, opaque *, size_t);
int _gnutls_proc_cert_client_cert_vrfy (gnutls_session_t, opaque *, size_t);
int _gnutls_proc_cert_server_certificate (gnutls_session_t, opaque *, size_t);
int _gnutls_get_selected_cert (gnutls_session_t session,
int mhd_gtls_gen_cert_server_certificate (mhd_gtls_session_t, opaque **);
int mhd_gtls_gen_cert_client_certificate (mhd_gtls_session_t, opaque **);
int mhd_gtls_gen_cert_client_cert_vrfy (mhd_gtls_session_t, opaque **);
int mhd_gtls_gen_cert_server_cert_req (mhd_gtls_session_t, opaque **);
int mhd_gtls_proc_cert_cert_req (mhd_gtls_session_t, opaque *, size_t);
int mhd_gtls_proc_cert_client_cert_vrfy (mhd_gtls_session_t, opaque *, size_t);
int mhd_gtls_proc_cert_server_certificate (mhd_gtls_session_t, opaque *, size_t);
int mhd_gtls_get_selected_cert (mhd_gtls_session_t session,
gnutls_cert ** apr_cert_list,
int *apr_cert_list_length,
gnutls_privkey ** apr_pkey);
int _gnutls_server_select_cert (struct gnutls_session_int *,
int mhd_gtls_server_select_cert (struct MHD_gtls_session_int *,
gnutls_pk_algorithm_t);
void _gnutls_selected_certs_deinit (gnutls_session_t session);
void _gnutls_selected_certs_set (gnutls_session_t session,
void mhd_gtls_selected_certs_deinit (mhd_gtls_session_t session);
void mhd_gtls_selected_certs_set (mhd_gtls_session_t session,
gnutls_cert * certs, int ncerts,
gnutls_privkey * key, int need_free);
#define _gnutls_proc_cert_client_certificate _gnutls_proc_cert_server_certificate
#define _gnutls_proc_cert_client_certificate mhd_gtls_proc_cert_server_certificate
gnutls_rsa_params_t _gnutls_certificate_get_rsa_params (gnutls_rsa_params_t
mhd_gtls_rsa_params_t mhd_gtls_certificate_get_rsa_params (mhd_gtls_rsa_params_t
rsa_params,
gnutls_params_function
* func,
gnutls_session_t);
mhd_gtls_session_t);
#endif
+52 -52
View File
@@ -42,7 +42,7 @@
/* Frees the dh_info_st structure.
*/
void
_gnutls_free_dh_info (dh_info_st * dh)
mhd_gtls_free_dh_info (dh_info_st * dh)
{
dh->secret_bits = 0;
_gnutls_free_datum (&dh->prime);
@@ -51,7 +51,7 @@ _gnutls_free_dh_info (dh_info_st * dh)
}
int
_gnutls_proc_dh_common_client_kx (gnutls_session_t session,
mhd_gtls_proc_dh_common_client_kx (mhd_gtls_session_t session,
opaque * data, size_t _data_size,
mpi_t g, mpi_t p)
{
@@ -62,20 +62,20 @@ _gnutls_proc_dh_common_client_kx (gnutls_session_t session,
DECR_LEN (data_size, 2);
n_Y = _gnutls_read_uint16 (&data[0]);
n_Y = mhd_gtls_read_uint16 (&data[0]);
_n_Y = n_Y;
DECR_LEN (data_size, n_Y);
if (_gnutls_mpi_scan_nz (&session->key->client_Y, &data[2], &_n_Y))
if (mhd_gtls_mpi_scan_nz (&session->key->client_Y, &data[2], &_n_Y))
{
gnutls_assert ();
return GNUTLS_E_MPI_SCAN_FAILED;
}
_gnutls_dh_set_peer_public (session, session->key->client_Y);
mhd_gtls_dh_set_peer_public (session, session->key->client_Y);
session->key->KEY =
gnutls_calc_dh_key (session->key->client_Y, session->key->dh_secret, p);
mhd_gtls_calc_dh_key (session->key->client_Y, session->key->dh_secret, p);
if (session->key->KEY == NULL)
{
@@ -83,12 +83,12 @@ _gnutls_proc_dh_common_client_kx (gnutls_session_t session,
return GNUTLS_E_MEMORY_ERROR;
}
_gnutls_mpi_release (&session->key->client_Y);
_gnutls_mpi_release (&session->key->dh_secret);
mhd_gtls_mpi_release (&session->key->client_Y);
mhd_gtls_mpi_release (&session->key->dh_secret);
ret = _gnutls_mpi_dprint (&session->key->key, session->key->KEY);
ret = mhd_gtls_mpi_dprint (&session->key->key, session->key->KEY);
_gnutls_mpi_release (&session->key->KEY);
mhd_gtls_mpi_release (&session->key->KEY);
if (ret < 0)
{
@@ -99,7 +99,7 @@ _gnutls_proc_dh_common_client_kx (gnutls_session_t session,
}
int
_gnutls_gen_dh_common_client_kx (gnutls_session_t session, opaque ** data)
mhd_gtls_gen_dh_common_client_kx (mhd_gtls_session_t session, opaque ** data)
{
mpi_t x = NULL, X = NULL;
size_t n_X;
@@ -107,7 +107,7 @@ _gnutls_gen_dh_common_client_kx (gnutls_session_t session, opaque ** data)
*data = NULL;
X = gnutls_calc_dh_secret (&x, session->key->client_g,
X = mhd_gtls_calc_dh_secret (&x, session->key->client_g,
session->key->client_p);
if (X == NULL || x == NULL)
{
@@ -116,9 +116,9 @@ _gnutls_gen_dh_common_client_kx (gnutls_session_t session, opaque ** data)
goto error;
}
_gnutls_dh_set_secret_bits (session, _gnutls_mpi_get_nbits (x));
mhd_gtls_dh_set_secret_bits (session, _gnutls_mpi_get_nbits (x));
_gnutls_mpi_print (NULL, &n_X, X);
mhd_gtls_mpi_print (NULL, &n_X, X);
(*data) = gnutls_malloc (n_X + 2);
if (*data == NULL)
{
@@ -126,16 +126,16 @@ _gnutls_gen_dh_common_client_kx (gnutls_session_t session, opaque ** data)
goto error;
}
_gnutls_mpi_print (&(*data)[2], &n_X, X);
_gnutls_mpi_release (&X);
mhd_gtls_mpi_print (&(*data)[2], &n_X, X);
mhd_gtls_mpi_release (&X);
_gnutls_write_uint16 (n_X, &(*data)[0]);
mhd_gtls_write_uint16 (n_X, &(*data)[0]);
/* calculate the key after calculating the message */
session->key->KEY =
gnutls_calc_dh_key (session->key->client_Y, x, session->key->client_p);
mhd_gtls_calc_dh_key (session->key->client_Y, x, session->key->client_p);
_gnutls_mpi_release (&x);
mhd_gtls_mpi_release (&x);
if (session->key->KEY == NULL)
{
gnutls_assert ();
@@ -144,13 +144,13 @@ _gnutls_gen_dh_common_client_kx (gnutls_session_t session, opaque ** data)
}
/* THESE SHOULD BE DISCARDED */
_gnutls_mpi_release (&session->key->client_Y);
_gnutls_mpi_release (&session->key->client_p);
_gnutls_mpi_release (&session->key->client_g);
mhd_gtls_mpi_release (&session->key->client_Y);
mhd_gtls_mpi_release (&session->key->client_p);
mhd_gtls_mpi_release (&session->key->client_g);
ret = _gnutls_mpi_dprint (&session->key->key, session->key->KEY);
ret = mhd_gtls_mpi_dprint (&session->key->key, session->key->KEY);
_gnutls_mpi_release (&session->key->KEY);
mhd_gtls_mpi_release (&session->key->KEY);
if (ret < 0)
{
@@ -161,15 +161,15 @@ _gnutls_gen_dh_common_client_kx (gnutls_session_t session, opaque ** data)
return n_X + 2;
error:
_gnutls_mpi_release (&x);
_gnutls_mpi_release (&X);
mhd_gtls_mpi_release (&x);
mhd_gtls_mpi_release (&X);
gnutls_free (*data);
*data = NULL;
return ret;
}
int
_gnutls_proc_dh_common_server_kx (gnutls_session_t session,
mhd_gtls_proc_dh_common_server_kx (mhd_gtls_session_t session,
opaque * data, size_t _data_size, int psk)
{
uint16_t n_Y, n_g, n_p;
@@ -185,13 +185,13 @@ _gnutls_proc_dh_common_server_kx (gnutls_session_t session,
if (psk != 0)
{
DECR_LEN (data_size, 2);
psk_size = _gnutls_read_uint16 (&data[i]);
psk_size = mhd_gtls_read_uint16 (&data[i]);
DECR_LEN (data_size, psk_size);
i += 2 + psk_size;
}
DECR_LEN (data_size, 2);
n_p = _gnutls_read_uint16 (&data[i]);
n_p = mhd_gtls_read_uint16 (&data[i]);
i += 2;
DECR_LEN (data_size, n_p);
@@ -199,7 +199,7 @@ _gnutls_proc_dh_common_server_kx (gnutls_session_t session,
i += n_p;
DECR_LEN (data_size, 2);
n_g = _gnutls_read_uint16 (&data[i]);
n_g = mhd_gtls_read_uint16 (&data[i]);
i += 2;
DECR_LEN (data_size, n_g);
@@ -207,7 +207,7 @@ _gnutls_proc_dh_common_server_kx (gnutls_session_t session,
i += n_g;
DECR_LEN (data_size, 2);
n_Y = _gnutls_read_uint16 (&data[i]);
n_Y = mhd_gtls_read_uint16 (&data[i]);
i += 2;
DECR_LEN (data_size, n_Y);
@@ -218,24 +218,24 @@ _gnutls_proc_dh_common_server_kx (gnutls_session_t session,
_n_g = n_g;
_n_p = n_p;
if (_gnutls_mpi_scan_nz (&session->key->client_Y, data_Y, &_n_Y) != 0)
if (mhd_gtls_mpi_scan_nz (&session->key->client_Y, data_Y, &_n_Y) != 0)
{
gnutls_assert ();
return GNUTLS_E_MPI_SCAN_FAILED;
}
if (_gnutls_mpi_scan_nz (&session->key->client_g, data_g, &_n_g) != 0)
if (mhd_gtls_mpi_scan_nz (&session->key->client_g, data_g, &_n_g) != 0)
{
gnutls_assert ();
return GNUTLS_E_MPI_SCAN_FAILED;
}
if (_gnutls_mpi_scan_nz (&session->key->client_p, data_p, &_n_p) != 0)
if (mhd_gtls_mpi_scan_nz (&session->key->client_p, data_p, &_n_p) != 0)
{
gnutls_assert ();
return GNUTLS_E_MPI_SCAN_FAILED;
}
bits = _gnutls_dh_get_allowed_prime_bits (session);
bits = mhd_gtls_dh_get_allowed_prime_bits (session);
if (bits < 0)
{
gnutls_assert ();
@@ -250,9 +250,9 @@ _gnutls_proc_dh_common_server_kx (gnutls_session_t session,
return GNUTLS_E_DH_PRIME_UNACCEPTABLE;
}
_gnutls_dh_set_group (session, session->key->client_g,
mhd_gtls_dh_set_group (session, session->key->client_g,
session->key->client_p);
_gnutls_dh_set_peer_public (session, session->key->client_Y);
mhd_gtls_dh_set_peer_public (session, session->key->client_Y);
ret = n_Y + n_p + n_g + 6;
if (psk != 0)
@@ -264,7 +264,7 @@ _gnutls_proc_dh_common_server_kx (gnutls_session_t session,
/* If the psk flag is set, then an empty psk_identity_hint will
* be inserted */
int
_gnutls_dh_common_print_server_kx (gnutls_session_t session,
mhd_gtls_dh_common_print_server_kx (mhd_gtls_session_t session,
mpi_t g, mpi_t p, opaque ** data, int psk)
{
mpi_t x, X;
@@ -272,7 +272,7 @@ _gnutls_dh_common_print_server_kx (gnutls_session_t session,
int ret, data_size, pos;
uint8_t *pdata;
X = gnutls_calc_dh_secret (&x, g, p);
X = mhd_gtls_calc_dh_secret (&x, g, p);
if (X == NULL || x == NULL)
{
gnutls_assert ();
@@ -280,11 +280,11 @@ _gnutls_dh_common_print_server_kx (gnutls_session_t session,
}
session->key->dh_secret = x;
_gnutls_dh_set_secret_bits (session, _gnutls_mpi_get_nbits (x));
mhd_gtls_dh_set_secret_bits (session, _gnutls_mpi_get_nbits (x));
_gnutls_mpi_print (NULL, &n_g, g);
_gnutls_mpi_print (NULL, &n_p, p);
_gnutls_mpi_print (NULL, &n_X, X);
mhd_gtls_mpi_print (NULL, &n_g, g);
mhd_gtls_mpi_print (NULL, &n_p, p);
mhd_gtls_mpi_print (NULL, &n_X, X);
data_size = n_g + n_p + n_X + 6;
if (psk != 0)
@@ -293,7 +293,7 @@ _gnutls_dh_common_print_server_kx (gnutls_session_t session,
(*data) = gnutls_malloc (data_size);
if (*data == NULL)
{
_gnutls_mpi_release (&X);
mhd_gtls_mpi_release (&X);
return GNUTLS_E_MEMORY_ERROR;
}
@@ -302,24 +302,24 @@ _gnutls_dh_common_print_server_kx (gnutls_session_t session,
if (psk != 0)
{
_gnutls_write_uint16 (0, &pdata[pos]);
mhd_gtls_write_uint16 (0, &pdata[pos]);
pos += 2;
}
_gnutls_mpi_print (&pdata[pos + 2], &n_p, p);
_gnutls_write_uint16 (n_p, &pdata[pos]);
mhd_gtls_mpi_print (&pdata[pos + 2], &n_p, p);
mhd_gtls_write_uint16 (n_p, &pdata[pos]);
pos += n_p + 2;
_gnutls_mpi_print (&pdata[pos + 2], &n_g, g);
_gnutls_write_uint16 (n_g, &pdata[pos]);
mhd_gtls_mpi_print (&pdata[pos + 2], &n_g, g);
mhd_gtls_write_uint16 (n_g, &pdata[pos]);
pos += n_g + 2;
_gnutls_mpi_print (&pdata[pos + 2], &n_X, X);
_gnutls_mpi_release (&X);
mhd_gtls_mpi_print (&pdata[pos + 2], &n_X, X);
mhd_gtls_mpi_release (&X);
_gnutls_write_uint16 (n_X, &pdata[pos]);
mhd_gtls_write_uint16 (n_X, &pdata[pos]);
ret = data_size;
+5 -5
View File
@@ -34,14 +34,14 @@ typedef struct
gnutls_datum_t public_key;
} dh_info_st;
void _gnutls_free_dh_info (dh_info_st * dh);
int _gnutls_gen_dh_common_client_kx (gnutls_session_t, opaque **);
int _gnutls_proc_dh_common_client_kx (gnutls_session_t session,
void mhd_gtls_free_dh_info (dh_info_st * dh);
int mhd_gtls_gen_dh_common_client_kx (mhd_gtls_session_t, opaque **);
int mhd_gtls_proc_dh_common_client_kx (mhd_gtls_session_t session,
opaque * data, size_t _data_size,
mpi_t p, mpi_t g);
int _gnutls_dh_common_print_server_kx (gnutls_session_t, mpi_t g, mpi_t p,
int mhd_gtls_dh_common_print_server_kx (mhd_gtls_session_t, mpi_t g, mpi_t p,
opaque ** data, int psk);
int _gnutls_proc_dh_common_server_kx (gnutls_session_t session,
int mhd_gtls_proc_dh_common_server_kx (mhd_gtls_session_t session,
opaque * data, size_t _data_size,
int psk);
+51 -51
View File
@@ -39,47 +39,47 @@
#include <gnutls_state.h>
#include <auth_dh_common.h>
static int gen_dhe_server_kx (gnutls_session_t, opaque **);
static int proc_dhe_server_kx (gnutls_session_t, opaque *, size_t);
static int proc_dhe_client_kx (gnutls_session_t, opaque *, size_t);
static int gen_dhe_server_kx (mhd_gtls_session_t, opaque **);
static int proc_dhe_server_kx (mhd_gtls_session_t, opaque *, size_t);
static int proc_dhe_client_kx (mhd_gtls_session_t, opaque *, size_t);
const mod_auth_st dhe_rsa_auth_struct = {
const mhd_gtls_mod_auth_st dhe_rsa_auth_struct = {
"DHE_RSA",
_gnutls_gen_cert_server_certificate,
_gnutls_gen_cert_client_certificate,
mhd_gtls_gen_cert_server_certificate,
mhd_gtls_gen_cert_client_certificate,
gen_dhe_server_kx,
_gnutls_gen_dh_common_client_kx,
_gnutls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */
_gnutls_gen_cert_server_cert_req, /* server cert request */
mhd_gtls_gen_dh_common_client_kx,
mhd_gtls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */
mhd_gtls_gen_cert_server_cert_req, /* server cert request */
_gnutls_proc_cert_server_certificate,
mhd_gtls_proc_cert_server_certificate,
_gnutls_proc_cert_client_certificate,
proc_dhe_server_kx,
proc_dhe_client_kx,
_gnutls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */
_gnutls_proc_cert_cert_req /* proc server cert request */
mhd_gtls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */
mhd_gtls_proc_cert_cert_req /* proc server cert request */
};
const mod_auth_st dhe_dss_auth_struct = {
const mhd_gtls_mod_auth_st dhe_dss_auth_struct = {
"DHE_DSS",
_gnutls_gen_cert_server_certificate,
_gnutls_gen_cert_client_certificate,
mhd_gtls_gen_cert_server_certificate,
mhd_gtls_gen_cert_client_certificate,
gen_dhe_server_kx,
_gnutls_gen_dh_common_client_kx,
_gnutls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */
_gnutls_gen_cert_server_cert_req, /* server cert request */
mhd_gtls_gen_dh_common_client_kx,
mhd_gtls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */
mhd_gtls_gen_cert_server_cert_req, /* server cert request */
_gnutls_proc_cert_server_certificate,
mhd_gtls_proc_cert_server_certificate,
_gnutls_proc_cert_client_certificate,
proc_dhe_server_kx,
proc_dhe_client_kx,
_gnutls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */
_gnutls_proc_cert_cert_req /* proc server cert request */
mhd_gtls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */
mhd_gtls_proc_cert_cert_req /* proc server cert request */
};
static int
gen_dhe_server_kx (gnutls_session_t session, opaque ** data)
gen_dhe_server_kx (mhd_gtls_session_t session, opaque ** data)
{
mpi_t g, p;
const mpi_t *mpis;
@@ -89,22 +89,22 @@ gen_dhe_server_kx (gnutls_session_t session, opaque ** data)
gnutls_privkey *apr_pkey;
int apr_cert_list_length;
gnutls_datum_t signature, ddata;
gnutls_certificate_credentials_t cred;
gnutls_dh_params_t dh_params;
mhd_gtls_cert_credentials_t cred;
mhd_gtls_dh_params_t dh_params;
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
cred = (mhd_gtls_cert_credentials_t)
mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
bits = _gnutls_dh_get_allowed_prime_bits (session);
bits = mhd_gtls_dh_get_allowed_prime_bits (session);
/* find the appropriate certificate */
if ((ret =
_gnutls_get_selected_cert (session, &apr_cert_list,
mhd_gtls_get_selected_cert (session, &apr_cert_list,
&apr_cert_list_length, &apr_pkey)) < 0)
{
gnutls_assert ();
@@ -112,8 +112,8 @@ gen_dhe_server_kx (gnutls_session_t session, opaque ** data)
}
dh_params =
_gnutls_get_dh_params (cred->dh_params, cred->params_func, session);
mpis = _gnutls_dh_params_to_mpi (dh_params);
mhd_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
mpis = mhd_gtls_dh_params_to_mpi (dh_params);
if (mpis == NULL)
{
gnutls_assert ();
@@ -123,16 +123,16 @@ gen_dhe_server_kx (gnutls_session_t session, opaque ** data)
p = mpis[0];
g = mpis[1];
if ((ret = _gnutls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
if ((ret = mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
sizeof (cert_auth_info_st), 0)) < 0)
{
gnutls_assert ();
return ret;
}
_gnutls_dh_set_group (session, g, p);
mhd_gtls_dh_set_group (session, g, p);
ret = _gnutls_dh_common_print_server_kx (session, g, p, data, 0);
ret = mhd_gtls_dh_common_print_server_kx (session, g, p, data, 0);
if (ret < 0)
{
gnutls_assert ();
@@ -148,7 +148,7 @@ gen_dhe_server_kx (gnutls_session_t session, opaque ** data)
if (apr_cert_list_length > 0)
{
if ((ret =
_gnutls_tls_sign_params (session, &apr_cert_list[0],
mhd_gtls_tls_sign_params (session, &apr_cert_list[0],
apr_pkey, &ddata, &signature)) < 0)
{
gnutls_assert ();
@@ -162,7 +162,7 @@ gen_dhe_server_kx (gnutls_session_t session, opaque ** data)
return data_size; /* do not put a signature - ILLEGAL! */
}
*data = gnutls_realloc_fast (*data, data_size + signature.size + 2);
*data = mhd_gtls_realloc_fast (*data, data_size + signature.size + 2);
if (*data == NULL)
{
_gnutls_free_datum (&signature);
@@ -170,7 +170,7 @@ gen_dhe_server_kx (gnutls_session_t session, opaque ** data)
return GNUTLS_E_MEMORY_ERROR;
}
_gnutls_write_datum16 (&(*data)[data_size], signature);
mhd_gtls_write_datum16 (&(*data)[data_size], signature);
data_size += signature.size + 2;
_gnutls_free_datum (&signature);
@@ -179,13 +179,13 @@ gen_dhe_server_kx (gnutls_session_t session, opaque ** data)
}
static int
proc_dhe_server_kx (gnutls_session_t session, opaque * data,
proc_dhe_server_kx (mhd_gtls_session_t session, opaque * data,
size_t _data_size)
{
int sigsize;
gnutls_datum_t vparams, signature;
int ret;
cert_auth_info_t info = _gnutls_get_auth_info (session);
cert_auth_info_t info = mhd_gtls_get_auth_info (session);
ssize_t data_size = _data_size;
gnutls_cert peer_cert;
@@ -196,7 +196,7 @@ proc_dhe_server_kx (gnutls_session_t session, opaque * data,
return GNUTLS_E_INTERNAL_ERROR;
}
ret = _gnutls_proc_dh_common_server_kx (session, data, _data_size, 0);
ret = mhd_gtls_proc_dh_common_server_kx (session, data, _data_size, 0);
if (ret < 0)
{
gnutls_assert ();
@@ -209,14 +209,14 @@ proc_dhe_server_kx (gnutls_session_t session, opaque * data,
vparams.data = data;
DECR_LEN (data_size, 2);
sigsize = _gnutls_read_uint16 (&data[vparams.size]);
sigsize = mhd_gtls_read_uint16 (&data[vparams.size]);
DECR_LEN (data_size, sigsize);
signature.data = &data[vparams.size + 2];
signature.size = sigsize;
if ((ret =
_gnutls_raw_cert_to_gcert (&peer_cert,
mhd_gtls_raw_cert_to_gcert (&peer_cert,
session->security_parameters.cert_type,
&info->raw_certificate_list[0],
CERT_NO_COPY)) < 0)
@@ -225,9 +225,9 @@ proc_dhe_server_kx (gnutls_session_t session, opaque * data,
return ret;
}
ret = _gnutls_verify_sig_params (session, &peer_cert, &vparams, &signature);
ret = mhd_gtls_verify_sig_params (session, &peer_cert, &vparams, &signature);
_gnutls_gcert_deinit (&peer_cert);
mhd_gtls_gcert_deinit (&peer_cert);
if (ret < 0)
{
gnutls_assert ();
@@ -240,17 +240,17 @@ proc_dhe_server_kx (gnutls_session_t session, opaque * data,
static int
proc_dhe_client_kx (gnutls_session_t session, opaque * data,
proc_dhe_client_kx (mhd_gtls_session_t session, opaque * data,
size_t _data_size)
{
gnutls_certificate_credentials_t cred;
mhd_gtls_cert_credentials_t cred;
int ret;
mpi_t p, g;
const mpi_t *mpis;
gnutls_dh_params_t dh_params;
mhd_gtls_dh_params_t dh_params;
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
cred = (mhd_gtls_cert_credentials_t)
mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
@@ -258,8 +258,8 @@ proc_dhe_client_kx (gnutls_session_t session, opaque * data,
}
dh_params =
_gnutls_get_dh_params (cred->dh_params, cred->params_func, session);
mpis = _gnutls_dh_params_to_mpi (dh_params);
mhd_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
mpis = mhd_gtls_dh_params_to_mpi (dh_params);
if (mpis == NULL)
{
gnutls_assert ();
@@ -269,7 +269,7 @@ proc_dhe_client_kx (gnutls_session_t session, opaque * data,
p = mpis[0];
g = mpis[1];
ret = _gnutls_proc_dh_common_client_kx (session, data, _data_size, g, p);
ret = mhd_gtls_proc_dh_common_client_kx (session, data, _data_size, g, p);
return ret;
+35 -35
View File
@@ -42,30 +42,30 @@
#include <gnutls_x509.h>
#include <gc.h>
int _gnutls_gen_rsa_client_kx (gnutls_session_t, opaque **);
int _gnutls_proc_rsa_client_kx (gnutls_session_t, opaque *, size_t);
int _gnutls_gen_rsa_client_kx (mhd_gtls_session_t, opaque **);
int _gnutls_proc_rsa_client_kx (mhd_gtls_session_t, opaque *, size_t);
const mod_auth_st rsa_auth_struct = {
const mhd_gtls_mod_auth_st rsa_auth_struct = {
"RSA",
_gnutls_gen_cert_server_certificate,
_gnutls_gen_cert_client_certificate,
mhd_gtls_gen_cert_server_certificate,
mhd_gtls_gen_cert_client_certificate,
NULL, /* gen server kx */
_gnutls_gen_rsa_client_kx,
_gnutls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */
_gnutls_gen_cert_server_cert_req, /* server cert request */
mhd_gtls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */
mhd_gtls_gen_cert_server_cert_req, /* server cert request */
_gnutls_proc_cert_server_certificate,
mhd_gtls_proc_cert_server_certificate,
_gnutls_proc_cert_client_certificate,
NULL, /* proc server kx */
_gnutls_proc_rsa_client_kx, /* proc client kx */
_gnutls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */
_gnutls_proc_cert_cert_req /* proc server cert request */
mhd_gtls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */
mhd_gtls_proc_cert_cert_req /* proc server cert request */
};
/* This function reads the RSA parameters from peer's certificate;
*/
int
_gnutls_get_public_rsa_params (gnutls_session_t session,
_gnutls_get_public_rsa_params (mhd_gtls_session_t session,
mpi_t params[MAX_PUBLIC_PARAMS_SIZE],
int *params_len)
{
@@ -76,7 +76,7 @@ _gnutls_get_public_rsa_params (gnutls_session_t session,
/* normal non export case */
info = _gnutls_get_auth_info (session);
info = mhd_gtls_get_auth_info (session);
if (info == NULL || info->ncerts == 0)
{
@@ -85,7 +85,7 @@ _gnutls_get_public_rsa_params (gnutls_session_t session,
}
ret =
_gnutls_raw_cert_to_gcert (&peer_cert,
mhd_gtls_raw_cert_to_gcert (&peer_cert,
session->security_parameters.cert_type,
&info->raw_certificate_list[0],
CERT_ONLY_PUBKEY | CERT_NO_COPY);
@@ -98,13 +98,13 @@ _gnutls_get_public_rsa_params (gnutls_session_t session,
/* EXPORT case: */
if (_gnutls_cipher_suite_get_kx_algo
if (mhd_gtls_cipher_suite_get_kx_algo
(&session->security_parameters.current_cipher_suite)
== MHD_GNUTLS_KX_RSA_EXPORT
&& _gnutls_mpi_get_nbits (peer_cert.params[0]) > 512)
{
_gnutls_gcert_deinit (&peer_cert);
mhd_gtls_gcert_deinit (&peer_cert);
if (session->key->rsa[0] == NULL || session->key->rsa[1] == NULL)
{
@@ -139,7 +139,7 @@ _gnutls_get_public_rsa_params (gnutls_session_t session,
{
params[i] = _gnutls_mpi_copy (peer_cert.params[i]);
}
_gnutls_gcert_deinit (&peer_cert);
mhd_gtls_gcert_deinit (&peer_cert);
return 0;
}
@@ -147,15 +147,15 @@ _gnutls_get_public_rsa_params (gnutls_session_t session,
/* This function reads the RSA parameters from the private key
*/
int
_gnutls_get_private_rsa_params (gnutls_session_t session,
_gnutls_get_private_rsa_params (mhd_gtls_session_t session,
mpi_t ** params, int *params_size)
{
int bits;
gnutls_certificate_credentials_t cred;
gnutls_rsa_params_t rsa_params;
mhd_gtls_cert_credentials_t cred;
mhd_gtls_rsa_params_t rsa_params;
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
cred = (mhd_gtls_cert_credentials_t)
mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
@@ -172,13 +172,13 @@ _gnutls_get_private_rsa_params (gnutls_session_t session,
_gnutls_mpi_get_nbits (session->internals.selected_cert_list[0].
params[0]);
if (_gnutls_cipher_suite_get_kx_algo
if (mhd_gtls_cipher_suite_get_kx_algo
(&session->security_parameters.current_cipher_suite)
== MHD_GNUTLS_KX_RSA_EXPORT && bits > 512)
{
rsa_params =
_gnutls_certificate_get_rsa_params (cred->rsa_params,
mhd_gtls_certificate_get_rsa_params (cred->rsa_params,
cred->params_func, session);
/* EXPORT case: */
if (rsa_params == NULL)
@@ -206,7 +206,7 @@ _gnutls_get_private_rsa_params (gnutls_session_t session,
}
int
_gnutls_proc_rsa_client_kx (gnutls_session_t session, opaque * data,
_gnutls_proc_rsa_client_kx (mhd_gtls_session_t session, opaque * data,
size_t _data_size)
{
gnutls_datum_t plaintext;
@@ -217,7 +217,7 @@ _gnutls_proc_rsa_client_kx (gnutls_session_t session, opaque * data,
int randomize_key = 0;
ssize_t data_size = _data_size;
if (gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
{
/* SSL 3.0
*/
@@ -230,7 +230,7 @@ _gnutls_proc_rsa_client_kx (gnutls_session_t session, opaque * data,
*/
DECR_LEN (data_size, 2);
ciphertext.data = &data[2];
dsize = _gnutls_read_uint16 (data);
dsize = mhd_gtls_read_uint16 (data);
if (dsize != data_size)
{
@@ -247,7 +247,7 @@ _gnutls_proc_rsa_client_kx (gnutls_session_t session, opaque * data,
return ret;
}
ret = _gnutls_pkcs1_rsa_decrypt (&plaintext, &ciphertext, params, params_len, 2); /* btype==2 */
ret = mhd_gtls_pkcs1_rsa_decrypt (&plaintext, &ciphertext, params, params_len, 2); /* btype==2 */
if (ret < 0 || plaintext.size != TLS_MASTER_SIZE)
{
@@ -318,7 +318,7 @@ _gnutls_proc_rsa_client_kx (gnutls_session_t session, opaque * data,
/* return RSA(random) using the peers public key
*/
int
_gnutls_gen_rsa_client_kx (gnutls_session_t session, opaque ** data)
_gnutls_gen_rsa_client_kx (mhd_gtls_session_t session, opaque ** data)
{
cert_auth_info_t auth = session->key->auth_info;
gnutls_datum_t sdata; /* data to send */
@@ -352,12 +352,12 @@ _gnutls_gen_rsa_client_kx (gnutls_session_t session, opaque ** data)
return GNUTLS_E_RANDOM_FAILED;
}
ver = _gnutls_get_adv_version (session);
ver = mhd_gtls_get_adv_version (session);
if (session->internals.rsa_pms_version[0] == 0)
{
session->key->key.data[0] = _gnutls_version_get_major (ver);
session->key->key.data[1] = _gnutls_version_get_minor (ver);
session->key->key.data[0] = mhd_gtls_version_get_major (ver);
session->key->key.data[1] = mhd_gtls_version_get_minor (ver);
}
else
{ /* use the version provided */
@@ -375,7 +375,7 @@ _gnutls_gen_rsa_client_kx (gnutls_session_t session, opaque ** data)
}
if ((ret =
_gnutls_pkcs1_rsa_encrypt (&sdata, &session->key->key,
mhd_gtls_pkcs1_rsa_encrypt (&sdata, &session->key->key,
params, params_len, 2)) < 0)
{
gnutls_assert ();
@@ -383,9 +383,9 @@ _gnutls_gen_rsa_client_kx (gnutls_session_t session, opaque ** data)
}
for (i = 0; i < params_len; i++)
_gnutls_mpi_release (&params[i]);
mhd_gtls_mpi_release (&params[i]);
if (gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
{
/* SSL 3.0 */
*data = sdata.data;
@@ -399,7 +399,7 @@ _gnutls_gen_rsa_client_kx (gnutls_session_t session, opaque ** data)
_gnutls_free_datum (&sdata);
return GNUTLS_E_MEMORY_ERROR;
}
_gnutls_write_datum16 (*data, sdata);
mhd_gtls_write_datum16 (*data, sdata);
ret = sdata.size + 2;
_gnutls_free_datum (&sdata);
return ret;
+48 -48
View File
@@ -43,32 +43,32 @@
#include <gnutls_rsa_export.h>
#include <gnutls_state.h>
int _gnutls_gen_rsa_client_kx (gnutls_session_t, opaque **);
int _gnutls_proc_rsa_client_kx (gnutls_session_t, opaque *, size_t);
static int gen_rsa_export_server_kx (gnutls_session_t, opaque **);
static int proc_rsa_export_server_kx (gnutls_session_t, opaque *, size_t);
int _gnutls_gen_rsa_client_kx (mhd_gtls_session_t, opaque **);
int _gnutls_proc_rsa_client_kx (mhd_gtls_session_t, opaque *, size_t);
static int gen_rsa_export_server_kx (mhd_gtls_session_t, opaque **);
static int proc_rsa_export_server_kx (mhd_gtls_session_t, opaque *, size_t);
const mod_auth_st rsa_export_auth_struct = {
const mhd_gtls_mod_auth_st rsa_export_auth_struct = {
"RSA EXPORT",
_gnutls_gen_cert_server_certificate,
_gnutls_gen_cert_client_certificate,
mhd_gtls_gen_cert_server_certificate,
mhd_gtls_gen_cert_client_certificate,
gen_rsa_export_server_kx,
_gnutls_gen_rsa_client_kx,
_gnutls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */
_gnutls_gen_cert_server_cert_req, /* server cert request */
mhd_gtls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */
mhd_gtls_gen_cert_server_cert_req, /* server cert request */
_gnutls_proc_cert_server_certificate,
mhd_gtls_proc_cert_server_certificate,
_gnutls_proc_cert_client_certificate,
proc_rsa_export_server_kx,
_gnutls_proc_rsa_client_kx, /* proc client kx */
_gnutls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */
_gnutls_proc_cert_cert_req /* proc server cert request */
mhd_gtls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */
mhd_gtls_proc_cert_cert_req /* proc server cert request */
};
static int
gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
gen_rsa_export_server_kx (mhd_gtls_session_t session, opaque ** data)
{
gnutls_rsa_params_t rsa_params;
mhd_gtls_rsa_params_t rsa_params;
const mpi_t *rsa_mpis;
size_t n_e, n_m;
uint8_t *data_e, *data_m;
@@ -78,10 +78,10 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
int apr_cert_list_length;
gnutls_datum_t signature, ddata;
cert_auth_info_t info;
gnutls_certificate_credentials_t cred;
mhd_gtls_cert_credentials_t cred;
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
cred = (mhd_gtls_cert_credentials_t)
mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
@@ -90,7 +90,7 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
/* find the appropriate certificate */
if ((ret =
_gnutls_get_selected_cert (session, &apr_cert_list,
mhd_gtls_get_selected_cert (session, &apr_cert_list,
&apr_cert_list_length, &apr_pkey)) < 0)
{
gnutls_assert ();
@@ -107,7 +107,7 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
}
rsa_params =
_gnutls_certificate_get_rsa_params (cred->rsa_params, cred->params_func,
mhd_gtls_certificate_get_rsa_params (cred->rsa_params, cred->params_func,
session);
rsa_mpis = _gnutls_rsa_params_to_mpi (rsa_params);
if (rsa_mpis == NULL)
@@ -116,18 +116,18 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
return GNUTLS_E_NO_TEMPORARY_RSA_PARAMS;
}
if ((ret = _gnutls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
if ((ret = mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
sizeof (cert_auth_info_st), 0)) < 0)
{
gnutls_assert ();
return ret;
}
info = _gnutls_get_auth_info (session);
_gnutls_rsa_export_set_pubkey (session, rsa_mpis[1], rsa_mpis[0]);
info = mhd_gtls_get_auth_info (session);
mhd_gtls_rsa_export_set_pubkey (session, rsa_mpis[1], rsa_mpis[0]);
_gnutls_mpi_print (NULL, &n_m, rsa_mpis[0]);
_gnutls_mpi_print (NULL, &n_e, rsa_mpis[1]);
mhd_gtls_mpi_print (NULL, &n_m, rsa_mpis[0]);
mhd_gtls_mpi_print (NULL, &n_e, rsa_mpis[1]);
(*data) = gnutls_malloc (n_e + n_m + 4);
if (*data == NULL)
@@ -136,14 +136,14 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
}
data_m = &(*data)[0];
_gnutls_mpi_print (&data_m[2], &n_m, rsa_mpis[0]);
mhd_gtls_mpi_print (&data_m[2], &n_m, rsa_mpis[0]);
_gnutls_write_uint16 (n_m, data_m);
mhd_gtls_write_uint16 (n_m, data_m);
data_e = &data_m[2 + n_m];
_gnutls_mpi_print (&data_e[2], &n_e, rsa_mpis[1]);
mhd_gtls_mpi_print (&data_e[2], &n_e, rsa_mpis[1]);
_gnutls_write_uint16 (n_e, data_e);
mhd_gtls_write_uint16 (n_e, data_e);
data_size = n_m + n_e + 4;
@@ -156,7 +156,7 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
if (apr_cert_list_length > 0)
{
if ((ret =
_gnutls_tls_sign_params (session, &apr_cert_list[0],
mhd_gtls_tls_sign_params (session, &apr_cert_list[0],
apr_pkey, &ddata, &signature)) < 0)
{
gnutls_assert ();
@@ -171,7 +171,7 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
return data_size; /* do not put a signature - ILLEGAL! */
}
*data = gnutls_realloc_fast (*data, data_size + signature.size + 2);
*data = mhd_gtls_realloc_fast (*data, data_size + signature.size + 2);
if (*data == NULL)
{
_gnutls_free_datum (&signature);
@@ -179,7 +179,7 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
return GNUTLS_E_MEMORY_ERROR;
}
_gnutls_write_datum16 (&((*data)[data_size]), signature);
mhd_gtls_write_datum16 (&((*data)[data_size]), signature);
data_size += signature.size + 2;
_gnutls_free_datum (&signature);
@@ -190,11 +190,11 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
/* if the peer's certificate is of 512 bits or less, returns non zero.
*/
int
_gnutls_peers_cert_less_512 (gnutls_session_t session)
_gnutls_peers_cert_less_512 (mhd_gtls_session_t session)
{
gnutls_cert peer_cert;
int ret;
cert_auth_info_t info = _gnutls_get_auth_info (session);
cert_auth_info_t info = mhd_gtls_get_auth_info (session);
if (info == NULL || info->ncerts == 0)
{
@@ -204,7 +204,7 @@ _gnutls_peers_cert_less_512 (gnutls_session_t session)
}
if ((ret =
_gnutls_raw_cert_to_gcert (&peer_cert,
mhd_gtls_raw_cert_to_gcert (&peer_cert,
session->security_parameters.cert_type,
&info->raw_certificate_list[0],
CERT_NO_COPY)) < 0)
@@ -216,23 +216,23 @@ _gnutls_peers_cert_less_512 (gnutls_session_t session)
if (peer_cert.subject_pk_algorithm != MHD_GNUTLS_PK_RSA)
{
gnutls_assert ();
_gnutls_gcert_deinit (&peer_cert);
mhd_gtls_gcert_deinit (&peer_cert);
return 0;
}
if (_gnutls_mpi_get_nbits (peer_cert.params[0]) <= 512)
{
_gnutls_gcert_deinit (&peer_cert);
mhd_gtls_gcert_deinit (&peer_cert);
return 1;
}
_gnutls_gcert_deinit (&peer_cert);
mhd_gtls_gcert_deinit (&peer_cert);
return 0;
}
static int
proc_rsa_export_server_kx (gnutls_session_t session,
proc_rsa_export_server_kx (mhd_gtls_session_t session,
opaque * data, size_t _data_size)
{
uint16_t n_m, n_e;
@@ -246,7 +246,7 @@ proc_rsa_export_server_kx (gnutls_session_t session,
cert_auth_info_t info;
gnutls_cert peer_cert;
info = _gnutls_get_auth_info (session);
info = mhd_gtls_get_auth_info (session);
if (info == NULL || info->ncerts == 0)
{
gnutls_assert ();
@@ -258,7 +258,7 @@ proc_rsa_export_server_kx (gnutls_session_t session,
i = 0;
DECR_LEN (data_size, 2);
n_m = _gnutls_read_uint16 (&data[i]);
n_m = mhd_gtls_read_uint16 (&data[i]);
i += 2;
DECR_LEN (data_size, n_m);
@@ -266,7 +266,7 @@ proc_rsa_export_server_kx (gnutls_session_t session,
i += n_m;
DECR_LEN (data_size, 2);
n_e = _gnutls_read_uint16 (&data[i]);
n_e = mhd_gtls_read_uint16 (&data[i]);
i += 2;
DECR_LEN (data_size, n_e);
@@ -276,19 +276,19 @@ proc_rsa_export_server_kx (gnutls_session_t session,
_n_e = n_e;
_n_m = n_m;
if (_gnutls_mpi_scan_nz (&session->key->rsa[0], data_m, &_n_m) != 0)
if (mhd_gtls_mpi_scan_nz (&session->key->rsa[0], data_m, &_n_m) != 0)
{
gnutls_assert ();
return GNUTLS_E_MPI_SCAN_FAILED;
}
if (_gnutls_mpi_scan_nz (&session->key->rsa[1], data_e, &_n_e) != 0)
if (mhd_gtls_mpi_scan_nz (&session->key->rsa[1], data_e, &_n_e) != 0)
{
gnutls_assert ();
return GNUTLS_E_MPI_SCAN_FAILED;
}
_gnutls_rsa_export_set_pubkey (session, session->key->rsa[1],
mhd_gtls_rsa_export_set_pubkey (session, session->key->rsa[1],
session->key->rsa[0]);
/* VERIFY SIGNATURE */
@@ -297,14 +297,14 @@ proc_rsa_export_server_kx (gnutls_session_t session,
vparams.data = data;
DECR_LEN (data_size, 2);
sigsize = _gnutls_read_uint16 (&data[vparams.size]);
sigsize = mhd_gtls_read_uint16 (&data[vparams.size]);
DECR_LEN (data_size, sigsize);
signature.data = &data[vparams.size + 2];
signature.size = sigsize;
if ((ret =
_gnutls_raw_cert_to_gcert (&peer_cert,
mhd_gtls_raw_cert_to_gcert (&peer_cert,
session->security_parameters.cert_type,
&info->raw_certificate_list[0],
CERT_NO_COPY)) < 0)
@@ -313,9 +313,9 @@ proc_rsa_export_server_kx (gnutls_session_t session,
return ret;
}
ret = _gnutls_verify_sig_params (session, &peer_cert, &vparams, &signature);
ret = mhd_gtls_verify_sig_params (session, &peer_cert, &vparams, &signature);
_gnutls_gcert_deinit (&peer_cert);
mhd_gtls_gcert_deinit (&peer_cert);
if (ret < 0)
{
gnutls_assert ();
+1 -1
View File
@@ -32,7 +32,7 @@
void
_gnutls_print_state (gnutls_session_t session)
_gnutls_print_state (mhd_gtls_session_t session)
{
_gnutls_debug_log ("GNUTLS State:\n");
+1 -1
View File
@@ -23,7 +23,7 @@
*/
#ifdef DEBUG
void _gnutls_print_state (gnutls_session_t session);
void _gnutls_print_state (mhd_gtls_session_t session);
#endif
const char *_gnutls_packet2str (content_type_t packet);
const char *_gnutls_handshake2str (gnutls_handshake_description_t handshake);
+5 -5
View File
@@ -46,7 +46,7 @@ inline static int _gnutls_cert_type2num (int record_size);
*/
int
_gnutls_cert_type_recv_params (gnutls_session_t session,
mhd_gtls_cert_type_recv_params (mhd_gtls_session_t session,
const opaque * data, size_t _data_size)
{
int new_type = -1, ret, i;
@@ -72,7 +72,7 @@ _gnutls_cert_type_recv_params (gnutls_session_t session,
/* Check if we support this cert_type */
if ((ret =
_gnutls_session_cert_type_supported (session, new_type)) < 0)
mhd_gtls_session_cert_type_supported (session, new_type)) < 0)
{
gnutls_assert ();
return ret;
@@ -100,7 +100,7 @@ _gnutls_cert_type_recv_params (gnutls_session_t session,
/* Check if we support this cert_type */
if ((ret =
_gnutls_session_cert_type_supported (session,
mhd_gtls_session_cert_type_supported (session,
new_type)) < 0)
{
gnutls_assert ();
@@ -118,7 +118,7 @@ _gnutls_cert_type_recv_params (gnutls_session_t session,
}
if ((ret =
_gnutls_session_cert_type_supported (session, new_type)) < 0)
mhd_gtls_session_cert_type_supported (session, new_type)) < 0)
{
gnutls_assert ();
/* The peer has requested unsupported certificate
@@ -141,7 +141,7 @@ _gnutls_cert_type_recv_params (gnutls_session_t session,
/* returns data_size or a negative number on failure
*/
int
_gnutls_cert_type_send_params (gnutls_session_t session, opaque * data,
mhd_gtls_cert_type_send_params (mhd_gtls_session_t session, opaque * data,
size_t data_size)
{
unsigned len, i;
+2 -2
View File
@@ -25,7 +25,7 @@
/* Maps record size to numbers according to the
* extensions draft.
*/
int _gnutls_cert_type_recv_params (gnutls_session_t session,
int mhd_gtls_cert_type_recv_params (mhd_gtls_session_t session,
const opaque * data, size_t data_size);
int _gnutls_cert_type_send_params (gnutls_session_t session, opaque * data,
int mhd_gtls_cert_type_send_params (mhd_gtls_session_t session, opaque * data,
size_t);
+6 -6
View File
@@ -32,10 +32,10 @@
#define YES 1
int
_gnutls_inner_application_recv_params (gnutls_session_t session,
mhd_gtls_inner_app_rcv_params (mhd_gtls_session_t session,
const opaque * data, size_t data_size)
{
tls_ext_st *ext = &session->security_parameters.extensions;
mhd_gtls_ext_st *ext = &session->security_parameters.extensions;
if (data_size != 1)
{
@@ -66,10 +66,10 @@ _gnutls_inner_application_recv_params (gnutls_session_t session,
/* returns data_size or a negative number on failure
*/
int
_gnutls_inner_application_send_params (gnutls_session_t session,
mhd_gtls_inner_app_send_params (mhd_gtls_session_t session,
opaque * data, size_t data_size)
{
tls_ext_st *ext = &session->security_parameters.extensions;
mhd_gtls_ext_st *ext = &session->security_parameters.extensions;
/* Set ext->gnutls_ia_enable depending on whether we have a TLS/IA
credential in the session. */
@@ -77,7 +77,7 @@ _gnutls_inner_application_send_params (gnutls_session_t session,
if (session->security_parameters.entity == GNUTLS_CLIENT)
{
gnutls_ia_client_credentials_t cred = (gnutls_ia_client_credentials_t)
_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_IA, NULL);
mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_IA, NULL);
if (cred)
ext->gnutls_ia_enable = 1;
@@ -85,7 +85,7 @@ _gnutls_inner_application_send_params (gnutls_session_t session,
else
{
gnutls_ia_server_credentials_t cred = (gnutls_ia_server_credentials_t)
_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_IA, NULL);
mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_IA, NULL);
if (cred)
ext->gnutls_ia_enable = 1;
+2 -2
View File
@@ -22,8 +22,8 @@
*
*/
int _gnutls_inner_application_recv_params (gnutls_session_t session,
int mhd_gtls_inner_app_rcv_params (mhd_gtls_session_t session,
const opaque * data,
size_t data_size);
int _gnutls_inner_application_send_params (gnutls_session_t session,
int mhd_gtls_inner_app_send_params (mhd_gtls_session_t session,
opaque * data, size_t);
+8 -8
View File
@@ -41,7 +41,7 @@
*/
int
_gnutls_max_record_recv_params (gnutls_session_t session,
mhd_gtls_max_record_recv_params (mhd_gtls_session_t session,
const opaque * data, size_t _data_size)
{
ssize_t new_size;
@@ -53,7 +53,7 @@ _gnutls_max_record_recv_params (gnutls_session_t session,
{
DECR_LEN (data_size, 1);
new_size = _gnutls_mre_num2record (data[0]);
new_size = mhd_gtls_mre_num2record (data[0]);
if (new_size < 0)
{
@@ -77,7 +77,7 @@ _gnutls_max_record_recv_params (gnutls_session_t session,
return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
}
new_size = _gnutls_mre_num2record (data[0]);
new_size = mhd_gtls_mre_num2record (data[0]);
if (new_size < 0
|| new_size != session->internals.proposed_record_size)
@@ -102,7 +102,7 @@ _gnutls_max_record_recv_params (gnutls_session_t session,
/* returns data_size or a negative number on failure
*/
int
_gnutls_max_record_send_params (gnutls_session_t session, opaque * data,
mhd_gtls_max_record_send_params (mhd_gtls_session_t session, opaque * data,
size_t data_size)
{
uint16_t len;
@@ -120,7 +120,7 @@ _gnutls_max_record_send_params (gnutls_session_t session, opaque * data,
}
data[0] =
(uint8_t) _gnutls_mre_record2num (session->internals.
(uint8_t) mhd_gtls_mre_record2num (session->internals.
proposed_record_size);
return len;
}
@@ -140,7 +140,7 @@ _gnutls_max_record_send_params (gnutls_session_t session, opaque * data,
}
data[0] =
(uint8_t) _gnutls_mre_record2num (session->
(uint8_t) mhd_gtls_mre_record2num (session->
security_parameters.
max_record_recv_size);
return len;
@@ -156,7 +156,7 @@ _gnutls_max_record_send_params (gnutls_session_t session, opaque * data,
* extensions draft.
*/
int
_gnutls_mre_num2record (int num)
mhd_gtls_mre_num2record (int num)
{
switch (num)
{
@@ -177,7 +177,7 @@ _gnutls_mre_num2record (int num)
* extensions draft.
*/
int
_gnutls_mre_record2num (uint16_t record_size)
mhd_gtls_mre_record2num (uint16_t record_size)
{
switch (record_size)
{
+4 -4
View File
@@ -25,9 +25,9 @@
/* Maps record size to numbers according to the
* extensions draft.
*/
int _gnutls_mre_num2record (int num);
int _gnutls_mre_record2num (uint16_t record_size);
int _gnutls_max_record_recv_params (gnutls_session_t session,
int mhd_gtls_mre_num2record (int num);
int mhd_gtls_mre_record2num (uint16_t record_size);
int mhd_gtls_max_record_recv_params (mhd_gtls_session_t session,
const opaque * data, size_t data_size);
int _gnutls_max_record_send_params (gnutls_session_t session, opaque * data,
int mhd_gtls_max_record_send_params (mhd_gtls_session_t session, opaque * data,
size_t);
+17 -17
View File
@@ -33,7 +33,7 @@
#include <gnutls_num.h>
int
oprfi_recv_server (gnutls_session_t session,
oprfi_recv_server (mhd_gtls_session_t session,
const opaque * data, size_t _data_size)
{
ssize_t data_size = _data_size;
@@ -46,7 +46,7 @@ oprfi_recv_server (gnutls_session_t session,
}
DECR_LEN (data_size, 2);
len = _gnutls_read_uint16 (data);
len = mhd_gtls_read_uint16 (data);
data += 2;
if (len != data_size)
@@ -69,7 +69,7 @@ oprfi_recv_server (gnutls_session_t session,
}
int
oprfi_recv_client (gnutls_session_t session,
oprfi_recv_client (mhd_gtls_session_t session,
const opaque * data, size_t _data_size)
{
ssize_t data_size = _data_size;
@@ -82,7 +82,7 @@ oprfi_recv_client (gnutls_session_t session,
}
DECR_LEN (data_size, 2);
len = _gnutls_read_uint16 (data);
len = mhd_gtls_read_uint16 (data);
data += 2;
if (len != data_size)
@@ -111,7 +111,7 @@ oprfi_recv_client (gnutls_session_t session,
}
int
_gnutls_oprfi_recv_params (gnutls_session_t session,
mhd_gtls_oprfi_recv_params (mhd_gtls_session_t session,
const opaque * data, size_t data_size)
{
if (session->security_parameters.entity == GNUTLS_CLIENT)
@@ -121,7 +121,7 @@ _gnutls_oprfi_recv_params (gnutls_session_t session,
}
int
oprfi_send_client (gnutls_session_t session, opaque * data, size_t _data_size)
oprfi_send_client (mhd_gtls_session_t session, opaque * data, size_t _data_size)
{
opaque *p = data;
ssize_t data_size = _data_size;
@@ -131,7 +131,7 @@ oprfi_send_client (gnutls_session_t session, opaque * data, size_t _data_size)
return 0;
DECR_LENGTH_RET (data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER);
_gnutls_write_uint16 (oprf_size, p);
mhd_gtls_write_uint16 (oprf_size, p);
p += 2;
DECR_LENGTH_RET (data_size, oprf_size, GNUTLS_E_SHORT_MEMORY_BUFFER);
@@ -142,7 +142,7 @@ oprfi_send_client (gnutls_session_t session, opaque * data, size_t _data_size)
}
int
oprfi_send_server (gnutls_session_t session, opaque * data, size_t _data_size)
oprfi_send_server (mhd_gtls_session_t session, opaque * data, size_t _data_size)
{
opaque *p = data;
int ret;
@@ -177,7 +177,7 @@ oprfi_send_server (gnutls_session_t session, opaque * data, size_t _data_size)
}
DECR_LENGTH_RET (data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER);
_gnutls_write_uint16 (session->security_parameters.
mhd_gtls_write_uint16 (session->security_parameters.
extensions.oprfi_server_len, p);
p += 2;
@@ -191,7 +191,7 @@ oprfi_send_server (gnutls_session_t session, opaque * data, size_t _data_size)
}
int
_gnutls_oprfi_send_params (gnutls_session_t session,
mhd_gtls_oprfi_send_params (mhd_gtls_session_t session,
opaque * data, size_t data_size)
{
if (session->security_parameters.entity == GNUTLS_CLIENT)
@@ -201,8 +201,8 @@ _gnutls_oprfi_send_params (gnutls_session_t session,
}
/**
* gnutls_oprfi_enable_client:
* @session: is a #gnutls_session_t structure.
* MHD_gtls_oprfi_enable_client:
* @session: is a #mhd_gtls_session_t structure.
* @len: length of Opaque PRF data to use in client.
* @data: Opaque PRF data to use in client.
*
@@ -214,7 +214,7 @@ _gnutls_oprfi_send_params (gnutls_session_t session,
* may de-allocate it immediately after calling this function.
**/
void
gnutls_oprfi_enable_client (gnutls_session_t session,
MHD_gtls_oprfi_enable_client (mhd_gtls_session_t session,
size_t len, unsigned char *data)
{
session->security_parameters.extensions.oprfi_client_len = len;
@@ -222,8 +222,8 @@ gnutls_oprfi_enable_client (gnutls_session_t session,
}
/**
* gnutls_oprfi_enable_server:
* @session: is a #gnutls_session_t structure.
* MHD_gtls_oprfi_enable_server:
* @session: is a #mhd_gtls_session_t structure.
* @cb: function pointer to Opaque PRF extension server callback.
* @userdata: hook passed to callback function for passing application state.
*
@@ -232,7 +232,7 @@ gnutls_oprfi_enable_client (gnutls_session_t session,
* provided callback @cb will be invoked. The callback must have the
* following prototype:
*
* int callback (gnutls_session_t session, void *userdata,
* int callback (mhd_gtls_session_t session, void *userdata,
* size_t oprfi_len, const unsigned char *in_oprfi,
* unsigned char *out_oprfi);
*
@@ -242,7 +242,7 @@ gnutls_oprfi_enable_client (gnutls_session_t session,
* handshake will be aborted.
**/
void
gnutls_oprfi_enable_server (gnutls_session_t session,
MHD_gtls_oprfi_enable_server (mhd_gtls_session_t session,
gnutls_oprfi_callback_func cb, void *userdata)
{
session->security_parameters.extensions.oprfi_cb = cb;
+2 -2
View File
@@ -24,10 +24,10 @@
#include <gnutls_int.h>
int _gnutls_oprfi_recv_params (gnutls_session_t state,
int mhd_gtls_oprfi_recv_params (mhd_gtls_session_t state,
const opaque * data,
size_t data_size);
int _gnutls_oprfi_send_params (gnutls_session_t state,
int mhd_gtls_oprfi_send_params (mhd_gtls_session_t state,
opaque * data,
size_t data_size);
+13 -13
View File
@@ -39,7 +39,7 @@
*/
int
_gnutls_server_name_recv_params (gnutls_session_t session,
mhd_gtls_server_name_recv_params (mhd_gtls_session_t session,
const opaque * data, size_t _data_size)
{
int i;
@@ -51,7 +51,7 @@ _gnutls_server_name_recv_params (gnutls_session_t session,
if (session->security_parameters.entity == GNUTLS_SERVER)
{
DECR_LENGTH_RET (data_size, 2, 0);
len = _gnutls_read_uint16 (data);
len = mhd_gtls_read_uint16 (data);
if (len != data_size)
{
@@ -71,7 +71,7 @@ _gnutls_server_name_recv_params (gnutls_session_t session,
p++;
DECR_LEN (data_size, 2);
len = _gnutls_read_uint16 (p);
len = mhd_gtls_read_uint16 (p);
p += 2;
DECR_LENGTH_RET (data_size, len, 0);
@@ -96,7 +96,7 @@ _gnutls_server_name_recv_params (gnutls_session_t session,
type = *p;
p++;
len = _gnutls_read_uint16 (p);
len = mhd_gtls_read_uint16 (p);
p += 2;
switch (type)
@@ -124,7 +124,7 @@ _gnutls_server_name_recv_params (gnutls_session_t session,
/* returns data_size or a negative number on failure
*/
int
_gnutls_server_name_send_params (gnutls_session_t session,
mhd_gtls_server_name_send_params (mhd_gtls_session_t session,
opaque * data, size_t _data_size)
{
uint16_t len;
@@ -163,7 +163,7 @@ _gnutls_server_name_send_params (gnutls_session_t session,
/* UINT16: write total size of all names
*/
DECR_LENGTH_RET (data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER);
_gnutls_write_uint16 (total_size - 2, p);
mhd_gtls_write_uint16 (total_size - 2, p);
p += 2;
for (i = 0;
@@ -191,7 +191,7 @@ _gnutls_server_name_send_params (gnutls_session_t session,
*p = 0; /* NAME_DNS type */
p++;
_gnutls_write_uint16 (len, p);
mhd_gtls_write_uint16 (len, p);
p += 2;
memcpy (p,
@@ -210,8 +210,8 @@ _gnutls_server_name_send_params (gnutls_session_t session,
}
/**
* gnutls_server_name_get - Used to get the server name indicator send by a client
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_server_name_get - Used to get the server name indicator send by a client
* @session: is a #mhd_gtls_session_t structure.
* @data: will hold the data
* @data_length: will hold the data length. Must hold the maximum size of data.
* @type: will hold the server name indicator type
@@ -233,7 +233,7 @@ _gnutls_server_name_send_params (gnutls_session_t session,
*
**/
int
gnutls_server_name_get (gnutls_session_t session, void *data,
MHD_gnutls_server_name_get (mhd_gtls_session_t session, void *data,
size_t * data_length,
unsigned int *type, unsigned int indx)
{
@@ -278,8 +278,8 @@ gnutls_server_name_get (gnutls_session_t session, void *data,
}
/**
* gnutls_server_name_set - Used to set a name indicator to be sent as an extension
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_server_name_set - Used to set a name indicator to be sent as an extension
* @session: is a #mhd_gtls_session_t structure.
* @type: specifies the indicator type
* @name: is a string that contains the server name.
* @name_length: holds the length of name
@@ -295,7 +295,7 @@ gnutls_server_name_get (gnutls_session_t session, void *data,
*
**/
int
gnutls_server_name_set (gnutls_session_t session,
MHD_gnutls_server_name_set (mhd_gtls_session_t session,
gnutls_server_name_type_t type,
const void *name, size_t name_length)
{
+2 -2
View File
@@ -22,7 +22,7 @@
*
*/
int _gnutls_server_name_recv_params (gnutls_session_t session,
int mhd_gtls_server_name_recv_params (mhd_gtls_session_t session,
const opaque * data, size_t data_size);
int _gnutls_server_name_send_params (gnutls_session_t session,
int mhd_gtls_server_name_send_params (mhd_gtls_session_t session,
opaque * data, size_t);
+18 -18
View File
@@ -80,15 +80,15 @@ static const gnutls_alert_entry sup_alerts[] = {
/**
* gnutls_alert_get_name - Returns a string describing the alert number given
* @alert: is an alert number #gnutls_session_t structure.
* MHD_gnutls_alert_get_name - Returns a string describing the alert number given
* @alert: is an alert number #mhd_gtls_session_t structure.
*
* This function will return a string that describes the given alert
* number or NULL. See gnutls_alert_get().
*
**/
const char *
gnutls_alert_get_name (gnutls_alert_description_t alert)
MHD_gnutls_alert_get_name (gnutls_alert_description_t alert)
{
const char *ret = NULL;
@@ -98,8 +98,8 @@ gnutls_alert_get_name (gnutls_alert_description_t alert)
}
/**
* gnutls_alert_send - This function sends an alert message to the peer
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_alert_send - This function sends an alert message to the peer
* @session: is a #mhd_gtls_session_t structure.
* @level: is the level of the alert
* @desc: is the alert description
*
@@ -115,7 +115,7 @@ gnutls_alert_get_name (gnutls_alert_description_t alert)
*
**/
int
gnutls_alert_send (gnutls_session_t session, gnutls_alert_level_t level,
MHD_gnutls_alert_send (mhd_gtls_session_t session, gnutls_alert_level_t level,
gnutls_alert_description_t desc)
{
uint8_t data[2];
@@ -125,20 +125,20 @@ gnutls_alert_send (gnutls_session_t session, gnutls_alert_level_t level,
data[0] = (uint8_t) level;
data[1] = (uint8_t) desc;
name = gnutls_alert_get_name ((int) data[1]);
name = MHD_gnutls_alert_get_name ((int) data[1]);
if (name == NULL)
name = "(unknown)";
_gnutls_record_log ("REC: Sending Alert[%d|%d] - %s\n", data[0],
data[1], name);
if ((ret = _gnutls_send_int (session, GNUTLS_ALERT, -1, data, 2)) >= 0)
if ((ret = mhd_gtls_send_int (session, GNUTLS_ALERT, -1, data, 2)) >= 0)
return 0;
else
return ret;
}
/**
* gnutls_error_to_alert - This function returns an alert code based on the given error code
* MHD_gtls_error_to_alert - This function returns an alert code based on the given error code
* @err: is a negative integer
* @level: the alert level will be stored there
*
@@ -153,7 +153,7 @@ gnutls_alert_send (gnutls_session_t session, gnutls_alert_level_t level,
*
**/
int
gnutls_error_to_alert (int err, int *level)
MHD_gtls_error_to_alert (int err, int *level)
{
int ret, _level = -1;
@@ -254,12 +254,12 @@ gnutls_error_to_alert (int err, int *level)
/**
* gnutls_alert_send_appropriate - This function sends an alert to the peer depending on the error code
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_alert_send_appropriate - This function sends an alert to the peer depending on the error code
* @session: is a #mhd_gtls_session_t structure.
* @err: is an integer
*
* Sends an alert to the peer depending on the error code returned by a gnutls
* function. This function will call gnutls_error_to_alert() to determine
* function. This function will call MHD_gtls_error_to_alert() to determine
* the appropriate alert to send.
*
* This function may also return GNUTLS_E_AGAIN, or GNUTLS_E_INTERRUPTED.
@@ -270,23 +270,23 @@ gnutls_error_to_alert (int err, int *level)
* Returns zero on success.
*/
int
gnutls_alert_send_appropriate (gnutls_session_t session, int err)
MHD_gnutls_alert_send_appropriate (mhd_gtls_session_t session, int err)
{
int alert;
int level;
alert = gnutls_error_to_alert (err, &level);
alert = MHD_gtls_error_to_alert (err, &level);
if (alert < 0)
{
return alert;
}
return gnutls_alert_send (session, level, alert);
return MHD_gnutls_alert_send (session, level, alert);
}
/**
* gnutls_alert_get - Returns the last alert number received.
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
*
* This function will return the last alert number received. This
* function should be called if GNUTLS_E_WARNING_ALERT_RECEIVED or
@@ -298,7 +298,7 @@ gnutls_alert_send_appropriate (gnutls_session_t session, int err)
*
**/
gnutls_alert_description_t
gnutls_alert_get (gnutls_session_t session)
gnutls_alert_get (mhd_gtls_session_t session)
{
return session->internals.last_alert;
}
+133 -246
View File
@@ -381,22 +381,22 @@ static const gnutls_compression_method_t supported_compressions[] = {
GNUTLS_COMPRESSION_LOOP( if(p->num == num) { a; break; } )
/* Key Exchange Section */
extern mod_auth_st rsa_auth_struct;
extern mod_auth_st rsa_export_auth_struct;
extern mod_auth_st dhe_rsa_auth_struct;
extern mod_auth_st dhe_dss_auth_struct;
extern mod_auth_st anon_auth_struct;
extern mod_auth_st srp_auth_struct;
extern mod_auth_st psk_auth_struct;
extern mod_auth_st dhe_psk_auth_struct;
extern mod_auth_st srp_rsa_auth_struct;
extern mod_auth_st srp_dss_auth_struct;
extern mhd_gtls_mod_auth_st rsa_auth_struct;
extern mhd_gtls_mod_auth_st rsa_export_auth_struct;
extern mhd_gtls_mod_auth_st dhe_rsa_auth_struct;
extern mhd_gtls_mod_auth_st dhe_dss_auth_struct;
extern mhd_gtls_mod_auth_st anon_auth_struct;
extern mhd_gtls_mod_auth_st srp_auth_struct;
extern mhd_gtls_mod_auth_st psk_auth_struct;
extern mhd_gtls_mod_auth_st dhe_psk_auth_struct;
extern mhd_gtls_mod_auth_st srp_rsa_auth_struct;
extern mhd_gtls_mod_auth_st srp_dss_auth_struct;
struct gnutls_kx_algo_entry
{
const char *name;
gnutls_kx_algorithm_t algorithm;
mod_auth_st *auth_struct;
mhd_gtls_mod_auth_st *auth_struct;
int needs_dh_params;
int needs_rsa_params;
};
@@ -763,7 +763,7 @@ static const gnutls_cipher_suite_entry cs_algorithms[] = {
/* Generic Functions */
int
_gnutls_mac_priority (gnutls_session_t session,
mhd_gtls_mac_priority (mhd_gtls_session_t session,
gnutls_mac_algorithm_t algorithm)
{ /* actually returns the priority */
unsigned int i;
@@ -776,14 +776,14 @@ _gnutls_mac_priority (gnutls_session_t session,
}
/**
* gnutls_mac_get_name - Returns a string with the name of the specified mac algorithm
* MHD_gnutls_mac_get_name - Returns a string with the name of the specified mac algorithm
* @algorithm: is a MAC algorithm
*
* Returns: a string that contains the name of the specified MAC
* algorithm, or %NULL.
**/
const char *
gnutls_mac_get_name (gnutls_mac_algorithm_t algorithm)
MHD_gnutls_mac_get_name (gnutls_mac_algorithm_t algorithm)
{
const char *ret = NULL;
@@ -794,7 +794,7 @@ gnutls_mac_get_name (gnutls_mac_algorithm_t algorithm)
}
/**
* gnutls_mac_get_id - Returns the gnutls id of the specified in string algorithm
* MHD_gtls_mac_get_id - Returns the gnutls id of the specified in string algorithm
* @algorithm: is a MAC algorithm name
*
* Returns: an %gnutls_mac_algorithm_tid of the specified in a string
@@ -802,7 +802,7 @@ gnutls_mac_get_name (gnutls_mac_algorithm_t algorithm)
* compared in a case insensitive way.
**/
gnutls_mac_algorithm_t
gnutls_mac_get_id (const char *name)
MHD_gtls_mac_get_id (const char *name)
{
gnutls_mac_algorithm_t ret = MHD_GNUTLS_MAC_UNKNOWN;
@@ -813,7 +813,7 @@ gnutls_mac_get_id (const char *name)
}
/**
* gnutls_mac_get_key_size - Returns the length of the MAC's key size
* MHD_gnutls_mac_get_key_size - Returns the length of the MAC's key size
* @algorithm: is an encryption algorithm
*
* Returns: length (in bytes) of the given MAC key size, or 0 if the
@@ -821,7 +821,7 @@ gnutls_mac_get_id (const char *name)
*
**/
size_t
gnutls_mac_get_key_size (gnutls_mac_algorithm_t algorithm)
MHD_gnutls_mac_get_key_size (gnutls_mac_algorithm_t algorithm)
{
size_t ret = 0;
@@ -832,7 +832,7 @@ gnutls_mac_get_key_size (gnutls_mac_algorithm_t algorithm)
}
/**
* gnutls_mac_list:
* MHD_gtls_mac_list:
*
* Get a list of hash algorithms for use as MACs. Note that not
* necessarily all MACs are supported in TLS cipher suites. For
@@ -843,13 +843,13 @@ gnutls_mac_get_key_size (gnutls_mac_algorithm_t algorithm)
* integers indicating the available MACs.
**/
const gnutls_mac_algorithm_t *
gnutls_mac_list (void)
MHD_gtls_mac_list (void)
{
return supported_macs;
}
const char *
_gnutls_x509_mac_to_oid (gnutls_mac_algorithm_t algorithm)
mhd_gtls_x509_mac_to_oid (gnutls_mac_algorithm_t algorithm)
{
const char *ret = NULL;
@@ -860,7 +860,7 @@ _gnutls_x509_mac_to_oid (gnutls_mac_algorithm_t algorithm)
}
gnutls_mac_algorithm_t
_gnutls_x509_oid2mac_algorithm (const char *oid)
mhd_gtls_x509_oid2mac_algorithm (const char *oid)
{
gnutls_mac_algorithm_t ret = 0;
@@ -876,7 +876,7 @@ _gnutls_x509_oid2mac_algorithm (const char *oid)
}
int
_gnutls_mac_is_ok (gnutls_mac_algorithm_t algorithm)
mhd_gnutls_mac_is_ok (gnutls_mac_algorithm_t algorithm)
{
ssize_t ret = -1;
GNUTLS_HASH_ALG_LOOP (ret = p->id);
@@ -889,7 +889,7 @@ _gnutls_mac_is_ok (gnutls_mac_algorithm_t algorithm)
/* Compression Functions */
int
_gnutls_compression_priority (gnutls_session_t session,
mhd_gtls_compression_priority (mhd_gtls_session_t session,
gnutls_compression_method_t algorithm)
{ /* actually returns the priority */
unsigned int i;
@@ -902,14 +902,14 @@ _gnutls_compression_priority (gnutls_session_t session,
}
/**
* gnutls_compression_get_name - Returns a string with the name of the specified compression algorithm
* MHD_gnutls_compression_get_name - Returns a string with the name of the specified compression algorithm
* @algorithm: is a Compression algorithm
*
* Returns: a pointer to a string that contains the name of the
* specified compression algorithm, or %NULL.
**/
const char *
gnutls_compression_get_name (gnutls_compression_method_t algorithm)
MHD_gnutls_compression_get_name (gnutls_compression_method_t algorithm)
{
const char *ret = NULL;
@@ -920,7 +920,7 @@ gnutls_compression_get_name (gnutls_compression_method_t algorithm)
}
/**
* gnutls_compression_get_id - Returns the gnutls id of the specified in string algorithm
* MHD_gtls_compression_get_id - Returns the gnutls id of the specified in string algorithm
* @algorithm: is a compression method name
*
* The names are compared in a case insensitive way.
@@ -930,7 +930,7 @@ gnutls_compression_get_name (gnutls_compression_method_t algorithm)
*
**/
gnutls_compression_method_t
gnutls_compression_get_id (const char *name)
MHD_gtls_compression_get_id (const char *name)
{
gnutls_compression_method_t ret = MHD_GNUTLS_COMP_UNKNOWN;
@@ -944,7 +944,7 @@ gnutls_compression_get_id (const char *name)
}
/**
* gnutls_compression_list:
* MHD_gtls_compression_list:
*
* Get a list of compression methods. Note that to be able to use LZO
* compression, you must link to libgnutls-extra and call
@@ -954,14 +954,14 @@ gnutls_compression_get_id (const char *name)
* integers indicating the available compression methods.
**/
const gnutls_compression_method_t *
gnutls_compression_list (void)
MHD_gtls_compression_list (void)
{
return supported_compressions;
}
/* return the tls number of the specified algorithm */
int
_gnutls_compression_get_num (gnutls_compression_method_t algorithm)
mhd_gtls_compression_get_num (gnutls_compression_method_t algorithm)
{
int ret = -1;
@@ -972,7 +972,7 @@ _gnutls_compression_get_num (gnutls_compression_method_t algorithm)
}
int
_gnutls_compression_get_wbits (gnutls_compression_method_t algorithm)
mhd_gtls_compression_get_wbits (gnutls_compression_method_t algorithm)
{
int ret = -1;
/* avoid prefix */
@@ -981,7 +981,7 @@ _gnutls_compression_get_wbits (gnutls_compression_method_t algorithm)
}
int
_gnutls_compression_get_mem_level (gnutls_compression_method_t algorithm)
mhd_gtls_compression_get_mem_level (gnutls_compression_method_t algorithm)
{
int ret = -1;
/* avoid prefix */
@@ -990,7 +990,7 @@ _gnutls_compression_get_mem_level (gnutls_compression_method_t algorithm)
}
int
_gnutls_compression_get_comp_level (gnutls_compression_method_t algorithm)
mhd_gtls_compression_get_comp_level (gnutls_compression_method_t algorithm)
{
int ret = -1;
/* avoid prefix */
@@ -1002,7 +1002,7 @@ _gnutls_compression_get_comp_level (gnutls_compression_method_t algorithm)
* method num
*/
gnutls_compression_method_t
_gnutls_compression_get_id (int num)
mhd_gtls_compression_get_id (int num)
{
gnutls_compression_method_t ret = -1;
@@ -1013,7 +1013,7 @@ _gnutls_compression_get_id (int num)
}
int
_gnutls_compression_is_ok (gnutls_compression_method_t algorithm)
mhd_gtls_compression_is_ok (gnutls_compression_method_t algorithm)
{
ssize_t ret = -1;
GNUTLS_COMPRESSION_ALG_LOOP (ret = p->id);
@@ -1026,7 +1026,7 @@ _gnutls_compression_is_ok (gnutls_compression_method_t algorithm)
/* CIPHER functions */
int
_gnutls_cipher_get_block_size (gnutls_cipher_algorithm_t algorithm)
mhd_gtls_cipher_get_block_size (gnutls_cipher_algorithm_t algorithm)
{
size_t ret = 0;
GNUTLS_ALG_LOOP (ret = p->blocksize);
@@ -1036,7 +1036,7 @@ _gnutls_cipher_get_block_size (gnutls_cipher_algorithm_t algorithm)
/* returns the priority */
int
_gnutls_cipher_priority (gnutls_session_t session,
mhd_gtls_cipher_priority (mhd_gtls_session_t session,
gnutls_cipher_algorithm_t algorithm)
{
unsigned int i;
@@ -1049,7 +1049,7 @@ _gnutls_cipher_priority (gnutls_session_t session,
}
int
_gnutls_cipher_is_block (gnutls_cipher_algorithm_t algorithm)
mhd_gtls_cipher_is_block (gnutls_cipher_algorithm_t algorithm)
{
size_t ret = 0;
@@ -1059,14 +1059,14 @@ _gnutls_cipher_is_block (gnutls_cipher_algorithm_t algorithm)
}
/**
* gnutls_cipher_get_key_size - Returns the length of the cipher's key size
* MHD_gnutls_cipher_get_key_size - Returns the length of the cipher's key size
* @algorithm: is an encryption algorithm
*
* Returns: length (in bytes) of the given cipher's key size, o 0 if
* the given cipher is invalid.
**/
size_t
gnutls_cipher_get_key_size (gnutls_cipher_algorithm_t algorithm)
MHD_gnutls_cipher_get_key_size (gnutls_cipher_algorithm_t algorithm)
{ /* In bytes */
size_t ret = 0;
GNUTLS_ALG_LOOP (ret = p->keysize);
@@ -1075,7 +1075,7 @@ gnutls_cipher_get_key_size (gnutls_cipher_algorithm_t algorithm)
}
int
_gnutls_cipher_get_iv_size (gnutls_cipher_algorithm_t algorithm)
mhd_gtls_cipher_get_iv_size (gnutls_cipher_algorithm_t algorithm)
{ /* In bytes */
size_t ret = 0;
GNUTLS_ALG_LOOP (ret = p->iv);
@@ -1084,7 +1084,7 @@ _gnutls_cipher_get_iv_size (gnutls_cipher_algorithm_t algorithm)
}
int
_gnutls_cipher_get_export_flag (gnutls_cipher_algorithm_t algorithm)
mhd_gtls_cipher_get_export_flag (gnutls_cipher_algorithm_t algorithm)
{ /* In bytes */
size_t ret = 0;
GNUTLS_ALG_LOOP (ret = p->export_flag);
@@ -1093,14 +1093,14 @@ _gnutls_cipher_get_export_flag (gnutls_cipher_algorithm_t algorithm)
}
/**
* gnutls_cipher_get_name - Returns a string with the name of the specified cipher algorithm
* MHD_gnutls_cipher_get_name - Returns a string with the name of the specified cipher algorithm
* @algorithm: is an encryption algorithm
*
* Returns: a pointer to a string that contains the name of the
* specified cipher, or %NULL.
**/
const char *
gnutls_cipher_get_name (gnutls_cipher_algorithm_t algorithm)
MHD_gnutls_cipher_get_name (gnutls_cipher_algorithm_t algorithm)
{
const char *ret = NULL;
@@ -1111,7 +1111,7 @@ gnutls_cipher_get_name (gnutls_cipher_algorithm_t algorithm)
}
/**
* gnutls_cipher_get_id - Returns the gnutls id of the specified in string algorithm
* MHD_gtls_cipher_get_id - Returns the gnutls id of the specified in string algorithm
* @algorithm: is a MAC algorithm name
*
* The names are compared in a case insensitive way.
@@ -1121,7 +1121,7 @@ gnutls_cipher_get_name (gnutls_cipher_algorithm_t algorithm)
*
**/
gnutls_cipher_algorithm_t
gnutls_cipher_get_id (const char *name)
MHD_gtls_cipher_get_id (const char *name)
{
gnutls_cipher_algorithm_t ret = MHD_GNUTLS_CIPHER_UNKNOWN;
@@ -1132,7 +1132,7 @@ gnutls_cipher_get_id (const char *name)
}
/**
* gnutls_cipher_list:
* MHD_gtls_cipher_list:
*
* Get a list of supported cipher algorithms. Note that not
* necessarily all ciphers are supported as TLS cipher suites. For
@@ -1144,13 +1144,13 @@ gnutls_cipher_get_id (const char *name)
*
**/
const gnutls_cipher_algorithm_t *
gnutls_cipher_list (void)
MHD_gtls_cipher_list (void)
{
return supported_ciphers;
}
int
_gnutls_cipher_is_ok (gnutls_cipher_algorithm_t algorithm)
mhd_gtls_cipher_is_ok (gnutls_cipher_algorithm_t algorithm)
{
ssize_t ret = -1;
GNUTLS_ALG_LOOP (ret = p->id);
@@ -1162,17 +1162,17 @@ _gnutls_cipher_is_ok (gnutls_cipher_algorithm_t algorithm)
}
/* Key EXCHANGE functions */
mod_auth_st *
_gnutls_kx_auth_struct (gnutls_kx_algorithm_t algorithm)
mhd_gtls_mod_auth_st *
mhd_gtls_kx_auth_struct (gnutls_kx_algorithm_t algorithm)
{
mod_auth_st *ret = NULL;
mhd_gtls_mod_auth_st *ret = NULL;
GNUTLS_KX_ALG_LOOP (ret = p->auth_struct);
return ret;
}
int
_gnutls_kx_priority (gnutls_session_t session,
mhd_gtls_kx_priority (mhd_gtls_session_t session,
gnutls_kx_algorithm_t algorithm)
{
unsigned int i;
@@ -1185,14 +1185,14 @@ _gnutls_kx_priority (gnutls_session_t session,
}
/**
* gnutls_kx_get_name - Returns a string with the name of the specified key exchange algorithm
* MHD_gnutls_kx_get_name - Returns a string with the name of the specified key exchange algorithm
* @algorithm: is a key exchange algorithm
*
* Returns: a pointer to a string that contains the name of the
* specified key exchange algorithm, or %NULL.
**/
const char *
gnutls_kx_get_name (gnutls_kx_algorithm_t algorithm)
MHD_gnutls_kx_get_name (gnutls_kx_algorithm_t algorithm)
{
const char *ret = NULL;
@@ -1203,7 +1203,7 @@ gnutls_kx_get_name (gnutls_kx_algorithm_t algorithm)
}
/**
* gnutls_kx_get_id - Returns the gnutls id of the specified in string algorithm
* MHD_gtls_kx_get_id - Returns the gnutls id of the specified in string algorithm
* @algorithm: is a KX name
*
* The names are compared in a case insensitive way.
@@ -1212,7 +1212,7 @@ gnutls_kx_get_name (gnutls_kx_algorithm_t algorithm)
* %GNUTLS_KX_UNKNOWN on error.
**/
gnutls_kx_algorithm_t
gnutls_kx_get_id (const char *name)
MHD_gtls_kx_get_id (const char *name)
{
gnutls_cipher_algorithm_t ret = MHD_GNUTLS_KX_UNKNOWN;
@@ -1223,7 +1223,7 @@ gnutls_kx_get_id (const char *name)
}
/**
* gnutls_kx_list:
* MHD_gtls_kx_list:
*
* Get a list of supported key exchange algorithms.
*
@@ -1231,13 +1231,13 @@ gnutls_kx_get_id (const char *name)
* indicating the available key exchange algorithms.
**/
const gnutls_kx_algorithm_t *
gnutls_kx_list (void)
MHD_gtls_kx_list (void)
{
return supported_kxs;
}
int
_gnutls_kx_is_ok (gnutls_kx_algorithm_t algorithm)
mhd_gtls_kx_is_ok (gnutls_kx_algorithm_t algorithm)
{
ssize_t ret = -1;
GNUTLS_KX_ALG_LOOP (ret = p->algorithm);
@@ -1249,7 +1249,7 @@ _gnutls_kx_is_ok (gnutls_kx_algorithm_t algorithm)
}
int
_gnutls_kx_needs_rsa_params (gnutls_kx_algorithm_t algorithm)
mhd_gtls_kx_needs_rsa_params (gnutls_kx_algorithm_t algorithm)
{
ssize_t ret = 0;
GNUTLS_KX_ALG_LOOP (ret = p->needs_rsa_params);
@@ -1257,7 +1257,7 @@ _gnutls_kx_needs_rsa_params (gnutls_kx_algorithm_t algorithm)
}
int
_gnutls_kx_needs_dh_params (gnutls_kx_algorithm_t algorithm)
mhd_gtls_kx_needs_dh_params (gnutls_kx_algorithm_t algorithm)
{
ssize_t ret = 0;
GNUTLS_KX_ALG_LOOP (ret = p->needs_dh_params);
@@ -1266,7 +1266,7 @@ _gnutls_kx_needs_dh_params (gnutls_kx_algorithm_t algorithm)
/* Version */
int
_gnutls_version_priority (gnutls_session_t session, gnutls_protocol_t version)
mhd_gtls_version_priority (mhd_gtls_session_t session, gnutls_protocol_t version)
{ /* actually returns the priority */
unsigned int i;
@@ -1285,7 +1285,7 @@ _gnutls_version_priority (gnutls_session_t session, gnutls_protocol_t version)
}
gnutls_protocol_t
_gnutls_version_lowest (gnutls_session_t session)
mhd_gtls_version_lowest (mhd_gtls_session_t session)
{ /* returns the lowest version supported */
unsigned int i, min = 0xff;
@@ -1307,7 +1307,7 @@ _gnutls_version_lowest (gnutls_session_t session)
}
gnutls_protocol_t
_gnutls_version_max (gnutls_session_t session)
mhd_gtls_version_max (mhd_gtls_session_t session)
{ /* returns the maximum version supported */
unsigned int i, max = 0x00;
@@ -1329,14 +1329,14 @@ _gnutls_version_max (gnutls_session_t session)
}
/**
* gnutls_protocol_get_name - Returns a string with the name of the specified SSL/TLS version
* MHD_gnutls_protocol_get_name - Returns a string with the name of the specified SSL/TLS version
* @version: is a (gnutls) version number
*
* Returns: a string that contains the name of the specified TLS
* version (e.g., "TLS 1.0"), or %NULL.
**/
const char *
gnutls_protocol_get_name (gnutls_protocol_t version)
MHD_gnutls_protocol_get_name (gnutls_protocol_t version)
{
const char *ret = NULL;
@@ -1346,7 +1346,7 @@ gnutls_protocol_get_name (gnutls_protocol_t version)
}
/**
* gnutls_protocol_get_id - Returns the gnutls id of the specified in string protocol
* MHD_gtls_protocol_get_id - Returns the gnutls id of the specified in string protocol
* @algorithm: is a protocol name
*
* The names are compared in a case insensitive way.
@@ -1355,7 +1355,7 @@ gnutls_protocol_get_name (gnutls_protocol_t version)
* %GNUTLS_VERSION_UNKNOWN on error.
**/
gnutls_protocol_t
gnutls_protocol_get_id (const char *name)
MHD_gtls_protocol_get_id (const char *name)
{
gnutls_protocol_t ret = MHD_GNUTLS_VERSION_UNKNOWN;
@@ -1366,7 +1366,7 @@ gnutls_protocol_get_id (const char *name)
}
/**
* gnutls_protocol_list:
* MHD_gtls_protocol_list:
*
* Get a list of supported protocols, e.g. SSL 3.0, TLS 1.0 etc.
*
@@ -1375,13 +1375,13 @@ gnutls_protocol_get_id (const char *name)
*
**/
const gnutls_protocol_t *
gnutls_protocol_list (void)
MHD_gtls_protocol_list (void)
{
return supported_protocols;
}
int
_gnutls_version_get_minor (gnutls_protocol_t version)
mhd_gtls_version_get_minor (gnutls_protocol_t version)
{
int ret = -1;
@@ -1390,7 +1390,7 @@ _gnutls_version_get_minor (gnutls_protocol_t version)
}
gnutls_protocol_t
_gnutls_version_get (int major, int minor)
mhd_gtls_version_get (int major, int minor)
{
int ret = -1;
@@ -1401,7 +1401,7 @@ _gnutls_version_get (int major, int minor)
}
int
_gnutls_version_get_major (gnutls_protocol_t version)
mhd_gtls_version_get_major (gnutls_protocol_t version)
{
int ret = -1;
@@ -1412,7 +1412,7 @@ _gnutls_version_get_major (gnutls_protocol_t version)
/* Version Functions */
int
_gnutls_version_is_supported (gnutls_session_t session,
mhd_gtls_version_is_supported (mhd_gtls_session_t session,
const gnutls_protocol_t version)
{
int ret = 0;
@@ -1421,7 +1421,7 @@ _gnutls_version_is_supported (gnutls_session_t session,
if (ret == 0)
return 0;
if (_gnutls_version_priority (session, version) < 0)
if (mhd_gtls_version_priority (session, version) < 0)
return 0; /* disabled by the user */
else
return 1;
@@ -1429,7 +1429,7 @@ _gnutls_version_is_supported (gnutls_session_t session,
/* Type to KX mappings */
gnutls_kx_algorithm_t
_gnutls_map_kx_get_kx (gnutls_credentials_type_t type, int server)
mhd_gtls_map_kx_get_kx (gnutls_credentials_type_t type, int server)
{
gnutls_kx_algorithm_t ret = -1;
@@ -1445,7 +1445,7 @@ _gnutls_map_kx_get_kx (gnutls_credentials_type_t type, int server)
}
gnutls_credentials_type_t
_gnutls_map_kx_get_cred (gnutls_kx_algorithm_t algorithm, int server)
mhd_gtls_map_kx_get_cred (gnutls_kx_algorithm_t algorithm, int server)
{
gnutls_credentials_type_t ret = -1;
if (server)
@@ -1464,7 +1464,7 @@ _gnutls_map_kx_get_cred (gnutls_kx_algorithm_t algorithm, int server)
/* Cipher Suite's functions */
gnutls_cipher_algorithm_t
_gnutls_cipher_suite_get_cipher_algo (const cipher_suite_st * suite)
mhd_gtls_cipher_suite_get_cipher_algo (const cipher_suite_st * suite)
{
int ret = 0;
GNUTLS_CIPHER_SUITE_ALG_LOOP (ret = p->block_algorithm);
@@ -1472,7 +1472,7 @@ _gnutls_cipher_suite_get_cipher_algo (const cipher_suite_st * suite)
}
gnutls_protocol_t
_gnutls_cipher_suite_get_version (const cipher_suite_st * suite)
mhd_gtls_cipher_suite_get_version (const cipher_suite_st * suite)
{
int ret = 0;
GNUTLS_CIPHER_SUITE_ALG_LOOP (ret = p->version);
@@ -1480,7 +1480,7 @@ _gnutls_cipher_suite_get_version (const cipher_suite_st * suite)
}
gnutls_kx_algorithm_t
_gnutls_cipher_suite_get_kx_algo (const cipher_suite_st * suite)
mhd_gtls_cipher_suite_get_kx_algo (const cipher_suite_st * suite)
{
int ret = 0;
@@ -1490,7 +1490,7 @@ _gnutls_cipher_suite_get_kx_algo (const cipher_suite_st * suite)
}
gnutls_mac_algorithm_t
_gnutls_cipher_suite_get_mac_algo (const cipher_suite_st * suite)
mhd_gtls_cipher_suite_get_mac_algo (const cipher_suite_st * suite)
{ /* In bytes */
int ret = 0;
GNUTLS_CIPHER_SUITE_ALG_LOOP (ret = p->mac_algorithm);
@@ -1499,7 +1499,7 @@ _gnutls_cipher_suite_get_mac_algo (const cipher_suite_st * suite)
}
const char *
_gnutls_cipher_suite_get_name (cipher_suite_st * suite)
mhd_gtls_cipher_suite_get_name (cipher_suite_st * suite)
{
const char *ret = NULL;
@@ -1509,78 +1509,6 @@ _gnutls_cipher_suite_get_name (cipher_suite_st * suite)
return ret;
}
/**
* gnutls_cipher_suite_get_name - Returns a string with the name of the specified cipher suite
* @kx_algorithm: is a Key exchange algorithm
* @cipher_algorithm: is a cipher algorithm
* @mac_algorithm: is a MAC algorithm
*
* Note that the full cipher suite name must be prepended by TLS or
* SSL depending of the protocol in use.
*
* Returns: a string that contains the name of a TLS cipher suite,
* specified by the given algorithms, or %NULL.
**/
const char *
gnutls_cipher_suite_get_name (gnutls_kx_algorithm_t kx_algorithm,
gnutls_cipher_algorithm_t cipher_algorithm,
gnutls_mac_algorithm_t mac_algorithm)
{
const char *ret = NULL;
/* avoid prefix */
GNUTLS_CIPHER_SUITE_LOOP (if (kx_algorithm == p->kx_algorithm &&
cipher_algorithm == p->block_algorithm &&
mac_algorithm == p->mac_algorithm)
ret = p->name + sizeof ("GNUTLS_") - 1)
;
return ret;
}
/**
* gnutls_cipher_suite_info:
* @idx: index of cipher suite to get information about, starts on 0.
* @cs_id: output buffer with room for 2 bytes, indicating cipher suite value
* @kx: output variable indicating key exchange algorithm, or %NULL.
* @cipher: output variable indicating cipher, or %NULL.
* @mac: output variable indicating MAC algorithm, or %NULL.
* @version: output variable indicating TLS protocol version, or %NULL.
*
* Get information about supported cipher suites. Use the function
* iteratively to get information about all supported cipher suites.
* Call with idx=0 to get information about first cipher suite, then
* idx=1 and so on until the function returns NULL.
*
* Returns: the name of @idx cipher suite, and set the information
* about the cipher suite in the output variables. If @idx is out of
* bounds, %NULL is returned.
**/
const char *
gnutls_cipher_suite_info (size_t idx,
char *cs_id,
gnutls_kx_algorithm_t * kx,
gnutls_cipher_algorithm_t * cipher,
gnutls_mac_algorithm_t * mac,
gnutls_protocol_t * version)
{
if (idx >= CIPHER_SUITES_COUNT)
return NULL;
if (cs_id)
memcpy (cs_id, cs_algorithms[idx].id.suite, 2);
if (kx)
*kx = cs_algorithms[idx].kx_algorithm;
if (cipher)
*cipher = cs_algorithms[idx].block_algorithm;
if (mac)
*mac = cs_algorithms[idx].mac_algorithm;
if (version)
*version = cs_algorithms[idx].version;
return cs_algorithms[idx].name + sizeof ("GNU") - 1;
}
static inline int
_gnutls_cipher_suite_is_ok (cipher_suite_st * suite)
{
@@ -1602,11 +1530,11 @@ _gnutls_cipher_suite_is_ok (cipher_suite_st * suite)
#define MAX_ELEM_SIZE 4
static inline int
_gnutls_partition (gnutls_session_t session,
_gnutls_partition (mhd_gtls_session_t session,
void *_base,
size_t nmemb,
size_t size,
int (*compar) (gnutls_session_t,
int (*compar) (mhd_gtls_session_t,
const void *, const void *))
{
uint8_t *base = _base;
@@ -1650,11 +1578,11 @@ _gnutls_partition (gnutls_session_t session,
}
static void
_gnutls_qsort (gnutls_session_t session,
_gnutls_qsort (mhd_gtls_session_t session,
void *_base,
size_t nmemb,
size_t size,
int (*compar) (gnutls_session_t, const void *, const void *))
int (*compar) (mhd_gtls_session_t, const void *, const void *))
{
unsigned int pivot;
char *base = _base;
@@ -1683,28 +1611,28 @@ _gnutls_qsort (gnutls_session_t session,
* For use with qsort
*/
static int
_gnutls_compare_algo (gnutls_session_t session,
_gnutls_compare_algo (mhd_gtls_session_t session,
const void *i_A1, const void *i_A2)
{
gnutls_kx_algorithm_t kA1 =
_gnutls_cipher_suite_get_kx_algo ((const cipher_suite_st *) i_A1);
mhd_gtls_cipher_suite_get_kx_algo ((const cipher_suite_st *) i_A1);
gnutls_kx_algorithm_t kA2 =
_gnutls_cipher_suite_get_kx_algo ((const cipher_suite_st *) i_A2);
mhd_gtls_cipher_suite_get_kx_algo ((const cipher_suite_st *) i_A2);
gnutls_cipher_algorithm_t cA1 =
_gnutls_cipher_suite_get_cipher_algo ((const cipher_suite_st *) i_A1);
mhd_gtls_cipher_suite_get_cipher_algo ((const cipher_suite_st *) i_A1);
gnutls_cipher_algorithm_t cA2 =
_gnutls_cipher_suite_get_cipher_algo ((const cipher_suite_st *) i_A2);
mhd_gtls_cipher_suite_get_cipher_algo ((const cipher_suite_st *) i_A2);
gnutls_mac_algorithm_t mA1 =
_gnutls_cipher_suite_get_mac_algo ((const cipher_suite_st *) i_A1);
mhd_gtls_cipher_suite_get_mac_algo ((const cipher_suite_st *) i_A1);
gnutls_mac_algorithm_t mA2 =
_gnutls_cipher_suite_get_mac_algo ((const cipher_suite_st *) i_A2);
mhd_gtls_cipher_suite_get_mac_algo ((const cipher_suite_st *) i_A2);
int p1 = (_gnutls_kx_priority (session, kA1) + 1) * 64;
int p2 = (_gnutls_kx_priority (session, kA2) + 1) * 64;
p1 += (_gnutls_cipher_priority (session, cA1) + 1) * 8;
p2 += (_gnutls_cipher_priority (session, cA2) + 1) * 8;
p1 += _gnutls_mac_priority (session, mA1);
p2 += _gnutls_mac_priority (session, mA2);
int p1 = (mhd_gtls_kx_priority (session, kA1) + 1) * 64;
int p2 = (mhd_gtls_kx_priority (session, kA2) + 1) * 64;
p1 += (mhd_gtls_cipher_priority (session, cA1) + 1) * 8;
p2 += (mhd_gtls_cipher_priority (session, cA2) + 1) * 8;
p1 += mhd_gtls_mac_priority (session, mA1);
p2 += mhd_gtls_mac_priority (session, mA2);
if (p1 > p2)
{
@@ -1722,8 +1650,8 @@ _gnutls_compare_algo (gnutls_session_t session,
#ifdef SORT_DEBUG
static void
_gnutls_bsort (gnutls_session_t session, void *_base, size_t nmemb,
size_t size, int (*compar) (gnutls_session_t, const void *,
_gnutls_bsort (mhd_gtls_session_t session, void *_base, size_t nmemb,
size_t size, int (*compar) (mhd_gtls_session_t, const void *,
const void *))
{
unsigned int i, j;
@@ -1746,7 +1674,7 @@ _gnutls_bsort (gnutls_session_t session, void *_base, size_t nmemb,
#endif
int
_gnutls_supported_ciphersuites_sorted (gnutls_session_t session,
mhd_gtls_supported_ciphersuites_sorted (mhd_gtls_session_t session,
cipher_suite_st ** ciphers)
{
@@ -1755,7 +1683,7 @@ _gnutls_supported_ciphersuites_sorted (gnutls_session_t session,
#endif
int count;
count = _gnutls_supported_ciphersuites (session, ciphers);
count = mhd_gtls_supported_ciphersuites (session, ciphers);
if (count <= 0)
{
gnutls_assert ();
@@ -1765,7 +1693,7 @@ _gnutls_supported_ciphersuites_sorted (gnutls_session_t session,
_gnutls_debug_log ("Unsorted: \n");
for (i = 0; i < count; i++)
_gnutls_debug_log ("\t%d: %s\n", i,
_gnutls_cipher_suite_get_name ((*ciphers)[i]));
mhd_gtls_cipher_suite_get_name ((*ciphers)[i]));
#endif
_gnutls_qsort (session, *ciphers, count, sizeof (cipher_suite_st),
@@ -1775,14 +1703,14 @@ _gnutls_supported_ciphersuites_sorted (gnutls_session_t session,
_gnutls_debug_log ("Sorted: \n");
for (i = 0; i < count; i++)
_gnutls_debug_log ("\t%d: %s\n", i,
_gnutls_cipher_suite_get_name ((*ciphers)[i]));
mhd_gtls_cipher_suite_get_name ((*ciphers)[i]));
#endif
return count;
}
int
_gnutls_supported_ciphersuites (gnutls_session_t session,
mhd_gtls_supported_ciphersuites (mhd_gtls_session_t session,
cipher_suite_st ** _ciphers)
{
@@ -1808,7 +1736,7 @@ _gnutls_supported_ciphersuites (gnutls_session_t session,
return GNUTLS_E_MEMORY_ERROR;
}
version = gnutls_protocol_get_version (session);
version = MHD_gnutls_protocol_get_version (session);
for (i = 0; i < count; i++)
{
@@ -1827,19 +1755,19 @@ _gnutls_supported_ciphersuites (gnutls_session_t session,
/* remove cipher suites which do not support the
* protocol version used.
*/
if (_gnutls_cipher_suite_get_version (&tmp_ciphers[i]) > version)
if (mhd_gtls_cipher_suite_get_version (&tmp_ciphers[i]) > version)
continue;
if (_gnutls_kx_priority (session,
_gnutls_cipher_suite_get_kx_algo (&tmp_ciphers
if (mhd_gtls_kx_priority (session,
mhd_gtls_cipher_suite_get_kx_algo (&tmp_ciphers
[i])) < 0)
continue;
if (_gnutls_mac_priority (session,
_gnutls_cipher_suite_get_mac_algo
if (mhd_gtls_mac_priority (session,
mhd_gtls_cipher_suite_get_mac_algo
(&tmp_ciphers[i])) < 0)
continue;
if (_gnutls_cipher_priority (session,
_gnutls_cipher_suite_get_cipher_algo
if (mhd_gtls_cipher_priority (session,
mhd_gtls_cipher_suite_get_cipher_algo
(&tmp_ciphers[i])) < 0)
continue;
@@ -1853,7 +1781,7 @@ _gnutls_supported_ciphersuites (gnutls_session_t session,
if (ret_count > 0 && ret_count != count)
{
ciphers =
gnutls_realloc_fast (ciphers, ret_count * sizeof (cipher_suite_st));
mhd_gtls_realloc_fast (ciphers, ret_count * sizeof (cipher_suite_st));
}
else
{
@@ -1888,7 +1816,7 @@ _gnutls_supported_ciphersuites (gnutls_session_t session,
*/
#define SUPPORTED_COMPRESSION_METHODS session->internals.priorities.compression.num_algorithms
int
_gnutls_supported_compression_methods (gnutls_session_t session,
mhd_gtls_supported_compression_methods (mhd_gtls_session_t session,
uint8_t ** comp)
{
unsigned int i, j;
@@ -1899,7 +1827,7 @@ _gnutls_supported_compression_methods (gnutls_session_t session,
for (i = j = 0; i < SUPPORTED_COMPRESSION_METHODS; i++)
{
int tmp = _gnutls_compression_get_num (session->internals.priorities.
int tmp = mhd_gtls_compression_get_num (session->internals.priorities.
compression.priority[i]);
/* remove private compression algorithms, if requested.
@@ -1926,14 +1854,14 @@ _gnutls_supported_compression_methods (gnutls_session_t session,
}
/**
* gnutls_certificate_type_get_name - Returns a string with the name of the specified certificate type
* MHD_gnutls_certificate_type_get_name - Returns a string with the name of the specified certificate type
* @type: is a certificate type
*
* Returns: a string (or %NULL) that contains the name of the
* specified certificate type.
**/
const char *
gnutls_certificate_type_get_name (gnutls_certificate_type_t type)
MHD_gnutls_certificate_type_get_name (gnutls_certificate_type_t type)
{
const char *ret = NULL;
@@ -1946,7 +1874,7 @@ gnutls_certificate_type_get_name (gnutls_certificate_type_t type)
}
/**
* gnutls_certificate_type_get_id - Returns the gnutls id of the specified in string type
* MHD_gtls_certificate_type_get_id - Returns the gnutls id of the specified in string type
* @name: is a certificate type name
*
* The names are compared in a case insensitive way.
@@ -1955,7 +1883,7 @@ gnutls_certificate_type_get_name (gnutls_certificate_type_t type)
* %GNUTLS_CRT_UNKNOWN on error.
**/
gnutls_certificate_type_t
gnutls_certificate_type_get_id (const char *name)
MHD_gtls_certificate_type_get_id (const char *name)
{
gnutls_certificate_type_t ret = MHD_GNUTLS_CRT_UNKNOWN;
@@ -1974,7 +1902,7 @@ static const gnutls_certificate_type_t supported_certificate_types[] =
};
/**
* gnutls_certificate_type_list:
* MHD_gtls_certificate_type_list:
*
* Get a list of certificate types. Note that to be able to use
* OpenPGP certificates, you must link to libgnutls-extra and call
@@ -1985,7 +1913,7 @@ static const gnutls_certificate_type_t supported_certificate_types[] =
*
**/
const gnutls_certificate_type_t *
gnutls_certificate_type_list (void)
MHD_gtls_certificate_type_list (void)
{
return supported_certificate_types;
}
@@ -1994,7 +1922,7 @@ gnutls_certificate_type_list (void)
* the given gnutls_kx_algorithm_t.
*/
gnutls_pk_algorithm_t
_gnutls_map_pk_get_pk (gnutls_kx_algorithm_t kx_algorithm)
mhd_gtls_map_pk_get_pk (gnutls_kx_algorithm_t kx_algorithm)
{
gnutls_pk_algorithm_t ret = -1;
@@ -2007,7 +1935,7 @@ _gnutls_map_pk_get_pk (gnutls_kx_algorithm_t kx_algorithm)
* ex. GNUTLS_KX_RSA requires a certificate able to encrypt... so returns CIPHER_ENCRYPT.
*/
enum encipher_type
_gnutls_kx_encipher_type (gnutls_kx_algorithm_t kx_algorithm)
mhd_gtls_kx_encipher_type (gnutls_kx_algorithm_t kx_algorithm)
{
int ret = CIPHER_IGN;
GNUTLS_PK_MAP_ALG_LOOP (ret = p->encipher_type) return ret;
@@ -2068,26 +1996,8 @@ static const gnutls_sign_entry sign_algorithms[] = {
#define GNUTLS_SIGN_ALG_LOOP(a) \
GNUTLS_SIGN_LOOP( if(p->id && p->id == sign) { a; break; } )
/**
* gnutls_sign_algorithm_get_name - Returns a string with the name of the specified sign algorithm
* @algorithm: is a sign algorithm
*
* Returns: a string that contains the name of the specified sign
* algorithm, or %NULL.
**/
const char *
gnutls_sign_algorithm_get_name (gnutls_sign_algorithm_t sign)
{
const char *ret = NULL;
/* avoid prefix */
GNUTLS_SIGN_ALG_LOOP (ret = p->name);
return ret;
}
gnutls_sign_algorithm_t
_gnutls_x509_oid2sign_algorithm (const char *oid)
mhd_gtls_x509_oid2sign_algorithm (const char *oid)
{
gnutls_sign_algorithm_t ret = 0;
@@ -2105,7 +2015,7 @@ _gnutls_x509_oid2sign_algorithm (const char *oid)
}
gnutls_sign_algorithm_t
_gnutls_x509_pk_to_sign (gnutls_pk_algorithm_t pk, gnutls_mac_algorithm_t mac)
mhd_gtls_x509_pk_to_sign (gnutls_pk_algorithm_t pk, gnutls_mac_algorithm_t mac)
{
gnutls_sign_algorithm_t ret = 0;
@@ -2120,13 +2030,13 @@ _gnutls_x509_pk_to_sign (gnutls_pk_algorithm_t pk, gnutls_mac_algorithm_t mac)
}
const char *
_gnutls_x509_sign_to_oid (gnutls_pk_algorithm_t pk,
mhd_gtls_x509_sign_to_oid (gnutls_pk_algorithm_t pk,
gnutls_mac_algorithm_t mac)
{
gnutls_sign_algorithm_t sign;
const char *ret = NULL;
sign = _gnutls_x509_pk_to_sign (pk, mac);
sign = mhd_gtls_x509_pk_to_sign (pk, mac);
if (sign == GNUTLS_SIGN_UNKNOWN)
return NULL;
@@ -2159,31 +2069,8 @@ static const gnutls_pk_entry pk_algorithms[] = {
0}
};
/**
* gnutls_pk_algorithm_get_name - Returns a string with the name of the specified public key algorithm
* @algorithm: is a pk algorithm
*
* Returns: a string that contains the name of the specified public
* key algorithm, or %NULL.
**/
const char *
gnutls_pk_algorithm_get_name (gnutls_pk_algorithm_t algorithm)
{
const char *ret = NULL;
const gnutls_pk_entry *p;
for (p = pk_algorithms; p->name != NULL; p++)
if (p->id && p->id == algorithm)
{
ret = p->name;
break;
}
return ret;
}
gnutls_pk_algorithm_t
_gnutls_x509_oid2pk_algorithm (const char *oid)
mhd_gtls_x509_oid2pk_algorithm (const char *oid)
{
gnutls_pk_algorithm_t ret = MHD_GNUTLS_PK_UNKNOWN;
const gnutls_pk_entry *p;
@@ -2199,7 +2086,7 @@ _gnutls_x509_oid2pk_algorithm (const char *oid)
}
const char *
_gnutls_x509_pk_to_oid (gnutls_pk_algorithm_t algorithm)
mhd_gtls_x509_pk_to_oid (gnutls_pk_algorithm_t algorithm)
{
const char *ret = NULL;
const gnutls_pk_entry *p;
+55 -55
View File
@@ -23,87 +23,87 @@
*/
#ifndef ALGORITHMS_H
# define ALGORITHMS_H
#define ALGORITHMS_H
#include "gnutls_auth.h"
/* Functions for version handling. */
gnutls_protocol_t _gnutls_version_lowest (gnutls_session_t session);
gnutls_protocol_t _gnutls_version_max (gnutls_session_t session);
int _gnutls_version_priority (gnutls_session_t session,
gnutls_protocol_t mhd_gtls_version_lowest (mhd_gtls_session_t session);
gnutls_protocol_t mhd_gtls_version_max (mhd_gtls_session_t session);
int mhd_gtls_version_priority (mhd_gtls_session_t session,
gnutls_protocol_t version);
int _gnutls_version_is_supported (gnutls_session_t session,
int mhd_gtls_version_is_supported (mhd_gtls_session_t session,
const gnutls_protocol_t version);
int _gnutls_version_get_major (gnutls_protocol_t ver);
int _gnutls_version_get_minor (gnutls_protocol_t ver);
gnutls_protocol_t _gnutls_version_get (int major, int minor);
int mhd_gtls_version_get_major (gnutls_protocol_t ver);
int mhd_gtls_version_get_minor (gnutls_protocol_t ver);
gnutls_protocol_t mhd_gtls_version_get (int major, int minor);
/* Functions for MACs. */
int _gnutls_mac_is_ok (gnutls_mac_algorithm_t algorithm);
gnutls_mac_algorithm_t _gnutls_x509_oid2mac_algorithm (const char *oid);
const char *_gnutls_x509_mac_to_oid (gnutls_mac_algorithm_t mac);
int mhd_gnutls_mac_is_ok (gnutls_mac_algorithm_t algorithm);
gnutls_mac_algorithm_t mhd_gtls_x509_oid2mac_algorithm (const char *oid);
const char * mhd_gtls_x509_mac_to_oid (gnutls_mac_algorithm_t mac);
/* Functions for cipher suites. */
int _gnutls_supported_ciphersuites (gnutls_session_t session,
int mhd_gtls_supported_ciphersuites (mhd_gtls_session_t session,
cipher_suite_st ** ciphers);
int _gnutls_supported_ciphersuites_sorted (gnutls_session_t session,
int mhd_gtls_supported_ciphersuites_sorted (mhd_gtls_session_t session,
cipher_suite_st ** ciphers);
int _gnutls_supported_compression_methods (gnutls_session_t session,
int mhd_gtls_supported_compression_methods (mhd_gtls_session_t session,
uint8_t ** comp);
const char *_gnutls_cipher_suite_get_name (cipher_suite_st * algorithm);
gnutls_cipher_algorithm_t _gnutls_cipher_suite_get_cipher_algo (const
const char * mhd_gtls_cipher_suite_get_name (cipher_suite_st * algorithm);
gnutls_cipher_algorithm_t mhd_gtls_cipher_suite_get_cipher_algo (const
cipher_suite_st
* algorithm);
gnutls_kx_algorithm_t _gnutls_cipher_suite_get_kx_algo (const cipher_suite_st
gnutls_kx_algorithm_t mhd_gtls_cipher_suite_get_kx_algo (const cipher_suite_st
* algorithm);
gnutls_mac_algorithm_t _gnutls_cipher_suite_get_mac_algo (const
gnutls_mac_algorithm_t mhd_gtls_cipher_suite_get_mac_algo (const
cipher_suite_st *
algorithm);
gnutls_protocol_t _gnutls_cipher_suite_get_version (const cipher_suite_st *
gnutls_protocol_t mhd_gtls_cipher_suite_get_version (const cipher_suite_st *
algorithm);
cipher_suite_st _gnutls_cipher_suite_get_suite_name (cipher_suite_st *
cipher_suite_st mhd_gtls_cipher_suite_get_suite_name (cipher_suite_st *
algorithm);
/* Functions for ciphers. */
int _gnutls_cipher_get_block_size (gnutls_cipher_algorithm_t algorithm);
int _gnutls_cipher_is_block (gnutls_cipher_algorithm_t algorithm);
int _gnutls_cipher_is_ok (gnutls_cipher_algorithm_t algorithm);
int _gnutls_cipher_get_iv_size (gnutls_cipher_algorithm_t algorithm);
int _gnutls_cipher_get_export_flag (gnutls_cipher_algorithm_t algorithm);
int mhd_gtls_cipher_get_block_size (gnutls_cipher_algorithm_t algorithm);
int mhd_gtls_cipher_is_block (gnutls_cipher_algorithm_t algorithm);
int mhd_gtls_cipher_is_ok (gnutls_cipher_algorithm_t algorithm);
int mhd_gtls_cipher_get_iv_size (gnutls_cipher_algorithm_t algorithm);
int mhd_gtls_cipher_get_export_flag (gnutls_cipher_algorithm_t algorithm);
/* Functions for key exchange. */
int _gnutls_kx_needs_dh_params (gnutls_kx_algorithm_t algorithm);
int _gnutls_kx_needs_rsa_params (gnutls_kx_algorithm_t algorithm);
mod_auth_st *_gnutls_kx_auth_struct (gnutls_kx_algorithm_t algorithm);
int _gnutls_kx_is_ok (gnutls_kx_algorithm_t algorithm);
int mhd_gtls_kx_needs_dh_params (gnutls_kx_algorithm_t algorithm);
int mhd_gtls_kx_needs_rsa_params (gnutls_kx_algorithm_t algorithm);
mhd_gtls_mod_auth_st * mhd_gtls_kx_auth_struct (gnutls_kx_algorithm_t algorithm);
int mhd_gtls_kx_is_ok (gnutls_kx_algorithm_t algorithm);
/* Functions for compression. */
int _gnutls_compression_is_ok (gnutls_compression_method_t algorithm);
int _gnutls_compression_get_num (gnutls_compression_method_t algorithm);
gnutls_compression_method_t _gnutls_compression_get_id (int num);
int _gnutls_compression_get_mem_level (gnutls_compression_method_t algorithm);
int _gnutls_compression_get_comp_level (gnutls_compression_method_t
int mhd_gtls_compression_is_ok (gnutls_compression_method_t algorithm);
int mhd_gtls_compression_get_num (gnutls_compression_method_t algorithm);
gnutls_compression_method_t mhd_gtls_compression_get_id (int num);
int mhd_gtls_compression_get_mem_level (gnutls_compression_method_t algorithm);
int mhd_gtls_compression_get_comp_level (gnutls_compression_method_t
algorithm);
int _gnutls_compression_get_wbits (gnutls_compression_method_t algorithm);
int mhd_gtls_compression_get_wbits (gnutls_compression_method_t algorithm);
/* Type to KX mappings. */
gnutls_kx_algorithm_t _gnutls_map_kx_get_kx (gnutls_credentials_type_t type,
gnutls_kx_algorithm_t mhd_gtls_map_kx_get_kx (gnutls_credentials_type_t type,
int server);
gnutls_credentials_type_t _gnutls_map_kx_get_cred (gnutls_kx_algorithm_t
gnutls_credentials_type_t mhd_gtls_map_kx_get_cred (gnutls_kx_algorithm_t
algorithm, int server);
/* KX to PK mapping. */
gnutls_pk_algorithm_t _gnutls_map_pk_get_pk (gnutls_kx_algorithm_t
gnutls_pk_algorithm_t mhd_gtls_map_pk_get_pk (gnutls_kx_algorithm_t
kx_algorithm);
gnutls_pk_algorithm_t _gnutls_x509_oid2pk_algorithm (const char *oid);
const char *_gnutls_x509_pk_to_oid (gnutls_pk_algorithm_t pk);
gnutls_pk_algorithm_t mhd_gtls_x509_oid2pk_algorithm (const char *oid);
const char * mhd_gtls_x509_pk_to_oid (gnutls_pk_algorithm_t pk);
enum encipher_type
{ CIPHER_ENCRYPT = 0, CIPHER_SIGN = 1, CIPHER_IGN };
enum encipher_type _gnutls_kx_encipher_type (gnutls_kx_algorithm_t algorithm);
enum encipher_type mhd_gtls_kx_encipher_type (gnutls_kx_algorithm_t algorithm);
struct gnutls_compression_entry
struct mhd_gtls_compression_entry
{
const char *name;
gnutls_compression_method_t id;
@@ -114,28 +114,28 @@ struct gnutls_compression_entry
int mem_level;
int comp_level;
};
typedef struct gnutls_compression_entry gnutls_compression_entry;
typedef struct mhd_gtls_compression_entry gnutls_compression_entry;
/* Functions for sign algorithms. */
gnutls_sign_algorithm_t _gnutls_x509_oid2sign_algorithm (const char *oid);
gnutls_sign_algorithm_t _gnutls_x509_pk_to_sign (gnutls_pk_algorithm_t pk,
gnutls_sign_algorithm_t mhd_gtls_x509_oid2sign_algorithm (const char *oid);
gnutls_sign_algorithm_t mhd_gtls_x509_pk_to_sign (gnutls_pk_algorithm_t pk,
gnutls_mac_algorithm_t mac);
const char *_gnutls_x509_sign_to_oid (gnutls_pk_algorithm_t,
const char * mhd_gtls_x509_sign_to_oid (gnutls_pk_algorithm_t,
gnutls_mac_algorithm_t mac);
int _gnutls_mac_priority (gnutls_session_t session,
int mhd_gtls_mac_priority (mhd_gtls_session_t session,
gnutls_mac_algorithm_t algorithm);
int _gnutls_cipher_priority (gnutls_session_t session,
int mhd_gtls_cipher_priority (mhd_gtls_session_t session,
gnutls_cipher_algorithm_t algorithm);
int _gnutls_kx_priority (gnutls_session_t session,
int mhd_gtls_kx_priority (mhd_gtls_session_t session,
gnutls_kx_algorithm_t algorithm);
int _gnutls_compression_priority (gnutls_session_t session,
int mhd_gtls_compression_priority (mhd_gtls_session_t session,
gnutls_compression_method_t algorithm);
gnutls_mac_algorithm_t gnutls_mac_get_id (const char* name);
gnutls_cipher_algorithm_t gnutls_cipher_get_id (const char* name);
gnutls_kx_algorithm_t gnutls_kx_get_id (const char* name);
gnutls_protocol_t gnutls_protocol_get_id (const char* name);
gnutls_certificate_type_t gnutls_certificate_type_get_id (const char* name);
gnutls_mac_algorithm_t MHD_gtls_mac_get_id (const char* name);
gnutls_cipher_algorithm_t MHD_gtls_cipher_get_id (const char* name);
gnutls_kx_algorithm_t MHD_gtls_kx_get_id (const char* name);
gnutls_protocol_t MHD_gtls_protocol_get_id (const char* name);
gnutls_certificate_type_t MHD_gtls_certificate_type_get_id (const char* name);
#endif
+20 -20
View File
@@ -36,22 +36,22 @@
static const int anon_dummy;
/**
* gnutls_anon_free_server_credentials - Used to free an allocated gnutls_anon_server_credentials_t structure
* @sc: is an #gnutls_anon_server_credentials_t structure.
* MHD_gnutls_anon_free_server_credentials - Used to free an allocated mhd_gtls_anon_server_credentials_t structure
* @sc: is an #mhd_gtls_anon_server_credentials_t structure.
*
* This structure is complex enough to manipulate directly thus this
* helper function is provided in order to free (deallocate) it.
**/
void
gnutls_anon_free_server_credentials (gnutls_anon_server_credentials_t sc)
MHD_gnutls_anon_free_server_credentials (mhd_gtls_anon_server_credentials_t sc)
{
gnutls_free (sc);
}
/**
* gnutls_anon_allocate_server_credentials - Used to allocate an gnutls_anon_server_credentials_t structure
* @sc: is a pointer to an #gnutls_anon_server_credentials_t structure.
* MHD_gnutls_anon_allocate_server_credentials - Used to allocate an mhd_gtls_anon_server_credentials_t structure
* @sc: is a pointer to an #mhd_gtls_anon_server_credentials_t structure.
*
* This structure is complex enough to manipulate directly thus this
* helper function is provided in order to allocate it.
@@ -59,10 +59,10 @@ gnutls_anon_free_server_credentials (gnutls_anon_server_credentials_t sc)
* Returns: %GNUTLS_E_SUCCESS on success, or an error code.
**/
int
gnutls_anon_allocate_server_credentials (gnutls_anon_server_credentials_t *
MHD_gnutls_anon_allocate_server_credentials (mhd_gtls_anon_server_credentials_t *
sc)
{
*sc = gnutls_calloc (1, sizeof (anon_server_credentials_st));
*sc = gnutls_calloc (1, sizeof (mhd_anon_server_credentials_st));
if (*sc == NULL)
return GNUTLS_E_MEMORY_ERROR;
@@ -71,20 +71,20 @@ gnutls_anon_allocate_server_credentials (gnutls_anon_server_credentials_t *
/**
* gnutls_anon_free_client_credentials - Used to free an allocated gnutls_anon_client_credentials_t structure
* @sc: is an #gnutls_anon_client_credentials_t structure.
* MHD_gnutls_anon_free_client_credentials - Used to free an allocated mhd_gtls_anon_client_credentials_t structure
* @sc: is an #mhd_gtls_anon_client_credentials_t structure.
*
* This structure is complex enough to manipulate directly thus this
* helper function is provided in order to free (deallocate) it.
**/
void
gnutls_anon_free_client_credentials (gnutls_anon_client_credentials_t sc)
MHD_gnutls_anon_free_client_credentials (mhd_gtls_anon_client_credentials_t sc)
{
}
/**
* gnutls_anon_allocate_client_credentials - Used to allocate a credentials structure
* @sc: is a pointer to an #gnutls_anon_client_credentials_t structure.
* MHD_gnutls_anon_allocate_client_credentials - Used to allocate a credentials structure
* @sc: is a pointer to an #mhd_gtls_anon_client_credentials_t structure.
*
* This structure is complex enough to manipulate directly thus
* this helper function is provided in order to allocate it.
@@ -92,7 +92,7 @@ gnutls_anon_free_client_credentials (gnutls_anon_client_credentials_t sc)
* Returns: %GNUTLS_E_SUCCESS on success, or an error code.
**/
int
gnutls_anon_allocate_client_credentials (gnutls_anon_client_credentials_t *
MHD_gnutls_anon_allocate_client_credentials (mhd_gtls_anon_client_credentials_t *
sc)
{
/* anon_dummy is only there for *sc not to be null.
@@ -104,8 +104,8 @@ gnutls_anon_allocate_client_credentials (gnutls_anon_client_credentials_t *
}
/**
* gnutls_anon_set_server_dh_params - This function will set the DH parameters for a server to use
* @res: is a gnutls_anon_server_credentials_t structure
* MHD_gnutls_anon_set_server_dh_params - This function will set the DH parameters for a server to use
* @res: is a mhd_gtls_anon_server_credentials_t structure
* @dh_params: is a structure that holds diffie hellman parameters.
*
* This function will set the diffie hellman parameters for an
@@ -113,15 +113,15 @@ gnutls_anon_allocate_client_credentials (gnutls_anon_client_credentials_t *
* Anonymous Diffie Hellman cipher suites.
**/
void
gnutls_anon_set_server_dh_params (gnutls_anon_server_credentials_t res,
gnutls_dh_params_t dh_params)
MHD_gnutls_anon_set_server_dh_params (mhd_gtls_anon_server_credentials_t res,
mhd_gtls_dh_params_t dh_params)
{
res->dh_params = dh_params;
}
/**
* gnutls_anon_set_server_params_function - This function will set the DH parameters callback
* @res: is a gnutls_certificate_credentials_t structure
* MHD_gnutls_anon_set_server_params_function - This function will set the DH parameters callback
* @res: is a mhd_gtls_cert_credentials_t structure
* @func: is the function to be called
*
* This function will set a callback in order for the server to get
@@ -129,7 +129,7 @@ gnutls_anon_set_server_dh_params (gnutls_anon_server_credentials_t res,
* callback should return zero on success.
**/
void
gnutls_anon_set_server_params_function (gnutls_anon_server_credentials_t res,
MHD_gnutls_anon_set_server_params_function (mhd_gtls_anon_server_credentials_t res,
gnutls_params_function * func)
{
res->params_func = func;
+42 -42
View File
@@ -37,14 +37,14 @@
*/
/**
* gnutls_credentials_clear - Clears all the credentials previously set
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_credentials_clear - Clears all the credentials previously set
* @session: is a #mhd_gtls_session_t structure.
*
* Clears all the credentials previously set in this session.
*
**/
void
gnutls_credentials_clear (gnutls_session_t session)
MHD_gnutls_credentials_clear (mhd_gtls_session_t session)
{
if (session->key && session->key->cred)
{ /* beginning of the list */
@@ -65,8 +65,8 @@ gnutls_credentials_clear (gnutls_session_t session)
* { algorithm, credentials, pointer to next }
*/
/**
* gnutls_credentials_set - Sets the needed credentials for the specified authentication algorithm.
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_credentials_set - Sets the needed credentials for the specified authentication algorithm.
* @session: is a #mhd_gtls_session_t structure.
* @type: is the type of the credentials
* @cred: is a pointer to a structure.
*
@@ -77,20 +77,20 @@ gnutls_credentials_clear (gnutls_session_t session)
* [ In order to minimize memory usage, and share credentials between
* several threads gnutls keeps a pointer to cred, and not the whole cred
* structure. Thus you will have to keep the structure allocated until
* you call gnutls_deinit(). ]
* you call MHD_gnutls_deinit(). ]
*
* For GNUTLS_CRD_ANON cred should be gnutls_anon_client_credentials_t in case of a client.
* In case of a server it should be gnutls_anon_server_credentials_t.
* For GNUTLS_CRD_ANON cred should be mhd_gtls_anon_client_credentials_t in case of a client.
* In case of a server it should be mhd_gtls_anon_server_credentials_t.
*
* For GNUTLS_CRD_SRP cred should be gnutls_srp_client_credentials_t
* in case of a client, and gnutls_srp_server_credentials_t, in case
* of a server.
*
* For GNUTLS_CRD_CERTIFICATE cred should be gnutls_certificate_credentials_t.
* For GNUTLS_CRD_CERTIFICATE cred should be mhd_gtls_cert_credentials_t.
*
**/
int
gnutls_credentials_set (gnutls_session_t session,
MHD_gnutls_credentials_set (mhd_gtls_session_t session,
gnutls_credentials_type_t type, void *cred)
{
auth_cred_st *ccred = NULL, *pcred = NULL;
@@ -150,8 +150,8 @@ gnutls_credentials_set (gnutls_session_t session,
}
/**
* gnutls_auth_get_type - Returns the type of credentials for the current authentication schema.
* @session: is a #gnutls_session_t structure.
* MHD_gtls_auth_get_type - Returns the type of credentials for the current authentication schema.
* @session: is a #mhd_gtls_session_t structure.
*
* Returns type of credentials for the current authentication schema.
* The returned information is to be used to distinguish the function used
@@ -161,7 +161,7 @@ gnutls_credentials_set (gnutls_session_t session,
* the same function are to be used to access the authentication data.
**/
gnutls_credentials_type_t
gnutls_auth_get_type (gnutls_session_t session)
MHD_gtls_auth_get_type (mhd_gtls_session_t session)
{
/* This is not the credentials we must set, but the authentication data
* we get by the peer, so it should be reversed.
@@ -169,14 +169,14 @@ gnutls_auth_get_type (gnutls_session_t session)
int server = session->security_parameters.entity == GNUTLS_SERVER ? 0 : 1;
return
_gnutls_map_kx_get_cred (_gnutls_cipher_suite_get_kx_algo
mhd_gtls_map_kx_get_cred (mhd_gtls_cipher_suite_get_kx_algo
(&session->security_parameters.
current_cipher_suite), server);
}
/**
* gnutls_auth_server_get_type - Returns the type of credentials for the server authentication schema.
* @session: is a #gnutls_session_t structure.
* MHD_gtls_auth_server_get_type - Returns the type of credentials for the server authentication schema.
* @session: is a #mhd_gtls_session_t structure.
*
* Returns the type of credentials that were used for server authentication.
* The returned information is to be used to distinguish the function used
@@ -184,17 +184,17 @@ gnutls_auth_get_type (gnutls_session_t session)
*
**/
gnutls_credentials_type_t
gnutls_auth_server_get_type (gnutls_session_t session)
MHD_gtls_auth_server_get_type (mhd_gtls_session_t session)
{
return
_gnutls_map_kx_get_cred (_gnutls_cipher_suite_get_kx_algo
mhd_gtls_map_kx_get_cred (mhd_gtls_cipher_suite_get_kx_algo
(&session->security_parameters.
current_cipher_suite), 1);
}
/**
* gnutls_auth_client_get_type - Returns the type of credentials for the client authentication schema.
* @session: is a #gnutls_session_t structure.
* MHD_gtls_auth_client_get_type - Returns the type of credentials for the client authentication schema.
* @session: is a #mhd_gtls_session_t structure.
*
* Returns the type of credentials that were used for client authentication.
* The returned information is to be used to distinguish the function used
@@ -202,10 +202,10 @@ gnutls_auth_server_get_type (gnutls_session_t session)
*
**/
gnutls_credentials_type_t
gnutls_auth_client_get_type (gnutls_session_t session)
MHD_gtls_auth_client_get_type (mhd_gtls_session_t session)
{
return
_gnutls_map_kx_get_cred (_gnutls_cipher_suite_get_kx_algo
mhd_gtls_map_kx_get_cred (mhd_gtls_cipher_suite_get_kx_algo
(&session->security_parameters.
current_cipher_suite), 0);
}
@@ -216,17 +216,17 @@ gnutls_auth_client_get_type (gnutls_session_t session)
* free that!!!
*/
const void *
_gnutls_get_kx_cred (gnutls_session_t session,
mhd_gtls_get_kx_cred (mhd_gtls_session_t session,
gnutls_kx_algorithm_t algo, int *err)
{
int server = session->security_parameters.entity == GNUTLS_SERVER ? 1 : 0;
return _gnutls_get_cred (session->key,
_gnutls_map_kx_get_cred (algo, server), err);
return mhd_gtls_get_cred (session->key,
mhd_gtls_map_kx_get_cred (algo, server), err);
}
const void *
_gnutls_get_cred (gnutls_key_st key, gnutls_credentials_type_t type, int *err)
mhd_gtls_get_cred (mhd_gtls_key_st key, gnutls_credentials_type_t type, int *err)
{
const void *retval = NULL;
int _err = -1;
@@ -257,10 +257,10 @@ out:
}
/*-
* _gnutls_get_auth_info - Returns a pointer to authentication information.
* @session: is a #gnutls_session_t structure.
* mhd_gtls_get_auth_info - Returns a pointer to authentication information.
* @session: is a #mhd_gtls_session_t structure.
*
* This function must be called after a succesful gnutls_handshake().
* This function must be called after a succesful MHD_gnutls_handshake().
* Returns a pointer to authentication information. That information
* is data obtained by the handshake protocol, the key exchange algorithm,
* and the TLS extensions messages.
@@ -270,21 +270,21 @@ out:
* In case of GNUTLS_CRD_SRP returns a type of &srp_(server/client)_auth_info_t;
-*/
void *
_gnutls_get_auth_info (gnutls_session_t session)
mhd_gtls_get_auth_info (mhd_gtls_session_t session)
{
return session->key->auth_info;
}
/*-
* _gnutls_free_auth_info - Frees the auth info structure
* @session: is a #gnutls_session_t structure.
* mhd_gtls_free_auth_info - Frees the auth info structure
* @session: is a #mhd_gtls_session_t structure.
*
* This function frees the auth info structure and sets it to
* null. It must be called since some structures contain malloced
* elements.
-*/
void
_gnutls_free_auth_info (gnutls_session_t session)
mhd_gtls_free_auth_info (mhd_gtls_session_t session)
{
dh_info_st *dh_info;
rsa_info_st *rsa_info;
@@ -301,19 +301,19 @@ _gnutls_free_auth_info (gnutls_session_t session)
break;
case MHD_GNUTLS_CRD_ANON:
{
anon_auth_info_t info = _gnutls_get_auth_info (session);
mhd_anon_auth_info_t info = mhd_gtls_get_auth_info (session);
if (info == NULL)
break;
dh_info = &info->dh;
_gnutls_free_dh_info (dh_info);
mhd_gtls_free_dh_info (dh_info);
}
break;
case MHD_GNUTLS_CRD_CERTIFICATE:
{
unsigned int i;
cert_auth_info_t info = _gnutls_get_auth_info (session);
cert_auth_info_t info = mhd_gtls_get_auth_info (session);
if (info == NULL)
break;
@@ -329,8 +329,8 @@ _gnutls_free_auth_info (gnutls_session_t session)
info->raw_certificate_list = NULL;
info->ncerts = 0;
_gnutls_free_dh_info (dh_info);
_gnutls_free_rsa_info (rsa_info);
mhd_gtls_free_dh_info (dh_info);
mhd_gtls_free_rsa_info (rsa_info);
}
@@ -353,7 +353,7 @@ _gnutls_free_auth_info (gnutls_session_t session)
* info structure to a different type.
*/
int
_gnutls_auth_info_set (gnutls_session_t session,
mhd_gtls_auth_info_set (mhd_gtls_session_t session,
gnutls_credentials_type_t type, int size,
int allow_change)
{
@@ -378,7 +378,7 @@ _gnutls_auth_info_set (gnutls_session_t session,
* ciphersuite which is negotiated has different authentication
* schema.
*/
if (gnutls_auth_get_type (session) != session->key->auth_info_type)
if (MHD_gtls_auth_get_type (session) != session->key->auth_info_type)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
@@ -392,10 +392,10 @@ _gnutls_auth_info_set (gnutls_session_t session,
* certificate (in order to prevent revealing the certificate's contents,
* to passive eavesdropers.
*/
if (gnutls_auth_get_type (session) != session->key->auth_info_type)
if (MHD_gtls_auth_get_type (session) != session->key->auth_info_type)
{
_gnutls_free_auth_info (session);
mhd_gtls_free_auth_info (session);
session->key->auth_info = calloc (1, size);
if (session->key->auth_info == NULL)
+15 -15
View File
@@ -23,28 +23,28 @@
*/
#ifndef GNUTLS_AUTH_H
# define GNUTLS_AUTH_H
#define GNUTLS_AUTH_H
typedef struct mod_auth_st_int
typedef struct mhd_gtls_mod_auth_st_int
{
const char *name; /* null terminated */
int (*gnutls_generate_server_certificate) (gnutls_session_t, opaque **);
int (*gnutls_generate_client_certificate) (gnutls_session_t, opaque **);
int (*gnutls_generate_server_kx) (gnutls_session_t, opaque **);
int (*gnutls_generate_client_kx) (gnutls_session_t, opaque **); /* used in SRP */
int (*gnutls_generate_client_cert_vrfy) (gnutls_session_t, opaque **);
int (*gnutls_generate_server_certificate_request) (gnutls_session_t,
int (* mhd_gtls_gen_server_certificate) (mhd_gtls_session_t, opaque **);
int (* mhd_gtls_gen_client_certificate) (mhd_gtls_session_t, opaque **);
int (* mhd_gtls_gen_server_kx) (mhd_gtls_session_t, opaque **);
int (* mhd_gtls_gen_client_kx) (mhd_gtls_session_t, opaque **); /* used in SRP */
int (* mhd_gtls_gen_client_cert_vrfy) (mhd_gtls_session_t, opaque **);
int (* mhd_gtls_gen_server_certificate_request) (mhd_gtls_session_t,
opaque **);
int (*gnutls_process_server_certificate) (gnutls_session_t, opaque *,
int (* mhd_gtls_process_server_certificate) (mhd_gtls_session_t, opaque *,
size_t);
int (*gnutls_process_client_certificate) (gnutls_session_t, opaque *,
int (* mhd_gtls_process_client_certificate) (mhd_gtls_session_t, opaque *,
size_t);
int (*gnutls_process_server_kx) (gnutls_session_t, opaque *, size_t);
int (*gnutls_process_client_kx) (gnutls_session_t, opaque *, size_t);
int (*gnutls_process_client_cert_vrfy) (gnutls_session_t, opaque *, size_t);
int (*gnutls_process_server_certificate_request) (gnutls_session_t,
int (* mhd_gtls_process_server_kx) (mhd_gtls_session_t, opaque *, size_t);
int (* mhd_gtls_process_client_kx) (mhd_gtls_session_t, opaque *, size_t);
int (* mhd_gtls_process_client_cert_vrfy) (mhd_gtls_session_t, opaque *, size_t);
int (* mhd_gtls_process_server_certificate_request) (mhd_gtls_session_t,
opaque *, size_t);
} mod_auth_st;
} mhd_gtls_mod_auth_st;
#endif
+4 -4
View File
@@ -22,11 +22,11 @@
*
*/
const void *_gnutls_get_cred (gnutls_key_st key,
const void * mhd_gtls_get_cred (mhd_gtls_key_st key,
gnutls_credentials_type_t kx, int *err);
const void *_gnutls_get_kx_cred (gnutls_session_t session,
const void * mhd_gtls_get_kx_cred (mhd_gtls_session_t session,
gnutls_kx_algorithm_t algo, int *err);
void *_gnutls_get_auth_info (gnutls_session_t session);
int _gnutls_auth_info_set (gnutls_session_t session,
void * mhd_gtls_get_auth_info (mhd_gtls_session_t session);
int mhd_gtls_auth_info_set (mhd_gtls_session_t session,
gnutls_credentials_type_t type, int size,
int allow_change);
-31
View File
@@ -1,31 +0,0 @@
/*
* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation
*
* Author: Nikos Mavrogiannopoulos
*
* This file is part of GNUTLS.
*
* The GNUTLS library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA
*
*/
#include <gnutls_str.h>
typedef gnutls_string gnutls_buffer;
#define _gnutls_buffer_init(buf) _gnutls_string_init(buf, gnutls_malloc, gnutls_realloc, gnutls_free);
#define _gnutls_buffer_clear _gnutls_string_clear
#define _gnutls_buffer_append _gnutls_string_append_data
+100 -104
View File
@@ -23,19 +23,19 @@
*/
/* This is the only file that uses the berkeley sockets API.
*
*
* Also holds all the buffering code used in gnutls.
* The buffering code works as:
*
* RECORD LAYER:
* RECORD LAYER:
* 1. uses a buffer to hold data (application/handshake),
* we got but they were not requested, yet.
* (see gnutls_record_buffer_put(), gnutls_record_buffer_get_size() etc.)
*
* 2. uses a buffer to hold data that were incomplete (ie the read/write
* was interrupted)
* (see _gnutls_io_read_buffered(), _gnutls_io_write_buffered() etc.)
*
* (see mhd_gtls_io_read_buffered(), mhd_gtls_io_write_buffered() etc.)
*
* HANDSHAKE LAYER:
* 1. Uses a buffer to hold data that was not sent or received
* complete. (E.g. sent 10 bytes of a handshake packet that is 20 bytes
@@ -43,7 +43,7 @@
* (see _gnutls_handshake_send_int(), _gnutls_handshake_recv_int())
*
* 2. Uses buffer to hold the last received handshake message.
* (see _gnutls_handshake_buffer_put() etc.)
* (see mhd_gtls_handshake_buffer_put() etc.)
*
*/
@@ -68,8 +68,8 @@
#endif
/**
* gnutls_transport_set_errno:
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_transport_set_errno:
* @session: is a #mhd_gtls_session_t structure.
* @err: error value to store in session-specific errno variable.
*
* Store @err in the session-specific errno variable. Useful values
@@ -77,7 +77,7 @@
* treated as real errors in the push/pull function.
*
* This function is useful in replacement push/pull functions set by
* gnutls_transport_set_push_function and
* MHD_gnutls_transport_set_push_function and
* gnutls_transport_set_pullpush_function under Windows, where the
* replacement push/pull may not have access to the same @errno
* variable that is used by GnuTLS (e.g., the application is linked to
@@ -85,16 +85,16 @@
*
* If you don't have the @session variable easily accessible from the
* push/pull function, and don't worry about thread conflicts, you can
* also use gnutls_transport_set_global_errno().
* also use MHD_gnutls_transport_set_global_errno().
**/
void
gnutls_transport_set_errno (gnutls_session_t session, int err)
MHD_gnutls_transport_set_errno (mhd_gtls_session_t session, int err)
{
session->internals.errnum = err;
}
/**
* gnutls_transport_set_global_errno:
* MHD_gnutls_transport_set_global_errno:
* @err: error value to store in global errno variable.
*
* Store @err in the global errno variable. Useful values for @err is
@@ -102,7 +102,7 @@ gnutls_transport_set_errno (gnutls_session_t session, int err)
* errors in the push/pull function.
*
* This function is useful in replacement push/pull functions set by
* gnutls_transport_set_push_function and
* MHD_gnutls_transport_set_push_function and
* gnutls_transport_set_pullpush_function under Windows, where the
* replacement push/pull may not have access to the same @errno
* variable that is used by GnuTLS (e.g., the application is linked to
@@ -111,10 +111,10 @@ gnutls_transport_set_errno (gnutls_session_t session, int err)
* Whether this function is thread safe or not depends on whether the
* global variable errno is thread safe, some system libraries make it
* a thread-local variable. When feasible, using the guaranteed
* thread-safe gnutls_transport_set_errno() may be better.
* thread-safe MHD_gnutls_transport_set_errno() may be better.
**/
void
gnutls_transport_set_global_errno (int err)
MHD_gnutls_transport_set_global_errno (int err)
{
errno = err;
}
@@ -123,11 +123,11 @@ gnutls_transport_set_global_errno (int err)
* HANDSHAKE DATA.
*/
int
_gnutls_record_buffer_put (content_type_t type,
gnutls_session_t session,
opaque * data, size_t length)
mhd_gnutls_record_buffer_put (content_type_t type,
mhd_gtls_session_t session, opaque * data,
size_t length)
{
gnutls_buffer *buf;
mhd_gtls_buffer *buf;
if (length == 0)
return 0;
@@ -157,7 +157,7 @@ _gnutls_record_buffer_put (content_type_t type,
return GNUTLS_E_INVALID_REQUEST;
}
if (_gnutls_buffer_append (buf, data, length) < 0)
if (mhd_gtls_buffer_append (buf, data, length) < 0)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
@@ -167,7 +167,8 @@ _gnutls_record_buffer_put (content_type_t type,
}
int
_gnutls_record_buffer_get_size (content_type_t type, gnutls_session_t session)
mhd_gnutls_record_buffer_get_size (content_type_t type,
mhd_gtls_session_t session)
{
switch (type)
{
@@ -186,8 +187,8 @@ _gnutls_record_buffer_get_size (content_type_t type, gnutls_session_t session)
}
/**
* gnutls_record_check_pending - checks if there are any data to receive in gnutls buffers.
* @session: is a #gnutls_session_t structure.
* MHD_gtls_record_check_pending - checks if there are any data to receive in gnutls buffers.
* @session: is a #mhd_gtls_session_t structure.
*
* This function checks if there are any data to receive
* in the gnutls buffers. Returns the size of that data or 0.
@@ -197,15 +198,14 @@ _gnutls_record_buffer_get_size (content_type_t type, gnutls_session_t session)
* to work).
**/
size_t
gnutls_record_check_pending (gnutls_session_t session)
MHD_gtls_record_check_pending (mhd_gtls_session_t session)
{
return _gnutls_record_buffer_get_size (GNUTLS_APPLICATION_DATA, session);
return mhd_gnutls_record_buffer_get_size (GNUTLS_APPLICATION_DATA, session);
}
int
_gnutls_record_buffer_get (content_type_t type,
gnutls_session_t session,
opaque * data, size_t length)
mhd_gtls_record_buffer_get (content_type_t type, mhd_gtls_session_t session,
opaque * data, size_t length)
{
if (length == 0 || data == NULL)
{
@@ -289,8 +289,8 @@ _gnutls_record_buffer_get (content_type_t type,
* Flags are only used if the default recv() function is being used.
*/
static ssize_t
_gnutls_read (gnutls_session_t session,
void *iptr, size_t sizeOfPtr, int flags)
_gnutls_read (mhd_gtls_session_t session, void *iptr,
size_t sizeOfPtr, int flags)
{
size_t left;
ssize_t i = 0;
@@ -303,13 +303,12 @@ _gnutls_read (gnutls_session_t session,
left = sizeOfPtr;
while (left > 0)
{
session->internals.errnum = 0;
if (session->internals._gnutls_pull_func == NULL)
{
i = recv (GNUTLS_POINTER_TO_INT (fd), &ptr[sizeOfPtr - left], left,
flags);
i =
recv (GNUTLS_POINTER_TO_INT (fd), &ptr[sizeOfPtr - left], left,
flags);
#if HAVE_WINSOCK
if (i < 0)
{
@@ -333,8 +332,9 @@ _gnutls_read (gnutls_session_t session,
#endif
}
else
i = session->internals._gnutls_pull_func (fd, &ptr[sizeOfPtr -
left], left);
i = session->internals._gnutls_pull_func (fd,
&ptr[sizeOfPtr - left],
left);
if (i < 0)
{
@@ -394,14 +394,14 @@ finish:
line[0] = 0;
sprintf (tmp, "%.4x - ", x);
_gnutls_str_cat (line, sizeof (line), tmp);
mhd_gtls_str_cat (line, sizeof (line), tmp);
for (j = 0; j < 16; j++)
{
if (sum < (sizeOfPtr - left))
{
sprintf (tmp, "%.2x ", ((unsigned char *) ptr)[sum++]);
_gnutls_str_cat (line, sizeof (line), tmp);
mhd_gtls_str_cat (line, sizeof (line), tmp);
}
}
_gnutls_read_log ("%s\n", line);
@@ -417,7 +417,7 @@ finish:
* Clears the peeked data (read with MSG_PEEK).
*/
int
_gnutls_io_clear_peeked_data (gnutls_session_t session)
mhd_gtls_io_clear_peeked_data (mhd_gtls_session_t session)
{
char *peekdata;
int ret, sum;
@@ -457,7 +457,7 @@ _gnutls_io_clear_peeked_data (gnutls_session_t session)
}
void
_gnutls_io_clear_read_buffer (gnutls_session_t session)
mhd_gtls_io_clear_read_buffer (mhd_gtls_session_t session)
{
session->internals.record_recv_buffer.length = 0;
}
@@ -465,16 +465,15 @@ _gnutls_io_clear_read_buffer (gnutls_session_t session)
/* This function is like recv(with MSG_PEEK). But it does not return -1 on error.
* It does return gnutls_errno instead.
* This function reads data from the socket and keeps them in a buffer, of up to
* MAX_RECV_SIZE.
* MAX_RECV_SIZE.
*
* This is not a general purpose function. It returns EXACTLY the data requested,
* which are stored in a local (in the session) buffer. A pointer (iptr) to this buffer is returned.
*
*/
ssize_t
_gnutls_io_read_buffered (gnutls_session_t session,
opaque ** iptr,
size_t sizeOfPtr, content_type_t recv_type)
mhd_gtls_io_read_buffered (mhd_gtls_session_t session, opaque ** iptr,
size_t sizeOfPtr, content_type_t recv_type)
{
ssize_t ret = 0, ret2 = 0;
size_t min;
@@ -501,7 +500,7 @@ _gnutls_io_read_buffered (gnutls_session_t session,
else
{
/* leave peeked data to the kernel space only if application data
* is received and we don't have any peeked
* is received and we don't have any peeked
* data in gnutls session.
*/
if (recv_type != GNUTLS_APPLICATION_DATA
@@ -534,8 +533,8 @@ _gnutls_io_read_buffered (gnutls_session_t session,
/* Check if the previously read data plus the new data to
* receive are longer than the maximum receive buffer size.
*/
if ((session->internals.record_recv_buffer.length + recvdata) >
MAX_RECV_SIZE)
if ((session->internals.record_recv_buffer.length + recvdata)
> MAX_RECV_SIZE)
{
gnutls_assert (); /* internal error */
return GNUTLS_E_INVALID_REQUEST;
@@ -544,8 +543,8 @@ _gnutls_io_read_buffered (gnutls_session_t session,
/* Allocate the data required to store the new packet.
*/
alloc_size = recvdata + session->internals.record_recv_buffer.length;
session->internals.record_recv_buffer.data
= gnutls_realloc_fast (session->internals.record_recv_buffer.data,
session->internals.record_recv_buffer.data =
mhd_gtls_realloc_fast (session->internals.record_recv_buffer.data,
alloc_size);
if (session->internals.record_recv_buffer.data == NULL)
{
@@ -565,7 +564,7 @@ _gnutls_io_read_buffered (gnutls_session_t session,
/* return immediately if we got an interrupt or eagain
* error.
*/
if (ret < 0 && gnutls_error_is_fatal (ret) == 0)
if (ret < 0 && MHD_gtls_error_is_fatal (ret) == 0)
{
return ret;
}
@@ -592,7 +591,7 @@ _gnutls_io_read_buffered (gnutls_session_t session,
{
ret2 = _gnutls_read (session, &buf[buf_pos], recvlowat, MSG_PEEK);
if (ret2 < 0 && gnutls_error_is_fatal (ret2) == 0)
if (ret2 < 0 && MHD_gtls_error_is_fatal (ret2) == 0)
{
return ret2;
}
@@ -652,7 +651,7 @@ _gnutls_io_read_buffered (gnutls_session_t session,
#define MEMSUB(x,y) ((ssize_t)((ptrdiff_t)x-(ptrdiff_t)y))
inline static int
_gnutls_buffer_insert (gnutls_buffer * buffer,
_gnutls_buffer_insert (mhd_gtls_buffer * buffer,
const opaque * _data, size_t data_size)
{
@@ -681,7 +680,7 @@ _gnutls_buffer_insert (gnutls_buffer * buffer,
}
if (_gnutls_buffer_append (buffer, _data, data_size) < 0)
if (mhd_gtls_buffer_append (buffer, _data, data_size) < 0)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
@@ -691,7 +690,7 @@ _gnutls_buffer_insert (gnutls_buffer * buffer,
}
inline static int
_gnutls_buffer_get (gnutls_buffer * buffer,
_gnutls_buffer_get (mhd_gtls_buffer * buffer,
const opaque ** ptr, size_t * ptr_size)
{
*ptr_size = buffer->length;
@@ -708,12 +707,12 @@ _gnutls_buffer_get (gnutls_buffer * buffer,
*
* We need to push exactly the data in n, since we cannot send less
* data. In TLS the peer must receive the whole packet in order
* to decrypt and verify the integrity.
* to decrypt and verify the integrity.
*
*/
ssize_t
_gnutls_io_write_buffered (gnutls_session_t session,
const void *iptr, size_t n)
mhd_gtls_io_write_buffered (mhd_gtls_session_t session,
const void *iptr, size_t n)
{
size_t left;
unsigned j, x, sum = 0;
@@ -743,9 +742,8 @@ _gnutls_io_write_buffered (gnutls_session_t session,
if (iptr == NULL)
{
/* checking is handled above */
ret
=
_gnutls_buffer_get (&session->internals.record_send_buffer, &ptr, &n);
ret = _gnutls_buffer_get (&session->internals.record_send_buffer, &ptr,
&n);
if (ret < 0)
{
gnutls_assert ();
@@ -843,14 +841,14 @@ _gnutls_io_write_buffered (gnutls_session_t session,
break;
sprintf (tmp, "%.4x - ", x);
_gnutls_str_cat (line, sizeof (line), tmp);
mhd_gtls_str_cat (line, sizeof (line), tmp);
for (j = 0; j < 16; j++)
{
if (sum < n - left)
{
sprintf (tmp, "%.2x ", ((unsigned char *) ptr)[sum++]);
_gnutls_str_cat (line, sizeof (line), tmp);
mhd_gtls_str_cat (line, sizeof (line), tmp);
}
else
break;
@@ -874,14 +872,14 @@ _gnutls_io_write_buffered (gnutls_session_t session,
* interrupted.
*/
ssize_t
_gnutls_io_write_flush (gnutls_session_t session)
mhd_gtls_io_write_flush (mhd_gtls_session_t session)
{
ssize_t ret;
if (session->internals.record_send_buffer.length == 0)
return 0; /* done */
ret = _gnutls_io_write_buffered (session, NULL, 0);
ret = mhd_gtls_io_write_buffered (session, NULL, 0);
_gnutls_write_log ("WRITE FLUSH: %d [buffer: %d]\n", ret,
session->internals.record_send_buffer.length);
@@ -893,10 +891,10 @@ _gnutls_io_write_flush (gnutls_session_t session)
* interrupted.
*/
ssize_t
_gnutls_handshake_io_write_flush (gnutls_session_t session)
mhd_gtls_handshake_io_write_flush (mhd_gtls_session_t session)
{
ssize_t ret;
ret = _gnutls_handshake_io_send_int (session, 0, 0, NULL, 0);
ret = mhd_gtls_handshake_io_send_int (session, 0, 0, NULL, 0);
if (ret < 0)
{
gnutls_assert ();
@@ -914,14 +912,14 @@ _gnutls_handshake_io_write_flush (gnutls_session_t session)
return ret;
}
/* This is a send function for the gnutls handshake
/* This is a send function for the gnutls handshake
* protocol. Just makes sure that all data have been sent.
*/
ssize_t
_gnutls_handshake_io_send_int (gnutls_session_t session,
content_type_t type,
gnutls_handshake_description_t htype,
const void *iptr, size_t n)
mhd_gtls_handshake_io_send_int (mhd_gtls_session_t session,
content_type_t type,
gnutls_handshake_description_t htype,
const void *iptr, size_t n)
{
size_t left;
ssize_t ret = 0;
@@ -936,9 +934,8 @@ _gnutls_handshake_io_send_int (gnutls_session_t session,
/* resuming previously interrupted write
*/
gnutls_assert ();
ret =
_gnutls_buffer_get (&session->internals.handshake_send_buffer, &ptr,
&n);
ret = _gnutls_buffer_get (&session->internals.handshake_send_buffer,
&ptr, &n);
if (ret < 0)
{
gnutls_assert ();
@@ -996,7 +993,7 @@ _gnutls_handshake_io_send_int (gnutls_session_t session,
left = n;
while (left > 0)
{
ret = _gnutls_send_int (session, type, htype, &ptr[n - left], left);
ret = mhd_gtls_send_int (session, type, htype, &ptr[n - left], left);
if (ret <= 0)
{
@@ -1006,14 +1003,15 @@ _gnutls_handshake_io_send_int (gnutls_session_t session,
ret = GNUTLS_E_INTERNAL_ERROR;
}
if (left > 0
&& (ret == GNUTLS_E_INTERRUPTED || ret == GNUTLS_E_AGAIN))
if (left > 0 && (ret == GNUTLS_E_INTERRUPTED || ret
== GNUTLS_E_AGAIN))
{
gnutls_assert ();
retval = _gnutls_buffer_insert (&session->internals.
handshake_send_buffer,
&ptr[n - left], left);
retval =
_gnutls_buffer_insert (&session->internals.
handshake_send_buffer, &ptr[n - left],
left);
if (retval < 0)
{
gnutls_assert ();
@@ -1047,14 +1045,14 @@ _gnutls_handshake_io_send_int (gnutls_session_t session,
}
/* This is a receive function for the gnutls handshake
/* This is a receive function for the gnutls handshake
* protocol. Makes sure that we have received all data.
*/
ssize_t
_gnutls_handshake_io_recv_int (gnutls_session_t session,
content_type_t type,
gnutls_handshake_description_t htype,
void *iptr, size_t sizeOfPtr)
mhd_gtls_handshake_io_recv_int (mhd_gtls_session_t session,
content_type_t type,
gnutls_handshake_description_t htype,
void *iptr, size_t sizeOfPtr)
{
size_t left;
ssize_t i;
@@ -1084,8 +1082,7 @@ _gnutls_handshake_io_recv_int (gnutls_session_t session,
session->internals.handshake_recv_buffer.length -= sizeOfPtr;
memmove (session->internals.handshake_recv_buffer.data,
&session->internals.handshake_recv_buffer.
data[sizeOfPtr],
&session->internals.handshake_recv_buffer.data[sizeOfPtr],
session->internals.handshake_recv_buffer.length);
return sizeOfPtr;
@@ -1105,7 +1102,7 @@ _gnutls_handshake_io_recv_int (gnutls_session_t session,
while (left > 0)
{
dsize = sizeOfPtr - left;
i = _gnutls_recv_int (session, type, htype, &ptr[dsize], left);
i = mhd_gtls_recv_int (session, type, htype, &ptr[dsize], left);
if (i < 0)
{
@@ -1114,7 +1111,8 @@ _gnutls_handshake_io_recv_int (gnutls_session_t session,
gnutls_assert ();
session->internals.handshake_recv_buffer.data
= gnutls_realloc_fast (session->internals.
=
mhd_gtls_realloc_fast (session->internals.
handshake_recv_buffer.data, dsize);
if (session->internals.handshake_recv_buffer.data == NULL)
{
@@ -1157,15 +1155,16 @@ _gnutls_handshake_io_recv_int (gnutls_session_t session,
* and finished messages.
*/
int
_gnutls_handshake_buffer_put (gnutls_session_t session,
opaque * data, size_t length)
mhd_gtls_handshake_buffer_put (mhd_gtls_session_t session, opaque * data,
size_t length)
{
if (length == 0)
return 0;
if ((session->internals.max_handshake_data_buffer_size > 0) && ((length
+ session->
+
session->
internals.
handshake_hash_buffer.
length) >
@@ -1179,8 +1178,8 @@ _gnutls_handshake_buffer_put (gnutls_session_t session,
_gnutls_buffers_log ("BUF[HSK]: Inserted %d bytes of Data\n", length);
if (_gnutls_buffer_append (&session->internals.handshake_hash_buffer, data,
length) < 0)
if (mhd_gtls_buffer_append (&session->internals.handshake_hash_buffer, data,
length) < 0)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
@@ -1190,7 +1189,7 @@ _gnutls_handshake_buffer_put (gnutls_session_t session,
}
int
_gnutls_handshake_buffer_get_size (gnutls_session_t session)
mhd_gtls_handshake_buffer_get_size (mhd_gtls_session_t session)
{
return session->internals.handshake_hash_buffer.length;
@@ -1200,8 +1199,8 @@ _gnutls_handshake_buffer_get_size (gnutls_session_t session)
* and returns data from it (peek mode!)
*/
int
_gnutls_handshake_buffer_peek (gnutls_session_t session,
opaque * data, size_t length)
mhd_gtls_handshake_buffer_peek (mhd_gtls_session_t session, opaque * data,
size_t length)
{
if (length > session->internals.handshake_hash_buffer.length)
{
@@ -1218,8 +1217,8 @@ _gnutls_handshake_buffer_peek (gnutls_session_t session,
* and returns data from it (peek mode!)
*/
int
_gnutls_handshake_buffer_get_ptr (gnutls_session_t session,
opaque ** data_ptr, size_t * length)
mhd_gtls_handshake_buffer_get_ptr (mhd_gtls_session_t session,
opaque ** data_ptr, size_t * length)
{
if (length != NULL)
*length = session->internals.handshake_hash_buffer.length;
@@ -1235,7 +1234,7 @@ _gnutls_handshake_buffer_get_ptr (gnutls_session_t session,
/* Does not free the buffer
*/
int
_gnutls_handshake_buffer_empty (gnutls_session_t session)
mhd_gtls_handshake_buffer_empty (mhd_gtls_session_t session)
{
_gnutls_buffers_log ("BUF[HSK]: Emptied buffer\n");
@@ -1246,12 +1245,9 @@ _gnutls_handshake_buffer_empty (gnutls_session_t session)
}
int
_gnutls_handshake_buffer_clear (gnutls_session_t session)
mhd_gtls_handshake_buffer_clear (mhd_gtls_session_t session)
{
_gnutls_buffers_log ("BUF[HSK]: Cleared Data from buffer\n");
_gnutls_buffer_clear (&session->internals.handshake_hash_buffer);
mhd_gtls_buffer_clear (&session->internals.handshake_hash_buffer);
return 0;
}
+24 -24
View File
@@ -22,46 +22,46 @@
*
*/
int _gnutls_record_buffer_put (content_type_t type,
gnutls_session_t session, opaque * data,
int mhd_gnutls_record_buffer_put (content_type_t type,
mhd_gtls_session_t session, opaque * data,
size_t length);
int _gnutls_record_buffer_get_size (content_type_t type,
gnutls_session_t session);
int _gnutls_record_buffer_get (content_type_t type,
gnutls_session_t session, opaque * data,
int mhd_gnutls_record_buffer_get_size (content_type_t type,
mhd_gtls_session_t session);
int mhd_gtls_record_buffer_get (content_type_t type,
mhd_gtls_session_t session, opaque * data,
size_t length);
ssize_t _gnutls_io_read_buffered (gnutls_session_t, opaque ** iptr,
ssize_t mhd_gtls_io_read_buffered (mhd_gtls_session_t, opaque ** iptr,
size_t n, content_type_t);
void _gnutls_io_clear_read_buffer (gnutls_session_t);
int _gnutls_io_clear_peeked_data (gnutls_session_t session);
void mhd_gtls_io_clear_read_buffer (mhd_gtls_session_t);
int mhd_gtls_io_clear_peeked_data (mhd_gtls_session_t session);
ssize_t _gnutls_io_write_buffered (gnutls_session_t, const void *iptr,
ssize_t mhd_gtls_io_write_buffered (mhd_gtls_session_t, const void *iptr,
size_t n);
ssize_t _gnutls_io_write_buffered2 (gnutls_session_t, const void *iptr,
ssize_t mhd_gtls_io_write_buffered2 (mhd_gtls_session_t, const void *iptr,
size_t n, const void *iptr2, size_t n2);
int _gnutls_handshake_buffer_get_size (gnutls_session_t session);
int _gnutls_handshake_buffer_peek (gnutls_session_t session, opaque * data,
int mhd_gtls_handshake_buffer_get_size (mhd_gtls_session_t session);
int mhd_gtls_handshake_buffer_peek (mhd_gtls_session_t session, opaque * data,
size_t length);
int _gnutls_handshake_buffer_put (gnutls_session_t session, opaque * data,
int mhd_gtls_handshake_buffer_put (mhd_gtls_session_t session, opaque * data,
size_t length);
int _gnutls_handshake_buffer_clear (gnutls_session_t session);
int _gnutls_handshake_buffer_empty (gnutls_session_t session);
int _gnutls_handshake_buffer_get_ptr (gnutls_session_t session,
int mhd_gtls_handshake_buffer_clear (mhd_gtls_session_t session);
int mhd_gtls_handshake_buffer_empty (mhd_gtls_session_t session);
int mhd_gtls_handshake_buffer_get_ptr (mhd_gtls_session_t session,
opaque ** data_ptr, size_t * length);
#define _gnutls_handshake_io_buffer_clear( session) \
_gnutls_buffer_clear( &session->internals.handshake_send_buffer); \
_gnutls_buffer_clear( &session->internals.handshake_recv_buffer); \
mhd_gtls_buffer_clear( &session->internals.handshake_send_buffer); \
mhd_gtls_buffer_clear( &session->internals.handshake_recv_buffer); \
session->internals.handshake_send_buffer_prev_size = 0
ssize_t _gnutls_handshake_io_recv_int (gnutls_session_t, content_type_t,
ssize_t mhd_gtls_handshake_io_recv_int (mhd_gtls_session_t, content_type_t,
gnutls_handshake_description_t, void *,
size_t);
ssize_t _gnutls_handshake_io_send_int (gnutls_session_t, content_type_t,
ssize_t mhd_gtls_handshake_io_send_int (mhd_gtls_session_t, content_type_t,
gnutls_handshake_description_t,
const void *, size_t);
ssize_t _gnutls_io_write_flush (gnutls_session_t session);
ssize_t _gnutls_handshake_io_write_flush (gnutls_session_t session);
ssize_t mhd_gtls_io_write_flush (mhd_gtls_session_t session);
ssize_t mhd_gtls_handshake_io_write_flush (mhd_gtls_session_t session);
size_t gnutls_record_check_pending (gnutls_session_t session);
size_t MHD_gtls_record_check_pending (mhd_gtls_session_t session);
+76 -76
View File
@@ -46,8 +46,8 @@
#include "mpi.h"
/**
* gnutls_certificate_free_keys - Used to free all the keys from a gnutls_certificate_credentials_t structure
* @sc: is an #gnutls_certificate_credentials_t structure.
* MHD_gnutls_certificate_free_keys - Used to free all the keys from a mhd_gtls_cert_credentials_t structure
* @sc: is an #mhd_gtls_cert_credentials_t structure.
*
* This function will delete all the keys and the certificates associated
* with the given credentials. This function must not be called when a
@@ -55,7 +55,7 @@
*
**/
void
gnutls_certificate_free_keys (gnutls_certificate_credentials_t sc)
MHD_gnutls_certificate_free_keys (mhd_gtls_cert_credentials_t sc)
{
unsigned i, j;
@@ -63,7 +63,7 @@ gnutls_certificate_free_keys (gnutls_certificate_credentials_t sc)
{
for (j = 0; j < sc->cert_list_length[i]; j++)
{
_gnutls_gcert_deinit (&sc->cert_list[i][j]);
mhd_gtls_gcert_deinit (&sc->cert_list[i][j]);
}
gnutls_free (sc->cert_list[i]);
}
@@ -76,7 +76,7 @@ gnutls_certificate_free_keys (gnutls_certificate_credentials_t sc)
for (i = 0; i < sc->ncerts; i++)
{
_gnutls_gkey_deinit (&sc->pkey[i]);
mhd_gtls_gkey_deinit (&sc->pkey[i]);
}
gnutls_free (sc->pkey);
@@ -87,17 +87,17 @@ gnutls_certificate_free_keys (gnutls_certificate_credentials_t sc)
}
/**
* gnutls_certificate_free_cas - Used to free all the CAs from a gnutls_certificate_credentials_t structure
* @sc: is an #gnutls_certificate_credentials_t structure.
* MHD_gnutls_certificate_free_cas - Used to free all the CAs from a mhd_gtls_cert_credentials_t structure
* @sc: is an #mhd_gtls_cert_credentials_t structure.
*
* This function will delete all the CAs associated
* with the given credentials. Servers that do not use
* gnutls_certificate_verify_peers2() may call this to
* MHD_gtls_certificate_verify_peers2() may call this to
* save some memory.
*
**/
void
gnutls_certificate_free_cas (gnutls_certificate_credentials_t sc)
MHD_gnutls_certificate_free_cas (mhd_gtls_cert_credentials_t sc)
{
unsigned j;
@@ -114,8 +114,8 @@ gnutls_certificate_free_cas (gnutls_certificate_credentials_t sc)
}
/**
* gnutls_certificate_free_ca_names - Used to free all the CA names from a gnutls_certificate_credentials_t structure
* @sc: is an #gnutls_certificate_credentials_t structure.
* MHD_gnutls_certificate_free_ca_names - Used to free all the CA names from a mhd_gtls_cert_credentials_t structure
* @sc: is an #mhd_gtls_cert_credentials_t structure.
*
* This function will delete all the CA name in the
* given credentials. Clients may call this to save some memory
@@ -126,13 +126,13 @@ gnutls_certificate_free_cas (gnutls_certificate_credentials_t sc)
*
**/
void
gnutls_certificate_free_ca_names (gnutls_certificate_credentials_t sc)
MHD_gnutls_certificate_free_ca_names (mhd_gtls_cert_credentials_t sc)
{
_gnutls_free_datum (&sc->x509_rdn_sequence);
}
/*-
* _gnutls_certificate_get_rsa_params - Returns the RSA parameters pointer
* mhd_gtls_certificate_get_rsa_params - Returns the RSA parameters pointer
* @rsa_params: holds the RSA parameters or NULL.
* @func: function to retrieve the parameters or NULL.
* @session: The session.
@@ -140,10 +140,10 @@ gnutls_certificate_free_ca_names (gnutls_certificate_credentials_t sc)
* This function will return the rsa parameters pointer.
*
-*/
gnutls_rsa_params_t
_gnutls_certificate_get_rsa_params (gnutls_rsa_params_t rsa_params,
mhd_gtls_rsa_params_t
mhd_gtls_certificate_get_rsa_params (mhd_gtls_rsa_params_t rsa_params,
gnutls_params_function * func,
gnutls_session_t session)
mhd_gtls_session_t session)
{
gnutls_params_st params;
int ret;
@@ -172,8 +172,8 @@ _gnutls_certificate_get_rsa_params (gnutls_rsa_params_t rsa_params,
/**
* gnutls_certificate_free_credentials - Used to free an allocated gnutls_certificate_credentials_t structure
* @sc: is an #gnutls_certificate_credentials_t structure.
* MHD_gnutls_certificate_free_credentials - Used to free an allocated mhd_gtls_cert_credentials_t structure
* @sc: is an #mhd_gtls_cert_credentials_t structure.
*
* This structure is complex enough to manipulate directly thus
* this helper function is provided in order to free (deallocate) it.
@@ -183,13 +183,13 @@ _gnutls_certificate_get_rsa_params (gnutls_rsa_params_t rsa_params,
* this function).
**/
void
gnutls_certificate_free_credentials (gnutls_certificate_credentials_t sc)
MHD_gnutls_certificate_free_credentials (mhd_gtls_cert_credentials_t sc)
{
gnutls_certificate_free_keys (sc);
gnutls_certificate_free_cas (sc);
gnutls_certificate_free_ca_names (sc);
MHD_gnutls_certificate_free_keys (sc);
MHD_gnutls_certificate_free_cas (sc);
MHD_gnutls_certificate_free_ca_names (sc);
#ifdef ENABLE_PKI
gnutls_certificate_free_crls (sc);
MHD_gnutls_certificate_free_crls (sc);
#endif
#ifndef KEYRING_HACK
@@ -204,8 +204,8 @@ gnutls_certificate_free_credentials (gnutls_certificate_credentials_t sc)
/**
* gnutls_certificate_allocate_credentials - Used to allocate a gnutls_certificate_credentials_t structure
* @res: is a pointer to an #gnutls_certificate_credentials_t structure.
* MHD_gnutls_certificate_allocate_credentials - Used to allocate a mhd_gtls_cert_credentials_t structure
* @res: is a pointer to an #mhd_gtls_cert_credentials_t structure.
*
* This structure is complex enough to manipulate directly thus this
* helper function is provided in order to allocate it.
@@ -213,7 +213,7 @@ gnutls_certificate_free_credentials (gnutls_certificate_credentials_t sc)
* Returns: %GNUTLS_E_SUCCESS on success, or an error code.
**/
int
gnutls_certificate_allocate_credentials (gnutls_certificate_credentials_t *
MHD_gnutls_certificate_allocate_credentials (mhd_gtls_cert_credentials_t *
res)
{
*res = gnutls_calloc (1, sizeof (certificate_credentials_st));
@@ -235,7 +235,7 @@ gnutls_certificate_allocate_credentials (gnutls_certificate_credentials_t *
* extensions in order to disable unneded algorithms.
*/
int
_gnutls_selected_cert_supported_kx (gnutls_session_t session,
mhd_gtls_selected_cert_supported_kx (mhd_gtls_session_t session,
gnutls_kx_algorithm_t ** alg,
int *alg_size)
{
@@ -257,7 +257,7 @@ _gnutls_selected_cert_supported_kx (gnutls_session_t session,
for (kx = 0; kx < MAX_ALGOS; kx++)
{
pk = _gnutls_map_pk_get_pk (kx);
pk = mhd_gtls_map_pk_get_pk (kx);
if (pk == cert->subject_pk_algorithm)
{
/* then check key usage */
@@ -288,8 +288,8 @@ _gnutls_selected_cert_supported_kx (gnutls_session_t session,
/**
* gnutls_certificate_server_set_request - Used to set whether to request a client certificate
* @session: is an #gnutls_session_t structure.
* MHD_gtls_certificate_server_set_request - Used to set whether to request a client certificate
* @session: is an #mhd_gtls_session_t structure.
* @req: is one of GNUTLS_CERT_REQUEST, GNUTLS_CERT_REQUIRE
*
* This function specifies if we (in case of a server) are going
@@ -300,21 +300,21 @@ _gnutls_selected_cert_supported_kx (gnutls_session_t session,
* send a certificate.
**/
void
gnutls_certificate_server_set_request (gnutls_session_t session,
MHD_gtls_certificate_server_set_request (mhd_gtls_session_t session,
gnutls_certificate_request_t req)
{
session->internals.send_cert_req = req;
}
/**
* gnutls_certificate_client_set_retrieve_function - Used to set a callback to retrieve the certificate
* @cred: is a #gnutls_certificate_credentials_t structure.
* MHD_gtls_certificate_client_set_retrieve_function - Used to set a callback to retrieve the certificate
* @cred: is a #mhd_gtls_cert_credentials_t structure.
* @func: is the callback function
*
* This function sets a callback to be called in order to retrieve the certificate
* to be used in the handshake.
* The callback's function prototype is:
* int (*callback)(gnutls_session_t, const gnutls_datum_t* req_ca_dn, int nreqs,
* int (*callback)(mhd_gtls_session_t, const gnutls_datum_t* req_ca_dn, int nreqs,
* const gnutls_pk_algorithm_t* pk_algos, int pk_algos_length, gnutls_retr_st* st);
*
* @req_ca_cert is only used in X.509 certificates.
@@ -336,22 +336,22 @@ gnutls_certificate_server_set_request (gnutls_session_t session,
* should be set to zero. The value (-1) indicates error and the handshake
* will be terminated.
**/
void gnutls_certificate_client_set_retrieve_function
(gnutls_certificate_credentials_t cred,
void MHD_gtls_certificate_client_set_retrieve_function
(mhd_gtls_cert_credentials_t cred,
gnutls_certificate_client_retrieve_function * func)
{
cred->client_get_cert_callback = func;
}
/**
* gnutls_certificate_server_set_retrieve_function - Used to set a callback to retrieve the certificate
* @cred: is a #gnutls_certificate_credentials_t structure.
* MHD_gtls_certificate_server_set_retrieve_function - Used to set a callback to retrieve the certificate
* @cred: is a #mhd_gtls_cert_credentials_t structure.
* @func: is the callback function
*
* This function sets a callback to be called in order to retrieve the certificate
* to be used in the handshake.
* The callback's function prototype is:
* int (*callback)(gnutls_session_t, gnutls_retr_st* st);
* int (*callback)(mhd_gtls_session_t, gnutls_retr_st* st);
*
* @st should contain the certificates and private keys.
*
@@ -362,8 +362,8 @@ void gnutls_certificate_client_set_retrieve_function
* return 0 on success. The value (-1) indicates error and the handshake
* will be terminated.
**/
void gnutls_certificate_server_set_retrieve_function
(gnutls_certificate_credentials_t cred,
void MHD_gtls_certificate_server_set_retrieve_function
(mhd_gtls_cert_credentials_t cred,
gnutls_certificate_server_retrieve_function * func)
{
cred->server_get_cert_callback = func;
@@ -446,21 +446,21 @@ _gnutls_x509_get_raw_crt_expiration_time (const gnutls_datum_t * cert)
*
-*/
int
_gnutls_openpgp_crt_verify_peers (gnutls_session_t session,
_gnutls_openpgp_crt_verify_peers (mhd_gtls_session_t session,
unsigned int *status)
{
cert_auth_info_t info;
gnutls_certificate_credentials_t cred;
mhd_gtls_cert_credentials_t cred;
int peer_certificate_list_size, ret;
CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
info = _gnutls_get_auth_info (session);
info = mhd_gtls_get_auth_info (session);
if (info == NULL)
return GNUTLS_E_INVALID_REQUEST;
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
cred = (mhd_gtls_cert_credentials_t)
mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
@@ -506,7 +506,7 @@ _gnutls_openpgp_crt_verify_peers (gnutls_session_t session,
/**
* gnutls_certificate_verify_peers2 - This function returns the peer's certificate verification status
* MHD_gtls_certificate_verify_peers2 - This function returns the peer's certificate verification status
* @session: is a gnutls session
* @status: is the output of the verification
*
@@ -516,7 +516,7 @@ _gnutls_openpgp_crt_verify_peers (gnutls_session_t session,
* elements bitwise or'd. To avoid denial of service attacks some
* default upper limits regarding the certificate key size and chain
* size are set. To override them use
* gnutls_certificate_set_verify_limits().
* MHD_gnutls_certificate_set_verify_limits().
*
* Note that you must also check the peer's name in order to check if
* the verified certificate belongs to the actual peer.
@@ -526,20 +526,20 @@ _gnutls_openpgp_crt_verify_peers (gnutls_session_t session,
*
* Note that some commonly used X.509 Certificate Authorities are
* still using Version 1 certificates. If you want to accept them,
* you need to call gnutls_certificate_set_verify_flags() with, e.g.,
* you need to call MHD_gnutls_certificate_set_verify_flags() with, e.g.,
* %GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT parameter.
*
* Returns: a negative error code on error and zero on success.
**/
int
gnutls_certificate_verify_peers2 (gnutls_session_t session,
MHD_gtls_certificate_verify_peers2 (mhd_gtls_session_t session,
unsigned int *status)
{
cert_auth_info_t info;
CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
info = _gnutls_get_auth_info (session);
info = mhd_gtls_get_auth_info (session);
if (info == NULL)
{
return GNUTLS_E_NO_CERTIFICATE_FOUND;
@@ -560,7 +560,7 @@ gnutls_certificate_verify_peers2 (gnutls_session_t session,
}
/**
* gnutls_certificate_verify_peers - This function returns the peer's certificate verification status
* MHD_gtls_certificate_verify_peers - This function returns the peer's certificate verification status
* @session: is a gnutls session
*
* This function will try to verify the peer's certificate and return
@@ -574,15 +574,15 @@ gnutls_certificate_verify_peers2 (gnutls_session_t session,
*
* This is the same as gnutls_x509_crt_list_verify().
*
* Deprecated: Use gnutls_certificate_verify_peers2() instead.
* Deprecated: Use MHD_gtls_certificate_verify_peers2() instead.
**/
int
gnutls_certificate_verify_peers (gnutls_session_t session)
MHD_gtls_certificate_verify_peers (mhd_gtls_session_t session)
{
unsigned int status;
int ret;
ret = gnutls_certificate_verify_peers2 (session, &status);
ret = MHD_gtls_certificate_verify_peers2 (session, &status);
if (ret < 0)
{
@@ -594,7 +594,7 @@ gnutls_certificate_verify_peers (gnutls_session_t session)
}
/**
* gnutls_certificate_expiration_time_peers - This function returns the peer's certificate expiration time
* MHD_gtls_certificate_expiration_time_peers - This function returns the peer's certificate expiration time
* @session: is a gnutls session
*
* This function will return the peer's certificate expiration time.
@@ -602,13 +602,13 @@ gnutls_certificate_verify_peers (gnutls_session_t session)
* Returns: (time_t)-1 on error.
**/
time_t
gnutls_certificate_expiration_time_peers (gnutls_session_t session)
MHD_gtls_certificate_expiration_time_peers (mhd_gtls_session_t session)
{
cert_auth_info_t info;
CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
info = _gnutls_get_auth_info (session);
info = mhd_gtls_get_auth_info (session);
if (info == NULL)
{
return (time_t) - 1;
@@ -638,7 +638,7 @@ gnutls_certificate_expiration_time_peers (gnutls_session_t session)
}
/**
* gnutls_certificate_activation_time_peers - This function returns the peer's certificate activation time
* MHD_gtls_certificate_activation_time_peers - This function returns the peer's certificate activation time
* @session: is a gnutls session
*
* This function will return the peer's certificate activation time.
@@ -647,13 +647,13 @@ gnutls_certificate_expiration_time_peers (gnutls_session_t session)
* Returns: (time_t)-1 on error.
**/
time_t
gnutls_certificate_activation_time_peers (gnutls_session_t session)
MHD_gtls_certificate_activation_time_peers (mhd_gtls_session_t session)
{
cert_auth_info_t info;
CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
info = _gnutls_get_auth_info (session);
info = mhd_gtls_get_auth_info (session);
if (info == NULL)
{
return (time_t) - 1;
@@ -683,7 +683,7 @@ gnutls_certificate_activation_time_peers (gnutls_session_t session)
}
int
_gnutls_raw_cert_to_gcert (gnutls_cert * gcert,
mhd_gtls_raw_cert_to_gcert (gnutls_cert * gcert,
gnutls_certificate_type_t type,
const gnutls_datum_t * raw_cert,
int flags /* OR of ConvFlags */ )
@@ -691,7 +691,7 @@ _gnutls_raw_cert_to_gcert (gnutls_cert * gcert,
switch (type)
{
case MHD_GNUTLS_CRT_X509:
return _gnutls_x509_raw_cert_to_gcert (gcert, raw_cert, flags);
return mhd_gtls_x509_raw_cert_to_gcert (gcert, raw_cert, flags);
case MHD_GNUTLS_CRT_OPENPGP:
if (_E_gnutls_openpgp_raw_key_to_gcert == NULL)
{
@@ -706,7 +706,7 @@ _gnutls_raw_cert_to_gcert (gnutls_cert * gcert,
}
int
_gnutls_raw_privkey_to_gkey (gnutls_privkey * key,
mhd_gtls_raw_privkey_to_gkey (gnutls_privkey * key,
gnutls_certificate_type_t type,
const gnutls_datum_t * raw_key,
int key_enc /* DER or PEM */ )
@@ -741,7 +741,7 @@ _gnutls_raw_privkey_to_gkey (gnutls_privkey * key,
* The critical extensions will be catched by the verification functions.
*/
int
_gnutls_x509_raw_cert_to_gcert (gnutls_cert * gcert,
mhd_gtls_x509_raw_cert_to_gcert (gnutls_cert * gcert,
const gnutls_datum_t * derCert,
int flags /* OR of ConvFlags */ )
{
@@ -763,7 +763,7 @@ _gnutls_x509_raw_cert_to_gcert (gnutls_cert * gcert,
return ret;
}
ret = _gnutls_x509_crt_to_gcert (gcert, cert, flags);
ret = mhd_gtls_x509_crt_to_gcert (gcert, cert, flags);
gnutls_x509_crt_deinit (cert);
return ret;
@@ -772,7 +772,7 @@ _gnutls_x509_raw_cert_to_gcert (gnutls_cert * gcert,
/* Like above but it accepts a parsed certificate instead.
*/
int
_gnutls_x509_crt_to_gcert (gnutls_cert * gcert,
mhd_gtls_x509_crt_to_gcert (gnutls_cert * gcert,
gnutls_x509_crt_t cert, unsigned int flags)
{
int ret = 0;
@@ -857,7 +857,7 @@ _gnutls_x509_crt_to_gcert (gnutls_cert * gcert,
}
void
_gnutls_gcert_deinit (gnutls_cert * cert)
mhd_gtls_gcert_deinit (gnutls_cert * cert)
{
int i;
@@ -866,21 +866,21 @@ _gnutls_gcert_deinit (gnutls_cert * cert)
for (i = 0; i < cert->params_size; i++)
{
_gnutls_mpi_release (&cert->params[i]);
mhd_gtls_mpi_release (&cert->params[i]);
}
_gnutls_free_datum (&cert->raw);
}
/**
* gnutls_sign_callback_set:
* MHD_gtls_sign_callback_set:
* @session: is a gnutls session
* @sign_func: function pointer to application's sign callback.
* @userdata: void pointer that will be passed to sign callback.
*
* Set the callback function. The function must have this prototype:
*
* typedef int (*gnutls_sign_func) (gnutls_session_t session,
* typedef int (*gnutls_sign_func) (mhd_gtls_session_t session,
* void *userdata,
* gnutls_certificate_type_t cert_type,
* const gnutls_datum_t * cert,
@@ -889,10 +889,10 @@ _gnutls_gcert_deinit (gnutls_cert * cert)
*
* The @userdata parameter is passed to the @sign_func verbatim, and
* can be used to store application-specific data needed in the
* callback function. See also gnutls_sign_callback_get().
* callback function. See also MHD_gtls_sign_callback_get().
**/
void
gnutls_sign_callback_set (gnutls_session_t session,
MHD_gtls_sign_callback_set (mhd_gtls_session_t session,
gnutls_sign_func sign_func, void *userdata)
{
session->internals.sign_func = sign_func;
@@ -900,17 +900,17 @@ gnutls_sign_callback_set (gnutls_session_t session,
}
/**
* gnutls_sign_callback_get:
* MHD_gtls_sign_callback_get:
* @session: is a gnutls session
* @userdata: if non-%NULL, will be set to abstract callback pointer.
*
* Retrieve the callback function, and its userdata pointer.
*
* Returns: The function pointer set by gnutls_sign_callback_set(), or
* Returns: The function pointer set by MHD_gtls_sign_callback_set(), or
* if not set, %NULL.
**/
gnutls_sign_func
gnutls_sign_callback_get (gnutls_session_t session, void **userdata)
MHD_gtls_sign_callback_get (mhd_gtls_session_t session, void **userdata)
{
if (userdata)
*userdata = session->internals.sign_func_userdata;
+8 -8
View File
@@ -98,7 +98,7 @@ typedef struct gnutls_privkey_int
gnutls_pk_algorithm_t pk_algorithm;
} gnutls_privkey;
struct gnutls_session_int; /* because gnutls_session_t is not defined when this file is included */
struct MHD_gtls_session_int; /* because mhd_gtls_session_t is not defined when this file is included */
typedef enum ConvFlags
{
@@ -107,24 +107,24 @@ typedef enum ConvFlags
CERT_ONLY_EXTENSIONS = 16
} ConvFlags;
int _gnutls_x509_raw_cert_to_gcert (gnutls_cert * gcert,
int mhd_gtls_x509_raw_cert_to_gcert (gnutls_cert * gcert,
const gnutls_datum_t * derCert,
int flags);
int _gnutls_x509_crt_to_gcert (gnutls_cert * gcert, gnutls_x509_crt_t cert,
int mhd_gtls_x509_crt_to_gcert (gnutls_cert * gcert, gnutls_x509_crt_t cert,
unsigned int flags);
void _gnutls_gkey_deinit (gnutls_privkey * key);
void _gnutls_gcert_deinit (gnutls_cert * cert);
void mhd_gtls_gkey_deinit (gnutls_privkey * key);
void mhd_gtls_gcert_deinit (gnutls_cert * cert);
int _gnutls_selected_cert_supported_kx (struct gnutls_session_int *session,
int mhd_gtls_selected_cert_supported_kx (struct MHD_gtls_session_int *session,
gnutls_kx_algorithm_t ** alg,
int *alg_size);
int _gnutls_raw_cert_to_gcert (gnutls_cert * gcert,
int mhd_gtls_raw_cert_to_gcert (gnutls_cert * gcert,
gnutls_certificate_type_t type,
const gnutls_datum_t * raw_cert,
int flags /* OR of ConvFlags */ );
int _gnutls_raw_privkey_to_gkey (gnutls_privkey * key,
int mhd_gtls_raw_privkey_to_gkey (gnutls_privkey * key,
gnutls_certificate_type_t type,
const gnutls_datum_t * raw_key,
int key_enc /* DER or PEM */ );
+43 -43
View File
@@ -42,7 +42,7 @@
#include <gc.h>
inline static int
is_write_comp_null (gnutls_session_t session)
is_write_comp_null (mhd_gtls_session_t session)
{
if (session->security_parameters.write_compression_algorithm ==
MHD_GNUTLS_COMP_NULL)
@@ -52,7 +52,7 @@ is_write_comp_null (gnutls_session_t session)
}
inline static int
is_read_comp_null (gnutls_session_t session)
is_read_comp_null (mhd_gtls_session_t session)
{
if (session->security_parameters.read_compression_algorithm ==
MHD_GNUTLS_COMP_NULL)
@@ -68,7 +68,7 @@ is_read_comp_null (gnutls_session_t session)
* If random pad != 0 then the random pad data will be appended.
*/
int
_gnutls_encrypt (gnutls_session_t session, const opaque * headers,
mhd_gtls_encrypt (mhd_gtls_session_t session, const opaque * headers,
size_t headers_size, const opaque * data,
size_t data_size, opaque * ciphertext,
size_t ciphertext_size, content_type_t type, int random_pad)
@@ -99,7 +99,7 @@ _gnutls_encrypt (gnutls_session_t session, const opaque * headers,
}
}
ret = _gnutls_compressed2ciphertext (session, &ciphertext[headers_size],
ret = mhd_gtls_compressed2ciphertext (session, &ciphertext[headers_size],
ciphertext_size - headers_size,
comp, type, random_pad);
@@ -115,7 +115,7 @@ _gnutls_encrypt (gnutls_session_t session, const opaque * headers,
/* copy the headers */
memcpy (ciphertext, headers, headers_size);
_gnutls_write_uint16 (ret, &ciphertext[3]);
mhd_gtls_write_uint16 (ret, &ciphertext[3]);
return ret + headers_size;
}
@@ -124,7 +124,7 @@ _gnutls_encrypt (gnutls_session_t session, const opaque * headers,
* Returns the decrypted data length.
*/
int
_gnutls_decrypt (gnutls_session_t session, opaque * ciphertext,
mhd_gtls_decrypt (mhd_gtls_session_t session, opaque * ciphertext,
size_t ciphertext_size, uint8_t * data,
size_t max_data_size, content_type_t type)
{
@@ -139,7 +139,7 @@ _gnutls_decrypt (gnutls_session_t session, opaque * ciphertext,
gcipher.data = ciphertext;
ret =
_gnutls_ciphertext2compressed (session, data, max_data_size,
mhd_gtls_ciphertext2compressed (session, data, max_data_size,
gcipher, type);
if (ret < 0)
{
@@ -204,11 +204,11 @@ mac_init (gnutls_mac_algorithm_t mac, opaque * secret, int secret_size,
if (ver == MHD_GNUTLS_SSL3)
{ /* SSL 3.0 */
td = _gnutls_mac_init_ssl3 (mac, secret, secret_size);
td = mhd_gnutls_mac_init_ssl3 (mac, secret, secret_size);
}
else
{ /* TLS 1.x */
td = _gnutls_hmac_init (mac, secret, secret_size);
td = mhd_gtls_hmac_init (mac, secret, secret_size);
}
return td;
@@ -219,16 +219,16 @@ mac_deinit (mac_hd_t td, opaque * res, int ver)
{
if (ver == MHD_GNUTLS_SSL3)
{ /* SSL 3.0 */
_gnutls_mac_deinit_ssl3 (td, res);
mhd_gnutls_mac_deinit_ssl3 (td, res);
}
else
{
_gnutls_hmac_deinit (td, res);
mhd_gnutls_hmac_deinit (td, res);
}
}
inline static int
calc_enc_length (gnutls_session_t session, int data_size,
calc_enc_length (mhd_gtls_session_t session, int data_size,
int hash_size, uint8_t * pad, int random_pad,
cipher_type_t block_algo, uint16_t blocksize)
{
@@ -289,7 +289,7 @@ calc_enc_length (gnutls_session_t session, int data_size,
* return the actual encrypted data length.
*/
int
_gnutls_compressed2ciphertext (gnutls_session_t session,
mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
opaque * cipher_data, int cipher_size,
gnutls_datum_t compressed,
content_type_t _type, int random_pad)
@@ -302,21 +302,21 @@ _gnutls_compressed2ciphertext (gnutls_session_t session,
uint8_t type = _type;
uint8_t major, minor;
int hash_size =
_gnutls_hash_get_algo_len (session->security_parameters.
mhd_gnutls_hash_get_algo_len (session->security_parameters.
write_mac_algorithm);
gnutls_protocol_t ver;
int blocksize =
_gnutls_cipher_get_block_size (session->security_parameters.
mhd_gtls_cipher_get_block_size (session->security_parameters.
write_bulk_cipher_algorithm);
cipher_type_t block_algo =
_gnutls_cipher_is_block (session->security_parameters.
mhd_gtls_cipher_is_block (session->security_parameters.
write_bulk_cipher_algorithm);
opaque *data_ptr;
ver = gnutls_protocol_get_version (session);
minor = _gnutls_version_get_minor (ver);
major = _gnutls_version_get_major (ver);
ver = MHD_gnutls_protocol_get_version (session);
minor = mhd_gtls_version_get_minor (ver);
major = mhd_gtls_version_get_major (ver);
/* Initialize MAC */
@@ -332,22 +332,22 @@ _gnutls_compressed2ciphertext (gnutls_session_t session,
return GNUTLS_E_INTERNAL_ERROR;
}
c_length = _gnutls_conv_uint16 (compressed.size);
c_length = mhd_gtls_conv_uint16 (compressed.size);
if (td != GNUTLS_MAC_FAILED)
{ /* actually when the algorithm in not the NULL one */
_gnutls_hmac (td,
mhd_gnutls_hash (td,
UINT64DATA (session->connection_state.
write_sequence_number), 8);
_gnutls_hmac (td, &type, 1);
mhd_gnutls_hash (td, &type, 1);
if (ver >= MHD_GNUTLS_TLS1_0)
{ /* TLS 1.0 or higher */
_gnutls_hmac (td, &major, 1);
_gnutls_hmac (td, &minor, 1);
mhd_gnutls_hash (td, &major, 1);
mhd_gnutls_hash (td, &minor, 1);
}
_gnutls_hmac (td, &c_length, 2);
_gnutls_hmac (td, compressed.data, compressed.size);
mhd_gnutls_hash (td, &c_length, 2);
mhd_gnutls_hash (td, compressed.data, compressed.size);
mac_deinit (td, MAC, ver);
}
@@ -401,7 +401,7 @@ _gnutls_compressed2ciphertext (gnutls_session_t session,
/* Actual encryption (inplace).
*/
ret = _gnutls_cipher_encrypt (session->connection_state.
ret = mhd_gtls_cipher_encrypt (session->connection_state.
write_cipher_state, cipher_data, length);
if (ret < 0)
{
@@ -416,7 +416,7 @@ _gnutls_compressed2ciphertext (gnutls_session_t session,
* Returns the actual compressed packet size.
*/
int
_gnutls_ciphertext2compressed (gnutls_session_t session,
mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
opaque * compress_data,
int compress_size,
gnutls_datum_t ciphertext, uint8_t type)
@@ -431,14 +431,14 @@ _gnutls_ciphertext2compressed (gnutls_session_t session,
uint8_t major, minor;
gnutls_protocol_t ver;
int hash_size =
_gnutls_hash_get_algo_len (session->security_parameters.
mhd_gnutls_hash_get_algo_len (session->security_parameters.
read_mac_algorithm);
ver = gnutls_protocol_get_version (session);
minor = _gnutls_version_get_minor (ver);
major = _gnutls_version_get_major (ver);
ver = MHD_gnutls_protocol_get_version (session);
minor = mhd_gtls_version_get_minor (ver);
major = mhd_gtls_version_get_major (ver);
blocksize = _gnutls_cipher_get_block_size (session->security_parameters.
blocksize = mhd_gtls_cipher_get_block_size (session->security_parameters.
read_bulk_cipher_algorithm);
/* initialize MAC
@@ -458,11 +458,11 @@ _gnutls_ciphertext2compressed (gnutls_session_t session,
/* actual decryption (inplace)
*/
switch (_gnutls_cipher_is_block
switch (mhd_gtls_cipher_is_block
(session->security_parameters.read_bulk_cipher_algorithm))
{
case CIPHER_STREAM:
if ((ret = _gnutls_cipher_decrypt (session->connection_state.
if ((ret = mhd_gtls_cipher_decrypt (session->connection_state.
read_cipher_state,
ciphertext.data,
ciphertext.size)) < 0)
@@ -481,7 +481,7 @@ _gnutls_ciphertext2compressed (gnutls_session_t session,
return GNUTLS_E_DECRYPTION_FAILED;
}
if ((ret = _gnutls_cipher_decrypt (session->connection_state.
if ((ret = mhd_gtls_cipher_decrypt (session->connection_state.
read_cipher_state,
ciphertext.data,
ciphertext.size)) < 0)
@@ -534,27 +534,27 @@ _gnutls_ciphertext2compressed (gnutls_session_t session,
if (length < 0)
length = 0;
c_length = _gnutls_conv_uint16 ((uint16_t) length);
c_length = mhd_gtls_conv_uint16 ((uint16_t) length);
/* Pass the type, version, length and compressed through
* MAC.
*/
if (td != GNUTLS_MAC_FAILED)
{
_gnutls_hmac (td,
mhd_gnutls_hash (td,
UINT64DATA (session->connection_state.
read_sequence_number), 8);
_gnutls_hmac (td, &type, 1);
mhd_gnutls_hash (td, &type, 1);
if (ver >= MHD_GNUTLS_TLS1_0)
{ /* TLS 1.x */
_gnutls_hmac (td, &major, 1);
_gnutls_hmac (td, &minor, 1);
mhd_gnutls_hash (td, &major, 1);
mhd_gnutls_hash (td, &minor, 1);
}
_gnutls_hmac (td, &c_length, 2);
mhd_gnutls_hash (td, &c_length, 2);
if (length > 0)
_gnutls_hmac (td, ciphertext.data, length);
mhd_gnutls_hash (td, ciphertext.data, length);
mac_deinit (td, MAC, ver);
}
+4 -4
View File
@@ -22,20 +22,20 @@
*
*/
int _gnutls_encrypt (gnutls_session_t session, const opaque * headers,
int mhd_gtls_encrypt (mhd_gtls_session_t session, const opaque * headers,
size_t headers_size, const opaque * data,
size_t data_size, opaque * ciphertext,
size_t ciphertext_size, content_type_t type,
int random_pad);
int _gnutls_decrypt (gnutls_session_t session, opaque * ciphertext,
int mhd_gtls_decrypt (mhd_gtls_session_t session, opaque * ciphertext,
size_t ciphertext_size, uint8_t * data, size_t data_size,
content_type_t type);
int _gnutls_compressed2ciphertext (gnutls_session_t session,
int mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
opaque * cipher_data, int cipher_size,
gnutls_datum_t compressed,
content_type_t _type, int random_pad);
int _gnutls_ciphertext2compressed (gnutls_session_t session,
int mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
opaque * compress_data,
int compress_size,
gnutls_datum_t ciphertext, uint8_t type);
+4 -4
View File
@@ -28,7 +28,7 @@
#include <gnutls_datum.h>
cipher_hd_t
_gnutls_cipher_init (gnutls_cipher_algorithm_t cipher,
mhd_gtls_cipher_init (gnutls_cipher_algorithm_t cipher,
const gnutls_datum_t * key, const gnutls_datum_t * iv)
{
cipher_hd_t ret = NULL;
@@ -95,7 +95,7 @@ _gnutls_cipher_init (gnutls_cipher_algorithm_t cipher,
}
int
_gnutls_cipher_encrypt (cipher_hd_t handle, void *text, int textlen)
mhd_gtls_cipher_encrypt (cipher_hd_t handle, void *text, int textlen)
{
if (handle != GNUTLS_CIPHER_FAILED)
{
@@ -109,7 +109,7 @@ _gnutls_cipher_encrypt (cipher_hd_t handle, void *text, int textlen)
}
int
_gnutls_cipher_decrypt (cipher_hd_t handle, void *ciphertext,
mhd_gtls_cipher_decrypt (cipher_hd_t handle, void *ciphertext,
int ciphertextlen)
{
if (handle != GNUTLS_CIPHER_FAILED)
@@ -124,7 +124,7 @@ _gnutls_cipher_decrypt (cipher_hd_t handle, void *ciphertext,
}
void
_gnutls_cipher_deinit (cipher_hd_t handle)
mhd_gnutls_cipher_deinit (cipher_hd_t handle)
{
if (handle != GNUTLS_CIPHER_FAILED)
{
+4 -4
View File
@@ -29,18 +29,18 @@
#define GNUTLS_CIPHER_FAILED NULL
// TODO gc_cipher_handle -> void * x3
void * _gnutls_cipher_init(gnutls_cipher_algorithm_t cipher,
void * mhd_gtls_cipher_init(gnutls_cipher_algorithm_t cipher,
const gnutls_datum_t * key,
const gnutls_datum_t * iv);
int _gnutls_cipher_encrypt(void * handle,
int mhd_gtls_cipher_encrypt(void * handle,
void *text,
int textlen);
int _gnutls_cipher_decrypt(void * handle,
int mhd_gtls_cipher_decrypt(void * handle,
void *ciphertext,
int ciphertextlen);
void _gnutls_cipher_deinit(void * handle);
void mhd_gnutls_cipher_deinit(void * handle);
#endif /* GNUTLS_CIPHER_INT */
+4 -4
View File
@@ -34,7 +34,7 @@
/* These functions allocate the return value internally
*/
int
_gnutls_m_plaintext2compressed (gnutls_session_t session,
_gnutls_m_plaintext2compressed (mhd_gtls_session_t session,
gnutls_datum_t * compressed,
const gnutls_datum_t * plaintext)
{
@@ -42,7 +42,7 @@ _gnutls_m_plaintext2compressed (gnutls_session_t session,
opaque *data;
size =
_gnutls_compress (session->connection_state.write_compression_state,
mhd_gtls_compress (session->connection_state.write_compression_state,
plaintext->data, plaintext->size, &data,
MAX_RECORD_SEND_SIZE + EXTRA_COMP_SIZE);
if (size < 0)
@@ -57,7 +57,7 @@ _gnutls_m_plaintext2compressed (gnutls_session_t session,
}
int
_gnutls_m_compressed2plaintext (gnutls_session_t session,
_gnutls_m_compressed2plaintext (mhd_gtls_session_t session,
gnutls_datum_t * plain,
const gnutls_datum_t * compressed)
{
@@ -65,7 +65,7 @@ _gnutls_m_compressed2plaintext (gnutls_session_t session,
opaque *data;
size =
_gnutls_decompress (session->connection_state.
mhd_gtls_decompress (session->connection_state.
read_compression_state, compressed->data,
compressed->size, &data, MAX_RECORD_RECV_SIZE);
if (size < 0)
+2 -2
View File
@@ -22,9 +22,9 @@
*
*/
int _gnutls_m_plaintext2compressed (gnutls_session_t session,
int _gnutls_m_plaintext2compressed (mhd_gtls_session_t session,
gnutls_datum_t * compressed,
const gnutls_datum_t *plaintext);
int _gnutls_m_compressed2plaintext (gnutls_session_t session,
int _gnutls_m_compressed2plaintext (mhd_gtls_session_t session,
gnutls_datum_t * plain,
const gnutls_datum_t* compressed);
+8 -8
View File
@@ -31,7 +31,7 @@
* decompress.
*/
comp_hd_t
_gnutls_comp_init (gnutls_compression_method_t method, int d)
mhd_gtls_comp_init (gnutls_compression_method_t method, int d)
{
comp_hd_t ret;
@@ -54,9 +54,9 @@ _gnutls_comp_init (gnutls_compression_method_t method, int d)
int comp_level;
z_stream *zhandle;
window_bits = _gnutls_compression_get_wbits (method);
mem_level = _gnutls_compression_get_mem_level (method);
comp_level = _gnutls_compression_get_comp_level (method);
window_bits = mhd_gtls_compression_get_wbits (method);
mem_level = mhd_gtls_compression_get_mem_level (method);
comp_level = mhd_gtls_compression_get_comp_level (method);
ret->handle = gnutls_malloc (sizeof (z_stream));
if (ret->handle == NULL)
@@ -102,7 +102,7 @@ cleanup_ret:
* decompress.
*/
void
_gnutls_comp_deinit (comp_hd_t handle, int d)
mhd_gtls_comp_deinit (comp_hd_t handle, int d)
{
if (handle != NULL)
{
@@ -129,7 +129,7 @@ _gnutls_comp_deinit (comp_hd_t handle, int d)
*/
int
_gnutls_compress (comp_hd_t handle, const opaque * plain,
mhd_gtls_compress (comp_hd_t handle, const opaque * plain,
size_t plain_size, opaque ** compressed,
size_t max_comp_size)
{
@@ -204,7 +204,7 @@ _gnutls_compress (comp_hd_t handle, const opaque * plain,
int
_gnutls_decompress (comp_hd_t handle, opaque * compressed,
mhd_gtls_decompress (comp_hd_t handle, opaque * compressed,
size_t compressed_size, opaque ** plain,
size_t max_record_size)
{
@@ -247,7 +247,7 @@ _gnutls_decompress (comp_hd_t handle, opaque * compressed,
do
{
out_size += 512;
*plain = gnutls_realloc_fast (*plain, out_size);
*plain = mhd_gtls_realloc_fast (*plain, out_size);
if (*plain == NULL)
{
gnutls_assert ();
+4 -4
View File
@@ -37,13 +37,13 @@ typedef struct comp_hd_t_STRUCT
gnutls_compression_method_t algo;
} *comp_hd_t;
comp_hd_t _gnutls_comp_init (gnutls_compression_method_t, int d);
void _gnutls_comp_deinit (comp_hd_t handle, int d);
comp_hd_t mhd_gtls_comp_init (gnutls_compression_method_t, int d);
void mhd_gtls_comp_deinit (comp_hd_t handle, int d);
int _gnutls_decompress (comp_hd_t handle, opaque * compressed,
int mhd_gtls_decompress (comp_hd_t handle, opaque * compressed,
size_t compressed_size, opaque ** plain,
size_t max_record_size);
int _gnutls_compress (comp_hd_t, const opaque * plain, size_t plain_size,
int mhd_gtls_compress (comp_hd_t, const opaque * plain, size_t plain_size,
opaque ** compressed, size_t max_comp_size);
#endif
+83 -83
View File
@@ -55,7 +55,7 @@ static const int servwrite_length = sizeof (servwrite) - 1;
* (session->cipher_specs)
*/
int
_gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
_gnutls_set_keys (mhd_gtls_session_t session, int hash_size, int IV_size,
int key_size, int export_flag)
{
@@ -99,7 +99,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
if (session->security_parameters.version == MHD_GNUTLS_SSL3)
{ /* SSL 3 */
ret =
_gnutls_ssl3_generate_random (session->
mhd_gnutls_ssl3_generate_random (session->
security_parameters.
master_secret,
TLS_MASTER_SIZE, rnd,
@@ -109,7 +109,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
else
{ /* TLS 1.0 */
ret =
_gnutls_PRF (session, session->security_parameters.master_secret,
mhd_gtls_PRF (session, session->security_parameters.master_secret,
TLS_MASTER_SIZE, keyexp, keyexp_length,
rnd, 2 * TLS_RANDOM_SIZE, block_size, key_block);
}
@@ -122,7 +122,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
}
_gnutls_hard_log ("INT: KEY BLOCK[%d]: %s\n", block_size,
_gnutls_bin2hex (key_block, block_size, buf,
mhd_gtls_bin2hex (key_block, block_size, buf,
sizeof (buf)));
pos = 0;
@@ -192,7 +192,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
if (session->security_parameters.version == MHD_GNUTLS_SSL3)
{ /* SSL 3 */
ret =
_gnutls_ssl3_hash_md5 (&key_block[pos],
mhd_gnutls_ssl3_hash_md5 (&key_block[pos],
key_size, rrnd,
2 * TLS_RANDOM_SIZE,
EXPORT_FINAL_KEY_SIZE,
@@ -202,7 +202,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
else
{ /* TLS 1.0 */
ret =
_gnutls_PRF (session, &key_block[pos], key_size,
mhd_gtls_PRF (session, &key_block[pos], key_size,
cliwrite, cliwrite_length,
rrnd,
2 * TLS_RANDOM_SIZE,
@@ -224,7 +224,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
if (session->security_parameters.version == MHD_GNUTLS_SSL3)
{ /* SSL 3 */
ret =
_gnutls_ssl3_hash_md5 (&key_block[pos], key_size,
mhd_gnutls_ssl3_hash_md5 (&key_block[pos], key_size,
rnd, 2 * TLS_RANDOM_SIZE,
EXPORT_FINAL_KEY_SIZE,
server_write_key);
@@ -232,7 +232,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
else
{ /* TLS 1.0 */
ret =
_gnutls_PRF (session, &key_block[pos], key_size,
mhd_gtls_PRF (session, &key_block[pos], key_size,
servwrite, servwrite_length,
rrnd, 2 * TLS_RANDOM_SIZE,
EXPORT_FINAL_KEY_SIZE, server_write_key);
@@ -262,7 +262,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
}
_gnutls_hard_log ("INT: CLIENT WRITE KEY [%d]: %s\n",
client_write_key_size,
_gnutls_bin2hex (client_write_key,
mhd_gtls_bin2hex (client_write_key,
client_write_key_size, buf,
sizeof (buf)));
@@ -278,7 +278,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
_gnutls_hard_log ("INT: SERVER WRITE KEY [%d]: %s\n",
server_write_key_size,
_gnutls_bin2hex (server_write_key,
mhd_gtls_bin2hex (server_write_key,
server_write_key_size, buf,
sizeof (buf)));
@@ -325,7 +325,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
if (session->security_parameters.version == MHD_GNUTLS_SSL3)
{ /* SSL 3 */
ret = _gnutls_ssl3_hash_md5 ("", 0,
ret = mhd_gnutls_ssl3_hash_md5 ("", 0,
rrnd, TLS_RANDOM_SIZE * 2,
IV_size, iv_block);
@@ -337,14 +337,14 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
return ret;
}
ret = _gnutls_ssl3_hash_md5 ("", 0, rnd,
ret = mhd_gnutls_ssl3_hash_md5 ("", 0, rnd,
TLS_RANDOM_SIZE * 2,
IV_size, &iv_block[IV_size]);
}
else
{ /* TLS 1.0 */
ret = _gnutls_PRF (session, "", 0,
ret = mhd_gtls_PRF (session, "", 0,
ivblock, ivblock_length, rrnd,
2 * TLS_RANDOM_SIZE, IV_size * 2, iv_block);
}
@@ -385,7 +385,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
}
int
_gnutls_set_read_keys (gnutls_session_t session)
_gnutls_set_read_keys (mhd_gtls_session_t session)
{
int hash_size;
int IV_size;
@@ -396,17 +396,17 @@ _gnutls_set_read_keys (gnutls_session_t session)
mac_algo = session->security_parameters.read_mac_algorithm;
algo = session->security_parameters.read_bulk_cipher_algorithm;
hash_size = _gnutls_hash_get_algo_len (mac_algo);
IV_size = _gnutls_cipher_get_iv_size (algo);
key_size = gnutls_cipher_get_key_size (algo);
export_flag = _gnutls_cipher_get_export_flag (algo);
hash_size = mhd_gnutls_hash_get_algo_len (mac_algo);
IV_size = mhd_gtls_cipher_get_iv_size (algo);
key_size = MHD_gnutls_cipher_get_key_size (algo);
export_flag = mhd_gtls_cipher_get_export_flag (algo);
return _gnutls_set_keys (session, hash_size, IV_size, key_size,
export_flag);
}
int
_gnutls_set_write_keys (gnutls_session_t session)
_gnutls_set_write_keys (mhd_gtls_session_t session)
{
int hash_size;
int IV_size;
@@ -417,10 +417,10 @@ _gnutls_set_write_keys (gnutls_session_t session)
mac_algo = session->security_parameters.write_mac_algorithm;
algo = session->security_parameters.write_bulk_cipher_algorithm;
hash_size = _gnutls_hash_get_algo_len (mac_algo);
IV_size = _gnutls_cipher_get_iv_size (algo);
key_size = gnutls_cipher_get_key_size (algo);
export_flag = _gnutls_cipher_get_export_flag (algo);
hash_size = mhd_gnutls_hash_get_algo_len (mac_algo);
IV_size = mhd_gtls_cipher_get_iv_size (algo);
key_size = MHD_gnutls_cipher_get_key_size (algo);
export_flag = mhd_gtls_cipher_get_export_flag (algo);
return _gnutls_set_keys (session, hash_size, IV_size, key_size,
export_flag);
@@ -439,12 +439,12 @@ _gnutls_set_write_keys (gnutls_session_t session)
dst->max_record_recv_size = src->max_record_recv_size; \
dst->max_record_send_size = src->max_record_send_size; \
dst->version = src->version; \
memcpy( &dst->extensions, &src->extensions, sizeof(tls_ext_st)); \
memcpy( &dst->extensions, &src->extensions, sizeof(mhd_gtls_ext_st)); \
memcpy( &dst->inner_secret, &src->inner_secret, TLS_MASTER_SIZE);
static void
_gnutls_cpy_read_security_parameters (security_parameters_st *
dst, security_parameters_st * src)
_gnutls_cpy_read_security_parameters (mhd_gtls_security_param_st *
dst, mhd_gtls_security_param_st * src)
{
CPY_COMMON;
@@ -454,8 +454,8 @@ _gnutls_cpy_read_security_parameters (security_parameters_st *
}
static void
_gnutls_cpy_write_security_parameters (security_parameters_st *
dst, security_parameters_st * src)
_gnutls_cpy_write_security_parameters (mhd_gtls_security_param_st *
dst, mhd_gtls_security_param_st * src)
{
CPY_COMMON;
@@ -471,13 +471,13 @@ _gnutls_cpy_write_security_parameters (security_parameters_st *
* This is to be called after sending the Change Cipher Spec packet.
*/
int
_gnutls_connection_state_init (gnutls_session_t session)
mhd_gtls_connection_state_init (mhd_gtls_session_t session)
{
int ret;
/* Setup the master secret
*/
if ((ret = _gnutls_generate_master (session, 0), 0) < 0)
if ((ret = mhd_gtls_generate_master (session, 0), 0) < 0)
{
gnutls_assert ();
return ret;
@@ -492,7 +492,7 @@ _gnutls_connection_state_init (gnutls_session_t session)
* (read encrypted data)
*/
int
_gnutls_read_connection_state_init (gnutls_session_t session)
mhd_gtls_read_connection_state_init (mhd_gtls_session_t session)
{
int mac_size;
int rc;
@@ -504,27 +504,27 @@ _gnutls_read_connection_state_init (gnutls_session_t session)
*/
if (session->internals.resumed == RESUME_FALSE)
{
rc = _gnutls_set_read_cipher (session,
_gnutls_cipher_suite_get_cipher_algo
rc = mhd_gtls_set_read_cipher (session,
mhd_gtls_cipher_suite_get_cipher_algo
(&session->security_parameters.
current_cipher_suite));
if (rc < 0)
return rc;
rc = _gnutls_set_read_mac (session,
_gnutls_cipher_suite_get_mac_algo
rc = mhd_gtls_set_read_mac (session,
mhd_gtls_cipher_suite_get_mac_algo
(&session->security_parameters.
current_cipher_suite));
if (rc < 0)
return rc;
rc = _gnutls_set_kx (session,
_gnutls_cipher_suite_get_kx_algo
rc = mhd_gtls_set_kx (session,
mhd_gtls_cipher_suite_get_kx_algo
(&session->security_parameters.
current_cipher_suite));
if (rc < 0)
return rc;
rc = _gnutls_set_read_compression (session,
rc = mhd_gtls_set_read_compression (session,
session->internals.
compression_method);
if (rc < 0)
@@ -545,18 +545,18 @@ _gnutls_read_connection_state_init (gnutls_session_t session)
return rc;
_gnutls_handshake_log ("HSK[%x]: Cipher Suite: %s\n",
session, _gnutls_cipher_suite_get_name (&session->
session, mhd_gtls_cipher_suite_get_name (&session->
security_parameters.
current_cipher_suite));
if (_gnutls_compression_is_ok
if (mhd_gtls_compression_is_ok
(session->security_parameters.read_compression_algorithm) != 0)
{
gnutls_assert ();
return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM;
}
if (_gnutls_mac_is_ok
if (mhd_gnutls_mac_is_ok
(session->security_parameters.read_mac_algorithm) != 0)
{
gnutls_assert ();
@@ -569,14 +569,14 @@ _gnutls_read_connection_state_init (gnutls_session_t session)
_gnutls_free_datum (&session->connection_state.read_mac_secret);
if (session->connection_state.read_cipher_state != NULL)
_gnutls_cipher_deinit (session->connection_state.read_cipher_state);
mhd_gnutls_cipher_deinit (session->connection_state.read_cipher_state);
if (session->connection_state.read_compression_state != NULL)
_gnutls_comp_deinit (session->connection_state.read_compression_state, 1);
mhd_gtls_comp_deinit (session->connection_state.read_compression_state, 1);
mac_size =
_gnutls_hash_get_algo_len (session->security_parameters.
mhd_gnutls_hash_get_algo_len (session->security_parameters.
read_mac_algorithm);
_gnutls_handshake_log
@@ -588,7 +588,7 @@ _gnutls_read_connection_state_init (gnutls_session_t session)
/* initialize cipher session
*/
session->connection_state.read_cipher_state =
_gnutls_cipher_init (session->security_parameters.
mhd_gtls_cipher_init (session->security_parameters.
read_bulk_cipher_algorithm,
&session->cipher_specs.
client_write_key,
@@ -624,7 +624,7 @@ _gnutls_read_connection_state_init (gnutls_session_t session)
case GNUTLS_CLIENT:
session->connection_state.read_cipher_state =
_gnutls_cipher_init (session->security_parameters.
mhd_gtls_cipher_init (session->security_parameters.
read_bulk_cipher_algorithm,
&session->cipher_specs.
server_write_key,
@@ -664,7 +664,7 @@ _gnutls_read_connection_state_init (gnutls_session_t session)
}
session->connection_state.read_compression_state =
_gnutls_comp_init (session->security_parameters.
mhd_gtls_comp_init (session->security_parameters.
read_compression_algorithm, 1);
if (session->connection_state.read_compression_state == GNUTLS_COMP_FAILED)
@@ -682,7 +682,7 @@ _gnutls_read_connection_state_init (gnutls_session_t session)
* (write encrypted data)
*/
int
_gnutls_write_connection_state_init (gnutls_session_t session)
mhd_gtls_write_connection_state_init (mhd_gtls_session_t session)
{
int mac_size;
int rc;
@@ -694,27 +694,27 @@ _gnutls_write_connection_state_init (gnutls_session_t session)
*/
if (session->internals.resumed == RESUME_FALSE)
{
rc = _gnutls_set_write_cipher (session,
_gnutls_cipher_suite_get_cipher_algo
rc = mhd_gtls_set_write_cipher (session,
mhd_gtls_cipher_suite_get_cipher_algo
(&session->security_parameters.
current_cipher_suite));
if (rc < 0)
return rc;
rc = _gnutls_set_write_mac (session,
_gnutls_cipher_suite_get_mac_algo
rc = mhd_gtls_set_write_mac (session,
mhd_gtls_cipher_suite_get_mac_algo
(&session->security_parameters.
current_cipher_suite));
if (rc < 0)
return rc;
rc = _gnutls_set_kx (session,
_gnutls_cipher_suite_get_kx_algo
rc = mhd_gtls_set_kx (session,
mhd_gtls_cipher_suite_get_kx_algo
(&session->security_parameters.
current_cipher_suite));
if (rc < 0)
return rc;
rc = _gnutls_set_write_compression (session,
rc = mhd_gtls_set_write_compression (session,
session->internals.
compression_method);
if (rc < 0)
@@ -734,18 +734,18 @@ _gnutls_write_connection_state_init (gnutls_session_t session)
return rc;
_gnutls_handshake_log ("HSK[%x]: Cipher Suite: %s\n", session,
_gnutls_cipher_suite_get_name (&session->
mhd_gtls_cipher_suite_get_name (&session->
security_parameters.
current_cipher_suite));
if (_gnutls_compression_is_ok
if (mhd_gtls_compression_is_ok
(session->security_parameters.write_compression_algorithm) != 0)
{
gnutls_assert ();
return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM;
}
if (_gnutls_mac_is_ok
if (mhd_gnutls_mac_is_ok
(session->security_parameters.write_mac_algorithm) != 0)
{
gnutls_assert ();
@@ -760,14 +760,14 @@ _gnutls_write_connection_state_init (gnutls_session_t session)
_gnutls_free_datum (&session->connection_state.write_mac_secret);
if (session->connection_state.write_cipher_state != NULL)
_gnutls_cipher_deinit (session->connection_state.write_cipher_state);
mhd_gnutls_cipher_deinit (session->connection_state.write_cipher_state);
if (session->connection_state.write_compression_state != NULL)
_gnutls_comp_deinit (session->connection_state.
mhd_gtls_comp_deinit (session->connection_state.
write_compression_state, 0);
mac_size =
_gnutls_hash_get_algo_len (session->security_parameters.
mhd_gnutls_hash_get_algo_len (session->security_parameters.
write_mac_algorithm);
_gnutls_handshake_log
@@ -779,7 +779,7 @@ _gnutls_write_connection_state_init (gnutls_session_t session)
/* initialize cipher session
*/
session->connection_state.write_cipher_state =
_gnutls_cipher_init (session->security_parameters.
mhd_gtls_cipher_init (session->security_parameters.
write_bulk_cipher_algorithm,
&session->cipher_specs.
server_write_key,
@@ -818,7 +818,7 @@ _gnutls_write_connection_state_init (gnutls_session_t session)
case GNUTLS_CLIENT:
session->connection_state.write_cipher_state =
_gnutls_cipher_init (session->security_parameters.
mhd_gtls_cipher_init (session->security_parameters.
write_bulk_cipher_algorithm,
&session->cipher_specs.
client_write_key,
@@ -858,7 +858,7 @@ _gnutls_write_connection_state_init (gnutls_session_t session)
session->connection_state.write_compression_state =
_gnutls_comp_init (session->security_parameters.
mhd_gtls_comp_init (session->security_parameters.
write_compression_algorithm, 0);
if (session->connection_state.write_compression_state == GNUTLS_COMP_FAILED)
@@ -873,13 +873,13 @@ _gnutls_write_connection_state_init (gnutls_session_t session)
/* Sets the specified cipher into the pending session
*/
int
_gnutls_set_read_cipher (gnutls_session_t session,
mhd_gtls_set_read_cipher (mhd_gtls_session_t session,
gnutls_cipher_algorithm_t algo)
{
if (_gnutls_cipher_is_ok (algo) == 0)
if (mhd_gtls_cipher_is_ok (algo) == 0)
{
if (_gnutls_cipher_priority (session, algo) < 0)
if (mhd_gtls_cipher_priority (session, algo) < 0)
{
gnutls_assert ();
return GNUTLS_E_UNWANTED_ALGORITHM;
@@ -899,13 +899,13 @@ _gnutls_set_read_cipher (gnutls_session_t session,
}
int
_gnutls_set_write_cipher (gnutls_session_t session,
mhd_gtls_set_write_cipher (mhd_gtls_session_t session,
gnutls_cipher_algorithm_t algo)
{
if (_gnutls_cipher_is_ok (algo) == 0)
if (mhd_gtls_cipher_is_ok (algo) == 0)
{
if (_gnutls_cipher_priority (session, algo) < 0)
if (mhd_gtls_cipher_priority (session, algo) < 0)
{
gnutls_assert ();
return GNUTLS_E_UNWANTED_ALGORITHM;
@@ -928,11 +928,11 @@ _gnutls_set_write_cipher (gnutls_session_t session,
/* Sets the specified algorithm into pending compression session
*/
int
_gnutls_set_read_compression (gnutls_session_t session,
mhd_gtls_set_read_compression (mhd_gtls_session_t session,
gnutls_compression_method_t algo)
{
if (_gnutls_compression_is_ok (algo) == 0)
if (mhd_gtls_compression_is_ok (algo) == 0)
{
session->security_parameters.read_compression_algorithm = algo;
}
@@ -946,11 +946,11 @@ _gnutls_set_read_compression (gnutls_session_t session,
}
int
_gnutls_set_write_compression (gnutls_session_t session,
mhd_gtls_set_write_compression (mhd_gtls_session_t session,
gnutls_compression_method_t algo)
{
if (_gnutls_compression_is_ok (algo) == 0)
if (mhd_gtls_compression_is_ok (algo) == 0)
{
session->security_parameters.write_compression_algorithm = algo;
}
@@ -966,10 +966,10 @@ _gnutls_set_write_compression (gnutls_session_t session,
/* Sets the specified kx algorithm into pending session
*/
int
_gnutls_set_kx (gnutls_session_t session, gnutls_kx_algorithm_t algo)
mhd_gtls_set_kx (mhd_gtls_session_t session, gnutls_kx_algorithm_t algo)
{
if (_gnutls_kx_is_ok (algo) == 0)
if (mhd_gtls_kx_is_ok (algo) == 0)
{
session->security_parameters.kx_algorithm = algo;
}
@@ -978,7 +978,7 @@ _gnutls_set_kx (gnutls_session_t session, gnutls_kx_algorithm_t algo)
gnutls_assert ();
return GNUTLS_E_INTERNAL_ERROR;
}
if (_gnutls_kx_priority (session, algo) < 0)
if (mhd_gtls_kx_priority (session, algo) < 0)
{
gnutls_assert ();
/* we shouldn't get here */
@@ -991,10 +991,10 @@ _gnutls_set_kx (gnutls_session_t session, gnutls_kx_algorithm_t algo)
/* Sets the specified mac algorithm into pending session */
int
_gnutls_set_read_mac (gnutls_session_t session, gnutls_mac_algorithm_t algo)
mhd_gtls_set_read_mac (mhd_gtls_session_t session, gnutls_mac_algorithm_t algo)
{
if (_gnutls_mac_is_ok (algo) == 0)
if (mhd_gnutls_mac_is_ok (algo) == 0)
{
session->security_parameters.read_mac_algorithm = algo;
}
@@ -1003,7 +1003,7 @@ _gnutls_set_read_mac (gnutls_session_t session, gnutls_mac_algorithm_t algo)
gnutls_assert ();
return GNUTLS_E_INTERNAL_ERROR;
}
if (_gnutls_mac_priority (session, algo) < 0)
if (mhd_gtls_mac_priority (session, algo) < 0)
{
gnutls_assert ();
return GNUTLS_E_UNWANTED_ALGORITHM;
@@ -1015,10 +1015,10 @@ _gnutls_set_read_mac (gnutls_session_t session, gnutls_mac_algorithm_t algo)
}
int
_gnutls_set_write_mac (gnutls_session_t session, gnutls_mac_algorithm_t algo)
mhd_gtls_set_write_mac (mhd_gtls_session_t session, gnutls_mac_algorithm_t algo)
{
if (_gnutls_mac_is_ok (algo) == 0)
if (mhd_gnutls_mac_is_ok (algo) == 0)
{
session->security_parameters.write_mac_algorithm = algo;
}
@@ -1027,7 +1027,7 @@ _gnutls_set_write_mac (gnutls_session_t session, gnutls_mac_algorithm_t algo)
gnutls_assert ();
return GNUTLS_E_INTERNAL_ERROR;
}
if (_gnutls_mac_priority (session, algo) < 0)
if (mhd_gtls_mac_priority (session, algo) < 0)
{
gnutls_assert ();
return GNUTLS_E_UNWANTED_ALGORITHM;
+10 -10
View File
@@ -22,19 +22,19 @@
*
*/
int _gnutls_connection_state_init (gnutls_session_t session);
int _gnutls_read_connection_state_init (gnutls_session_t session);
int _gnutls_write_connection_state_init (gnutls_session_t session);
int _gnutls_set_write_cipher (gnutls_session_t session,
int mhd_gtls_connection_state_init (mhd_gtls_session_t session);
int mhd_gtls_read_connection_state_init (mhd_gtls_session_t session);
int mhd_gtls_write_connection_state_init (mhd_gtls_session_t session);
int mhd_gtls_set_write_cipher (mhd_gtls_session_t session,
gnutls_cipher_algorithm_t algo);
int _gnutls_set_write_mac (gnutls_session_t session,
int mhd_gtls_set_write_mac (mhd_gtls_session_t session,
gnutls_mac_algorithm_t algo);
int _gnutls_set_read_cipher (gnutls_session_t session,
int mhd_gtls_set_read_cipher (mhd_gtls_session_t session,
gnutls_cipher_algorithm_t algo);
int _gnutls_set_read_mac (gnutls_session_t session,
int mhd_gtls_set_read_mac (mhd_gtls_session_t session,
gnutls_mac_algorithm_t algo);
int _gnutls_set_read_compression (gnutls_session_t session,
int mhd_gtls_set_read_compression (mhd_gtls_session_t session,
gnutls_compression_method_t algo);
int _gnutls_set_write_compression (gnutls_session_t session,
int mhd_gtls_set_write_compression (mhd_gtls_session_t session,
gnutls_compression_method_t algo);
int _gnutls_set_kx (gnutls_session_t session, gnutls_kx_algorithm_t algo);
int mhd_gtls_set_kx (mhd_gtls_session_t session, gnutls_kx_algorithm_t algo);
+10 -10
View File
@@ -34,31 +34,31 @@
void
_gnutls_write_datum16 (opaque * dest, gnutls_datum_t dat)
mhd_gtls_write_datum16 (opaque * dest, gnutls_datum_t dat)
{
_gnutls_write_uint16 (dat.size, dest);
mhd_gtls_write_uint16 (dat.size, dest);
if (dat.data != NULL)
memcpy (&dest[2], dat.data, dat.size);
}
void
_gnutls_write_datum24 (opaque * dest, gnutls_datum_t dat)
mhd_gtls_write_datum24 (opaque * dest, gnutls_datum_t dat)
{
_gnutls_write_uint24 (dat.size, dest);
mhd_gtls_write_uint24 (dat.size, dest);
if (dat.data != NULL)
memcpy (&dest[3], dat.data, dat.size);
}
void
_gnutls_write_datum32 (opaque * dest, gnutls_datum_t dat)
mhd_gtls_write_datum32 (opaque * dest, gnutls_datum_t dat)
{
_gnutls_write_uint32 (dat.size, dest);
mhd_gtls_write_uint32 (dat.size, dest);
if (dat.data != NULL)
memcpy (&dest[4], dat.data, dat.size);
}
void
_gnutls_write_datum8 (opaque * dest, gnutls_datum_t dat)
mhd_gtls_write_datum8 (opaque * dest, gnutls_datum_t dat)
{
dest[0] = (uint8_t) dat.size;
if (dat.data != NULL)
@@ -67,7 +67,7 @@ _gnutls_write_datum8 (opaque * dest, gnutls_datum_t dat)
int
_gnutls_set_datum_m (gnutls_datum_t * dat, const void *data,
mhd_gtls_set_datum_m (gnutls_datum_t * dat, const void *data,
size_t data_size, gnutls_alloc_function galloc_func)
{
if (data_size == 0 || data == NULL)
@@ -88,7 +88,7 @@ _gnutls_set_datum_m (gnutls_datum_t * dat, const void *data,
}
int
_gnutls_datum_append_m (gnutls_datum_t * dst, const void *data,
mhd_gtls_datum_append_m (gnutls_datum_t * dst, const void *data,
size_t data_size,
gnutls_realloc_function grealloc_func)
{
@@ -104,7 +104,7 @@ _gnutls_datum_append_m (gnutls_datum_t * dst, const void *data,
}
void
_gnutls_free_datum_m (gnutls_datum_t * dat, gnutls_free_function gfree_func)
mhd_gtls_free_datum_m (gnutls_datum_t * dat, gnutls_free_function gfree_func)
{
if (dat->data != NULL)
gfree_func (dat->data);
+11 -11
View File
@@ -22,19 +22,19 @@
*
*/
void _gnutls_write_datum16 (opaque * dest, gnutls_datum_t dat);
void _gnutls_write_datum24 (opaque * dest, gnutls_datum_t dat);
void _gnutls_write_datum32 (opaque * dest, gnutls_datum_t dat);
void _gnutls_write_datum8 (opaque * dest, gnutls_datum_t dat);
void mhd_gtls_write_datum16 (opaque * dest, gnutls_datum_t dat);
void mhd_gtls_write_datum24 (opaque * dest, gnutls_datum_t dat);
void mhd_gtls_write_datum32 (opaque * dest, gnutls_datum_t dat);
void mhd_gtls_write_datum8 (opaque * dest, gnutls_datum_t dat);
int _gnutls_set_datum_m (gnutls_datum_t * dat, const void *data,
int mhd_gtls_set_datum_m (gnutls_datum_t * dat, const void *data,
size_t data_size, gnutls_alloc_function);
#define _gnutls_set_datum( x, y, z) _gnutls_set_datum_m(x,y,z, gnutls_malloc)
#define _gnutls_sset_datum( x, y, z) _gnutls_set_datum_m(x,y,z, gnutls_secure_malloc)
#define _gnutls_set_datum( x, y, z) mhd_gtls_set_datum_m(x,y,z, gnutls_malloc)
#define _gnutls_sset_datum( x, y, z) mhd_gtls_set_datum_m(x,y,z, gnutls_secure_malloc)
int _gnutls_datum_append_m (gnutls_datum_t * dat, const void *data,
int mhd_gtls_datum_append_m (gnutls_datum_t * dat, const void *data,
size_t data_size, gnutls_realloc_function);
#define _gnutls_datum_append(x,y,z) _gnutls_datum_append_m(x,y,z, gnutls_realloc)
#define _gnutls_datum_append(x,y,z) mhd_gtls_datum_append_m(x,y,z, gnutls_realloc)
void _gnutls_free_datum_m (gnutls_datum_t * dat, gnutls_free_function);
#define _gnutls_free_datum(x) _gnutls_free_datum_m(x, gnutls_free)
void mhd_gtls_free_datum_m (gnutls_datum_t * dat, gnutls_free_function);
#define _gnutls_free_datum(x) mhd_gtls_free_datum_m(x, gnutls_free)
+12 -12
View File
@@ -35,11 +35,11 @@
his_key = X ^ y mod p;
// generate our secret and the public value (X) for it
X = gnutls_calc_dh_secret(&x, g, p);
X = mhd_gtls_calc_dh_secret(&x, g, p);
// now we can calculate the shared secret
key = gnutls_calc_dh_key(Y, x, g, p);
_gnutls_mpi_release(x);
_gnutls_mpi_release(g);
key = mhd_gtls_calc_dh_key(Y, x, g, p);
mhd_gtls_mpi_release(x);
mhd_gtls_mpi_release(g);
*/
#define MAX_BITS 18000
@@ -47,7 +47,7 @@
/* returns the public value (X), and the secret (ret_x).
*/
mpi_t
gnutls_calc_dh_secret (mpi_t * ret_x, mpi_t g, mpi_t prime)
mhd_gtls_calc_dh_secret (mpi_t * ret_x, mpi_t g, mpi_t prime)
{
mpi_t e, x;
int x_size = _gnutls_mpi_get_nbits (prime) - 1;
@@ -89,7 +89,7 @@ gnutls_calc_dh_secret (mpi_t * ret_x, mpi_t g, mpi_t prime)
if (ret_x)
*ret_x = NULL;
_gnutls_mpi_release (&x);
mhd_gtls_mpi_release (&x);
return NULL;
}
@@ -98,13 +98,13 @@ gnutls_calc_dh_secret (mpi_t * ret_x, mpi_t g, mpi_t prime)
if (ret_x)
*ret_x = x;
else
_gnutls_mpi_release (&x);
mhd_gtls_mpi_release (&x);
return e;
}
mpi_t
gnutls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime)
mhd_gtls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime)
{
mpi_t k;
int bits;
@@ -124,7 +124,7 @@ gnutls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime)
}
/*-
* _gnutls_get_dh_params - Returns the DH parameters pointer
* mhd_gtls_get_dh_params - Returns the DH parameters pointer
* @dh_params: is an DH parameters structure, or NULL.
* @func: is a callback function to receive the parameters or NULL.
* @session: a gnutls session.
@@ -132,10 +132,10 @@ gnutls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime)
* This function will return the dh parameters pointer.
*
-*/
gnutls_dh_params_t
_gnutls_get_dh_params (gnutls_dh_params_t dh_params,
mhd_gtls_dh_params_t
mhd_gtls_get_dh_params (mhd_gtls_dh_params_t dh_params,
gnutls_params_function * func,
gnutls_session_t session)
mhd_gtls_session_t session)
{
gnutls_params_st params;
int ret;
+7 -7
View File
@@ -25,14 +25,14 @@
#ifndef GNUTLS_DH_H
# define GNUTLS_DH_H
const mpi_t *_gnutls_dh_params_to_mpi (gnutls_dh_params_t);
mpi_t gnutls_calc_dh_secret (mpi_t * ret_x, mpi_t g, mpi_t prime);
mpi_t gnutls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime);
int _gnutls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned bits);
const mpi_t * mhd_gtls_dh_params_to_mpi (mhd_gtls_dh_params_t);
mpi_t mhd_gtls_calc_dh_secret (mpi_t * ret_x, mpi_t g, mpi_t prime);
mpi_t mhd_gtls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime);
int mhd_gtls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned bits);
gnutls_dh_params_t
_gnutls_get_dh_params (gnutls_dh_params_t dh_params,
mhd_gtls_dh_params_t
mhd_gtls_get_dh_params (mhd_gtls_dh_params_t dh_params,
gnutls_params_function * func,
gnutls_session_t session);
mhd_gtls_session_t session);
#endif
+20 -433
View File
@@ -36,7 +36,7 @@
/* returns the prime and the generator of DH params.
*/
const mpi_t *
_gnutls_dh_params_to_mpi (gnutls_dh_params_t dh_primes)
mhd_gtls_dh_params_to_mpi (mhd_gtls_dh_params_t dh_primes)
{
if (dh_primes == NULL || dh_primes->params[1] == NULL
|| dh_primes->params[0] == NULL)
@@ -48,7 +48,7 @@ _gnutls_dh_params_to_mpi (gnutls_dh_params_t dh_primes)
}
int
_gnutls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned int bits)
mhd_gtls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned int bits)
{
mpi_t g = NULL, prime = NULL;
gcry_error_t err;
@@ -75,7 +75,7 @@ _gnutls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned int bits)
if (times)
{
_gnutls_mpi_release (&prime);
mhd_gtls_mpi_release (&prime);
gcry_prime_release_factors (factors);
}
@@ -119,17 +119,17 @@ _gnutls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned int bits)
if (ret_g)
*ret_g = g;
else
_gnutls_mpi_release (&g);
mhd_gtls_mpi_release (&g);
if (ret_n)
*ret_n = prime;
else
_gnutls_mpi_release (&prime);
mhd_gtls_mpi_release (&prime);
return 0;
cleanup:gcry_prime_release_factors (factors);
_gnutls_mpi_release (&g);
_gnutls_mpi_release (&prime);
mhd_gtls_mpi_release (&g);
mhd_gtls_mpi_release (&prime);
return result;
@@ -139,60 +139,17 @@ cleanup:gcry_prime_release_factors (factors);
* generated one.
*/
/**
* gnutls_dh_params_import_raw - This function will import DH parameters
* @dh_params: Is a structure that will hold the prime numbers
* @prime: holds the new prime
* @generator: holds the new generator
*
* This function will replace the pair of prime and generator for use in
* the Diffie-Hellman key exchange. The new parameters should be stored in the
* appropriate gnutls_datum.
*
**/
int
gnutls_dh_params_import_raw (gnutls_dh_params_t dh_params,
const gnutls_datum_t * prime,
const gnutls_datum_t * generator)
{
mpi_t tmp_prime, tmp_g;
size_t siz;
siz = prime->size;
if (_gnutls_mpi_scan_nz (&tmp_prime, prime->data, &siz))
{
gnutls_assert ();
return GNUTLS_E_MPI_SCAN_FAILED;
}
siz = generator->size;
if (_gnutls_mpi_scan_nz (&tmp_g, generator->data, &siz))
{
_gnutls_mpi_release (&tmp_prime);
gnutls_assert ();
return GNUTLS_E_MPI_SCAN_FAILED;
}
/* store the generated values
*/
dh_params->params[0] = tmp_prime;
dh_params->params[1] = tmp_g;
return 0;
}
/**
* gnutls_dh_params_init - This function will initialize the DH parameters
* MHD_gnutls_dh_params_init - This function will initialize the DH parameters
* @dh_params: Is a structure that will hold the prime numbers
*
* This function will initialize the DH parameters structure.
*
**/
int
gnutls_dh_params_init (gnutls_dh_params_t * dh_params)
MHD_gnutls_dh_params_init (mhd_gtls_dh_params_t * dh_params)
{
(*dh_params) = gnutls_calloc (1, sizeof (dh_params_st));
(*dh_params) = gnutls_calloc (1, sizeof (mhd_gtls_dh_params_st));
if (*dh_params == NULL)
{
gnutls_assert ();
@@ -204,59 +161,35 @@ gnutls_dh_params_init (gnutls_dh_params_t * dh_params)
}
/**
* gnutls_dh_params_deinit - This function will deinitialize the DH parameters
* MHD_gnutls_dh_params_deinit - This function will deinitialize the DH parameters
* @dh_params: Is a structure that holds the prime numbers
*
* This function will deinitialize the DH parameters structure.
*
**/
void
gnutls_dh_params_deinit (gnutls_dh_params_t dh_params)
MHD_gnutls_dh_params_deinit (mhd_gtls_dh_params_t dh_params)
{
if (dh_params == NULL)
return;
_gnutls_mpi_release (&dh_params->params[0]);
_gnutls_mpi_release (&dh_params->params[1]);
mhd_gtls_mpi_release (&dh_params->params[0]);
mhd_gtls_mpi_release (&dh_params->params[1]);
gnutls_free (dh_params);
}
/**
* gnutls_dh_params_cpy - This function will copy a DH parameters structure
* @dst: Is the destination structure, which should be initialized.
* @src: Is the source structure
*
* This function will copy the DH parameters structure from source
* to destination.
*
**/
int
gnutls_dh_params_cpy (gnutls_dh_params_t dst, gnutls_dh_params_t src)
{
if (src == NULL)
return GNUTLS_E_INVALID_REQUEST;
dst->params[0] = _gnutls_mpi_copy (src->params[0]);
dst->params[1] = _gnutls_mpi_copy (src->params[1]);
if (dst->params[0] == NULL || dst->params[1] == NULL)
return GNUTLS_E_MEMORY_ERROR;
return 0;
}
/**
* gnutls_dh_params_generate2 - This function will generate new DH parameters
* MHD_gnutls_dh_params_generate2 - This function will generate new DH parameters
* @params: Is the structure that the DH parameters will be stored
* @bits: is the prime's number of bits
*
* This function will generate a new pair of prime and generator for use in
* This function will generate a new pair of prime and generator for use in
* the Diffie-Hellman key exchange. The new parameters will be allocated using
* gnutls_malloc() and will be stored in the appropriate datum.
* This function is normally slow.
*
* This function is normally slow.
*
* Note that the bits value should be one of 768, 1024, 2048, 3072 or 4096.
* Also note that the DH parameters are only useful to servers.
* Since clients use the parameters sent by the server, it's of
@@ -264,12 +197,12 @@ gnutls_dh_params_cpy (gnutls_dh_params_t dst, gnutls_dh_params_t src)
*
**/
int
gnutls_dh_params_generate2 (gnutls_dh_params_t params, unsigned int bits)
MHD_gnutls_dh_params_generate2 (mhd_gtls_dh_params_t params, unsigned int bits)
{
int ret;
ret =
_gnutls_dh_generate_prime (&params->params[1], &params->params[0], bits);
mhd_gtls_dh_generate_prime (&params->params[1], &params->params[0], bits);
if (ret < 0)
{
gnutls_assert ();
@@ -278,349 +211,3 @@ gnutls_dh_params_generate2 (gnutls_dh_params_t params, unsigned int bits)
return 0;
}
/**
* gnutls_dh_params_import_pkcs3 - This function will import DH params from a pkcs3 structure
* @params: A structure where the parameters will be copied to
* @pkcs3_params: should contain a PKCS3 DHParams structure PEM or DER encoded
* @format: the format of params. PEM or DER.
*
* This function will extract the DHParams found in a PKCS3 formatted
* structure. This is the format generated by "openssl dhparam" tool.
*
* If the structure is PEM encoded, it should have a header
* of "BEGIN DH PARAMETERS".
*
* In case of failure a negative value will be returned, and
* 0 on success.
*
**/
int
gnutls_dh_params_import_pkcs3 (gnutls_dh_params_t params,
const gnutls_datum_t * pkcs3_params,
gnutls_x509_crt_fmt_t format)
{
ASN1_TYPE c2;
int result, need_free = 0;
gnutls_datum_t _params;
if (format == GNUTLS_X509_FMT_PEM)
{
opaque *out;
result = _gnutls_fbase64_decode ("DH PARAMETERS", pkcs3_params->data,
pkcs3_params->size, &out);
if (result <= 0)
{
if (result == 0)
result = GNUTLS_E_INTERNAL_ERROR;
gnutls_assert ();
return result;
}
_params.data = out;
_params.size = result;
need_free = 1;
}
else
{
_params.data = pkcs3_params->data;
_params.size = pkcs3_params->size;
}
if ((result =
asn1_create_element (_gnutls_get_gnutls_asn (), "GNUTLS.DHParameter",
&c2)) != ASN1_SUCCESS)
{
gnutls_assert ();
if (need_free != 0)
{
gnutls_free (_params.data);
_params.data = NULL;
}
return _gnutls_asn2err (result);
}
result = asn1_der_decoding (&c2, _params.data, _params.size, NULL);
if (need_free != 0)
{
gnutls_free (_params.data);
_params.data = NULL;
}
if (result != ASN1_SUCCESS)
{
/* couldn't decode DER */
_gnutls_x509_log ("DHParams: Decoding error %d\n", result);
gnutls_assert ();
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
/* Read PRIME
*/
result = _gnutls_x509_read_int (c2, "prime", &params->params[0]);
if (result < 0)
{
asn1_delete_structure (&c2);
gnutls_assert ();
return result;
}
/* read the generator
*/
result = _gnutls_x509_read_int (c2, "base", &params->params[1]);
if (result < 0)
{
asn1_delete_structure (&c2);
_gnutls_mpi_release (&params->params[0]);
gnutls_assert ();
return result;
}
asn1_delete_structure (&c2);
return 0;
}
/**
* gnutls_dh_params_export_pkcs3 - This function will export DH params to a pkcs3 structure
* @params: Holds the DH parameters
* @format: the format of output params. One of PEM or DER.
* @params_data: will contain a PKCS3 DHParams structure PEM or DER encoded
* @params_data_size: holds the size of params_data (and will be replaced by the actual size of parameters)
*
* This function will export the given dh parameters to a PKCS3
* DHParams structure. This is the format generated by "openssl dhparam" tool.
* If the buffer provided is not long enough to hold the output, then
* GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.
*
* If the structure is PEM encoded, it will have a header
* of "BEGIN DH PARAMETERS".
*
* In case of failure a negative value will be returned, and
* 0 on success.
*
**/
int
gnutls_dh_params_export_pkcs3 (gnutls_dh_params_t params,
gnutls_x509_crt_fmt_t format,
unsigned char *params_data,
size_t * params_data_size)
{
ASN1_TYPE c2;
int result, _params_data_size;
size_t g_size, p_size;
opaque *p_data, *g_data;
opaque *all_data;
_gnutls_mpi_print_lz (NULL, &g_size, params->params[1]);
_gnutls_mpi_print_lz (NULL, &p_size, params->params[0]);
all_data = gnutls_malloc (g_size + p_size);
if (all_data == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
p_data = &all_data[0];
g_data = &all_data[p_size];
_gnutls_mpi_print_lz (p_data, &p_size, params->params[0]);
_gnutls_mpi_print_lz (g_data, &g_size, params->params[1]);
/* Ok. Now we have the data. Create the asn1 structures
*/
if ((result =
asn1_create_element (_gnutls_get_gnutls_asn (), "GNUTLS.DHParameter",
&c2)) != ASN1_SUCCESS)
{
gnutls_assert ();
gnutls_free (all_data);
return _gnutls_asn2err (result);
}
/* Write PRIME
*/
if ((result =
asn1_write_value (c2, "prime", p_data, p_size)) != ASN1_SUCCESS)
{
gnutls_assert ();
gnutls_free (all_data);
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
/* Write the GENERATOR
*/
if ((result =
asn1_write_value (c2, "base", g_data, g_size)) != ASN1_SUCCESS)
{
gnutls_assert ();
gnutls_free (all_data);
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
gnutls_free (all_data);
if ((result = asn1_write_value (c2, "privateValueLength",
NULL, 0)) != ASN1_SUCCESS)
{
gnutls_assert ();
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
if (format == GNUTLS_X509_FMT_DER)
{
if (params_data == NULL)
*params_data_size = 0;
_params_data_size = *params_data_size;
result =
asn1_der_coding (c2, "", params_data, &_params_data_size, NULL);
*params_data_size = _params_data_size;
asn1_delete_structure (&c2);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
if (result == ASN1_MEM_ERROR)
return GNUTLS_E_SHORT_MEMORY_BUFFER;
return _gnutls_asn2err (result);
}
}
else
{ /* PEM */
opaque *tmp;
opaque *out;
int len;
len = 0;
asn1_der_coding (c2, "", NULL, &len, NULL);
tmp = gnutls_malloc (len);
if (tmp == NULL)
{
gnutls_assert ();
asn1_delete_structure (&c2);
return GNUTLS_E_MEMORY_ERROR;
}
if ((result =
asn1_der_coding (c2, "", tmp, &len, NULL)) != ASN1_SUCCESS)
{
gnutls_assert ();
gnutls_free (tmp);
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
asn1_delete_structure (&c2);
result = _gnutls_fbase64_encode ("DH PARAMETERS", tmp, len, &out);
gnutls_free (tmp);
if (result < 0)
{
gnutls_assert ();
return result;
}
if (result == 0)
{ /* oooops */
gnutls_assert ();
gnutls_free (out);
return GNUTLS_E_INTERNAL_ERROR;
}
if ((unsigned) result + 1 > *params_data_size)
{
gnutls_assert ();
gnutls_free (out);
*params_data_size = result + 1;
return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
*params_data_size = result;
if (params_data)
{
memcpy (params_data, out, result);
params_data[result] = 0;
}
gnutls_free (out);
}
return 0;
}
/**
* gnutls_dh_params_export_raw - This function will export the raw DH parameters
* @params: Holds the DH parameters
* @prime: will hold the new prime
* @generator: will hold the new generator
* @bits: if non null will hold is the prime's number of bits
*
* This function will export the pair of prime and generator for use in
* the Diffie-Hellman key exchange. The new parameters will be allocated using
* gnutls_malloc() and will be stored in the appropriate datum.
*
**/
int
gnutls_dh_params_export_raw (gnutls_dh_params_t params,
gnutls_datum_t * prime,
gnutls_datum_t * generator, unsigned int *bits)
{
size_t size;
if (params->params[1] == NULL || params->params[0] == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
size = 0;
_gnutls_mpi_print (NULL, &size, params->params[1]);
generator->data = gnutls_malloc (size);
if (generator->data == NULL)
{
return GNUTLS_E_MEMORY_ERROR;
}
generator->size = size;
_gnutls_mpi_print (generator->data, &size, params->params[1]);
size = 0;
_gnutls_mpi_print (NULL, &size, params->params[0]);
prime->data = gnutls_malloc (size);
if (prime->data == NULL)
{
gnutls_free (generator->data);
generator->data = NULL;
return GNUTLS_E_MEMORY_ERROR;
}
prime->size = size;
_gnutls_mpi_print (prime->data, &size, params->params[0]);
if (bits)
*bits = _gnutls_mpi_get_nbits (params->params[0]);
return 0;
}
+6 -6
View File
@@ -263,7 +263,7 @@ static const gnutls_error_entry error_algorithms[] = {
/**
* gnutls_error_is_fatal - Returns non-zero in case of a fatal error
* MHD_gtls_error_is_fatal - Returns non-zero in case of a fatal error
* @error: is an error returned by a gnutls function. Error should be a negative value.
*
* If a function returns a negative value you may feed that value
@@ -279,7 +279,7 @@ static const gnutls_error_entry error_algorithms[] = {
*
**/
int
gnutls_error_is_fatal (int error)
MHD_gtls_error_is_fatal (int error)
{
int ret = 1;
@@ -294,14 +294,14 @@ gnutls_error_is_fatal (int error)
}
/**
* gnutls_perror - prints a string to stderr with a description of an error
* MHD_gtls_perror - prints a string to stderr with a description of an error
* @error: is an error returned by a gnutls function. Error is always a negative value.
*
* This function is like perror(). The only difference is that it accepts an
* error number returned by a gnutls function.
**/
void
gnutls_perror (int error)
MHD_gtls_perror (int error)
{
const char *ret = NULL;
@@ -314,7 +314,7 @@ gnutls_perror (int error)
/**
* gnutls_strerror - Returns a string with a description of an error
* MHD_gtls_strerror - Returns a string with a description of an error
* @error: is an error returned by a gnutls function. Error is always a negative value.
*
* This function is similar to strerror(). Differences: it accepts an error
@@ -322,7 +322,7 @@ gnutls_perror (int error)
* a descriptive string is sent instead of NULL.
**/
const char *
gnutls_strerror (int error)
MHD_gtls_strerror (int error)
{
const char *ret = NULL;
+41 -41
View File
@@ -43,26 +43,26 @@
#define MAX_EXT_SIZE 10
const int _gnutls_extensions_size = MAX_EXT_SIZE;
const int mhd_gtls_extensions_size = MAX_EXT_SIZE;
gnutls_extension_entry _gnutls_extensions[MAX_EXT_SIZE] = {
mhd_gtls_extension_entry mhd_gtls_extensions[MAX_EXT_SIZE] = {
GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_MAX_RECORD_SIZE,
EXTENSION_TLS,
_gnutls_max_record_recv_params,
_gnutls_max_record_send_params),
mhd_gtls_max_record_recv_params,
mhd_gtls_max_record_send_params),
GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_CERT_TYPE,
EXTENSION_TLS,
_gnutls_cert_type_recv_params,
_gnutls_cert_type_send_params),
mhd_gtls_cert_type_recv_params,
mhd_gtls_cert_type_send_params),
GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_SERVER_NAME,
EXTENSION_APPLICATION,
_gnutls_server_name_recv_params,
_gnutls_server_name_send_params),
mhd_gtls_server_name_recv_params,
mhd_gtls_server_name_send_params),
#ifdef ENABLE_OPRFI
GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_OPAQUE_PRF_INPUT,
EXTENSION_TLS,
_gnutls_oprfi_recv_params,
_gnutls_oprfi_send_params),
mhd_gtls_oprfi_recv_params,
mhd_gtls_oprfi_send_params),
#endif
#ifdef ENABLE_SRP
GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_SRP,
@@ -72,14 +72,14 @@ gnutls_extension_entry _gnutls_extensions[MAX_EXT_SIZE] = {
#endif
GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_INNER_APPLICATION,
EXTENSION_TLS,
_gnutls_inner_application_recv_params,
_gnutls_inner_application_send_params),
mhd_gtls_inner_app_rcv_params,
mhd_gtls_inner_app_send_params),
{0, 0, 0, 0}
};
#define GNUTLS_EXTENSION_LOOP2(b) \
gnutls_extension_entry *p; \
for(p = _gnutls_extensions; p->name != NULL; p++) { b ; }
mhd_gtls_extension_entry *p; \
for(p = mhd_gtls_extensions; p->name != NULL; p++) { b ; }
#define GNUTLS_EXTENSION_LOOP(a) \
GNUTLS_EXTENSION_LOOP2( if(p->type == type) { a; break; } )
@@ -87,10 +87,10 @@ gnutls_extension_entry _gnutls_extensions[MAX_EXT_SIZE] = {
/* EXTENSION functions */
ext_recv_func
_gnutls_ext_func_recv (uint16_t type, tls_ext_parse_type_t parse_type)
mhd_gtls_ext_recv_func
mhd_gtls_ext_func_recv (uint16_t type, mhd_gtls_ext_parse_type_t parse_type)
{
ext_recv_func ret = NULL;
mhd_gtls_ext_recv_func ret = NULL;
GNUTLS_EXTENSION_LOOP (if
(parse_type == EXTENSION_ANY
|| p->parse_type == parse_type) ret =
@@ -99,17 +99,17 @@ _gnutls_ext_func_recv (uint16_t type, tls_ext_parse_type_t parse_type)
}
ext_send_func
_gnutls_ext_func_send (uint16_t type)
mhd_gtls_ext_send_func
mhd_gtls_ext_func_send (uint16_t type)
{
ext_send_func ret = NULL;
mhd_gtls_ext_send_func ret = NULL;
GNUTLS_EXTENSION_LOOP (ret = p->gnutls_ext_func_send);
return ret;
}
const char *
_gnutls_extension_get_name (uint16_t type)
mhd_gtls_extension_get_name (uint16_t type)
{
const char *ret = NULL;
@@ -123,7 +123,7 @@ _gnutls_extension_get_name (uint16_t type)
* requested ones. Otherwise it's a fatal error.
*/
static int
_gnutls_extension_list_check (gnutls_session_t session, uint16_t type)
_gnutls_extension_list_check (mhd_gtls_session_t session, uint16_t type)
{
if (session->security_parameters.entity == GNUTLS_CLIENT)
{
@@ -140,15 +140,15 @@ _gnutls_extension_list_check (gnutls_session_t session, uint16_t type)
}
int
_gnutls_parse_extensions (gnutls_session_t session,
tls_ext_parse_type_t parse_type,
mhd_gtls_parse_extensions (mhd_gtls_session_t session,
mhd_gtls_ext_parse_type_t parse_type,
const opaque * data, int data_size)
{
int next, ret;
int pos = 0;
uint16_t type;
const opaque *sdata;
ext_recv_func ext_recv;
mhd_gtls_ext_recv_func ext_recv;
uint16_t size;
#ifdef DEBUG
@@ -159,14 +159,14 @@ _gnutls_parse_extensions (gnutls_session_t session,
{
_gnutls_debug_log ("EXT[%d]: expecting extension '%s'\n",
session,
_gnutls_extension_get_name (session->
mhd_gtls_extension_get_name (session->
internals.
extensions_sent[i]));
}
#endif
DECR_LENGTH_RET (data_size, 2, 0);
next = _gnutls_read_uint16 (data);
next = mhd_gtls_read_uint16 (data);
pos += 2;
DECR_LENGTH_RET (data_size, next, 0);
@@ -174,11 +174,11 @@ _gnutls_parse_extensions (gnutls_session_t session,
do
{
DECR_LENGTH_RET (next, 2, 0);
type = _gnutls_read_uint16 (&data[pos]);
type = mhd_gtls_read_uint16 (&data[pos]);
pos += 2;
_gnutls_debug_log ("EXT[%x]: Received extension '%s/%d'\n", session,
_gnutls_extension_get_name (type), type);
mhd_gtls_extension_get_name (type), type);
if ((ret = _gnutls_extension_list_check (session, type)) < 0)
{
@@ -187,14 +187,14 @@ _gnutls_parse_extensions (gnutls_session_t session,
}
DECR_LENGTH_RET (next, 2, 0);
size = _gnutls_read_uint16 (&data[pos]);
size = mhd_gtls_read_uint16 (&data[pos]);
pos += 2;
DECR_LENGTH_RET (next, size, 0);
sdata = &data[pos];
pos += size;
ext_recv = _gnutls_ext_func_recv (type, parse_type);
ext_recv = mhd_gtls_ext_func_recv (type, parse_type);
if (ext_recv == NULL)
continue;
if ((ret = ext_recv (session, sdata, size)) < 0)
@@ -215,7 +215,7 @@ _gnutls_parse_extensions (gnutls_session_t session,
* extensions are the ones we requested.
*/
static void
_gnutls_extension_list_add (gnutls_session_t session, uint16_t type)
_gnutls_extension_list_add (mhd_gtls_session_t session, uint16_t type)
{
if (session->security_parameters.entity == GNUTLS_CLIENT)
@@ -234,15 +234,15 @@ _gnutls_extension_list_add (gnutls_session_t session, uint16_t type)
}
int
_gnutls_gen_extensions (gnutls_session_t session, opaque * data,
mhd_gtls_gen_extensions (mhd_gtls_session_t session, opaque * data,
size_t data_size)
{
int size;
uint16_t pos = 0;
opaque *sdata;
int sdata_size;
ext_send_func ext_send;
gnutls_extension_entry *p;
mhd_gtls_ext_send_func ext_send;
mhd_gtls_extension_entry *p;
if (data_size < 2)
{
@@ -261,9 +261,9 @@ _gnutls_gen_extensions (gnutls_session_t session, opaque * data,
}
pos += 2;
for (p = _gnutls_extensions; p->name != NULL; p++)
for (p = mhd_gtls_extensions; p->name != NULL; p++)
{
ext_send = _gnutls_ext_func_send (p->type);
ext_send = mhd_gtls_ext_func_send (p->type);
if (ext_send == NULL)
continue;
size = ext_send (session, sdata, sdata_size);
@@ -277,11 +277,11 @@ _gnutls_gen_extensions (gnutls_session_t session, opaque * data,
}
/* write extension type */
_gnutls_write_uint16 (p->type, &data[pos]);
mhd_gtls_write_uint16 (p->type, &data[pos]);
pos += 2;
/* write size */
_gnutls_write_uint16 (size, &data[pos]);
mhd_gtls_write_uint16 (size, &data[pos]);
pos += 2;
memcpy (&data[pos], sdata, size);
@@ -292,7 +292,7 @@ _gnutls_gen_extensions (gnutls_session_t session, opaque * data,
_gnutls_extension_list_add (session, p->type);
_gnutls_debug_log ("EXT[%x]: Sending extension %s\n", session,
_gnutls_extension_get_name (p->type));
mhd_gtls_extension_get_name (p->type));
}
else if (size < 0)
{
@@ -305,7 +305,7 @@ _gnutls_gen_extensions (gnutls_session_t session, opaque * data,
size = pos;
pos -= 2; /* remove the size of the size header! */
_gnutls_write_uint16 (pos, data);
mhd_gtls_write_uint16 (pos, data);
if (size == 2)
{ /* empty */
+11 -11
View File
@@ -24,22 +24,22 @@
#include <gnutls_int.h>
const char *_gnutls_extension_get_name (uint16_t type);
int _gnutls_parse_extensions (gnutls_session_t, tls_ext_parse_type_t, const opaque *, int);
int _gnutls_gen_extensions (gnutls_session_t session, opaque * data,
const char * mhd_gtls_extension_get_name (uint16_t type);
int mhd_gtls_parse_extensions (mhd_gtls_session_t, mhd_gtls_ext_parse_type_t, const opaque *, int);
int mhd_gtls_gen_extensions (mhd_gtls_session_t session, opaque * data,
size_t data_size);
typedef int (*ext_recv_func) (gnutls_session_t, const opaque *, size_t); /* recv data */
typedef int (*ext_send_func) (gnutls_session_t, opaque *, size_t); /* send data */
typedef int (* mhd_gtls_ext_recv_func) (mhd_gtls_session_t, const opaque *, size_t); /* recv data */
typedef int (* mhd_gtls_ext_send_func) (mhd_gtls_session_t, opaque *, size_t); /* send data */
ext_send_func _gnutls_ext_func_send (uint16_t type);
ext_recv_func _gnutls_ext_func_recv (uint16_t type, tls_ext_parse_type_t);
mhd_gtls_ext_send_func mhd_gtls_ext_func_send (uint16_t type);
mhd_gtls_ext_recv_func mhd_gtls_ext_func_recv (uint16_t type, mhd_gtls_ext_parse_type_t);
typedef struct
{
const char *name;
uint16_t type;
tls_ext_parse_type_t parse_type;
ext_recv_func gnutls_ext_func_recv;
ext_send_func gnutls_ext_func_send;
} gnutls_extension_entry;
mhd_gtls_ext_parse_type_t parse_type;
mhd_gtls_ext_recv_func gnutls_ext_func_recv;
mhd_gtls_ext_send_func gnutls_ext_func_send;
} mhd_gtls_extension_entry;
+3 -3
View File
@@ -29,7 +29,7 @@
#include <auth_cert.h>
typedef int (*_gnutls_openpgp_verify_key_func)
(const gnutls_certificate_credentials_t,
(const mhd_gtls_cert_credentials_t,
const gnutls_datum_t *, int,
unsigned int *);
@@ -40,8 +40,8 @@ typedef time_t (*_gnutls_openpgp_crt_expiration_time_func)
(const gnutls_datum_t *);
typedef int (*_gnutls_openpgp_crt_request_func)
(gnutls_session_t, gnutls_datum_t *,
const gnutls_certificate_credentials_t,
(mhd_gtls_session_t, gnutls_datum_t *,
const mhd_gtls_cert_credentials_t,
opaque *, int);
typedef int (*_gnutls_openpgp_fingerprint_func)
+34 -35
View File
@@ -59,7 +59,7 @@ ASN1_TYPE _gnutls_pkix1_asn;
ASN1_TYPE _gnutls_gnutls_asn;
/**
* gnutls_global_set_log_function - This function sets the logging function
* MHD_gtls_global_set_log_function - This function sets the logging function
* @log_func: it's a log function
*
* This is the function where you set the logging function gnutls
@@ -71,13 +71,13 @@ ASN1_TYPE _gnutls_gnutls_asn;
* void (*gnutls_log_func)( int level, const char*);
**/
void
gnutls_global_set_log_function (gnutls_log_func log_func)
MHD_gtls_global_set_log_function (gnutls_log_func log_func)
{
_gnutls_log_func = log_func;
}
/**
* gnutls_global_set_log_level - This function sets the logging level
* MHD_gtls_global_set_log_level - This function sets the logging level
* @level: it's an integer from 0 to 9.
*
* This is the function that allows you to set the log level.
@@ -89,7 +89,7 @@ gnutls_global_set_log_function (gnutls_log_func log_func)
*
**/
void
gnutls_global_set_log_level (int level)
MHD_gtls_global_set_log_level (int level)
{
_gnutls_log_level = level;
}
@@ -105,7 +105,7 @@ extern void *(*gnutls_calloc) (size_t, size_t);
int _gnutls_is_secure_mem_null (const void *);
/**
* gnutls_global_set_mem_functions - This function sets the memory allocation functions
* MHD_gtls_global_set_mem_functions - This function sets the memory allocation functions
* @alloc_func: it's the default memory allocation function. Like malloc().
* @secure_alloc_func: This is the memory allocation function that will be used for sensitive data.
* @is_secure_func: a function that returns 0 if the memory given is not secure. May be NULL.
@@ -118,17 +118,16 @@ int _gnutls_is_secure_mem_null (const void *);
* This function is provided to set the memory allocation functions to
* something other than the defaults (ie the gcrypt allocation functions).
*
* This function must be called before gnutls_global_init() is called.
* This function must be called before MHD_gnutls_global_init() is called.
*
**/
void
gnutls_global_set_mem_functions (gnutls_alloc_function alloc_func,
gnutls_alloc_function
secure_alloc_func,
gnutls_is_secure_function
is_secure_func,
gnutls_realloc_function realloc_func,
gnutls_free_function free_func)
void MHD_gtls_global_set_mem_functions(gnutls_alloc_function alloc_func,
gnutls_alloc_function
secure_alloc_func,
gnutls_is_secure_function
is_secure_func,
gnutls_realloc_function realloc_func,
gnutls_free_function free_func)
{
gnutls_secure_malloc = secure_alloc_func;
gnutls_malloc = alloc_func;
@@ -148,10 +147,10 @@ gnutls_global_set_mem_functions (gnutls_alloc_function alloc_func,
gnutls_calloc = calloc;
}
else
{ /* use the included ones */
gnutls_calloc = _gnutls_calloc;
{ /* use the included ones */
gnutls_calloc = mhd_gtls_calloc;
}
gnutls_strdup = _gnutls_strdup;
gnutls_strdup = mhd_gtls_strdup;
}
@@ -167,12 +166,12 @@ _gnutls_gcry_log_handler (void *dummy, int level,
static int _gnutls_init = 0;
/**
* gnutls_global_init - This function initializes the global data to defaults.
* MHD_gnutls_global_init - This function initializes the global data to defaults.
*
* This function initializes the global data to defaults.
* Every gnutls application has a global data which holds common parameters
* shared by gnutls session structures.
* You must call gnutls_global_deinit() when gnutls usage is no longer needed
* You must call MHD_gnutls_global_deinit() when gnutls usage is no longer needed
* Returns zero on success.
*
* Note that this function will also initialize libgcrypt, if it has not
@@ -181,8 +180,8 @@ static int _gnutls_init = 0;
* want to disable libgcrypt's internal lockings etc.
*
* This function increment a global counter, so that
* gnutls_global_deinit() only releases resources when it has been
* called as many times as gnutls_global_init(). This is useful when
* MHD_gnutls_global_deinit() only releases resources when it has been
* called as many times as MHD_gnutls_global_init(). This is useful when
* GnuTLS is used by more than one library in an application. This
* function can be called many times, but will only do something the
* first time.
@@ -197,7 +196,7 @@ static int _gnutls_init = 0;
*
**/
int
gnutls_global_init (void)
MHD_gnutls_global_init (void)
{
int result = 0;
int res;
@@ -279,7 +278,7 @@ gnutls_global_init (void)
}
#ifdef DEBUG
gnutls_global_set_log_function (MHD_tls_log_func);
MHD_gtls_global_set_log_function (MHD_tls_log_func);
#endif
/* initialize parser
@@ -308,17 +307,17 @@ gnutls_global_init (void)
}
/**
* gnutls_global_deinit - This function deinitializes the global data
* MHD_gnutls_global_deinit - This function deinitializes the global data
*
* This function deinitializes the global data, that were initialized
* using gnutls_global_init().
* using MHD_gnutls_global_init().
*
* Note! This function is not thread safe. See the discussion for
* gnutls_global_init() for more information.
* MHD_gnutls_global_init() for more information.
*
**/
void
gnutls_global_deinit (void)
MHD_gnutls_global_deinit (void)
{
if (_gnutls_init == 1)
{
@@ -337,7 +336,7 @@ gnutls_global_deinit (void)
*/
/**
* gnutls_transport_set_pull_function - This function sets a read like function
* MHD_gnutls_transport_set_pull_function - This function sets a read like function
* @pull_func: a callback function similar to read()
* @session: gnutls session
*
@@ -347,17 +346,17 @@ gnutls_global_deinit (void)
* probably be ok.
*
* PULL_FUNC is of the form,
* ssize_t (*gnutls_pull_func)(gnutls_transport_ptr_t, void*, size_t);
* ssize_t (*mhd_gtls_pull_func)(gnutls_transport_ptr_t, void*, size_t);
**/
void
gnutls_transport_set_pull_function (gnutls_session_t session,
gnutls_pull_func pull_func)
MHD_gnutls_transport_set_pull_function (mhd_gtls_session_t session,
mhd_gtls_pull_func pull_func)
{
session->internals._gnutls_pull_func = pull_func;
}
/**
* gnutls_transport_set_push_function - This function sets the function to send data
* MHD_gnutls_transport_set_push_function - This function sets the function to send data
* @push_func: a callback function similar to write()
* @session: gnutls session
*
@@ -368,11 +367,11 @@ gnutls_transport_set_pull_function (gnutls_session_t session,
* specify this function for gnutls to be able to send data.
*
* PUSH_FUNC is of the form,
* ssize_t (*gnutls_push_func)(gnutls_transport_ptr_t, const void*, size_t);
* ssize_t (*mhd_gtls_push_func)(gnutls_transport_ptr_t, const void*, size_t);
**/
void
gnutls_transport_set_push_function (gnutls_session_t session,
gnutls_push_func push_func)
MHD_gnutls_transport_set_push_function (mhd_gtls_session_t session,
mhd_gtls_push_func push_func)
{
session->internals._gnutls_push_func = push_func;
}
+1 -1
View File
@@ -27,7 +27,7 @@
#include <libtasn1.h>
/* this mutex is used to synchronize threads attemting call gnutls_global_init / gnutls_global_deinit */
/* this mutex is used to synchronize threads attemting call MHD_gnutls_global_init / MHD_gnutls_global_deinit */
pthread_mutex_t gnutls_init_mutex;
int gnutls_is_secure_memory (const void *mem);
+247 -247
View File
@@ -46,7 +46,7 @@
#include "gnutls_record.h"
#include "gnutls_state.h"
#include "gnutls_rsa_export.h" /* for gnutls_get_rsa_params() */
#include "auth_anon.h" /* for gnutls_anon_server_credentials_t */
#include "auth_anon.h" /* for mhd_gtls_anon_server_credentials_t */
#include "gc.h"
#ifdef HANDSHAKE_DEBUG
@@ -58,20 +58,20 @@
#define TRUE 1
#define FALSE 0
int _gnutls_server_select_comp_method (gnutls_session_t session,
int _gnutls_server_select_comp_method (mhd_gtls_session_t session,
opaque * data, int datalen);
/* Clears the handshake hash buffers and handles.
*/
inline static void
_gnutls_handshake_hash_buffers_clear (gnutls_session_t session)
_gnutls_handshake_hash_buffers_clear (mhd_gtls_session_t session)
{
_gnutls_hash_deinit (session->internals.handshake_mac_handle_md5, NULL);
_gnutls_hash_deinit (session->internals.handshake_mac_handle_sha, NULL);
mhd_gnutls_hash_deinit (session->internals.handshake_mac_handle_md5, NULL);
mhd_gnutls_hash_deinit (session->internals.handshake_mac_handle_sha, NULL);
session->internals.handshake_mac_handle_md5 = NULL;
session->internals.handshake_mac_handle_sha = NULL;
_gnutls_handshake_buffer_clear (session);
mhd_gtls_handshake_buffer_clear (session);
}
/* this will copy the required values for resuming to
@@ -79,7 +79,7 @@ _gnutls_handshake_hash_buffers_clear (gnutls_session_t session)
* this will keep as less data to security_parameters.
*/
static void
resume_copy_required_values (gnutls_session_t session)
resume_copy_required_values (mhd_gtls_session_t session)
{
/* get the new random values */
memcpy (session->internals.resumed_security_parameters.
@@ -107,7 +107,7 @@ resume_copy_required_values (gnutls_session_t session)
session->security_parameters.entity =
session->internals.resumed_security_parameters.entity;
_gnutls_set_current_version (session,
mhd_gtls_set_current_version (session,
session->internals.
resumed_security_parameters.version);
@@ -122,13 +122,13 @@ resume_copy_required_values (gnutls_session_t session)
}
void
_gnutls_set_server_random (gnutls_session_t session, uint8_t * rnd)
mhd_gtls_set_server_random (mhd_gtls_session_t session, uint8_t * rnd)
{
memcpy (session->security_parameters.server_random, rnd, TLS_RANDOM_SIZE);
}
void
_gnutls_set_client_random (gnutls_session_t session, uint8_t * rnd)
mhd_gtls_set_client_random (mhd_gtls_session_t session, uint8_t * rnd)
{
memcpy (session->security_parameters.client_random, rnd, TLS_RANDOM_SIZE);
}
@@ -138,25 +138,25 @@ _gnutls_set_client_random (gnutls_session_t session, uint8_t * rnd)
#define SSL3_SERVER_MSG "SRVR"
#define SSL_MSG_LEN 4
static int
_gnutls_ssl3_finished (gnutls_session_t session, int type, opaque * ret)
_gnutls_ssl3_finished (mhd_gtls_session_t session, int type, opaque * ret)
{
const int siz = SSL_MSG_LEN;
mac_hd_t td_md5;
mac_hd_t td_sha;
const char *mesg;
td_md5 = _gnutls_hash_copy (session->internals.handshake_mac_handle_md5);
td_md5 = mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_md5);
if (td_md5 == NULL)
{
gnutls_assert ();
return GNUTLS_E_HASH_FAILED;
}
td_sha = _gnutls_hash_copy (session->internals.handshake_mac_handle_sha);
td_sha = mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_sha);
if (td_sha == NULL)
{
gnutls_assert ();
_gnutls_hash_deinit (td_md5, NULL);
mhd_gnutls_hash_deinit (td_md5, NULL);
return GNUTLS_E_HASH_FAILED;
}
@@ -169,13 +169,13 @@ _gnutls_ssl3_finished (gnutls_session_t session, int type, opaque * ret)
mesg = SSL3_CLIENT_MSG;
}
_gnutls_hash (td_md5, mesg, siz);
_gnutls_hash (td_sha, mesg, siz);
mhd_gnutls_hash (td_md5, mesg, siz);
mhd_gnutls_hash (td_sha, mesg, siz);
_gnutls_mac_deinit_ssl3_handshake (td_md5, ret,
mhd_gnutls_mac_deinit_ssl3_handshake (td_md5, ret,
session->security_parameters.
master_secret, TLS_MASTER_SIZE);
_gnutls_mac_deinit_ssl3_handshake (td_sha, &ret[16],
mhd_gnutls_mac_deinit_ssl3_handshake (td_sha, &ret[16],
session->security_parameters.
master_secret, TLS_MASTER_SIZE);
@@ -187,7 +187,7 @@ _gnutls_ssl3_finished (gnutls_session_t session, int type, opaque * ret)
#define CLIENT_MSG "client finished"
#define TLS_MSG_LEN 15
int
_gnutls_finished (gnutls_session_t session, int type, void *ret)
_gnutls_finished (mhd_gtls_session_t session, int type, void *ret)
{
const int siz = TLS_MSG_LEN;
opaque concat[36];
@@ -195,12 +195,12 @@ _gnutls_finished (gnutls_session_t session, int type, void *ret)
const char *mesg;
mac_hd_t td_md5 = NULL;
mac_hd_t td_sha;
gnutls_protocol_t ver = gnutls_protocol_get_version (session);
gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session);
if (ver < MHD_GNUTLS_TLS1_2)
{
td_md5 =
_gnutls_hash_copy (session->internals.handshake_mac_handle_md5);
mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_md5);
if (td_md5 == NULL)
{
gnutls_assert ();
@@ -208,23 +208,23 @@ _gnutls_finished (gnutls_session_t session, int type, void *ret)
}
}
td_sha = _gnutls_hash_copy (session->internals.handshake_mac_handle_sha);
td_sha = mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_sha);
if (td_sha == NULL)
{
gnutls_assert ();
_gnutls_hash_deinit (td_md5, NULL);
mhd_gnutls_hash_deinit (td_md5, NULL);
return GNUTLS_E_HASH_FAILED;
}
if (ver < MHD_GNUTLS_TLS1_2)
{
_gnutls_hash_deinit (td_md5, concat);
_gnutls_hash_deinit (td_sha, &concat[16]);
mhd_gnutls_hash_deinit (td_md5, concat);
mhd_gnutls_hash_deinit (td_sha, &concat[16]);
len = 20 + 16;
}
else
{
_gnutls_hash_deinit (td_sha, concat);
mhd_gnutls_hash_deinit (td_sha, concat);
len = 20;
}
@@ -237,7 +237,7 @@ _gnutls_finished (gnutls_session_t session, int type, void *ret)
mesg = CLIENT_MSG;
}
return _gnutls_PRF (session, session->security_parameters.master_secret,
return mhd_gtls_PRF (session, session->security_parameters.master_secret,
TLS_MASTER_SIZE, mesg, siz, concat, len, 12, ret);
}
@@ -245,7 +245,7 @@ _gnutls_finished (gnutls_session_t session, int type, void *ret)
* and put it to dst.
*/
int
_gnutls_tls_create_random (opaque * dst)
mhd_gtls_tls_create_random (opaque * dst)
{
uint32_t tim;
@@ -256,7 +256,7 @@ _gnutls_tls_create_random (opaque * dst)
tim = time (NULL);
/* generate server random value */
_gnutls_write_uint32 (tim, dst);
mhd_gtls_write_uint32 (tim, dst);
if (gc_nonce (&dst[4], TLS_RANDOM_SIZE - 4) != GC_OK)
{
@@ -270,18 +270,18 @@ _gnutls_tls_create_random (opaque * dst)
/* returns the 0 on success or a negative value.
*/
int
_gnutls_negotiate_version (gnutls_session_t session,
mhd_gtls_negotiate_version (mhd_gtls_session_t session,
gnutls_protocol_t adv_version)
{
int ret;
/* if we do not support that version */
if (_gnutls_version_is_supported (session, adv_version) == 0)
if (mhd_gtls_version_is_supported (session, adv_version) == 0)
{
/* If he requested something we do not support
* then we send him the highest we support.
*/
ret = _gnutls_version_max (session);
ret = mhd_gtls_version_max (session);
if (ret == MHD_GNUTLS_VERSION_UNKNOWN)
{
/* this check is not really needed.
@@ -295,13 +295,13 @@ _gnutls_negotiate_version (gnutls_session_t session,
ret = adv_version;
}
_gnutls_set_current_version (session, ret);
mhd_gtls_set_current_version (session, ret);
return ret;
}
int
_gnutls_user_hello_func (gnutls_session session,
mhd_gtls_user_hello_func (gnutls_session session,
gnutls_protocol_t adv_version)
{
int ret;
@@ -317,7 +317,7 @@ _gnutls_user_hello_func (gnutls_session session,
/* Here we need to renegotiate the version since the callee might
* have disabled some TLS versions.
*/
ret = _gnutls_negotiate_version (session, adv_version);
ret = mhd_gtls_negotiate_version (session, adv_version);
if (ret < 0)
{
gnutls_assert ();
@@ -333,7 +333,7 @@ _gnutls_user_hello_func (gnutls_session session,
* since SSL version 2.0 is not supported).
*/
int
_gnutls_read_client_hello (gnutls_session_t session, opaque * data,
_gnutls_read_client_hello (mhd_gtls_session_t session, opaque * data,
int datalen)
{
uint8_t session_id_len;
@@ -349,11 +349,11 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
_gnutls_handshake_log ("HSK[%x]: Client's version: %d.%d\n", session,
data[pos], data[pos + 1]);
adv_version = _gnutls_version_get (data[pos], data[pos + 1]);
adv_version = mhd_gtls_version_get (data[pos], data[pos + 1]);
set_adv_version (session, data[pos], data[pos + 1]);
pos += 2;
neg_version = _gnutls_negotiate_version (session, adv_version);
neg_version = mhd_gtls_negotiate_version (session, adv_version);
if (neg_version < 0)
{
gnutls_assert ();
@@ -363,11 +363,11 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
/* Read client random value.
*/
DECR_LEN (len, TLS_RANDOM_SIZE);
_gnutls_set_client_random (session, &data[pos]);
mhd_gtls_set_client_random (session, &data[pos]);
pos += TLS_RANDOM_SIZE;
_gnutls_tls_create_random (rnd);
_gnutls_set_server_random (session, rnd);
mhd_gtls_tls_create_random (rnd);
mhd_gtls_set_server_random (session, rnd);
session->security_parameters.timestamp = time (NULL);
@@ -389,11 +389,11 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
{ /* resumed! */
resume_copy_required_values (session);
session->internals.resumed = RESUME_TRUE;
return _gnutls_user_hello_func (session, adv_version);
return mhd_gtls_user_hello_func (session, adv_version);
}
else
{
_gnutls_generate_session_id (session->security_parameters.
mhd_gtls_generate_session_id (session->security_parameters.
session_id,
&session->security_parameters.
session_id_size);
@@ -404,7 +404,7 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
/* Remember ciphersuites for later
*/
DECR_LEN (len, 2);
suite_size = _gnutls_read_uint16 (&data[pos]);
suite_size = mhd_gtls_read_uint16 (&data[pos]);
pos += 2;
DECR_LEN (len, suite_size);
@@ -424,7 +424,7 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
*/
if (neg_version >= MHD_GNUTLS_TLS1_0)
{
ret = _gnutls_parse_extensions (session, EXTENSION_APPLICATION, &data[pos], len); /* len is the rest of the parsed length */
ret = mhd_gtls_parse_extensions (session, EXTENSION_APPLICATION, &data[pos], len); /* len is the rest of the parsed length */
if (ret < 0)
{
gnutls_assert ();
@@ -432,7 +432,7 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
}
}
ret = _gnutls_user_hello_func (session, adv_version);
ret = mhd_gtls_user_hello_func (session, adv_version);
if (ret < 0)
{
gnutls_assert ();
@@ -441,7 +441,7 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
if (neg_version >= MHD_GNUTLS_TLS1_0)
{
ret = _gnutls_parse_extensions (session, EXTENSION_TLS, &data[pos], len); /* len is the rest of the parsed length */
ret = mhd_gtls_parse_extensions (session, EXTENSION_TLS, &data[pos], len); /* len is the rest of the parsed length */
if (ret < 0)
{
gnutls_assert ();
@@ -451,7 +451,7 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
/* select an appropriate cipher suite
*/
ret = _gnutls_server_select_suite (session, suite_ptr, suite_size);
ret = mhd_gtls_server_select_suite (session, suite_ptr, suite_size);
if (ret < 0)
{
gnutls_assert ();
@@ -472,7 +472,7 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
/* here we hash all pending data.
*/
inline static int
_gnutls_handshake_hash_pending (gnutls_session_t session)
_gnutls_handshake_hash_pending (mhd_gtls_session_t session)
{
size_t siz;
int ret;
@@ -487,7 +487,7 @@ _gnutls_handshake_hash_pending (gnutls_session_t session)
/* We check if there are pending data to hash.
*/
if ((ret = _gnutls_handshake_buffer_get_ptr (session, &data, &siz)) < 0)
if ((ret = mhd_gtls_handshake_buffer_get_ptr (session, &data, &siz)) < 0)
{
gnutls_assert ();
return ret;
@@ -495,11 +495,11 @@ _gnutls_handshake_hash_pending (gnutls_session_t session)
if (siz > 0)
{
_gnutls_hash (session->internals.handshake_mac_handle_sha, data, siz);
_gnutls_hash (session->internals.handshake_mac_handle_md5, data, siz);
mhd_gnutls_hash (session->internals.handshake_mac_handle_sha, data, siz);
mhd_gnutls_hash (session->internals.handshake_mac_handle_md5, data, siz);
}
_gnutls_handshake_buffer_empty (session);
mhd_gtls_handshake_buffer_empty (session);
return 0;
}
@@ -510,7 +510,7 @@ _gnutls_handshake_hash_pending (gnutls_session_t session)
* we send.
*/
int
_gnutls_send_finished (gnutls_session_t session, int again)
_gnutls_send_finished (mhd_gtls_session_t session, int again)
{
uint8_t data[36];
int ret;
@@ -529,7 +529,7 @@ _gnutls_send_finished (gnutls_session_t session, int again)
return ret;
}
if (gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
{
ret =
_gnutls_ssl3_finished (session,
@@ -553,7 +553,7 @@ _gnutls_send_finished (gnutls_session_t session, int again)
}
ret =
_gnutls_send_handshake (session, data, data_size,
mhd_gtls_send_handshake (session, data, data_size,
GNUTLS_HANDSHAKE_FINISHED);
return ret;
@@ -563,7 +563,7 @@ _gnutls_send_finished (gnutls_session_t session, int again)
* went fine we have negotiated a secure connection
*/
int
_gnutls_recv_finished (gnutls_session_t session)
_gnutls_recv_finished (mhd_gtls_session_t session)
{
uint8_t data[36], *vrfy;
int data_size;
@@ -571,7 +571,7 @@ _gnutls_recv_finished (gnutls_session_t session)
int vrfysize;
ret =
_gnutls_recv_handshake (session, &vrfy, &vrfysize,
mhd_gtls_recv_handshake (session, &vrfy, &vrfysize,
GNUTLS_HANDSHAKE_FINISHED, MANDATORY_PACKET);
if (ret < 0)
{
@@ -581,7 +581,7 @@ _gnutls_recv_finished (gnutls_session_t session)
}
if (gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
{
data_size = 36;
}
@@ -597,7 +597,7 @@ _gnutls_recv_finished (gnutls_session_t session)
return GNUTLS_E_ERROR_IN_FINISHED_PACKET;
}
if (gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
{
ret =
_gnutls_ssl3_finished (session,
@@ -650,11 +650,11 @@ _gnutls_server_find_pk_algos_in_ciphersuites (const opaque *
for (j = 0; j < datalen; j += 2)
{
memcpy (&cs.suite, &data[j], 2);
kx = _gnutls_cipher_suite_get_kx_algo (&cs);
kx = mhd_gtls_cipher_suite_get_kx_algo (&cs);
if (_gnutls_map_kx_get_cred (kx, 1) == MHD_GNUTLS_CRD_CERTIFICATE)
if (mhd_gtls_map_kx_get_cred (kx, 1) == MHD_GNUTLS_CRD_CERTIFICATE)
{
algo = _gnutls_map_pk_get_pk (kx);
algo = mhd_gtls_map_pk_get_pk (kx);
if (algo != prev_algo && prev_algo != 0)
return GNUTLS_PK_ANY;
@@ -670,7 +670,7 @@ _gnutls_server_find_pk_algos_in_ciphersuites (const opaque *
* it adds the suite to the session and performs some checks.
*/
int
_gnutls_server_select_suite (gnutls_session_t session, opaque * data,
mhd_gtls_server_select_suite (mhd_gtls_session_t session, opaque * data,
int datalen)
{
int x, i, j;
@@ -682,7 +682,7 @@ _gnutls_server_select_suite (gnutls_session_t session, opaque * data,
pk_algo = _gnutls_server_find_pk_algos_in_ciphersuites (data, datalen);
x = _gnutls_supported_ciphersuites (session, &ciphers);
x = mhd_gtls_supported_ciphersuites (session, &ciphers);
if (x < 0)
{ /* the case x==0 is handled within the function. */
gnutls_assert ();
@@ -693,7 +693,7 @@ _gnutls_server_select_suite (gnutls_session_t session, opaque * data,
* the certificate requested, or to the
* authentication requested (e.g. SRP).
*/
x = _gnutls_remove_unwanted_ciphersuites (session, &ciphers, x, pk_algo);
x = mhd_gtls_remove_unwanted_ciphersuites (session, &ciphers, x, pk_algo);
if (x <= 0)
{
gnutls_assert ();
@@ -719,12 +719,12 @@ _gnutls_server_select_suite (gnutls_session_t session, opaque * data,
for (j = 0; j < datalen; j += 2)
{
memcpy (&cs.suite, &data[j], 2);
_gnutls_handshake_log ("\t%s\n", _gnutls_cipher_suite_get_name (&cs));
_gnutls_handshake_log ("\t%s\n", mhd_gtls_cipher_suite_get_name (&cs));
}
_gnutls_handshake_log ("HSK[%x]: Supported cipher suites: \n", session);
for (j = 0; j < x; j++)
_gnutls_handshake_log ("\t%s\n",
_gnutls_cipher_suite_get_name (&ciphers[j]));
mhd_gtls_cipher_suite_get_name (&ciphers[j]));
#endif
memset (session->security_parameters.current_cipher_suite.suite, '\0', 2);
@@ -740,7 +740,7 @@ _gnutls_server_select_suite (gnutls_session_t session, opaque * data,
_gnutls_handshake_log
("HSK[%x]: Selected cipher suite: %s\n", session,
_gnutls_cipher_suite_get_name (&cs));
mhd_gtls_cipher_suite_get_name (&cs));
memcpy (session->security_parameters.current_cipher_suite.
suite, ciphers[i].suite, 2);
retval = 0;
@@ -760,9 +760,9 @@ finish:
/* check if the credentials (username, public key etc.) are ok
*/
if (_gnutls_get_kx_cred
if (mhd_gtls_get_kx_cred
(session,
_gnutls_cipher_suite_get_kx_algo (&session->security_parameters.
mhd_gtls_cipher_suite_get_kx_algo (&session->security_parameters.
current_cipher_suite),
&err) == NULL && err != 0)
{
@@ -771,12 +771,12 @@ finish:
}
/* set the mod_auth_st to the appropriate struct
/* set the mhd_gtls_mod_auth_st to the appropriate struct
* according to the KX algorithm. This is needed since all the
* handshake functions are read from there;
*/
session->internals.auth_struct =
_gnutls_kx_auth_struct (_gnutls_cipher_suite_get_kx_algo
mhd_gtls_kx_auth_struct (mhd_gtls_cipher_suite_get_kx_algo
(&session->security_parameters.
current_cipher_suite));
if (session->internals.auth_struct == NULL)
@@ -797,13 +797,13 @@ finish:
/* This selects the best supported compression method from the ones provided
*/
int
_gnutls_server_select_comp_method (gnutls_session_t session,
_gnutls_server_select_comp_method (mhd_gtls_session_t session,
opaque * data, int datalen)
{
int x, i, j;
uint8_t *comps;
x = _gnutls_supported_compression_methods (session, &comps);
x = mhd_gtls_supported_compression_methods (session, &comps);
if (x < 0)
{
gnutls_assert ();
@@ -820,14 +820,14 @@ _gnutls_server_select_comp_method (gnutls_session_t session,
if (comps[i] == data[j])
{
gnutls_compression_method_t method =
_gnutls_compression_get_id (comps[i]);
mhd_gtls_compression_get_id (comps[i]);
session->internals.compression_method = method;
gnutls_free (comps);
_gnutls_handshake_log
("HSK[%x]: Selected Compression Method: %s\n", session,
gnutls_compression_get_name (session->internals.
MHD_gnutls_compression_get_name (session->internals.
compression_method));
@@ -851,7 +851,7 @@ _gnutls_server_select_comp_method (gnutls_session_t session,
* (until it returns ok), with NULL parameters.
*/
int
_gnutls_send_empty_handshake (gnutls_session_t session,
_gnutls_send_empty_handshake (mhd_gtls_session_t session,
gnutls_handshake_description_t type, int again)
{
opaque data = 0;
@@ -862,13 +862,13 @@ _gnutls_send_empty_handshake (gnutls_session_t session,
else
ptr = NULL;
return _gnutls_send_handshake (session, ptr, 0, type);
return mhd_gtls_send_handshake (session, ptr, 0, type);
}
/* This function will hash the handshake message we sent. */
static int
_gnutls_handshake_hash_add_sent (gnutls_session_t session,
_gnutls_handshake_hash_add_sent (mhd_gtls_session_t session,
gnutls_handshake_description_t type,
opaque * dataptr, uint32_t datalen)
{
@@ -882,9 +882,9 @@ _gnutls_handshake_hash_add_sent (gnutls_session_t session,
if (type != GNUTLS_HANDSHAKE_HELLO_REQUEST)
{
_gnutls_hash (session->internals.handshake_mac_handle_sha, dataptr,
mhd_gnutls_hash (session->internals.handshake_mac_handle_sha, dataptr,
datalen);
_gnutls_hash (session->internals.handshake_mac_handle_md5, dataptr,
mhd_gnutls_hash (session->internals.handshake_mac_handle_md5, dataptr,
datalen);
}
@@ -893,12 +893,12 @@ _gnutls_handshake_hash_add_sent (gnutls_session_t session,
/* This function sends a handshake message of type 'type' containing the
* data specified here. If the previous _gnutls_send_handshake() returned
* data specified here. If the previous mhd_gtls_send_handshake() returned
* GNUTLS_E_AGAIN or GNUTLS_E_INTERRUPTED, then it must be called again
* (until it returns ok), with NULL parameters.
*/
int
_gnutls_send_handshake (gnutls_session_t session, void *i_data,
mhd_gtls_send_handshake (mhd_gtls_session_t session, void *i_data,
uint32_t i_datasize,
gnutls_handshake_description_t type)
{
@@ -912,7 +912,7 @@ _gnutls_send_handshake (gnutls_session_t session, void *i_data,
/* we are resuming a previously interrupted
* send.
*/
ret = _gnutls_handshake_io_write_flush (session);
ret = mhd_gtls_handshake_io_write_flush (session);
return ret;
}
@@ -933,7 +933,7 @@ _gnutls_send_handshake (gnutls_session_t session, void *i_data,
}
data[pos++] = (uint8_t) type;
_gnutls_write_uint24 (i_datasize, &data[pos]);
mhd_gtls_write_uint24 (i_datasize, &data[pos]);
pos += 3;
if (i_datasize > 0)
@@ -953,7 +953,7 @@ _gnutls_send_handshake (gnutls_session_t session, void *i_data,
session->internals.last_handshake_out = type;
ret =
_gnutls_handshake_io_send_int (session, GNUTLS_HANDSHAKE, type,
mhd_gtls_handshake_io_send_int (session, GNUTLS_HANDSHAKE, type,
data, datasize);
_gnutls_handshake_log ("HSK[%x]: %s was sent [%ld bytes]\n",
@@ -972,7 +972,7 @@ _gnutls_send_handshake (gnutls_session_t session, void *i_data,
*/
#define SSL2_HEADERS 1
static int
_gnutls_recv_handshake_header (gnutls_session_t session,
_gnutls_recv_handshake_header (mhd_gtls_session_t session,
gnutls_handshake_description_t type,
gnutls_handshake_description_t * recv_type)
{
@@ -1006,7 +1006,7 @@ _gnutls_recv_handshake_header (gnutls_session_t session,
if (session->internals.handshake_header_buffer.header_size < SSL2_HEADERS)
{
ret =
_gnutls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE,
mhd_gtls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE,
type, dataptr, SSL2_HEADERS);
if (ret < 0)
@@ -1029,7 +1029,7 @@ _gnutls_recv_handshake_header (gnutls_session_t session,
|| type != GNUTLS_HANDSHAKE_CLIENT_HELLO)
{
ret =
_gnutls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE,
mhd_gtls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE,
type,
&dataptr[session->
internals.
@@ -1055,7 +1055,7 @@ _gnutls_recv_handshake_header (gnutls_session_t session,
/* we do not use DECR_LEN because we know
* that the packet has enough data.
*/
length32 = _gnutls_read_uint24 (&dataptr[1]);
length32 = mhd_gtls_read_uint24 (&dataptr[1]);
handshake_header_size = HANDSHAKE_HEADER_SIZE;
_gnutls_handshake_log ("HSK[%x]: %s was received [%ld bytes]\n",
@@ -1105,7 +1105,7 @@ _gnutls_recv_handshake_header (gnutls_session_t session,
* handshake data.
*/
static int
_gnutls_handshake_hash_add_recvd (gnutls_session_t session,
_gnutls_handshake_hash_add_recvd (mhd_gtls_session_t session,
gnutls_handshake_description_t recv_type,
opaque * header, uint16_t header_size,
opaque * dataptr, uint32_t datalen)
@@ -1127,7 +1127,7 @@ _gnutls_handshake_hash_add_recvd (gnutls_session_t session,
{
if ((ret =
_gnutls_handshake_buffer_put (session, header, header_size)) < 0)
mhd_gtls_handshake_buffer_put (session, header, header_size)) < 0)
{
gnutls_assert ();
return ret;
@@ -1136,7 +1136,7 @@ _gnutls_handshake_hash_add_recvd (gnutls_session_t session,
if (datalen > 0)
{
if ((ret =
_gnutls_handshake_buffer_put (session, dataptr, datalen)) < 0)
mhd_gtls_handshake_buffer_put (session, dataptr, datalen)) < 0)
{
gnutls_assert ();
return ret;
@@ -1151,10 +1151,10 @@ _gnutls_handshake_hash_add_recvd (gnutls_session_t session,
/* This function will receive handshake messages of the given types,
* and will pass the message to the right place in order to be processed.
* E.g. for the SERVER_HELLO message (if it is expected), it will be
* passed to _gnutls_recv_hello().
* passed to mhd_gtls_recv_hello().
*/
int
_gnutls_recv_handshake (gnutls_session_t session, uint8_t ** data,
mhd_gtls_recv_handshake (mhd_gtls_session_t session, uint8_t ** data,
int *datalen, gnutls_handshake_description_t type,
Optional optional)
{
@@ -1204,7 +1204,7 @@ _gnutls_recv_handshake (gnutls_session_t session, uint8_t ** data,
if (length32 > 0)
{
ret =
_gnutls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE,
mhd_gtls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE,
type, dataptr, length32);
if (ret <= 0)
{
@@ -1241,7 +1241,7 @@ _gnutls_recv_handshake (gnutls_session_t session, uint8_t ** data,
{
case GNUTLS_HANDSHAKE_CLIENT_HELLO:
case GNUTLS_HANDSHAKE_SERVER_HELLO:
ret = _gnutls_recv_hello (session, dataptr, length32);
ret = mhd_gtls_recv_hello (session, dataptr, length32);
/* dataptr is freed because the caller does not
* need it */
gnutls_free (dataptr);
@@ -1278,7 +1278,7 @@ _gnutls_recv_handshake (gnutls_session_t session, uint8_t ** data,
* to the session;
*/
static int
_gnutls_client_set_ciphersuite (gnutls_session_t session, opaque suite[2])
_gnutls_client_set_ciphersuite (mhd_gtls_session_t session, opaque suite[2])
{
uint8_t z;
cipher_suite_st *cipher_suites;
@@ -1286,7 +1286,7 @@ _gnutls_client_set_ciphersuite (gnutls_session_t session, opaque suite[2])
int i, err;
z = 1;
cipher_suite_num = _gnutls_supported_ciphersuites (session, &cipher_suites);
cipher_suite_num = mhd_gtls_supported_ciphersuites (session, &cipher_suites);
if (cipher_suite_num < 0)
{
gnutls_assert ();
@@ -1313,7 +1313,7 @@ _gnutls_client_set_ciphersuite (gnutls_session_t session, opaque suite[2])
memcpy (session->security_parameters.current_cipher_suite.suite, suite, 2);
_gnutls_handshake_log ("HSK[%x]: Selected cipher suite: %s\n", session,
_gnutls_cipher_suite_get_name (&session->
mhd_gtls_cipher_suite_get_name (&session->
security_parameters.
current_cipher_suite));
@@ -1321,8 +1321,8 @@ _gnutls_client_set_ciphersuite (gnutls_session_t session, opaque suite[2])
/* check if the credentials (username, public key etc.) are ok.
* Actually checks if they exist.
*/
if (_gnutls_get_kx_cred
(session, _gnutls_cipher_suite_get_kx_algo (&session->
if (mhd_gtls_get_kx_cred
(session, mhd_gtls_cipher_suite_get_kx_algo (&session->
security_parameters.
current_cipher_suite),
&err) == NULL && err != 0)
@@ -1332,12 +1332,12 @@ _gnutls_client_set_ciphersuite (gnutls_session_t session, opaque suite[2])
}
/* set the mod_auth_st to the appropriate struct
/* set the mhd_gtls_mod_auth_st to the appropriate struct
* according to the KX algorithm. This is needed since all the
* handshake functions are read from there;
*/
session->internals.auth_struct =
_gnutls_kx_auth_struct (_gnutls_cipher_suite_get_kx_algo
mhd_gtls_kx_auth_struct (mhd_gtls_cipher_suite_get_kx_algo
(&session->security_parameters.
current_cipher_suite));
@@ -1358,13 +1358,13 @@ _gnutls_client_set_ciphersuite (gnutls_session_t session, opaque suite[2])
/* This function sets the given comp method to the session.
*/
static int
_gnutls_client_set_comp_method (gnutls_session_t session, opaque comp_method)
_gnutls_client_set_comp_method (mhd_gtls_session_t session, opaque comp_method)
{
int comp_methods_num;
uint8_t *compression_methods;
int i;
comp_methods_num = _gnutls_supported_compression_methods (session,
comp_methods_num = mhd_gtls_supported_compression_methods (session,
&compression_methods);
if (comp_methods_num < 0)
{
@@ -1390,7 +1390,7 @@ _gnutls_client_set_comp_method (gnutls_session_t session, opaque comp_method)
}
session->internals.compression_method =
_gnutls_compression_get_id (comp_method);
mhd_gtls_compression_get_id (comp_method);
return 0;
@@ -1401,7 +1401,7 @@ _gnutls_client_set_comp_method (gnutls_session_t session, opaque comp_method)
* hello.
*/
static int
_gnutls_client_check_if_resuming (gnutls_session_t session,
_gnutls_client_check_if_resuming (mhd_gtls_session_t session,
opaque * session_id, int session_id_len)
{
opaque buf[2 * TLS_MAX_SESSION_ID_SIZE + 1];
@@ -1409,7 +1409,7 @@ _gnutls_client_check_if_resuming (gnutls_session_t session,
_gnutls_handshake_log ("HSK[%x]: SessionID length: %d\n", session,
session_id_len);
_gnutls_handshake_log ("HSK[%x]: SessionID: %s\n", session,
_gnutls_bin2hex (session_id, session_id_len, buf,
mhd_gtls_bin2hex (session_id, session_id_len, buf,
sizeof (buf)));
if (session_id_len > 0 &&
@@ -1448,7 +1448,7 @@ _gnutls_client_check_if_resuming (gnutls_session_t session,
* session.
*/
static int
_gnutls_read_server_hello (gnutls_session_t session,
_gnutls_read_server_hello (mhd_gtls_session_t session,
opaque * data, int datalen)
{
uint8_t session_id_len = 0;
@@ -1467,21 +1467,21 @@ _gnutls_read_server_hello (gnutls_session_t session,
session, data[pos], data[pos + 1]);
DECR_LEN (len, 2);
version = _gnutls_version_get (data[pos], data[pos + 1]);
if (_gnutls_version_is_supported (session, version) == 0)
version = mhd_gtls_version_get (data[pos], data[pos + 1]);
if (mhd_gtls_version_is_supported (session, version) == 0)
{
gnutls_assert ();
return GNUTLS_E_UNSUPPORTED_VERSION_PACKET;
}
else
{
_gnutls_set_current_version (session, version);
mhd_gtls_set_current_version (session, version);
}
pos += 2;
DECR_LEN (len, TLS_RANDOM_SIZE);
_gnutls_set_server_random (session, &data[pos]);
mhd_gtls_set_server_random (session, &data[pos]);
pos += TLS_RANDOM_SIZE;
@@ -1536,7 +1536,7 @@ _gnutls_read_server_hello (gnutls_session_t session,
*/
if (version >= MHD_GNUTLS_TLS1_0)
{
ret = _gnutls_parse_extensions (session, EXTENSION_ANY, &data[pos], len); /* len is the rest of the parsed length */
ret = mhd_gtls_parse_extensions (session, EXTENSION_ANY, &data[pos], len); /* len is the rest of the parsed length */
if (ret < 0)
{
gnutls_assert ();
@@ -1551,7 +1551,7 @@ _gnutls_read_server_hello (gnutls_session_t session,
* Needed in client hello messages. Returns the new data length.
*/
static int
_gnutls_copy_ciphersuites (gnutls_session_t session,
_gnutls_copy_ciphersuites (mhd_gtls_session_t session,
opaque * ret_data, size_t ret_data_size)
{
int ret, i;
@@ -1559,7 +1559,7 @@ _gnutls_copy_ciphersuites (gnutls_session_t session,
uint16_t cipher_num;
int datalen, pos;
ret = _gnutls_supported_ciphersuites_sorted (session, &cipher_suites);
ret = mhd_gtls_supported_ciphersuites_sorted (session, &cipher_suites);
if (ret < 0)
{
gnutls_assert ();
@@ -1571,7 +1571,7 @@ _gnutls_copy_ciphersuites (gnutls_session_t session,
* authentication requested (eg SRP).
*/
ret =
_gnutls_remove_unwanted_ciphersuites (session, &cipher_suites, ret, -1);
mhd_gtls_remove_unwanted_ciphersuites (session, &cipher_suites, ret, -1);
if (ret < 0)
{
gnutls_assert ();
@@ -1602,7 +1602,7 @@ _gnutls_copy_ciphersuites (gnutls_session_t session,
return GNUTLS_E_INTERNAL_ERROR;
}
_gnutls_write_uint16 (cipher_num, ret_data);
mhd_gtls_write_uint16 (cipher_num, ret_data);
pos += 2;
for (i = 0; i < (cipher_num / 2); i++)
@@ -1620,14 +1620,14 @@ _gnutls_copy_ciphersuites (gnutls_session_t session,
* Needed in hello messages. Returns the new data length.
*/
static int
_gnutls_copy_comp_methods (gnutls_session_t session,
_gnutls_copy_comp_methods (mhd_gtls_session_t session,
opaque * ret_data, size_t ret_data_size)
{
int ret, i;
uint8_t *compression_methods, comp_num;
int datalen, pos;
ret = _gnutls_supported_compression_methods (session, &compression_methods);
ret = mhd_gtls_supported_compression_methods (session, &compression_methods);
if (ret < 0)
{
gnutls_assert ();
@@ -1665,7 +1665,7 @@ _gnutls_copy_comp_methods (gnutls_session_t session,
/* This function sends the client hello handshake message.
*/
static int
_gnutls_send_client_hello (gnutls_session_t session, int again)
_gnutls_send_client_hello (mhd_gtls_session_t session, int again)
{
opaque *data = NULL;
int extdatalen;
@@ -1703,7 +1703,7 @@ _gnutls_send_client_hello (gnutls_session_t session, int again)
* version number to the previously established.
*/
if (SessionID == NULL)
hver = _gnutls_version_max (session);
hver = mhd_gtls_version_max (session);
else
{ /* we are resuming a session */
hver = session->internals.resumed_security_parameters.version;
@@ -1716,13 +1716,13 @@ _gnutls_send_client_hello (gnutls_session_t session, int again)
return GNUTLS_E_INTERNAL_ERROR;
}
data[pos++] = _gnutls_version_get_major (hver);
data[pos++] = _gnutls_version_get_minor (hver);
data[pos++] = mhd_gtls_version_get_major (hver);
data[pos++] = mhd_gtls_version_get_minor (hver);
/* Set the version we advertized as maximum
* (RSA uses it).
*/
_gnutls_set_adv_version (session, hver);
mhd_gtls_set_adv_version (session, hver);
/* Some old implementations do not interoperate if we send a
* different version in the record layer.
@@ -1732,7 +1732,7 @@ _gnutls_send_client_hello (gnutls_session_t session, int again)
* handshake packet and ignore the one in the packet's record
* header.
*/
_gnutls_set_current_version (session, hver);
mhd_gtls_set_current_version (session, hver);
/* In order to know when this session was initiated.
*/
@@ -1740,8 +1740,8 @@ _gnutls_send_client_hello (gnutls_session_t session, int again)
/* Generate random data
*/
_gnutls_tls_create_random (rnd);
_gnutls_set_client_random (session, rnd);
mhd_gtls_tls_create_random (rnd);
mhd_gtls_set_client_random (session, rnd);
memcpy (&data[pos], rnd, TLS_RANDOM_SIZE);
pos += TLS_RANDOM_SIZE;
@@ -1763,7 +1763,7 @@ _gnutls_send_client_hello (gnutls_session_t session, int again)
if (extdatalen > 0)
{
datalen += extdatalen;
data = gnutls_realloc_fast (data, datalen);
data = mhd_gtls_realloc_fast (data, datalen);
if (data == NULL)
{
gnutls_assert ();
@@ -1791,7 +1791,7 @@ _gnutls_send_client_hello (gnutls_session_t session, int again)
if (extdatalen > 0)
{
datalen += extdatalen;
data = gnutls_realloc_fast (data, datalen);
data = mhd_gtls_realloc_fast (data, datalen);
if (data == NULL)
{
gnutls_assert ();
@@ -1816,12 +1816,12 @@ _gnutls_send_client_hello (gnutls_session_t session, int again)
if (hver >= MHD_GNUTLS_TLS1_0)
{
extdatalen =
_gnutls_gen_extensions (session, extdata, sizeof (extdata));
mhd_gtls_gen_extensions (session, extdata, sizeof (extdata));
if (extdatalen > 0)
{
datalen += extdatalen;
data = gnutls_realloc_fast (data, datalen);
data = mhd_gtls_realloc_fast (data, datalen);
if (data == NULL)
{
gnutls_assert ();
@@ -1840,7 +1840,7 @@ _gnutls_send_client_hello (gnutls_session_t session, int again)
}
ret =
_gnutls_send_handshake (session, data, datalen,
mhd_gtls_send_handshake (session, data, datalen,
GNUTLS_HANDSHAKE_CLIENT_HELLO);
gnutls_free (data);
@@ -1848,7 +1848,7 @@ _gnutls_send_client_hello (gnutls_session_t session, int again)
}
static int
_gnutls_send_server_hello (gnutls_session_t session, int again)
_gnutls_send_server_hello (mhd_gtls_session_t session, int again)
{
opaque *data = NULL;
opaque extdata[MAX_EXT_DATA_LENGTH];
@@ -1867,7 +1867,7 @@ _gnutls_send_server_hello (gnutls_session_t session, int again)
#ifdef ENABLE_SRP
if (IS_SRP_KX
(_gnutls_cipher_suite_get_kx_algo
(mhd_gtls_cipher_suite_get_kx_algo
(&session->security_parameters.current_cipher_suite)))
{
/* While resuming we cannot check the username extension since it is
@@ -1882,7 +1882,7 @@ _gnutls_send_server_hello (gnutls_session_t session, int again)
* alert and abort.
*/
gnutls_assert ();
ret = gnutls_alert_send (session, GNUTLS_AL_FATAL,
ret = MHD_gnutls_alert_send (session, GNUTLS_AL_FATAL,
GNUTLS_A_UNKNOWN_PSK_IDENTITY);
if (ret < 0)
{
@@ -1899,7 +1899,7 @@ _gnutls_send_server_hello (gnutls_session_t session, int again)
{
datalen = 2 + session_id_len + 1 + TLS_RANDOM_SIZE + 3;
extdatalen =
_gnutls_gen_extensions (session, extdata, sizeof (extdata));
mhd_gtls_gen_extensions (session, extdata, sizeof (extdata));
if (extdatalen < 0)
{
@@ -1915,9 +1915,9 @@ _gnutls_send_server_hello (gnutls_session_t session, int again)
}
data[pos++] =
_gnutls_version_get_major (session->security_parameters.version);
mhd_gtls_version_get_major (session->security_parameters.version);
data[pos++] =
_gnutls_version_get_minor (session->security_parameters.version);
mhd_gtls_version_get_minor (session->security_parameters.version);
memcpy (&data[pos],
session->security_parameters.server_random, TLS_RANDOM_SIZE);
@@ -1931,7 +1931,7 @@ _gnutls_send_server_hello (gnutls_session_t session, int again)
pos += session_id_len;
_gnutls_handshake_log ("HSK[%x]: SessionID: %s\n", session,
_gnutls_bin2hex (SessionID, session_id_len,
mhd_gtls_bin2hex (SessionID, session_id_len,
buf, sizeof (buf)));
memcpy (&data[pos],
@@ -1939,7 +1939,7 @@ _gnutls_send_server_hello (gnutls_session_t session, int again)
pos += 2;
comp =
(uint8_t) _gnutls_compression_get_num (session->
(uint8_t) mhd_gtls_compression_get_num (session->
internals.compression_method);
data[pos++] = comp;
@@ -1953,7 +1953,7 @@ _gnutls_send_server_hello (gnutls_session_t session, int again)
}
ret =
_gnutls_send_handshake (session, data, datalen,
mhd_gtls_send_handshake (session, data, datalen,
GNUTLS_HANDSHAKE_SERVER_HELLO);
gnutls_afree (data);
@@ -1961,7 +1961,7 @@ _gnutls_send_server_hello (gnutls_session_t session, int again)
}
int
_gnutls_send_hello (gnutls_session_t session, int again)
mhd_gtls_send_hello (mhd_gtls_session_t session, int again)
{
int ret;
@@ -1983,7 +1983,7 @@ _gnutls_send_hello (gnutls_session_t session, int again)
* and internals.compression_method.
*/
int
_gnutls_recv_hello (gnutls_session_t session, opaque * data, int datalen)
mhd_gtls_recv_hello (mhd_gtls_session_t session, opaque * data, int datalen)
{
int ret;
@@ -2010,7 +2010,7 @@ _gnutls_recv_hello (gnutls_session_t session, opaque * data, int datalen)
return ret;
}
/* The packets in gnutls_handshake (it's more broad than original TLS handshake)
/* The packets in MHD_gnutls_handshake (it's more broad than original TLS handshake)
*
* Client Server
*
@@ -2034,8 +2034,8 @@ _gnutls_recv_hello (gnutls_session_t session, opaque * data, int datalen)
*/
/**
* gnutls_rehandshake - This function will renegotiate security parameters
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_rehandshake - This function will renegotiate security parameters
* @session: is a #mhd_gtls_session_t structure.
*
* This function will renegotiate security parameters with the
* client. This should only be called in case of a server.
@@ -2044,7 +2044,7 @@ _gnutls_recv_hello (gnutls_session_t session, opaque * data, int datalen)
* parameters (perform a handshake).
*
* If this function succeeds (returns 0), you must call the
* gnutls_handshake() function in order to negotiate the new
* MHD_gnutls_handshake() function in order to negotiate the new
* parameters.
*
* If the client does not wish to renegotiate parameters he will
@@ -2057,7 +2057,7 @@ _gnutls_recv_hello (gnutls_session_t session, opaque * data, int datalen)
*
**/
int
gnutls_rehandshake (gnutls_session_t session)
MHD_gnutls_rehandshake (mhd_gtls_session_t session)
{
int ret;
@@ -2081,7 +2081,7 @@ gnutls_rehandshake (gnutls_session_t session)
}
inline static int
_gnutls_abort_handshake (gnutls_session_t session, int ret)
_gnutls_abort_handshake (mhd_gtls_session_t session, int ret)
{
if (((ret == GNUTLS_E_WARNING_ALERT_RECEIVED) &&
(gnutls_alert_get (session) == GNUTLS_A_NO_RENEGOTIATION))
@@ -2097,13 +2097,13 @@ _gnutls_abort_handshake (gnutls_session_t session, int ret)
* required for finished messages.
*/
inline static int
_gnutls_handshake_hash_init (gnutls_session_t session)
_gnutls_handshake_hash_init (mhd_gtls_session_t session)
{
if (session->internals.handshake_mac_handle_md5 == NULL)
{
session->internals.handshake_mac_handle_md5 =
_gnutls_hash_init (MHD_GNUTLS_MAC_MD5);
mhd_gtls_hash_init (MHD_GNUTLS_MAC_MD5);
if (session->internals.handshake_mac_handle_md5 == GNUTLS_HASH_FAILED)
{
@@ -2115,7 +2115,7 @@ _gnutls_handshake_hash_init (gnutls_session_t session)
if (session->internals.handshake_mac_handle_sha == NULL)
{
session->internals.handshake_mac_handle_sha =
_gnutls_hash_init (MHD_GNUTLS_MAC_SHA1);
mhd_gtls_hash_init (MHD_GNUTLS_MAC_SHA1);
if (session->internals.handshake_mac_handle_sha == GNUTLS_HASH_FAILED)
{
gnutls_assert ();
@@ -2127,19 +2127,19 @@ _gnutls_handshake_hash_init (gnutls_session_t session)
}
int
_gnutls_send_supplemental (gnutls_session_t session, int again)
_gnutls_send_supplemental (mhd_gtls_session_t session, int again)
{
int ret = 0;
_gnutls_debug_log ("EXT[%x]: Sending supplemental data\n", session);
if (again)
ret = _gnutls_send_handshake (session, NULL, 0,
ret = mhd_gtls_send_handshake (session, NULL, 0,
GNUTLS_HANDSHAKE_SUPPLEMENTAL);
else
{
gnutls_buffer buf;
_gnutls_buffer_init (&buf);
mhd_gtls_buffer buf;
mhd_gtls_buffer_init (&buf);
ret = _gnutls_gen_supplemental (session, &buf);
if (ret < 0)
@@ -2148,16 +2148,16 @@ _gnutls_send_supplemental (gnutls_session_t session, int again)
return ret;
}
ret = _gnutls_send_handshake (session, buf.data, buf.length,
ret = mhd_gtls_send_handshake (session, buf.data, buf.length,
GNUTLS_HANDSHAKE_SUPPLEMENTAL);
_gnutls_buffer_clear (&buf);
mhd_gtls_buffer_clear (&buf);
}
return ret;
}
int
_gnutls_recv_supplemental (gnutls_session_t session)
_gnutls_recv_supplemental (mhd_gtls_session_t session)
{
uint8_t *data = NULL;
int datalen = 0;
@@ -2165,7 +2165,7 @@ _gnutls_recv_supplemental (gnutls_session_t session)
_gnutls_debug_log ("EXT[%x]: Expecting supplemental data\n", session);
ret = _gnutls_recv_handshake (session, &data, &datalen,
ret = mhd_gtls_recv_handshake (session, &data, &datalen,
GNUTLS_HANDSHAKE_SUPPLEMENTAL,
OPTIONAL_PACKET);
if (ret < 0)
@@ -2187,8 +2187,8 @@ _gnutls_recv_supplemental (gnutls_session_t session)
}
/**
* gnutls_handshake - This is the main function in the handshake protocol.
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_handshake - This is the main function in the handshake protocol.
* @session: is a #mhd_gtls_session_t structure.
*
* This function does the handshake of the TLS/SSL protocol, and
* initializes the TLS connection.
@@ -2201,8 +2201,8 @@ _gnutls_recv_supplemental (gnutls_session_t session)
* The non-fatal errors such as %GNUTLS_E_AGAIN and
* %GNUTLS_E_INTERRUPTED interrupt the handshake procedure, which
* should be later be resumed. Call this function again, until it
* returns 0; cf. gnutls_record_get_direction() and
* gnutls_error_is_fatal().
* returns 0; cf. MHD_gnutls_record_get_direction() and
* MHD_gtls_error_is_fatal().
*
* If this function is called by a server after a rehandshake request
* then %GNUTLS_E_GOT_APPLICATION_DATA or
@@ -2214,7 +2214,7 @@ _gnutls_recv_supplemental (gnutls_session_t session)
*
**/
int
gnutls_handshake (gnutls_session_t session)
MHD_gnutls_handshake (mhd_gtls_session_t session)
{
int ret;
@@ -2226,11 +2226,11 @@ gnutls_handshake (gnutls_session_t session)
if (session->security_parameters.entity == GNUTLS_CLIENT)
{
ret = _gnutls_handshake_client (session);
ret = mhd_gtls_handshake_client (session);
}
else
{
ret = _gnutls_handshake_server (session);
ret = mhd_gtls_handshake_server (session);
}
if (ret < 0)
{
@@ -2243,7 +2243,7 @@ gnutls_handshake (gnutls_session_t session)
return ret;
}
ret = _gnutls_handshake_common (session);
ret = mhd_gtls_handshake_common (session);
if (ret < 0)
{
@@ -2256,14 +2256,14 @@ gnutls_handshake (gnutls_session_t session)
STATE = STATE0;
_gnutls_handshake_io_buffer_clear (session);
_gnutls_handshake_internal_state_clear (session);
mhd_gtls_handshake_internal_state_clear (session);
return 0;
}
#define IMED_RET( str, ret) do { \
if (ret < 0) { \
if (gnutls_error_is_fatal(ret)==0) return ret; \
if (MHD_gtls_error_is_fatal(ret)==0) return ret; \
gnutls_assert(); \
ERR( str, ret); \
_gnutls_handshake_hash_buffers_clear(session); \
@@ -2273,11 +2273,11 @@ gnutls_handshake (gnutls_session_t session)
/*
* _gnutls_handshake_client
* mhd_gtls_handshake_client
* This function performs the client side of the handshake of the TLS/SSL protocol.
*/
int
_gnutls_handshake_client (gnutls_session_t session)
mhd_gtls_handshake_client (mhd_gtls_session_t session)
{
int ret = 0;
@@ -2286,7 +2286,7 @@ _gnutls_handshake_client (gnutls_session_t session)
if (session->internals.resumed_security_parameters.session_id_size > 0)
_gnutls_handshake_log ("HSK[%x]: Ask to resume: %s\n", session,
_gnutls_bin2hex (session->internals.
mhd_gtls_bin2hex (session->internals.
resumed_security_parameters.
session_id,
session->internals.
@@ -2299,14 +2299,14 @@ _gnutls_handshake_client (gnutls_session_t session)
{
case STATE0:
case STATE1:
ret = _gnutls_send_hello (session, AGAIN (STATE1));
ret = mhd_gtls_send_hello (session, AGAIN (STATE1));
STATE = STATE1;
IMED_RET ("send hello", ret);
case STATE2:
/* receive the server hello */
ret =
_gnutls_recv_handshake (session, NULL, NULL,
mhd_gtls_recv_handshake (session, NULL, NULL,
GNUTLS_HANDSHAKE_SERVER_HELLO,
MANDATORY_PACKET);
STATE = STATE2;
@@ -2323,14 +2323,14 @@ _gnutls_handshake_client (gnutls_session_t session)
case STATE3:
/* RECV CERTIFICATE */
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret = _gnutls_recv_server_certificate (session);
ret = mhd_gtls_recv_server_certificate (session);
STATE = STATE3;
IMED_RET ("recv server certificate", ret);
case STATE4:
/* receive the server key exchange */
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret = _gnutls_recv_server_kx_message (session);
ret = mhd_gtls_recv_server_kx_message (session);
STATE = STATE4;
IMED_RET ("recv server kx message", ret);
@@ -2339,7 +2339,7 @@ _gnutls_handshake_client (gnutls_session_t session)
*/
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret = _gnutls_recv_server_certificate_request (session);
ret = mhd_gtls_recv_server_certificate_request (session);
STATE = STATE5;
IMED_RET ("recv server certificate request message", ret);
@@ -2347,7 +2347,7 @@ _gnutls_handshake_client (gnutls_session_t session)
/* receive the server hello done */
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret =
_gnutls_recv_handshake (session, NULL, NULL,
mhd_gtls_recv_handshake (session, NULL, NULL,
GNUTLS_HANDSHAKE_SERVER_HELLO_DONE,
MANDATORY_PACKET);
STATE = STATE6;
@@ -2365,13 +2365,13 @@ _gnutls_handshake_client (gnutls_session_t session)
/* send our certificate - if any and if requested
*/
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret = _gnutls_send_client_certificate (session, AGAIN (STATE7));
ret = mhd_gtls_send_client_certificate (session, AGAIN (STATE7));
STATE = STATE7;
IMED_RET ("send client certificate", ret);
case STATE8:
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret = _gnutls_send_client_kx_message (session, AGAIN (STATE8));
ret = mhd_gtls_send_client_kx_message (session, AGAIN (STATE8));
STATE = STATE8;
IMED_RET ("send client kx", ret);
@@ -2379,7 +2379,7 @@ _gnutls_handshake_client (gnutls_session_t session)
/* send client certificate verify */
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret =
_gnutls_send_client_certificate_verify (session, AGAIN (STATE9));
mhd_gtls_send_client_certificate_verify (session, AGAIN (STATE9));
STATE = STATE9;
IMED_RET ("send client certificate verify", ret);
@@ -2395,7 +2395,7 @@ _gnutls_handshake_client (gnutls_session_t session)
/* This function sends the final handshake packets and initializes connection
*/
static int
_gnutls_send_handshake_final (gnutls_session_t session, int init)
_gnutls_send_handshake_final (mhd_gtls_session_t session, int init)
{
int ret = 0;
@@ -2405,7 +2405,7 @@ _gnutls_send_handshake_final (gnutls_session_t session, int init)
{
case STATE0:
case STATE20:
ret = _gnutls_send_change_cipher_spec (session, AGAIN (STATE20));
ret = mhd_gtls_send_change_cipher_spec (session, AGAIN (STATE20));
STATE = STATE20;
if (ret < 0)
{
@@ -2418,7 +2418,7 @@ _gnutls_send_handshake_final (gnutls_session_t session, int init)
*/
if (init == TRUE)
{
ret = _gnutls_connection_state_init (session);
ret = mhd_gtls_connection_state_init (session);
if (ret < 0)
{
gnutls_assert ();
@@ -2426,7 +2426,7 @@ _gnutls_send_handshake_final (gnutls_session_t session, int init)
}
}
ret = _gnutls_write_connection_state_init (session);
ret = mhd_gtls_write_connection_state_init (session);
if (ret < 0)
{
gnutls_assert ();
@@ -2457,7 +2457,7 @@ _gnutls_send_handshake_final (gnutls_session_t session, int init)
* read session.
*/
static int
_gnutls_recv_handshake_final (gnutls_session_t session, int init)
_gnutls_recv_handshake_final (mhd_gtls_session_t session, int init)
{
int ret = 0;
uint8_t ch;
@@ -2466,7 +2466,7 @@ _gnutls_recv_handshake_final (gnutls_session_t session, int init)
{
case STATE0:
case STATE30:
ret = _gnutls_recv_int (session, GNUTLS_CHANGE_CIPHER_SPEC, -1, &ch, 1);
ret = mhd_gtls_recv_int (session, GNUTLS_CHANGE_CIPHER_SPEC, -1, &ch, 1);
STATE = STATE30;
if (ret <= 0)
{
@@ -2478,7 +2478,7 @@ _gnutls_recv_handshake_final (gnutls_session_t session, int init)
/* Initialize the connection session (start encryption) - in case of server */
if (init == TRUE)
{
ret = _gnutls_connection_state_init (session);
ret = mhd_gtls_connection_state_init (session);
if (ret < 0)
{
gnutls_assert ();
@@ -2486,7 +2486,7 @@ _gnutls_recv_handshake_final (gnutls_session_t session, int init)
}
}
ret = _gnutls_read_connection_state_init (session);
ret = mhd_gtls_read_connection_state_init (session);
if (ret < 0)
{
gnutls_assert ();
@@ -2512,12 +2512,12 @@ _gnutls_recv_handshake_final (gnutls_session_t session, int init)
}
/*
* _gnutls_handshake_server
* mhd_gtls_handshake_server
* This function does the server stuff of the handshake protocol.
*/
int
_gnutls_handshake_server (gnutls_session_t session)
mhd_gtls_handshake_server (mhd_gtls_session_t session)
{
int ret = 0;
@@ -2526,14 +2526,14 @@ _gnutls_handshake_server (gnutls_session_t session)
case STATE0:
case STATE1:
ret =
_gnutls_recv_handshake (session, NULL, NULL,
mhd_gtls_recv_handshake (session, NULL, NULL,
GNUTLS_HANDSHAKE_CLIENT_HELLO,
MANDATORY_PACKET);
STATE = STATE1;
IMED_RET ("recv hello", ret);
case STATE2:
ret = _gnutls_send_hello (session, AGAIN (STATE2));
ret = mhd_gtls_send_hello (session, AGAIN (STATE2));
STATE = STATE2;
IMED_RET ("send hello", ret);
@@ -2550,14 +2550,14 @@ _gnutls_handshake_server (gnutls_session_t session)
/* NOTE: these should not be send if we are resuming */
if (session->internals.resumed == RESUME_FALSE)
ret = _gnutls_send_server_certificate (session, AGAIN (STATE3));
ret = mhd_gtls_send_server_certificate (session, AGAIN (STATE3));
STATE = STATE3;
IMED_RET ("send server certificate", ret);
case STATE4:
/* send server key exchange (A) */
if (session->internals.resumed == RESUME_FALSE)
ret = _gnutls_send_server_kx_message (session, AGAIN (STATE4));
ret = mhd_gtls_send_server_kx_message (session, AGAIN (STATE4));
STATE = STATE4;
IMED_RET ("send server kx", ret);
@@ -2565,7 +2565,7 @@ _gnutls_handshake_server (gnutls_session_t session)
/* Send certificate request - if requested to */
if (session->internals.resumed == RESUME_FALSE)
ret =
_gnutls_send_server_certificate_request (session, AGAIN (STATE5));
mhd_gtls_send_server_certificate_request (session, AGAIN (STATE5));
STATE = STATE5;
IMED_RET ("send server cert request", ret);
@@ -2591,21 +2591,21 @@ _gnutls_handshake_server (gnutls_session_t session)
case STATE7:
/* receive the client certificate message */
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret = _gnutls_recv_client_certificate (session);
ret = mhd_gtls_recv_client_certificate (session);
STATE = STATE7;
IMED_RET ("recv client certificate", ret);
case STATE8:
/* receive the client key exchange message */
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret = _gnutls_recv_client_kx_message (session);
ret = mhd_gtls_recv_client_kx_message (session);
STATE = STATE8;
IMED_RET ("recv client kx", ret);
case STATE9:
/* receive the client certificate verify message */
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret = _gnutls_recv_client_certificate_verify_message (session);
ret = mhd_gtls_recv_client_certificate_verify_message (session);
STATE = STATE9;
IMED_RET ("recv client certificate verify", ret);
@@ -2618,7 +2618,7 @@ _gnutls_handshake_server (gnutls_session_t session)
}
int
_gnutls_handshake_common (gnutls_session_t session)
mhd_gtls_handshake_common (mhd_gtls_session_t session)
{
int ret = 0;
@@ -2653,7 +2653,7 @@ _gnutls_handshake_common (gnutls_session_t session)
}
int
_gnutls_generate_session_id (opaque * session_id, uint8_t * len)
mhd_gtls_generate_session_id (opaque * session_id, uint8_t * len)
{
*len = TLS_MAX_SESSION_ID_SIZE;
@@ -2667,7 +2667,7 @@ _gnutls_generate_session_id (opaque * session_id, uint8_t * len)
}
int
_gnutls_recv_hello_request (gnutls_session_t session, void *data,
mhd_gtls_recv_hello_request (mhd_gtls_session_t session, void *data,
uint32_t data_size)
{
uint8_t type;
@@ -2696,33 +2696,33 @@ _gnutls_recv_hello_request (gnutls_session_t session, void *data,
* (DH or RSA) set up. Otherwise returns 0.
*/
inline static int
check_server_params (gnutls_session_t session,
check_server_params (mhd_gtls_session_t session,
gnutls_kx_algorithm_t kx,
gnutls_kx_algorithm_t * alg, int alg_size)
{
int cred_type;
gnutls_dh_params_t dh_params = NULL;
gnutls_rsa_params_t rsa_params = NULL;
mhd_gtls_dh_params_t dh_params = NULL;
mhd_gtls_rsa_params_t rsa_params = NULL;
int j;
cred_type = _gnutls_map_kx_get_cred (kx, 1);
cred_type = mhd_gtls_map_kx_get_cred (kx, 1);
/* Read the Diffie Hellman parameters, if any.
*/
if (cred_type == MHD_GNUTLS_CRD_CERTIFICATE)
{
int delete;
gnutls_certificate_credentials_t x509_cred =
(gnutls_certificate_credentials_t) _gnutls_get_cred (session->key,
mhd_gtls_cert_credentials_t x509_cred =
(mhd_gtls_cert_credentials_t) mhd_gtls_get_cred (session->key,
cred_type, NULL);
if (x509_cred != NULL)
{
dh_params =
_gnutls_get_dh_params (x509_cred->dh_params,
mhd_gtls_get_dh_params (x509_cred->dh_params,
x509_cred->params_func, session);
rsa_params =
_gnutls_certificate_get_rsa_params (x509_cred->rsa_params,
mhd_gtls_certificate_get_rsa_params (x509_cred->rsa_params,
x509_cred->params_func,
session);
}
@@ -2747,14 +2747,14 @@ check_server_params (gnutls_session_t session,
}
else if (cred_type == MHD_GNUTLS_CRD_ANON)
{
gnutls_anon_server_credentials_t anon_cred =
(gnutls_anon_server_credentials_t) _gnutls_get_cred (session->key,
mhd_gtls_anon_server_credentials_t anon_cred =
(mhd_gtls_anon_server_credentials_t) mhd_gtls_get_cred (session->key,
cred_type, NULL);
if (anon_cred != NULL)
{
dh_params =
_gnutls_get_dh_params (anon_cred->dh_params,
mhd_gtls_get_dh_params (anon_cred->dh_params,
anon_cred->params_func, session);
}
#endif
@@ -2763,13 +2763,13 @@ check_server_params (gnutls_session_t session,
else if (cred_type == MHD_GNUTLS_CRD_PSK)
{
gnutls_psk_server_credentials_t psk_cred =
(gnutls_psk_server_credentials_t) _gnutls_get_cred (session->key,
(gnutls_psk_server_credentials_t) mhd_gtls_get_cred (session->key,
cred_type, NULL);
if (psk_cred != NULL)
{
dh_params =
_gnutls_get_dh_params (psk_cred->dh_params, psk_cred->params_func,
mhd_gtls_get_dh_params (psk_cred->dh_params, psk_cred->params_func,
session);
}
#endif
@@ -2781,7 +2781,7 @@ check_server_params (gnutls_session_t session,
/* If the key exchange method needs RSA or DH params,
* but they are not set then remove it.
*/
if (_gnutls_kx_needs_rsa_params (kx) != 0)
if (mhd_gtls_kx_needs_rsa_params (kx) != 0)
{
/* needs rsa params. */
if (_gnutls_rsa_params_to_mpi (rsa_params) == NULL)
@@ -2791,10 +2791,10 @@ check_server_params (gnutls_session_t session,
}
}
if (_gnutls_kx_needs_dh_params (kx) != 0)
if (mhd_gtls_kx_needs_dh_params (kx) != 0)
{
/* needs DH params. */
if (_gnutls_dh_params_to_mpi (dh_params) == NULL)
if (mhd_gtls_dh_params_to_mpi (dh_params) == NULL)
{
gnutls_assert ();
return 1;
@@ -2812,7 +2812,7 @@ check_server_params (gnutls_session_t session,
* by checking certificates etc.
*/
int
_gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
mhd_gtls_remove_unwanted_ciphersuites (mhd_gtls_session_t session,
cipher_suite_st ** cipherSuites,
int numCipherSuites,
gnutls_pk_algorithm_t requested_pk_algo)
@@ -2821,7 +2821,7 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
int ret = 0;
cipher_suite_st *newSuite, cs;
int newSuiteSize = 0, i;
gnutls_certificate_credentials_t cert_cred;
mhd_gtls_cert_credentials_t cert_cred;
gnutls_kx_algorithm_t kx;
int server = session->security_parameters.entity == GNUTLS_SERVER ? 1 : 0;
gnutls_kx_algorithm_t *alg = NULL;
@@ -2834,7 +2834,7 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
*/
cert_cred =
(gnutls_certificate_credentials_t) _gnutls_get_cred (session->key,
(mhd_gtls_cert_credentials_t) mhd_gtls_get_cred (session->key,
MHD_GNUTLS_CRD_CERTIFICATE,
NULL);
@@ -2844,12 +2844,12 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
if (session->security_parameters.entity == GNUTLS_SERVER
&& cert_cred != NULL)
{
ret = _gnutls_server_select_cert (session, requested_pk_algo);
ret = mhd_gtls_server_select_cert (session, requested_pk_algo);
if (ret < 0)
{
gnutls_assert ();
_gnutls_x509_log ("Could not find an appropriate certificate: %s\n",
gnutls_strerror (ret));
MHD_gtls_strerror (ret));
cert_cred = NULL;
}
}
@@ -2858,7 +2858,7 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
* supported by the X509 certificate parameters.
*/
if ((ret =
_gnutls_selected_cert_supported_kx (session, &alg, &alg_size)) < 0)
mhd_gtls_selected_cert_supported_kx (session, &alg, &alg_size)) < 0)
{
gnutls_assert ();
return ret;
@@ -2881,11 +2881,11 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
/* finds the key exchange algorithm in
* the ciphersuite
*/
kx = _gnutls_cipher_suite_get_kx_algo (&(*cipherSuites)[i]);
kx = mhd_gtls_cipher_suite_get_kx_algo (&(*cipherSuites)[i]);
/* if it is defined but had no credentials
*/
if (_gnutls_get_kx_cred (session, kx, NULL) == NULL)
if (mhd_gtls_get_kx_cred (session, kx, NULL) == NULL)
{
delete = 1;
}
@@ -2903,7 +2903,7 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
SRP credential too. */
if (kx == MHD_GNUTLS_KX_SRP_RSA || kx == MHD_GNUTLS_KX_SRP_DSS)
{
if (!_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_SRP, NULL))
if (!mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_SRP, NULL))
delete = 1;
}
@@ -2914,7 +2914,7 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
_gnutls_handshake_log ("HSK[%x]: Keeping ciphersuite: %s\n",
session,
_gnutls_cipher_suite_get_name (&cs));
mhd_gtls_cipher_suite_get_name (&cs));
memcpy (newSuite[newSuiteSize].suite, (*cipherSuites)[i].suite, 2);
newSuiteSize++;
@@ -2923,7 +2923,7 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
{
_gnutls_handshake_log ("HSK[%x]: Removing ciphersuite: %s\n",
session,
_gnutls_cipher_suite_get_name (&cs));
mhd_gtls_cipher_suite_get_name (&cs));
}
}
@@ -2939,8 +2939,8 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
}
/**
* gnutls_handshake_set_max_packet_length - This function will set the maximum length of a handshake message
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_handshake_set_max_packet_length - This function will set the maximum length of a handshake message
* @session: is a #mhd_gtls_session_t structure.
* @max: is the maximum number.
*
* This function will set the maximum size of a handshake message.
@@ -2950,28 +2950,28 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
*
**/
void
gnutls_handshake_set_max_packet_length (gnutls_session_t session, size_t max)
MHD_gnutls_handshake_set_max_packet_length (mhd_gtls_session_t session, size_t max)
{
session->internals.max_handshake_data_buffer_size = max;
}
void
_gnutls_set_adv_version (gnutls_session_t session, gnutls_protocol_t ver)
mhd_gtls_set_adv_version (mhd_gtls_session_t session, gnutls_protocol_t ver)
{
set_adv_version (session, _gnutls_version_get_major (ver),
_gnutls_version_get_minor (ver));
set_adv_version (session, mhd_gtls_version_get_major (ver),
mhd_gtls_version_get_minor (ver));
}
gnutls_protocol_t
_gnutls_get_adv_version (gnutls_session_t session)
mhd_gtls_get_adv_version (mhd_gtls_session_t session)
{
return _gnutls_version_get (_gnutls_get_adv_version_major (session),
return mhd_gtls_version_get (_gnutls_get_adv_version_major (session),
_gnutls_get_adv_version_minor (session));
}
/**
* gnutls_handshake_get_last_in - Returns the last handshake message received.
* @session: is a #gnutls_session_t structure.
* MHD_gtls_handshake_get_last_in - Returns the last handshake message received.
* @session: is a #mhd_gtls_session_t structure.
*
* This function is only useful to check where the last performed
* handshake failed. If the previous handshake succeed or was not
@@ -2984,14 +2984,14 @@ _gnutls_get_adv_version (gnutls_session_t session)
* %gnutls_handshake_description_t.
**/
gnutls_handshake_description_t
gnutls_handshake_get_last_in (gnutls_session_t session)
MHD_gtls_handshake_get_last_in (mhd_gtls_session_t session)
{
return session->internals.last_handshake_in;
}
/**
* gnutls_handshake_get_last_out - Returns the last handshake message sent.
* @session: is a #gnutls_session_t structure.
* MHD_gtls_handshake_get_last_out - Returns the last handshake message sent.
* @session: is a #mhd_gtls_session_t structure.
*
* This function is only useful to check where the last performed
* handshake failed. If the previous handshake succeed or was not
@@ -3004,7 +3004,7 @@ gnutls_handshake_get_last_in (gnutls_session_t session)
* %gnutls_handshake_description_t.
**/
gnutls_handshake_description_t
gnutls_handshake_get_last_out (gnutls_session_t session)
MHD_gtls_handshake_get_last_out (mhd_gtls_session_t session)
{
return session->internals.last_handshake_out;
}
+17 -17
View File
@@ -25,33 +25,33 @@
typedef enum Optional
{ OPTIONAL_PACKET, MANDATORY_PACKET } Optional;
int _gnutls_send_handshake (gnutls_session_t session, void *i_data,
int mhd_gtls_send_handshake (mhd_gtls_session_t session, void *i_data,
uint32_t i_datasize,
gnutls_handshake_description_t type);
int _gnutls_recv_hello_request (gnutls_session_t session, void *data,
int mhd_gtls_recv_hello_request (mhd_gtls_session_t session, void *data,
uint32_t data_size);
int _gnutls_send_hello (gnutls_session_t session, int again);
int _gnutls_recv_hello (gnutls_session_t session, opaque * data, int datalen);
int _gnutls_recv_handshake (gnutls_session_t session, uint8_t **, int *,
int mhd_gtls_send_hello (mhd_gtls_session_t session, int again);
int mhd_gtls_recv_hello (mhd_gtls_session_t session, opaque * data, int datalen);
int mhd_gtls_recv_handshake (mhd_gtls_session_t session, uint8_t **, int *,
gnutls_handshake_description_t,
Optional optional);
int _gnutls_generate_session_id (opaque * session_id, uint8_t * len);
int _gnutls_handshake_common (gnutls_session_t session);
int _gnutls_handshake_client (gnutls_session_t session);
int _gnutls_handshake_server (gnutls_session_t session);
void _gnutls_set_server_random (gnutls_session_t session, uint8_t * rnd);
void _gnutls_set_client_random (gnutls_session_t session, uint8_t * rnd);
int _gnutls_tls_create_random (opaque * dst);
int _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
int mhd_gtls_generate_session_id (opaque * session_id, uint8_t * len);
int mhd_gtls_handshake_common (mhd_gtls_session_t session);
int mhd_gtls_handshake_client (mhd_gtls_session_t session);
int mhd_gtls_handshake_server (mhd_gtls_session_t session);
void mhd_gtls_set_server_random (mhd_gtls_session_t session, uint8_t * rnd);
void mhd_gtls_set_client_random (mhd_gtls_session_t session, uint8_t * rnd);
int mhd_gtls_tls_create_random (opaque * dst);
int mhd_gtls_remove_unwanted_ciphersuites (mhd_gtls_session_t session,
cipher_suite_st ** cipherSuites,
int numCipherSuites,
gnutls_pk_algorithm_t);
int _gnutls_find_pk_algos_in_ciphersuites (opaque * data, int datalen);
int _gnutls_server_select_suite (gnutls_session_t session, opaque * data,
int mhd_gtls_find_pk_algos_in_ciphersuites (opaque * data, int datalen);
int mhd_gtls_server_select_suite (mhd_gtls_session_t session, opaque * data,
int datalen);
int _gnutls_negotiate_version( gnutls_session_t session, gnutls_protocol_t adv_version);
int _gnutls_user_hello_func( gnutls_session, gnutls_protocol_t adv_version);
int mhd_gtls_negotiate_version( mhd_gtls_session_t session, gnutls_protocol_t adv_version);
int mhd_gtls_user_hello_func( gnutls_session, gnutls_protocol_t adv_version);
#define STATE session->internals.handshake_state
/* This returns true if we have got there
+49 -49
View File
@@ -55,7 +55,7 @@ _gnutls_mac2gc (gnutls_mac_algorithm_t mac)
}
GNUTLS_HASH_HANDLE
_gnutls_hash_init (gnutls_mac_algorithm_t algorithm)
mhd_gtls_hash_init (gnutls_mac_algorithm_t algorithm)
{
mac_hd_t ret;
int result;
@@ -81,7 +81,7 @@ _gnutls_hash_init (gnutls_mac_algorithm_t algorithm)
}
int
_gnutls_hash_get_algo_len (gnutls_mac_algorithm_t algorithm)
mhd_gnutls_hash_get_algo_len (gnutls_mac_algorithm_t algorithm)
{
int ret;
@@ -92,7 +92,7 @@ _gnutls_hash_get_algo_len (gnutls_mac_algorithm_t algorithm)
}
int
_gnutls_hash (GNUTLS_HASH_HANDLE handle, const void *text, size_t textlen)
mhd_gnutls_hash (GNUTLS_HASH_HANDLE handle, const void *text, size_t textlen)
{
if (textlen > 0)
gc_hash_write (handle->handle, textlen, text);
@@ -100,7 +100,7 @@ _gnutls_hash (GNUTLS_HASH_HANDLE handle, const void *text, size_t textlen)
}
GNUTLS_HASH_HANDLE
_gnutls_hash_copy (GNUTLS_HASH_HANDLE handle)
mhd_gnutls_hash_copy (GNUTLS_HASH_HANDLE handle)
{
GNUTLS_HASH_HANDLE ret;
int result;
@@ -126,12 +126,12 @@ _gnutls_hash_copy (GNUTLS_HASH_HANDLE handle)
}
void
_gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest)
mhd_gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest)
{
const opaque *mac;
int maclen;
maclen = _gnutls_hash_get_algo_len (handle->algorithm);
maclen = mhd_gnutls_hash_get_algo_len (handle->algorithm);
mac = gc_hash_read (handle->handle);
if (digest != NULL)
@@ -144,7 +144,7 @@ _gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest)
mac_hd_t
_gnutls_hmac_init (gnutls_mac_algorithm_t algorithm,
mhd_gtls_hmac_init (gnutls_mac_algorithm_t algorithm,
const void *key, int keylen)
{
mac_hd_t ret;
@@ -171,12 +171,12 @@ _gnutls_hmac_init (gnutls_mac_algorithm_t algorithm,
}
void
_gnutls_hmac_deinit (mac_hd_t handle, void *digest)
mhd_gnutls_hmac_deinit (mac_hd_t handle, void *digest)
{
const opaque *mac;
int maclen;
maclen = _gnutls_hash_get_algo_len (handle->algorithm);
maclen = mhd_gnutls_hash_get_algo_len (handle->algorithm);
mac = gc_hash_read (handle->handle);
@@ -203,7 +203,7 @@ get_padsize (gnutls_mac_algorithm_t algorithm)
}
mac_hd_t
_gnutls_mac_init_ssl3 (gnutls_mac_algorithm_t algorithm, void *key,
mhd_gnutls_mac_init_ssl3 (gnutls_mac_algorithm_t algorithm, void *key,
int keylen)
{
mac_hd_t ret;
@@ -219,22 +219,22 @@ _gnutls_mac_init_ssl3 (gnutls_mac_algorithm_t algorithm, void *key,
memset (ipad, 0x36, padsize);
ret = _gnutls_hash_init (algorithm);
ret = mhd_gtls_hash_init (algorithm);
if (ret != GNUTLS_HASH_FAILED)
{
ret->key = key;
ret->keysize = keylen;
if (keylen > 0)
_gnutls_hash (ret, key, keylen);
_gnutls_hash (ret, ipad, padsize);
mhd_gnutls_hash (ret, key, keylen);
mhd_gnutls_hash (ret, ipad, padsize);
}
return ret;
}
void
_gnutls_mac_deinit_ssl3 (mac_hd_t handle, void *digest)
mhd_gnutls_mac_deinit_ssl3 (mac_hd_t handle, void *digest)
{
opaque ret[MAX_HASH_SIZE];
mac_hd_t td;
@@ -251,23 +251,23 @@ _gnutls_mac_deinit_ssl3 (mac_hd_t handle, void *digest)
memset (opad, 0x5C, padsize);
td = _gnutls_hash_init (handle->algorithm);
td = mhd_gtls_hash_init (handle->algorithm);
if (td != GNUTLS_MAC_FAILED)
{
if (handle->keysize > 0)
_gnutls_hash (td, handle->key, handle->keysize);
mhd_gnutls_hash (td, handle->key, handle->keysize);
_gnutls_hash (td, opad, padsize);
block = _gnutls_hmac_get_algo_len (handle->algorithm);
_gnutls_hash_deinit (handle, ret); /* get the previous hash */
_gnutls_hash (td, ret, block);
mhd_gnutls_hash (td, opad, padsize);
block = mhd_gnutls_hash_get_algo_len (handle->algorithm);
mhd_gnutls_hash_deinit (handle, ret); /* get the previous hash */
mhd_gnutls_hash (td, ret, block);
_gnutls_hash_deinit (td, digest);
mhd_gnutls_hash_deinit (td, digest);
}
}
void
_gnutls_mac_deinit_ssl3_handshake (mac_hd_t handle,
mhd_gnutls_mac_deinit_ssl3_handshake (mac_hd_t handle,
void *digest, opaque * key,
uint32_t key_size)
{
@@ -288,23 +288,23 @@ _gnutls_mac_deinit_ssl3_handshake (mac_hd_t handle,
memset (opad, 0x5C, padsize);
memset (ipad, 0x36, padsize);
td = _gnutls_hash_init (handle->algorithm);
td = mhd_gtls_hash_init (handle->algorithm);
if (td != GNUTLS_HASH_FAILED)
{
if (key_size > 0)
_gnutls_hash (td, key, key_size);
mhd_gnutls_hash (td, key, key_size);
_gnutls_hash (td, opad, padsize);
block = _gnutls_hmac_get_algo_len (handle->algorithm);
mhd_gnutls_hash (td, opad, padsize);
block = mhd_gnutls_hash_get_algo_len (handle->algorithm);
if (key_size > 0)
_gnutls_hash (handle, key, key_size);
_gnutls_hash (handle, ipad, padsize);
_gnutls_hash_deinit (handle, ret); /* get the previous hash */
mhd_gnutls_hash (handle, key, key_size);
mhd_gnutls_hash (handle, ipad, padsize);
mhd_gnutls_hash_deinit (handle, ret); /* get the previous hash */
_gnutls_hash (td, ret, block);
mhd_gnutls_hash (td, ret, block);
_gnutls_hash_deinit (td, digest);
mhd_gnutls_hash_deinit (td, digest);
}
}
@@ -322,18 +322,18 @@ ssl3_sha (int i, opaque * secret, int secret_len,
text1[j] = 65 + i; /* A==65 */
}
td = _gnutls_hash_init (MHD_GNUTLS_MAC_SHA1);
td = mhd_gtls_hash_init (MHD_GNUTLS_MAC_SHA1);
if (td == NULL)
{
gnutls_assert ();
return GNUTLS_E_HASH_FAILED;
}
_gnutls_hash (td, text1, i + 1);
_gnutls_hash (td, secret, secret_len);
_gnutls_hash (td, rnd, rnd_len);
mhd_gnutls_hash (td, text1, i + 1);
mhd_gnutls_hash (td, secret, secret_len);
mhd_gnutls_hash (td, rnd, rnd_len);
_gnutls_hash_deinit (td, digest);
mhd_gnutls_hash_deinit (td, digest);
return 0;
}
@@ -345,49 +345,49 @@ ssl3_md5 (int i, opaque * secret, int secret_len,
mac_hd_t td;
int ret;
td = _gnutls_hash_init (MHD_GNUTLS_MAC_MD5);
td = mhd_gtls_hash_init (MHD_GNUTLS_MAC_MD5);
if (td == NULL)
{
gnutls_assert ();
return GNUTLS_E_HASH_FAILED;
}
_gnutls_hash (td, secret, secret_len);
mhd_gnutls_hash (td, secret, secret_len);
ret = ssl3_sha (i, secret, secret_len, rnd, rnd_len, tmp);
if (ret < 0)
{
gnutls_assert ();
_gnutls_hash_deinit (td, digest);
mhd_gnutls_hash_deinit (td, digest);
return ret;
}
_gnutls_hash (td, tmp, _gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_SHA1));
mhd_gnutls_hash (td, tmp, mhd_gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_SHA1));
_gnutls_hash_deinit (td, digest);
mhd_gnutls_hash_deinit (td, digest);
return 0;
}
int
_gnutls_ssl3_hash_md5 (void *first, int first_len,
mhd_gnutls_ssl3_hash_md5 (void *first, int first_len,
void *second, int second_len, int ret_len,
opaque * ret)
{
opaque digest[MAX_HASH_SIZE];
mac_hd_t td;
int block = _gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_MD5);
int block = mhd_gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_MD5);
td = _gnutls_hash_init (MHD_GNUTLS_MAC_MD5);
td = mhd_gtls_hash_init (MHD_GNUTLS_MAC_MD5);
if (td == NULL)
{
gnutls_assert ();
return GNUTLS_E_HASH_FAILED;
}
_gnutls_hash (td, first, first_len);
_gnutls_hash (td, second, second_len);
mhd_gnutls_hash (td, first, first_len);
mhd_gnutls_hash (td, second, second_len);
_gnutls_hash_deinit (td, digest);
mhd_gnutls_hash_deinit (td, digest);
if (ret_len > block)
{
@@ -402,13 +402,13 @@ _gnutls_ssl3_hash_md5 (void *first, int first_len,
}
int
_gnutls_ssl3_generate_random (void *secret, int secret_len,
mhd_gnutls_ssl3_generate_random (void *secret, int secret_len,
void *rnd, int rnd_len,
int ret_bytes, opaque * ret)
{
int i = 0, copy, output_bytes;
opaque digest[MAX_HASH_SIZE];
int block = _gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_MD5);
int block = mhd_gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_MD5);
int result, times;
output_bytes = 0;
+13 -14
View File
@@ -42,31 +42,30 @@ typedef mac_hd_t GNUTLS_HASH_HANDLE;
#define GNUTLS_HASH_FAILED NULL
#define GNUTLS_MAC_FAILED NULL
mac_hd_t _gnutls_hmac_init (gnutls_mac_algorithm_t algorithm,
mac_hd_t mhd_gtls_hmac_init (gnutls_mac_algorithm_t algorithm,
const void *key, int keylen);
#define _gnutls_hmac_get_algo_len _gnutls_hash_get_algo_len
#define _gnutls_hmac _gnutls_hash
void _gnutls_hmac_deinit (mac_hd_t handle, void *digest);
mac_hd_t _gnutls_mac_init_ssl3 (gnutls_mac_algorithm_t algorithm, void *key,
void mhd_gnutls_hmac_deinit (mac_hd_t handle, void *digest);
mac_hd_t mhd_gnutls_mac_init_ssl3 (gnutls_mac_algorithm_t algorithm, void *key,
int keylen);
void _gnutls_mac_deinit_ssl3 (mac_hd_t handle, void *digest);
void mhd_gnutls_mac_deinit_ssl3 (mac_hd_t handle, void *digest);
GNUTLS_HASH_HANDLE _gnutls_hash_init (gnutls_mac_algorithm_t algorithm);
int _gnutls_hash_get_algo_len (gnutls_mac_algorithm_t algorithm);
int _gnutls_hash (GNUTLS_HASH_HANDLE handle, const void *text,
GNUTLS_HASH_HANDLE mhd_gtls_hash_init (gnutls_mac_algorithm_t algorithm);
int mhd_gnutls_hash_get_algo_len (gnutls_mac_algorithm_t algorithm);
int mhd_gnutls_hash (GNUTLS_HASH_HANDLE handle, const void *text,
size_t textlen);
void _gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest);
void mhd_gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest);
int _gnutls_ssl3_generate_random (void *secret, int secret_len,
int mhd_gnutls_ssl3_generate_random (void *secret, int secret_len,
void *rnd, int random_len, int bytes,
opaque * ret);
int _gnutls_ssl3_hash_md5 (void *first, int first_len, void *second,
int mhd_gnutls_ssl3_hash_md5 (void *first, int first_len, void *second,
int second_len, int ret_len, opaque * ret);
void _gnutls_mac_deinit_ssl3_handshake (mac_hd_t handle, void *digest,
void mhd_gnutls_mac_deinit_ssl3_handshake (mac_hd_t handle, void *digest,
opaque * key, uint32_t key_size);
GNUTLS_HASH_HANDLE _gnutls_hash_copy (GNUTLS_HASH_HANDLE handle);
GNUTLS_HASH_HANDLE mhd_gnutls_hash_copy (GNUTLS_HASH_HANDLE handle);
#endif /* GNUTLS_HASH_INT_H */
+63 -65
View File
@@ -128,7 +128,13 @@ typedef enum handshake_state_t
STATE70, STATE71
} handshake_state_t;
#include <gnutls_buffer.h>
#include <gnutls_str.h>
typedef mhd_gtls_string mhd_gtls_buffer;
#define mhd_gtls_buffer_init(buf) mhd_gtls_string_init(buf, gnutls_malloc, gnutls_realloc, gnutls_free);
#define mhd_gtls_buffer_clear mhd_gtls_string_clear
#define mhd_gtls_buffer_append mhd_gtls_string_append_data
/* This is the maximum number of algorithms (ciphers or macs etc).
* keep it synced with GNUTLS_MAX_ALGORITHM_NUM in gnutls.h
@@ -175,17 +181,17 @@ typedef void (*LOG_FUNC)(int,
const char *);
/* Store & Retrieve functions defines: */
typedef struct auth_cred_st
typedef struct mhd_gtls_auth_cred_st
{
gnutls_credentials_type_t algorithm;
/* the type of credentials depends on algorithm
*/
void *credentials;
struct auth_cred_st *next;
struct mhd_gtls_auth_cred_st *next;
} auth_cred_st;
struct gnutls_key_st
struct mhd_gtls_key
{
/* For DH KX */
gnutls_datum_t key;
@@ -229,7 +235,7 @@ struct gnutls_key_st
* for a client certificate verify
*/
};
typedef struct gnutls_key_st *gnutls_key_st;
typedef struct mhd_gtls_key * mhd_gtls_key_st;
/* STATE (cont) */
#include <gnutls_hash_int.h>
@@ -276,7 +282,7 @@ typedef struct
uint16_t oprfi_client_len;
opaque *oprfi_server;
uint16_t oprfi_server_len;
} tls_ext_st;
} mhd_gtls_ext_st;
/* This flag indicates for an extension whether
* it is useful to application level or TLS level only.
@@ -288,7 +294,7 @@ typedef enum tls_ext_parse_type_t
EXTENSION_ANY,
EXTENSION_APPLICATION,
EXTENSION_TLS
} tls_ext_parse_type_t;
} mhd_gtls_ext_parse_type_t;
/* auth_info_t structures now MAY contain malloced
* elements.
@@ -335,7 +341,7 @@ typedef struct
opaque session_id[TLS_MAX_SESSION_ID_SIZE];
uint8_t session_id_size;
time_t timestamp;
tls_ext_st extensions;
mhd_gtls_ext_st extensions;
/* The send size is the one requested by the programmer.
* The recv size is the one negotiated with the peer.
@@ -347,7 +353,7 @@ typedef struct
gnutls_protocol_t version; /* moved here */
/* For TLS/IA. XXX: Move to IA credential? */
opaque inner_secret[TLS_MASTER_SIZE];
} security_parameters_st;
} mhd_gtls_security_param_st;
/* This structure holds the generated keys
*/
@@ -363,7 +369,7 @@ typedef struct
* been generated. Non zero
* otherwise.
*/
} cipher_specs_st;
} mhd_gtls_cipher_specs_st;
typedef struct
{
@@ -375,25 +381,25 @@ typedef struct
gnutls_datum_t write_mac_secret;
uint64 read_sequence_number;
uint64 write_sequence_number;
} conn_stat_st;
} mhd_gtls_conn_stat_st;
typedef struct
{
unsigned int priority[MAX_ALGOS];
unsigned int num_algorithms;
} priority_st;
} mhd_gtls_priority_st;
/* For the external api */
struct gnutls_priority_st
struct MHD_gtls_priority_st
{
priority_st cipher;
priority_st mac;
priority_st kx;
priority_st compression;
priority_st protocol;
mhd_gtls_priority_st cipher;
mhd_gtls_priority_st mac;
mhd_gtls_priority_st kx;
mhd_gtls_priority_st compression;
mhd_gtls_priority_st protocol;
/* certificate type : x509, OpenPGP, etc. */
priority_st cert_type;
mhd_gtls_priority_st cert_type;
/* to disable record padding */
int no_padding;
@@ -401,20 +407,20 @@ struct gnutls_priority_st
/* DH and RSA parameters types.
*/
typedef struct gnutls_dh_params_int
typedef struct MHD_gtls_dh_params_int
{
/* [0] is the prime, [1] is the generator.
*/
mpi_t params[2];
} dh_params_st;
} mhd_gtls_dh_params_st;
typedef struct
{
gnutls_dh_params_t dh_params;
mhd_gtls_dh_params_t dh_params;
int free_dh_params;
gnutls_rsa_params_t rsa_params;
mhd_gtls_rsa_params_t rsa_params;
int free_rsa_params;
} internal_params_st;
} mhd_gtls_internal_params_st;
typedef struct
{
@@ -424,18 +430,18 @@ typedef struct
/* this holds the length of the handshake packet */
size_t packet_length;
gnutls_handshake_description_t recv_type;
} handshake_header_buffer_st;
} mhd_gtls_handshake_header_buffer_st;
typedef struct
{
gnutls_buffer application_data_buffer; /* holds data to be delivered to application layer */
gnutls_buffer handshake_hash_buffer; /* used to keep the last received handshake
mhd_gtls_buffer application_data_buffer; /* holds data to be delivered to application layer */
mhd_gtls_buffer handshake_hash_buffer; /* used to keep the last received handshake
* message */
mac_hd_t handshake_mac_handle_sha; /* hash of the handshake messages */
mac_hd_t handshake_mac_handle_md5; /* hash of the handshake messages */
gnutls_buffer handshake_data_buffer; /* this is a buffer that holds the current handshake message */
gnutls_buffer ia_data_buffer; /* holds inner application data (TLS/IA) */
mhd_gtls_buffer handshake_data_buffer; /* this is a buffer that holds the current handshake message */
mhd_gtls_buffer ia_data_buffer; /* holds inner application data (TLS/IA) */
resumable_session_t resumable; /* TRUE or FALSE - if we can resume that session */
handshake_state_t handshake_state; /* holds
* a number which indicates where
@@ -463,11 +469,11 @@ typedef struct
gnutls_compression_method_t compression_method;
/* priorities */
struct gnutls_priority_st priorities;
struct MHD_gtls_priority_st priorities;
/* resumed session */
resumable_session_t resumed; /* RESUME_TRUE or FALSE - if we are resuming a session */
security_parameters_st resumed_security_parameters;
mhd_gtls_security_param_st resumed_security_parameters;
/* sockets internals */
int lowat;
@@ -475,19 +481,19 @@ typedef struct
/* These buffers are used in the handshake
* protocol only. freed using _gnutls_handshake_io_buffer_clear();
*/
gnutls_buffer handshake_send_buffer;
mhd_gtls_buffer handshake_send_buffer;
size_t handshake_send_buffer_prev_size;
content_type_t handshake_send_buffer_type;
gnutls_handshake_description_t handshake_send_buffer_htype;
content_type_t handshake_recv_buffer_type;
gnutls_handshake_description_t handshake_recv_buffer_htype;
gnutls_buffer handshake_recv_buffer;
mhd_gtls_buffer handshake_recv_buffer;
/* this buffer holds a record packet -mostly used for
* non blocking IO.
*/
gnutls_buffer record_recv_buffer;
gnutls_buffer record_send_buffer; /* holds cached data
mhd_gtls_buffer record_recv_buffer;
mhd_gtls_buffer record_send_buffer; /* holds cached data
* for the gnutls_io_write_buffered()
* function.
*/
@@ -504,7 +510,7 @@ typedef struct
int have_peeked_data;
int expire_time; /* after expire_time seconds this session will expire */
struct mod_auth_st_int *auth_struct; /* used in handshake packets and KX algorithms */
struct mhd_gtls_mod_auth_st_int *auth_struct; /* used in handshake packets and KX algorithms */
/* TODO rm */
int v2_hello; /* 0 if the client hello is v3+.
@@ -512,7 +518,7 @@ typedef struct
*/
/* keeps the headers of the handshake packet
*/
handshake_header_buffer_st handshake_header_buffer;
mhd_gtls_handshake_header_buffer_st handshake_header_buffer;
/* this is the highest version available
* to the peer. (advertized version).
@@ -529,7 +535,7 @@ typedef struct
int send_cert_req;
/* bits to use for DHE and DHA
* use _gnutls_dh_get_prime_bits() and gnutls_dh_set_prime_bits()
* use _gnutls_dh_get_prime_bits() and MHD_gnutls_dh_set_prime_bits()
* to access it.
*/
uint16_t dh_prime_bits;
@@ -538,22 +544,14 @@ typedef struct
/* PUSH & PULL functions.
*/
gnutls_pull_func _gnutls_pull_func;
gnutls_push_func _gnutls_push_func;
mhd_gtls_pull_func _gnutls_pull_func;
mhd_gtls_push_func _gnutls_push_func;
/* Holds the first argument of PUSH and PULL
* functions;
*/
gnutls_transport_ptr_t transport_recv_ptr;
gnutls_transport_ptr_t transport_send_ptr;
/* STORE & RETRIEVE functions. Only used if other
* backend than gdbm is used.
*/
gnutls_db_store_func db_store_func;
gnutls_db_retr_func db_retrieve_func;
gnutls_db_remove_func db_remove_func;
void *db_ptr;
/* post client hello callback (server side only)
*/
gnutls_handshake_post_client_hello_func user_hello_func;
@@ -564,7 +562,7 @@ typedef struct
uint16_t proposed_record_size;
/* holds the selected certificate and key.
* use _gnutls_selected_certs_deinit() and _gnutls_selected_certs_set()
* use mhd_gtls_selected_certs_deinit() and mhd_gtls_selected_certs_set()
* to change them.
*/
gnutls_cert *selected_cert_list;
@@ -604,7 +602,7 @@ typedef struct
/* This callback will be used (if set) to receive an
* openpgp key. (if the peer sends a fingerprint)
*/
gnutls_openpgp_recv_key_func openpgp_recv_key_func;
mhd_gtls_openpgp_recv_key_func openpgp_recv_key_func;
/* If non zero the server will not advertize the CA's he
* trusts (do not send an RDN sequence).
@@ -624,7 +622,7 @@ typedef struct
* credentials structure, or from a callback. That is to
* minimize external calls.
*/
internal_params_st params;
mhd_gtls_internal_params_st params;
/* This buffer is used by the record recv functions,
* as a temporary store buffer.
@@ -633,7 +631,7 @@ typedef struct
/* To avoid using global variables, and especially on Windows where
* the application may use a different errno variable than GnuTLS,
* it is possible to use gnutls_transport_set_errno to set a
* it is possible to use MHD_gnutls_transport_set_errno to set a
* session-specific errno variable in the user-replaceable push/pull
* functions. This value is used by the send/recv functions. (The
* strange name of this variable is because 'errno' is typically
@@ -643,28 +641,28 @@ typedef struct
/* Function used to perform public-key signing operation during
handshake. Used by gnutls_sig.c:_gnutls_tls_sign(), see also
gnutls_sign_callback_set(). */
MHD_gtls_sign_callback_set(). */
gnutls_sign_func sign_func;
void *sign_func_userdata;
/* If you add anything here, check _gnutls_handshake_internal_state_clear().
/* If you add anything here, check mhd_gtls_handshake_internal_state_clear().
*/
} internals_st;
} mhd_gtls_internals_st;
struct gnutls_session_int
struct MHD_gtls_session_int
{
security_parameters_st security_parameters;
cipher_specs_st cipher_specs;
conn_stat_st connection_state;
internals_st internals;
gnutls_key_st key;
mhd_gtls_security_param_st security_parameters;
mhd_gtls_cipher_specs_st cipher_specs;
mhd_gtls_conn_stat_st connection_state;
mhd_gtls_internals_st internals;
mhd_gtls_key_st key;
};
/* functions */
void _gnutls_set_current_version(gnutls_session_t session,
void mhd_gtls_set_current_version(mhd_gtls_session_t session,
gnutls_protocol_t version);
void _gnutls_free_auth_info(gnutls_session_t session);
void mhd_gtls_free_auth_info(mhd_gtls_session_t session);
/* These two macros return the advertized TLS version of
* the peer.
@@ -679,8 +677,8 @@ void _gnutls_free_auth_info(gnutls_session_t session);
session->internals.adv_version_major = major; \
session->internals.adv_version_minor = minor
void _gnutls_set_adv_version(gnutls_session_t,
void mhd_gtls_set_adv_version(mhd_gtls_session_t,
gnutls_protocol_t);
gnutls_protocol_t _gnutls_get_adv_version(gnutls_session_t);
gnutls_protocol_t mhd_gtls_get_adv_version(mhd_gtls_session_t);
#endif /* GNUTLS_INT_H */
+67 -67
View File
@@ -23,7 +23,7 @@
*/
/* This file contains functions which are wrappers for the key exchange
* part of TLS. They are called by the handshake functions (gnutls_handshake)
* part of TLS. They are called by the handshake functions (MHD_gnutls_handshake)
*/
#include "gnutls_int.h"
@@ -42,10 +42,10 @@
*/
#define MASTER_SECRET "master secret"
static int generate_normal_master (gnutls_session_t session, int);
static int generate_normal_master (mhd_gtls_session_t session, int);
int
_gnutls_generate_master (gnutls_session_t session, int keep_premaster)
mhd_gtls_generate_master (mhd_gtls_session_t session, int keep_premaster)
{
if (session->internals.resumed == RESUME_FALSE)
return generate_normal_master (session, keep_premaster);
@@ -56,22 +56,22 @@ _gnutls_generate_master (gnutls_session_t session, int keep_premaster)
*/
#define PREMASTER session->key->key
static int
generate_normal_master (gnutls_session_t session, int keep_premaster)
generate_normal_master (mhd_gtls_session_t session, int keep_premaster)
{
int ret = 0;
char buf[512];
_gnutls_hard_log ("INT: PREMASTER SECRET[%d]: %s\n", PREMASTER.size,
_gnutls_bin2hex (PREMASTER.data, PREMASTER.size, buf,
mhd_gtls_bin2hex (PREMASTER.data, PREMASTER.size, buf,
sizeof (buf)));
_gnutls_hard_log ("INT: CLIENT RANDOM[%d]: %s\n", 32,
_gnutls_bin2hex (session->security_parameters.
mhd_gtls_bin2hex (session->security_parameters.
client_random, 32, buf, sizeof (buf)));
_gnutls_hard_log ("INT: SERVER RANDOM[%d]: %s\n", 32,
_gnutls_bin2hex (session->security_parameters.
mhd_gtls_bin2hex (session->security_parameters.
server_random, 32, buf, sizeof (buf)));
if (gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
{
opaque rnd[2 * TLS_RANDOM_SIZE + 1];
@@ -81,7 +81,7 @@ generate_normal_master (gnutls_session_t session, int keep_premaster)
session->security_parameters.server_random, TLS_RANDOM_SIZE);
ret =
_gnutls_ssl3_generate_random (PREMASTER.data, PREMASTER.size,
mhd_gnutls_ssl3_generate_random (PREMASTER.data, PREMASTER.size,
rnd, 2 * TLS_RANDOM_SIZE,
TLS_MASTER_SIZE,
session->security_parameters.
@@ -107,7 +107,7 @@ generate_normal_master (gnutls_session_t session, int keep_premaster)
_gnutls_hard_log ("INT: CLIENT OPRFI[%d]: %s\n",
session->security_parameters.
extensions.oprfi_server_len,
_gnutls_bin2hex (session->security_parameters.
mhd_gtls_bin2hex (session->security_parameters.
extensions.oprfi_client,
session->security_parameters.
extensions.oprfi_client_len,
@@ -115,7 +115,7 @@ generate_normal_master (gnutls_session_t session, int keep_premaster)
_gnutls_hard_log ("INT: SERVER OPRFI[%d]: %s\n",
session->security_parameters.
extensions.oprfi_server_len,
_gnutls_bin2hex (session->security_parameters.
mhd_gtls_bin2hex (session->security_parameters.
extensions.oprfi_server,
session->security_parameters.
extensions.oprfi_server_len,
@@ -135,7 +135,7 @@ generate_normal_master (gnutls_session_t session, int keep_premaster)
session->security_parameters.extensions.oprfi_server,
session->security_parameters.extensions.oprfi_server_len);
ret = _gnutls_PRF (session, PREMASTER.data, PREMASTER.size,
ret = mhd_gtls_PRF (session, PREMASTER.data, PREMASTER.size,
MASTER_SECRET, strlen (MASTER_SECRET),
rnd, rndlen, TLS_MASTER_SIZE,
session->security_parameters.master_secret);
@@ -152,7 +152,7 @@ generate_normal_master (gnutls_session_t session, int keep_premaster)
session->security_parameters.server_random, TLS_RANDOM_SIZE);
ret =
_gnutls_PRF (session, PREMASTER.data, PREMASTER.size,
mhd_gtls_PRF (session, PREMASTER.data, PREMASTER.size,
MASTER_SECRET, strlen (MASTER_SECRET),
rnd, 2 * TLS_RANDOM_SIZE, TLS_MASTER_SIZE,
session->security_parameters.master_secret);
@@ -169,7 +169,7 @@ generate_normal_master (gnutls_session_t session, int keep_premaster)
return ret;
_gnutls_hard_log ("INT: MASTER SECRET: %s\n",
_gnutls_bin2hex (session->security_parameters.
mhd_gtls_bin2hex (session->security_parameters.
master_secret, TLS_MASTER_SIZE, buf,
sizeof (buf)));
@@ -182,13 +182,13 @@ generate_normal_master (gnutls_session_t session, int keep_premaster)
* by the selected ciphersuite.
*/
int
_gnutls_send_server_kx_message (gnutls_session_t session, int again)
mhd_gtls_send_server_kx_message (mhd_gtls_session_t session, int again)
{
uint8_t *data = NULL;
int data_size = 0;
int ret = 0;
if (session->internals.auth_struct->gnutls_generate_server_kx == NULL)
if (session->internals.auth_struct->mhd_gtls_gen_server_kx == NULL)
return 0;
data = NULL;
@@ -198,7 +198,7 @@ _gnutls_send_server_kx_message (gnutls_session_t session, int again)
{
data_size =
session->internals.auth_struct->
gnutls_generate_server_kx (session, &data);
mhd_gtls_gen_server_kx (session, &data);
if (data_size == GNUTLS_E_INT_RET_0)
{
@@ -214,7 +214,7 @@ _gnutls_send_server_kx_message (gnutls_session_t session, int again)
}
ret =
_gnutls_send_handshake (session, data, data_size,
mhd_gtls_send_handshake (session, data, data_size,
GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE);
gnutls_free (data);
@@ -230,14 +230,14 @@ _gnutls_send_server_kx_message (gnutls_session_t session, int again)
* client.
*/
int
_gnutls_send_server_certificate_request (gnutls_session_t session, int again)
mhd_gtls_send_server_certificate_request (mhd_gtls_session_t session, int again)
{
uint8_t *data = NULL;
int data_size = 0;
int ret = 0;
if (session->internals.auth_struct->
gnutls_generate_server_certificate_request == NULL)
mhd_gtls_gen_server_certificate_request == NULL)
return 0;
if (session->internals.send_cert_req <= 0)
@@ -250,7 +250,7 @@ _gnutls_send_server_certificate_request (gnutls_session_t session, int again)
{
data_size =
session->internals.auth_struct->
gnutls_generate_server_certificate_request (session, &data);
mhd_gtls_gen_server_certificate_request (session, &data);
if (data_size < 0)
{
@@ -259,7 +259,7 @@ _gnutls_send_server_certificate_request (gnutls_session_t session, int again)
}
}
ret =
_gnutls_send_handshake (session, data, data_size,
mhd_gtls_send_handshake (session, data, data_size,
GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST);
gnutls_free (data);
@@ -276,13 +276,13 @@ _gnutls_send_server_certificate_request (gnutls_session_t session, int again)
* exchange message
*/
int
_gnutls_send_client_kx_message (gnutls_session_t session, int again)
mhd_gtls_send_client_kx_message (mhd_gtls_session_t session, int again)
{
uint8_t *data;
int data_size;
int ret = 0;
if (session->internals.auth_struct->gnutls_generate_client_kx == NULL)
if (session->internals.auth_struct->mhd_gtls_gen_client_kx == NULL)
return 0;
@@ -293,7 +293,7 @@ _gnutls_send_client_kx_message (gnutls_session_t session, int again)
{
data_size =
session->internals.auth_struct->
gnutls_generate_client_kx (session, &data);
mhd_gtls_gen_client_kx (session, &data);
if (data_size < 0)
{
gnutls_assert ();
@@ -301,7 +301,7 @@ _gnutls_send_client_kx_message (gnutls_session_t session, int again)
}
}
ret =
_gnutls_send_handshake (session, data, data_size,
mhd_gtls_send_handshake (session, data, data_size,
GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE);
gnutls_free (data);
@@ -319,7 +319,7 @@ _gnutls_send_client_kx_message (gnutls_session_t session, int again)
* verify message
*/
int
_gnutls_send_client_certificate_verify (gnutls_session_t session, int again)
mhd_gtls_send_client_certificate_verify (mhd_gtls_session_t session, int again)
{
uint8_t *data;
int ret = 0;
@@ -335,7 +335,7 @@ _gnutls_send_client_certificate_verify (gnutls_session_t session, int again)
if (session->key->certificate_requested == 0)
return 0;
if (session->internals.auth_struct->gnutls_generate_client_cert_vrfy ==
if (session->internals.auth_struct->mhd_gtls_gen_client_cert_vrfy ==
NULL)
{
gnutls_assert ();
@@ -350,7 +350,7 @@ _gnutls_send_client_certificate_verify (gnutls_session_t session, int again)
{
data_size =
session->internals.auth_struct->
gnutls_generate_client_cert_vrfy (session, &data);
mhd_gtls_gen_client_cert_vrfy (session, &data);
if (data_size < 0)
{
gnutls_assert ();
@@ -361,7 +361,7 @@ _gnutls_send_client_certificate_verify (gnutls_session_t session, int again)
}
ret =
_gnutls_send_handshake (session, data,
mhd_gtls_send_handshake (session, data,
data_size, GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY);
gnutls_free (data);
@@ -370,18 +370,18 @@ _gnutls_send_client_certificate_verify (gnutls_session_t session, int again)
int
_gnutls_recv_server_kx_message (gnutls_session_t session)
mhd_gtls_recv_server_kx_message (mhd_gtls_session_t session)
{
uint8_t *data = NULL;
int datasize;
int ret = 0;
if (session->internals.auth_struct->gnutls_process_server_kx != NULL)
if (session->internals.auth_struct->mhd_gtls_process_server_kx != NULL)
{
/* EXCEPTION FOR RSA_EXPORT cipher suite
*/
if (_gnutls_session_is_export (session) != 0 &&
if (mhd_gtls_session_is_export (session) != 0 &&
_gnutls_peers_cert_less_512 (session) != 0)
{
gnutls_assert ();
@@ -389,7 +389,7 @@ _gnutls_recv_server_kx_message (gnutls_session_t session)
}
ret =
_gnutls_recv_handshake (session, &data,
mhd_gtls_recv_handshake (session, &data,
&datasize,
GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE,
MANDATORY_PACKET);
@@ -401,7 +401,7 @@ _gnutls_recv_server_kx_message (gnutls_session_t session)
ret =
session->internals.auth_struct->
gnutls_process_server_kx (session, data, datasize);
mhd_gtls_process_server_kx (session, data, datasize);
gnutls_free (data);
if (ret < 0)
@@ -415,18 +415,18 @@ _gnutls_recv_server_kx_message (gnutls_session_t session)
}
int
_gnutls_recv_server_certificate_request (gnutls_session_t session)
mhd_gtls_recv_server_certificate_request (mhd_gtls_session_t session)
{
uint8_t *data;
int datasize;
int ret = 0;
if (session->internals.auth_struct->
gnutls_process_server_certificate_request != NULL)
mhd_gtls_process_server_certificate_request != NULL)
{
ret =
_gnutls_recv_handshake (session, &data,
mhd_gtls_recv_handshake (session, &data,
&datasize,
GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST,
OPTIONAL_PACKET);
@@ -438,7 +438,7 @@ _gnutls_recv_server_certificate_request (gnutls_session_t session)
ret =
session->internals.auth_struct->
gnutls_process_server_certificate_request (session, data, datasize);
mhd_gtls_process_server_certificate_request (session, data, datasize);
gnutls_free (data);
if (ret < 0)
return ret;
@@ -448,7 +448,7 @@ _gnutls_recv_server_certificate_request (gnutls_session_t session)
}
int
_gnutls_recv_client_kx_message (gnutls_session_t session)
mhd_gtls_recv_client_kx_message (mhd_gtls_session_t session)
{
uint8_t *data;
int datasize;
@@ -456,11 +456,11 @@ _gnutls_recv_client_kx_message (gnutls_session_t session)
/* Do key exchange only if the algorithm permits it */
if (session->internals.auth_struct->gnutls_process_client_kx != NULL)
if (session->internals.auth_struct->mhd_gtls_process_client_kx != NULL)
{
ret =
_gnutls_recv_handshake (session, &data,
mhd_gtls_recv_handshake (session, &data,
&datasize,
GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE,
MANDATORY_PACKET);
@@ -469,7 +469,7 @@ _gnutls_recv_client_kx_message (gnutls_session_t session)
ret =
session->internals.auth_struct->
gnutls_process_client_kx (session, data, datasize);
mhd_gtls_process_client_kx (session, data, datasize);
gnutls_free (data);
if (ret < 0)
return ret;
@@ -483,7 +483,7 @@ _gnutls_recv_client_kx_message (gnutls_session_t session)
/* This is called when we want send our certificate
*/
int
_gnutls_send_client_certificate (gnutls_session_t session, int again)
mhd_gtls_send_client_certificate (mhd_gtls_session_t session, int again)
{
uint8_t *data = NULL;
int data_size = 0;
@@ -494,7 +494,7 @@ _gnutls_send_client_certificate (gnutls_session_t session, int again)
return 0;
if (session->internals.auth_struct->
gnutls_generate_client_certificate == NULL)
mhd_gtls_gen_client_certificate == NULL)
return 0;
data = NULL;
@@ -502,14 +502,14 @@ _gnutls_send_client_certificate (gnutls_session_t session, int again)
if (again == 0)
{
if (gnutls_protocol_get_version (session) != MHD_GNUTLS_SSL3 ||
if (MHD_gnutls_protocol_get_version (session) != MHD_GNUTLS_SSL3 ||
session->internals.selected_cert_list_length > 0)
{
/* TLS 1.0 or SSL 3.0 with a valid certificate
*/
data_size =
session->internals.auth_struct->
gnutls_generate_client_certificate (session, &data);
mhd_gtls_gen_client_certificate (session, &data);
if (data_size < 0)
{
@@ -523,11 +523,11 @@ _gnutls_send_client_certificate (gnutls_session_t session, int again)
* no certificate alert instead of an
* empty certificate.
*/
if (gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3 &&
if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3 &&
session->internals.selected_cert_list_length == 0)
{
ret =
gnutls_alert_send (session, GNUTLS_AL_WARNING,
MHD_gnutls_alert_send (session, GNUTLS_AL_WARNING,
GNUTLS_A_SSL3_NO_CERTIFICATE);
}
@@ -535,7 +535,7 @@ _gnutls_send_client_certificate (gnutls_session_t session, int again)
{ /* TLS 1.0 or SSL 3.0 with a valid certificate
*/
ret =
_gnutls_send_handshake (session, data, data_size,
mhd_gtls_send_handshake (session, data, data_size,
GNUTLS_HANDSHAKE_CERTIFICATE_PKT);
gnutls_free (data);
}
@@ -553,7 +553,7 @@ _gnutls_send_client_certificate (gnutls_session_t session, int again)
/* This is called when we want send our certificate
*/
int
_gnutls_send_server_certificate (gnutls_session_t session, int again)
mhd_gtls_send_server_certificate (mhd_gtls_session_t session, int again)
{
uint8_t *data = NULL;
int data_size = 0;
@@ -561,7 +561,7 @@ _gnutls_send_server_certificate (gnutls_session_t session, int again)
if (session->internals.auth_struct->
gnutls_generate_server_certificate == NULL)
mhd_gtls_gen_server_certificate == NULL)
return 0;
data = NULL;
@@ -571,7 +571,7 @@ _gnutls_send_server_certificate (gnutls_session_t session, int again)
{
data_size =
session->internals.auth_struct->
gnutls_generate_server_certificate (session, &data);
mhd_gtls_gen_server_certificate (session, &data);
if (data_size < 0)
{
@@ -580,7 +580,7 @@ _gnutls_send_server_certificate (gnutls_session_t session, int again)
}
}
ret =
_gnutls_send_handshake (session, data, data_size,
mhd_gtls_send_handshake (session, data, data_size,
GNUTLS_HANDSHAKE_CERTIFICATE_PKT);
gnutls_free (data);
@@ -595,7 +595,7 @@ _gnutls_send_server_certificate (gnutls_session_t session, int again)
int
_gnutls_recv_client_certificate (gnutls_session_t session)
mhd_gtls_recv_client_certificate (mhd_gtls_session_t session)
{
int datasize;
opaque *data;
@@ -603,7 +603,7 @@ _gnutls_recv_client_certificate (gnutls_session_t session)
int optional;
if (session->internals.auth_struct->
gnutls_process_client_certificate != NULL)
mhd_gtls_process_client_certificate != NULL)
{
/* if we have not requested a certificate then just return
@@ -619,7 +619,7 @@ _gnutls_recv_client_certificate (gnutls_session_t session)
optional = OPTIONAL_PACKET;
ret =
_gnutls_recv_handshake (session, &data,
mhd_gtls_recv_handshake (session, &data,
&datasize,
GNUTLS_HANDSHAKE_CERTIFICATE_PKT, optional);
@@ -631,7 +631,7 @@ _gnutls_recv_client_certificate (gnutls_session_t session)
*/
if (optional == OPTIONAL_PACKET &&
ret == GNUTLS_E_WARNING_ALERT_RECEIVED &&
gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3 &&
MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3 &&
gnutls_alert_get (session) == GNUTLS_A_SSL3_NO_CERTIFICATE)
{
@@ -666,7 +666,7 @@ _gnutls_recv_client_certificate (gnutls_session_t session)
}
ret =
session->internals.auth_struct->
gnutls_process_client_certificate (session, data, datasize);
mhd_gtls_process_client_certificate (session, data, datasize);
gnutls_free (data);
if (ret < 0 && ret != GNUTLS_E_NO_CERTIFICATE_FOUND)
@@ -688,18 +688,18 @@ _gnutls_recv_client_certificate (gnutls_session_t session)
}
int
_gnutls_recv_server_certificate (gnutls_session_t session)
mhd_gtls_recv_server_certificate (mhd_gtls_session_t session)
{
int datasize;
opaque *data;
int ret = 0;
if (session->internals.auth_struct->
gnutls_process_server_certificate != NULL)
mhd_gtls_process_server_certificate != NULL)
{
ret =
_gnutls_recv_handshake (session, &data,
mhd_gtls_recv_handshake (session, &data,
&datasize,
GNUTLS_HANDSHAKE_CERTIFICATE_PKT,
MANDATORY_PACKET);
@@ -711,7 +711,7 @@ _gnutls_recv_server_certificate (gnutls_session_t session)
ret =
session->internals.auth_struct->
gnutls_process_server_certificate (session, data, datasize);
mhd_gtls_process_server_certificate (session, data, datasize);
gnutls_free (data);
if (ret < 0)
{
@@ -728,14 +728,14 @@ _gnutls_recv_server_certificate (gnutls_session_t session)
* arrive if the peer did not send us a certificate.
*/
int
_gnutls_recv_client_certificate_verify_message (gnutls_session_t session)
mhd_gtls_recv_client_certificate_verify_message (mhd_gtls_session_t session)
{
uint8_t *data;
int datasize;
int ret = 0;
if (session->internals.auth_struct->gnutls_process_client_cert_vrfy != NULL)
if (session->internals.auth_struct->mhd_gtls_process_client_cert_vrfy != NULL)
{
if (session->internals.send_cert_req == 0 ||
@@ -745,7 +745,7 @@ _gnutls_recv_client_certificate_verify_message (gnutls_session_t session)
}
ret =
_gnutls_recv_handshake (session, &data,
mhd_gtls_recv_handshake (session, &data,
&datasize,
GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY,
OPTIONAL_PACKET);
@@ -762,7 +762,7 @@ _gnutls_recv_client_certificate_verify_message (gnutls_session_t session)
ret =
session->internals.auth_struct->
gnutls_process_client_cert_vrfy (session, data, datasize);
mhd_gtls_process_client_cert_vrfy (session, data, datasize);
gnutls_free (data);
if (ret < 0)
return ret;
+13 -13
View File
@@ -22,18 +22,18 @@
*
*/
int _gnutls_send_server_kx_message (gnutls_session_t session, int again);
int _gnutls_send_client_kx_message (gnutls_session_t session, int again);
int _gnutls_recv_server_kx_message (gnutls_session_t session);
int _gnutls_recv_client_kx_message (gnutls_session_t session);
int _gnutls_send_client_certificate_verify (gnutls_session_t session,
int mhd_gtls_send_server_kx_message (mhd_gtls_session_t session, int again);
int mhd_gtls_send_client_kx_message (mhd_gtls_session_t session, int again);
int mhd_gtls_recv_server_kx_message (mhd_gtls_session_t session);
int mhd_gtls_recv_client_kx_message (mhd_gtls_session_t session);
int mhd_gtls_send_client_certificate_verify (mhd_gtls_session_t session,
int again);
int _gnutls_send_server_certificate (gnutls_session_t session, int again);
int _gnutls_generate_master (gnutls_session_t session, int keep_premaster);
int _gnutls_recv_client_certificate (gnutls_session_t session);
int _gnutls_recv_server_certificate (gnutls_session_t session);
int _gnutls_send_client_certificate (gnutls_session_t session, int again);
int _gnutls_recv_server_certificate_request (gnutls_session_t session);
int _gnutls_send_server_certificate_request (gnutls_session_t session,
int mhd_gtls_send_server_certificate (mhd_gtls_session_t session, int again);
int mhd_gtls_generate_master (mhd_gtls_session_t session, int keep_premaster);
int mhd_gtls_recv_client_certificate (mhd_gtls_session_t session);
int mhd_gtls_recv_server_certificate (mhd_gtls_session_t session);
int mhd_gtls_send_client_certificate (mhd_gtls_session_t session, int again);
int mhd_gtls_recv_server_certificate_request (mhd_gtls_session_t session);
int mhd_gtls_send_server_certificate_request (mhd_gtls_session_t session,
int again);
int _gnutls_recv_client_certificate_verify_message (gnutls_session_t session);
int mhd_gtls_recv_client_certificate_verify_message (mhd_gtls_session_t session);
+7 -7
View File
@@ -32,7 +32,7 @@ gnutls_free_function gnutls_free = free;
gnutls_realloc_function gnutls_realloc = realloc;
void *(*gnutls_calloc) (size_t, size_t) = calloc;
char *(*gnutls_strdup) (const char *) = _gnutls_strdup;
char *(*gnutls_strdup) (const char *) = mhd_gtls_strdup;
int
_gnutls_is_secure_mem_null (const void *ign)
@@ -44,7 +44,7 @@ int (*_gnutls_is_secure_memory) (const void *) = _gnutls_is_secure_mem_null;
void *
_gnutls_calloc (size_t nmemb, size_t size)
mhd_gtls_calloc (size_t nmemb, size_t size)
{
void *ret;
size *= nmemb;
@@ -55,7 +55,7 @@ _gnutls_calloc (size_t nmemb, size_t size)
}
svoid *
gnutls_secure_calloc (size_t nmemb, size_t size)
mhd_gtls_secure_calloc (size_t nmemb, size_t size)
{
svoid *ret;
size *= nmemb;
@@ -69,7 +69,7 @@ gnutls_secure_calloc (size_t nmemb, size_t size)
* fails.
*/
void *
gnutls_realloc_fast (void *ptr, size_t size)
mhd_gtls_realloc_fast (void *ptr, size_t size)
{
void *ret;
@@ -86,7 +86,7 @@ gnutls_realloc_fast (void *ptr, size_t size)
}
char *
_gnutls_strdup (const char *str)
mhd_gtls_strdup (const char *str)
{
size_t siz = strlen (str) + 1;
char *ret;
@@ -109,7 +109,7 @@ _gnutls_strdup (const char *str)
* return a pointer to memory. This function is supposed
* to be used by callbacks.
*
* The allocation function used is the one set by gnutls_global_set_mem_functions().
* The allocation function used is the one set by MHD_gtls_global_set_mem_functions().
*
**/
void *
@@ -123,7 +123,7 @@ gnutls_malloc (size_t s)
*
* This function will free data pointed by ptr.
*
* The deallocation function used is the one set by gnutls_global_set_mem_functions().
* The deallocation function used is the one set by MHD_gtls_global_set_mem_functions().
*
**/
void
+4 -4
View File
@@ -60,11 +60,11 @@ extern int (*_gnutls_is_secure_memory) (const void *);
/* this realloc function will return ptr if size==0, and
* will free the ptr if the new allocation failed.
*/
void *gnutls_realloc_fast (void *ptr, size_t size);
void * mhd_gtls_realloc_fast (void *ptr, size_t size);
svoid *gnutls_secure_calloc (size_t nmemb, size_t size);
svoid * mhd_gtls_secure_calloc (size_t nmemb, size_t size);
void *_gnutls_calloc (size_t nmemb, size_t size);
char *_gnutls_strdup (const char *);
void * mhd_gtls_calloc (size_t nmemb, size_t size);
char * mhd_gtls_strdup (const char *);
#endif /* GNUTLS_MEM_H */
+15 -15
View File
@@ -35,7 +35,7 @@
*/
void
_gnutls_mpi_release (mpi_t * x)
mhd_gtls_mpi_release (mpi_t * x)
{
if (*x == NULL)
return;
@@ -46,7 +46,7 @@ _gnutls_mpi_release (mpi_t * x)
/* returns zero on success
*/
int
_gnutls_mpi_scan (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
mhd_gtls_mpi_scan (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
{
int ret;
@@ -60,7 +60,7 @@ _gnutls_mpi_scan (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
/* returns zero on success. Fails if the number is zero.
*/
int
_gnutls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
mhd_gtls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
{
int ret;
@@ -72,7 +72,7 @@ _gnutls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
*/
if (_gnutls_mpi_get_nbits (*ret_mpi) == 0)
{
_gnutls_mpi_release (ret_mpi);
mhd_gtls_mpi_release (ret_mpi);
return GNUTLS_E_MPI_SCAN_FAILED;
}
@@ -80,7 +80,7 @@ _gnutls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
}
int
_gnutls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
mhd_gtls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
{
int ret;
ret = gcry_mpi_scan (ret_mpi, GCRYMPI_FMT_PGP, buffer, *nbytes, nbytes);
@@ -91,7 +91,7 @@ _gnutls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
*/
if (_gnutls_mpi_get_nbits (*ret_mpi) == 0)
{
_gnutls_mpi_release (ret_mpi);
mhd_gtls_mpi_release (ret_mpi);
return GNUTLS_E_MPI_SCAN_FAILED;
}
@@ -99,7 +99,7 @@ _gnutls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
}
int
_gnutls_mpi_print (void *buffer, size_t * nbytes, const mpi_t a)
mhd_gtls_mpi_print (void *buffer, size_t * nbytes, const mpi_t a)
{
int ret;
@@ -115,7 +115,7 @@ _gnutls_mpi_print (void *buffer, size_t * nbytes, const mpi_t a)
/* Always has the first bit zero */
int
_gnutls_mpi_print_lz (void *buffer, size_t * nbytes, const mpi_t a)
mhd_gtls_mpi_print_lz (void *buffer, size_t * nbytes, const mpi_t a)
{
int ret;
@@ -131,7 +131,7 @@ _gnutls_mpi_print_lz (void *buffer, size_t * nbytes, const mpi_t a)
/* Always has the first bit zero */
int
_gnutls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a)
mhd_gtls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a)
{
int ret;
opaque *buf = NULL;
@@ -160,7 +160,7 @@ _gnutls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a)
}
int
_gnutls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a)
mhd_gtls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a)
{
int ret;
opaque *buf = NULL;
@@ -225,7 +225,7 @@ _gnutls_x509_read_int (ASN1_TYPE node, const char *value, mpi_t * ret_mpi)
}
s_len = tmpstr_size;
if (_gnutls_mpi_scan (ret_mpi, tmpstr, &s_len) != 0)
if (mhd_gtls_mpi_scan (ret_mpi, tmpstr, &s_len) != 0)
{
gnutls_assert ();
gnutls_afree (tmpstr);
@@ -248,9 +248,9 @@ _gnutls_x509_write_int (ASN1_TYPE node, const char *value, mpi_t mpi, int lz)
s_len = 0;
if (lz)
result = _gnutls_mpi_print_lz (NULL, &s_len, mpi);
result = mhd_gtls_mpi_print_lz (NULL, &s_len, mpi);
else
result = _gnutls_mpi_print (NULL, &s_len, mpi);
result = mhd_gtls_mpi_print (NULL, &s_len, mpi);
tmpstr = gnutls_alloca (s_len);
if (tmpstr == NULL)
@@ -260,9 +260,9 @@ _gnutls_x509_write_int (ASN1_TYPE node, const char *value, mpi_t mpi, int lz)
}
if (lz)
result = _gnutls_mpi_print_lz (tmpstr, &s_len, mpi);
result = mhd_gtls_mpi_print_lz (tmpstr, &s_len, mpi);
else
result = _gnutls_mpi_print (tmpstr, &s_len, mpi);
result = mhd_gtls_mpi_print (tmpstr, &s_len, mpi);
if (result != 0)
{
+8 -8
View File
@@ -60,19 +60,19 @@ typedef gcry_mpi_t mpi_t;
#define _gnutls_mpi_alloc_like(x) _gnutls_mpi_new(_gnutls_mpi_get_nbits(x))
#define _gnutls_mpi_salloc_like(x) _gnutls_mpi_snew(_gnutls_mpi_get_nbits(x))
void _gnutls_mpi_release (mpi_t * x);
void mhd_gtls_mpi_release (mpi_t * x);
int _gnutls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer,
int mhd_gtls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer,
size_t * nbytes);
int _gnutls_mpi_scan (mpi_t * ret_mpi, const opaque * buffer,
int mhd_gtls_mpi_scan (mpi_t * ret_mpi, const opaque * buffer,
size_t * nbytes);
int _gnutls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer,
int mhd_gtls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer,
size_t * nbytes);
int _gnutls_mpi_print (void *buffer, size_t * nbytes, const mpi_t a);
int _gnutls_mpi_print_lz (void *buffer, size_t * nbytes, const mpi_t a);
int mhd_gtls_mpi_print (void *buffer, size_t * nbytes, const mpi_t a);
int mhd_gtls_mpi_print_lz (void *buffer, size_t * nbytes, const mpi_t a);
int _gnutls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a);
int _gnutls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a);
int mhd_gtls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a);
int mhd_gtls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a);
#endif
+14 -14
View File
@@ -35,7 +35,7 @@
* has been reached.
*/
int
_gnutls_uint64pp (uint64 * x)
mhd_gtls_uint64pp (uint64 * x)
{
register int i, y = 0;
@@ -60,7 +60,7 @@ _gnutls_uint64pp (uint64 * x)
}
uint32_t
_gnutls_uint24touint32 (uint24 num)
mhd_gtls_uint24touint32 (uint24 num)
{
uint32_t ret = 0;
@@ -71,7 +71,7 @@ _gnutls_uint24touint32 (uint24 num)
}
uint24
_gnutls_uint32touint24 (uint32_t num)
mhd_gtls_uint32touint24 (uint32_t num)
{
uint24 ret;
@@ -84,7 +84,7 @@ _gnutls_uint32touint24 (uint32_t num)
/* data should be at least 3 bytes */
uint32_t
_gnutls_read_uint24 (const opaque * data)
mhd_gtls_read_uint24 (const opaque * data)
{
uint32_t res;
uint24 num;
@@ -93,7 +93,7 @@ _gnutls_read_uint24 (const opaque * data)
num.pint[1] = data[1];
num.pint[2] = data[2];
res = _gnutls_uint24touint32 (num);
res = mhd_gtls_uint24touint32 (num);
#ifndef WORDS_BIGENDIAN
res = byteswap32 (res);
#endif
@@ -101,14 +101,14 @@ _gnutls_read_uint24 (const opaque * data)
}
void
_gnutls_write_uint24 (uint32_t num, opaque * data)
mhd_gtls_write_uint24 (uint32_t num, opaque * data)
{
uint24 tmp;
#ifndef WORDS_BIGENDIAN
num = byteswap32 (num);
#endif
tmp = _gnutls_uint32touint24 (num);
tmp = mhd_gtls_uint32touint24 (num);
data[0] = tmp.pint[0];
data[1] = tmp.pint[1];
@@ -116,7 +116,7 @@ _gnutls_write_uint24 (uint32_t num, opaque * data)
}
uint32_t
_gnutls_read_uint32 (const opaque * data)
mhd_gtls_read_uint32 (const opaque * data)
{
uint32_t res;
@@ -128,7 +128,7 @@ _gnutls_read_uint32 (const opaque * data)
}
void
_gnutls_write_uint32 (uint32_t num, opaque * data)
mhd_gtls_write_uint32 (uint32_t num, opaque * data)
{
#ifndef WORDS_BIGENDIAN
@@ -138,7 +138,7 @@ _gnutls_write_uint32 (uint32_t num, opaque * data)
}
uint16_t
_gnutls_read_uint16 (const opaque * data)
mhd_gtls_read_uint16 (const opaque * data)
{
uint16_t res;
memcpy (&res, data, sizeof (uint16_t));
@@ -149,7 +149,7 @@ _gnutls_read_uint16 (const opaque * data)
}
void
_gnutls_write_uint16 (uint16_t num, opaque * data)
mhd_gtls_write_uint16 (uint16_t num, opaque * data)
{
#ifndef WORDS_BIGENDIAN
@@ -159,7 +159,7 @@ _gnutls_write_uint16 (uint16_t num, opaque * data)
}
uint32_t
_gnutls_conv_uint32 (uint32_t data)
mhd_gtls_conv_uint32 (uint32_t data)
{
#ifndef WORDS_BIGENDIAN
return byteswap32 (data);
@@ -169,7 +169,7 @@ _gnutls_conv_uint32 (uint32_t data)
}
uint16_t
_gnutls_conv_uint16 (uint16_t data)
mhd_gtls_conv_uint16 (uint16_t data)
{
#ifndef WORDS_BIGENDIAN
return byteswap16 (data);
@@ -179,7 +179,7 @@ _gnutls_conv_uint16 (uint16_t data)
}
uint32_t
_gnutls_uint64touint32 (const uint64 * num)
mhd_gtls_uint64touint32 (const uint64 * num)
{
uint32_t ret;
+12 -12
View File
@@ -32,18 +32,18 @@
#define byteswap16(x) ((rotl16(x, 8) & 0x00ff) | (rotr16(x, 8) & 0xff00))
#define byteswap32(x) ((rotl32(x, 8) & 0x00ff00ffUL) | (rotr32(x, 8) & 0xff00ff00UL))
uint32_t _gnutls_uint24touint32 (uint24 num);
uint24 _gnutls_uint32touint24 (uint32_t num);
uint32_t _gnutls_read_uint32 (const opaque * data);
uint16_t _gnutls_read_uint16 (const opaque * data);
uint32_t _gnutls_conv_uint32 (uint32_t data);
uint16_t _gnutls_conv_uint16 (uint16_t data);
uint32_t _gnutls_read_uint24 (const opaque * data);
void _gnutls_write_uint24 (uint32_t num, opaque * data);
void _gnutls_write_uint32 (uint32_t num, opaque * data);
void _gnutls_write_uint16 (uint16_t num, opaque * data);
uint32_t _gnutls_uint64touint32 (const uint64 *);
uint32_t mhd_gtls_uint24touint32 (uint24 num);
uint24 mhd_gtls_uint32touint24 (uint32_t num);
uint32_t mhd_gtls_read_uint32 (const opaque * data);
uint16_t mhd_gtls_read_uint16 (const opaque * data);
uint32_t mhd_gtls_conv_uint32 (uint32_t data);
uint16_t mhd_gtls_conv_uint16 (uint16_t data);
uint32_t mhd_gtls_read_uint24 (const opaque * data);
void mhd_gtls_write_uint24 (uint32_t num, opaque * data);
void mhd_gtls_write_uint32 (uint32_t num, opaque * data);
void mhd_gtls_write_uint16 (uint16_t num, opaque * data);
uint32_t mhd_gtls_uint64touint32 (const uint64 *);
int _gnutls_uint64pp (uint64 *);
int mhd_gtls_uint64pp (uint64 *);
# define _gnutls_uint64zero(x) x.i[0] = x.i[1] = x.i[2] = x.i[3] = x.i[4] = x.i[5] = x.i[6] = x.i[7] = 0
# define UINT64DATA(x) x.i
+30 -30
View File
@@ -54,7 +54,7 @@ static int _gnutls_pk_decrypt (int algo, mpi_t * resarr, mpi_t data,
* params is modulus, public exp.
*/
int
_gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
mhd_gtls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
const gnutls_datum_t * plaintext,
mpi_t * params, unsigned params_len,
unsigned btype)
@@ -143,7 +143,7 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
ps[psize] = 0;
memcpy (&ps[psize + 1], plaintext->data, plaintext->size);
if (_gnutls_mpi_scan_nz (&m, edata, &k) != 0)
if (mhd_gtls_mpi_scan_nz (&m, edata, &k) != 0)
{
gnutls_assert ();
gnutls_afree (edata);
@@ -156,7 +156,7 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
else /* sign */
ret = _gnutls_pk_sign (GCRY_PK_RSA, &res, m, params, params_len);
_gnutls_mpi_release (&m);
mhd_gtls_mpi_release (&m);
if (ret < 0)
{
@@ -164,7 +164,7 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
return ret;
}
_gnutls_mpi_print (NULL, &psize, res);
mhd_gtls_mpi_print (NULL, &psize, res);
if (psize < k)
{
@@ -180,7 +180,7 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
{ /* psize > k !!! */
/* This is an impossible situation */
gnutls_assert ();
_gnutls_mpi_release (&res);
mhd_gtls_mpi_release (&res);
return GNUTLS_E_INTERNAL_ERROR;
}
@@ -188,16 +188,16 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
if (ciphertext->data == NULL)
{
gnutls_assert ();
_gnutls_mpi_release (&res);
mhd_gtls_mpi_release (&res);
return GNUTLS_E_MEMORY_ERROR;
}
_gnutls_mpi_print (&ciphertext->data[pad], &psize, res);
mhd_gtls_mpi_print (&ciphertext->data[pad], &psize, res);
for (i = 0; i < pad; i++)
ciphertext->data[i] = 0;
ciphertext->size = k;
_gnutls_mpi_release (&res);
mhd_gtls_mpi_release (&res);
return 0;
}
@@ -208,7 +208,7 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
* Can decrypt block type 1 and type 2 packets.
*/
int
_gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
mhd_gtls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
const gnutls_datum_t * ciphertext,
mpi_t * params, unsigned params_len,
unsigned btype)
@@ -232,7 +232,7 @@ _gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
return GNUTLS_E_PK_DECRYPTION_FAILED;
}
if (_gnutls_mpi_scan_nz (&c, ciphertext->data, &esize) != 0)
if (mhd_gtls_mpi_scan_nz (&c, ciphertext->data, &esize) != 0)
{
gnutls_assert ();
return GNUTLS_E_MPI_SCAN_FAILED;
@@ -247,7 +247,7 @@ _gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
{
ret = _gnutls_pk_encrypt (GCRY_PK_RSA, &res, c, params, params_len);
}
_gnutls_mpi_release (&c);
mhd_gtls_mpi_release (&c);
if (ret < 0)
{
@@ -255,17 +255,17 @@ _gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
return ret;
}
_gnutls_mpi_print (NULL, &esize, res);
mhd_gtls_mpi_print (NULL, &esize, res);
edata = gnutls_alloca (esize + 1);
if (edata == NULL)
{
gnutls_assert ();
_gnutls_mpi_release (&res);
mhd_gtls_mpi_release (&res);
return GNUTLS_E_MEMORY_ERROR;
}
_gnutls_mpi_print (&edata[1], &esize, res);
mhd_gtls_mpi_print (&edata[1], &esize, res);
_gnutls_mpi_release (&res);
mhd_gtls_mpi_release (&res);
/* EB = 00||BT||PS||00||D
* (use block type 'btype')
@@ -345,7 +345,7 @@ _gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
int
_gnutls_rsa_verify (const gnutls_datum_t * vdata,
mhd_gtls_rsa_verify (const gnutls_datum_t * vdata,
const gnutls_datum_t * ciphertext, mpi_t * params,
int params_len, int btype)
{
@@ -355,7 +355,7 @@ _gnutls_rsa_verify (const gnutls_datum_t * vdata,
/* decrypt signature */
if ((ret =
_gnutls_pkcs1_rsa_decrypt (&plain, ciphertext, params, params_len,
mhd_gtls_pkcs1_rsa_decrypt (&plain, ciphertext, params, params_len,
btype)) < 0)
{
gnutls_assert ();
@@ -433,7 +433,7 @@ encode_ber_rs (gnutls_datum_t * sig_value, mpi_t r, mpi_t s)
/* Do DSA signature calculation. params is p, q, g, y, x in that order.
*/
int
_gnutls_dsa_sign (gnutls_datum_t * signature,
mhd_gtls_dsa_sign (gnutls_datum_t * signature,
const gnutls_datum_t * hash, mpi_t * params,
unsigned params_len)
{
@@ -448,7 +448,7 @@ _gnutls_dsa_sign (gnutls_datum_t * signature,
return GNUTLS_E_PK_SIGN_FAILED;
}
if (_gnutls_mpi_scan_nz (&mdata, hash->data, &k) != 0)
if (mhd_gtls_mpi_scan_nz (&mdata, hash->data, &k) != 0)
{
gnutls_assert ();
return GNUTLS_E_MPI_SCAN_FAILED;
@@ -456,7 +456,7 @@ _gnutls_dsa_sign (gnutls_datum_t * signature,
ret = _gnutls_pk_sign (GCRY_PK_DSA, rs, mdata, params, params_len);
/* rs[0], rs[1] now hold r,s */
_gnutls_mpi_release (&mdata);
mhd_gtls_mpi_release (&mdata);
if (ret < 0)
{
@@ -467,8 +467,8 @@ _gnutls_dsa_sign (gnutls_datum_t * signature,
ret = encode_ber_rs (signature, rs[0], rs[1]);
/* free r,s */
_gnutls_mpi_release (&rs[0]);
_gnutls_mpi_release (&rs[1]);
mhd_gtls_mpi_release (&rs[0]);
mhd_gtls_mpi_release (&rs[1]);
if (ret != 0)
{
@@ -516,7 +516,7 @@ decode_ber_rs (const gnutls_datum_t * sig_value, mpi_t * r, mpi_t * s)
if (result < 0)
{
gnutls_assert ();
_gnutls_mpi_release (s);
mhd_gtls_mpi_release (s);
asn1_delete_structure (&sig);
return result;
}
@@ -529,7 +529,7 @@ decode_ber_rs (const gnutls_datum_t * sig_value, mpi_t * r, mpi_t * s)
/* params is p, q, g, y in that order
*/
int
_gnutls_dsa_verify (const gnutls_datum_t * vdata,
mhd_gtls_dsa_verify (const gnutls_datum_t * vdata,
const gnutls_datum_t * sig_value, mpi_t * params,
int params_len)
{
@@ -552,19 +552,19 @@ _gnutls_dsa_verify (const gnutls_datum_t * vdata,
}
k = vdata->size;
if (_gnutls_mpi_scan_nz (&mdata, vdata->data, &k) != 0)
if (mhd_gtls_mpi_scan_nz (&mdata, vdata->data, &k) != 0)
{
gnutls_assert ();
_gnutls_mpi_release (&rs[0]);
_gnutls_mpi_release (&rs[1]);
mhd_gtls_mpi_release (&rs[0]);
mhd_gtls_mpi_release (&rs[1]);
return GNUTLS_E_MPI_SCAN_FAILED;
}
/* decrypt signature */
ret = _gnutls_pk_verify (GCRY_PK_DSA, mdata, rs, params, params_len);
_gnutls_mpi_release (&mdata);
_gnutls_mpi_release (&rs[0]);
_gnutls_mpi_release (&rs[1]);
mhd_gtls_mpi_release (&mdata);
mhd_gtls_mpi_release (&rs[0]);
mhd_gtls_mpi_release (&rs[1]);
if (ret < 0)
{
+5 -5
View File
@@ -25,21 +25,21 @@
#ifndef GNUTLS_PK_H
#define GNUTLS_PK_H
int _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
int mhd_gtls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
const gnutls_datum_t * plaintext,
mpi_t * params, unsigned params_len,
unsigned btype);
int _gnutls_dsa_sign (gnutls_datum_t * signature,
int mhd_gtls_dsa_sign (gnutls_datum_t * signature,
const gnutls_datum_t * plaintext, mpi_t * params,
unsigned params_len);
int _gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
int mhd_gtls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
const gnutls_datum_t * ciphertext,
mpi_t * params, unsigned params_len,
unsigned btype);
int _gnutls_rsa_verify (const gnutls_datum_t * vdata,
int mhd_gtls_rsa_verify (const gnutls_datum_t * vdata,
const gnutls_datum_t * ciphertext, mpi_t * params,
int params_len, int btype);
int _gnutls_dsa_verify (const gnutls_datum_t * vdata,
int mhd_gtls_dsa_verify (const gnutls_datum_t * vdata,
const gnutls_datum_t * sig_value, mpi_t * params,
int params_len);
+37 -87
View File
@@ -33,8 +33,8 @@
#define MAX_ELEMENTS 48
/**
* gnutls_cipher_set_priority - Sets the priority on the ciphers supported by gnutls.
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_cipher_set_priority - Sets the priority on the ciphers supported by gnutls.
* @session: is a #mhd_gtls_session_t structure.
* @list: is a 0 terminated list of gnutls_cipher_algorithm_t elements.
*
* Sets the priority on the ciphers supported by gnutls.
@@ -48,7 +48,7 @@
*
**/
int
gnutls_cipher_set_priority (gnutls_session_t session, const int *list)
MHD_gnutls_cipher_set_priority (mhd_gtls_session_t session, const int *list)
{
int num = 0, i;
@@ -67,7 +67,7 @@ gnutls_cipher_set_priority (gnutls_session_t session, const int *list)
}
inline static int
_set_priority (priority_st * st, const int *list)
_set_priority (mhd_gtls_priority_st * st, const int *list)
{
int num = 0, i;
@@ -86,8 +86,8 @@ _set_priority (priority_st * st, const int *list)
}
/**
* gnutls_kx_set_priority - Sets the priority on the key exchange algorithms supported by gnutls.
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_kx_set_priority - Sets the priority on the key exchange algorithms supported by gnutls.
* @session: is a #mhd_gtls_session_t structure.
* @list: is a 0 terminated list of gnutls_kx_algorithm_t elements.
*
* Sets the priority on the key exchange algorithms supported by gnutls.
@@ -101,14 +101,14 @@ _set_priority (priority_st * st, const int *list)
*
**/
int
gnutls_kx_set_priority (gnutls_session_t session, const int *list)
MHD_gnutls_kx_set_priority (mhd_gtls_session_t session, const int *list)
{
return _set_priority (&session->internals.priorities.kx, list);
}
/**
* gnutls_mac_set_priority - Sets the priority on the mac algorithms supported by gnutls.
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_mac_set_priority - Sets the priority on the mac algorithms supported by gnutls.
* @session: is a #mhd_gtls_session_t structure.
* @list: is a 0 terminated list of gnutls_mac_algorithm_t elements.
*
* Sets the priority on the mac algorithms supported by gnutls.
@@ -122,14 +122,14 @@ gnutls_kx_set_priority (gnutls_session_t session, const int *list)
*
**/
int
gnutls_mac_set_priority (gnutls_session_t session, const int *list)
MHD_gnutls_mac_set_priority (mhd_gtls_session_t session, const int *list)
{
return _set_priority (&session->internals.priorities.mac, list);
}
/**
* gnutls_compression_set_priority - Sets the priority on the compression algorithms supported by gnutls.
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_compression_set_priority - Sets the priority on the compression algorithms supported by gnutls.
* @session: is a #mhd_gtls_session_t structure.
* @list: is a 0 terminated list of gnutls_compression_method_t elements.
*
* Sets the priority on the compression algorithms supported by gnutls.
@@ -147,14 +147,14 @@ gnutls_mac_set_priority (gnutls_session_t session, const int *list)
*
**/
int
gnutls_compression_set_priority (gnutls_session_t session, const int *list)
MHD_gnutls_compression_set_priority (mhd_gtls_session_t session, const int *list)
{
return _set_priority (&session->internals.priorities.compression, list);
}
/**
* gnutls_protocol_set_priority - Sets the priority on the protocol versions supported by gnutls.
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_protocol_set_priority - Sets the priority on the protocol versions supported by gnutls.
* @session: is a #mhd_gtls_session_t structure.
* @list: is a 0 terminated list of gnutls_protocol_t elements.
*
* Sets the priority on the protocol versions supported by gnutls.
@@ -165,7 +165,7 @@ gnutls_compression_set_priority (gnutls_session_t session, const int *list)
*
**/
int
gnutls_protocol_set_priority (gnutls_session_t session, const int *list)
MHD_gnutls_protocol_set_priority (mhd_gtls_session_t session, const int *list)
{
int ret;
@@ -175,14 +175,14 @@ gnutls_protocol_set_priority (gnutls_session_t session, const int *list)
* This will be overridden later.
*/
if (list)
_gnutls_set_current_version (session, list[0]);
mhd_gtls_set_current_version (session, list[0]);
return ret;
}
/**
* gnutls_certificate_type_set_priority - Sets the priority on the certificate types supported by gnutls.
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_certificate_type_set_priority - Sets the priority on the certificate types supported by gnutls.
* @session: is a #mhd_gtls_session_t structure.
* @list: is a 0 terminated list of gnutls_certificate_type_t elements.
*
* Sets the priority on the certificate types supported by gnutls.
@@ -196,7 +196,7 @@ gnutls_protocol_set_priority (gnutls_session_t session, const int *list)
*
**/
int
gnutls_certificate_type_set_priority (gnutls_session_t session,
MHD_gnutls_certificate_type_set_priority (mhd_gtls_session_t session,
const int *list)
{
#if ENABLE_OPENPGP
@@ -235,11 +235,11 @@ static const int comp_priority[] = { MHD_GNUTLS_COMP_NULL,
0
};
typedef void (rmadd_func) (priority_st * priority_list, int alg);
typedef void (rmadd_func) (mhd_gtls_priority_st * priority_list, int alg);
/**
* gnutls_priority_set - Sets priorities for the cipher suites supported by gnutls.
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_priority_set - Sets priorities for the cipher suites supported by gnutls.
* @session: is a #mhd_gtls_session_t structure.
* @priority: is a #gnutls_priority_t structure.
*
* Sets the priorities to use on the ciphers, key exchange methods,
@@ -249,7 +249,7 @@ typedef void (rmadd_func) (priority_st * priority_list, int alg);
*
**/
int
gnutls_priority_set (gnutls_session_t session, gnutls_priority_t priority)
MHD_gnutls_priority_set (mhd_gtls_session_t session, gnutls_priority_t priority)
{
if (priority == NULL)
{
@@ -258,13 +258,13 @@ gnutls_priority_set (gnutls_session_t session, gnutls_priority_t priority)
}
memcpy (&session->internals.priorities, priority,
sizeof (struct gnutls_priority_st));
sizeof (struct MHD_gtls_priority_st));
return 0;
}
/**
* gnutls_priority_init - Sets priorities for the cipher suites supported by gnutls.
* MHD_tls_set_default_priority - Sets priorities for the cipher suites supported by gnutls.
* @priority_cache: is a #gnutls_prioritity_t structure.
* @priorities: is a string describing priorities
* @err_pos: In case of an error this will have the position in the string the error occured
@@ -329,10 +329,10 @@ gnutls_priority_set (gnutls_session_t session, gnutls_priority_t priority)
* 0 on success.
**/
int
gnutls_priority_init (gnutls_priority_t * priority_cache,
MHD_tls_set_default_priority (gnutls_priority_t * priority_cache,
const char *priorities, const char **err_pos)
{
*priority_cache = gnutls_calloc (1, sizeof (struct gnutls_priority_st));
*priority_cache = gnutls_calloc (1, sizeof (struct MHD_gtls_priority_st));
if (*priority_cache == NULL)
{
gnutls_assert ();
@@ -352,104 +352,54 @@ gnutls_priority_init (gnutls_priority_t * priority_cache,
}
/**
* gnutls_priority_deinit - Deinitialize the priorities cache for the cipher suites supported by gnutls.
* MHD_gnutls_priority_deinit - Deinitialize the priorities cache for the cipher suites supported by gnutls.
* @priority_cache: is a #gnutls_prioritity_t structure.
*
* Deinitializes the priority cache.
*
**/
void
gnutls_priority_deinit (gnutls_priority_t priority_cache)
MHD_gnutls_priority_deinit (gnutls_priority_t priority_cache)
{
gnutls_free (priority_cache);
}
/**
* gnutls_priority_set_direct - Sets priorities for the cipher suites supported by gnutls.
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_priority_set_direct - Sets priorities for the cipher suites supported by gnutls.
* @session: is a #mhd_gtls_session_t structure.
* @priorities: is a string describing priorities
* @err_pos: In case of an error this will have the position in the string the error occured
*
* Sets the priorities to use on the ciphers, key exchange methods,
* macs and compression methods. This function avoids keeping a
* priority cache and is used to directly set string priorities to a
* TLS session. For documentation check the gnutls_priority_init().
* TLS session. For documentation check the MHD_tls_set_default_priority().
*
* On syntax error GNUTLS_E_INVALID_REQUEST is returned and 0 on success.
*
**/
int
gnutls_priority_set_direct (gnutls_session_t session,
MHD_gnutls_priority_set_direct (mhd_gtls_session_t session,
const char *priorities, const char **err_pos)
{
gnutls_priority_t prio;
int ret;
ret = gnutls_priority_init (&prio, priorities, err_pos);
ret = MHD_tls_set_default_priority (&prio, priorities, err_pos);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
ret = gnutls_priority_set (session, prio);
ret = MHD_gnutls_priority_set (session, prio);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
gnutls_priority_deinit (prio);
MHD_gnutls_priority_deinit (prio);
return 0;
}
/**
* gnutls_set_default_priority - Sets some default priority on the cipher suites supported by gnutls.
* @session: is a #gnutls_session_t structure.
*
* Sets some default priority on the ciphers, key exchange methods,
* macs and compression methods.
*
* This is the same as calling:
*
* gnutls_priority_set_direct (session, "NORMAL", NULL);
*
* This function is kept around for backwards compatibility, but
* because of its wide use it is still fully supported. If you wish
* to allow users to provide a string that specify which ciphers to
* use (which is recommended), you should use
* gnutls_priority_set_direct() or gnutls_priority_set() instead.
*
* Returns 0 on success.
**/
int
gnutls_set_default_priority (gnutls_session_t session)
{
return gnutls_priority_set_direct (session, "NORMAL", NULL);
}
/**
* gnutls_set_default_export_priority - Sets some default priority on the cipher suites supported by gnutls.
* @session: is a #gnutls_session_t structure.
*
* Sets some default priority on the ciphers, key exchange methods, macs
* and compression methods. This function also includes weak algorithms.
*
* This is the same as calling:
*
* gnutls_priority_set_direct (session, "EXPORT", NULL);
*
* This function is kept around for backwards compatibility, but
* because of its wide use it is still fully supported. If you wish
* to allow users to provide a string that specify which ciphers to
* use (which is recommended), you should use
* gnutls_priority_set_direct() or gnutls_priority_set() instead.
*
* Returns 0 on success.
**/
int
gnutls_set_default_export_priority (gnutls_session_t session)
{
return gnutls_priority_set_direct (session, "EXPORT", NULL);
}
+94 -130
View File
@@ -44,27 +44,27 @@
#include <gnutls_dh.h>
/**
* gnutls_protocol_get_version - Returns the version of the currently used protocol
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_protocol_get_version - Returns the version of the currently used protocol
* @session: is a #mhd_gtls_session_t structure.
*
* Returns: the version of the currently used protocol.
**/
gnutls_protocol_t
gnutls_protocol_get_version (gnutls_session_t session)
MHD_gnutls_protocol_get_version (mhd_gtls_session_t session)
{
return session->security_parameters.version;
}
void
_gnutls_set_current_version (gnutls_session_t session,
mhd_gtls_set_current_version (mhd_gtls_session_t session,
gnutls_protocol_t version)
{
session->security_parameters.version = version;
}
/**
* gnutls_transport_set_lowat - Used to set the lowat value in order for select to check for pending data.
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_transport_set_lowat - Used to set the lowat value in order for select to check for pending data.
* @session: is a #mhd_gtls_session_t structure.
* @num: is the low water value.
*
* Used to set the lowat value in order for select to check if there
@@ -75,14 +75,14 @@ _gnutls_set_current_version (gnutls_session_t session,
* to zero.
**/
void
gnutls_transport_set_lowat (gnutls_session_t session, int num)
MHD_gnutls_transport_set_lowat (mhd_gtls_session_t session, int num)
{
session->internals.lowat = num;
}
/**
* gnutls_record_disable_padding - Used to disabled padding in TLS 1.0 and above
* @session: is a #gnutls_session_t structure.
* MHD_gtls_record_disable_padding - Used to disabled padding in TLS 1.0 and above
* @session: is a #mhd_gtls_session_t structure.
*
* Used to disabled padding in TLS 1.0 and above. Normally you do
* not need to use this function, but there are buggy clients that
@@ -93,14 +93,14 @@ gnutls_transport_set_lowat (gnutls_session_t session, int num)
* out there, need to call this function.
**/
void
gnutls_record_disable_padding (gnutls_session_t session)
MHD_gtls_record_disable_padding (mhd_gtls_session_t session)
{
session->internals.priorities.no_padding = 1;
}
/**
* gnutls_transport_set_ptr - Used to set first argument of the transport functions
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_transport_set_ptr - Used to set first argument of the transport functions
* @session: is a #mhd_gtls_session_t structure.
* @ptr: is the value.
*
* Used to set the first argument of the transport function (like
@@ -108,7 +108,7 @@ gnutls_record_disable_padding (gnutls_session_t session)
* the connection handle.
**/
void
gnutls_transport_set_ptr (gnutls_session_t session,
MHD_gnutls_transport_set_ptr (mhd_gtls_session_t session,
gnutls_transport_ptr_t ptr)
{
session->internals.transport_recv_ptr = ptr;
@@ -116,8 +116,8 @@ gnutls_transport_set_ptr (gnutls_session_t session,
}
/**
* gnutls_transport_set_ptr2 - Used to set first argument of the transport functions
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_transport_set_ptr2 - Used to set first argument of the transport functions
* @session: is a #mhd_gtls_session_t structure.
* @recv_ptr: is the value for the pull function
* @send_ptr: is the value for the push function
*
@@ -127,7 +127,7 @@ gnutls_transport_set_ptr (gnutls_session_t session,
* different pointers for receiving and sending.
**/
void
gnutls_transport_set_ptr2 (gnutls_session_t session,
MHD_gnutls_transport_set_ptr2 (mhd_gtls_session_t session,
gnutls_transport_ptr_t recv_ptr,
gnutls_transport_ptr_t send_ptr)
{
@@ -136,48 +136,12 @@ gnutls_transport_set_ptr2 (gnutls_session_t session,
}
/**
* gnutls_transport_get_ptr - Used to return the first argument of the transport functions
* @session: is a #gnutls_session_t structure.
*
* Used to get the first argument of the transport function (like
* PUSH and PULL). This must have been set using
* gnutls_transport_set_ptr().
*
* Returns: first argument of the transport function.
**/
gnutls_transport_ptr_t
gnutls_transport_get_ptr (gnutls_session_t session)
{
return session->internals.transport_recv_ptr;
}
/**
* gnutls_transport_get_ptr2 - Used to return the first argument of the transport functions
* @session: is a #gnutls_session_t structure.
* @recv_ptr: will hold the value for the pull function
* @send_ptr: will hold the value for the push function
*
* Used to get the arguments of the transport functions (like PUSH
* and PULL). These should have been set using
* gnutls_transport_set_ptr2().
**/
void
gnutls_transport_get_ptr2 (gnutls_session_t session,
gnutls_transport_ptr_t * recv_ptr,
gnutls_transport_ptr_t * send_ptr)
{
*recv_ptr = session->internals.transport_recv_ptr;
*send_ptr = session->internals.transport_send_ptr;
}
/**
* gnutls_bye - This function terminates the current TLS/SSL connection.
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_bye - This function terminates the current TLS/SSL connection.
* @session: is a #mhd_gtls_session_t structure.
* @how: is an integer
*
* Terminates the current TLS/SSL connection. The connection should
* have been initiated using gnutls_handshake(). @how should be one
* have been initiated using MHD_gnutls_handshake(). @how should be one
* of %GNUTLS_SHUT_RDWR, %GNUTLS_SHUT_WR.
*
* In case of %GNUTLS_SHUT_RDWR then the TLS connection gets
@@ -199,13 +163,13 @@ gnutls_transport_get_ptr2 (gnutls_session_t session,
* session, thus this behavior is not recommended.
*
* This function may also return %GNUTLS_E_AGAIN or
* %GNUTLS_E_INTERRUPTED; cf. gnutls_record_get_direction().
* %GNUTLS_E_INTERRUPTED; cf. MHD_gnutls_record_get_direction().
*
* Returns: %GNUTLS_E_SUCCESS on success, or an error code, see
* function documentation for entire semantics.
**/
int
gnutls_bye (gnutls_session_t session, gnutls_close_request_t how)
MHD_gnutls_bye (mhd_gtls_session_t session, gnutls_close_request_t how)
{
int ret = 0;
@@ -213,7 +177,7 @@ gnutls_bye (gnutls_session_t session, gnutls_close_request_t how)
{
case STATE0:
case STATE60:
ret = _gnutls_io_write_flush (session);
ret = mhd_gtls_io_write_flush (session);
STATE = STATE60;
if (ret < 0)
{
@@ -223,7 +187,7 @@ gnutls_bye (gnutls_session_t session, gnutls_close_request_t how)
case STATE61:
ret =
gnutls_alert_send (session, GNUTLS_AL_WARNING, GNUTLS_A_CLOSE_NOTIFY);
MHD_gnutls_alert_send (session, GNUTLS_AL_WARNING, GNUTLS_A_CLOSE_NOTIFY);
STATE = STATE61;
if (ret < 0)
{
@@ -237,8 +201,8 @@ gnutls_bye (gnutls_session_t session, gnutls_close_request_t how)
{
do
{
_gnutls_io_clear_peeked_data (session);
ret = _gnutls_recv_int (session, GNUTLS_ALERT, -1, NULL, 0);
mhd_gtls_io_clear_peeked_data (session);
ret = mhd_gtls_recv_int (session, GNUTLS_ALERT, -1, NULL, 0);
}
while (ret == GNUTLS_E_GOT_APPLICATION_DATA);
@@ -266,13 +230,13 @@ gnutls_bye (gnutls_session_t session, gnutls_close_request_t how)
}
inline static void
session_invalidate (gnutls_session_t session)
session_invalidate (mhd_gtls_session_t session)
{
session->internals.valid_connection = VALID_FALSE;
}
inline static void
session_unresumable (gnutls_session_t session)
session_unresumable (mhd_gtls_session_t session)
{
session->internals.resumable = RESUME_FALSE;
}
@@ -280,7 +244,7 @@ session_unresumable (gnutls_session_t session)
/* returns 0 if session is valid
*/
inline static int
session_is_valid (gnutls_session_t session)
session_is_valid (mhd_gtls_session_t session)
{
if (session->internals.valid_connection == VALID_FALSE)
return GNUTLS_E_INVALID_SESSION;
@@ -292,7 +256,7 @@ session_is_valid (gnutls_session_t session)
* version must have 2 bytes at least.
*/
inline static void
copy_record_version (gnutls_session_t session,
copy_record_version (mhd_gtls_session_t session,
gnutls_handshake_description_t htype, opaque version[2])
{
gnutls_protocol_t lver;
@@ -300,10 +264,10 @@ copy_record_version (gnutls_session_t session,
if (htype != GNUTLS_HANDSHAKE_CLIENT_HELLO
|| session->internals.default_record_version[0] == 0)
{
lver = gnutls_protocol_get_version (session);
lver = MHD_gnutls_protocol_get_version (session);
version[0] = _gnutls_version_get_major (lver);
version[1] = _gnutls_version_get_minor (lver);
version[0] = mhd_gtls_version_get_major (lver);
version[1] = mhd_gtls_version_get_minor (lver);
}
else
{
@@ -313,7 +277,7 @@ copy_record_version (gnutls_session_t session,
}
/* This function behaves exactly like write(). The only difference is
* that it accepts, the gnutls_session_t and the content_type_t of data to
* that it accepts, the mhd_gtls_session_t and the content_type_t of data to
* send (if called by the user the Content is specific)
* It is intended to transfer data, under the current session.
*
@@ -327,7 +291,7 @@ copy_record_version (gnutls_session_t session,
*
*/
ssize_t
_gnutls_send_int (gnutls_session_t session,
mhd_gtls_send_int (mhd_gtls_session_t session,
content_type_t type,
gnutls_handshake_description_t htype,
const void *_data, size_t sizeofdata)
@@ -366,7 +330,7 @@ _gnutls_send_int (gnutls_session_t session,
_gnutls_record_log
("REC[%x]: Sending Packet[%d] %s(%d) with length: %d\n", session,
(int) _gnutls_uint64touint32 (&session->connection_state.
(int) mhd_gtls_uint64touint32 (&session->connection_state.
write_sequence_number),
_gnutls_packet2str (type), type, sizeofdata);
@@ -380,7 +344,7 @@ _gnutls_send_int (gnutls_session_t session,
*/
if (session->internals.record_send_buffer.length > 0)
{
ret = _gnutls_io_write_flush (session);
ret = mhd_gtls_io_write_flush (session);
if (ret > 0)
cipher_size = ret;
else
@@ -403,7 +367,7 @@ _gnutls_send_int (gnutls_session_t session,
}
cipher_size =
_gnutls_encrypt (session, headers, RECORD_HEADER_SIZE, data,
mhd_gtls_encrypt (session, headers, RECORD_HEADER_SIZE, data,
data2send_size, cipher, cipher_size, type,
(session->internals.priorities.no_padding ==
0) ? 1 : 0);
@@ -421,7 +385,7 @@ _gnutls_send_int (gnutls_session_t session,
/* increase sequence number
*/
if (_gnutls_uint64pp
if (mhd_gtls_uint64pp
(&session->connection_state.write_sequence_number) != 0)
{
session_invalidate (session);
@@ -430,13 +394,13 @@ _gnutls_send_int (gnutls_session_t session,
return GNUTLS_E_RECORD_LIMIT_REACHED;
}
ret = _gnutls_io_write_buffered (session, cipher, cipher_size);
ret = mhd_gtls_io_write_buffered (session, cipher, cipher_size);
gnutls_free (cipher);
}
if (ret != cipher_size)
{
if (ret < 0 && gnutls_error_is_fatal (ret) == 0)
if (ret < 0 && MHD_gtls_error_is_fatal (ret) == 0)
{
/* If we have sent any data then just return
* the error value. Do not invalidate the session.
@@ -460,7 +424,7 @@ _gnutls_send_int (gnutls_session_t session,
_gnutls_record_log ("REC[%x]: Sent Packet[%d] %s(%d) with length: %d\n",
session,
(int) _gnutls_uint64touint32 (&session->
(int) mhd_gtls_uint64touint32 (&session->
connection_state.
write_sequence_number),
_gnutls_packet2str (type), type, cipher_size);
@@ -472,7 +436,7 @@ _gnutls_send_int (gnutls_session_t session,
* completed. This sends a Change Cipher Spec packet to the peer.
*/
ssize_t
_gnutls_send_change_cipher_spec (gnutls_session_t session, int again)
mhd_gtls_send_change_cipher_spec (mhd_gtls_session_t session, int again)
{
static const opaque data[1] = {
GNUTLS_TYPE_CHANGE_CIPHER_SPEC
@@ -481,10 +445,10 @@ _gnutls_send_change_cipher_spec (gnutls_session_t session, int again)
_gnutls_handshake_log ("REC[%x]: Sent ChangeCipherSpec\n", session);
if (again == 0)
return _gnutls_send_int (session, GNUTLS_CHANGE_CIPHER_SPEC, -1, data, 1);
return mhd_gtls_send_int (session, GNUTLS_CHANGE_CIPHER_SPEC, -1, data, 1);
else
{
return _gnutls_io_write_flush (session);
return mhd_gtls_io_write_flush (session);
}
}
@@ -510,16 +474,16 @@ check_recv_type (content_type_t recv_type)
* then it copies the data.
*/
static int
check_buffers (gnutls_session_t session,
check_buffers (mhd_gtls_session_t session,
content_type_t type, opaque * data, int sizeofdata)
{
if ((type == GNUTLS_APPLICATION_DATA || type == GNUTLS_HANDSHAKE || type
== GNUTLS_INNER_APPLICATION) && _gnutls_record_buffer_get_size (type,
== GNUTLS_INNER_APPLICATION) && mhd_gnutls_record_buffer_get_size (type,
session)
> 0)
{
int ret, ret2;
ret = _gnutls_record_buffer_get (type, session, data, sizeofdata);
ret = mhd_gtls_record_buffer_get (type, session, data, sizeofdata);
if (ret < 0)
{
gnutls_assert ();
@@ -527,9 +491,9 @@ check_buffers (gnutls_session_t session,
}
/* if the buffer just got empty */
if (_gnutls_record_buffer_get_size (type, session) == 0)
if (mhd_gnutls_record_buffer_get_size (type, session) == 0)
{
if ((ret2 = _gnutls_io_clear_peeked_data (session)) < 0)
if ((ret2 = mhd_gtls_io_clear_peeked_data (session)) < 0)
{
gnutls_assert ();
return ret2;
@@ -546,7 +510,7 @@ check_buffers (gnutls_session_t session,
* content type.
*/
static int
record_check_headers (gnutls_session_t session,
record_check_headers (mhd_gtls_session_t session,
uint8_t headers[RECORD_HEADER_SIZE],
content_type_t type,
gnutls_handshake_description_t htype,
@@ -594,7 +558,7 @@ record_check_headers (gnutls_session_t session,
/* No DECR_LEN, since headers has enough size.
*/
*length = _gnutls_read_uint16 (&headers[3]);
*length = mhd_gtls_read_uint16 (&headers[3]);
}
return 0;
@@ -604,7 +568,7 @@ record_check_headers (gnutls_session_t session,
* negotiated in the handshake.
*/
inline static int
record_check_version (gnutls_session_t session,
record_check_version (mhd_gtls_session_t session,
gnutls_handshake_description_t htype, opaque version[2])
{
if (htype == GNUTLS_HANDSHAKE_CLIENT_HELLO)
@@ -621,8 +585,8 @@ record_check_version (gnutls_session_t session,
}
}
else if (htype != GNUTLS_HANDSHAKE_SERVER_HELLO
&& gnutls_protocol_get_version (session)
!= _gnutls_version_get (version[0], version[1]))
&& MHD_gnutls_protocol_get_version (session)
!= mhd_gtls_version_get (version[0], version[1]))
{
/* Reject record packets that have a different version than the
* one negotiated. Note that this version is not protected by any
@@ -642,7 +606,7 @@ record_check_version (gnutls_session_t session,
* the one we actually expect.
*/
static int
record_check_type (gnutls_session_t session,
record_check_type (mhd_gtls_session_t session,
content_type_t recv_type,
content_type_t type,
gnutls_handshake_description_t htype,
@@ -655,7 +619,7 @@ record_check_type (gnutls_session_t session,
== GNUTLS_HANDSHAKE
|| type == GNUTLS_INNER_APPLICATION))
{
_gnutls_record_buffer_put (type, session, (void *) data, data_size);
mhd_gnutls_record_buffer_put (type, session, (void *) data, data_size);
}
else
{
@@ -665,7 +629,7 @@ record_check_type (gnutls_session_t session,
_gnutls_record_log
("REC[%x]: Alert[%d|%d] - %s - was received\n", session,
data[0], data[1], gnutls_alert_get_name ((int) data[1]));
data[0], data[1], MHD_gnutls_alert_get_name ((int) data[1]));
session->internals.last_alert = data[1];
session->internals.last_alert_level = data[0];
@@ -710,7 +674,7 @@ record_check_type (gnutls_session_t session,
case GNUTLS_APPLICATION_DATA:
/* even if data is unexpected put it into the buffer */
if ((ret =
_gnutls_record_buffer_put (recv_type, session, (void *) data,
mhd_gnutls_record_buffer_put (recv_type, session, (void *) data,
data_size)) < 0)
{
gnutls_assert ();
@@ -747,13 +711,13 @@ record_check_type (gnutls_session_t session,
*/
/* So we accept it */
return _gnutls_recv_hello_request (session, data, data_size);
return mhd_gtls_recv_hello_request (session, data, data_size);
break;
case GNUTLS_INNER_APPLICATION:
/* even if data is unexpected put it into the buffer */
if ((ret =
_gnutls_record_buffer_put (recv_type, session, (void *) data,
mhd_gnutls_record_buffer_put (recv_type, session, (void *) data,
data_size)) < 0)
{
gnutls_assert ();
@@ -782,7 +746,7 @@ record_check_type (gnutls_session_t session,
* also initialize it.
*/
inline static int
get_temp_recv_buffer (gnutls_session_t session, gnutls_datum_t * tmp)
get_temp_recv_buffer (mhd_gtls_session_t session, gnutls_datum_t * tmp)
{
size_t max_record_size;
@@ -824,14 +788,14 @@ get_temp_recv_buffer (gnutls_session_t session, gnutls_datum_t * tmp)
#define MAX_EMPTY_PACKETS_SEQUENCE 4
/* This function behaves exactly like read(). The only difference is
* that it accepts the gnutls_session_t and the content_type_t of data to
* that it accepts the mhd_gtls_session_t and the content_type_t of data to
* receive (if called by the user the Content is Userdata only)
* It is intended to receive data, under the current session.
*
* The gnutls_handshake_description_t was introduced to support SSL V2.0 client hellos.
*/
ssize_t
_gnutls_recv_int (gnutls_session_t session,
mhd_gtls_recv_int (mhd_gtls_session_t session,
content_type_t type,
gnutls_handshake_description_t htype,
opaque * data, size_t sizeofdata)
@@ -885,10 +849,10 @@ begin:
*/
header_size = RECORD_HEADER_SIZE;
if ((ret = _gnutls_io_read_buffered (session, &headers, header_size, -1))
if ((ret = mhd_gtls_io_read_buffered (session, &headers, header_size, -1))
!= header_size)
{
if (ret < 0 && gnutls_error_is_fatal (ret) == 0)
if (ret < 0 && MHD_gtls_error_is_fatal (ret) == 0)
return ret;
session_invalidate (session);
@@ -930,12 +894,12 @@ begin:
_gnutls_record_log
("REC[%x]: Expected Packet[%d] %s(%d) with length: %d\n", session,
(int) _gnutls_uint64touint32 (&session->connection_state.
(int) mhd_gtls_uint64touint32 (&session->connection_state.
read_sequence_number),
_gnutls_packet2str (type), type, sizeofdata);
_gnutls_record_log
("REC[%x]: Received Packet[%d] %s(%d) with length: %d\n", session,
(int) _gnutls_uint64touint32 (&session->connection_state.
(int) mhd_gtls_uint64touint32 (&session->connection_state.
read_sequence_number),
_gnutls_packet2str (recv_type), recv_type, length);
@@ -953,11 +917,11 @@ begin:
/* check if we have that data into buffer.
*/
if ((ret = _gnutls_io_read_buffered (session, &recv_data,
if ((ret = mhd_gtls_io_read_buffered (session, &recv_data,
header_size + length, recv_type))
!= header_size + length)
{
if (ret < 0 && gnutls_error_is_fatal (ret) == 0)
if (ret < 0 && MHD_gtls_error_is_fatal (ret) == 0)
return ret;
session_unresumable (session);
@@ -969,7 +933,7 @@ begin:
/* ok now we are sure that we can read all the data - so
* move on !
*/
_gnutls_io_clear_read_buffer (session);
mhd_gtls_io_clear_read_buffer (session);
ciphertext = &recv_data[header_size];
ret = get_temp_recv_buffer (session, &tmp);
@@ -980,7 +944,7 @@ begin:
}
/* decrypt the data we got. */
ret = _gnutls_decrypt (session, ciphertext, length, tmp.data, tmp.size,
ret = mhd_gtls_decrypt (session, ciphertext, length, tmp.data, tmp.size,
recv_type);
if (ret < 0)
{
@@ -1012,13 +976,13 @@ begin:
_gnutls_record_log
("REC[%x]: Decrypted Packet[%d] %s(%d) with length: %d\n", session,
(int) _gnutls_uint64touint32 (&session->connection_state.
(int) mhd_gtls_uint64touint32 (&session->connection_state.
read_sequence_number),
_gnutls_packet2str (recv_type), recv_type, decrypted_length);
/* increase sequence number
*/
if (_gnutls_uint64pp (&session->connection_state.read_sequence_number) != 0)
if (mhd_gtls_uint64pp (&session->connection_state.read_sequence_number) != 0)
{
session_invalidate (session);
gnutls_assert ();
@@ -1043,7 +1007,7 @@ begin:
|| type == GNUTLS_INNER_APPLICATION))
{
ret = _gnutls_record_buffer_get (type, session, data, sizeofdata);
ret = mhd_gtls_record_buffer_get (type, session, data, sizeofdata);
if (ret < 0)
{
gnutls_assert ();
@@ -1052,9 +1016,9 @@ begin:
/* if the buffer just got empty
*/
if (_gnutls_record_buffer_get_size (type, session) == 0)
if (mhd_gnutls_record_buffer_get_size (type, session) == 0)
{
if ((ret2 = _gnutls_io_clear_peeked_data (session)) < 0)
if ((ret2 = mhd_gtls_io_clear_peeked_data (session)) < 0)
{
gnutls_assert ();
return ret2;
@@ -1086,8 +1050,8 @@ begin:
}
/**
* gnutls_record_send - sends to the peer the specified data
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_record_send - sends to the peer the specified data
* @session: is a #mhd_gtls_session_t structure.
* @data: contains the data to send
* @sizeofdata: is the length of the data
*
@@ -1098,7 +1062,7 @@ begin:
* Note that if the send buffer is full, send() will block this
* function. See the send() documentation for full information. You
* can replace the default push function by using
* gnutls_transport_set_ptr2() with a call to send() with a
* MHD_gnutls_transport_set_ptr2() with a call to send() with a
* MSG_DONTWAIT flag if blocking is a problem.
*
* If the EINTR is returned by the internal push function (the
@@ -1106,7 +1070,7 @@ begin:
* %GNUTLS_E_INTERRUPTED or %GNUTLS_E_AGAIN is returned, you must
* call this function again, with the same parameters; alternatively
* you could provide a %NULL pointer for data, and 0 for
* size. cf. gnutls_record_get_direction().
* size. cf. MHD_gnutls_record_get_direction().
*
* Returns: the number of bytes sent, or a negative error code. The
* number of bytes sent might be less than @sizeofdata. The maximum
@@ -1114,16 +1078,16 @@ begin:
* the negotiated maximum record size.
**/
ssize_t
gnutls_record_send (gnutls_session_t session,
MHD_gnutls_record_send (mhd_gtls_session_t session,
const void *data, size_t sizeofdata)
{
return _gnutls_send_int (session, GNUTLS_APPLICATION_DATA, -1, data,
return mhd_gtls_send_int (session, GNUTLS_APPLICATION_DATA, -1, data,
sizeofdata);
}
/**
* gnutls_record_recv - reads data from the TLS record protocol
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_record_recv - reads data from the TLS record protocol
* @session: is a #mhd_gtls_session_t structure.
* @data: the buffer that the data will be read into
* @sizeofdata: the number of requested bytes
*
@@ -1141,7 +1105,7 @@ gnutls_record_send (gnutls_session_t session,
* is recv()) then %GNUTLS_E_INTERRUPTED will be returned. If
* %GNUTLS_E_INTERRUPTED or %GNUTLS_E_AGAIN is returned, you must
* call this function again to get the data. See also
* gnutls_record_get_direction().
* MHD_gnutls_record_get_direction().
*
* A server may also receive %GNUTLS_E_REHANDSHAKE when a client has
* initiated a handshake. In that case the server can only initiate a
@@ -1152,22 +1116,22 @@ gnutls_record_send (gnutls_session_t session,
* received might be less than @sizeofdata.
**/
ssize_t
gnutls_record_recv (gnutls_session_t session, void *data, size_t sizeofdata)
MHD_gnutls_record_recv (mhd_gtls_session_t session, void *data, size_t sizeofdata)
{
return _gnutls_recv_int (session, GNUTLS_APPLICATION_DATA, -1, data,
return mhd_gtls_recv_int (session, GNUTLS_APPLICATION_DATA, -1, data,
sizeofdata);
}
/**
* gnutls_record_get_max_size - returns the maximum record size
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_record_get_max_size - returns the maximum record size
* @session: is a #mhd_gtls_session_t structure.
*
* This function returns the maximum record packet size in this
* connection. The maximum record size is negotiated by the client
* after the first handshake message.
**/
size_t
gnutls_record_get_max_size (gnutls_session_t session)
MHD_gnutls_record_get_max_size (mhd_gtls_session_t session)
{
/* Recv will hold the negotiated max record size
* always.
@@ -1176,8 +1140,8 @@ gnutls_record_get_max_size (gnutls_session_t session)
}
/**
* gnutls_record_set_max_size - sets the maximum record size
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_record_set_max_size - sets the maximum record size
* @session: is a #mhd_gtls_session_t structure.
* @size: is the new size
*
* This function sets the maximum record packet size in this
@@ -1193,14 +1157,14 @@ gnutls_record_get_max_size (gnutls_session_t session)
* all TLS implementations use or even understand this extension.
**/
ssize_t
gnutls_record_set_max_size (gnutls_session_t session, size_t size)
MHD_gnutls_record_set_max_size (mhd_gtls_session_t session, size_t size)
{
ssize_t new_size;
if (session->security_parameters.entity == GNUTLS_SERVER)
return GNUTLS_E_INVALID_REQUEST;
new_size = _gnutls_mre_record2num (size);
new_size = mhd_gtls_mre_record2num (size);
if (new_size < 0)
{
+4 -4
View File
@@ -22,11 +22,11 @@
*
*/
ssize_t _gnutls_send_int (gnutls_session_t session, content_type_t type,
ssize_t mhd_gtls_send_int (mhd_gtls_session_t session, content_type_t type,
gnutls_handshake_description_t htype,
const void *data, size_t sizeofdata);
ssize_t _gnutls_recv_int (gnutls_session_t session, content_type_t type,
ssize_t mhd_gtls_recv_int (mhd_gtls_session_t session, content_type_t type,
gnutls_handshake_description_t, opaque * data,
size_t sizeofdata);
ssize_t _gnutls_send_change_cipher_spec (gnutls_session_t session, int again);
void gnutls_transport_set_lowat (gnutls_session_t session, int num);
ssize_t mhd_gtls_send_change_cipher_spec (mhd_gtls_session_t session, int again);
void MHD_gnutls_transport_set_lowat (mhd_gtls_session_t session, int num);
+11 -146
View File
@@ -46,7 +46,7 @@
* We only support limited key sizes.
*/
const mpi_t *
_gnutls_rsa_params_to_mpi (gnutls_rsa_params_t rsa_params)
_gnutls_rsa_params_to_mpi (mhd_gtls_rsa_params_t rsa_params)
{
if (rsa_params == NULL)
{
@@ -167,42 +167,15 @@ _gnutls_rsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
}
/**
* gnutls_rsa_params_import_raw - This function will replace the old RSA parameters
* @rsa_params: Is a structure will hold the parameters
* @m: holds the modulus
* @e: holds the public exponent
* @d: holds the private exponent
* @p: holds the first prime (p)
* @q: holds the second prime (q)
* @u: holds the coefficient
*
* This function will replace the parameters in the given structure.
* The new parameters should be stored in the appropriate gnutls_datum.
*
**/
int
gnutls_rsa_params_import_raw (gnutls_rsa_params_t rsa_params,
const gnutls_datum_t * m,
const gnutls_datum_t * e,
const gnutls_datum_t * d,
const gnutls_datum_t * p,
const gnutls_datum_t * q,
const gnutls_datum_t * u)
{
return gnutls_x509_privkey_import_rsa_raw (rsa_params, m, e, d, p, q, u);
}
/**
* gnutls_rsa_params_init - This function will initialize the temporary RSA parameters
* MHD_gnutls_rsa_params_init - This function will initialize the temporary RSA parameters
* @rsa_params: Is a structure that will hold the parameters
*
* This function will initialize the temporary RSA parameters structure.
*
**/
int
gnutls_rsa_params_init (gnutls_rsa_params_t * rsa_params)
MHD_gnutls_rsa_params_init (mhd_gtls_rsa_params_t * rsa_params)
{
int ret;
@@ -219,42 +192,27 @@ gnutls_rsa_params_init (gnutls_rsa_params_t * rsa_params)
}
/**
* gnutls_rsa_params_deinit - This function will deinitialize the RSA parameters
* MHD_gnutls_rsa_params_deinit - This function will deinitialize the RSA parameters
* @rsa_params: Is a structure that holds the parameters
*
* This function will deinitialize the RSA parameters structure.
*
**/
void
gnutls_rsa_params_deinit (gnutls_rsa_params_t rsa_params)
MHD_gnutls_rsa_params_deinit (mhd_gtls_rsa_params_t rsa_params)
{
gnutls_x509_privkey_deinit (rsa_params);
}
/**
* gnutls_rsa_params_cpy - This function will copy an RSA parameters structure
* @dst: Is the destination structure, which should be initialized.
* @src: Is the source structure
*
* This function will copy the RSA parameters structure from source
* to destination.
*
**/
int
gnutls_rsa_params_cpy (gnutls_rsa_params_t dst, gnutls_rsa_params_t src)
{
return gnutls_x509_privkey_cpy (dst, src);
}
/**
* gnutls_rsa_params_generate2 - This function will generate temporary RSA parameters
* MHD_gnutls_rsa_params_generate2 - This function will generate temporary RSA parameters
* @params: The structure where the parameters will be stored
* @bits: is the prime's number of bits
*
* This function will generate new temporary RSA parameters for use in
* RSA-EXPORT ciphersuites. This function is normally slow.
*
* Note that if the parameters are to be used in export cipher suites the
* This function will generate new temporary RSA parameters for use in
* RSA-EXPORT ciphersuites. This function is normally slow.
*
* Note that if the parameters are to be used in export cipher suites the
* bits value should be 512 or less.
* Also note that the generation of new RSA parameters is only useful
* to servers. Clients use the parameters sent by the server, thus it's
@@ -262,100 +220,7 @@ gnutls_rsa_params_cpy (gnutls_rsa_params_t dst, gnutls_rsa_params_t src)
*
**/
int
gnutls_rsa_params_generate2 (gnutls_rsa_params_t params, unsigned int bits)
MHD_gnutls_rsa_params_generate2 (mhd_gtls_rsa_params_t params, unsigned int bits)
{
return gnutls_x509_privkey_generate (params, MHD_GNUTLS_PK_RSA, bits, 0);
}
/**
* gnutls_rsa_params_import_pkcs1 - This function will import RSA params from a pkcs1 structure
* @params: A structure where the parameters will be copied to
* @pkcs1_params: should contain a PKCS1 RSAPublicKey structure PEM or DER encoded
* @format: the format of params. PEM or DER.
*
* This function will extract the RSAPublicKey found in a PKCS1 formatted
* structure.
*
* If the structure is PEM encoded, it should have a header
* of "BEGIN RSA PRIVATE KEY".
*
* In case of failure a negative value will be returned, and
* 0 on success.
*
**/
int
gnutls_rsa_params_import_pkcs1 (gnutls_rsa_params_t params,
const gnutls_datum_t * pkcs1_params,
gnutls_x509_crt_fmt_t format)
{
return gnutls_x509_privkey_import (params, pkcs1_params, format);
}
/**
* gnutls_rsa_params_export_pkcs1 - This function will export RSA params to a pkcs1 structure
* @params: Holds the RSA parameters
* @format: the format of output params. One of PEM or DER.
* @params_data: will contain a PKCS1 RSAPublicKey structure PEM or DER encoded
* @params_data_size: holds the size of params_data (and will be replaced by the actual size of parameters)
*
* This function will export the given RSA parameters to a PKCS1
* RSAPublicKey structure. If the buffer provided is not long enough to
* hold the output, then GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.
*
* If the structure is PEM encoded, it will have a header
* of "BEGIN RSA PRIVATE KEY".
*
* In case of failure a negative value will be returned, and
* 0 on success.
*
**/
int
gnutls_rsa_params_export_pkcs1 (gnutls_rsa_params_t params,
gnutls_x509_crt_fmt_t format,
unsigned char *params_data,
size_t * params_data_size)
{
return gnutls_x509_privkey_export (params, format,
params_data, params_data_size);
}
/**
* gnutls_rsa_params_export_raw - This function will export the RSA parameters
* @params: a structure that holds the rsa parameters
* @m: will hold the modulus
* @e: will hold the public exponent
* @d: will hold the private exponent
* @p: will hold the first prime (p)
* @q: will hold the second prime (q)
* @u: will hold the coefficient
* @bits: if non null will hold the prime's number of bits
*
* This function will export the RSA parameters found in the given
* structure. The new parameters will be allocated using
* gnutls_malloc() and will be stored in the appropriate datum.
*
**/
int
gnutls_rsa_params_export_raw (gnutls_rsa_params_t params,
gnutls_datum_t * m, gnutls_datum_t * e,
gnutls_datum_t * d, gnutls_datum_t * p,
gnutls_datum_t * q, gnutls_datum_t * u,
unsigned int *bits)
{
int ret;
ret = gnutls_x509_privkey_export_rsa_raw (params, m, e, d, p, q, u);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
if (bits)
*bits = _gnutls_mpi_get_nbits (params->params[3]);
return 0;
}
+2 -2
View File
@@ -22,6 +22,6 @@
*
*/
const mpi_t *_gnutls_rsa_params_to_mpi (gnutls_rsa_params_t);
int _gnutls_peers_cert_less_512 (gnutls_session_t session);
const mpi_t * _gnutls_rsa_params_to_mpi (mhd_gtls_rsa_params_t);
int _gnutls_peers_cert_less_512 (mhd_gtls_session_t session);
int _gnutls_rsa_generate_params (mpi_t * resarr, int *resarr_len, int bits);
+92 -90
View File
@@ -27,9 +27,11 @@
#include "gnutls_session_pack.h"
#include <gnutls_datum.h>
/* TODO this file should be removed if session resumption will be abandoned */
/**
* gnutls_session_get_data - Returns all session parameters.
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
* @session_data: is a pointer to space to hold the session.
* @session_data_size: is the session_data's size, or it will be set by the function.
*
@@ -40,46 +42,46 @@
*
* Resuming sessions is really useful and speedups connections after a succesful one.
**/
int
gnutls_session_get_data (gnutls_session_t session,
void *session_data, size_t * session_data_size)
{
gnutls_datum_t psession;
int ret;
if (session->internals.resumable == RESUME_FALSE)
return GNUTLS_E_INVALID_SESSION;
psession.data = session_data;
ret = _gnutls_session_pack (session, &psession);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
*session_data_size = psession.size;
if (psession.size > *session_data_size)
{
ret = GNUTLS_E_SHORT_MEMORY_BUFFER;
goto error;
}
if (session_data != NULL)
memcpy (session_data, psession.data, psession.size);
ret = 0;
error:
_gnutls_free_datum (&psession);
return ret;
}
//int
//gnutls_session_get_data (mhd_gtls_session_t session,
// void *session_data, size_t * session_data_size)
//{
//
// gnutls_datum_t psession;
// int ret;
//
// if (session->internals.resumable == RESUME_FALSE)
// return GNUTLS_E_INVALID_SESSION;
//
// psession.data = session_data;
//
// ret = _gnutls_session_pack (session, &psession);
// if (ret < 0)
// {
// gnutls_assert ();
// return ret;
// }
// *session_data_size = psession.size;
//
// if (psession.size > *session_data_size)
// {
// ret = GNUTLS_E_SHORT_MEMORY_BUFFER;
// goto error;
// }
//
// if (session_data != NULL)
// memcpy (session_data, psession.data, psession.size);
//
// ret = 0;
//
//error:
// _gnutls_free_datum (&psession);
// return ret;
//}
/**
* gnutls_session_get_data2 - Returns all session parameters.
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
* @session_data: is a pointer to a datum that will hold the session.
*
* Returns all session parameters, in order to support resuming.
@@ -90,34 +92,34 @@ error:
*
* Resuming sessions is really useful and speedups connections after a succesful one.
**/
int
gnutls_session_get_data2 (gnutls_session_t session, gnutls_datum_t * data)
{
int ret;
if (data == NULL)
{
return GNUTLS_E_INVALID_REQUEST;
}
if (session->internals.resumable == RESUME_FALSE)
return GNUTLS_E_INVALID_SESSION;
ret = _gnutls_session_pack (session, data);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
return 0;
}
//int
//gnutls_session_get_data2 (mhd_gtls_session_t session, gnutls_datum_t * data)
//{
//
// int ret;
//
// if (data == NULL)
// {
// return GNUTLS_E_INVALID_REQUEST;
// }
//
// if (session->internals.resumable == RESUME_FALSE)
// return GNUTLS_E_INVALID_SESSION;
//
// ret = _gnutls_session_pack (session, data);
// if (ret < 0)
// {
// gnutls_assert ();
// return ret;
// }
//
// return 0;
//}
/**
* gnutls_session_get_id - Returns session id.
* @session: is a #gnutls_session_t structure.
* MHD_gtls_session_get_id - Returns session id.
* @session: is a #mhd_gtls_session_t structure.
* @session_id: is a pointer to space to hold the session id.
* @session_id_size: is the session id's size, or it will be set by the function.
*
@@ -132,7 +134,7 @@ gnutls_session_get_data2 (gnutls_session_t session, gnutls_datum_t * data)
* Returns zero on success.
**/
int
gnutls_session_get_id (gnutls_session_t session,
MHD_gtls_session_get_id (mhd_gtls_session_t session,
void *session_id, size_t * session_id_size)
{
size_t given_session_id_size = *session_id_size;
@@ -158,13 +160,13 @@ gnutls_session_get_id (gnutls_session_t session,
/**
* gnutls_session_set_data - Sets all session parameters
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
* @session_data: is a pointer to space to hold the session.
* @session_data_size: is the session's size
*
* Sets all session parameters, in order to resume a previously established
* session. The session data given must be the one returned by gnutls_session_get_data().
* This function should be called before gnutls_handshake().
* This function should be called before MHD_gnutls_handshake().
*
* Keep in mind that session resuming is advisory. The server may
* choose not to resume the session, thus a full handshake will be
@@ -173,27 +175,27 @@ gnutls_session_get_id (gnutls_session_t session,
* Returns a negative value on error.
*
**/
int
gnutls_session_set_data (gnutls_session_t session,
const void *session_data, size_t session_data_size)
{
int ret;
gnutls_datum_t psession;
psession.data = (opaque *) session_data;
psession.size = session_data_size;
if (session_data == NULL || session_data_size == 0)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
ret = _gnutls_session_unpack (session, &psession);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
return 0;
}
//int
//gnutls_session_set_data (mhd_gtls_session_t session,
// const void *session_data, size_t session_data_size)
//{
// int ret;
// gnutls_datum_t psession;
//
// psession.data = (opaque *) session_data;
// psession.size = session_data_size;
//
// if (session_data == NULL || session_data_size == 0)
// {
// gnutls_assert ();
// return GNUTLS_E_INVALID_REQUEST;
// }
// ret = _gnutls_session_unpack (session, &psession);
// if (ret < 0)
// {
// gnutls_assert ();
// return ret;
// }
//
// return 0;
//}
+90 -90
View File
@@ -43,15 +43,15 @@
#define PACK_HEADER_SIZE 1
#define MAX_SEC_PARAMS 7+MAX_SRP_USERNAME+MAX_SERVER_NAME_EXTENSIONS*(3+MAX_SERVER_NAME_SIZE)+165
static int pack_certificate_auth_info (gnutls_session_t,
static int pack_certificate_auth_info (mhd_gtls_session_t,
gnutls_datum_t * packed_session);
static int unpack_certificate_auth_info (gnutls_session_t,
static int unpack_certificate_auth_info (mhd_gtls_session_t,
const gnutls_datum_t *
packed_session);
static int unpack_security_parameters (gnutls_session_t session,
static int unpack_security_parameters (mhd_gtls_session_t session,
const gnutls_datum_t * packed_session);
static int pack_security_parameters (gnutls_session_t session,
static int pack_security_parameters (mhd_gtls_session_t session,
gnutls_datum_t * packed_session);
/* Packs the ANON session authentication data. */
@@ -69,9 +69,9 @@ static int pack_security_parameters (gnutls_session_t session,
* x bytes the public key
*/
static int
pack_anon_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session)
pack_anon_auth_info (mhd_gtls_session_t session, gnutls_datum_t * packed_session)
{
anon_auth_info_t info = _gnutls_get_auth_info (session);
mhd_anon_auth_info_t info = mhd_gtls_get_auth_info (session);
int pos = 0;
size_t pack_size;
@@ -95,19 +95,19 @@ pack_anon_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session)
}
packed_session->data[0] = MHD_GNUTLS_CRD_ANON;
_gnutls_write_uint32 (pack_size, &packed_session->data[PACK_HEADER_SIZE]);
mhd_gtls_write_uint32 (pack_size, &packed_session->data[PACK_HEADER_SIZE]);
pos += 4 + PACK_HEADER_SIZE;
if (pack_size > 0)
{
_gnutls_write_uint16 (info->dh.secret_bits, &packed_session->data[pos]);
mhd_gtls_write_uint16 (info->dh.secret_bits, &packed_session->data[pos]);
pos += 2;
_gnutls_write_datum32 (&packed_session->data[pos], info->dh.prime);
mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.prime);
pos += 4 + info->dh.prime.size;
_gnutls_write_datum32 (&packed_session->data[pos], info->dh.generator);
mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.generator);
pos += 4 + info->dh.generator.size;
_gnutls_write_datum32 (&packed_session->data[pos], info->dh.public_key);
mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.public_key);
pos += 4 + info->dh.public_key.size;
}
@@ -127,12 +127,12 @@ pack_anon_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session)
* x bytes the public key
*/
static int
unpack_anon_auth_info (gnutls_session_t session,
unpack_anon_auth_info (mhd_gtls_session_t session,
const gnutls_datum_t * packed_session)
{
size_t pack_size;
int pos = 0, size, ret;
anon_auth_info_t info;
mhd_anon_auth_info_t info;
if (packed_session->data[0] != MHD_GNUTLS_CRD_ANON)
{
@@ -140,7 +140,7 @@ unpack_anon_auth_info (gnutls_session_t session,
return GNUTLS_E_INVALID_REQUEST;
}
pack_size = _gnutls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]);
pack_size = mhd_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]);
pos += PACK_HEADER_SIZE + 4;
@@ -157,7 +157,7 @@ unpack_anon_auth_info (gnutls_session_t session,
/* client and serer have the same auth_info here
*/
ret =
_gnutls_auth_info_set (session, MHD_GNUTLS_CRD_ANON,
mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_ANON,
sizeof (anon_auth_info_st), 1);
if (ret < 0)
{
@@ -165,17 +165,17 @@ unpack_anon_auth_info (gnutls_session_t session,
return ret;
}
info = _gnutls_get_auth_info (session);
info = mhd_gtls_get_auth_info (session);
if (info == NULL)
{
gnutls_assert ();
return GNUTLS_E_INTERNAL_ERROR;
}
info->dh.secret_bits = _gnutls_read_uint16 (&packed_session->data[pos]);
info->dh.secret_bits = mhd_gtls_read_uint16 (&packed_session->data[pos]);
pos += 2;
size = _gnutls_read_uint32 (&packed_session->data[pos]);
size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
pos += 4;
ret = _gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size);
if (ret < 0)
@@ -185,7 +185,7 @@ unpack_anon_auth_info (gnutls_session_t session,
}
pos += size;
size = _gnutls_read_uint32 (&packed_session->data[pos]);
size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
pos += 4;
ret =
_gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size);
@@ -196,7 +196,7 @@ unpack_anon_auth_info (gnutls_session_t session,
}
pos += size;
size = _gnutls_read_uint32 (&packed_session->data[pos]);
size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
pos += 4;
ret =
_gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos],
@@ -227,7 +227,7 @@ error:
* The data will be in a platform independent format.
*/
int
_gnutls_session_pack (gnutls_session_t session,
_gnutls_session_pack (mhd_gtls_session_t session,
gnutls_datum_t * packed_session)
{
int ret;
@@ -239,7 +239,7 @@ _gnutls_session_pack (gnutls_session_t session,
}
switch (gnutls_auth_get_type (session))
switch (MHD_gtls_auth_get_type (session))
{
#ifdef ENABLE_SRP
case MHD_GNUTLS_CRD_SRP:
@@ -284,7 +284,7 @@ _gnutls_session_pack (gnutls_session_t session,
}
/* Auth_info structures copied. Now copy security_parameters_st.
/* Auth_info structures copied. Now copy mhd_gtls_security_param_st.
* packed_session must have allocated space for the security parameters.
*/
ret = pack_security_parameters (session, packed_session);
@@ -302,7 +302,7 @@ _gnutls_session_pack (gnutls_session_t session,
/* Load session data from a buffer.
*/
int
_gnutls_session_unpack (gnutls_session_t session,
_gnutls_session_unpack (mhd_gtls_session_t session,
const gnutls_datum_t * packed_session)
{
int ret;
@@ -313,9 +313,9 @@ _gnutls_session_unpack (gnutls_session_t session,
return GNUTLS_E_INTERNAL_ERROR;
}
if (_gnutls_get_auth_info (session) != NULL)
if (mhd_gtls_get_auth_info (session) != NULL)
{
_gnutls_free_auth_info (session);
mhd_gtls_free_auth_info (session);
}
switch (packed_session->data[0])
@@ -364,7 +364,7 @@ _gnutls_session_unpack (gnutls_session_t session,
}
/* Auth_info structures copied. Now copy security_parameters_st.
/* Auth_info structures copied. Now copy mhd_gtls_security_param_st.
* packed_session must have allocated space for the security parameters.
*/
ret = unpack_security_parameters (session, packed_session);
@@ -401,12 +401,12 @@ _gnutls_session_unpack (gnutls_session_t session,
* and so on...
*/
static int
pack_certificate_auth_info (gnutls_session_t session,
pack_certificate_auth_info (mhd_gtls_session_t session,
gnutls_datum_t * packed_session)
{
unsigned int pos = 0, i;
int cert_size, pack_size;
cert_auth_info_t info = _gnutls_get_auth_info (session);
cert_auth_info_t info = mhd_gtls_get_auth_info (session);
if (info)
{
@@ -437,36 +437,36 @@ pack_certificate_auth_info (gnutls_session_t session,
}
packed_session->data[0] = MHD_GNUTLS_CRD_CERTIFICATE;
_gnutls_write_uint32 (pack_size, &packed_session->data[PACK_HEADER_SIZE]);
mhd_gtls_write_uint32 (pack_size, &packed_session->data[PACK_HEADER_SIZE]);
pos += 4 + PACK_HEADER_SIZE;
if (pack_size > 0)
{
_gnutls_write_uint16 (info->dh.secret_bits, &packed_session->data[pos]);
mhd_gtls_write_uint16 (info->dh.secret_bits, &packed_session->data[pos]);
pos += 2;
_gnutls_write_datum32 (&packed_session->data[pos], info->dh.prime);
mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.prime);
pos += 4 + info->dh.prime.size;
_gnutls_write_datum32 (&packed_session->data[pos], info->dh.generator);
mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.generator);
pos += 4 + info->dh.generator.size;
_gnutls_write_datum32 (&packed_session->data[pos], info->dh.public_key);
mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.public_key);
pos += 4 + info->dh.public_key.size;
_gnutls_write_datum32 (&packed_session->data[pos],
mhd_gtls_write_datum32 (&packed_session->data[pos],
info->rsa_export.modulus);
pos += 4 + info->rsa_export.modulus.size;
_gnutls_write_datum32 (&packed_session->data[pos],
mhd_gtls_write_datum32 (&packed_session->data[pos],
info->rsa_export.exponent);
pos += 4 + info->rsa_export.exponent.size;
_gnutls_write_uint32 (info->ncerts, &packed_session->data[pos]);
mhd_gtls_write_uint32 (info->ncerts, &packed_session->data[pos]);
pos += 4;
for (i = 0; i < info->ncerts; i++)
{
_gnutls_write_datum32 (&packed_session->data[pos],
mhd_gtls_write_datum32 (&packed_session->data[pos],
info->raw_certificate_list[i]);
pos += sizeof (uint32_t) + info->raw_certificate_list[i].size;
}
@@ -479,7 +479,7 @@ pack_certificate_auth_info (gnutls_session_t session,
/* Upack certificate info.
*/
static int
unpack_certificate_auth_info (gnutls_session_t session,
unpack_certificate_auth_info (mhd_gtls_session_t session,
const gnutls_datum_t * packed_session)
{
int pos = 0, size, ret;
@@ -493,7 +493,7 @@ unpack_certificate_auth_info (gnutls_session_t session,
return GNUTLS_E_INVALID_REQUEST;
}
pack_size = _gnutls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]);
pack_size = mhd_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]);
pos += PACK_HEADER_SIZE + 4;
if (pack_size == 0)
@@ -509,7 +509,7 @@ unpack_certificate_auth_info (gnutls_session_t session,
/* client and server have the same auth_info here
*/
ret =
_gnutls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
sizeof (cert_auth_info_st), 1);
if (ret < 0)
{
@@ -517,17 +517,17 @@ unpack_certificate_auth_info (gnutls_session_t session,
return ret;
}
info = _gnutls_get_auth_info (session);
info = mhd_gtls_get_auth_info (session);
if (info == NULL)
{
gnutls_assert ();
return GNUTLS_E_INTERNAL_ERROR;
}
info->dh.secret_bits = _gnutls_read_uint16 (&packed_session->data[pos]);
info->dh.secret_bits = mhd_gtls_read_uint16 (&packed_session->data[pos]);
pos += 2;
size = _gnutls_read_uint32 (&packed_session->data[pos]);
size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
pos += 4;
ret = _gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size);
if (ret < 0)
@@ -537,7 +537,7 @@ unpack_certificate_auth_info (gnutls_session_t session,
}
pos += size;
size = _gnutls_read_uint32 (&packed_session->data[pos]);
size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
pos += 4;
ret =
_gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size);
@@ -548,7 +548,7 @@ unpack_certificate_auth_info (gnutls_session_t session,
}
pos += size;
size = _gnutls_read_uint32 (&packed_session->data[pos]);
size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
pos += 4;
ret =
_gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos],
@@ -560,7 +560,7 @@ unpack_certificate_auth_info (gnutls_session_t session,
}
pos += size;
size = _gnutls_read_uint32 (&packed_session->data[pos]);
size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
pos += 4;
ret =
_gnutls_set_datum (&info->rsa_export.modulus,
@@ -572,7 +572,7 @@ unpack_certificate_auth_info (gnutls_session_t session,
}
pos += size;
size = _gnutls_read_uint32 (&packed_session->data[pos]);
size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
pos += 4;
ret =
_gnutls_set_datum (&info->rsa_export.exponent,
@@ -584,7 +584,7 @@ unpack_certificate_auth_info (gnutls_session_t session,
}
pos += size;
info->ncerts = _gnutls_read_uint32 (&packed_session->data[pos]);
info->ncerts = mhd_gtls_read_uint32 (&packed_session->data[pos]);
pos += 4;
if (info->ncerts > 0)
@@ -601,7 +601,7 @@ unpack_certificate_auth_info (gnutls_session_t session,
for (i = 0; i < info->ncerts; i++)
{
size = _gnutls_read_uint32 (&packed_session->data[pos]);
size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
pos += sizeof (uint32_t);
ret =
@@ -646,9 +646,9 @@ error:
* x bytes the SRP username
*/
static int
pack_srp_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session)
pack_srp_auth_info (mhd_gtls_session_t session, gnutls_datum_t * packed_session)
{
srp_server_auth_info_t info = _gnutls_get_auth_info (session);
srp_server_auth_info_t info = mhd_gtls_get_auth_info (session);
int pack_size;
if (info && info->username)
@@ -670,7 +670,7 @@ pack_srp_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session)
}
packed_session->data[0] = MHD_GNUTLS_CRD_SRP;
_gnutls_write_uint32 (pack_size, &packed_session->data[PACK_HEADER_SIZE]);
mhd_gtls_write_uint32 (pack_size, &packed_session->data[PACK_HEADER_SIZE]);
if (pack_size > 0)
memcpy (&packed_session->data[PACK_HEADER_SIZE + sizeof (uint32_t)],
@@ -681,7 +681,7 @@ pack_srp_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session)
static int
unpack_srp_auth_info (gnutls_session_t session,
unpack_srp_auth_info (mhd_gtls_session_t session,
const gnutls_datum_t * packed_session)
{
size_t username_size;
@@ -695,7 +695,7 @@ unpack_srp_auth_info (gnutls_session_t session,
}
username_size =
_gnutls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]);
mhd_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]);
if (username_size == 0)
return 0; /* nothing to be done */
@@ -708,7 +708,7 @@ unpack_srp_auth_info (gnutls_session_t session,
}
ret =
_gnutls_auth_info_set (session, MHD_GNUTLS_CRD_SRP,
mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_SRP,
sizeof (srp_server_auth_info_st), 1);
if (ret < 0)
{
@@ -716,7 +716,7 @@ unpack_srp_auth_info (gnutls_session_t session,
return ret;
}
info = _gnutls_get_auth_info (session);
info = mhd_gtls_get_auth_info (session);
if (info == NULL)
{
gnutls_assert ();
@@ -751,12 +751,12 @@ unpack_srp_auth_info (gnutls_session_t session,
* x bytes the public key
*/
static int
pack_psk_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session)
pack_psk_auth_info (mhd_gtls_session_t session, gnutls_datum_t * packed_session)
{
psk_auth_info_t info;
int pack_size, username_size = 0, pos;
info = _gnutls_get_auth_info (session);
info = mhd_gtls_get_auth_info (session);
if (info)
{
@@ -786,26 +786,26 @@ pack_psk_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session)
packed_session->data[pos] = MHD_GNUTLS_CRD_PSK;
pos++;
_gnutls_write_uint32 (pack_size, &packed_session->data[pos]);
mhd_gtls_write_uint32 (pack_size, &packed_session->data[pos]);
pos += 4;
if (pack_size > 0)
{
_gnutls_write_uint32 (username_size, &packed_session->data[pos]);
mhd_gtls_write_uint32 (username_size, &packed_session->data[pos]);
pos += 4;
memcpy (&packed_session->data[pos], info->username, username_size);
pos += username_size;
_gnutls_write_uint16 (info->dh.secret_bits, &packed_session->data[pos]);
mhd_gtls_write_uint16 (info->dh.secret_bits, &packed_session->data[pos]);
pos += 2;
_gnutls_write_datum32 (&packed_session->data[pos], info->dh.prime);
mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.prime);
pos += 4 + info->dh.prime.size;
_gnutls_write_datum32 (&packed_session->data[pos], info->dh.generator);
mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.generator);
pos += 4 + info->dh.generator.size;
_gnutls_write_datum32 (&packed_session->data[pos], info->dh.public_key);
mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.public_key);
pos += 4 + info->dh.public_key.size;
}
@@ -815,7 +815,7 @@ pack_psk_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session)
}
static int
unpack_psk_auth_info (gnutls_session_t session,
unpack_psk_auth_info (mhd_gtls_session_t session,
const gnutls_datum_t * packed_session)
{
size_t username_size;
@@ -829,7 +829,7 @@ unpack_psk_auth_info (gnutls_session_t session,
return GNUTLS_E_INVALID_REQUEST;
}
pack_size = _gnutls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]);
pack_size = mhd_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]);
pos += PACK_HEADER_SIZE + 4;
@@ -846,7 +846,7 @@ unpack_psk_auth_info (gnutls_session_t session,
/* client and serer have the same auth_info here
*/
ret =
_gnutls_auth_info_set (session, MHD_GNUTLS_CRD_PSK,
mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_PSK,
sizeof (psk_auth_info_st), 1);
if (ret < 0)
{
@@ -854,23 +854,23 @@ unpack_psk_auth_info (gnutls_session_t session,
return ret;
}
info = _gnutls_get_auth_info (session);
info = mhd_gtls_get_auth_info (session);
if (info == NULL)
{
gnutls_assert ();
return GNUTLS_E_INTERNAL_ERROR;
}
username_size = _gnutls_read_uint32 (&packed_session->data[pos]);
username_size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
pos += 4;
memcpy (info->username, &packed_session->data[pos], username_size);
pos += username_size;
info->dh.secret_bits = _gnutls_read_uint16 (&packed_session->data[pos]);
info->dh.secret_bits = mhd_gtls_read_uint16 (&packed_session->data[pos]);
pos += 2;
size = _gnutls_read_uint32 (&packed_session->data[pos]);
size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
pos += 4;
ret = _gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size);
if (ret < 0)
@@ -880,7 +880,7 @@ unpack_psk_auth_info (gnutls_session_t session,
}
pos += size;
size = _gnutls_read_uint32 (&packed_session->data[pos]);
size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
pos += 4;
ret =
_gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size);
@@ -891,7 +891,7 @@ unpack_psk_auth_info (gnutls_session_t session,
}
pos += size;
size = _gnutls_read_uint32 (&packed_session->data[pos]);
size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
pos += 4;
ret =
_gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos],
@@ -963,7 +963,7 @@ error:
* MAX: 7+MAX_SRP_USERNAME+MAX_SERVER_NAME_EXTENSIONS*(3+MAX_SERVER_NAME_SIZE)
*/
static int
pack_security_parameters (gnutls_session_t session,
pack_security_parameters (mhd_gtls_session_t session,
gnutls_datum_t * packed_session)
{
int pos = 0;
@@ -972,7 +972,7 @@ pack_security_parameters (gnutls_session_t session,
/* move after the auth info stuff.
*/
init =
_gnutls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]) + 4 +
mhd_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]) + 4 +
PACK_HEADER_SIZE;
pos = init + 4; /* make some space to write later the size */
@@ -1015,16 +1015,16 @@ pack_security_parameters (gnutls_session_t session,
session->security_parameters.session_id_size);
pos += session->security_parameters.session_id_size;
_gnutls_write_uint32 (session->security_parameters.timestamp,
mhd_gtls_write_uint32 (session->security_parameters.timestamp,
&packed_session->data[pos]);
pos += 4;
/* Extensions */
_gnutls_write_uint16 (session->security_parameters.max_record_send_size,
mhd_gtls_write_uint16 (session->security_parameters.max_record_send_size,
&packed_session->data[pos]);
pos += 2;
_gnutls_write_uint16 (session->security_parameters.max_record_recv_size,
mhd_gtls_write_uint16 (session->security_parameters.max_record_recv_size,
&packed_session->data[pos]);
pos += 2;
@@ -1036,7 +1036,7 @@ pack_security_parameters (gnutls_session_t session,
session->security_parameters.extensions.srp_username, len);
pos += len;
_gnutls_write_uint16 (session->security_parameters.extensions.
mhd_gtls_write_uint16 (session->security_parameters.extensions.
server_names_size, &packed_session->data[pos]);
pos += 2;
@@ -1045,7 +1045,7 @@ pack_security_parameters (gnutls_session_t session,
{
packed_session->data[pos++] =
session->security_parameters.extensions.server_names[i].type;
_gnutls_write_uint16 (session->security_parameters.extensions.
mhd_gtls_write_uint16 (session->security_parameters.extensions.
server_names[i].name_length,
&packed_session->data[pos]);
pos += 2;
@@ -1059,7 +1059,7 @@ pack_security_parameters (gnutls_session_t session,
}
/* write the total size */
_gnutls_write_uint32 (pos - init - 4, &packed_session->data[init]);
mhd_gtls_write_uint32 (pos - init - 4, &packed_session->data[init]);
packed_session->size += pos - init;
return 0;
@@ -1067,7 +1067,7 @@ pack_security_parameters (gnutls_session_t session,
static int
unpack_security_parameters (gnutls_session_t session,
unpack_security_parameters (mhd_gtls_session_t session,
const gnutls_datum_t * packed_session)
{
size_t pack_size, init, i;
@@ -1077,12 +1077,12 @@ unpack_security_parameters (gnutls_session_t session,
/* skip the auth info stuff */
init =
_gnutls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]) + 4 +
mhd_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]) + 4 +
PACK_HEADER_SIZE;
pos = init;
pack_size = _gnutls_read_uint32 (&packed_session->data[pos]);
pack_size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
pos += 4;
@@ -1141,7 +1141,7 @@ unpack_security_parameters (gnutls_session_t session,
pos += session->internals.resumed_security_parameters.session_id_size;
session->internals.resumed_security_parameters.timestamp =
_gnutls_read_uint32 (&packed_session->data[pos]);
mhd_gtls_read_uint32 (&packed_session->data[pos]);
pos += 4;
if (timestamp - session->internals.resumed_security_parameters.timestamp >
@@ -1154,11 +1154,11 @@ unpack_security_parameters (gnutls_session_t session,
/* Extensions */
session->internals.resumed_security_parameters.max_record_send_size =
_gnutls_read_uint16 (&packed_session->data[pos]);
mhd_gtls_read_uint16 (&packed_session->data[pos]);
pos += 2;
session->internals.resumed_security_parameters.max_record_recv_size =
_gnutls_read_uint16 (&packed_session->data[pos]);
mhd_gtls_read_uint16 (&packed_session->data[pos]);
pos += 2;
@@ -1171,7 +1171,7 @@ unpack_security_parameters (gnutls_session_t session,
pos += len;
session->internals.resumed_security_parameters.extensions.
server_names_size = _gnutls_read_uint16 (&packed_session->data[pos]);
server_names_size = mhd_gtls_read_uint16 (&packed_session->data[pos]);
pos += 2;
for (i = 0;
i <
@@ -1182,7 +1182,7 @@ unpack_security_parameters (gnutls_session_t session,
server_names[i].type = packed_session->data[pos++];
session->internals.resumed_security_parameters.extensions.
server_names[i].name_length =
_gnutls_read_uint16 (&packed_session->data[pos]);
mhd_gtls_read_uint16 (&packed_session->data[pos]);
pos += 2;
memcpy (session->internals.resumed_security_parameters.extensions.
+2 -2
View File
@@ -22,7 +22,7 @@
*
*/
int _gnutls_session_pack (gnutls_session_t session,
int _gnutls_session_pack (mhd_gtls_session_t session,
gnutls_datum_t * packed_session);
int _gnutls_session_unpack (gnutls_session_t session,
int _gnutls_session_unpack (mhd_gtls_session_t session,
const gnutls_datum_t * packed_session);
+55 -55
View File
@@ -37,7 +37,7 @@
#include <gnutls_sig.h>
#include <gnutls_kx.h>
static int _gnutls_tls_sign (gnutls_session_t session,
static int _gnutls_tls_sign (mhd_gtls_session_t session,
gnutls_cert * cert,
gnutls_privkey * pkey,
const gnutls_datum_t * hash_concat,
@@ -47,7 +47,7 @@ static int _gnutls_tls_sign (gnutls_session_t session,
* handshake procedure. (20040227: now it works for SSL 3.0 as well)
*/
int
_gnutls_tls_sign_hdata (gnutls_session_t session,
mhd_gtls_tls_sign_hdata (mhd_gtls_session_t session,
gnutls_cert * cert,
gnutls_privkey * pkey, gnutls_datum_t * signature)
{
@@ -56,9 +56,9 @@ _gnutls_tls_sign_hdata (gnutls_session_t session,
opaque concat[36];
mac_hd_t td_md5;
mac_hd_t td_sha;
gnutls_protocol_t ver = gnutls_protocol_get_version (session);
gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session);
td_sha = _gnutls_hash_copy (session->internals.handshake_mac_handle_sha);
td_sha = mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_sha);
if (td_sha == NULL)
{
gnutls_assert ();
@@ -67,25 +67,25 @@ _gnutls_tls_sign_hdata (gnutls_session_t session,
if (ver == MHD_GNUTLS_SSL3)
{
ret = _gnutls_generate_master (session, 1);
ret = mhd_gtls_generate_master (session, 1);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
_gnutls_mac_deinit_ssl3_handshake (td_sha, &concat[16],
mhd_gnutls_mac_deinit_ssl3_handshake (td_sha, &concat[16],
session->security_parameters.
master_secret, TLS_MASTER_SIZE);
}
else
_gnutls_hash_deinit (td_sha, &concat[16]);
mhd_gnutls_hash_deinit (td_sha, &concat[16]);
switch (cert->subject_pk_algorithm)
{
case MHD_GNUTLS_PK_RSA:
td_md5 =
_gnutls_hash_copy (session->internals.handshake_mac_handle_md5);
mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_md5);
if (td_md5 == NULL)
{
gnutls_assert ();
@@ -93,11 +93,11 @@ _gnutls_tls_sign_hdata (gnutls_session_t session,
}
if (ver == MHD_GNUTLS_SSL3)
_gnutls_mac_deinit_ssl3_handshake (td_md5, concat,
mhd_gnutls_mac_deinit_ssl3_handshake (td_md5, concat,
session->security_parameters.
master_secret, TLS_MASTER_SIZE);
else
_gnutls_hash_deinit (td_md5, concat);
mhd_gnutls_hash_deinit (td_md5, concat);
dconcat.data = concat;
dconcat.size = 36;
@@ -119,7 +119,7 @@ _gnutls_tls_sign_hdata (gnutls_session_t session,
* Used in DHE_* ciphersuites.
*/
int
_gnutls_tls_sign_params (gnutls_session_t session,
mhd_gtls_tls_sign_params (mhd_gtls_session_t session,
gnutls_cert * cert,
gnutls_privkey * pkey,
gnutls_datum_t * params, gnutls_datum_t * signature)
@@ -128,41 +128,41 @@ _gnutls_tls_sign_params (gnutls_session_t session,
int ret;
mac_hd_t td_sha;
opaque concat[36];
gnutls_protocol_t ver = gnutls_protocol_get_version (session);
gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session);
td_sha = _gnutls_hash_init (MHD_GNUTLS_MAC_SHA1);
td_sha = mhd_gtls_hash_init (MHD_GNUTLS_MAC_SHA1);
if (td_sha == NULL)
{
gnutls_assert ();
return GNUTLS_E_HASH_FAILED;
}
_gnutls_hash (td_sha, session->security_parameters.client_random,
mhd_gnutls_hash (td_sha, session->security_parameters.client_random,
TLS_RANDOM_SIZE);
_gnutls_hash (td_sha, session->security_parameters.server_random,
mhd_gnutls_hash (td_sha, session->security_parameters.server_random,
TLS_RANDOM_SIZE);
_gnutls_hash (td_sha, params->data, params->size);
mhd_gnutls_hash (td_sha, params->data, params->size);
switch (cert->subject_pk_algorithm)
{
case MHD_GNUTLS_PK_RSA:
if (ver < MHD_GNUTLS_TLS1_2)
{
mac_hd_t td_md5 = _gnutls_hash_init (MHD_GNUTLS_MAC_MD5);
mac_hd_t td_md5 = mhd_gtls_hash_init (MHD_GNUTLS_MAC_MD5);
if (td_md5 == NULL)
{
gnutls_assert ();
return GNUTLS_E_HASH_FAILED;
}
_gnutls_hash (td_md5, session->security_parameters.client_random,
mhd_gnutls_hash (td_md5, session->security_parameters.client_random,
TLS_RANDOM_SIZE);
_gnutls_hash (td_md5, session->security_parameters.server_random,
mhd_gnutls_hash (td_md5, session->security_parameters.server_random,
TLS_RANDOM_SIZE);
_gnutls_hash (td_md5, params->data, params->size);
mhd_gnutls_hash (td_md5, params->data, params->size);
_gnutls_hash_deinit (td_md5, concat);
_gnutls_hash_deinit (td_sha, &concat[16]);
mhd_gnutls_hash_deinit (td_md5, concat);
mhd_gnutls_hash_deinit (td_sha, &concat[16]);
dconcat.size = 36;
}
@@ -173,13 +173,13 @@ _gnutls_tls_sign_params (gnutls_session_t session,
memcpy (concat,
"\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14",
15);
_gnutls_hash_deinit (td_sha, &concat[15]);
mhd_gnutls_hash_deinit (td_sha, &concat[15]);
dconcat.size = 35;
#else
/* No parameters field. */
memcpy (concat,
"\x30\x1f\x30\x07\x06\x05\x2b\x0e\x03\x02\x1a\x04\x14", 13);
_gnutls_hash_deinit (td_sha, &concat[13]);
mhd_gnutls_hash_deinit (td_sha, &concat[13]);
dconcat.size = 33;
#endif
}
@@ -187,7 +187,7 @@ _gnutls_tls_sign_params (gnutls_session_t session,
break;
default:
gnutls_assert ();
_gnutls_hash_deinit (td_sha, NULL);
mhd_gnutls_hash_deinit (td_sha, NULL);
return GNUTLS_E_INTERNAL_ERROR;
}
ret = _gnutls_tls_sign (session, cert, pkey, &dconcat, signature);
@@ -204,7 +204,7 @@ _gnutls_tls_sign_params (gnutls_session_t session,
* given data. The output will be allocated and be put in signature.
*/
int
_gnutls_sign (gnutls_pk_algorithm_t algo,
mhd_gtls_sign (gnutls_pk_algorithm_t algo,
mpi_t * params,
int params_size,
const gnutls_datum_t * data, gnutls_datum_t * signature)
@@ -216,7 +216,7 @@ _gnutls_sign (gnutls_pk_algorithm_t algo,
case MHD_GNUTLS_PK_RSA:
/* encrypt */
if ((ret =
_gnutls_pkcs1_rsa_encrypt (signature, data, params, params_size,
mhd_gtls_pkcs1_rsa_encrypt (signature, data, params, params_size,
1)) < 0)
{
gnutls_assert ();
@@ -238,7 +238,7 @@ _gnutls_sign (gnutls_pk_algorithm_t algo,
* it supports signing.
*/
static int
_gnutls_tls_sign (gnutls_session_t session,
_gnutls_tls_sign (mhd_gtls_session_t session,
gnutls_cert * cert,
gnutls_privkey * pkey,
const gnutls_datum_t * hash_concat,
@@ -269,7 +269,7 @@ _gnutls_tls_sign (gnutls_session_t session,
hash_concat, signature);
}
return _gnutls_sign (pkey->pk_algorithm, pkey->params, pkey->params_size,
return mhd_gtls_sign (pkey->pk_algorithm, pkey->params, pkey->params_size,
hash_concat, signature);
}
@@ -307,7 +307,7 @@ _gnutls_verify_sig (gnutls_cert * cert,
vdata.size = hash_concat->size;
/* verify signature */
if ((ret = _gnutls_rsa_verify (&vdata, signature, cert->params,
if ((ret = mhd_gtls_rsa_verify (&vdata, signature, cert->params,
cert->params_size, 1)) < 0)
{
gnutls_assert ();
@@ -327,7 +327,7 @@ _gnutls_verify_sig (gnutls_cert * cert,
* verify message).
*/
int
_gnutls_verify_sig_hdata (gnutls_session_t session,
mhd_gtls_verify_sig_hdata (mhd_gtls_session_t session,
gnutls_cert * cert, gnutls_datum_t * signature)
{
int ret;
@@ -335,43 +335,43 @@ _gnutls_verify_sig_hdata (gnutls_session_t session,
mac_hd_t td_md5;
mac_hd_t td_sha;
gnutls_datum_t dconcat;
gnutls_protocol_t ver = gnutls_protocol_get_version (session);
gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session);
td_md5 = _gnutls_hash_copy (session->internals.handshake_mac_handle_md5);
td_md5 = mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_md5);
if (td_md5 == NULL)
{
gnutls_assert ();
return GNUTLS_E_HASH_FAILED;
}
td_sha = _gnutls_hash_copy (session->internals.handshake_mac_handle_sha);
td_sha = mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_sha);
if (td_sha == NULL)
{
gnutls_assert ();
_gnutls_hash_deinit (td_md5, NULL);
mhd_gnutls_hash_deinit (td_md5, NULL);
return GNUTLS_E_HASH_FAILED;
}
if (ver == MHD_GNUTLS_SSL3)
{
ret = _gnutls_generate_master (session, 1);
ret = mhd_gtls_generate_master (session, 1);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
_gnutls_mac_deinit_ssl3_handshake (td_md5, concat,
mhd_gnutls_mac_deinit_ssl3_handshake (td_md5, concat,
session->security_parameters.
master_secret, TLS_MASTER_SIZE);
_gnutls_mac_deinit_ssl3_handshake (td_sha, &concat[16],
mhd_gnutls_mac_deinit_ssl3_handshake (td_sha, &concat[16],
session->security_parameters.
master_secret, TLS_MASTER_SIZE);
}
else
{
_gnutls_hash_deinit (td_md5, concat);
_gnutls_hash_deinit (td_sha, &concat[16]);
mhd_gnutls_hash_deinit (td_md5, concat);
mhd_gnutls_hash_deinit (td_sha, &concat[16]);
}
dconcat.data = concat;
@@ -392,7 +392,7 @@ _gnutls_verify_sig_hdata (gnutls_session_t session,
* Used in DHE_* ciphersuites.
*/
int
_gnutls_verify_sig_params (gnutls_session_t session,
mhd_gtls_verify_sig_params (mhd_gtls_session_t session,
gnutls_cert * cert,
const gnutls_datum_t * params,
gnutls_datum_t * signature)
@@ -402,43 +402,43 @@ _gnutls_verify_sig_params (gnutls_session_t session,
mac_hd_t td_md5 = NULL;
mac_hd_t td_sha;
opaque concat[36];
gnutls_protocol_t ver = gnutls_protocol_get_version (session);
gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session);
if (ver < MHD_GNUTLS_TLS1_2)
{
td_md5 = _gnutls_hash_init (MHD_GNUTLS_MAC_MD5);
td_md5 = mhd_gtls_hash_init (MHD_GNUTLS_MAC_MD5);
if (td_md5 == NULL)
{
gnutls_assert ();
return GNUTLS_E_HASH_FAILED;
}
_gnutls_hash (td_md5, session->security_parameters.client_random,
mhd_gnutls_hash (td_md5, session->security_parameters.client_random,
TLS_RANDOM_SIZE);
_gnutls_hash (td_md5, session->security_parameters.server_random,
mhd_gnutls_hash (td_md5, session->security_parameters.server_random,
TLS_RANDOM_SIZE);
_gnutls_hash (td_md5, params->data, params->size);
mhd_gnutls_hash (td_md5, params->data, params->size);
}
td_sha = _gnutls_hash_init (MHD_GNUTLS_MAC_SHA1);
td_sha = mhd_gtls_hash_init (MHD_GNUTLS_MAC_SHA1);
if (td_sha == NULL)
{
gnutls_assert ();
if (td_md5)
_gnutls_hash_deinit (td_md5, NULL);
mhd_gnutls_hash_deinit (td_md5, NULL);
return GNUTLS_E_HASH_FAILED;
}
_gnutls_hash (td_sha, session->security_parameters.client_random,
mhd_gnutls_hash (td_sha, session->security_parameters.client_random,
TLS_RANDOM_SIZE);
_gnutls_hash (td_sha, session->security_parameters.server_random,
mhd_gnutls_hash (td_sha, session->security_parameters.server_random,
TLS_RANDOM_SIZE);
_gnutls_hash (td_sha, params->data, params->size);
mhd_gnutls_hash (td_sha, params->data, params->size);
if (ver < MHD_GNUTLS_TLS1_2)
{
_gnutls_hash_deinit (td_md5, concat);
_gnutls_hash_deinit (td_sha, &concat[16]);
mhd_gnutls_hash_deinit (td_md5, concat);
mhd_gnutls_hash_deinit (td_sha, &concat[16]);
dconcat.size = 36;
}
else
@@ -448,13 +448,13 @@ _gnutls_verify_sig_params (gnutls_session_t session,
memcpy (concat,
"\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14",
15);
_gnutls_hash_deinit (td_sha, &concat[15]);
mhd_gnutls_hash_deinit (td_sha, &concat[15]);
dconcat.size = 35;
#else
/* No parameters field. */
memcpy (concat,
"\x30\x1f\x30\x07\x06\x05\x2b\x0e\x03\x02\x1a\x04\x14", 13);
_gnutls_hash_deinit (td_sha, &concat[13]);
mhd_gnutls_hash_deinit (td_sha, &concat[13]);
dconcat.size = 33;
#endif
}
+5 -5
View File
@@ -25,26 +25,26 @@
#ifndef GNUTLS_SIG_H
# define GNUTLS_SIG_H
int _gnutls_tls_sign_hdata (gnutls_session_t session,
int mhd_gtls_tls_sign_hdata (mhd_gtls_session_t session,
gnutls_cert * cert,
gnutls_privkey * pkey,
gnutls_datum_t * signature);
int _gnutls_tls_sign_params (gnutls_session_t session,
int mhd_gtls_tls_sign_params (mhd_gtls_session_t session,
gnutls_cert * cert,
gnutls_privkey * pkey,
gnutls_datum_t * params,
gnutls_datum_t * signature);
int _gnutls_verify_sig_hdata (gnutls_session_t session,
int mhd_gtls_verify_sig_hdata (mhd_gtls_session_t session,
gnutls_cert * cert, gnutls_datum_t * signature);
int _gnutls_verify_sig_params (gnutls_session_t session,
int mhd_gtls_verify_sig_params (mhd_gtls_session_t session,
gnutls_cert * cert,
const gnutls_datum_t * params,
gnutls_datum_t * signature);
int _gnutls_sign (gnutls_pk_algorithm_t algo,
int mhd_gtls_sign (gnutls_pk_algorithm_t algo,
mpi_t * params, int params_size,
const gnutls_datum_t * data, gnutls_datum_t * signature);
+160 -178
View File
@@ -43,7 +43,7 @@
#include <gnutls_rsa_export.h>
void
_gnutls_session_cert_type_set (gnutls_session_t session,
_gnutls_session_cert_type_set (mhd_gtls_session_t session,
gnutls_certificate_type_t ct)
{
session->security_parameters.cert_type = ct;
@@ -51,19 +51,19 @@ _gnutls_session_cert_type_set (gnutls_session_t session,
/**
* gnutls_cipher_get - Returns the currently used cipher.
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
*
* Returns: the currently used cipher.
**/
gnutls_cipher_algorithm_t
gnutls_cipher_get (gnutls_session_t session)
gnutls_cipher_get (mhd_gtls_session_t session)
{
return session->security_parameters.read_bulk_cipher_algorithm;
}
/**
* gnutls_certificate_type_get - Returns the currently used certificate type.
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
*
* The certificate type is by default X.509, unless it is negotiated
* as a TLS extension.
@@ -72,43 +72,43 @@ gnutls_cipher_get (gnutls_session_t session)
* type.
**/
gnutls_certificate_type_t
gnutls_certificate_type_get (gnutls_session_t session)
gnutls_certificate_type_get (mhd_gtls_session_t session)
{
return session->security_parameters.cert_type;
}
/**
* gnutls_kx_get - Returns the key exchange algorithm.
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
*
* Returns: the key exchange algorithm used in the last handshake.
**/
gnutls_kx_algorithm_t
gnutls_kx_get (gnutls_session_t session)
gnutls_kx_get (mhd_gtls_session_t session)
{
return session->security_parameters.kx_algorithm;
}
/**
* gnutls_mac_get - Returns the currently used mac algorithm.
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
*
* Returns: the currently used mac algorithm.
**/
gnutls_mac_algorithm_t
gnutls_mac_get (gnutls_session_t session)
gnutls_mac_get (mhd_gtls_session_t session)
{
return session->security_parameters.read_mac_algorithm;
}
/**
* gnutls_compression_get - Returns the currently used compression algorithm.
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
*
* Returns: the currently used compression method.
**/
gnutls_compression_method_t
gnutls_compression_get (gnutls_session_t session)
gnutls_compression_get (mhd_gtls_session_t session)
{
return session->security_parameters.read_compression_algorithm;
}
@@ -118,17 +118,17 @@ gnutls_compression_get (gnutls_session_t session)
* and a matching certificate exists.
*/
int
_gnutls_session_cert_type_supported (gnutls_session_t session,
mhd_gtls_session_cert_type_supported (mhd_gtls_session_t session,
gnutls_certificate_type_t cert_type)
{
unsigned i;
unsigned cert_found = 0;
gnutls_certificate_credentials_t cred;
mhd_gtls_cert_credentials_t cred;
if (session->security_parameters.entity == GNUTLS_SERVER)
{
cred
= (gnutls_certificate_credentials_t) _gnutls_get_cred (session->key,
= (mhd_gtls_cert_credentials_t) mhd_gtls_get_cred (session->key,
MHD_GNUTLS_CRD_CERTIFICATE,
NULL);
@@ -172,13 +172,13 @@ _gnutls_session_cert_type_supported (gnutls_session_t session,
* in a session struct.
*/
inline static void
deinit_internal_params (gnutls_session_t session)
deinit_internal_params (mhd_gtls_session_t session)
{
if (session->internals.params.free_dh_params)
gnutls_dh_params_deinit (session->internals.params.dh_params);
MHD_gnutls_dh_params_deinit (session->internals.params.dh_params);
if (session->internals.params.free_rsa_params)
gnutls_rsa_params_deinit (session->internals.params.rsa_params);
MHD_gnutls_rsa_params_deinit (session->internals.params.rsa_params);
memset (&session->internals.params, 0, sizeof (session->internals.params));
}
@@ -188,7 +188,7 @@ deinit_internal_params (gnutls_session_t session)
* This is used to allow further handshakes.
*/
void
_gnutls_handshake_internal_state_clear (gnutls_session_t session)
mhd_gtls_handshake_internal_state_clear (mhd_gtls_session_t session)
{
session->internals.extensions_sent_size = 0;
@@ -198,7 +198,7 @@ _gnutls_handshake_internal_state_clear (gnutls_session_t session)
session->internals.adv_version_minor = 0;
session->internals.v2_hello = 0;
memset (&session->internals.handshake_header_buffer, 0,
sizeof (handshake_header_buffer_st));
sizeof (mhd_gtls_handshake_header_buffer_st));
session->internals.adv_version_minor = 0;
session->internals.adv_version_minor = 0;
session->internals.direction = 0;
@@ -218,14 +218,14 @@ _gnutls_handshake_internal_state_clear (gnutls_session_t session)
#define MIN_DH_BITS 727
/**
* gnutls_init - This function initializes the session to null (null encryption etc...).
* MHD_gnutls_init - This function initializes the session to null (null encryption etc...).
* @con_end: indicate if this session is to be used for server or client.
* @session: is a pointer to a #gnutls_session_t structure.
* @session: is a pointer to a #mhd_gtls_session_t structure.
*
* This function initializes the current session to null. Every
* session must be initialized before use, so internal structures can
* be allocated. This function allocates structures which can only
* be free'd by calling gnutls_deinit(). Returns zero on success.
* be free'd by calling MHD_gnutls_deinit(). Returns zero on success.
*
* @con_end can be one of %GNUTLS_CLIENT and %GNUTLS_SERVER.
*
@@ -234,9 +234,9 @@ _gnutls_handshake_internal_state_clear (gnutls_session_t session)
/* TODO rm redundent pointer ref */
int
gnutls_init (gnutls_session_t * session, gnutls_connection_end_t con_end)
MHD_gnutls_init (mhd_gtls_session_t * session, gnutls_connection_end_t con_end)
{
*session = gnutls_calloc (1, sizeof (struct gnutls_session_int));
*session = gnutls_calloc (1, sizeof (struct MHD_gtls_session_int));
if (*session == NULL)
return GNUTLS_E_MEMORY_ERROR;
@@ -261,18 +261,18 @@ gnutls_init (gnutls_session_t * session, gnutls_connection_end_t con_end)
(*session)->internals.enable_private = 0;
/* Initialize buffers */
_gnutls_buffer_init (&(*session)->internals.application_data_buffer);
_gnutls_buffer_init (&(*session)->internals.handshake_data_buffer);
_gnutls_buffer_init (&(*session)->internals.handshake_hash_buffer);
_gnutls_buffer_init (&(*session)->internals.ia_data_buffer);
mhd_gtls_buffer_init (&(*session)->internals.application_data_buffer);
mhd_gtls_buffer_init (&(*session)->internals.handshake_data_buffer);
mhd_gtls_buffer_init (&(*session)->internals.handshake_hash_buffer);
mhd_gtls_buffer_init (&(*session)->internals.ia_data_buffer);
_gnutls_buffer_init (&(*session)->internals.record_send_buffer);
_gnutls_buffer_init (&(*session)->internals.record_recv_buffer);
mhd_gtls_buffer_init (&(*session)->internals.record_send_buffer);
mhd_gtls_buffer_init (&(*session)->internals.record_recv_buffer);
_gnutls_buffer_init (&(*session)->internals.handshake_send_buffer);
_gnutls_buffer_init (&(*session)->internals.handshake_recv_buffer);
mhd_gtls_buffer_init (&(*session)->internals.handshake_send_buffer);
mhd_gtls_buffer_init (&(*session)->internals.handshake_recv_buffer);
(*session)->key = gnutls_calloc (1, sizeof (struct gnutls_key_st));
(*session)->key = gnutls_calloc (1, sizeof (struct mhd_gtls_key));
if ((*session)->key == NULL)
{
cleanup_session:gnutls_free (*session);
@@ -282,11 +282,11 @@ gnutls_init (gnutls_session_t * session, gnutls_connection_end_t con_end)
(*session)->internals.expire_time = DEFAULT_EXPIRE_TIME; /* one hour default */
gnutls_dh_set_prime_bits ((*session), MIN_DH_BITS);
MHD_gnutls_dh_set_prime_bits ((*session), MIN_DH_BITS);
gnutls_transport_set_lowat ((*session), DEFAULT_LOWAT); /* the default for tcp */
MHD_gnutls_transport_set_lowat ((*session), DEFAULT_LOWAT); /* the default for tcp */
gnutls_handshake_set_max_packet_length ((*session),
MHD_gnutls_handshake_set_max_packet_length ((*session),
MAX_HANDSHAKE_PACKET_SIZE);
/* Allocate a minimum size for recv_data
@@ -316,7 +316,7 @@ gnutls_init (gnutls_session_t * session, gnutls_connection_end_t con_end)
* as NULL or 0. This is why calloc is used.
*/
_gnutls_handshake_internal_state_clear (*session);
mhd_gtls_handshake_internal_state_clear (*session);
return 0;
}
@@ -324,54 +324,54 @@ gnutls_init (gnutls_session_t * session, gnutls_connection_end_t con_end)
/* returns RESUME_FALSE or RESUME_TRUE.
*/
int
_gnutls_session_is_resumable (gnutls_session_t session)
mhd_gtls_session_is_resumable (mhd_gtls_session_t session)
{
return session->internals.resumable;
}
/**
* gnutls_deinit - This function clears all buffers associated with a session
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_deinit - This function clears all buffers associated with a session
* @session: is a #mhd_gtls_session_t structure.
*
* This function clears all buffers associated with the @session.
* This function will also remove session data from the session
* database if the session was terminated abnormally.
**/
void
gnutls_deinit (gnutls_session_t session)
MHD_gnutls_deinit (mhd_gtls_session_t session)
{
if (session == NULL)
return;
/* remove auth info firstly */
_gnutls_free_auth_info (session);
mhd_gtls_free_auth_info (session);
_gnutls_handshake_internal_state_clear (session);
mhd_gtls_handshake_internal_state_clear (session);
_gnutls_handshake_io_buffer_clear (session);
_gnutls_free_datum (&session->connection_state.read_mac_secret);
_gnutls_free_datum (&session->connection_state.write_mac_secret);
_gnutls_buffer_clear (&session->internals.ia_data_buffer);
_gnutls_buffer_clear (&session->internals.handshake_hash_buffer);
_gnutls_buffer_clear (&session->internals.handshake_data_buffer);
_gnutls_buffer_clear (&session->internals.application_data_buffer);
_gnutls_buffer_clear (&session->internals.record_recv_buffer);
_gnutls_buffer_clear (&session->internals.record_send_buffer);
mhd_gtls_buffer_clear (&session->internals.ia_data_buffer);
mhd_gtls_buffer_clear (&session->internals.handshake_hash_buffer);
mhd_gtls_buffer_clear (&session->internals.handshake_data_buffer);
mhd_gtls_buffer_clear (&session->internals.application_data_buffer);
mhd_gtls_buffer_clear (&session->internals.record_recv_buffer);
mhd_gtls_buffer_clear (&session->internals.record_send_buffer);
gnutls_credentials_clear (session);
_gnutls_selected_certs_deinit (session);
MHD_gnutls_credentials_clear (session);
mhd_gtls_selected_certs_deinit (session);
if (session->connection_state.read_cipher_state != NULL)
_gnutls_cipher_deinit (session->connection_state.read_cipher_state);
mhd_gnutls_cipher_deinit (session->connection_state.read_cipher_state);
if (session->connection_state.write_cipher_state != NULL)
_gnutls_cipher_deinit (session->connection_state.write_cipher_state);
mhd_gnutls_cipher_deinit (session->connection_state.write_cipher_state);
if (session->connection_state.read_compression_state != NULL)
_gnutls_comp_deinit (session->connection_state.read_compression_state, 1);
mhd_gtls_comp_deinit (session->connection_state.read_compression_state, 1);
if (session->connection_state.write_compression_state != NULL)
_gnutls_comp_deinit (session->connection_state.
mhd_gtls_comp_deinit (session->connection_state.
write_compression_state, 0);
_gnutls_free_datum (&session->cipher_specs.server_write_mac_secret);
@@ -383,23 +383,23 @@ gnutls_deinit (gnutls_session_t session)
if (session->key != NULL)
{
_gnutls_mpi_release (&session->key->KEY);
_gnutls_mpi_release (&session->key->client_Y);
_gnutls_mpi_release (&session->key->client_p);
_gnutls_mpi_release (&session->key->client_g);
mhd_gtls_mpi_release (&session->key->KEY);
mhd_gtls_mpi_release (&session->key->client_Y);
mhd_gtls_mpi_release (&session->key->client_p);
mhd_gtls_mpi_release (&session->key->client_g);
_gnutls_mpi_release (&session->key->u);
_gnutls_mpi_release (&session->key->a);
_gnutls_mpi_release (&session->key->x);
_gnutls_mpi_release (&session->key->A);
_gnutls_mpi_release (&session->key->B);
_gnutls_mpi_release (&session->key->b);
mhd_gtls_mpi_release (&session->key->u);
mhd_gtls_mpi_release (&session->key->a);
mhd_gtls_mpi_release (&session->key->x);
mhd_gtls_mpi_release (&session->key->A);
mhd_gtls_mpi_release (&session->key->B);
mhd_gtls_mpi_release (&session->key->b);
/* RSA */
_gnutls_mpi_release (&session->key->rsa[0]);
_gnutls_mpi_release (&session->key->rsa[1]);
mhd_gtls_mpi_release (&session->key->rsa[0]);
mhd_gtls_mpi_release (&session->key->rsa[1]);
_gnutls_mpi_release (&session->key->dh_secret);
mhd_gtls_mpi_release (&session->key->dh_secret);
gnutls_free (session->key);
session->key = NULL;
@@ -414,30 +414,30 @@ gnutls_deinit (gnutls_session_t session)
gnutls_free (session->internals.srp_password);
}
memset (session, 0, sizeof (struct gnutls_session_int));
memset (session, 0, sizeof (struct MHD_gtls_session_int));
gnutls_free (session);
}
/* Returns the minimum prime bits that are acceptable.
*/
int
_gnutls_dh_get_allowed_prime_bits (gnutls_session_t session)
mhd_gtls_dh_get_allowed_prime_bits (mhd_gtls_session_t session)
{
return session->internals.dh_prime_bits;
}
int
_gnutls_dh_set_peer_public (gnutls_session_t session, mpi_t public)
mhd_gtls_dh_set_peer_public (mhd_gtls_session_t session, mpi_t public)
{
dh_info_st *dh;
int ret;
switch (gnutls_auth_get_type (session))
switch (MHD_gtls_auth_get_type (session))
{
case MHD_GNUTLS_CRD_ANON:
{
anon_auth_info_t info;
info = _gnutls_get_auth_info (session);
mhd_anon_auth_info_t info;
info = mhd_gtls_get_auth_info (session);
if (info == NULL)
return GNUTLS_E_INTERNAL_ERROR;
@@ -448,7 +448,7 @@ _gnutls_dh_set_peer_public (gnutls_session_t session, mpi_t public)
{
cert_auth_info_t info;
info = _gnutls_get_auth_info (session);
info = mhd_gtls_get_auth_info (session);
if (info == NULL)
return GNUTLS_E_INTERNAL_ERROR;
@@ -460,7 +460,7 @@ _gnutls_dh_set_peer_public (gnutls_session_t session, mpi_t public)
return GNUTLS_E_INTERNAL_ERROR;
}
ret = _gnutls_mpi_dprint_lz (&dh->public_key, public);
ret = mhd_gtls_mpi_dprint_lz (&dh->public_key, public);
if (ret < 0)
{
gnutls_assert ();
@@ -471,14 +471,14 @@ _gnutls_dh_set_peer_public (gnutls_session_t session, mpi_t public)
}
int
_gnutls_dh_set_secret_bits (gnutls_session_t session, unsigned bits)
mhd_gtls_dh_set_secret_bits (mhd_gtls_session_t session, unsigned bits)
{
switch (gnutls_auth_get_type (session))
switch (MHD_gtls_auth_get_type (session))
{
case MHD_GNUTLS_CRD_ANON:
{
anon_auth_info_t info;
info = _gnutls_get_auth_info (session);
mhd_anon_auth_info_t info;
info = mhd_gtls_get_auth_info (session);
if (info == NULL)
return GNUTLS_E_INTERNAL_ERROR;
info->dh.secret_bits = bits;
@@ -488,7 +488,7 @@ _gnutls_dh_set_secret_bits (gnutls_session_t session, unsigned bits)
{
cert_auth_info_t info;
info = _gnutls_get_auth_info (session);
info = mhd_gtls_get_auth_info (session);
if (info == NULL)
return GNUTLS_E_INTERNAL_ERROR;
@@ -507,24 +507,24 @@ _gnutls_dh_set_secret_bits (gnutls_session_t session, unsigned bits)
* RSA exponent and the modulus.
*/
int
_gnutls_rsa_export_set_pubkey (gnutls_session_t session,
mhd_gtls_rsa_export_set_pubkey (mhd_gtls_session_t session,
mpi_t exponent, mpi_t modulus)
{
cert_auth_info_t info;
int ret;
info = _gnutls_get_auth_info (session);
info = mhd_gtls_get_auth_info (session);
if (info == NULL)
return GNUTLS_E_INTERNAL_ERROR;
ret = _gnutls_mpi_dprint_lz (&info->rsa_export.modulus, modulus);
ret = mhd_gtls_mpi_dprint_lz (&info->rsa_export.modulus, modulus);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
ret = _gnutls_mpi_dprint_lz (&info->rsa_export.exponent, exponent);
ret = mhd_gtls_mpi_dprint_lz (&info->rsa_export.exponent, exponent);
if (ret < 0)
{
gnutls_assert ();
@@ -538,17 +538,17 @@ _gnutls_rsa_export_set_pubkey (gnutls_session_t session,
/* Sets the prime and the generator in the auth info structure.
*/
int
_gnutls_dh_set_group (gnutls_session_t session, mpi_t gen, mpi_t prime)
mhd_gtls_dh_set_group (mhd_gtls_session_t session, mpi_t gen, mpi_t prime)
{
dh_info_st *dh;
int ret;
switch (gnutls_auth_get_type (session))
switch (MHD_gtls_auth_get_type (session))
{
case MHD_GNUTLS_CRD_ANON:
{
anon_auth_info_t info;
info = _gnutls_get_auth_info (session);
mhd_anon_auth_info_t info;
info = mhd_gtls_get_auth_info (session);
if (info == NULL)
return GNUTLS_E_INTERNAL_ERROR;
@@ -559,7 +559,7 @@ _gnutls_dh_set_group (gnutls_session_t session, mpi_t gen, mpi_t prime)
{
cert_auth_info_t info;
info = _gnutls_get_auth_info (session);
info = mhd_gtls_get_auth_info (session);
if (info == NULL)
return GNUTLS_E_INTERNAL_ERROR;
@@ -573,7 +573,7 @@ _gnutls_dh_set_group (gnutls_session_t session, mpi_t gen, mpi_t prime)
/* prime
*/
ret = _gnutls_mpi_dprint_lz (&dh->prime, prime);
ret = mhd_gtls_mpi_dprint_lz (&dh->prime, prime);
if (ret < 0)
{
gnutls_assert ();
@@ -582,7 +582,7 @@ _gnutls_dh_set_group (gnutls_session_t session, mpi_t gen, mpi_t prime)
/* generator
*/
ret = _gnutls_mpi_dprint_lz (&dh->generator, gen);
ret = mhd_gtls_mpi_dprint_lz (&dh->generator, gen);
if (ret < 0)
{
gnutls_assert ();
@@ -594,8 +594,8 @@ _gnutls_dh_set_group (gnutls_session_t session, mpi_t gen, mpi_t prime)
}
/**
* gnutls_openpgp_send_cert - This function will order gnutls to send the openpgp fingerprint instead of the key
* @session: is a pointer to a #gnutls_session_t structure.
* MHD_gtls_openpgp_send_cert - This function will order gnutls to send the openpgp fingerprint instead of the key
* @session: is a pointer to a #mhd_gtls_session_t structure.
* @status: is one of GNUTLS_OPENPGP_CERT, or GNUTLS_OPENPGP_CERT_FINGERPRINT
*
* This function will order gnutls to send the key fingerprint
@@ -604,15 +604,15 @@ _gnutls_dh_set_group (gnutls_session_t session, mpi_t gen, mpi_t prime)
* that the server can obtain the client's key.
**/
void
gnutls_openpgp_send_cert (gnutls_session_t session,
MHD_gtls_openpgp_send_cert (mhd_gtls_session_t session,
gnutls_openpgp_crt_status_t status)
{
session->internals.pgp_fingerprint = status;
}
/**
* gnutls_certificate_send_x509_rdn_sequence - This function will order gnutls to send or not the x.509 rdn sequence
* @session: is a pointer to a #gnutls_session_t structure.
* MHD_gnutls_certificate_send_x509_rdn_sequence - This function will order gnutls to send or not the x.509 rdn sequence
* @session: is a pointer to a #mhd_gtls_session_t structure.
* @status: is 0 or 1
*
* If status is non zero, this function will order gnutls not to send
@@ -625,21 +625,21 @@ gnutls_openpgp_send_cert (gnutls_session_t session,
* methods other than certificate with X.509 certificates.
**/
void
gnutls_certificate_send_x509_rdn_sequence (gnutls_session_t session,
MHD_gnutls_certificate_send_x509_rdn_sequence (mhd_gtls_session_t session,
int status)
{
session->internals.ignore_rdn_sequence = status;
}
int
_gnutls_openpgp_send_fingerprint (gnutls_session_t session)
mhd_gtls_openpgp_send_fingerprint (mhd_gtls_session_t session)
{
return session->internals.pgp_fingerprint;
}
/*-
* _gnutls_record_set_default_version - Used to set the default version for the first record packet
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
* @major: is a tls major version
* @minor: is a tls minor version
*
@@ -649,7 +649,7 @@ _gnutls_openpgp_send_fingerprint (gnutls_session_t session)
*
-*/
void
_gnutls_record_set_default_version (gnutls_session_t session,
_gnutls_record_set_default_version (mhd_gtls_session_t session,
unsigned char major, unsigned char minor)
{
session->internals.default_record_version[0] = major;
@@ -657,8 +657,8 @@ _gnutls_record_set_default_version (gnutls_session_t session,
}
/**
* gnutls_handshake_set_private_extensions - Used to enable the private cipher suites
* @session: is a #gnutls_session_t structure.
* MHD_gtls_handshake_set_private_extensions - Used to enable the private cipher suites
* @session: is a #mhd_gtls_session_t structure.
* @allow: is an integer (0 or 1)
*
* This function will enable or disable the use of private cipher
@@ -673,7 +673,7 @@ _gnutls_record_set_default_version (gnutls_session_t session,
* gnutls servers and clients may cause interoperability problems.
**/
void
gnutls_handshake_set_private_extensions (gnutls_session_t session, int allow)
MHD_gtls_handshake_set_private_extensions (mhd_gtls_session_t session, int allow)
{
session->internals.enable_private = allow;
}
@@ -686,15 +686,15 @@ _gnutls_cal_PRF_A (gnutls_mac_algorithm_t algorithm,
{
mac_hd_t td1;
td1 = _gnutls_hmac_init (algorithm, secret, secret_size);
td1 = mhd_gtls_hmac_init (algorithm, secret, secret_size);
if (td1 == GNUTLS_MAC_FAILED)
{
gnutls_assert ();
return GNUTLS_E_INTERNAL_ERROR;
}
_gnutls_hmac (td1, seed, seed_size);
_gnutls_hmac_deinit (td1, result);
mhd_gnutls_hash (td1, seed, seed_size);
mhd_gnutls_hmac_deinit (td1, result);
return 0;
}
@@ -723,7 +723,7 @@ _gnutls_P_hash (gnutls_mac_algorithm_t algorithm,
return GNUTLS_E_INTERNAL_ERROR;
}
blocksize = _gnutls_hmac_get_algo_len (algorithm);
blocksize = mhd_gnutls_hash_get_algo_len (algorithm);
output_bytes = 0;
do
@@ -741,7 +741,7 @@ _gnutls_P_hash (gnutls_mac_algorithm_t algorithm,
for (i = 0; i < times; i++)
{
td2 = _gnutls_hmac_init (algorithm, secret, secret_size);
td2 = mhd_gtls_hmac_init (algorithm, secret, secret_size);
if (td2 == GNUTLS_MAC_FAILED)
{
gnutls_assert ();
@@ -753,15 +753,15 @@ _gnutls_P_hash (gnutls_mac_algorithm_t algorithm,
A_size, Atmp)) < 0)
{
gnutls_assert ();
_gnutls_hmac_deinit (td2, final);
mhd_gnutls_hmac_deinit (td2, final);
return result;
}
A_size = blocksize;
_gnutls_hmac (td2, Atmp, A_size);
_gnutls_hmac (td2, seed, seed_size);
_gnutls_hmac_deinit (td2, final);
mhd_gnutls_hash (td2, Atmp, A_size);
mhd_gnutls_hash (td2, seed, seed_size);
mhd_gnutls_hmac_deinit (td2, final);
if ((1 + i) * blocksize < total_bytes)
{
@@ -800,7 +800,7 @@ _gnutls_xor (opaque * o1, opaque * o2, int length)
* available.
*/
int
_gnutls_PRF (gnutls_session_t session,
mhd_gtls_PRF (mhd_gtls_session_t session,
const opaque * secret,
int secret_size,
const char *label,
@@ -812,7 +812,7 @@ _gnutls_PRF (gnutls_session_t session,
opaque s_seed[MAX_SEED_SIZE];
opaque o1[MAX_PRF_BYTES], o2[MAX_PRF_BYTES];
int result;
gnutls_protocol_t ver = gnutls_protocol_get_version (session);
gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session);
if (total_bytes > MAX_PRF_BYTES)
{
@@ -882,8 +882,8 @@ _gnutls_PRF (gnutls_session_t session,
}
/**
* gnutls_prf_raw - access the TLS PRF directly
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_prf_raw - access the TLS PRF directly
* @session: is a #mhd_gtls_session_t structure.
* @label_size: length of the @label variable.
* @label: label used in PRF computation, typically a short string.
* @seed_size: length of the @seed variable.
@@ -904,21 +904,21 @@ _gnutls_PRF (gnutls_session_t session,
* session unless @seed include the client random and server random
* fields (the PRF would output the same data on another connection
* resumed from the first one), it is not recommended to use this
* function directly. The gnutls_prf() function seed the PRF with the
* function directly. The MHD_gnutls_prf() function seed the PRF with the
* client and server random fields directly, and is recommended if you
* want to generate pseudo random data unique for each session.
*
* Returns: %GNUTLS_E_SUCCESS on success, or an error code.
**/
int
gnutls_prf_raw (gnutls_session_t session,
MHD_gnutls_prf_raw (mhd_gtls_session_t session,
size_t label_size,
const char *label,
size_t seed_size, const char *seed, size_t outsize, char *out)
{
int ret;
ret = _gnutls_PRF (session, session->security_parameters.master_secret,
ret = mhd_gtls_PRF (session, session->security_parameters.master_secret,
TLS_MASTER_SIZE, label, label_size, (opaque *) seed,
seed_size, outsize, out);
@@ -926,8 +926,8 @@ gnutls_prf_raw (gnutls_session_t session,
}
/**
* gnutls_prf - derive pseudo-random data using the TLS PRF
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_prf - derive pseudo-random data using the TLS PRF
* @session: is a #mhd_gtls_session_t structure.
* @label_size: length of the @label variable.
* @label: label used in PRF computation, typically a short string.
* @server_random_first: non-0 if server random field should be first in seed
@@ -955,7 +955,7 @@ gnutls_prf_raw (gnutls_session_t session,
* Returns: %GNUTLS_E_SUCCESS on success, or an error code.
**/
int
gnutls_prf (gnutls_session_t session,
MHD_gnutls_prf (mhd_gtls_session_t session,
size_t label_size,
const char *label,
int server_random_first,
@@ -981,7 +981,7 @@ gnutls_prf (gnutls_session_t session,
memcpy (seed + 2 * TLS_RANDOM_SIZE, extra, extra_size);
ret = _gnutls_PRF (session, session->security_parameters.master_secret,
ret = mhd_gtls_PRF (session, session->security_parameters.master_secret,
TLS_MASTER_SIZE, label, label_size, seed, seedsize,
outsize, out);
@@ -991,8 +991,8 @@ gnutls_prf (gnutls_session_t session,
}
/**
* gnutls_session_get_client_random - get the session's client random value
* @session: is a #gnutls_session_t structure.
* MHD_gtls_session_get_client_random - get the session's client random value
* @session: is a #mhd_gtls_session_t structure.
*
* Return a pointer to the 32-byte client random field used in the
* session. The pointer must not be modified or deallocated.
@@ -1004,14 +1004,14 @@ gnutls_prf (gnutls_session_t session,
* Returns: pointer to client random data.
**/
const void *
gnutls_session_get_client_random (gnutls_session_t session)
MHD_gtls_session_get_client_random (mhd_gtls_session_t session)
{
return (char *) session->security_parameters.client_random;
}
/**
* gnutls_session_get_server_random - get the session's server random value
* @session: is a #gnutls_session_t structure.
* MHD_gtls_session_get_server_random - get the session's server random value
* @session: is a #mhd_gtls_session_t structure.
*
* Return a pointer to the 32-byte server random field used in the
* session. The pointer must not be modified or deallocated.
@@ -1023,14 +1023,14 @@ gnutls_session_get_client_random (gnutls_session_t session)
* Returns: pointer to server random data.
**/
const void *
gnutls_session_get_server_random (gnutls_session_t session)
MHD_gtls_session_get_server_random (mhd_gtls_session_t session)
{
return (char *) session->security_parameters.server_random;
}
/**
* gnutls_session_get_master_secret - get the session's master secret value
* @session: is a #gnutls_session_t structure.
* MHD_gtls_session_get_master_secret - get the session's master secret value
* @session: is a #mhd_gtls_session_t structure.
*
* Return a pointer to the 48-byte master secret in the session. The
* pointer must not be modified or deallocated.
@@ -1039,26 +1039,26 @@ gnutls_session_get_server_random (gnutls_session_t session)
* will be garbage; in particular, a %NULL return value should not be
* expected.
*
* Consider using gnutls_prf() rather than extracting the master
* Consider using MHD_gnutls_prf() rather than extracting the master
* secret and use it to derive further data.
*
* Returns: pointer to master secret data.
**/
const void *
gnutls_session_get_master_secret (gnutls_session_t session)
MHD_gtls_session_get_master_secret (mhd_gtls_session_t session)
{
return (char *) session->security_parameters.master_secret;
}
/**
* gnutls_session_is_resumed - Used to check whether this session is a resumed one
* @session: is a #gnutls_session_t structure.
* MHD_gtls_session_is_resumed - Used to check whether this session is a resumed one
* @session: is a #mhd_gtls_session_t structure.
*
* Returns: non zero if this session is resumed, or a zero if this is
* a new session.
**/
int
gnutls_session_is_resumed (gnutls_session_t session)
MHD_gtls_session_is_resumed (mhd_gtls_session_t session)
{
if (session->security_parameters.entity == GNUTLS_CLIENT)
{
@@ -1081,81 +1081,81 @@ gnutls_session_is_resumed (gnutls_session_t session)
}
/*-
* _gnutls_session_is_export - Used to check whether this session is of export grade
* @session: is a #gnutls_session_t structure.
* mhd_gtls_session_is_export - Used to check whether this session is of export grade
* @session: is a #mhd_gtls_session_t structure.
*
* This function will return non zero if this session is of export grade.
*
-*/
int
_gnutls_session_is_export (gnutls_session_t session)
mhd_gtls_session_is_export (mhd_gtls_session_t session)
{
gnutls_cipher_algorithm_t cipher;
cipher =
_gnutls_cipher_suite_get_cipher_algo (&session->security_parameters.
mhd_gtls_cipher_suite_get_cipher_algo (&session->security_parameters.
current_cipher_suite);
if (_gnutls_cipher_get_export_flag (cipher) != 0)
if (mhd_gtls_cipher_get_export_flag (cipher) != 0)
return 1;
return 0;
}
/**
* gnutls_session_get_ptr - Used to get the user pointer from the session structure
* @session: is a #gnutls_session_t structure.
* MHD_gtls_session_get_ptr - Used to get the user pointer from the session structure
* @session: is a #mhd_gtls_session_t structure.
*
* Returns: the user given pointer from the session structure. This
* is the pointer set with gnutls_session_set_ptr().
* is the pointer set with MHD_gnutls_session_set_ptr().
**/
void *
gnutls_session_get_ptr (gnutls_session_t session)
MHD_gtls_session_get_ptr (mhd_gtls_session_t session)
{
return session->internals.user_ptr;
}
/**
* gnutls_session_set_ptr - Used to set the user pointer to the session structure
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_session_set_ptr - Used to set the user pointer to the session structure
* @session: is a #mhd_gtls_session_t structure.
* @ptr: is the user pointer
*
* This function will set (associate) the user given pointer to the
* session structure. This is pointer can be accessed with
* gnutls_session_get_ptr().
* MHD_gtls_session_get_ptr().
**/
void
gnutls_session_set_ptr (gnutls_session_t session, void *ptr)
MHD_gnutls_session_set_ptr (mhd_gtls_session_t session, void *ptr)
{
session->internals.user_ptr = ptr;
}
/**
* gnutls_record_get_direction - This function will return the direction of the last interrupted function call
* @session: is a #gnutls_session_t structure.
* MHD_gnutls_record_get_direction - This function will return the direction of the last interrupted function call
* @session: is a #mhd_gtls_session_t structure.
*
* This function provides information about the internals of the
* record protocol and is only useful if a prior gnutls function call
* (e.g. gnutls_handshake()) was interrupted for some reason, that
* (e.g. MHD_gnutls_handshake()) was interrupted for some reason, that
* is, if a function returned %GNUTLS_E_INTERRUPTED or
* %GNUTLS_E_AGAIN. In such a case, you might want to call select()
* or poll() before calling the interrupted gnutls function again.
* To tell you whether a file descriptor should be selected for
* either reading or writing, gnutls_record_get_direction() returns 0
* either reading or writing, MHD_gnutls_record_get_direction() returns 0
* if the interrupted function was trying to read data, and 1 if it
* was trying to write data.
*
* Returns: 0 if trying to read data, 1 if trying to write data.
**/
int
gnutls_record_get_direction (gnutls_session_t session)
MHD_gnutls_record_get_direction (mhd_gtls_session_t session)
{
return session->internals.direction;
}
/*-
* _gnutls_rsa_pms_set_version - Sets a version to be used at the RSA PMS
* @session: is a #gnutls_session_t structure.
* @session: is a #mhd_gtls_session_t structure.
* @major: is the major version to use
* @minor: is the minor version to use
*
@@ -1165,7 +1165,7 @@ gnutls_record_get_direction (gnutls_session_t session)
*
-*/
void
_gnutls_rsa_pms_set_version (gnutls_session_t session,
_gnutls_rsa_pms_set_version (mhd_gtls_session_t session,
unsigned char major, unsigned char minor)
{
session->internals.rsa_pms_version[0] = major;
@@ -1173,8 +1173,8 @@ _gnutls_rsa_pms_set_version (gnutls_session_t session,
}
/**
* gnutls_handshake_set_post_client_hello_function - This function will a callback to be called after the client hello is received
* @res: is a gnutls_anon_server_credentials_t structure
* MHD_gnutls_handshake_set_post_client_hello_function - This function will a callback to be called after the client hello is received
* @res: is a mhd_gtls_anon_server_credentials_t structure
* @func: is the function to be called
*
* This function will set a callback to be called after the client
@@ -1195,27 +1195,9 @@ _gnutls_rsa_pms_set_version (gnutls_session_t session,
*
**/
void
gnutls_handshake_set_post_client_hello_function (gnutls_session_t session,
MHD_gnutls_handshake_set_post_client_hello_function (mhd_gtls_session_t session,
gnutls_handshake_post_client_hello_func
func)
{
session->internals.user_hello_func = func;
}
/**
* gnutls_session_enable_compatibility_mode - Used to disable certain features in TLS in order to honour compatibility
* @session: is a #gnutls_session_t structure.
*
* This function can be used to disable certain (security) features
* in TLS in order to maintain maximum compatibility with buggy
* clients. It is equivalent to calling:
* gnutls_record_disable_padding()
*
* Normally only servers that require maximum compatibility with
* everything out there, need to call this function.
**/
void
gnutls_session_enable_compatibility_mode (gnutls_session_t session)
{
gnutls_record_disable_padding (session);
}
+17 -17
View File
@@ -27,46 +27,46 @@
#include <gnutls_int.h>
void _gnutls_session_cert_type_set (gnutls_session_t session,
void _gnutls_session_cert_type_set (mhd_gtls_session_t session,
gnutls_certificate_type_t);
gnutls_kx_algorithm_t gnutls_kx_get (gnutls_session_t session);
gnutls_cipher_algorithm_t gnutls_cipher_get (gnutls_session_t session);
gnutls_certificate_type_t gnutls_certificate_type_get (gnutls_session_t);
gnutls_kx_algorithm_t gnutls_kx_get (mhd_gtls_session_t session);
gnutls_cipher_algorithm_t gnutls_cipher_get (mhd_gtls_session_t session);
gnutls_certificate_type_t gnutls_certificate_type_get (mhd_gtls_session_t);
#include <gnutls_auth_int.h>
#define CHECK_AUTH(auth, ret) if (gnutls_auth_get_type(session) != auth) { \
#define CHECK_AUTH(auth, ret) if (MHD_gtls_auth_get_type(session) != auth) { \
gnutls_assert(); \
return ret; \
}
#endif
int _gnutls_session_cert_type_supported (gnutls_session_t,
int mhd_gtls_session_cert_type_supported (mhd_gtls_session_t,
gnutls_certificate_type_t);
int _gnutls_dh_set_secret_bits (gnutls_session_t session, unsigned bits);
int mhd_gtls_dh_set_secret_bits (mhd_gtls_session_t session, unsigned bits);
int _gnutls_dh_set_peer_public (gnutls_session_t session, mpi_t public);
int _gnutls_dh_set_group (gnutls_session_t session, mpi_t gen, mpi_t prime);
int mhd_gtls_dh_set_peer_public (mhd_gtls_session_t session, mpi_t public);
int mhd_gtls_dh_set_group (mhd_gtls_session_t session, mpi_t gen, mpi_t prime);
int _gnutls_dh_get_allowed_prime_bits (gnutls_session_t session);
void _gnutls_handshake_internal_state_clear (gnutls_session_t);
int mhd_gtls_dh_get_allowed_prime_bits (mhd_gtls_session_t session);
void mhd_gtls_handshake_internal_state_clear (mhd_gtls_session_t);
int _gnutls_rsa_export_set_pubkey (gnutls_session_t session,
int mhd_gtls_rsa_export_set_pubkey (mhd_gtls_session_t session,
mpi_t exponent, mpi_t modulus);
int _gnutls_session_is_resumable (gnutls_session_t session);
int _gnutls_session_is_export (gnutls_session_t session);
int mhd_gtls_session_is_resumable (mhd_gtls_session_t session);
int mhd_gtls_session_is_export (mhd_gtls_session_t session);
int _gnutls_openpgp_send_fingerprint (gnutls_session_t session);
int mhd_gtls_openpgp_send_fingerprint (mhd_gtls_session_t session);
int _gnutls_PRF (gnutls_session_t session,
int mhd_gtls_PRF (mhd_gtls_session_t session,
const opaque * secret, int secret_size,
const char *label, int label_size,
const opaque * seed, int seed_size,
int total_bytes, void *ret);
int gnutls_init (gnutls_session_t * session, gnutls_connection_end_t con_end);
int MHD_gnutls_init (mhd_gtls_session_t * session, gnutls_connection_end_t con_end);
#define DEFAULT_CERT_TYPE MHD_GNUTLS_CRT_X509
+13 -13
View File
@@ -34,7 +34,7 @@
* They should be used only with null terminated strings.
*/
void
_gnutls_str_cat (char *dest, size_t dest_tot_size, const char *src)
mhd_gtls_str_cat (char *dest, size_t dest_tot_size, const char *src)
{
size_t str_size = strlen (src);
size_t dest_size = strlen (dest);
@@ -54,7 +54,7 @@ _gnutls_str_cat (char *dest, size_t dest_tot_size, const char *src)
}
void
_gnutls_str_cpy (char *dest, size_t dest_tot_size, const char *src)
mhd_gtls_str_cpy (char *dest, size_t dest_tot_size, const char *src)
{
size_t str_size = strlen (src);
@@ -73,7 +73,7 @@ _gnutls_str_cpy (char *dest, size_t dest_tot_size, const char *src)
}
void
_gnutls_mem_cpy (char *dest,
mhd_gtls_mem_cpy (char *dest,
size_t dest_tot_size, const char *src, size_t src_size)
{
@@ -91,7 +91,7 @@ _gnutls_mem_cpy (char *dest,
}
void
_gnutls_string_init (gnutls_string * str,
mhd_gtls_string_init (mhd_gtls_string * str,
gnutls_alloc_function alloc_func,
gnutls_realloc_function realloc_func,
gnutls_free_function free_func)
@@ -106,7 +106,7 @@ _gnutls_string_init (gnutls_string * str,
}
void
_gnutls_string_clear (gnutls_string * str)
mhd_gtls_string_clear (mhd_gtls_string * str)
{
if (str == NULL || str->data == NULL)
return;
@@ -120,7 +120,7 @@ _gnutls_string_clear (gnutls_string * str)
/* This one does not copy the string.
*/
gnutls_datum_t
_gnutls_string2datum (gnutls_string * str)
mhd_gtls_string2datum (mhd_gtls_string * str)
{
gnutls_datum_t ret;
@@ -133,7 +133,7 @@ _gnutls_string2datum (gnutls_string * str)
#define MIN_CHUNK 256
int
_gnutls_string_copy_str (gnutls_string * dest, const char *src)
mhd_gtls_string_copy_str (mhd_gtls_string * dest, const char *src)
{
size_t src_len = strlen (src);
size_t max;
@@ -163,7 +163,7 @@ _gnutls_string_copy_str (gnutls_string * dest, const char *src)
}
int
_gnutls_string_append_str (gnutls_string * dest, const char *src)
mhd_gtls_string_append_str (mhd_gtls_string * dest, const char *src)
{
size_t src_len = strlen (src);
size_t tot_len = src_len + dest->length;
@@ -196,7 +196,7 @@ _gnutls_string_append_str (gnutls_string * dest, const char *src)
}
int
_gnutls_string_append_data (gnutls_string * dest,
mhd_gtls_string_append_data (mhd_gtls_string * dest,
const void *data, size_t data_size)
{
size_t tot_len = data_size + dest->length;
@@ -229,7 +229,7 @@ _gnutls_string_append_data (gnutls_string * dest,
}
int
_gnutls_string_append_printf (gnutls_string * dest, const char *fmt, ...)
mhd_gtls_string_append_printf (mhd_gtls_string * dest, const char *fmt, ...)
{
va_list args;
int len;
@@ -242,7 +242,7 @@ _gnutls_string_append_printf (gnutls_string * dest, const char *fmt, ...)
if (len < 0 || !str)
return -1;
len = _gnutls_string_append_str (dest, str);
len = mhd_gtls_string_append_str (dest, str);
free (str);
@@ -255,7 +255,7 @@ _gnutls_string_append_printf (gnutls_string * dest, const char *fmt, ...)
* truncated hex string is returned (always null terminated).
*/
char *
_gnutls_bin2hex (const void *_old,
mhd_gtls_bin2hex (const void *_old,
size_t oldlen, char *buffer, size_t buffer_size)
{
unsigned int i, j;
@@ -274,7 +274,7 @@ _gnutls_bin2hex (const void *_old,
/* just a hex2bin function.
*/
int
_gnutls_hex2bin (const opaque * hex_data,
mhd_gtls_hex2bin (const opaque * hex_data,
int hex_size, opaque * bin_data, size_t * bin_size)
{
int i, j;

Some files were not shown because too many files have changed in this diff Show More