diff options
author | Daiki Ueno <ueno@gnu.org> | 2023-04-24 12:39:42 +0900 |
---|---|---|
committer | Daiki Ueno <ueno@gnu.org> | 2023-04-24 12:45:46 +0900 |
commit | aa5950abab56b011331ad4331409b6ff8efb8aeb (patch) | |
tree | ad363fb38e8b65c942876641cda9c76caa13b498 /lib/state.c | |
parent | 0fe9cb6842d63761718046cc7dd7eb437e6c5163 (diff) | |
download | gnutls-aa5950abab56b011331ad4331409b6ff8efb8aeb.tar.gz |
build: re-indent code
Signed-off-by: Daiki Ueno <ueno@gnu.org>
Diffstat (limited to 'lib/state.c')
-rw-r--r-- | lib/state.c | 445 |
1 files changed, 203 insertions, 242 deletions
diff --git a/lib/state.c b/lib/state.c index 5d732b0f17..bc6e6bf99b 100644 --- a/lib/state.c +++ b/lib/state.c @@ -62,9 +62,8 @@ unsigned _gnutls_disable_tls13 = 0; /* These should really be static, but src/tests.c calls them. Make them public functions? */ -void -_gnutls_rsa_pms_set_version(gnutls_session_t session, - unsigned char major, unsigned char minor); +void _gnutls_rsa_pms_set_version(gnutls_session_t session, unsigned char major, + unsigned char minor); /** * gnutls_cipher_get: @@ -106,12 +105,13 @@ gnutls_cipher_algorithm_t gnutls_early_cipher_get(gnutls_session_t session) return gnutls_assert_val(GNUTLS_CIPHER_UNKNOWN); } - if (unlikely(session->internals.resumed_security_parameters.cs == NULL)) { + if (unlikely(session->internals.resumed_security_parameters.cs == + NULL)) { return gnutls_assert_val(GNUTLS_CIPHER_UNKNOWN); } - ce = cipher_to_entry(session->internals.resumed_security_parameters. - cs->block_algorithm); + ce = cipher_to_entry(session->internals.resumed_security_parameters.cs + ->block_algorithm); if (unlikely(ce == NULL)) { return gnutls_assert_val(GNUTLS_CIPHER_UNKNOWN); } @@ -197,7 +197,7 @@ gnutls_kx_algorithm_t gnutls_kx_get(gnutls_session_t session) if (session->security_parameters.cs == 0) return 0; - if (session->security_parameters.cs->kx_algorithm == 0) { /* TLS 1.3 */ + if (session->security_parameters.cs->kx_algorithm == 0) { /* TLS 1.3 */ const version_entry_st *ver = get_version(session); const gnutls_group_entry_st *group = get_group(session); @@ -280,7 +280,7 @@ gnutls_digest_algorithm_t gnutls_prf_hash_get(const gnutls_session_t session) if (session->security_parameters.prf->id >= GNUTLS_MAC_AEAD) return gnutls_assert_val(GNUTLS_DIG_UNKNOWN); - return (gnutls_digest_algorithm_t) session->security_parameters.prf->id; + return (gnutls_digest_algorithm_t)session->security_parameters.prf->id; } /** @@ -302,19 +302,18 @@ gnutls_early_prf_hash_get(const gnutls_session_t session) return gnutls_assert_val(GNUTLS_DIG_UNKNOWN); } - if (unlikely - (session->internals.resumed_security_parameters.prf == NULL)) { + if (unlikely(session->internals.resumed_security_parameters.prf == + NULL)) { return gnutls_assert_val(GNUTLS_DIG_UNKNOWN); } - if (unlikely - (session->internals.resumed_security_parameters.prf->id >= - GNUTLS_MAC_AEAD)) { + if (unlikely(session->internals.resumed_security_parameters.prf->id >= + GNUTLS_MAC_AEAD)) { return gnutls_assert_val(GNUTLS_DIG_UNKNOWN); } - return (gnutls_digest_algorithm_t) session->internals. - resumed_security_parameters.prf->id; + return (gnutls_digest_algorithm_t) + session->internals.resumed_security_parameters.prf->id; } /** @@ -365,8 +364,8 @@ static bool _gnutls_has_cert_credentials(gnutls_session_t session, /* First, check for certificate credentials. If we have no certificate * credentials set then we don't support certificates at all. */ - cred = (gnutls_certificate_credentials_t) - _gnutls_get_cred(session, GNUTLS_CRD_CERTIFICATE); + cred = (gnutls_certificate_credentials_t)_gnutls_get_cred( + session, GNUTLS_CRD_CERTIFICATE); if (cred == NULL) return false; @@ -389,7 +388,7 @@ static bool _gnutls_has_cert_credentials(gnutls_session_t session, } } - return true; // OK + return true; // OK } /* Check if the given certificate type is supported. @@ -397,11 +396,10 @@ static bool _gnutls_has_cert_credentials(gnutls_session_t session, * and in some cases a matching certificate exists. A check for * the latter can be toggled via the parameter @check_credentials. */ -bool -_gnutls_session_is_cert_type_supported(gnutls_session_t session, - gnutls_certificate_type_t cert_type, - bool check_credentials, - gnutls_ctype_target_t target) +bool _gnutls_session_is_cert_type_supported(gnutls_session_t session, + gnutls_certificate_type_t cert_type, + bool check_credentials, + gnutls_ctype_target_t target) { unsigned i; priority_st *ctype_priorities; @@ -413,9 +411,8 @@ _gnutls_session_is_cert_type_supported(gnutls_session_t session, // Perform a credentials check if requested if (check_credentials) { if (!_gnutls_has_cert_credentials(session, cert_type)) - return - gnutls_assert_val - (GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE); + return gnutls_assert_val( + GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE); } /* So far so good. We have the required credentials (if needed). @@ -426,19 +423,19 @@ _gnutls_session_is_cert_type_supported(gnutls_session_t session, switch (target) { case GNUTLS_CTYPE_CLIENT: ctype_priorities = - &(session->internals.priorities->client_ctype); + &(session->internals.priorities->client_ctype); break; case GNUTLS_CTYPE_SERVER: ctype_priorities = - &(session->internals.priorities->server_ctype); + &(session->internals.priorities->server_ctype); break; default: return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST); } // No explicit priorities set, and default ctype is asked - if (ctype_priorities->num_priorities == 0 - && cert_type == DEFAULT_CERT_TYPE) + if (ctype_priorities->num_priorities == 0 && + cert_type == DEFAULT_CERT_TYPE) return 0; /* Now lets find out whether our cert type is in our priority @@ -570,7 +567,7 @@ void _gnutls_handshake_internal_state_clear(gnutls_session_t session) * * Returns: %GNUTLS_E_SUCCESS on success, or an error code. **/ -int gnutls_init(gnutls_session_t * session, unsigned int flags) +int gnutls_init(gnutls_session_t *session, unsigned int flags) { int ret; @@ -591,16 +588,16 @@ int gnutls_init(gnutls_session_t * session, unsigned int flags) ret = gnutls_mutex_init(&(*session)->internals.epoch_lock); if (ret < 0) { gnutls_assert(); - gnutls_mutex_deinit(&(*session)-> - internals.post_negotiation_lock); + gnutls_mutex_deinit( + &(*session)->internals.post_negotiation_lock); gnutls_free(*session); return ret; } ret = _gnutls_epoch_setup_next(*session, 1, NULL); if (ret < 0) { - gnutls_mutex_deinit(&(*session)-> - internals.post_negotiation_lock); + gnutls_mutex_deinit( + &(*session)->internals.post_negotiation_lock); gnutls_mutex_deinit(&(*session)->internals.epoch_lock); gnutls_free(*session); return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR); @@ -608,7 +605,7 @@ int gnutls_init(gnutls_session_t * session, unsigned int flags) _gnutls_epoch_bump(*session); (*session)->security_parameters.entity = - (flags & GNUTLS_SERVER ? GNUTLS_SERVER : GNUTLS_CLIENT); + (flags & GNUTLS_SERVER ? GNUTLS_SERVER : GNUTLS_CLIENT); /* the default certificate type for TLS */ (*session)->security_parameters.client_ctype = DEFAULT_CERT_TYPE; @@ -642,28 +639,28 @@ int gnutls_init(gnutls_session_t * session, unsigned int flags) /* set the socket pointers to -1; */ - (*session)->internals.transport_recv_ptr = (gnutls_transport_ptr_t) - 1; - (*session)->internals.transport_send_ptr = (gnutls_transport_ptr_t) - 1; + (*session)->internals.transport_recv_ptr = (gnutls_transport_ptr_t)-1; + (*session)->internals.transport_send_ptr = (gnutls_transport_ptr_t)-1; /* set the default maximum record size for TLS */ (*session)->security_parameters.max_record_recv_size = - DEFAULT_MAX_RECORD_SIZE; + DEFAULT_MAX_RECORD_SIZE; (*session)->security_parameters.max_record_send_size = - DEFAULT_MAX_RECORD_SIZE; + DEFAULT_MAX_RECORD_SIZE; (*session)->security_parameters.max_user_record_recv_size = - DEFAULT_MAX_RECORD_SIZE; + DEFAULT_MAX_RECORD_SIZE; (*session)->security_parameters.max_user_record_send_size = - DEFAULT_MAX_RECORD_SIZE; + DEFAULT_MAX_RECORD_SIZE; /* set the default early data size for TLS */ if ((*session)->security_parameters.entity == GNUTLS_SERVER) { (*session)->security_parameters.max_early_data_size = - DEFAULT_MAX_EARLY_DATA_SIZE; + DEFAULT_MAX_EARLY_DATA_SIZE; } else { (*session)->security_parameters.max_early_data_size = - UINT32_MAX; + UINT32_MAX; } /* Everything else not initialized here is initialized as NULL @@ -672,15 +669,15 @@ int gnutls_init(gnutls_session_t * session, unsigned int flags) * runtime before being used. Mark such regions with a * valgrind client request as undefined. */ - _gnutls_memory_mark_undefined((*session)-> - security_parameters.master_secret, - GNUTLS_MASTER_SIZE); - _gnutls_memory_mark_undefined((*session)-> - security_parameters.client_random, - GNUTLS_RANDOM_SIZE); - _gnutls_memory_mark_undefined((*session)-> - security_parameters.server_random, - GNUTLS_RANDOM_SIZE); + _gnutls_memory_mark_undefined( + (*session)->security_parameters.master_secret, + GNUTLS_MASTER_SIZE); + _gnutls_memory_mark_undefined( + (*session)->security_parameters.client_random, + GNUTLS_RANDOM_SIZE); + _gnutls_memory_mark_undefined( + (*session)->security_parameters.server_random, + GNUTLS_RANDOM_SIZE); _gnutls_memory_mark_undefined((*session)->key.session_ticket_key, TICKET_MASTER_KEY_SIZE); _gnutls_memory_mark_undefined((*session)->key.previous_ticket_key, @@ -718,7 +715,8 @@ int gnutls_init(gnutls_session_t * session, unsigned int flags) } /* Enable useful extensions */ - if ((flags & GNUTLS_CLIENT) && !(flags & GNUTLS_NO_DEFAULT_EXTENSIONS)) { + if ((flags & GNUTLS_CLIENT) && + !(flags & GNUTLS_NO_DEFAULT_EXTENSIONS)) { #ifdef ENABLE_OCSP if (!(flags & GNUTLS_NO_STATUS_REQUEST)) gnutls_ocsp_status_request_enable_client(*session, NULL, @@ -841,42 +839,34 @@ int _gnutls_dh_set_peer_public(gnutls_session_t session, bigint_t public) int ret; switch (gnutls_auth_get_type(session)) { - case GNUTLS_CRD_ANON: - { - anon_auth_info_t info; - info = _gnutls_get_auth_info(session, GNUTLS_CRD_ANON); - if (info == NULL) - return - gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); - - dh = &info->dh; - break; - } - case GNUTLS_CRD_PSK: - { - psk_auth_info_t info; - info = _gnutls_get_auth_info(session, GNUTLS_CRD_PSK); - if (info == NULL) - return - gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); - - dh = &info->dh; - break; - } - case GNUTLS_CRD_CERTIFICATE: - { - cert_auth_info_t info; - - info = - _gnutls_get_auth_info(session, - GNUTLS_CRD_CERTIFICATE); - if (info == NULL) - return - gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); - - dh = &info->dh; - break; - } + case GNUTLS_CRD_ANON: { + anon_auth_info_t info; + info = _gnutls_get_auth_info(session, GNUTLS_CRD_ANON); + if (info == NULL) + return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); + + dh = &info->dh; + break; + } + case GNUTLS_CRD_PSK: { + psk_auth_info_t info; + info = _gnutls_get_auth_info(session, GNUTLS_CRD_PSK); + if (info == NULL) + return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); + + dh = &info->dh; + break; + } + case GNUTLS_CRD_CERTIFICATE: { + cert_auth_info_t info; + + info = _gnutls_get_auth_info(session, GNUTLS_CRD_CERTIFICATE); + if (info == NULL) + return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); + + dh = &info->dh; + break; + } default: return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); } @@ -896,42 +886,34 @@ int _gnutls_dh_set_peer_public(gnutls_session_t session, bigint_t public) int _gnutls_dh_set_secret_bits(gnutls_session_t session, unsigned bits) { switch (gnutls_auth_get_type(session)) { - case GNUTLS_CRD_ANON: - { - anon_auth_info_t info; - info = _gnutls_get_auth_info(session, GNUTLS_CRD_ANON); - if (info == NULL) - return - gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); - info->dh.secret_bits = bits; - break; - } - case GNUTLS_CRD_PSK: - { - psk_auth_info_t info; - info = _gnutls_get_auth_info(session, GNUTLS_CRD_PSK); - if (info == NULL) - return - gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); - info->dh.secret_bits = bits; - break; - } - case GNUTLS_CRD_CERTIFICATE: - { - cert_auth_info_t info; - - info = - _gnutls_get_auth_info(session, - GNUTLS_CRD_CERTIFICATE); - if (info == NULL) - return - gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); - - info->dh.secret_bits = bits; - break; - default: + case GNUTLS_CRD_ANON: { + anon_auth_info_t info; + info = _gnutls_get_auth_info(session, GNUTLS_CRD_ANON); + if (info == NULL) return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); - } + info->dh.secret_bits = bits; + break; + } + case GNUTLS_CRD_PSK: { + psk_auth_info_t info; + info = _gnutls_get_auth_info(session, GNUTLS_CRD_PSK); + if (info == NULL) + return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); + info->dh.secret_bits = bits; + break; + } + case GNUTLS_CRD_CERTIFICATE: { + cert_auth_info_t info; + + info = _gnutls_get_auth_info(session, GNUTLS_CRD_CERTIFICATE); + if (info == NULL) + return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); + + info->dh.secret_bits = bits; + break; + default: + return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); + } } return 0; @@ -939,49 +921,41 @@ int _gnutls_dh_set_secret_bits(gnutls_session_t session, unsigned bits) /* Sets the prime and the generator in the auth info structure. */ -int -_gnutls_dh_save_group(gnutls_session_t session, bigint_t gen, bigint_t prime) +int _gnutls_dh_save_group(gnutls_session_t session, bigint_t gen, + bigint_t prime) { dh_info_st *dh; int ret; switch (gnutls_auth_get_type(session)) { - case GNUTLS_CRD_ANON: - { - anon_auth_info_t info; - info = _gnutls_get_auth_info(session, GNUTLS_CRD_ANON); - if (info == NULL) - return - gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); - - dh = &info->dh; - break; - } - case GNUTLS_CRD_PSK: - { - psk_auth_info_t info; - info = _gnutls_get_auth_info(session, GNUTLS_CRD_PSK); - if (info == NULL) - return - gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); - - dh = &info->dh; - break; - } - case GNUTLS_CRD_CERTIFICATE: - { - cert_auth_info_t info; - - info = - _gnutls_get_auth_info(session, - GNUTLS_CRD_CERTIFICATE); - if (info == NULL) - return - gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); - - dh = &info->dh; - break; - } + case GNUTLS_CRD_ANON: { + anon_auth_info_t info; + info = _gnutls_get_auth_info(session, GNUTLS_CRD_ANON); + if (info == NULL) + return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); + + dh = &info->dh; + break; + } + case GNUTLS_CRD_PSK: { + psk_auth_info_t info; + info = _gnutls_get_auth_info(session, GNUTLS_CRD_PSK); + if (info == NULL) + return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); + + dh = &info->dh; + break; + } + case GNUTLS_CRD_CERTIFICATE: { + cert_auth_info_t info; + + info = _gnutls_get_auth_info(session, GNUTLS_CRD_CERTIFICATE); + if (info == NULL) + return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); + + dh = &info->dh; + break; + } default: return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); } @@ -1026,8 +1000,8 @@ _gnutls_dh_save_group(gnutls_session_t session, bigint_t gen, bigint_t prime) * This function has no effect in clients, and in authentication * methods other than certificate with X.509 certificates. **/ -void -gnutls_certificate_send_x509_rdn_sequence(gnutls_session_t session, int status) +void gnutls_certificate_send_x509_rdn_sequence(gnutls_session_t session, + int status) { session->internals.ignore_rdn_sequence = status; } @@ -1042,9 +1016,9 @@ gnutls_certificate_send_x509_rdn_sequence(gnutls_session_t session, int status) * record packet (client hello). This function is only useful to people * that know TLS internals and want to debug other implementations. -*/ -void -_gnutls_record_set_default_version(gnutls_session_t session, - unsigned char major, unsigned char minor) +void _gnutls_record_set_default_version(gnutls_session_t session, + unsigned char major, + unsigned char minor) { session->internals.default_record_version[0] = major; session->internals.default_record_version[1] = minor; @@ -1060,9 +1034,8 @@ _gnutls_record_set_default_version(gnutls_session_t session, * record packet (client hello). This function is only useful to people * that know TLS internals and want to debug other implementations. -*/ -void -_gnutls_hello_set_default_version(gnutls_session_t session, - unsigned char major, unsigned char minor) +void _gnutls_hello_set_default_version(gnutls_session_t session, + unsigned char major, unsigned char minor) { session->internals.default_hello_version[0] = major; session->internals.default_hello_version[1] = minor; @@ -1083,8 +1056,8 @@ _gnutls_hello_set_default_version(gnutls_session_t session, * Enabling the private ciphersuites when talking to other than * gnutls servers and clients may cause interoperability problems. **/ -void -gnutls_handshake_set_private_extensions(gnutls_session_t session, int allow) +void gnutls_handshake_set_private_extensions(gnutls_session_t session, + int allow) { /* we have no private extensions */ return; @@ -1110,13 +1083,12 @@ int gnutls_session_is_resumed(gnutls_session_t session) if (session->security_parameters.session_id_size > 0 && session->security_parameters.session_id_size == - session->internals.resumed_security_parameters. - session_id_size - && memcmp(session->security_parameters.session_id, - session->internals.resumed_security_parameters. - session_id, - session->security_parameters.session_id_size) == - 0) + session->internals.resumed_security_parameters + .session_id_size && + memcmp(session->security_parameters.session_id, + session->internals.resumed_security_parameters + .session_id, + session->security_parameters.session_id_size) == 0) return 1; } else { if (session->internals.resumed) @@ -1156,8 +1128,8 @@ int _gnutls_session_is_psk(gnutls_session_t session) gnutls_kx_algorithm_t kx; kx = session->security_parameters.cs->kx_algorithm; - if (kx == GNUTLS_KX_PSK || kx == GNUTLS_KX_DHE_PSK - || kx == GNUTLS_KX_RSA_PSK) + if (kx == GNUTLS_KX_PSK || kx == GNUTLS_KX_DHE_PSK || + kx == GNUTLS_KX_RSA_PSK) return 1; return 0; @@ -1235,8 +1207,9 @@ void gnutls_session_set_ptr(gnutls_session_t session, void *ptr) * * Since: 3.4.6 **/ -void gnutls_session_set_verify_function - (gnutls_session_t session, gnutls_certificate_verify_function * func) { +void gnutls_session_set_verify_function( + gnutls_session_t session, gnutls_certificate_verify_function *func) +{ session->internals.verify_callback = func; } @@ -1274,9 +1247,8 @@ int gnutls_record_get_direction(gnutls_session_t session) * RSA PMS secret. This is only useful to clients, which want to * test server's capabilities. -*/ -void -_gnutls_rsa_pms_set_version(gnutls_session_t session, - unsigned char major, unsigned char minor) +void _gnutls_rsa_pms_set_version(gnutls_session_t session, unsigned char major, + unsigned char minor) { session->internals.rsa_pms_version[0] = major; session->internals.rsa_pms_version[1] = minor; @@ -1285,18 +1257,18 @@ _gnutls_rsa_pms_set_version(gnutls_session_t session, void _gnutls_session_client_cert_type_set(gnutls_session_t session, gnutls_certificate_type_t ct) { - _gnutls_handshake_log - ("HSK[%p]: Selected client certificate type %s (%d)\n", session, - gnutls_certificate_type_get_name(ct), ct); + _gnutls_handshake_log( + "HSK[%p]: Selected client certificate type %s (%d)\n", session, + gnutls_certificate_type_get_name(ct), ct); session->security_parameters.client_ctype = ct; } void _gnutls_session_server_cert_type_set(gnutls_session_t session, gnutls_certificate_type_t ct) { - _gnutls_handshake_log - ("HSK[%p]: Selected server certificate type %s (%d)\n", session, - gnutls_certificate_type_get_name(ct), ct); + _gnutls_handshake_log( + "HSK[%p]: Selected server certificate type %s (%d)\n", session, + gnutls_certificate_type_get_name(ct), ct); session->security_parameters.server_ctype = ct; } @@ -1326,10 +1298,8 @@ void _gnutls_session_server_cert_type_set(gnutls_session_t session, * doing. Before the handshake is finished there is no way to know if * there is a man-in-the-middle attack being performed. **/ -void -gnutls_handshake_set_post_client_hello_function(gnutls_session_t session, - gnutls_handshake_simple_hook_func - func) +void gnutls_handshake_set_post_client_hello_function( + gnutls_session_t session, gnutls_handshake_simple_hook_func func) { session->internals.user_hello_func = func; } @@ -1372,10 +1342,9 @@ void gnutls_session_enable_compatibility_mode(gnutls_session_t session) * * Since: 2.12.0 **/ -int -gnutls_session_channel_binding(gnutls_session_t session, - gnutls_channel_binding_t cbtype, - gnutls_datum_t * cb) +int gnutls_session_channel_binding(gnutls_session_t session, + gnutls_channel_binding_t cbtype, + gnutls_datum_t *cb) { if (!session->internals.initial_negotiation_completed) return GNUTLS_E_CHANNEL_BINDING_NOT_AVAILABLE; @@ -1409,8 +1378,8 @@ gnutls_session_channel_binding(gnutls_session_t session, return GNUTLS_E_UNIMPLEMENTED_FEATURE; if (session->security_parameters.entity == GNUTLS_CLIENT) - ders = - gnutls_certificate_get_peers(session, &num_certs); + ders = gnutls_certificate_get_peers(session, + &num_certs); else ders = gnutls_certificate_get_ours(session); @@ -1496,10 +1465,10 @@ gnutls_session_channel_binding(gnutls_session_t session, if (cb->data == NULL) return GNUTLS_E_MEMORY_ERROR; - return gnutls_prf_rfc5705(session, - RFC5705_LABEL_LEN, RFC5705_LABEL_DATA, - EXPORTER_CTX_LEN, EXPORTER_CTX_DATA, - cb->size, (char *)cb->data); + return gnutls_prf_rfc5705(session, RFC5705_LABEL_LEN, + RFC5705_LABEL_DATA, EXPORTER_CTX_LEN, + EXPORTER_CTX_DATA, cb->size, + (char *)cb->data); } return GNUTLS_E_UNIMPLEMENTED_FEATURE; @@ -1577,20 +1546,19 @@ gnutls_protocol_t gnutls_protocol_get_version(gnutls_session_t session) * * Since: 3.0 **/ -void -gnutls_session_get_random(gnutls_session_t session, - gnutls_datum_t * client, gnutls_datum_t * server) +void gnutls_session_get_random(gnutls_session_t session, gnutls_datum_t *client, + gnutls_datum_t *server) { if (client) { client->data = session->security_parameters.client_random; client->size = - sizeof(session->security_parameters.client_random); + sizeof(session->security_parameters.client_random); } if (server) { server->data = session->security_parameters.server_random; server->size = - sizeof(session->security_parameters.server_random); + sizeof(session->security_parameters.server_random); } } @@ -1606,9 +1574,8 @@ gnutls_session_get_random(gnutls_session_t session, * * Since: 3.5.0 **/ -void -gnutls_session_get_master_secret(gnutls_session_t session, - gnutls_datum_t * secret) +void gnutls_session_get_master_secret(gnutls_session_t session, + gnutls_datum_t *secret) { secret->data = session->security_parameters.master_secret; secret->size = sizeof(session->security_parameters.master_secret); @@ -1645,20 +1612,21 @@ unsigned int timespec_sub_ms(struct timespec *a, struct timespec *b) * * Since 3.1.9 **/ -int -gnutls_handshake_set_random(gnutls_session_t session, - const gnutls_datum_t * random) +int gnutls_handshake_set_random(gnutls_session_t session, + const gnutls_datum_t *random) { if (random->size != GNUTLS_RANDOM_SIZE) return GNUTLS_E_INVALID_REQUEST; session->internals.sc_random_set = 1; if (session->security_parameters.entity == GNUTLS_CLIENT) - memcpy(session->internals.resumed_security_parameters. - client_random, random->data, random->size); + memcpy(session->internals.resumed_security_parameters + .client_random, + random->data, random->size); else - memcpy(session->internals.resumed_security_parameters. - server_random, random->data, random->size); + memcpy(session->internals.resumed_security_parameters + .server_random, + random->data, random->size); return 0; } @@ -1688,10 +1656,9 @@ gnutls_handshake_set_random(gnutls_session_t session, * doing. Before the handshake is finished there is no way to know if * there is a man-in-the-middle attack being performed. **/ -void -gnutls_handshake_set_hook_function(gnutls_session_t session, - unsigned int htype, - int when, gnutls_handshake_hook_func func) +void gnutls_handshake_set_hook_function(gnutls_session_t session, + unsigned int htype, int when, + gnutls_handshake_hook_func func) { session->internals.h_hook = func; session->internals.h_type = htype; @@ -1708,9 +1675,8 @@ gnutls_handshake_set_hook_function(gnutls_session_t session, * * Since: 3.7.0 */ -void -gnutls_handshake_set_read_function(gnutls_session_t session, - gnutls_handshake_read_func func) +void gnutls_handshake_set_read_function(gnutls_session_t session, + gnutls_handshake_read_func func) { session->internals.h_read_func = func; } @@ -1725,9 +1691,8 @@ gnutls_handshake_set_read_function(gnutls_session_t session, * * Since: 3.7.0 */ -void -gnutls_alert_set_read_function(gnutls_session_t session, - gnutls_alert_read_func func) +void gnutls_alert_set_read_function(gnutls_session_t session, + gnutls_alert_read_func func) { session->internals.alert_read_func = func; } @@ -1752,13 +1717,10 @@ gnutls_alert_set_read_function(gnutls_session_t session, * * Since 3.4.0 **/ -int -gnutls_record_get_state(gnutls_session_t session, - unsigned read, - gnutls_datum_t * mac_key, - gnutls_datum_t * IV, - gnutls_datum_t * cipher_key, - unsigned char seq_number[8]) +int gnutls_record_get_state(gnutls_session_t session, unsigned read, + gnutls_datum_t *mac_key, gnutls_datum_t *IV, + gnutls_datum_t *cipher_key, + unsigned char seq_number[8]) { record_parameters_st *record_params; record_state_st *record_state; @@ -1816,9 +1778,8 @@ gnutls_record_get_state(gnutls_session_t session, * * Since 3.4.0 **/ -int -gnutls_record_set_state(gnutls_session_t session, - unsigned read, const unsigned char seq_number[8]) +int gnutls_record_set_state(gnutls_session_t session, unsigned read, + const unsigned char seq_number[8]) { record_parameters_st *record_params; record_state_st *record_state; |