diff options
author | Simon Josefsson <simon@josefsson.org> | 2005-12-15 13:24:28 +0000 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2005-12-15 13:24:28 +0000 |
commit | 24214e48b4d4328d5a5afbfa19acbbbec30274c9 (patch) | |
tree | f80ae5a0d9a98f571a0ff1182265c30451cea62c | |
parent | 667527f161cb4a694a78db129cb2d4519800260b (diff) | |
download | gnutls-24214e48b4d4328d5a5afbfa19acbbbec30274c9.tar.gz |
Indent more.
53 files changed, 1317 insertions, 1111 deletions
diff --git a/Makefile.am b/Makefile.am index e6f1cee91e..2ba3c5bef4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -49,4 +49,4 @@ release: cvs commit -m "Update." manual/ reference/ releases/ indent: - indent `ls {lib,lib/x509,libextra,libextra/openpgp,src,tests}/*.{c,h} | grep -v -- -gaa` + indent `ls includes/gnutls/*.h{,.in} {lib,lib/x509,libextra,libextra/openpgp,src,tests}/*.{c,h} | grep -v -- -gaa` diff --git a/includes/gnutls/extra.h b/includes/gnutls/extra.h index a3f166f72f..cc7b80c41a 100644 --- a/includes/gnutls/extra.h +++ b/includes/gnutls/extra.h @@ -32,7 +32,8 @@ #include <gnutls/gnutls.h> #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif #define LIBGNUTLS_EXTRA_VERSION LIBGNUTLS_VERSION @@ -53,36 +54,46 @@ extern "C" { * gnutls_openpgp_set_recv_key_function(). * */ -typedef int (*gnutls_openpgp_recv_key_func) (gnutls_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 func); - -int gnutls_certificate_set_openpgp_key_file( gnutls_certificate_credentials_t res, - const char *CERTFILE, const char* KEYFILE); -int gnutls_certificate_set_openpgp_key_mem( gnutls_certificate_credentials_t res, - const gnutls_datum_t* CERT, const gnutls_datum_t* KEY); - -int gnutls_certificate_set_openpgp_keyserver(gnutls_certificate_credentials_t res, - const char* keyserver, int port); - -int gnutls_certificate_set_openpgp_trustdb(gnutls_certificate_credentials_t res, - const char* trustdb); - -int gnutls_certificate_set_openpgp_keyring_mem( - gnutls_certificate_credentials_t c, - const unsigned char *data, size_t dlen ); - -int gnutls_certificate_set_openpgp_keyring_file( gnutls_certificate_credentials_t c, - const char *file); + typedef int (*gnutls_openpgp_recv_key_func) (gnutls_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 + func); + + int + gnutls_certificate_set_openpgp_key_file (gnutls_certificate_credentials_t + res, const char *CERTFILE, + const char *KEYFILE); + int gnutls_certificate_set_openpgp_key_mem (gnutls_certificate_credentials_t + res, + const gnutls_datum_t * CERT, + const gnutls_datum_t * KEY); + + int + gnutls_certificate_set_openpgp_keyserver (gnutls_certificate_credentials_t + res, const char *keyserver, + int port); + + int gnutls_certificate_set_openpgp_trustdb (gnutls_certificate_credentials_t + res, const char *trustdb); + + int + gnutls_certificate_set_openpgp_keyring_mem + (gnutls_certificate_credentials_t c, const unsigned char *data, + size_t dlen); + + int + gnutls_certificate_set_openpgp_keyring_file + (gnutls_certificate_credentials_t c, const char *file); /* TLS/IA stuff */ - typedef enum { + typedef enum + { GNUTLS_IA_APPLICATION_PAYLOAD = 0, GNUTLS_IA_INTERMEDIATE_PHASE_FINISHED = 1, GNUTLS_IA_FINAL_PHASE_FINISHED = 2 @@ -93,41 +104,45 @@ int gnutls_certificate_set_openpgp_keyring_file( gnutls_certificate_credentials_ typedef int (*gnutls_ia_avp_func) (gnutls_session_t session, void *ptr, const char *last, size_t lastlen, - char **new, size_t *newlen); + char **new, size_t * newlen); - typedef struct gnutls_ia_server_credentials_st* gnutls_ia_server_credentials_t; - typedef struct gnutls_ia_client_credentials_st* gnutls_ia_client_credentials_t; + typedef struct gnutls_ia_server_credentials_st + *gnutls_ia_server_credentials_t; + typedef struct gnutls_ia_client_credentials_st + *gnutls_ia_client_credentials_t; /* Allocate and free TLS/IA credentials. */ extern void - gnutls_ia_free_client_credentials(gnutls_ia_client_credentials_t sc); + gnutls_ia_free_client_credentials (gnutls_ia_client_credentials_t sc); extern int - gnutls_ia_allocate_client_credentials(gnutls_ia_client_credentials_t * sc); + gnutls_ia_allocate_client_credentials (gnutls_ia_client_credentials_t * + sc); extern void - gnutls_ia_free_server_credentials(gnutls_ia_server_credentials_t sc); + gnutls_ia_free_server_credentials (gnutls_ia_server_credentials_t sc); extern int - gnutls_ia_allocate_server_credentials(gnutls_ia_server_credentials_t * sc); + gnutls_ia_allocate_server_credentials (gnutls_ia_server_credentials_t * + sc); /* Client TLS/IA credential functions. */ extern void - gnutls_ia_set_client_avp_function(gnutls_ia_client_credentials_t cred, - gnutls_ia_avp_func avp_func); + gnutls_ia_set_client_avp_function (gnutls_ia_client_credentials_t cred, + gnutls_ia_avp_func avp_func); extern void - gnutls_ia_set_client_avp_ptr (gnutls_ia_client_credentials_t cred, - void *ptr); - extern void * - gnutls_ia_get_client_avp_ptr (gnutls_ia_client_credentials_t cred); + gnutls_ia_set_client_avp_ptr (gnutls_ia_client_credentials_t cred, + void *ptr); + extern void *gnutls_ia_get_client_avp_ptr (gnutls_ia_client_credentials_t + cred); /* Server TLS/IA credential functions. */ extern void - gnutls_ia_set_server_avp_function(gnutls_ia_server_credentials_t cred, - gnutls_ia_avp_func avp_func); + gnutls_ia_set_server_avp_function (gnutls_ia_server_credentials_t cred, + gnutls_ia_avp_func avp_func); extern void - gnutls_ia_set_server_avp_ptr (gnutls_ia_server_credentials_t cred, - void *ptr); - extern void * - gnutls_ia_get_server_avp_ptr (gnutls_ia_server_credentials_t cred); + gnutls_ia_set_server_avp_ptr (gnutls_ia_server_credentials_t cred, + void *ptr); + extern void *gnutls_ia_get_server_avp_ptr (gnutls_ia_server_credentials_t + cred); /* TLS/IA handshake. */ extern int gnutls_ia_handshake_p (gnutls_session_t session); @@ -136,35 +151,32 @@ int gnutls_certificate_set_openpgp_keyring_file( gnutls_certificate_credentials_ /* TLS/IA low level interface. */ extern int - gnutls_ia_permute_inner_secret (gnutls_session_t session, - size_t session_keys_size, - const char *session_keys); - extern int - gnutls_ia_endphase_send(gnutls_session_t session, int final_p); + gnutls_ia_permute_inner_secret (gnutls_session_t session, + size_t session_keys_size, + const char *session_keys); + extern int gnutls_ia_endphase_send (gnutls_session_t session, int final_p); extern ssize_t - gnutls_ia_send(gnutls_session_t session, char *data, size_t datal); + gnutls_ia_send (gnutls_session_t session, char *data, size_t datal); extern ssize_t - gnutls_ia_recv(gnutls_session_t session, char *data, size_t datal); + gnutls_ia_recv (gnutls_session_t session, char *data, size_t datal); /* Utility stuff. */ extern int - gnutls_ia_generate_challenge (gnutls_session_t session, - size_t buffer_size, - char *buffer); + gnutls_ia_generate_challenge (gnutls_session_t session, + size_t buffer_size, char *buffer); extern void - gnutls_ia_extract_inner_secret (gnutls_session_t session, - char *buffer); + gnutls_ia_extract_inner_secret (gnutls_session_t session, char *buffer); /* Toggle whether inner phases are required. */ extern void - gnutls_ia_require_inner_phase (gnutls_session_t session, int require); + gnutls_ia_require_inner_phase (gnutls_session_t session, int require); -int gnutls_global_init_extra(void); + int gnutls_global_init_extra (void); /* returns libgnutls-extra version (call it with a NULL argument) */ -const char* gnutls_extra_check_version( const char *req_version); + const char *gnutls_extra_check_version (const char *req_version); #ifdef __cplusplus } diff --git a/includes/gnutls/gnutls.h.in b/includes/gnutls/gnutls.h.in index 7c752cfc7d..5c6607f21e 100644 --- a/includes/gnutls/gnutls.h.in +++ b/includes/gnutls/gnutls.h.in @@ -37,7 +37,8 @@ # define GNUTLS_H #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif #define LIBGNUTLS_VERSION "@VERSION@" @@ -48,72 +49,72 @@ extern "C" { #define LIBGNUTLS_VERSION_NUMBER @NUMBER_VERSION@ -@POSSIBLY_WARN_ABOUT_MISSING_FEATURES@ - + @POSSIBLY_WARN_ABOUT_MISSING_FEATURES @ /* Get size_t. */ #include <stddef.h> - /* Get ssize_t. */ #ifndef HAVE_SSIZE_T # define HAVE_SSIZE_T -@DEFINE_SSIZE_T@ + @DEFINE_SSIZE_T @ #endif - /* Get time_t. */ #include <time.h> - #include <gnutls/compat.h> - #define GNUTLS_CIPHER_RIJNDAEL_128_CBC GNUTLS_CIPHER_AES_128_CBC #define GNUTLS_CIPHER_RIJNDAEL_256_CBC GNUTLS_CIPHER_AES_256_CBC #define GNUTLS_CIPHER_RIJNDAEL_CBC GNUTLS_CIPHER_AES_128_CBC #define GNUTLS_CIPHER_ARCFOUR GNUTLS_CIPHER_ARCFOUR_128 - -typedef enum gnutls_cipher_algorithm { GNUTLS_CIPHER_NULL = 1, + typedef enum gnutls_cipher_algorithm + { GNUTLS_CIPHER_NULL = 1, GNUTLS_CIPHER_ARCFOUR_128, GNUTLS_CIPHER_3DES_CBC, GNUTLS_CIPHER_AES_128_CBC, GNUTLS_CIPHER_AES_256_CBC, GNUTLS_CIPHER_ARCFOUR_40, GNUTLS_CIPHER_RC2_40_CBC = 90, GNUTLS_CIPHER_DES_CBC -} gnutls_cipher_algorithm_t; + } gnutls_cipher_algorithm_t; -typedef enum { GNUTLS_KX_RSA=1, GNUTLS_KX_DHE_DSS, + typedef enum + { GNUTLS_KX_RSA = 1, GNUTLS_KX_DHE_DSS, GNUTLS_KX_DHE_RSA, GNUTLS_KX_ANON_DH, GNUTLS_KX_SRP, GNUTLS_KX_RSA_EXPORT, GNUTLS_KX_SRP_RSA, GNUTLS_KX_SRP_DSS, GNUTLS_KX_PSK, GNUTLS_KX_DHE_PSK -} gnutls_kx_algorithm_t; - -typedef enum { GNUTLS_PARAMS_RSA_EXPORT=1, - GNUTLS_PARAMS_DH -} gnutls_params_type_t; - -typedef enum { - GNUTLS_CRD_CERTIFICATE=1, - GNUTLS_CRD_ANON, - GNUTLS_CRD_SRP, - GNUTLS_CRD_PSK, - GNUTLS_CRD_IA -} gnutls_credentials_type_t; + } gnutls_kx_algorithm_t; + + typedef enum + { GNUTLS_PARAMS_RSA_EXPORT = 1, + GNUTLS_PARAMS_DH + } gnutls_params_type_t; + + typedef enum + { + GNUTLS_CRD_CERTIFICATE = 1, + GNUTLS_CRD_ANON, + GNUTLS_CRD_SRP, + GNUTLS_CRD_PSK, + GNUTLS_CRD_IA + } gnutls_credentials_type_t; #define GNUTLS_MAC_SHA GNUTLS_MAC_SHA1 #define GNUTLS_DIG_SHA GNUTLS_DIG_SHA1 -typedef enum { - GNUTLS_MAC_UNKNOWN = 0, - GNUTLS_MAC_NULL = 1, - GNUTLS_MAC_MD5, - GNUTLS_MAC_SHA1, - GNUTLS_MAC_RMD160, - GNUTLS_MAC_MD2 -} gnutls_mac_algorithm_t; + typedef enum + { + GNUTLS_MAC_UNKNOWN = 0, + GNUTLS_MAC_NULL = 1, + GNUTLS_MAC_MD5, + GNUTLS_MAC_SHA1, + GNUTLS_MAC_RMD160, + GNUTLS_MAC_MD2 + } gnutls_mac_algorithm_t; /* The enumerations here should have the same value with gnutls_mac_algorithm_t. */ -typedef enum { - GNUTLS_DIG_NULL=1, - GNUTLS_DIG_MD5, - GNUTLS_DIG_SHA1, - GNUTLS_DIG_RMD160, - GNUTLS_DIG_MD2 -} gnutls_digest_algorithm_t; + typedef enum + { + GNUTLS_DIG_NULL = 1, + GNUTLS_DIG_MD5, + GNUTLS_DIG_SHA1, + GNUTLS_DIG_RMD160, + GNUTLS_DIG_MD2 + } gnutls_digest_algorithm_t; /* exported for other gnutls headers. This is the maximum number * of algorithms (ciphers, kx or macs). @@ -121,559 +122,697 @@ typedef enum { #define GNUTLS_MAX_ALGORITHM_NUM 16 #define GNUTLS_COMP_ZLIB GNUTLS_COMP_DEFLATE -typedef enum { GNUTLS_COMP_NULL=1, - GNUTLS_COMP_DEFLATE, - GNUTLS_COMP_LZO /* only available if gnutls-extra has been initialized - */ -} gnutls_compression_method_t; - -typedef enum { GNUTLS_SERVER=1, GNUTLS_CLIENT } gnutls_connection_end_t; - -typedef enum { GNUTLS_AL_WARNING=1, GNUTLS_AL_FATAL } gnutls_alert_level_t; - -typedef enum { GNUTLS_A_CLOSE_NOTIFY, - GNUTLS_A_UNEXPECTED_MESSAGE=10, GNUTLS_A_BAD_RECORD_MAC=20, - GNUTLS_A_DECRYPTION_FAILED, GNUTLS_A_RECORD_OVERFLOW, GNUTLS_A_DECOMPRESSION_FAILURE=30, - GNUTLS_A_HANDSHAKE_FAILURE=40, GNUTLS_A_SSL3_NO_CERTIFICATE=41, - GNUTLS_A_BAD_CERTIFICATE=42, GNUTLS_A_UNSUPPORTED_CERTIFICATE, - GNUTLS_A_CERTIFICATE_REVOKED, GNUTLS_A_CERTIFICATE_EXPIRED, GNUTLS_A_CERTIFICATE_UNKNOWN, - GNUTLS_A_ILLEGAL_PARAMETER, GNUTLS_A_UNKNOWN_CA, GNUTLS_A_ACCESS_DENIED, GNUTLS_A_DECODE_ERROR=50, - GNUTLS_A_DECRYPT_ERROR, GNUTLS_A_EXPORT_RESTRICTION=60, GNUTLS_A_PROTOCOL_VERSION=70, - GNUTLS_A_INSUFFICIENT_SECURITY, GNUTLS_A_INTERNAL_ERROR=80, GNUTLS_A_USER_CANCELED=90, - GNUTLS_A_NO_RENEGOTIATION=100, GNUTLS_A_UNSUPPORTED_EXTENSION=110, - GNUTLS_A_CERTIFICATE_UNOBTAINABLE=111, GNUTLS_A_UNRECOGNIZED_NAME=112, - GNUTLS_A_UNKNOWN_SRP_USERNAME=120, GNUTLS_A_MISSING_SRP_USERNAME=121, - GNUTLS_A_INNER_APPLICATION_FAILURE=208, - GNUTLS_A_INNER_APPLICATION_VERIFICATION=209 -} gnutls_alert_description_t; - -typedef enum { GNUTLS_HANDSHAKE_HELLO_REQUEST, + typedef enum + { GNUTLS_COMP_NULL = 1, + GNUTLS_COMP_DEFLATE, + GNUTLS_COMP_LZO /* only available if gnutls-extra has been initialized + */ + } gnutls_compression_method_t; + + typedef enum + { GNUTLS_SERVER = 1, GNUTLS_CLIENT } gnutls_connection_end_t; + + typedef enum + { GNUTLS_AL_WARNING = 1, GNUTLS_AL_FATAL } gnutls_alert_level_t; + + typedef enum + { GNUTLS_A_CLOSE_NOTIFY, + GNUTLS_A_UNEXPECTED_MESSAGE = 10, GNUTLS_A_BAD_RECORD_MAC = 20, + GNUTLS_A_DECRYPTION_FAILED, GNUTLS_A_RECORD_OVERFLOW, + GNUTLS_A_DECOMPRESSION_FAILURE = 30, + GNUTLS_A_HANDSHAKE_FAILURE = 40, GNUTLS_A_SSL3_NO_CERTIFICATE = 41, + GNUTLS_A_BAD_CERTIFICATE = 42, GNUTLS_A_UNSUPPORTED_CERTIFICATE, + GNUTLS_A_CERTIFICATE_REVOKED, GNUTLS_A_CERTIFICATE_EXPIRED, + GNUTLS_A_CERTIFICATE_UNKNOWN, + GNUTLS_A_ILLEGAL_PARAMETER, GNUTLS_A_UNKNOWN_CA, GNUTLS_A_ACCESS_DENIED, + GNUTLS_A_DECODE_ERROR = 50, + GNUTLS_A_DECRYPT_ERROR, GNUTLS_A_EXPORT_RESTRICTION = + 60, GNUTLS_A_PROTOCOL_VERSION = 70, + GNUTLS_A_INSUFFICIENT_SECURITY, GNUTLS_A_INTERNAL_ERROR = + 80, GNUTLS_A_USER_CANCELED = 90, + GNUTLS_A_NO_RENEGOTIATION = 100, GNUTLS_A_UNSUPPORTED_EXTENSION = 110, + GNUTLS_A_CERTIFICATE_UNOBTAINABLE = 111, GNUTLS_A_UNRECOGNIZED_NAME = 112, + GNUTLS_A_UNKNOWN_SRP_USERNAME = 120, GNUTLS_A_MISSING_SRP_USERNAME = 121, + GNUTLS_A_INNER_APPLICATION_FAILURE = 208, + GNUTLS_A_INNER_APPLICATION_VERIFICATION = 209 + } gnutls_alert_description_t; + + typedef enum + { GNUTLS_HANDSHAKE_HELLO_REQUEST, GNUTLS_HANDSHAKE_CLIENT_HELLO, GNUTLS_HANDSHAKE_SERVER_HELLO, - GNUTLS_HANDSHAKE_CERTIFICATE_PKT=11, GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE, + GNUTLS_HANDSHAKE_CERTIFICATE_PKT = + 11, GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE, GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST, GNUTLS_HANDSHAKE_SERVER_HELLO_DONE, GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY, GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE, - GNUTLS_HANDSHAKE_FINISHED=20 -} gnutls_handshake_description_t; + GNUTLS_HANDSHAKE_FINISHED = 20 + } gnutls_handshake_description_t; /* Note that the status bits have different meanings * in openpgp keys and x.509 certificate verification. */ -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 - */ + 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 + */ /* Those are extra information about the verification * process. Will be set only if the certificate was * not verified. */ - GNUTLS_CERT_SIGNER_NOT_FOUND=64, - GNUTLS_CERT_SIGNER_NOT_CA=128, - GNUTLS_CERT_INSECURE_ALGORITHM=256 -} gnutls_certificate_status_t; + GNUTLS_CERT_SIGNER_NOT_FOUND = 64, + GNUTLS_CERT_SIGNER_NOT_CA = 128, + GNUTLS_CERT_INSECURE_ALGORITHM = 256 + } gnutls_certificate_status_t; -typedef enum { GNUTLS_CERT_IGNORE, GNUTLS_CERT_REQUEST=1, GNUTLS_CERT_REQUIRE } gnutls_certificate_request_t; + typedef enum + { GNUTLS_CERT_IGNORE, GNUTLS_CERT_REQUEST = 1, GNUTLS_CERT_REQUIRE + } gnutls_certificate_request_t; -typedef enum { GNUTLS_OPENPGP_KEY, + typedef enum + { GNUTLS_OPENPGP_KEY, GNUTLS_OPENPGP_KEY_FINGERPRINT -} gnutls_openpgp_key_status_t; + } gnutls_openpgp_key_status_t; -typedef enum { GNUTLS_SHUT_RDWR=0, GNUTLS_SHUT_WR=1 } gnutls_close_request_t; + typedef enum + { GNUTLS_SHUT_RDWR = 0, GNUTLS_SHUT_WR = 1 } gnutls_close_request_t; #define GNUTLS_TLS1 GNUTLS_TLS1_0 -typedef enum { - GNUTLS_SSL3 = 1, - GNUTLS_TLS1_0, - GNUTLS_TLS1_1, - GNUTLS_VERSION_UNKNOWN = 0xff -} gnutls_protocol_t; + typedef enum + { + GNUTLS_SSL3 = 1, + GNUTLS_TLS1_0, + GNUTLS_TLS1_1, + GNUTLS_VERSION_UNKNOWN = 0xff + } gnutls_protocol_t; -typedef enum { GNUTLS_CRT_X509=1, GNUTLS_CRT_OPENPGP -} gnutls_certificate_type_t; + typedef enum + { GNUTLS_CRT_X509 = 1, GNUTLS_CRT_OPENPGP + } gnutls_certificate_type_t; -typedef enum { GNUTLS_X509_FMT_DER, - GNUTLS_X509_FMT_PEM } gnutls_x509_crt_fmt_t; + typedef enum + { GNUTLS_X509_FMT_DER, + GNUTLS_X509_FMT_PEM + } gnutls_x509_crt_fmt_t; -typedef enum { GNUTLS_PK_UNKNOWN=0, GNUTLS_PK_RSA = 1, GNUTLS_PK_DSA -} gnutls_pk_algorithm_t; + typedef enum + { GNUTLS_PK_UNKNOWN = 0, GNUTLS_PK_RSA = 1, GNUTLS_PK_DSA + } gnutls_pk_algorithm_t; -const char *gnutls_pk_algorithm_get_name( gnutls_pk_algorithm_t algorithm); + 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, GNUTLS_SIGN_RSA_SHA1 = 1, GNUTLS_SIGN_DSA_SHA1, + typedef enum + { GNUTLS_SIGN_UNKNOWN = 0, GNUTLS_SIGN_RSA_SHA1 = 1, GNUTLS_SIGN_DSA_SHA1, GNUTLS_SIGN_RSA_MD5, GNUTLS_SIGN_RSA_MD2, GNUTLS_SIGN_RSA_RMD160 -} gnutls_sign_algorithm_t; + } gnutls_sign_algorithm_t; -const char *gnutls_sign_algorithm_get_name( gnutls_sign_algorithm_t algorithm); + 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 gnutls_session_int; + typedef struct gnutls_session_int *gnutls_session_t; -struct gnutls_dh_params_int; -typedef struct gnutls_dh_params_int* gnutls_dh_params_t; + struct gnutls_dh_params_int; + typedef struct gnutls_dh_params_int *gnutls_dh_params_t; -struct gnutls_x509_privkey_int; /* XXX ugly. */ -typedef struct gnutls_x509_privkey_int* gnutls_rsa_params_t; /* XXX ugly. */ + struct gnutls_x509_privkey_int; /* XXX ugly. */ + typedef struct gnutls_x509_privkey_int *gnutls_rsa_params_t; /* XXX ugly. */ -typedef struct { - unsigned char * data; + typedef struct + { + unsigned char *data; unsigned int size; -} gnutls_datum_t; + } gnutls_datum_t; /* internal functions */ -int gnutls_init(gnutls_session_t * session, gnutls_connection_end_t con_end); -void gnutls_deinit(gnutls_session_t session); + 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 gnutls_bye( gnutls_session_t session, gnutls_close_request_t how); + int gnutls_bye (gnutls_session_t session, gnutls_close_request_t how); -int gnutls_handshake( gnutls_session_t session); -int gnutls_rehandshake( gnutls_session_t session); + int gnutls_handshake (gnutls_session_t session); + int gnutls_rehandshake (gnutls_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); + 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); + 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_cipher_get_key_size (gnutls_cipher_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); + 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); /* error functions */ -int gnutls_error_is_fatal( int error); -int gnutls_error_to_alert( int err, int* level); + int gnutls_error_is_fatal (int error); + int gnutls_error_to_alert (int err, int *level); -void gnutls_perror( int error); -const char* gnutls_strerror( int error); + void gnutls_perror (int error); + const char *gnutls_strerror (int error); /* Semi-internal 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); + 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); /* Record layer functions. */ -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); + 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 -int gnutls_record_get_direction(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_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); + 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 (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); + 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; + 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 gnutls_server_name_set (gnutls_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 gnutls_server_name_get (gnutls_session_t session, + void *data, size_t * data_length, + unsigned int *type, unsigned int indx); -typedef enum { - GNUTLS_IA_DISABLED = 0, - GNUTLS_IA_APP_PHASE_ON_RESUMPTION_NO = 1, - GNUTLS_IA_APP_PHASE_ON_RESUMPTION_YES = 2 -} gnutls_ia_mode_t; + typedef enum + { + GNUTLS_IA_DISABLED = 0, + GNUTLS_IA_APP_PHASE_ON_RESUMPTION_NO = 1, + GNUTLS_IA_APP_PHASE_ON_RESUMPTION_YES = 2 + } gnutls_ia_mode_t; /* 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 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); /* if you just want some defaults, use the following. */ -int gnutls_set_default_priority(gnutls_session_t session); -int gnutls_set_default_export_priority(gnutls_session_t session); + 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); + 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); /* get the currently used protocol version */ -gnutls_protocol_t gnutls_protocol_get_version(gnutls_session_t session); + gnutls_protocol_t gnutls_protocol_get_version (gnutls_session_t session); -const char *gnutls_protocol_get_name(gnutls_protocol_t version); + const char *gnutls_protocol_get_name (gnutls_protocol_t version); /* 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* data); + 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 * 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 gnutls_session_get_id (gnutls_session_t session, void *session_id, + size_t * session_id_size); /* returns the client/server random fields. */ -const char *gnutls_session_get_server_random (gnutls_session_t session); -const char *gnutls_session_get_client_random (gnutls_session_t session); + const char *gnutls_session_get_server_random (gnutls_session_t session); + const char *gnutls_session_get_client_random (gnutls_session_t session); /* checks if this session is a resumed one */ -int gnutls_session_is_resumed(gnutls_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); - -void gnutls_handshake_set_max_packet_length( gnutls_session_t session, int max); + int gnutls_session_is_resumed (gnutls_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); + + void gnutls_handshake_set_max_packet_length (gnutls_session_t session, + int max); /* returns libgnutls version (call it with a NULL argument) */ -const char* gnutls_check_version( const char *req_version); + const char *gnutls_check_version (const char *req_version); /* Functions for setting/clearing credentials */ -void gnutls_credentials_clear( gnutls_session_t session); + void gnutls_credentials_clear (gnutls_session_t session); /* cred is a structure defined by the kx algorithm */ -int gnutls_credentials_set( gnutls_session_t session, - gnutls_credentials_type_t type, - void* cred); + int gnutls_credentials_set (gnutls_session_t session, + gnutls_credentials_type_t type, void *cred); #define gnutls_cred_set gnutls_credentials_set /* Credential structures for SRP - used in gnutls_credentials_set(); */ -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; - -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 gnutls_anon_free_client_credentials( gnutls_anon_client_credentials_t sc); -int gnutls_anon_allocate_client_credentials( gnutls_anon_client_credentials_t *sc); + 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; + + 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 gnutls_anon_free_client_credentials (gnutls_anon_client_credentials_t + sc); + int + gnutls_anon_allocate_client_credentials (gnutls_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); -int gnutls_certificate_allocate_credentials( gnutls_certificate_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 gnutls_certificate_set_dh_params(gnutls_certificate_credentials_t res, - gnutls_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); - -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 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 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); - -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); + void gnutls_certificate_free_credentials (gnutls_certificate_credentials_t + sc); + int + gnutls_certificate_allocate_credentials (gnutls_certificate_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 gnutls_certificate_set_dh_params (gnutls_certificate_credentials_t res, + gnutls_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); + + 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 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 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); + + 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. */ -struct gnutls_x509_privkey_int; -typedef struct gnutls_x509_privkey_int* gnutls_x509_privkey_t; + struct gnutls_x509_privkey_int; + typedef struct gnutls_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_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; + struct gnutls_x509_crt_int; + 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 (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); /* 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); -typedef int (*gnutls_is_secure_function)(const void*); -typedef void (*gnutls_free_function)(void*); -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); + 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); + typedef int (*gnutls_is_secure_function) (const void *); + typedef void (*gnutls_free_function) (void *); + 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); /* For use in callbacks */ -extern gnutls_alloc_function gnutls_malloc; -extern gnutls_alloc_function gnutls_secure_malloc; -extern gnutls_realloc_function gnutls_realloc; -extern gnutls_calloc_function gnutls_calloc; -extern gnutls_free_function gnutls_free; + extern gnutls_alloc_function gnutls_malloc; + extern gnutls_alloc_function gnutls_secure_malloc; + extern gnutls_realloc_function gnutls_realloc; + extern gnutls_calloc_function gnutls_calloc; + extern gnutls_free_function gnutls_free; -extern char* (*gnutls_strdup)( const char*); + 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); + 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); /* 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 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); /* RSA params */ -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); + 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); /* Session stuff */ -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); + 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); -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); + 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 gnutls_transport_set_lowat( gnutls_session_t session, int num); + 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_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); /* session specific */ -void gnutls_session_set_ptr(gnutls_session_t session, void* ptr); -void* gnutls_session_get_ptr(gnutls_session_t session); + void gnutls_session_set_ptr (gnutls_session_t session, void *ptr); + void *gnutls_session_get_ptr (gnutls_session_t session); -void gnutls_openpgp_send_key(gnutls_session_t session, gnutls_openpgp_key_status_t status); + void gnutls_openpgp_send_key (gnutls_session_t session, + gnutls_openpgp_key_status_t status); /* fingerprint * Actually this function returns the hash of the given data. */ -int gnutls_fingerprint(gnutls_digest_algorithm_t algo, const gnutls_datum_t* data, - void* result, size_t* result_size); + int gnutls_fingerprint (gnutls_digest_algorithm_t algo, + const gnutls_datum_t * data, void *result, + size_t * result_size); /* SRP */ -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, char *username, 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); + 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, + char *username, 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, unsigned int, - 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); + 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, + unsigned int, 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; - -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* key, unsigned int flags); -typedef enum gnutls_psk_key_flags { + typedef struct gnutls_psk_server_credentials_st + *gnutls_psk_server_credentials_t; + typedef struct gnutls_psk_client_credentials_st + *gnutls_psk_client_credentials_t; + + 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 * key, + unsigned int flags); + typedef enum gnutls_psk_key_flags + { GNUTLS_PSK_KEY_RAW = 0, GNUTLS_PSK_KEY_HEX -} gnutls_psk_key_flags; - -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* 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); + } gnutls_psk_key_flags; + + 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 * 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); #ifndef GNUTLS_UI_H # define GNUTLS_UI_H - typedef enum gnutls_x509_subject_alt_name_t { + typedef enum gnutls_x509_subject_alt_name_t + { GNUTLS_SAN_DNSNAME = 1, GNUTLS_SAN_RFC822NAME, GNUTLS_SAN_URI, GNUTLS_SAN_IPADDRESS } gnutls_x509_subject_alt_name_t; @@ -686,15 +825,18 @@ void gnutls_psk_set_server_dh_params( gnutls_psk_server_credentials_t res, gnutl struct gnutls_openpgp_privkey_int; typedef struct gnutls_openpgp_privkey_int *gnutls_openpgp_privkey_t; - typedef struct gnutls_retr_st { + typedef struct gnutls_retr_st + { gnutls_certificate_type_t type; - union cert { + union cert + { gnutls_x509_crt_t *x509; gnutls_openpgp_key_t pgp; } cert; unsigned int ncerts; /* one for pgp keys */ - union key { + union key + { gnutls_x509_privkey_t x509; gnutls_openpgp_privkey_t pgp; } key; @@ -702,92 +844,94 @@ void gnutls_psk_set_server_dh_params( gnutls_psk_server_credentials_t res, gnutl 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 (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 *); /* Functions that allow auth_info_t structures handling */ - gnutls_credentials_type_t gnutls_auth_get_type(gnutls_session_t session); - gnutls_credentials_type_t - gnutls_auth_server_get_type(gnutls_session_t session); - gnutls_credentials_type_t - gnutls_auth_client_get_type(gnutls_session_t session); + gnutls_credentials_type_t gnutls_auth_get_type (gnutls_session_t session); + gnutls_credentials_type_t + gnutls_auth_server_get_type (gnutls_session_t session); + gnutls_credentials_type_t + gnutls_auth_client_get_type (gnutls_session_t session); /* DH */ - 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); + 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 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); + 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); + 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 */ /* These are set on the credentials structure. */ void gnutls_certificate_client_set_retrieve_function - (gnutls_certificate_credentials_t cred, - gnutls_certificate_client_retrieve_function * func); + (gnutls_certificate_credentials_t cred, + gnutls_certificate_client_retrieve_function * func); void gnutls_certificate_server_set_retrieve_function - (gnutls_certificate_credentials_t cred, - gnutls_certificate_server_retrieve_function * func); + (gnutls_certificate_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 gnutls_certificate_server_set_request (gnutls_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); + 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); - time_t gnutls_certificate_activation_time_peers(gnutls_session_t session); - time_t gnutls_certificate_expiration_time_peers(gnutls_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); - int gnutls_certificate_client_get_request_status(gnutls_session_t session); - int gnutls_certificate_verify_peers2(gnutls_session_t session, - unsigned int *status); + int gnutls_certificate_client_get_request_status (gnutls_session_t session); + int gnutls_certificate_verify_peers2 (gnutls_session_t session, + unsigned int *status); /* this is obsolete (?). */ - int gnutls_certificate_verify_peers(gnutls_session_t session); + int gnutls_certificate_verify_peers (gnutls_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 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 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 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); /* key_usage will be an OR of the following values: */ @@ -805,25 +949,28 @@ void gnutls_psk_set_server_dh_params( gnutls_psk_server_credentials_t res, gnutl #define GNUTLS_KEY_ENCIPHER_ONLY 1 #define GNUTLS_KEY_DECIPHER_ONLY 32768 -typedef struct gnutls_params_st { + typedef struct gnutls_params_st + { gnutls_params_type_t type; - union params { + union params + { gnutls_dh_params_t dh; gnutls_rsa_params_t rsa_export; } params; int deinit; -} gnutls_params_st; + } gnutls_params_st; -typedef int gnutls_params_function(gnutls_session_t, gnutls_params_type_t, - gnutls_params_st *); + typedef int gnutls_params_function (gnutls_session_t, gnutls_params_type_t, + gnutls_params_st *); -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_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, + void gnutls_psk_set_params_function (gnutls_psk_server_credentials_t res, gnutls_params_function * func); @@ -967,4 +1114,4 @@ void gnutls_psk_set_params_function(gnutls_psk_server_credentials_t res, } #endif -#endif /* GNUTLS_H */ +#endif /* GNUTLS_H */ diff --git a/includes/gnutls/openpgp.h b/includes/gnutls/openpgp.h index 7f31de617e..1c7412b4bb 100644 --- a/includes/gnutls/openpgp.h +++ b/includes/gnutls/openpgp.h @@ -30,7 +30,8 @@ # define GNUTLS_OPENPGP_H #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif #include <gnutls/gnutls.h> @@ -39,101 +40,113 @@ extern "C" { /* gnutls_openpgp_key_t should be defined in gnutls.h */ -typedef enum gnutls_openpgp_key_fmt { GNUTLS_OPENPGP_FMT_RAW, - GNUTLS_OPENPGP_FMT_BASE64 } gnutls_openpgp_key_fmt; + typedef enum gnutls_openpgp_key_fmt + { GNUTLS_OPENPGP_FMT_RAW, + GNUTLS_OPENPGP_FMT_BASE64 + } gnutls_openpgp_key_fmt; -int gnutls_openpgp_key_init( gnutls_openpgp_key* key); /* initializes the memory for gnutls_openpgp_key_t struct */ -void gnutls_openpgp_key_deinit(gnutls_openpgp_key_t key); /* frees all memory */ + int gnutls_openpgp_key_init (gnutls_openpgp_key * key); /* initializes the memory for gnutls_openpgp_key_t struct */ + void gnutls_openpgp_key_deinit (gnutls_openpgp_key_t key); /* frees all memory */ -int gnutls_openpgp_key_import(gnutls_openpgp_key_t key, - const gnutls_datum_t* data, gnutls_openpgp_key_fmt format); -int gnutls_openpgp_key_export (gnutls_openpgp_key_t key, - gnutls_openpgp_key_fmt_t format, - void *output_data, size_t * output_data_size); + int gnutls_openpgp_key_import (gnutls_openpgp_key_t key, + const gnutls_datum_t * data, + gnutls_openpgp_key_fmt format); + int gnutls_openpgp_key_export (gnutls_openpgp_key_t key, + gnutls_openpgp_key_fmt_t format, + void *output_data, + size_t * output_data_size); /* The key_usage flags are defined in gnutls.h. They are * the GNUTLS_KEY_* definitions. */ -int gnutls_openpgp_key_get_key_usage( gnutls_openpgp_key_t cert, unsigned int* key_usage); -int gnutls_openpgp_key_get_fingerprint(gnutls_openpgp_key_t key, - void *fpr, size_t * fprlen); - -int gnutls_openpgp_key_get_name( gnutls_openpgp_key_t key, - int idx, char *buf, size_t *sizeof_buf); + int gnutls_openpgp_key_get_key_usage (gnutls_openpgp_key_t cert, + unsigned int *key_usage); + int gnutls_openpgp_key_get_fingerprint (gnutls_openpgp_key_t key, void *fpr, + size_t * fprlen); -int gnutls_openpgp_key_get_pk_algorithm(gnutls_openpgp_key_t key, - unsigned int *bits); + int gnutls_openpgp_key_get_name (gnutls_openpgp_key_t key, + int idx, char *buf, size_t * sizeof_buf); -int gnutls_openpgp_key_get_version( gnutls_openpgp_key_t key ); + int gnutls_openpgp_key_get_pk_algorithm (gnutls_openpgp_key_t key, + unsigned int *bits); -time_t gnutls_openpgp_key_get_creation_time( gnutls_openpgp_key_t key ); -time_t gnutls_openpgp_key_get_expiration_time( gnutls_openpgp_key_t key ); + int gnutls_openpgp_key_get_version (gnutls_openpgp_key_t key); -int gnutls_openpgp_key_get_id( gnutls_openpgp_key_t key, unsigned char keyid[8]); + time_t gnutls_openpgp_key_get_creation_time (gnutls_openpgp_key_t key); + time_t gnutls_openpgp_key_get_expiration_time (gnutls_openpgp_key_t key); -int gnutls_openpgp_key_check_hostname( gnutls_openpgp_key_t key, const char *hostname); + int gnutls_openpgp_key_get_id (gnutls_openpgp_key_t key, + unsigned char keyid[8]); -int gnutls_openpgp_key_to_xml( gnutls_openpgp_key_t key, gnutls_datum_t *xmlkey, - int ext); + int gnutls_openpgp_key_check_hostname (gnutls_openpgp_key_t key, + const char *hostname); + + int gnutls_openpgp_key_to_xml (gnutls_openpgp_key_t key, + gnutls_datum_t * xmlkey, int ext); /* privkey stuff. */ -int gnutls_openpgp_privkey_init(gnutls_openpgp_privkey_t * key); -void gnutls_openpgp_privkey_deinit(gnutls_openpgp_privkey_t key); -int gnutls_openpgp_privkey_get_pk_algorithm( gnutls_openpgp_privkey_t key, unsigned int *bits); -int gnutls_openpgp_privkey_import(gnutls_openpgp_privkey_t key, - const gnutls_datum_t * data, gnutls_openpgp_key_fmt format, - const char* pass, unsigned int flags); + int gnutls_openpgp_privkey_init (gnutls_openpgp_privkey_t * key); + void gnutls_openpgp_privkey_deinit (gnutls_openpgp_privkey_t key); + int gnutls_openpgp_privkey_get_pk_algorithm (gnutls_openpgp_privkey_t key, + unsigned int *bits); + int gnutls_openpgp_privkey_import (gnutls_openpgp_privkey_t key, + const gnutls_datum_t * data, + gnutls_openpgp_key_fmt format, + const char *pass, unsigned int flags); /* Keyring stuff. */ -struct gnutls_openpgp_keyring_int; /* object to hold (parsed) openpgp keyrings */ -typedef struct gnutls_openpgp_keyring_int* gnutls_openpgp_keyring; + struct gnutls_openpgp_keyring_int; /* object to hold (parsed) openpgp keyrings */ + typedef struct gnutls_openpgp_keyring_int *gnutls_openpgp_keyring; -int gnutls_openpgp_keyring_init( gnutls_openpgp_keyring* keyring); -void gnutls_openpgp_keyring_deinit(gnutls_openpgp_keyring_t keyring); + int gnutls_openpgp_keyring_init (gnutls_openpgp_keyring * keyring); + void gnutls_openpgp_keyring_deinit (gnutls_openpgp_keyring_t keyring); -int gnutls_openpgp_keyring_import(gnutls_openpgp_keyring_t keyring, - const gnutls_datum_t* data, gnutls_openpgp_key_fmt format); + int gnutls_openpgp_keyring_import (gnutls_openpgp_keyring_t keyring, + const gnutls_datum_t * data, + gnutls_openpgp_key_fmt format); -int gnutls_openpgp_keyring_check_id( gnutls_openpgp_keyring_t ring, - const unsigned char keyid[8], unsigned int flags); + int gnutls_openpgp_keyring_check_id (gnutls_openpgp_keyring_t ring, + const unsigned char keyid[8], + unsigned int flags); /* Trustdb functions. */ -struct gnutls_openpgp_trustdb_int; /* object to hold (parsed) openpgp trustdbs */ -typedef struct gnutls_openpgp_trustdb_int* gnutls_openpgp_trustdb; + struct gnutls_openpgp_trustdb_int; /* object to hold (parsed) openpgp trustdbs */ + typedef struct gnutls_openpgp_trustdb_int *gnutls_openpgp_trustdb; -int gnutls_openpgp_trustdb_init( gnutls_openpgp_trustdb* trustdb); -void gnutls_openpgp_trustdb_deinit(gnutls_openpgp_trustdb_t trustdb); + int gnutls_openpgp_trustdb_init (gnutls_openpgp_trustdb * trustdb); + void gnutls_openpgp_trustdb_deinit (gnutls_openpgp_trustdb_t trustdb); -int gnutls_openpgp_trustdb_import(gnutls_openpgp_trustdb_t trustdb, - const char* file); + int gnutls_openpgp_trustdb_import (gnutls_openpgp_trustdb_t trustdb, + const char *file); -int gnutls_openpgp_key_verify_ring( - gnutls_openpgp_key_t key, - gnutls_openpgp_keyring_t keyring, - unsigned int flags, - unsigned int * verify /* the output of the verification */); + int gnutls_openpgp_key_verify_ring (gnutls_openpgp_key_t key, + gnutls_openpgp_keyring_t keyring, + unsigned int flags, unsigned int *verify + /* the output of the verification */ ); -int gnutls_openpgp_key_verify_self( gnutls_openpgp_key_t key, - unsigned int flags, unsigned int *verify); + int gnutls_openpgp_key_verify_self (gnutls_openpgp_key_t key, + unsigned int flags, + unsigned int *verify); -int gnutls_openpgp_key_verify_trustdb( - gnutls_openpgp_key_t key, - gnutls_openpgp_trustdb_t trustdb, - unsigned int flags, - unsigned int * verify /* the output of the verification */); + int gnutls_openpgp_key_verify_trustdb (gnutls_openpgp_key_t key, + gnutls_openpgp_trustdb_t trustdb, + unsigned int flags, + unsigned int *verify + /* the output of the verification */ + ); /* certificate authentication stuff. */ -int gnutls_certificate_set_openpgp_key(gnutls_certificate_credentials_t res, - gnutls_openpgp_key_t key, gnutls_openpgp_privkey_t pkey); + int gnutls_certificate_set_openpgp_key (gnutls_certificate_credentials_t + res, gnutls_openpgp_key_t key, + gnutls_openpgp_privkey_t pkey); #ifdef __cplusplus } #endif -#endif /* GNUTLS_OPENPGP_H */ - +#endif /* GNUTLS_OPENPGP_H */ diff --git a/includes/gnutls/openssl.h b/includes/gnutls/openssl.h index fb0dd82568..bf85e6e490 100644 --- a/includes/gnutls/openssl.h +++ b/includes/gnutls/openssl.h @@ -35,7 +35,8 @@ #define GNUTLS_OPENSSL_H #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif #include <gnutls/gnutls.h> @@ -50,15 +51,16 @@ extern "C" { #define GNUTLS_X509_S_SIZE 256 #define GNUTLS_X509_EMAIL_SIZE 256 -typedef struct { - char common_name[GNUTLS_X509_CN_SIZE]; - char country[GNUTLS_X509_C_SIZE]; - char organization[GNUTLS_X509_O_SIZE]; - char organizational_unit_name[GNUTLS_X509_OU_SIZE]; - char locality_name[GNUTLS_X509_L_SIZE]; - char state_or_province_name[GNUTLS_X509_S_SIZE]; - char email[GNUTLS_X509_EMAIL_SIZE]; -} gnutls_x509_dn; + typedef struct + { + char common_name[GNUTLS_X509_CN_SIZE]; + char country[GNUTLS_X509_C_SIZE]; + char organization[GNUTLS_X509_O_SIZE]; + char organizational_unit_name[GNUTLS_X509_OU_SIZE]; + char locality_name[GNUTLS_X509_L_SIZE]; + char state_or_province_name[GNUTLS_X509_S_SIZE]; + char email[GNUTLS_X509_EMAIL_SIZE]; + } gnutls_x509_dn; #define OPENSSL_VERSION_NUMBER (0x0090604F) @@ -89,48 +91,48 @@ typedef struct { #define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER (0x2) #define SSL_MODE_AUTO_RETRY (0x4) -typedef gnutls_x509_dn X509_NAME; -typedef gnutls_datum_t X509; + typedef gnutls_x509_dn X509_NAME; + typedef gnutls_datum_t X509; -typedef struct _SSL SSL; + typedef struct _SSL SSL; -typedef struct -{ + typedef struct + { int protocol_priority[GNUTLS_MAX_ALGORITHM_NUM]; int cipher_priority[GNUTLS_MAX_ALGORITHM_NUM]; int comp_priority[GNUTLS_MAX_ALGORITHM_NUM]; int kx_priority[GNUTLS_MAX_ALGORITHM_NUM]; int mac_priority[GNUTLS_MAX_ALGORITHM_NUM]; gnutls_connection_end_t connend; -} SSL_METHOD; + } SSL_METHOD; -typedef struct -{ + typedef struct + { gnutls_protocol_t version; gnutls_cipher_algorithm_t cipher; gnutls_kx_algorithm_t kx; gnutls_mac_algorithm_t mac; gnutls_compression_method_t compression; gnutls_certificate_type_t cert; -} SSL_CIPHER; + } SSL_CIPHER; -typedef struct _BIO -{ + typedef struct _BIO + { gnutls_transport_ptr_t fd; -} BIO; + } BIO; -typedef struct -{ + typedef struct + { SSL *ssl; int error; const gnutls_datum_t *cert_list; #define current_cert cert_list -} X509_STORE_CTX; + } X509_STORE_CTX; #define X509_STORE_CTX_get_current_cert(ctx) ((ctx)->current_cert) -typedef struct _SSL_CTX -{ + typedef struct _SSL_CTX + { SSL_METHOD *method; char *certfile; int certfile_type; @@ -138,13 +140,13 @@ typedef struct _SSL_CTX int keyfile_type; unsigned long options; - int (*verify_callback)(int, X509_STORE_CTX *); + int (*verify_callback) (int, X509_STORE_CTX *); int verify_mode; -} SSL_CTX; + } SSL_CTX; -struct _SSL -{ + struct _SSL + { gnutls_session_t gnutls_state; gnutls_certificate_client_credentials gnutls_cred; @@ -157,22 +159,22 @@ struct _SSL int state; unsigned long options; - int (*verify_callback)(int, X509_STORE_CTX *); + int (*verify_callback) (int, X509_STORE_CTX *); int verify_mode; - + gnutls_transport_ptr_t rfd; gnutls_transport_ptr_t wfd; -}; + }; #define rbio gnutls_state -typedef struct -{ + typedef struct + { void *handle; -} MD_CTX; + } MD_CTX; -struct RSA; -typedef struct RSA RSA; + struct RSA; + typedef struct RSA RSA; #define MD5_CTX MD_CTX #define RIPEMD160_CTX MD_CTX @@ -189,63 +191,65 @@ typedef struct RSA RSA; /* Library initialisation functions */ -int SSL_library_init(void); -void OpenSSL_add_all_algorithms(void); + int SSL_library_init (void); + void OpenSSL_add_all_algorithms (void); /* SSL_CTX structure handling */ -SSL_CTX *SSL_CTX_new(SSL_METHOD *method); -void SSL_CTX_free(SSL_CTX *ctx); -int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx); -int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *certfile, int type); -int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *keyfile, int type); -void SSL_CTX_set_verify(SSL_CTX *ctx, int verify_mode, - int (*verify_callback)(int, X509_STORE_CTX *)); -unsigned long SSL_CTX_set_options(SSL_CTX *ctx, unsigned long options); -long SSL_CTX_set_mode(SSL_CTX *ctx, long mode); -int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *list); + SSL_CTX *SSL_CTX_new (SSL_METHOD * method); + void SSL_CTX_free (SSL_CTX * ctx); + int SSL_CTX_set_default_verify_paths (SSL_CTX * ctx); + int SSL_CTX_use_certificate_file (SSL_CTX * ctx, const char *certfile, + int type); + int SSL_CTX_use_PrivateKey_file (SSL_CTX * ctx, const char *keyfile, + int type); + void SSL_CTX_set_verify (SSL_CTX * ctx, int verify_mode, + int (*verify_callback) (int, X509_STORE_CTX *)); + unsigned long SSL_CTX_set_options (SSL_CTX * ctx, unsigned long options); + long SSL_CTX_set_mode (SSL_CTX * ctx, long mode); + int SSL_CTX_set_cipher_list (SSL_CTX * ctx, const char *list); /* SSL_CTX statistics */ -long SSL_CTX_sess_number(SSL_CTX *ctx); -long SSL_CTX_sess_connect(SSL_CTX *ctx); -long SSL_CTX_sess_connect_good(SSL_CTX *ctx); -long SSL_CTX_sess_connect_renegotiate(SSL_CTX *ctx); -long SSL_CTX_sess_accept(SSL_CTX *ctx); -long SSL_CTX_sess_accept_good(SSL_CTX *ctx); -long SSL_CTX_sess_accept_renegotiate(SSL_CTX *ctx); -long SSL_CTX_sess_hits(SSL_CTX *ctx); -long SSL_CTX_sess_misses(SSL_CTX *ctx); -long SSL_CTX_sess_timeouts(SSL_CTX *ctx); + long SSL_CTX_sess_number (SSL_CTX * ctx); + long SSL_CTX_sess_connect (SSL_CTX * ctx); + long SSL_CTX_sess_connect_good (SSL_CTX * ctx); + long SSL_CTX_sess_connect_renegotiate (SSL_CTX * ctx); + long SSL_CTX_sess_accept (SSL_CTX * ctx); + long SSL_CTX_sess_accept_good (SSL_CTX * ctx); + long SSL_CTX_sess_accept_renegotiate (SSL_CTX * ctx); + long SSL_CTX_sess_hits (SSL_CTX * ctx); + long SSL_CTX_sess_misses (SSL_CTX * ctx); + long SSL_CTX_sess_timeouts (SSL_CTX * ctx); /* SSL structure handling */ -SSL *SSL_new(SSL_CTX *ctx); -void SSL_free(SSL *ssl); -void SSL_load_error_strings(void); -int SSL_get_error(SSL *ssl, int ret); -int SSL_set_fd(SSL *ssl, int fd); -int SSL_set_rfd(SSL *ssl, int fd); -int SSL_set_wfd(SSL *ssl, int fd); -void SSL_set_bio(SSL *ssl, BIO *rbio, BIO *wbio); -void SSL_set_connect_state(SSL *ssl); -int SSL_pending(SSL *ssl); -void SSL_set_verify(SSL *ssl, int verify_mode, - int (*verify_callback)(int, X509_STORE_CTX *)); -const X509 *SSL_get_peer_certificate(SSL *ssl); + SSL *SSL_new (SSL_CTX * ctx); + void SSL_free (SSL * ssl); + void SSL_load_error_strings (void); + int SSL_get_error (SSL * ssl, int ret); + int SSL_set_fd (SSL * ssl, int fd); + int SSL_set_rfd (SSL * ssl, int fd); + int SSL_set_wfd (SSL * ssl, int fd); + void SSL_set_bio (SSL * ssl, BIO * rbio, BIO * wbio); + void SSL_set_connect_state (SSL * ssl); + int SSL_pending (SSL * ssl); + void SSL_set_verify (SSL * ssl, int verify_mode, + int (*verify_callback) (int, X509_STORE_CTX *)); + const X509 *SSL_get_peer_certificate (SSL * ssl); /* SSL connection open/close/read/write functions */ -int SSL_connect(SSL *ssl); -int SSL_accept(SSL *ssl); -int SSL_shutdown(SSL *ssl); -int SSL_read(SSL *ssl, void *buf, int len); -int SSL_write(SSL *ssl, const void *buf, int len); + int SSL_connect (SSL * ssl); + int SSL_accept (SSL * ssl); + int SSL_shutdown (SSL * ssl); + int SSL_read (SSL * ssl, void *buf, int len); + int SSL_write (SSL * ssl, const void *buf, int len); -int SSL_want(SSL *ssl); + int SSL_want (SSL * ssl); #define SSL_NOTHING (1) #define SSL_WRITING (2) @@ -260,69 +264,69 @@ int SSL_want(SSL *ssl); /* SSL_METHOD functions */ -SSL_METHOD *SSLv23_client_method(void); -SSL_METHOD *SSLv23_server_method(void); -SSL_METHOD *SSLv3_client_method(void); -SSL_METHOD *SSLv3_server_method(void); -SSL_METHOD *TLSv1_client_method(void); -SSL_METHOD *TLSv1_server_method(void); + SSL_METHOD *SSLv23_client_method (void); + SSL_METHOD *SSLv23_server_method (void); + SSL_METHOD *SSLv3_client_method (void); + SSL_METHOD *SSLv3_server_method (void); + SSL_METHOD *TLSv1_client_method (void); + SSL_METHOD *TLSv1_server_method (void); /* SSL_CIPHER functions */ -SSL_CIPHER *SSL_get_current_cipher(SSL *ssl); -const char *SSL_CIPHER_get_name(SSL_CIPHER *cipher); -int SSL_CIPHER_get_bits(SSL_CIPHER *cipher, int *bits); -const char *SSL_CIPHER_get_version(SSL_CIPHER *cipher); -char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int size); + SSL_CIPHER *SSL_get_current_cipher (SSL * ssl); + const char *SSL_CIPHER_get_name (SSL_CIPHER * cipher); + int SSL_CIPHER_get_bits (SSL_CIPHER * cipher, int *bits); + const char *SSL_CIPHER_get_version (SSL_CIPHER * cipher); + char *SSL_CIPHER_description (SSL_CIPHER * cipher, char *buf, int size); /* X509 functions */ -X509_NAME *X509_get_subject_name(const X509 *cert); -X509_NAME *X509_get_issuer_name(const X509 *cert); -char *X509_NAME_oneline(gnutls_x509_dn *name, char *buf, int len); -void X509_free(const X509 *cert); + X509_NAME *X509_get_subject_name (const X509 * cert); + X509_NAME *X509_get_issuer_name (const X509 * cert); + char *X509_NAME_oneline (gnutls_x509_dn * name, char *buf, int len); + void X509_free (const X509 * cert); /* BIO functions */ -void BIO_get_fd(gnutls_session_t gnutls_state, int *fd); -BIO *BIO_new_socket(int sock, int close_flag); + void BIO_get_fd (gnutls_session_t gnutls_state, int *fd); + BIO *BIO_new_socket (int sock, int close_flag); /* error handling */ -unsigned long ERR_get_error(void); -const char *ERR_error_string(unsigned long e, char *buf); + unsigned long ERR_get_error (void); + const char *ERR_error_string (unsigned long e, char *buf); /* RAND functions */ -int RAND_status(void); -void RAND_seed(const void *buf, int num); -int RAND_bytes(unsigned char *buf, int num); -const char *RAND_file_name(char *buf, size_t len); -int RAND_load_file(const char *name, long maxbytes); -int RAND_write_file(const char *name); + int RAND_status (void); + void RAND_seed (const void *buf, int num); + int RAND_bytes (unsigned char *buf, int num); + const char *RAND_file_name (char *buf, size_t len); + int RAND_load_file (const char *name, long maxbytes); + int RAND_write_file (const char *name); -int RAND_egd_bytes(const char *path, int bytes); + int RAND_egd_bytes (const char *path, int bytes); #define RAND_egd(p) RAND_egd_bytes((p), 255) /* message digest functions */ #define MD5_DIGEST_LENGTH 16 -void MD5_Init(MD5_CTX *ctx); -void MD5_Update(MD5_CTX *ctx, const void *buf, int len); -void MD5_Final(unsigned char *md, MD5_CTX *ctx); -unsigned char *MD5(const unsigned char *buf, unsigned long len, - unsigned char *md); - -void RIPEMD160_Init(RIPEMD160_CTX *ctx); -void RIPEMD160_Update(RIPEMD160_CTX *ctx, const void *buf, int len); -void RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *ctx); -unsigned char *RIPEMD160(const unsigned char *buf, unsigned long len, - unsigned char *md); + void MD5_Init (MD5_CTX * ctx); + void MD5_Update (MD5_CTX * ctx, const void *buf, int len); + void MD5_Final (unsigned char *md, MD5_CTX * ctx); + unsigned char *MD5 (const unsigned char *buf, unsigned long len, + unsigned char *md); + + void RIPEMD160_Init (RIPEMD160_CTX * ctx); + void RIPEMD160_Update (RIPEMD160_CTX * ctx, const void *buf, int len); + void RIPEMD160_Final (unsigned char *md, RIPEMD160_CTX * ctx); + unsigned char *RIPEMD160 (const unsigned char *buf, unsigned long len, + unsigned char *md); #ifdef __cplusplus } diff --git a/includes/gnutls/pkcs12.h b/includes/gnutls/pkcs12.h index dd0dbb39a9..c46da6f3bc 100644 --- a/includes/gnutls/pkcs12.h +++ b/includes/gnutls/pkcs12.h @@ -26,69 +26,79 @@ # define GNUTLS_PKCS12_H #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif #include <gnutls/x509.h> /* PKCS12 structures handling */ -struct gnutls_pkcs12_int; -typedef struct gnutls_pkcs12_int* gnutls_pkcs12_t; - -struct gnutls_pkcs12_bag_int; -typedef struct gnutls_pkcs12_bag_int* gnutls_pkcs12_bag_t; - -int gnutls_pkcs12_init(gnutls_pkcs12_t * pkcs12); -void gnutls_pkcs12_deinit(gnutls_pkcs12_t pkcs12); -int gnutls_pkcs12_import(gnutls_pkcs12_t pkcs12, const gnutls_datum_t * data, - gnutls_x509_crt_fmt format, unsigned int flags); -int gnutls_pkcs12_export( gnutls_pkcs12_t pkcs12, - gnutls_x509_crt_fmt format, void* output_data, size_t* output_data_size); - -int gnutls_pkcs12_get_bag(gnutls_pkcs12_t pkcs12, - int indx, gnutls_pkcs12_bag_t bag); -int gnutls_pkcs12_set_bag(gnutls_pkcs12_t pkcs12, gnutls_pkcs12_bag_t bag); - -int gnutls_pkcs12_generate_mac(gnutls_pkcs12_t pkcs12, const char* pass); -int gnutls_pkcs12_verify_mac(gnutls_pkcs12_t pkcs12, const char* pass); - -int gnutls_pkcs12_bag_decrypt(gnutls_pkcs12_bag_t bag, const char* pass); -int gnutls_pkcs12_bag_encrypt(gnutls_pkcs12_bag_t bag, const char* pass, unsigned int flags); - -typedef enum gnutls_pkcs12_bag_type_t { + struct gnutls_pkcs12_int; + typedef struct gnutls_pkcs12_int *gnutls_pkcs12_t; + + struct gnutls_pkcs12_bag_int; + typedef struct gnutls_pkcs12_bag_int *gnutls_pkcs12_bag_t; + + int gnutls_pkcs12_init (gnutls_pkcs12_t * pkcs12); + void gnutls_pkcs12_deinit (gnutls_pkcs12_t pkcs12); + int gnutls_pkcs12_import (gnutls_pkcs12_t pkcs12, + const gnutls_datum_t * data, + gnutls_x509_crt_fmt format, unsigned int flags); + int gnutls_pkcs12_export (gnutls_pkcs12_t pkcs12, + gnutls_x509_crt_fmt format, void *output_data, + size_t * output_data_size); + + int gnutls_pkcs12_get_bag (gnutls_pkcs12_t pkcs12, + int indx, gnutls_pkcs12_bag_t bag); + int gnutls_pkcs12_set_bag (gnutls_pkcs12_t pkcs12, gnutls_pkcs12_bag_t bag); + + int gnutls_pkcs12_generate_mac (gnutls_pkcs12_t pkcs12, const char *pass); + int gnutls_pkcs12_verify_mac (gnutls_pkcs12_t pkcs12, const char *pass); + + int gnutls_pkcs12_bag_decrypt (gnutls_pkcs12_bag_t bag, const char *pass); + int gnutls_pkcs12_bag_encrypt (gnutls_pkcs12_bag_t bag, const char *pass, + unsigned int flags); + + typedef enum gnutls_pkcs12_bag_type_t + { GNUTLS_BAG_EMPTY = 0, - GNUTLS_BAG_PKCS8_ENCRYPTED_KEY=1, + GNUTLS_BAG_PKCS8_ENCRYPTED_KEY = 1, GNUTLS_BAG_PKCS8_KEY, GNUTLS_BAG_CERTIFICATE, GNUTLS_BAG_CRL, - GNUTLS_BAG_ENCRYPTED=10, - GNUTLS_BAG_UNKNOWN=20 -} gnutls_pkcs12_bag_type_t; - -gnutls_pkcs12_bag_type_t gnutls_pkcs12_bag_get_type(gnutls_pkcs12_bag_t bag, int indx); -int gnutls_pkcs12_bag_get_data(gnutls_pkcs12_bag_t bag, int indx, gnutls_datum_t* data); -int gnutls_pkcs12_bag_set_data(gnutls_pkcs12_bag_t bag, gnutls_pkcs12_bag_type_t type, - const gnutls_datum_t* data); -int gnutls_pkcs12_bag_set_crl(gnutls_pkcs12_bag_t bag, gnutls_x509_crl_t crl); -int gnutls_pkcs12_bag_set_crt(gnutls_pkcs12_bag_t bag, gnutls_x509_crt_t crt); - -int gnutls_pkcs12_bag_init(gnutls_pkcs12_bag_t * bag); -void gnutls_pkcs12_bag_deinit(gnutls_pkcs12_bag_t bag); -int gnutls_pkcs12_bag_get_count(gnutls_pkcs12_bag_t bag); - -int gnutls_pkcs12_bag_get_key_id(gnutls_pkcs12_bag_t bag, int indx, - gnutls_datum_t* id); -int gnutls_pkcs12_bag_set_key_id(gnutls_pkcs12_bag_t bag, int indx, - const gnutls_datum_t* id); - -int gnutls_pkcs12_bag_get_friendly_name(gnutls_pkcs12_bag_t bag, int indx, - char **name); -int gnutls_pkcs12_bag_set_friendly_name(gnutls_pkcs12_bag_t bag, int indx, - const char* name); + GNUTLS_BAG_ENCRYPTED = 10, + GNUTLS_BAG_UNKNOWN = 20 + } gnutls_pkcs12_bag_type_t; + + gnutls_pkcs12_bag_type_t gnutls_pkcs12_bag_get_type (gnutls_pkcs12_bag_t + bag, int indx); + int gnutls_pkcs12_bag_get_data (gnutls_pkcs12_bag_t bag, int indx, + gnutls_datum_t * data); + int gnutls_pkcs12_bag_set_data (gnutls_pkcs12_bag_t bag, + gnutls_pkcs12_bag_type_t type, + const gnutls_datum_t * data); + int gnutls_pkcs12_bag_set_crl (gnutls_pkcs12_bag_t bag, + gnutls_x509_crl_t crl); + int gnutls_pkcs12_bag_set_crt (gnutls_pkcs12_bag_t bag, + gnutls_x509_crt_t crt); + + int gnutls_pkcs12_bag_init (gnutls_pkcs12_bag_t * bag); + void gnutls_pkcs12_bag_deinit (gnutls_pkcs12_bag_t bag); + int gnutls_pkcs12_bag_get_count (gnutls_pkcs12_bag_t bag); + + int gnutls_pkcs12_bag_get_key_id (gnutls_pkcs12_bag_t bag, int indx, + gnutls_datum_t * id); + int gnutls_pkcs12_bag_set_key_id (gnutls_pkcs12_bag_t bag, int indx, + const gnutls_datum_t * id); + + int gnutls_pkcs12_bag_get_friendly_name (gnutls_pkcs12_bag_t bag, int indx, + char **name); + int gnutls_pkcs12_bag_set_friendly_name (gnutls_pkcs12_bag_t bag, int indx, + const char *name); #ifdef __cplusplus } #endif -#endif /* GNUTLS_PKCS12_H */ +#endif /* GNUTLS_PKCS12_H */ diff --git a/includes/gnutls/x509.h b/includes/gnutls/x509.h index 8e6b9dc409..46b3f7dfcd 100644 --- a/includes/gnutls/x509.h +++ b/includes/gnutls/x509.h @@ -395,13 +395,13 @@ extern "C" int gnutls_x509_crt_check_issuer (gnutls_x509_crt_t cert, gnutls_x509_crt_t issuer); - int gnutls_x509_crt_list_verify(const gnutls_x509_crt_t * cert_list, - int cert_list_length, - const gnutls_x509_crt_t * CA_list, - int CA_list_length, - const gnutls_x509_crl_t * CRL_list, - int CRL_list_length, - unsigned int flags, unsigned int *verify); + int gnutls_x509_crt_list_verify (const gnutls_x509_crt_t * cert_list, + int cert_list_length, + const gnutls_x509_crt_t * CA_list, + int CA_list_length, + const gnutls_x509_crl_t * CRL_list, + int CRL_list_length, + unsigned int flags, unsigned int *verify); int gnutls_x509_crt_verify (gnutls_x509_crt_t cert, const gnutls_x509_crt_t * CA_list, diff --git a/lib/auth_anon.c b/lib/auth_anon.c index 3dea26d729..ed65a3cc1b 100644 --- a/lib/auth_anon.c +++ b/lib/auth_anon.c @@ -78,7 +78,8 @@ gen_anon_server_kx (gnutls_session_t session, opaque ** data) return GNUTLS_E_INSUFFICIENT_CREDENTIALS; } - dh_params = _gnutls_get_dh_params (cred->dh_params, cred->params_func, session); + dh_params = + _gnutls_get_dh_params (cred->dh_params, cred->params_func, session); mpis = _gnutls_dh_params_to_mpi (dh_params); if (mpis == NULL) { @@ -130,7 +131,8 @@ proc_anon_client_kx (gnutls_session_t session, opaque * data, return GNUTLS_E_INSUFFICIENT_CREDENTIALS; } - dh_params = _gnutls_get_dh_params (cred->dh_params, cred->params_func, session); + dh_params = + _gnutls_get_dh_params (cred->dh_params, cred->params_func, session); mpis = _gnutls_dh_params_to_mpi (dh_params); if (mpis == NULL) { diff --git a/lib/auth_cert.h b/lib/auth_cert.h index ba082233f7..778a3e18b0 100644 --- a/lib/auth_cert.h +++ b/lib/auth_cert.h @@ -52,7 +52,7 @@ typedef struct gnutls_certificate_credentials_st /* contains the number of the certificates in a * row (should be 1 for OpenPGP keys). */ - unsigned ncerts; /* contains the number of columns in cert_list. + unsigned ncerts; /* contains the number of columns in cert_list. * This is the same with the number of pkeys. */ @@ -147,7 +147,10 @@ void _gnutls_selected_certs_set (gnutls_session_t session, #define _gnutls_proc_cert_client_certificate _gnutls_proc_cert_server_certificate -gnutls_rsa_params_t _gnutls_certificate_get_rsa_params (gnutls_rsa_params_t rsa_params, gnutls_params_function* func, - gnutls_session_t); +gnutls_rsa_params_t _gnutls_certificate_get_rsa_params (gnutls_rsa_params_t + rsa_params, + gnutls_params_function + * func, + gnutls_session_t); #endif diff --git a/lib/auth_dh_common.c b/lib/auth_dh_common.c index 43e9ffb9d4..2bcfa6b6f7 100644 --- a/lib/auth_dh_common.c +++ b/lib/auth_dh_common.c @@ -95,7 +95,7 @@ _gnutls_proc_dh_common_client_kx (gnutls_session_t session, { ret = _gnutls_mpi_dprint (&session->key->key, session->key->KEY); } - else /* In DHE_PSK the key is set differently */ + else /* In DHE_PSK the key is set differently */ { gnutls_datum tmp_dh_key; ret = _gnutls_mpi_dprint (&tmp_dh_key, session->key->KEY); @@ -178,7 +178,7 @@ _gnutls_gen_dh_common_client_kx (gnutls_session_t session, opaque ** data) { ret = _gnutls_mpi_dprint (&session->key->key, session->key->KEY); } - else /* In DHE_PSK the key is set differently */ + else /* In DHE_PSK the key is set differently */ { gnutls_datum tmp_dh_key; ret = _gnutls_mpi_dprint (&tmp_dh_key, session->key->KEY); @@ -225,12 +225,13 @@ _gnutls_proc_dh_common_server_kx (gnutls_session_t session, i = 0; - if (psk != 0) { - DECR_LEN (data_size, 2); - psk_size = _gnutls_read_uint16 (&data[i]); - DECR_LEN (data_size, psk_size); - i += 2 + psk_size; - } + if (psk != 0) + { + DECR_LEN (data_size, 2); + psk_size = _gnutls_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]); @@ -297,8 +298,9 @@ _gnutls_proc_dh_common_server_kx (gnutls_session_t session, _gnutls_dh_set_peer_public (session, session->key->client_Y); ret = n_Y + n_p + n_g + 6; - if (psk != 0) ret += 2; - + if (psk != 0) + ret += 2; + return ret; } @@ -326,11 +328,12 @@ _gnutls_dh_common_print_server_kx (gnutls_session_t session, _gnutls_mpi_print (NULL, &n_g, g); _gnutls_mpi_print (NULL, &n_p, p); _gnutls_mpi_print (NULL, &n_X, X); - + data_size = n_g + n_p + n_X + 6; - if (psk != 0) data_size += 2; + if (psk != 0) + data_size += 2; - (*data) = gnutls_malloc ( data_size); + (*data) = gnutls_malloc (data_size); if (*data == NULL) { _gnutls_mpi_release (&X); @@ -340,14 +343,15 @@ _gnutls_dh_common_print_server_kx (gnutls_session_t session, pos = 0; pdata = *data; - if (psk != 0) { - _gnutls_write_uint16 (0, &pdata[pos]); - pos += 2; - } + if (psk != 0) + { + _gnutls_write_uint16 (0, &pdata[pos]); + pos += 2; + } - _gnutls_mpi_print (&pdata[pos+2], &n_p, p); + _gnutls_mpi_print (&pdata[pos + 2], &n_p, p); _gnutls_write_uint16 (n_p, &pdata[pos]); - + pos += n_p + 2; _gnutls_mpi_print (&pdata[pos + 2], &n_g, g); diff --git a/lib/auth_dh_common.h b/lib/auth_dh_common.h index 6923bedfcd..570bf05c71 100644 --- a/lib/auth_dh_common.h +++ b/lib/auth_dh_common.h @@ -42,6 +42,7 @@ int _gnutls_proc_dh_common_client_kx (gnutls_session_t session, int _gnutls_dh_common_print_server_kx (gnutls_session_t, mpi_t g, mpi_t p, opaque ** data, int psk); int _gnutls_proc_dh_common_server_kx (gnutls_session_t session, - opaque * data, size_t _data_size, int psk); + opaque * data, size_t _data_size, + int psk); #endif diff --git a/lib/auth_dhe.c b/lib/auth_dhe.c index f579cc5841..c95a91a352 100644 --- a/lib/auth_dhe.c +++ b/lib/auth_dhe.c @@ -112,7 +112,8 @@ gen_dhe_server_kx (gnutls_session_t session, opaque ** data) return ret; } - dh_params = _gnutls_get_dh_params (cred->dh_params, cred->params_func, session); + dh_params = + _gnutls_get_dh_params (cred->dh_params, cred->params_func, session); mpis = _gnutls_dh_params_to_mpi (dh_params); if (mpis == NULL) { @@ -257,7 +258,8 @@ proc_dhe_client_kx (gnutls_session_t session, opaque * data, return GNUTLS_E_INSUFFICIENT_CREDENTIALS; } - dh_params = _gnutls_get_dh_params (cred->dh_params, cred->params_func, session); + dh_params = + _gnutls_get_dh_params (cred->dh_params, cred->params_func, session); mpis = _gnutls_dh_params_to_mpi (dh_params); if (mpis == NULL) { diff --git a/lib/auth_dhe_psk.c b/lib/auth_dhe_psk.c index 8b4db217f3..2586604eca 100644 --- a/lib/auth_dhe_psk.c +++ b/lib/auth_dhe_psk.c @@ -66,14 +66,14 @@ const mod_auth_st dhe_psk_auth_struct = { static int gen_psk_client_kx (gnutls_session_t session, opaque ** data) { -int ret; -opaque * tmp_data = NULL; -int data_size, tmp_data_size; -gnutls_psk_client_credentials_t cred; - + int ret; + opaque *tmp_data = NULL; + int data_size, tmp_data_size; + gnutls_psk_client_credentials_t cred; + cred = (gnutls_psk_client_credentials_t) - _gnutls_get_cred (session->key, GNUTLS_CRD_PSK, NULL); - + _gnutls_get_cred (session->key, GNUTLS_CRD_PSK, NULL); + if (cred == NULL) { gnutls_assert (); @@ -87,32 +87,33 @@ gnutls_psk_client_credentials_t cred; } /* The PSK key is set in there */ - ret = _gnutls_gen_dh_common_client_kx( session, &tmp_data); - if (ret < 0) { - gnutls_assert(); - return ret; - } - + ret = _gnutls_gen_dh_common_client_kx (session, &tmp_data); + if (ret < 0) + { + gnutls_assert (); + return ret; + } + tmp_data_size = ret; data_size = tmp_data_size + cred->username.size + 2; - - (*data) = gnutls_malloc ( data_size); + + (*data) = gnutls_malloc (data_size); if ((*data) == NULL) { - gnutls_assert(); + gnutls_assert (); ret = GNUTLS_E_MEMORY_ERROR; goto error; } - + _gnutls_write_datum16 (*data, cred->username); - memcpy( &(*data)[cred->username.size + 2], tmp_data, tmp_data_size); + memcpy (&(*data)[cred->username.size + 2], tmp_data, tmp_data_size); ret = data_size; error: - gnutls_free( tmp_data); + gnutls_free (tmp_data); return ret; - + } static int @@ -132,7 +133,8 @@ gen_psk_server_kx (gnutls_session_t session, opaque ** data) return GNUTLS_E_INSUFFICIENT_CREDENTIALS; } - dh_params = _gnutls_get_dh_params (cred->dh_params, cred->params_func, session); + dh_params = + _gnutls_get_dh_params (cred->dh_params, cred->params_func, session); mpis = _gnutls_dh_params_to_mpi (dh_params); if (mpis == NULL) { @@ -165,7 +167,7 @@ gen_psk_server_kx (gnutls_session_t session, opaque ** data) static int proc_psk_client_kx (gnutls_session_t session, opaque * data, - size_t _data_size) + size_t _data_size) { int bits; int ret; @@ -176,27 +178,28 @@ proc_psk_client_kx (gnutls_session_t session, opaque * data, psk_auth_info_t info; gnutls_datum username; ssize_t data_size = _data_size; - + cred = (gnutls_psk_server_credentials_t) - _gnutls_get_cred (session->key, GNUTLS_CRD_PSK, NULL); - + _gnutls_get_cred (session->key, GNUTLS_CRD_PSK, NULL); + if (cred == NULL) { gnutls_assert (); return GNUTLS_E_INSUFFICIENT_CREDENTIALS; } - + bits = _gnutls_dh_get_allowed_prime_bits (session); if ((ret = _gnutls_auth_info_set (session, GNUTLS_CRD_PSK, - sizeof (psk_auth_info_st), 1)) < 0) + sizeof (psk_auth_info_st), 1)) < 0) { gnutls_assert (); return ret; } - dh_params = _gnutls_get_dh_params (cred->dh_params, cred->params_func, session); + dh_params = + _gnutls_get_dh_params (cred->dh_params, cred->params_func, session); mpis = _gnutls_dh_params_to_mpi (dh_params); if (mpis == NULL) { @@ -206,7 +209,7 @@ proc_psk_client_kx (gnutls_session_t session, opaque * data, p = mpis[0]; g = mpis[1]; - + DECR_LEN (data_size, 2); username.size = _gnutls_read_uint16 (&data[0]); @@ -238,7 +241,7 @@ proc_psk_client_kx (gnutls_session_t session, opaque * data, int proc_psk_server_kx (gnutls_session_t session, opaque * data, - size_t _data_size) + size_t _data_size) { int ret; diff --git a/lib/auth_psk.c b/lib/auth_psk.c index 3bb84f3838..60c83873f5 100644 --- a/lib/auth_psk.c +++ b/lib/auth_psk.c @@ -60,7 +60,8 @@ const mod_auth_st psk_auth_struct = { /* Set the PSK premaster secret. */ int -_gnutls_set_psk_session_key (gnutls_session_t session, gnutls_datum * dh_secret) +_gnutls_set_psk_session_key (gnutls_session_t session, + gnutls_datum * dh_secret) { gnutls_datum pwd_psk = { NULL, 0 }; gnutls_datum *ppsk; @@ -131,10 +132,10 @@ _gnutls_set_psk_session_key (gnutls_session_t session, gnutls_datum * dh_secret) _gnutls_write_datum16 (&session->key->key.data[dh_secret_size + 2], *ppsk); ret = 0; - - error: - _gnutls_free_datum( &pwd_psk); - return ret; + +error: + _gnutls_free_datum (&pwd_psk); + return ret; } diff --git a/lib/auth_rsa.c b/lib/auth_rsa.c index 20e006b794..a76ea0a3bf 100644 --- a/lib/auth_rsa.c +++ b/lib/auth_rsa.c @@ -178,7 +178,9 @@ _gnutls_get_private_rsa_params (gnutls_session_t session, == GNUTLS_KX_RSA_EXPORT && bits > 512) { - rsa_params = _gnutls_certificate_get_rsa_params (cred->rsa_params, cred->params_func, session); + rsa_params = + _gnutls_certificate_get_rsa_params (cred->rsa_params, + cred->params_func, session); /* EXPORT case: */ if (rsa_params == NULL) { diff --git a/lib/auth_rsa_export.c b/lib/auth_rsa_export.c index 50712cdedc..8b4397ab69 100644 --- a/lib/auth_rsa_export.c +++ b/lib/auth_rsa_export.c @@ -107,7 +107,9 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data) return GNUTLS_E_INT_RET_0; } - rsa_params = _gnutls_certificate_get_rsa_params (cred->rsa_params, cred->params_func, session); + rsa_params = + _gnutls_certificate_get_rsa_params (cred->rsa_params, cred->params_func, + session); rsa_mpis = _gnutls_rsa_params_to_mpi (rsa_params); if (rsa_mpis == NULL) { diff --git a/lib/auth_srp.c b/lib/auth_srp.c index b7b699ee3b..e30c069caa 100644 --- a/lib/auth_srp.c +++ b/lib/auth_srp.c @@ -335,7 +335,7 @@ _gnutls_gen_srp_client_kx (gnutls_session_t session, opaque ** data) _gnutls_mpi_release (&session->key->u); _gnutls_mpi_release (&B); - ret = _gnutls_mpi_dprint( &session->key->key, session->key->KEY); + ret = _gnutls_mpi_dprint (&session->key->key, session->key->KEY); _gnutls_mpi_release (&S); if (ret < 0) @@ -431,7 +431,7 @@ _gnutls_proc_srp_client_kx (gnutls_session_t session, opaque * data, _gnutls_mpi_release (&session->key->u); _gnutls_mpi_release (&B); - ret = _gnutls_mpi_dprint( &session->key->key, session->key->KEY); + ret = _gnutls_mpi_dprint (&session->key->key, session->key->KEY); _gnutls_mpi_release (&S); if (ret < 0) diff --git a/lib/auth_srp_passwd.h b/lib/auth_srp_passwd.h index 9adaf20c76..cc6b00a6a7 100644 --- a/lib/auth_srp_passwd.h +++ b/lib/auth_srp_passwd.h @@ -38,7 +38,9 @@ typedef struct int _gnutls_srp_pwd_read_entry (gnutls_session_t state, char *username, SRP_PWD_ENTRY **); void _gnutls_srp_entry_free (SRP_PWD_ENTRY * entry); -int _gnutls_sbase64_encode (uint8_t * data, size_t data_size, uint8_t ** result); -int _gnutls_sbase64_decode (uint8_t * data, size_t data_size, uint8_t ** result); +int _gnutls_sbase64_encode (uint8_t * data, size_t data_size, + uint8_t ** result); +int _gnutls_sbase64_decode (uint8_t * data, size_t data_size, + uint8_t ** result); #endif /* ENABLE_SRP */ diff --git a/lib/auth_srp_sb64.c b/lib/auth_srp_sb64.c index 488c243f02..2834fba7b5 100644 --- a/lib/auth_srp_sb64.c +++ b/lib/auth_srp_sb64.c @@ -330,7 +330,7 @@ gnutls_srp_base64_encode (const gnutls_datum_t * data, char *result, if (size < 0) return size; - if (result == NULL || *result_size < (size_t)size) + if (result == NULL || *result_size < (size_t) size) { gnutls_free (ret); *result_size = size; @@ -408,7 +408,7 @@ gnutls_srp_base64_decode (const gnutls_datum_t * b64_data, char *result, if (size < 0) return size; - if (result == NULL || *result_size < (size_t)size) + if (result == NULL || *result_size < (size_t) size) { gnutls_free (ret); *result_size = size; diff --git a/lib/ext_inner_application.c b/lib/ext_inner_application.c index a05f906e30..3cbf77b3ba 100644 --- a/lib/ext_inner_application.c +++ b/lib/ext_inner_application.c @@ -44,7 +44,7 @@ _gnutls_inner_application_recv_params (gnutls_session_t session, return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; } - switch ((unsigned char)*data) + switch ((unsigned char) *data) { case NO: state = GNUTLS_IA_APP_PHASE_ON_RESUMPTION_NO; @@ -81,7 +81,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, GNUTLS_CRD_IA, NULL); + _gnutls_get_cred (session->key, GNUTLS_CRD_IA, NULL); if (cred == NULL) return 0; @@ -96,7 +96,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, GNUTLS_CRD_IA, NULL); + _gnutls_get_cred (session->key, GNUTLS_CRD_IA, NULL); if (cred == NULL) return 0; @@ -105,12 +105,12 @@ _gnutls_inner_application_send_params (gnutls_session_t session, client set app_phase_on_resumption to "yes" or if the server does not resume the session. */ if ((ext->peer_mode == GNUTLS_IA_APP_PHASE_ON_RESUMPTION_YES) || - !gnutls_session_is_resumed(session)) + !gnutls_session_is_resumed (session)) *data = YES; /* The server MAY set app_phase_on_resumption to "yes" for a - resumed session even if the client set - app_phase_on_resumption to "no", as the server may have - reason to proceed with one or more application phases. */ + resumed session even if the client set + app_phase_on_resumption to "no", as the server may have + reason to proceed with one or more application phases. */ else if (!ext->inner_phase_optional) *data = YES; else diff --git a/lib/ext_inner_application.h b/lib/ext_inner_application.h index 86e0a1e12c..e75719e3d5 100644 --- a/lib/ext_inner_application.h +++ b/lib/ext_inner_application.h @@ -22,8 +22,8 @@ * */ -int _gnutls_inner_application_recv_params(gnutls_session_t session, - const opaque * data, - size_t data_size); -int _gnutls_inner_application_send_params(gnutls_session_t session, - opaque * data, size_t); +int _gnutls_inner_application_recv_params (gnutls_session_t session, + const opaque * data, + size_t data_size); +int _gnutls_inner_application_send_params (gnutls_session_t session, + opaque * data, size_t); diff --git a/lib/ext_max_record.c b/lib/ext_max_record.c index 00d451e7c6..6289bcbe4c 100644 --- a/lib/ext_max_record.c +++ b/lib/ext_max_record.c @@ -121,7 +121,7 @@ _gnutls_max_record_send_params (gnutls_session_t session, opaque * data, data[0] = (uint8_t) _gnutls_mre_record2num (session->internals. - proposed_record_size); + proposed_record_size); return len; } @@ -141,8 +141,8 @@ _gnutls_max_record_send_params (gnutls_session_t session, opaque * data, data[0] = (uint8_t) _gnutls_mre_record2num (session-> - security_parameters. - max_record_recv_size); + security_parameters. + max_record_recv_size); return len; } diff --git a/lib/gnutls_algorithms.c b/lib/gnutls_algorithms.c index 864b9f9806..9dbff2e509 100644 --- a/lib/gnutls_algorithms.c +++ b/lib/gnutls_algorithms.c @@ -243,7 +243,8 @@ gnutls_kx_algo_entry _gnutls_kx_algorithms[MAX_KX_ALGOS] = { {"Anon DH", GNUTLS_KX_ANON_DH, &anon_auth_struct, 1, 0}, #endif {"RSA", GNUTLS_KX_RSA, &rsa_auth_struct, 0, 0}, - {"RSA EXPORT", GNUTLS_KX_RSA_EXPORT, &rsa_export_auth_struct, 0, 1 /* needs RSA params */}, + {"RSA EXPORT", GNUTLS_KX_RSA_EXPORT, &rsa_export_auth_struct, 0, + 1 /* needs RSA params */ }, {"DHE RSA", GNUTLS_KX_DHE_RSA, &dhe_rsa_auth_struct, 1, 0}, {"DHE DSS", GNUTLS_KX_DHE_DSS, &dhe_dss_auth_struct, 1, 0}, @@ -254,7 +255,8 @@ gnutls_kx_algo_entry _gnutls_kx_algorithms[MAX_KX_ALGOS] = { #endif #ifdef ENABLE_PSK {"PSK", GNUTLS_KX_PSK, &psk_auth_struct, 0, 0}, - {"DHE PSK", GNUTLS_KX_DHE_PSK, &dhe_psk_auth_struct, 1 /* needs DHE params */, 0}, + {"DHE PSK", GNUTLS_KX_DHE_PSK, &dhe_psk_auth_struct, + 1 /* needs DHE params */ , 0}, #endif /* other algorithms are appended here by gnutls-extra * initialization function. diff --git a/lib/gnutls_anon_cred.c b/lib/gnutls_anon_cred.c index 45a221e408..d9552b5e63 100644 --- a/lib/gnutls_anon_cred.c +++ b/lib/gnutls_anon_cred.c @@ -131,7 +131,7 @@ gnutls_anon_set_server_dh_params (gnutls_anon_server_credentials_t res, **/ void gnutls_anon_set_server_params_function (gnutls_anon_server_credentials_t res, - gnutls_params_function * func) + gnutls_params_function * func) { res->params_func = func; } diff --git a/lib/gnutls_auth.c b/lib/gnutls_auth.c index 926c754b1f..d72944321d 100644 --- a/lib/gnutls_auth.c +++ b/lib/gnutls_auth.c @@ -409,4 +409,3 @@ _gnutls_auth_info_set (gnutls_session_t session, } return 0; } - diff --git a/lib/gnutls_buffers.c b/lib/gnutls_buffers.c index 7034e5e868..497f196284 100644 --- a/lib/gnutls_buffers.c +++ b/lib/gnutls_buffers.c @@ -94,30 +94,30 @@ _gnutls_record_buffer_put (content_type_t type, { case GNUTLS_APPLICATION_DATA: buf = &session->internals.application_data_buffer; - _gnutls_buffers_log("BUF[REC]: Inserted %d bytes of Data(%d)\n", - length, type); + _gnutls_buffers_log ("BUF[REC]: Inserted %d bytes of Data(%d)\n", + length, type); break; case GNUTLS_HANDSHAKE: buf = &session->internals.handshake_data_buffer; - _gnutls_buffers_log("BUF[HSK]: Inserted %d bytes of Data(%d)\n", - length, type); + _gnutls_buffers_log ("BUF[HSK]: Inserted %d bytes of Data(%d)\n", + length, type); break; case GNUTLS_INNER_APPLICATION: buf = &session->internals.ia_data_buffer; - _gnutls_buffers_log("BUF[IA]: Inserted %d bytes of Data(%d)\n", - length, type); + _gnutls_buffers_log ("BUF[IA]: Inserted %d bytes of Data(%d)\n", + length, type); break; default: - gnutls_assert(); + gnutls_assert (); return GNUTLS_E_INVALID_REQUEST; } if (_gnutls_buffer_append (buf, data, length) < 0) { - gnutls_assert(); + gnutls_assert (); return GNUTLS_E_MEMORY_ERROR; } @@ -220,16 +220,16 @@ _gnutls_record_buffer_get (content_type_t type, if (length > session->internals.ia_data_buffer.length) length = session->internals.ia_data_buffer.length; - _gnutls_buffers_log("BUF[REC][IA]: Read %d bytes of Data(%d)\n", - length, type); + _gnutls_buffers_log ("BUF[REC][IA]: Read %d bytes of Data(%d)\n", + length, type); session->internals.ia_data_buffer.length -= length; - memcpy(data, session->internals.ia_data_buffer.data, length); + memcpy (data, session->internals.ia_data_buffer.data, length); /* overwrite buffer */ - memmove(session->internals.ia_data_buffer.data, - &session->internals.ia_data_buffer.data[length], - session->internals.ia_data_buffer.length); + memmove (session->internals.ia_data_buffer.data, + &session->internals.ia_data_buffer.data[length], + session->internals.ia_data_buffer.length); break; diff --git a/lib/gnutls_cert.c b/lib/gnutls_cert.c index 45bb53ab0a..d70b62805b 100644 --- a/lib/gnutls_cert.c +++ b/lib/gnutls_cert.c @@ -141,7 +141,8 @@ gnutls_certificate_free_ca_names (gnutls_certificate_credentials_t sc) * -*/ gnutls_rsa_params_t -_gnutls_certificate_get_rsa_params (gnutls_rsa_params_t rsa_params, gnutls_params_function* func, +_gnutls_certificate_get_rsa_params (gnutls_rsa_params_t rsa_params, + gnutls_params_function * func, gnutls_session_t session) { gnutls_params_st params; diff --git a/lib/gnutls_db.h b/lib/gnutls_db.h index 342886a47a..f06e6a51fb 100644 --- a/lib/gnutls_db.h +++ b/lib/gnutls_db.h @@ -24,7 +24,8 @@ int _gnutls_server_register_current_session (gnutls_session_t session); int _gnutls_server_restore_session (gnutls_session_t session, - uint8_t * session_id, int session_id_size); + uint8_t * session_id, + int session_id_size); int _gnutls_db_remove_session (gnutls_session_t session, uint8_t * session_id, int session_id_size); int _gnutls_store_session (gnutls_session_t session, diff --git a/lib/gnutls_dh.c b/lib/gnutls_dh.c index 76c851ecfe..4d1e99f83e 100644 --- a/lib/gnutls_dh.c +++ b/lib/gnutls_dh.c @@ -133,8 +133,9 @@ gnutls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime) * -*/ gnutls_dh_params_t -_gnutls_get_dh_params (gnutls_dh_params_t dh_params, gnutls_params_function* func, - gnutls_session_t session) +_gnutls_get_dh_params (gnutls_dh_params_t dh_params, + gnutls_params_function * func, + gnutls_session_t session) { gnutls_params_st params; int ret; diff --git a/lib/gnutls_dh.h b/lib/gnutls_dh.h index f6fea3fe5f..0048889ee8 100644 --- a/lib/gnutls_dh.h +++ b/lib/gnutls_dh.h @@ -31,7 +31,8 @@ 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); gnutls_dh_params_t -_gnutls_get_dh_params (gnutls_dh_params_t dh_params, gnutls_params_function* func, - gnutls_session_t session); +_gnutls_get_dh_params (gnutls_dh_params_t dh_params, + gnutls_params_function * func, + gnutls_session_t session); #endif diff --git a/lib/gnutls_errors.c b/lib/gnutls_errors.c index 4307318425..e7cb7cdfe1 100644 --- a/lib/gnutls_errors.c +++ b/lib/gnutls_errors.c @@ -234,12 +234,12 @@ static gnutls_error_entry error_algorithms[] = { ERROR_ENTRY ("Failed to acquire random data.", GNUTLS_E_RANDOM_FAILED, 1), - ERROR_ENTRY("Received a TLS/IA Intermediate Phase Finished message", - GNUTLS_E_WARNING_IA_IPHF_RECEIVED, 0), - ERROR_ENTRY("Received a TLS/IA Final Phase Finished message", - GNUTLS_E_WARNING_IA_FPHF_RECEIVED, 0), - ERROR_ENTRY("Verifying TLS/IA phase checksum failed", - GNUTLS_E_IA_VERIFY_FAILED, 1), + ERROR_ENTRY ("Received a TLS/IA Intermediate Phase Finished message", + GNUTLS_E_WARNING_IA_IPHF_RECEIVED, 0), + ERROR_ENTRY ("Received a TLS/IA Final Phase Finished message", + GNUTLS_E_WARNING_IA_FPHF_RECEIVED, 0), + ERROR_ENTRY ("Verifying TLS/IA phase checksum failed", + GNUTLS_E_IA_VERIFY_FAILED, 1), {NULL, NULL, 0, 0} }; diff --git a/lib/gnutls_extensions.c b/lib/gnutls_extensions.c index def360b895..c1ea2cfd11 100644 --- a/lib/gnutls_extensions.c +++ b/lib/gnutls_extensions.c @@ -60,9 +60,9 @@ gnutls_extension_entry _gnutls_extensions[MAX_EXT_SIZE] = { _gnutls_srp_recv_params, _gnutls_srp_send_params), #endif - GNUTLS_EXTENSION_ENTRY(GNUTLS_EXTENSION_INNER_APPLICATION, - _gnutls_inner_application_recv_params, - _gnutls_inner_application_send_params), + GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_INNER_APPLICATION, + _gnutls_inner_application_recv_params, + _gnutls_inner_application_send_params), {0, 0, 0, 0} }; @@ -246,9 +246,9 @@ _gnutls_gen_extensions (gnutls_session_t session, opaque * data, } pos += 2; - for(p = _gnutls_extensions; p->name != NULL; p++) + for (p = _gnutls_extensions; p->name != NULL; p++) { - ext_send = _gnutls_ext_func_send(p->type); + ext_send = _gnutls_ext_func_send (p->type); if (ext_send == NULL) continue; size = ext_send (session, sdata, sdata_size); @@ -262,7 +262,7 @@ _gnutls_gen_extensions (gnutls_session_t session, opaque * data, } /* write extension type */ - _gnutls_write_uint16(p->type, &data[pos]); + _gnutls_write_uint16 (p->type, &data[pos]); pos += 2; /* write size */ @@ -274,7 +274,7 @@ _gnutls_gen_extensions (gnutls_session_t session, opaque * data, /* add this extension to the extension list */ - _gnutls_extension_list_add(session, p->type); + _gnutls_extension_list_add (session, p->type); _gnutls_debug_log ("EXT[%x]: Sending extension %s\n", session, _gnutls_extension_get_name (p->type)); diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c index 23c4e83ef7..bf314aea1b 100644 --- a/lib/gnutls_handshake.c +++ b/lib/gnutls_handshake.c @@ -1887,7 +1887,7 @@ _gnutls_send_server_hello (gnutls_session_t session, int again) comp = (uint8_t) _gnutls_compression_get_num (session-> - internals.compression_method); + internals.compression_method); data[pos++] = comp; @@ -2593,9 +2593,13 @@ check_server_params (gnutls_session_t session, if (x509_cred != NULL) { - dh_params = _gnutls_get_dh_params (x509_cred->dh_params, x509_cred->params_func, session); + dh_params = + _gnutls_get_dh_params (x509_cred->dh_params, + x509_cred->params_func, session); rsa_params = - _gnutls_certificate_get_rsa_params (x509_cred->rsa_params, x509_cred->params_func, session); + _gnutls_certificate_get_rsa_params (x509_cred->rsa_params, + x509_cred->params_func, + session); } /* Check also if the certificate supports the @@ -2624,7 +2628,9 @@ check_server_params (gnutls_session_t session, if (anon_cred != NULL) { - dh_params = _gnutls_get_dh_params (anon_cred->dh_params, anon_cred->params_func, session); + dh_params = + _gnutls_get_dh_params (anon_cred->dh_params, + anon_cred->params_func, session); } #endif #ifdef ENABLE_PSK @@ -2633,11 +2639,13 @@ check_server_params (gnutls_session_t session, { gnutls_psk_server_credentials_t psk_cred = (gnutls_psk_server_credentials_t) _gnutls_get_cred (session->key, - cred_type, NULL); + cred_type, NULL); if (psk_cred != NULL) { - dh_params = _gnutls_get_dh_params (psk_cred->dh_params, psk_cred->params_func, session); + dh_params = + _gnutls_get_dh_params (psk_cred->dh_params, psk_cred->params_func, + session); } #endif } @@ -2651,19 +2659,21 @@ check_server_params (gnutls_session_t session, if (_gnutls_kx_needs_rsa_params (kx) != 0) { /* needs rsa params. */ - if (_gnutls_rsa_params_to_mpi (rsa_params) == NULL) { - gnutls_assert(); - return 1; - } + if (_gnutls_rsa_params_to_mpi (rsa_params) == NULL) + { + gnutls_assert (); + return 1; + } } if (_gnutls_kx_needs_dh_params (kx) != 0) { /* needs DH params. */ - if (_gnutls_dh_params_to_mpi (dh_params) == NULL) { - gnutls_assert(); - return 1; - } + if (_gnutls_dh_params_to_mpi (dh_params) == NULL) + { + gnutls_assert (); + return 1; + } } return 0; diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h index f3af0d50a3..5f54da8a8f 100644 --- a/lib/gnutls_int.h +++ b/lib/gnutls_int.h @@ -398,7 +398,7 @@ typedef struct 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) */ + gnutls_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 diff --git a/lib/gnutls_mpi.c b/lib/gnutls_mpi.c index 5385f795e8..d031f854b6 100644 --- a/lib/gnutls_mpi.c +++ b/lib/gnutls_mpi.c @@ -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) +_gnutls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a) { int ret; opaque *buf = NULL; diff --git a/lib/gnutls_mpi.h b/lib/gnutls_mpi.h index 8d83aaba9d..5fdfb3498b 100644 --- a/lib/gnutls_mpi.h +++ b/lib/gnutls_mpi.h @@ -72,6 +72,6 @@ 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 _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 _gnutls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a); #endif diff --git a/lib/gnutls_pk.c b/lib/gnutls_pk.c index 020e64c0e7..514b87bd07 100644 --- a/lib/gnutls_pk.c +++ b/lib/gnutls_pk.c @@ -54,7 +54,8 @@ static int _gnutls_pk_decrypt (int algo, mpi_t * resarr, mpi_t data, int _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext, const gnutls_datum_t * plaintext, - mpi_t * params, unsigned params_len, unsigned btype) + mpi_t * params, unsigned params_len, + unsigned btype) { unsigned int i, pad; int ret; @@ -207,7 +208,8 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext, int _gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext, const gnutls_datum_t * ciphertext, - mpi_t * params, unsigned params_len, unsigned btype) + mpi_t * params, unsigned params_len, + unsigned btype) { unsigned k, i; int ret; diff --git a/lib/gnutls_pk.h b/lib/gnutls_pk.h index 422d0079b5..55d2b8afa7 100644 --- a/lib/gnutls_pk.h +++ b/lib/gnutls_pk.h @@ -27,13 +27,15 @@ int _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext, const gnutls_datum_t * plaintext, - mpi_t * params, unsigned params_len, unsigned btype); + mpi_t * params, unsigned params_len, + unsigned btype); int _gnutls_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, const gnutls_datum_t * ciphertext, - mpi_t * params, unsigned params_len, unsigned btype); + mpi_t * params, unsigned params_len, + unsigned btype); int _gnutls_rsa_verify (const gnutls_datum_t * vdata, const gnutls_datum_t * ciphertext, mpi_t * params, int params_len, int btype); diff --git a/lib/gnutls_psk.c b/lib/gnutls_psk.c index 47559bfd50..f544ce4fe5 100644 --- a/lib/gnutls_psk.c +++ b/lib/gnutls_psk.c @@ -299,8 +299,8 @@ gnutls_psk_server_get_username (gnutls_session_t session) info = _gnutls_get_auth_info (session); if (info == NULL) return NULL; - - if (info->username[0] != 0) + + if (info->username[0] != 0) return info->username; return NULL; @@ -374,7 +374,7 @@ gnutls_hex_encode (const gnutls_datum_t * data, char *result, **/ void gnutls_psk_set_server_dh_params (gnutls_psk_server_credentials_t res, - gnutls_dh_params_t dh_params) + gnutls_dh_params_t dh_params) { res->dh_params = dh_params; } @@ -391,7 +391,7 @@ gnutls_psk_set_server_dh_params (gnutls_psk_server_credentials_t res, **/ void gnutls_psk_set_server_params_function (gnutls_psk_server_credentials_t res, - gnutls_params_function * func) + gnutls_params_function * func) { res->params_func = func; } diff --git a/lib/gnutls_record.c b/lib/gnutls_record.c index 24930ad144..c23a4b3d02 100644 --- a/lib/gnutls_record.c +++ b/lib/gnutls_record.c @@ -533,7 +533,8 @@ check_buffers (gnutls_session_t session, content_type_t type, */ static int record_check_headers (gnutls_session_t session, - uint8_t headers[RECORD_HEADER_SIZE], content_type_t type, + uint8_t headers[RECORD_HEADER_SIZE], + content_type_t type, gnutls_handshake_description_t htype, /*output */ content_type_t * recv_type, opaque version[2], uint16_t * length, @@ -638,8 +639,7 @@ record_check_type (gnutls_session_t session, if ((recv_type == type) && (type == GNUTLS_APPLICATION_DATA || - type == GNUTLS_HANDSHAKE || - type == GNUTLS_INNER_APPLICATION)) + type == GNUTLS_HANDSHAKE || type == GNUTLS_INNER_APPLICATION)) { _gnutls_record_buffer_put (type, session, (void *) data, data_size); } @@ -738,13 +738,14 @@ record_check_type (gnutls_session_t session, 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, - data_size)) < 0) { - gnutls_assert(); - return ret; - } - gnutls_assert(); + if ((ret = _gnutls_record_buffer_put (recv_type, session, + (void *) data, + data_size)) < 0) + { + gnutls_assert (); + return ret; + } + gnutls_assert (); return GNUTLS_E_UNEXPECTED_PACKET; break; default: @@ -1026,8 +1027,7 @@ begin: */ if ((recv_type == type) && (type == GNUTLS_APPLICATION_DATA || - type == GNUTLS_HANDSHAKE || - type == GNUTLS_INNER_APPLICATION)) + type == GNUTLS_HANDSHAKE || type == GNUTLS_INNER_APPLICATION)) { ret = _gnutls_record_buffer_get (type, session, data, sizeofdata); diff --git a/lib/gnutls_session.c b/lib/gnutls_session.c index edded34215..1d500e28ec 100644 --- a/lib/gnutls_session.c +++ b/lib/gnutls_session.c @@ -127,7 +127,7 @@ int gnutls_session_get_id (gnutls_session_t session, void *session_id, size_t * session_id_size) { -size_t given_session_id_size = *session_id_size; + size_t given_session_id_size = *session_id_size; *session_id_size = session->security_parameters.session_id_size; @@ -137,9 +137,9 @@ size_t given_session_id_size = *session_id_size; return 0; } - if ( given_session_id_size < session->security_parameters.session_id_size) + if (given_session_id_size < session->security_parameters.session_id_size) { - return GNUTLS_E_SHORT_MEMORY_BUFFER; + return GNUTLS_E_SHORT_MEMORY_BUFFER; } memcpy (session_id, &session->security_parameters.session_id, diff --git a/lib/gnutls_session_pack.c b/lib/gnutls_session_pack.c index 6cf9542a14..68dc9b29eb 100644 --- a/lib/gnutls_session_pack.c +++ b/lib/gnutls_session_pack.c @@ -270,7 +270,7 @@ pack_certificate_auth_info (gnutls_session_t session, if (info) { cert_size = 4; - + for (i = 0; i < info->ncerts; i++) cert_size += 4 + info->raw_certificate_list[i].size; @@ -325,8 +325,8 @@ pack_certificate_auth_info (gnutls_session_t session, for (i = 0; i < info->ncerts; i++) { - _gnutls_write_datum32 (&packed_session->data[pos], - info->raw_certificate_list[i]); + _gnutls_write_datum32 (&packed_session->data[pos], + info->raw_certificate_list[i]); pos += sizeof (uint32_t) + info->raw_certificate_list[i].size; } } @@ -445,17 +445,17 @@ unpack_certificate_auth_info (gnutls_session_t session, info->ncerts = _gnutls_read_uint32 (&packed_session->data[pos]); pos += 4; - - if (info->ncerts > 0) + + if (info->ncerts > 0) { - info->raw_certificate_list = - gnutls_calloc (1, sizeof (gnutls_datum_t) * info->ncerts); + info->raw_certificate_list = + gnutls_calloc (1, sizeof (gnutls_datum_t) * info->ncerts); if (info->raw_certificate_list == NULL) - { - gnutls_assert (); - ret = GNUTLS_E_MEMORY_ERROR; - goto error; - } + { + gnutls_assert (); + ret = GNUTLS_E_MEMORY_ERROR; + goto error; + } } for (i = 0; i < info->ncerts; i++) @@ -789,11 +789,14 @@ pack_psk_auth_info (gnutls_session_t session, gnutls_datum * packed_session) return GNUTLS_E_INVALID_REQUEST; } - if (info) { - username_size = strlen (info->username) + 1; /* include the terminating null */ - pack_size = username_size + - 2 + 4 * 3 + info->dh.prime.size + info->dh.generator.size + info->dh.public_key.size; - } else + if (info) + { + username_size = strlen (info->username) + 1; /* include the terminating null */ + pack_size = username_size + + 2 + 4 * 3 + info->dh.prime.size + info->dh.generator.size + + info->dh.public_key.size; + } + else pack_size = 0; packed_session->size = PACK_HEADER_SIZE + pack_size + sizeof (uint32_t); @@ -810,21 +813,21 @@ pack_psk_auth_info (gnutls_session_t session, gnutls_datum * packed_session) } pos = 0; - + packed_session->data[pos] = GNUTLS_CRD_PSK; pos++; _gnutls_write_uint32 (pack_size, &packed_session->data[pos]); - pos+=4; + pos += 4; - if (pack_size > 0) + if (pack_size > 0) { _gnutls_write_uint32 (username_size, &packed_session->data[pos]); - pos+=4; + pos += 4; memcpy (&packed_session->data[pos], info->username, username_size); - pos+=username_size; + pos += username_size; _gnutls_write_uint16 (info->dh.secret_bits, &packed_session->data[pos]); pos += 2; @@ -844,7 +847,7 @@ pack_psk_auth_info (gnutls_session_t session, gnutls_datum * packed_session) static int unpack_psk_auth_info (gnutls_session_t session, - const gnutls_datum * packed_session) + const gnutls_datum * packed_session) { size_t username_size; size_t pack_size; @@ -889,14 +892,11 @@ unpack_psk_auth_info (gnutls_session_t session, return GNUTLS_E_INTERNAL_ERROR; } - username_size = - _gnutls_read_uint32 (&packed_session->data[pos]); - pos+=4; - - memcpy (info->username, - &packed_session->data[pos], - username_size); - pos+=username_size; + username_size = _gnutls_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]); pos += 2; diff --git a/lib/gnutls_state.c b/lib/gnutls_state.c index 6da385c5f1..401bd0217b 100644 --- a/lib/gnutls_state.c +++ b/lib/gnutls_state.c @@ -262,7 +262,7 @@ gnutls_init (gnutls_session_t * session, gnutls_connection_end_t con_end) _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); + _gnutls_buffer_init (&(*session)->internals.ia_data_buffer); _gnutls_buffer_init (&(*session)->internals.record_send_buffer); _gnutls_buffer_init (&(*session)->internals.record_recv_buffer); @@ -355,7 +355,7 @@ gnutls_deinit (gnutls_session_t 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.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); @@ -932,21 +932,14 @@ 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) + size_t seed_size, const char *seed, size_t outsize, char *out) { int ret; ret = _gnutls_PRF (session->security_parameters.master_secret, TLS_MASTER_SIZE, label, - label_size, - (opaque*) seed, - seed_size, - outsize, - out); + label_size, (opaque *) seed, seed_size, outsize, out); return ret; } @@ -985,10 +978,7 @@ 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) + size_t extra_size, const char *extra, size_t outsize, char *out) { int ret; opaque *seed; @@ -997,7 +987,7 @@ gnutls_prf (gnutls_session_t session, seed = gnutls_malloc (seedsize); if (!seed) { - gnutls_assert(); + gnutls_assert (); return GNUTLS_E_MEMORY_ERROR; } @@ -1006,19 +996,13 @@ gnutls_prf (gnutls_session_t session, session->security_parameters.client_random, TLS_RANDOM_SIZE); memcpy (seed + TLS_RANDOM_SIZE, server_random_first ? session->security_parameters.client_random : - session->security_parameters.server_random, - TLS_RANDOM_SIZE); + session->security_parameters.server_random, TLS_RANDOM_SIZE); memcpy (seed + 2 * TLS_RANDOM_SIZE, extra, extra_size); ret = _gnutls_PRF (session->security_parameters.master_secret, TLS_MASTER_SIZE, - label, - label_size, - seed, - seedsize, - outsize, - out); + label, label_size, seed, seedsize, outsize, out); gnutls_free (seed); @@ -1041,7 +1025,7 @@ gnutls_prf (gnutls_session_t session, const char * gnutls_session_get_client_random (gnutls_session_t session) { - return (char*) session->security_parameters.client_random; + return (char *) session->security_parameters.client_random; } /** @@ -1060,7 +1044,7 @@ gnutls_session_get_client_random (gnutls_session_t session) const char * gnutls_session_get_server_random (gnutls_session_t session) { - return (char*) session->security_parameters.server_random; + return (char *) session->security_parameters.server_random; } /** diff --git a/lib/gnutls_ui.c b/lib/gnutls_ui.c index 5194586702..66e33f8568 100644 --- a/lib/gnutls_ui.c +++ b/lib/gnutls_ui.c @@ -662,7 +662,7 @@ gnutls_certificate_set_rsa_export_params (gnutls_certificate_credentials_t **/ void gnutls_psk_set_params_function (gnutls_psk_server_credentials_t res, - gnutls_params_function * func) + gnutls_params_function * func) { res->params_func = func; } @@ -681,7 +681,7 @@ gnutls_psk_set_params_function (gnutls_psk_server_credentials_t res, **/ void gnutls_anon_set_params_function (gnutls_anon_server_credentials_t res, - gnutls_params_function * func) + gnutls_params_function * func) { res->params_func = func; } diff --git a/lib/gnutls_x509.c b/lib/gnutls_x509.c index 1f4725820c..d52e89a7fa 100644 --- a/lib/gnutls_x509.c +++ b/lib/gnutls_x509.c @@ -266,7 +266,7 @@ _gnutls_check_key_cert_match (gnutls_certificate_credentials_t res) * returns the number of certificates parsed (1) */ static int -parse_crt_mem (gnutls_cert ** cert_list, unsigned * ncerts, +parse_crt_mem (gnutls_cert ** cert_list, unsigned *ncerts, gnutls_x509_crt_t cert) { int i; @@ -301,7 +301,7 @@ parse_crt_mem (gnutls_cert ** cert_list, unsigned * ncerts, * returns the number of certificates parsed (1) */ static int -parse_der_cert_mem (gnutls_cert ** cert_list, unsigned * ncerts, +parse_der_cert_mem (gnutls_cert ** cert_list, unsigned *ncerts, const void *input_cert, int input_cert_size) { gnutls_datum_t tmp; @@ -340,7 +340,7 @@ parse_der_cert_mem (gnutls_cert ** cert_list, unsigned * ncerts, * returns the number of certificate parsed */ static int -parse_pkcs7_cert_mem (gnutls_cert ** cert_list, unsigned * ncerts, const +parse_pkcs7_cert_mem (gnutls_cert ** cert_list, unsigned *ncerts, const void *input_cert, int input_cert_size, int flags) { #ifdef ENABLE_PKI @@ -463,7 +463,7 @@ parse_pkcs7_cert_mem (gnutls_cert ** cert_list, unsigned * ncerts, const * a gnutls_cert structure. Returns the number of certificate parsed. */ static int -parse_pem_cert_mem (gnutls_cert ** cert_list, unsigned * ncerts, +parse_pem_cert_mem (gnutls_cert ** cert_list, unsigned *ncerts, const char *input_cert, int input_cert_size) { int size, siz2, i; @@ -1214,7 +1214,7 @@ _gnutls_check_key_usage (const gnutls_cert * cert, gnutls_kx_algorithm_t alg) static int -parse_pem_ca_mem (gnutls_x509_crt_t ** cert_list, unsigned * ncerts, +parse_pem_ca_mem (gnutls_x509_crt_t ** cert_list, unsigned *ncerts, const opaque * input_cert, int input_cert_size) { int i, size; @@ -1312,7 +1312,7 @@ parse_pem_ca_mem (gnutls_x509_crt_t ** cert_list, unsigned * ncerts, * returns the number of certificates parsed (1) */ static int -parse_der_ca_mem (gnutls_x509_crt_t ** cert_list, unsigned * ncerts, +parse_der_ca_mem (gnutls_x509_crt_t ** cert_list, unsigned *ncerts, const void *input_cert, int input_cert_size) { int i; @@ -1516,7 +1516,7 @@ gnutls_certificate_set_x509_trust_file (gnutls_certificate_credentials_t #ifdef ENABLE_PKI static int -parse_pem_crl_mem (gnutls_x509_crl_t ** crl_list, unsigned * ncrls, +parse_pem_crl_mem (gnutls_x509_crl_t ** crl_list, unsigned *ncrls, const opaque * input_crl, int input_crl_size) { int size, i; @@ -1601,7 +1601,7 @@ parse_pem_crl_mem (gnutls_x509_crl_t ** crl_list, unsigned * ncrls, * returns the number of certificates parsed (1) */ static int -parse_der_crl_mem (gnutls_x509_crl_t ** crl_list, unsigned * ncrls, +parse_der_crl_mem (gnutls_x509_crl_t ** crl_list, unsigned *ncrls, const void *input_crl, int input_crl_size) { int i; @@ -1810,9 +1810,8 @@ static int parse_pkcs12 (gnutls_certificate_credentials_t res, gnutls_pkcs12_t p12, const char *password, - gnutls_x509_privkey *key, - gnutls_x509_crt_t *cert, - gnutls_x509_crl_t *crl) + gnutls_x509_privkey * key, + gnutls_x509_crt_t * cert, gnutls_x509_crl_t * crl) { gnutls_pkcs12_bag bag = NULL; int index = 0; @@ -1912,7 +1911,8 @@ parse_pkcs12 (gnutls_certificate_credentials_t res, goto done; } - ret = gnutls_x509_crt_import (*cert, &data, GNUTLS_X509_FMT_DER); + ret = + gnutls_x509_crt_import (*cert, &data, GNUTLS_X509_FMT_DER); if (ret < 0) { gnutls_assert (); @@ -1938,7 +1938,7 @@ parse_pkcs12 (gnutls_certificate_credentials_t res, case GNUTLS_BAG_ENCRYPTED: /* XXX Bother to recurse one level down? Unlikely to - use the same password anyway. */ + use the same password anyway. */ case GNUTLS_BAG_EMPTY: default: break; @@ -1951,7 +1951,7 @@ parse_pkcs12 (gnutls_certificate_credentials_t res, ret = 0; - done: +done: if (bag) gnutls_pkcs12_bag_deinit (bag); @@ -1991,10 +1991,9 @@ parse_pkcs12 (gnutls_certificate_credentials_t res, * Return value: Returns 0 on success, or an error code. **/ 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) + gnutls_certificate_set_x509_simple_pkcs12_file + (gnutls_certificate_credentials_t res, const char *pkcs12file, + gnutls_x509_crt_fmt_t type, const char *password) { gnutls_pkcs12_t p12; gnutls_datum_t p12blob; @@ -2072,7 +2071,7 @@ gnutls_certificate_set_x509_simple_pkcs12_file (gnutls_certificate_credentials_t ret = 0; - done: +done: if (cert) gnutls_x509_crt_deinit (cert); if (key) diff --git a/lib/x509/mpi.h b/lib/x509/mpi.h index f748155881..6d11aede46 100644 --- a/lib/x509/mpi.h +++ b/lib/x509/mpi.h @@ -45,7 +45,8 @@ int _gnutls_x509_read_int (ASN1_TYPE node, const char *value, mpi_t * ret_mpi); int _gnutls_x509_write_int (ASN1_TYPE node, const char *value, mpi_t mpi, int lz); -int _gnutls_x509_write_uint32 (ASN1_TYPE node, const char *value, uint32_t num); +int _gnutls_x509_write_uint32 (ASN1_TYPE node, const char *value, + uint32_t num); int _gnutls_x509_write_sig_params (ASN1_TYPE dst, const char *dst_name, gnutls_pk_algorithm_t pk_algorithm, diff --git a/lib/x509_b64.c b/lib/x509_b64.c index d4313170ce..c433291764 100644 --- a/lib/x509_b64.c +++ b/lib/x509_b64.c @@ -142,7 +142,8 @@ decode (uint8_t * result, const opaque * data) * The result_size is the return value */ int -_gnutls_base64_encode (const uint8_t * data, size_t data_size, uint8_t ** result) +_gnutls_base64_encode (const uint8_t * data, size_t data_size, + uint8_t ** result) { unsigned int i, j; int ret, tmp; @@ -365,7 +366,8 @@ gnutls_pem_base64_encode_alloc (const char *msg, * The result_size is the return value */ int -_gnutls_base64_decode (const uint8_t * data, size_t data_size, uint8_t ** result) +_gnutls_base64_decode (const uint8_t * data, size_t data_size, + uint8_t ** result) { unsigned int i, j; int ret, tmp, est; diff --git a/libextra/gnutls_ia.c b/libextra/gnutls_ia.c index 56677ee772..3df7b8befe 100644 --- a/libextra/gnutls_ia.c +++ b/libextra/gnutls_ia.c @@ -111,7 +111,7 @@ _gnutls_send_inner_application (gnutls_session_t session, static ssize_t _gnutls_recv_inner_application (gnutls_session_t session, gnutls_ia_apptype_t * msg_type, - opaque *data, size_t sizeofdata) + opaque * data, size_t sizeofdata) { ssize_t len; opaque pkt[4]; @@ -166,9 +166,7 @@ _gnutls_ia_prf (gnutls_session_t session, size_t label_size, const char *label, size_t extra_size, - const char *extra, - size_t outsize, - opaque *out) + const char *extra, size_t outsize, opaque * out) { int ret; opaque *seed; @@ -177,7 +175,7 @@ _gnutls_ia_prf (gnutls_session_t session, seed = gnutls_malloc (seedsize); if (!seed) { - gnutls_assert(); + gnutls_assert (); return GNUTLS_E_MEMORY_ERROR; } @@ -188,12 +186,7 @@ _gnutls_ia_prf (gnutls_session_t session, ret = _gnutls_PRF (session->security_parameters.inner_secret, TLS_MASTER_SIZE, - label, - label_size, - seed, - seedsize, - outsize, - out); + label, label_size, seed, seedsize, outsize, out); gnutls_free (seed); @@ -241,16 +234,11 @@ gnutls_ia_permute_inner_secret (gnutls_session_t session, **/ int gnutls_ia_generate_challenge (gnutls_session_t session, - size_t buffer_size, - char *buffer) + size_t buffer_size, char *buffer) { return _gnutls_ia_prf (session, sizeof (challenge_label) - 1, - challenge_label, - 0, - NULL, - buffer_size, - buffer); + challenge_label, 0, NULL, buffer_size, buffer); } /** @@ -270,8 +258,7 @@ 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 (gnutls_session_t session, char *buffer) { memcpy (buffer, session->security_parameters.inner_secret, TLS_MASTER_SIZE); } @@ -292,7 +279,7 @@ gnutls_ia_extract_inner_secret (gnutls_session_t session, * 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 (gnutls_session_t session, int final_p) { opaque local_checksum[CHECKSUM_SIZE]; int client = session->security_parameters.entity == GNUTLS_CLIENT; @@ -303,8 +290,7 @@ gnutls_ia_endphase_send(gnutls_session_t session, int final_p) int ret; ret = _gnutls_PRF (session->security_parameters.inner_secret, - TLS_MASTER_SIZE, - label, size_of_label - 1, + TLS_MASTER_SIZE, label, size_of_label - 1, /* XXX specification unclear on seed. */ "", 0, CHECKSUM_SIZE, local_checksum); if (ret < 0) @@ -313,8 +299,7 @@ gnutls_ia_endphase_send(gnutls_session_t session, int final_p) len = _gnutls_send_inner_application (session, final_p ? GNUTLS_IA_FINAL_PHASE_FINISHED : - GNUTLS_IA_INTERMEDIATE_PHASE_FINISHED, - local_checksum, CHECKSUM_SIZE); + GNUTLS_IA_INTERMEDIATE_PHASE_FINISHED, local_checksum, CHECKSUM_SIZE); /* XXX Instead of calling this function over and over...? * while (len == GNUTLS_E_AGAIN || len == GNUTLS_E_INTERRUPTED) @@ -323,7 +308,7 @@ gnutls_ia_endphase_send(gnutls_session_t session, int final_p) if (len < 0) { - gnutls_assert(); + gnutls_assert (); return len; } @@ -453,8 +438,7 @@ gnutls_ia_recv (gnutls_session_t session, char *data, size_t sizeofdata) gnutls_ia_apptype_t msg_type; ssize_t len; - len = _gnutls_recv_inner_application (session, &msg_type, - data, sizeofdata); + len = _gnutls_recv_inner_application (session, &msg_type, data, sizeofdata); if (msg_type == GNUTLS_IA_INTERMEDIATE_PHASE_FINISHED) return GNUTLS_E_WARNING_IA_IPHF_RECEIVED; @@ -476,7 +460,7 @@ _gnutls_ia_client_handshake (gnutls_session_t session) char tmp[1024]; /* XXX */ ssize_t len; int ret; - const struct gnutls_ia_client_credentials_st * cred = + const struct gnutls_ia_client_credentials_st *cred = _gnutls_get_cred (session->key, GNUTLS_CRD_IA, NULL); if (cred == NULL) @@ -544,7 +528,7 @@ _gnutls_ia_server_handshake (gnutls_session_t session) ssize_t len; char buf[1024]; int ret; - const struct gnutls_ia_server_credentials_st * cred = + const struct gnutls_ia_server_credentials_st *cred = _gnutls_get_cred (session->key, GNUTLS_CRD_IA, NULL); if (cred == NULL) diff --git a/libextra/openpgp/gnutls_openpgp.h b/libextra/openpgp/gnutls_openpgp.h index efcb396df5..a84b903981 100644 --- a/libextra/openpgp/gnutls_openpgp.h +++ b/libextra/openpgp/gnutls_openpgp.h @@ -57,7 +57,8 @@ int gnutls_openpgp_get_key (gnutls_datum_t * key, key_attr_t by, opaque * pattern); int gnutls_openpgp_recv_key (const char *host, - short port, uint32_t keyid, gnutls_datum_t * key); + short port, uint32_t keyid, + gnutls_datum_t * key); /* internal */ int _gnutls_openpgp_raw_key_to_gcert (gnutls_cert * cert, diff --git a/src/common.c b/src/common.c index d57147f1e1..02de9203de 100644 --- a/src/common.c +++ b/src/common.c @@ -520,13 +520,14 @@ print_info (gnutls_session session, const char *hostname) if (gnutls_psk_server_get_username (session) != NULL) printf ("- PSK authentication. Connected as '%s'\n", gnutls_psk_server_get_username (session)); - if (kx == GNUTLS_KX_DHE_PSK) { - printf ("- DH using prime of %d bits, secret key " - "of %d bits, and peer's public key is %d bits.\n", - gnutls_dh_get_prime_bits (session), - gnutls_dh_get_secret_bits (session), - gnutls_dh_get_peers_public_bits (session)); - } + if (kx == GNUTLS_KX_DHE_PSK) + { + printf ("- DH using prime of %d bits, secret key " + "of %d bits, and peer's public key is %d bits.\n", + gnutls_dh_get_prime_bits (session), + gnutls_dh_get_secret_bits (session), + gnutls_dh_get_peers_public_bits (session)); + } break; #endif case GNUTLS_CRD_CERTIFICATE: diff --git a/src/serv.c b/src/serv.c index 6c6bfc5fcc..57cb9136f5 100644 --- a/src/serv.c +++ b/src/serv.c @@ -118,11 +118,12 @@ static int wrap_db_delete (void *dbf, gnutls_datum key); #define HTTP_STATE_RESPONSE 2 #define HTTP_STATE_CLOSING 3 -LIST_TYPE_DECLARE (listener_item, char *http_request; - char *http_response; int request_length; - int response_length; int response_written; - int http_state; - int fd; gnutls_session tls_session; int handshake_ok;); +LIST_TYPE_DECLARE (listener_item, char *http_request; char *http_response; + int request_length; int response_length; + int response_written; int http_state; int fd; + gnutls_session tls_session; + int handshake_ok; + ); static const char * safe_strerror (int value) @@ -237,13 +238,19 @@ get_params (gnutls_session session, gnutls_params_type type, gnutls_params_st * st) { - if (type == GNUTLS_PARAMS_RSA_EXPORT) { - if (rsa_params == NULL) return -1; - st->params.rsa_export = rsa_params; - } else if (type == GNUTLS_PARAMS_DH) { - if (dh_params == NULL) return -1; - st->params.dh = dh_params; - } else + if (type == GNUTLS_PARAMS_RSA_EXPORT) + { + if (rsa_params == NULL) + return -1; + st->params.rsa_export = rsa_params; + } + else if (type == GNUTLS_PARAMS_DH) + { + if (dh_params == NULL) + return -1; + st->params.dh = dh_params; + } + else return -1; st->type = type; @@ -764,7 +771,7 @@ main (int argc, char **argv) exit (1); } - gnutls_certificate_set_params_function (cert_cred, get_params); + gnutls_certificate_set_params_function (cert_cred, get_params); /* gnutls_certificate_set_dh_params(cert_cred, dh_params); * gnutls_certificate_set_rsa_export_params(cert_cred, rsa_params); */ diff --git a/tests/dhepskself.c b/tests/dhepskself.c index fff760179e..57a6a555f2 100644 --- a/tests/dhepskself.c +++ b/tests/dhepskself.c @@ -256,11 +256,11 @@ server_start (void) gnutls_global_set_log_function (tls_log_func); // gnutls_global_set_log_level (99); - generate_dh_params(); + generate_dh_params (); gnutls_psk_allocate_server_credentials (&server_pskcred); gnutls_psk_set_server_credentials_function (server_pskcred, pskfunc); - gnutls_psk_set_server_dh_params( server_pskcred, dh_params); + gnutls_psk_set_server_dh_params (server_pskcred, dh_params); success ("Launched, generating DH parameters...\n"); diff --git a/tests/tlsia.c b/tests/tlsia.c index be4fde9e76..2aeb6ee218 100644 --- a/tests/tlsia.c +++ b/tests/tlsia.c @@ -64,7 +64,7 @@ tcp_connect (void) sa.sin_port = htons (atoi (PORT)); inet_pton (AF_INET, SERVER, &sa.sin_addr); - err = connect (sd, (struct sockaddr *) & sa, sizeof (sa)); + err = connect (sd, (struct sockaddr *) &sa, sizeof (sa)); if (err < 0) { fprintf (stderr, "Connect error\n"); @@ -83,9 +83,9 @@ tcp_close (int sd) close (sd); } -int client_avp (gnutls_session_t session, void *ptr, - const char *last, size_t lastlen, - char **new, size_t *newlen) +int +client_avp (gnutls_session_t session, void *ptr, + const char *last, size_t lastlen, char **new, size_t * newlen) { static int iter = 0; char *p; @@ -145,10 +145,10 @@ client (void) const int kx_prio[] = { GNUTLS_KX_ANON_DH, 0 }; gnutls_global_init (); - gnutls_global_init_extra(); + gnutls_global_init_extra (); gnutls_anon_allocate_client_credentials (&anoncred); - gnutls_ia_allocate_client_credentials(&iacred); + gnutls_ia_allocate_client_credentials (&iacred); /* Initialize TLS session */ @@ -188,11 +188,11 @@ client (void) } /* - To test TLS/IA alert's (the server will print that a fatal alert - was received): - gnutls_alert_send(session, GNUTLS_AL_FATAL, - GNUTLS_A_INNER_APPLICATION_FAILURE); - */ + To test TLS/IA alert's (the server will print that a fatal alert + was received): + gnutls_alert_send(session, GNUTLS_AL_FATAL, + GNUTLS_A_INNER_APPLICATION_FAILURE); + */ if (!gnutls_ia_handshake_p (session)) fail ("client: No TLS/IA negotiation\n"); @@ -313,9 +313,9 @@ gnutls_session_t session; char buffer[MAX_BUF + 1]; int optval = 1; -int server_avp (gnutls_session_t session, void *ptr, - const char *last, size_t lastlen, - char **new, size_t *newlen) +int +server_avp (gnutls_session_t session, void *ptr, + const char *last, size_t lastlen, char **new, size_t * newlen) { static int iter = 0; char *p; @@ -512,8 +512,8 @@ server (void) { gnutls_alert_description_t alert; const char *err; - alert = gnutls_alert_get(session); - err = gnutls_alert_get_name(alert); + alert = gnutls_alert_get (session); + err = gnutls_alert_get_name (alert); if (err) printf ("Fatal alert: %s\n", err); } |