gnutls

## gnutls gnutls |

## Functions

const char * | gnutls_handshake_description_get_name ()
const char * | gnutls_pk_algorithm_get_name ()
#define | GNUTLS_CURVE_TO_BITS()
#define | GNUTLS_BITS_TO_CURVE()
#define | GNUTLS_BITS_ARE_CURVE()
int | gnutls_init ()
void | gnutls_deinit ()
int | gnutls_bye ()
int | gnutls_handshake ()
int | gnutls_reauth ()
void | gnutls_handshake_set_timeout ()
int | gnutls_rehandshake ()
int | gnutls_session_key_update ()
int | gnutls_handshake_update_receiving_key ()
return | gnutls_alert_get ()
int | gnutls_alert_send ()
int | gnutls_alert_send_appropriate ()
const char * | gnutls_alert_get_name ()
const char * | gnutls_alert_get_strname ()
gnutls_sec_param_t | gnutls_pk_bits_to_sec_param ()
const char * | gnutls_sec_param_get_name ()
unsigned int | gnutls_sec_param_to_pk_bits ()
unsigned int | gnutls_sec_param_to_symmetric_bits ()
gnutls_group_t | gnutls_group_get ()
return | gnutls_cipher_get ()
gnutls_cipher_algorithm_t | gnutls_early_cipher_get ()
return | gnutls_kx_get ()
return | gnutls_mac_get ()
gnutls_digest_algorithm_t | gnutls_prf_hash_get ()
gnutls_digest_algorithm_t | gnutls_early_prf_hash_get ()
return | gnutls_certificate_type_get ()
gnutls_certificate_type_t | gnutls_certificate_type_get2 ()
int | gnutls_sign_algorithm_get ()
int | gnutls_sign_algorithm_get_client ()
int | gnutls_sign_algorithm_get_requested ()
const char * | gnutls_cipher_get_name ()
gnutls_digest_algorithm_t | gnutls_oid_to_digest ()
int | gnutls_ecc_curve_set_enabled ()
int | gnutls_sign_set_secure ()
int | gnutls_sign_set_secure_for_certs ()
int | gnutls_digest_set_secure ()
int | gnutls_protocol_set_enabled ()
int | gnutls_error_is_fatal ()
void | gnutls_perror ()
return | gnutls_strerror ()
int | gnutls_handshake_set_random ()
return | gnutls_handshake_get_last_out ()
return | gnutls_handshake_get_last_in ()
int | gnutls_heartbeat_ping ()
int | gnutls_heartbeat_pong ()
void | gnutls_record_set_timeout ()
void | gnutls_record_disable_padding ()
void | gnutls_record_cork ()
int | gnutls_record_uncork ()
size_t | gnutls_record_discard_queued ()
int | gnutls_record_get_state ()
int | gnutls_record_set_state ()
int | gnutls_range_split ()
ssize_t | gnutls_record_send ()
ssize_t | gnutls_record_send2 ()
ssize_t | gnutls_record_send_range ()
ssize_t | gnutls_record_send_file ()
ssize_t | gnutls_record_recv ()
ssize_t | gnutls_record_recv_packet ()
void | gnutls_packet_get ()
void | gnutls_packet_deinit ()
ssize_t | gnutls_record_recv_seq ()
size_t | gnutls_record_overhead_size ()
size_t | gnutls_est_record_overhead_size ()
#define | gnutls_record_set_max_empty_records()
unsigned | gnutls_record_can_use_length_hiding ()
return | gnutls_record_get_direction ()
return | gnutls_record_get_max_size ()
ssize_t | gnutls_record_set_max_size ()
ssize_t | gnutls_record_set_max_recv_size ()
return | gnutls_record_check_pending ()
size_t | gnutls_record_check_corked ()
size_t | gnutls_record_get_max_early_data_size ()
int | gnutls_record_set_max_early_data_size ()
ssize_t | gnutls_record_send_early_data ()
ssize_t | gnutls_record_recv_early_data ()
size_t | gnutls_record_get_max_send_size ()
void | gnutls_session_force_valid ()
int | gnutls_prf ()
int | gnutls_prf_rfc5705 ()
int | gnutls_prf_early ()
int | gnutls_prf_raw ()
int | gnutls_server_name_set ()
int | gnutls_server_name_get ()
unsigned int | gnutls_heartbeat_get_timeout ()
void | gnutls_heartbeat_set_timeouts ()
void | gnutls_heartbeat_enable ()
unsigned | gnutls_heartbeat_allowed ()
unsigned | gnutls_safe_renegotiation_status ()
unsigned | gnutls_session_ext_master_secret_status ()
unsigned | gnutls_session_etm_status ()
unsigned | gnutls_session_get_flags ()
const char * | gnutls_supplemental_get_name ()
int | gnutls_session_ticket_key_generate ()
int | gnutls_session_ticket_enable_client ()
int | gnutls_session_ticket_enable_server ()
int | gnutls_session_ticket_send ()
int | gnutls_srtp_set_profile ()
int | gnutls_srtp_set_profile_direct ()
int | gnutls_srtp_get_selected_profile ()
const char * | gnutls_srtp_get_profile_name ()
int | gnutls_srtp_get_profile_id ()
int | gnutls_srtp_get_keys ()
int | gnutls_srtp_set_mki ()
int | gnutls_srtp_get_mki ()
gnutls_compression_method_t | gnutls_compress_certificate_get_selected_method ()
int | gnutls_compress_certificate_set_methods ()
int | gnutls_alpn_get_selected_protocol ()
int | gnutls_alpn_set_protocols ()
int | gnutls_key_generate ()
int | gnutls_priority_init ()
int | gnutls_priority_init2 ()
void | gnutls_priority_deinit ()
int | gnutls_priority_get_cipher_suite_index ()
const char * | gnutls_priority_string_list ()
int | gnutls_priority_set ()
int | gnutls_priority_set_direct ()
int | gnutls_priority_certificate_type_list ()
int | gnutls_priority_certificate_type_list2 ()
int | gnutls_priority_sign_list ()
int | gnutls_priority_protocol_list ()
int | gnutls_priority_ecc_curve_list ()
int | gnutls_priority_group_list ()
int | gnutls_priority_kx_list ()
int | gnutls_priority_cipher_list ()
int | gnutls_priority_mac_list ()
const char * | gnutls_get_system_config_file ()
int | gnutls_set_default_priority ()
int | gnutls_set_default_priority_append ()
const char * | gnutls_cipher_suite_get_name ()
const char * | gnutls_protocol_get_name ()
int | gnutls_session_get_data ()
int | gnutls_session_get_data2 ()
void | gnutls_session_get_random ()
void | gnutls_session_get_master_secret ()
char * | gnutls_session_get_desc ()
void | gnutls_session_set_verify_function ()
void | gnutls_session_set_verify_cert ()
void | gnutls_session_set_verify_cert2 ()
unsigned int | gnutls_session_get_verify_cert_status ()
int | gnutls_session_set_premaster ()
int | gnutls_session_get_id ()
int | gnutls_session_get_id2 ()
int | gnutls_session_set_id ()
int | gnutls_session_channel_binding ()
int | gnutls_session_is_resumed ()
int | gnutls_session_resumption_requested ()
int | (*gnutls_db_store_func) ()
int | (*gnutls_db_remove_func) ()
gnutls_datum_t | (*gnutls_db_retr_func) ()
void | gnutls_db_set_cache_expiration ()
unsigned | gnutls_db_get_default_cache_expiration ()
void | gnutls_db_remove_session ()
void | gnutls_db_set_retrieve_function ()
void | gnutls_db_set_remove_function ()
void | gnutls_db_set_store_function ()
void | gnutls_db_set_ptr ()
void * | gnutls_db_get_ptr ()
int | gnutls_db_check_entry ()
time_t | gnutls_db_check_entry_time ()
time_t | gnutls_db_check_entry_expire_time ()
int | (*gnutls_handshake_hook_func) ()
void | gnutls_handshake_set_hook_function ()
int | (*gnutls_handshake_simple_hook_func) ()
void | gnutls_handshake_set_post_client_hello_function ()
void | gnutls_handshake_set_max_packet_length ()
const char * | gnutls_check_version ()
int | gnutls_credentials_set ()
int | gnutls_credentials_get ()
void | gnutls_anon_free_server_credentials ()
int | gnutls_anon_allocate_server_credentials ()
void | gnutls_anon_set_server_dh_params ()
int | gnutls_anon_set_server_known_dh_params ()
void | gnutls_anon_set_server_params_function ()
void | gnutls_anon_free_client_credentials ()
int | gnutls_anon_allocate_client_credentials ()
void | gnutls_certificate_free_credentials ()
int | gnutls_certificate_allocate_credentials ()
int | gnutls_certificate_get_issuer ()
int | gnutls_certificate_get_crt_raw ()
void | gnutls_certificate_free_keys ()
void | gnutls_certificate_free_cas ()
void | gnutls_certificate_free_ca_names ()
void | gnutls_certificate_free_crls ()
void | gnutls_certificate_set_dh_params ()
int | gnutls_certificate_set_known_dh_params ()
void | gnutls_certificate_set_verify_flags ()
unsigned int | gnutls_certificate_get_verify_flags ()
void | gnutls_certificate_set_flags ()
void | gnutls_certificate_set_verify_limits ()
int | gnutls_certificate_set_x509_system_trust ()
int | gnutls_certificate_set_x509_trust_file ()
int | gnutls_certificate_set_x509_trust_dir ()
int | gnutls_certificate_set_x509_trust_mem ()
int | gnutls_certificate_set_x509_crl_file ()
int | gnutls_certificate_set_x509_crl_mem ()
int | gnutls_certificate_set_x509_key_file ()
int | gnutls_certificate_set_x509_key_file2 ()
int | gnutls_certificate_set_x509_key_mem ()
int | gnutls_certificate_set_x509_key_mem2 ()
void | gnutls_certificate_send_x509_rdn_sequence ()
int | gnutls_certificate_set_x509_simple_pkcs12_file ()
int | gnutls_certificate_set_x509_simple_pkcs12_mem ()
int | gnutls_certificate_set_x509_key ()
int | gnutls_certificate_set_x509_trust ()
int | gnutls_certificate_set_x509_crl ()
int | gnutls_certificate_get_x509_key ()
int | gnutls_certificate_get_x509_crt ()
int | (*gnutls_status_request_ocsp_func) ()
void | gnutls_certificate_set_ocsp_status_request_function ()
int | gnutls_certificate_set_ocsp_status_request_function2 ()
int | gnutls_certificate_set_ocsp_status_request_file ()
int | gnutls_certificate_set_ocsp_status_request_file2 ()
int | gnutls_certificate_set_ocsp_status_request_mem ()
time_t | gnutls_certificate_get_ocsp_expiration ()
int | gnutls_ocsp_status_request_enable_client ()
int | gnutls_ocsp_status_request_get ()
unsigned | gnutls_ocsp_status_request_is_checked ()
int | gnutls_ocsp_status_request_get2 ()
int | gnutls_certificate_set_rawpk_key_mem ()
int | gnutls_certificate_set_rawpk_key_file ()
int | gnutls_global_init ()
void | gnutls_global_deinit ()
const gnutls_library_config_st * | gnutls_get_library_config ()
time_t | (*gnutls_time_func) ()
int | (*mutex_init_func) ()
int | (*mutex_lock_func) ()
int | (*mutex_unlock_func) ()
int | (*mutex_deinit_func) ()
void | gnutls_global_set_mutex ()
void * | (*gnutls_alloc_function) ()
void * | (*gnutls_calloc_function) ()
int | (*gnutls_is_secure_function) ()
void | (*gnutls_free_function) ()
void * | (*gnutls_realloc_function) ()
void | gnutls_global_set_time_function ()
#define | gnutls_free()
void | gnutls_memset ()
if | gnutls_memcmp ()
void | (*gnutls_log_func) ()
void | (*gnutls_audit_log_func) ()
void | gnutls_global_set_log_function ()
void | gnutls_global_set_audit_log_function ()
void | gnutls_global_set_log_level ()
int | (*gnutls_keylog_func) ()
gnutls_keylog_func | gnutls_session_get_keylog_function ()
void | gnutls_session_set_keylog_function ()
int | gnutls_dh_params_init ()
void | gnutls_dh_params_deinit ()
int | gnutls_dh_params_import_raw ()
int | gnutls_dh_params_import_dsa ()
int | gnutls_dh_params_import_raw2 ()
int | gnutls_dh_params_import_raw3 ()
int | gnutls_dh_params_import_pkcs3 ()
int | gnutls_dh_params_generate2 ()
int | gnutls_dh_params_export_pkcs3 ()
int | gnutls_dh_params_export2_pkcs3 ()
int | gnutls_dh_params_export_raw ()
int | gnutls_dh_params_cpy ()
ssize_t | (*gnutls_pull_func) ()
ssize_t | (*gnutls_push_func) ()
int | gnutls_system_recv_timeout ()
int | (*gnutls_pull_timeout_func) ()
ssize_t | (*gnutls_vec_push_func) ()
int | (*gnutls_errno_func) ()
void | gnutls_transport_set_int ()
void | gnutls_transport_set_int2 ()
void | gnutls_transport_get_int2 ()
int | gnutls_transport_get_int ()
void | gnutls_transport_set_ptr ()
void | gnutls_transport_set_ptr2 ()
return | gnutls_transport_get_ptr ()
void | gnutls_transport_get_ptr2 ()
void | gnutls_transport_set_vec_push_function ()
void | gnutls_transport_set_push_function ()
void | gnutls_transport_set_pull_function ()
void | gnutls_transport_set_pull_timeout_function ()
void | gnutls_transport_set_errno_function ()
void | gnutls_transport_set_errno ()
void | gnutls_session_set_ptr ()
return | gnutls_session_get_ptr ()
void | gnutls_openpgp_send_cert ()
int | gnutls_fingerprint ()
int | gnutls_random_art ()
int | gnutls_idna_map ()
int | gnutls_idna_reverse_map ()
void | gnutls_srp_free_client_credentials ()
int | gnutls_srp_allocate_client_credentials ()
int | gnutls_srp_set_client_credentials ()
void | gnutls_srp_free_server_credentials ()
int | gnutls_srp_allocate_server_credentials ()
int | gnutls_srp_set_server_credentials_file ()
return | gnutls_srp_server_get_username ()
void | gnutls_srp_set_prime_bits ()
int | gnutls_srp_verifier ()
void | gnutls_srp_set_server_credentials_function ()
void | gnutls_srp_set_client_credentials_function ()
int | gnutls_srp_base64_encode ()
int | gnutls_srp_base64_encode2 ()
int | gnutls_srp_base64_decode ()
int | gnutls_srp_base64_decode2 ()
void | gnutls_srp_set_server_fake_salt_seed ()
void | gnutls_psk_free_client_credentials ()
int | gnutls_psk_allocate_client_credentials ()
int | gnutls_psk_allocate_client_credentials2 ()
int | gnutls_psk_set_client_credentials ()
int | gnutls_psk_set_client_credentials2 ()
void | gnutls_psk_free_server_credentials ()
int | gnutls_psk_allocate_server_credentials ()
int | gnutls_psk_allocate_server_credentials2 ()
int | gnutls_psk_set_server_credentials_file ()
int | gnutls_psk_set_server_credentials_hint ()
return | gnutls_psk_server_get_username ()
int | gnutls_psk_server_get_username2 ()
const char * | gnutls_psk_client_get_hint ()
void | gnutls_psk_set_server_credentials_function ()
void | gnutls_psk_set_server_credentials_function2 ()
void | gnutls_psk_set_server_credentials_function3 ()
int | gnutls_psk_format_imported_identity ()
void | gnutls_psk_set_client_credentials_function ()
void | gnutls_psk_set_client_credentials_function2 ()
void | gnutls_psk_set_client_credentials_function3 ()
int | gnutls_hex_encode ()
int | gnutls_hex_decode ()
int | gnutls_hex_encode2 ()
int | gnutls_hex_decode2 ()
void | gnutls_psk_set_server_dh_params ()
int | gnutls_psk_set_server_known_dh_params ()
void | gnutls_psk_set_server_params_function ()
void | gnutls_dh_set_prime_bits ()
int | gnutls_dh_get_secret_bits ()
int | gnutls_dh_get_peers_public_bits ()
int | gnutls_dh_get_prime_bits ()
int | gnutls_dh_get_group ()
int | gnutls_dh_get_pubkey ()
void | gnutls_certificate_set_retrieve_function ()
void | gnutls_certificate_set_verify_function ()
void | gnutls_certificate_server_set_request ()
const gnutls_datum_t * | gnutls_certificate_get_peers ()
const gnutls_datum_t * | gnutls_certificate_get_ours ()
int | gnutls_certificate_get_peers_subkey_id ()
return | gnutls_certificate_activation_time_peers ()
return | gnutls_certificate_expiration_time_peers ()
unsigned | gnutls_certificate_client_get_request_status ()
int | gnutls_certificate_verify_peers2 ()
int | gnutls_certificate_verify_peers3 ()
int | gnutls_certificate_verify_peers ()
int | gnutls_certificate_verification_status_print ()
int | gnutls_pem_base64_encode ()
int | gnutls_pem_base64_decode ()
int | gnutls_pem_base64_encode2 ()
int | gnutls_pem_base64_decode2 ()
int | gnutls_base64_encode2 ()
int | gnutls_base64_decode2 ()
void | gnutls_certificate_set_params_function ()
void | gnutls_anon_set_params_function ()
void | gnutls_psk_set_params_function ()
int | gnutls_hex2bin ()
int | (*gnutls_tdb_store_func) ()
int | (*gnutls_tdb_store_commitment_func) ()
int | (*gnutls_tdb_verify_func) ()
int | gnutls_tdb_init ()
void | gnutls_tdb_set_store_func ()
void | gnutls_tdb_set_store_commitment_func ()
void | gnutls_tdb_set_verify_func ()
void | gnutls_tdb_deinit ()
int | gnutls_verify_stored_pubkey ()
int | gnutls_store_commitment ()
int | gnutls_store_pubkey ()
int | gnutls_load_file ()
unsigned | gnutls_url_is_supported ()
int | (*gnutls_pin_callback_t) ()
void | gnutls_certificate_set_pin_function ()
int | gnutls_buffer_append_data ()
int | gnutls_utf8_password_normalize ()
void | gnutls_ext_set_data ()
int | gnutls_ext_get_data ()
unsigned | gnutls_ext_get_current_msg ()
int | (*gnutls_ext_recv_func) ()
int | (*gnutls_ext_send_func) ()
void | (*gnutls_ext_deinit_data_func) ()
int | (*gnutls_ext_pack_func) ()
int | (*gnutls_ext_unpack_func) ()
int | (*gnutls_ext_raw_process_func) ()
int | gnutls_ext_raw_parse ()
int | gnutls_ext_register ()
int | gnutls_session_ext_register ()
const char * | gnutls_ext_get_name ()
const char * | gnutls_ext_get_name2 ()
int | (*gnutls_supp_recv_func) ()
int | (*gnutls_supp_send_func) ()
int | gnutls_supplemental_register ()
int | gnutls_session_supplemental_register ()
void | gnutls_supplemental_recv ()
void | gnutls_supplemental_send ()
int | gnutls_anti_replay_init ()
void | gnutls_anti_replay_deinit ()
void | gnutls_anti_replay_set_window ()
void | gnutls_anti_replay_enable ()
int | (*gnutls_db_add_func) ()
void | gnutls_anti_replay_set_add_function ()
void | gnutls_anti_replay_set_ptr ()
int | (*gnutls_handshake_read_func) ()
void | gnutls_handshake_set_read_function ()
int | gnutls_handshake_write ()
int | (*gnutls_handshake_secret_func) ()
void | gnutls_handshake_set_secret_function ()
int | (*gnutls_alert_read_func) ()
void | gnutls_alert_set_read_function ()
unsigned | gnutls_fips140_mode_enabled ()
void | gnutls_fips140_set_mode ()
#define | GNUTLS_FIPS140_SET_LAX_MODE
#define | GNUTLS_FIPS140_SET_STRICT_MODE
int | gnutls_fips140_context_init ()
void | gnutls_fips140_context_deinit ()
gnutls_fips140_operation_state_t | gnutls_fips140_get_operation_state ()
int | gnutls_fips140_push_context ()
int | gnutls_fips140_pop_context ()
int | gnutls_fips140_run_self_tests ()
void | gnutls_audit_push_context ()
void | gnutls_audit_pop_context ()
long | gnutls_audit_current_context ()
gnutls_transport_ktls_enable_flags_t | gnutls_transport_is_ktls_enabled ()

## Types and Values

#define | GNUTLS_VERSION
#define | GNUTLS_VERSION_MAJOR
#define | GNUTLS_VERSION_MINOR
#define | GNUTLS_VERSION_PATCH
#define | GNUTLS_VERSION_NUMBER
#define | GNUTLS_CIPHER_RIJNDAEL_128_CBC
#define | GNUTLS_CIPHER_RIJNDAEL_256_CBC
#define | GNUTLS_CIPHER_RIJNDAEL_CBC
#define | GNUTLS_CIPHER_ARCFOUR
#define | GNUTLS_SKIP_GLOBAL_INIT
enum | gnutls_cipher_algorithm_t
enum | gnutls_kx_algorithm_t
enum | gnutls_params_type_t
enum | gnutls_credentials_type_t
#define | GNUTLS_MAC_SHA
#define | GNUTLS_DIG_SHA
enum | gnutls_mac_algorithm_t
enum | gnutls_digest_algorithm_t
#define | GNUTLS_MAX_ALGORITHM_NUM
#define | GNUTLS_MAX_SESSION_ID_SIZE
enum | gnutls_compression_method_t
enum | gnutls_init_flags_t
#define | GNUTLS_SERVER
#define | GNUTLS_CLIENT
#define | GNUTLS_DATAGRAM
#define | GNUTLS_NONBLOCK
#define | GNUTLS_NO_DEFAULT_EXTENSIONS
#define | GNUTLS_NO_REPLAY_PROTECTION
#define | GNUTLS_NO_SIGNAL
#define | GNUTLS_ALLOW_ID_CHANGE
#define | GNUTLS_ENABLE_FALSE_START
#define | GNUTLS_FORCE_CLIENT_CERT
#define | GNUTLS_NO_TICKETS
#define | GNUTLS_ENABLE_CERT_TYPE_NEG
#define | GNUTLS_NO_EXTENSIONS
enum | gnutls_alert_level_t
enum | gnutls_alert_description_t
enum | gnutls_handshake_description_t
#define | GNUTLS_HANDSHAKE_ANY
enum | gnutls_certificate_status_t
enum | gnutls_certificate_request_t
enum | gnutls_openpgp_crt_status_t
enum | gnutls_close_request_t
enum | gnutls_protocol_t
#define | GNUTLS_CRT_RAW
enum | gnutls_certificate_type_t
enum | gnutls_x509_crt_fmt_t
enum | gnutls_certificate_print_formats_t
#define | GNUTLS_PK_ECC
#define | GNUTLS_PK_EC
#define | GNUTLS_PK_ECDHX
enum | gnutls_pk_algorithm_t
enum | gnutls_sign_algorithm_t
enum | gnutls_ecc_curve_t
enum | gnutls_group_t
enum | gnutls_sec_param_t
#define | GNUTLS_SEC_PARAM_NORMAL
enum | gnutls_channel_binding_t
enum | gnutls_gost_paramset_t
enum | gnutls_ctype_target_t
typedef | gnutls_transport_ptr_t
typedef | gnutls_session_t
typedef | gnutls_dh_params_t
typedef | gnutls_rsa_params_t
typedef | gnutls_priority_t
| gnutls_datum_t
| gnutls_library_config_st
| gnutls_params_st
#define | GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT
#define | GNUTLS_INDEFINITE_TIMEOUT
#define | GNUTLS_KU_PEER
#define | GNUTLS_HEARTBEAT_WAIT
#define | GNUTLS_RECORD_WAIT
| gnutls_range_st
typedef | gnutls_packet_t
#define | gnutls_read
#define | gnutls_write
enum | gnutls_server_name_type_t
#define | GNUTLS_HB_PEER_ALLOWED_TO_SEND
#define | GNUTLS_HB_PEER_NOT_ALLOWED_TO_SEND
#define | GNUTLS_HB_LOCAL_ALLOWED_TO_SEND
enum | gnutls_session_flags_t
enum | gnutls_supplemental_data_format_type_t
enum | gnutls_srtp_profile_t
enum | gnutls_alpn_flags_t
#define | GNUTLS_ALPN_MAND
#define | GNUTLS_PRIORITY_INIT_DEF_APPEND
#define | GNUTLS_PRIORITY_LIST_INIT_KEYWORDS
#define | GNUTLS_PRIORITY_LIST_SPECIAL
enum | gnutls_vdata_types_t
| gnutls_typed_vdata_st
#define | GNUTLS_MAX_SESSION_ID
#define | GNUTLS_HOOK_POST
#define | GNUTLS_HOOK_PRE
#define | GNUTLS_HOOK_BOTH
#define | gnutls_handshake_post_client_hello_func
#define | gnutls_cred_set
typedef | gnutls_pubkey_t
typedef | gnutls_privkey_t
typedef | gnutls_x509_privkey_t
typedef | gnutls_x509_crl_t
typedef | gnutls_x509_crt_t
typedef | gnutls_x509_crq_t
typedef | gnutls_openpgp_keyring_t
typedef | gnutls_certificate_server_credentials
typedef | gnutls_certificate_client_credentials
enum | gnutls_certificate_flags
| gnutls_ocsp_data_st
typedef | giovec_t
enum | gnutls_random_art_t
#define | GNUTLS_IDNA_FORCE_2008
typedef | gnutls_srp_server_credentials_t
typedef | gnutls_srp_client_credentials_t
#define | gnutls_srp_base64_encode_alloc
#define | gnutls_srp_base64_decode_alloc
typedef | gnutls_psk_server_credentials_t
typedef | gnutls_psk_client_credentials_t
enum | gnutls_psk_key_flags
enum | gnutls_x509_subject_alt_name_t
typedef | gnutls_openpgp_crt_t
typedef | gnutls_openpgp_privkey_t
typedef | gnutls_pkcs11_privkey_t
enum | gnutls_privkey_type_t
| gnutls_retr2_st
#define | gnutls_pem_base64_encode_alloc
#define | gnutls_pem_base64_decode_alloc
#define | GNUTLS_KEY_DIGITAL_SIGNATURE
#define | GNUTLS_KEY_NON_REPUDIATION
#define | GNUTLS_KEY_KEY_ENCIPHERMENT
#define | GNUTLS_KEY_DATA_ENCIPHERMENT
#define | GNUTLS_KEY_KEY_AGREEMENT
#define | GNUTLS_KEY_KEY_CERT_SIGN
#define | GNUTLS_KEY_CRL_SIGN
#define | GNUTLS_KEY_ENCIPHER_ONLY
#define | GNUTLS_KEY_DECIPHER_ONLY
typedef | gnutls_tdb_t
#define | GNUTLS_SCOMMIT_FLAG_ALLOW_BROKEN
enum | gnutls_pin_flag_t
#define | GNUTLS_PKCS11_PIN_USER
#define | GNUTLS_PKCS11_PIN_SO
#define | GNUTLS_PKCS11_PIN_FINAL_TRY
#define | GNUTLS_PKCS11_PIN_COUNT_LOW
#define | GNUTLS_PKCS11_PIN_CONTEXT_SPECIFIC
#define | GNUTLS_PKCS11_PIN_WRONG
typedef | gnutls_buffer_t
#define | GNUTLS_UTF8_IGNORE_ERRS
typedef | gnutls_ext_priv_data_t
#define | GNUTLS_EXT_RAW_FLAG_TLS_CLIENT_HELLO
#define | GNUTLS_EXT_RAW_FLAG_DTLS_CLIENT_HELLO
enum | gnutls_ext_parse_type_t
enum | gnutls_ext_flags_t
typedef | gnutls_anti_replay_t
enum | gnutls_record_encryption_level_t
enum | gnutls_fips_mode_t
#define | GNUTLS_FIPS140_SET_MODE_THREAD
typedef | gnutls_fips140_context_t
enum | gnutls_fips140_operation_state_t
enum | gnutls_transport_ktls_enable_flags_t
#define | GNUTLS_E_SUCCESS
#define | GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM
#define | GNUTLS_E_UNKNOWN_CIPHER_TYPE
#define | GNUTLS_E_LARGE_PACKET
#define | GNUTLS_E_UNSUPPORTED_VERSION_PACKET
#define | GNUTLS_E_TLS_PACKET_DECODING_ERROR
#define | GNUTLS_E_UNEXPECTED_PACKET_LENGTH
#define | GNUTLS_E_INVALID_SESSION
#define | GNUTLS_E_FATAL_ALERT_RECEIVED
#define | GNUTLS_E_UNEXPECTED_PACKET
#define | GNUTLS_E_WARNING_ALERT_RECEIVED
#define | GNUTLS_E_ERROR_IN_FINISHED_PACKET
#define | GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET
#define | GNUTLS_E_UNKNOWN_CIPHER_SUITE
#define | GNUTLS_E_UNWANTED_ALGORITHM
#define | GNUTLS_E_MPI_SCAN_FAILED
#define | GNUTLS_E_DECRYPTION_FAILED
#define | GNUTLS_E_MEMORY_ERROR
#define | GNUTLS_E_DECOMPRESSION_FAILED
#define | GNUTLS_E_COMPRESSION_FAILED
#define | GNUTLS_E_AGAIN
#define | GNUTLS_E_EXPIRED
#define | GNUTLS_E_DB_ERROR
#define | GNUTLS_E_SRP_PWD_ERROR
#define | GNUTLS_E_KEYFILE_ERROR
#define | GNUTLS_E_INSUFFICIENT_CREDENTIALS
#define | GNUTLS_E_INSUFICIENT_CREDENTIALS
#define | GNUTLS_E_INSUFFICIENT_CRED
#define | GNUTLS_E_INSUFICIENT_CRED
#define | GNUTLS_E_HASH_FAILED
#define | GNUTLS_E_BASE64_DECODING_ERROR
#define | GNUTLS_E_MPI_PRINT_FAILED
#define | GNUTLS_E_REHANDSHAKE
#define | GNUTLS_E_GOT_APPLICATION_DATA
#define | GNUTLS_E_RECORD_LIMIT_REACHED
#define | GNUTLS_E_ENCRYPTION_FAILED
#define | GNUTLS_E_PK_ENCRYPTION_FAILED
#define | GNUTLS_E_PK_DECRYPTION_FAILED
#define | GNUTLS_E_PK_SIGN_FAILED
#define | GNUTLS_E_X509_UNSUPPORTED_CRITICAL_EXTENSION
#define | GNUTLS_E_KEY_USAGE_VIOLATION
#define | GNUTLS_E_NO_CERTIFICATE_FOUND
#define | GNUTLS_E_INVALID_REQUEST
#define | GNUTLS_E_SHORT_MEMORY_BUFFER
#define | GNUTLS_E_INTERRUPTED
#define | GNUTLS_E_PUSH_ERROR
#define | GNUTLS_E_PULL_ERROR
#define | GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER
#define | GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE
#define | GNUTLS_E_PKCS1_WRONG_PAD
#define | GNUTLS_E_RECEIVED_ILLEGAL_EXTENSION
#define | GNUTLS_E_INTERNAL_ERROR
#define | GNUTLS_E_DH_PRIME_UNACCEPTABLE
#define | GNUTLS_E_FILE_ERROR
#define | GNUTLS_E_TOO_MANY_EMPTY_PACKETS
#define | GNUTLS_E_UNKNOWN_PK_ALGORITHM
#define | GNUTLS_E_TOO_MANY_HANDSHAKE_PACKETS
#define | GNUTLS_E_RECEIVED_DISALLOWED_NAME
#define | GNUTLS_E_CERTIFICATE_REQUIRED
#define | GNUTLS_E_UNSUPPORTED_ENCRYPTION_ALGORITHM
#define | GNUTLS_E_NO_TEMPORARY_RSA_PARAMS
#define | GNUTLS_E_NO_COMPRESSION_ALGORITHMS
#define | GNUTLS_E_NO_CIPHER_SUITES
#define | GNUTLS_E_OPENPGP_GETKEY_FAILED
#define | GNUTLS_E_PK_SIG_VERIFY_FAILED
#define | GNUTLS_E_ILLEGAL_SRP_USERNAME
#define | GNUTLS_E_SRP_PWD_PARSING_ERROR
#define | GNUTLS_E_KEYFILE_PARSING_ERROR
#define | GNUTLS_E_NO_TEMPORARY_DH_PARAMS
#define | GNUTLS_E_ASN1_ELEMENT_NOT_FOUND
#define | GNUTLS_E_ASN1_IDENTIFIER_NOT_FOUND
#define | GNUTLS_E_ASN1_DER_ERROR
#define | GNUTLS_E_ASN1_VALUE_NOT_FOUND
#define | GNUTLS_E_ASN1_GENERIC_ERROR
#define | GNUTLS_E_ASN1_VALUE_NOT_VALID
#define | GNUTLS_E_ASN1_TAG_ERROR
#define | GNUTLS_E_ASN1_TAG_IMPLICIT
#define | GNUTLS_E_ASN1_TYPE_ANY_ERROR
#define | GNUTLS_E_ASN1_SYNTAX_ERROR
#define | GNUTLS_E_ASN1_DER_OVERFLOW
#define | GNUTLS_E_OPENPGP_UID_REVOKED
#define | GNUTLS_E_CERTIFICATE_ERROR
#define | GNUTLS_E_X509_CERTIFICATE_ERROR
#define | GNUTLS_E_CERTIFICATE_KEY_MISMATCH
#define | GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE
#define | GNUTLS_E_X509_UNKNOWN_SAN
#define | GNUTLS_E_OPENPGP_FINGERPRINT_UNSUPPORTED
#define | GNUTLS_E_X509_UNSUPPORTED_ATTRIBUTE
#define | GNUTLS_E_UNKNOWN_HASH_ALGORITHM
#define | GNUTLS_E_UNKNOWN_PKCS_CONTENT_TYPE
#define | GNUTLS_E_UNKNOWN_PKCS_BAG_TYPE
#define | GNUTLS_E_INVALID_PASSWORD
#define | GNUTLS_E_MAC_VERIFY_FAILED
#define | GNUTLS_E_CONSTRAINT_ERROR
#define | GNUTLS_E_WARNING_IA_IPHF_RECEIVED
#define | GNUTLS_E_WARNING_IA_FPHF_RECEIVED
#define | GNUTLS_E_IA_VERIFY_FAILED
#define | GNUTLS_E_UNKNOWN_ALGORITHM
#define | GNUTLS_E_UNSUPPORTED_SIGNATURE_ALGORITHM
#define | GNUTLS_E_SAFE_RENEGOTIATION_FAILED
#define | GNUTLS_E_UNSAFE_RENEGOTIATION_DENIED
#define | GNUTLS_E_UNKNOWN_SRP_USERNAME
#define | GNUTLS_E_PREMATURE_TERMINATION
#define | GNUTLS_E_MALFORMED_CIDR
#define | GNUTLS_E_BASE64_ENCODING_ERROR
#define | GNUTLS_E_INCOMPATIBLE_GCRYPT_LIBRARY
#define | GNUTLS_E_INCOMPATIBLE_CRYPTO_LIBRARY
#define | GNUTLS_E_INCOMPATIBLE_LIBTASN1_LIBRARY
#define | GNUTLS_E_OPENPGP_KEYRING_ERROR
#define | GNUTLS_E_X509_UNSUPPORTED_OID
#define | GNUTLS_E_RANDOM_FAILED
#define | GNUTLS_E_BASE64_UNEXPECTED_HEADER_ERROR
#define | GNUTLS_E_OPENPGP_SUBKEY_ERROR
#define | GNUTLS_E_CRYPTO_ALREADY_REGISTERED
#define | GNUTLS_E_ALREADY_REGISTERED
#define | GNUTLS_E_HANDSHAKE_TOO_LARGE
#define | GNUTLS_E_CRYPTODEV_IOCTL_ERROR
#define | GNUTLS_E_CRYPTODEV_DEVICE_ERROR
#define | GNUTLS_E_CHANNEL_BINDING_NOT_AVAILABLE
#define | GNUTLS_E_BAD_COOKIE
#define | GNUTLS_E_OPENPGP_PREFERRED_KEY_ERROR
#define | GNUTLS_E_INCOMPAT_DSA_KEY_WITH_TLS_PROTOCOL
#define | GNUTLS_E_INSUFFICIENT_SECURITY
#define | GNUTLS_E_HEARTBEAT_PONG_RECEIVED
#define | GNUTLS_E_HEARTBEAT_PING_RECEIVED
#define | GNUTLS_E_UNRECOGNIZED_NAME
#define | GNUTLS_E_PKCS11_ERROR
#define | GNUTLS_E_PKCS11_LOAD_ERROR
#define | GNUTLS_E_PARSING_ERROR
#define | GNUTLS_E_PKCS11_PIN_ERROR
#define | GNUTLS_E_PKCS11_SLOT_ERROR
#define | GNUTLS_E_LOCKING_ERROR
#define | GNUTLS_E_PKCS11_ATTRIBUTE_ERROR
#define | GNUTLS_E_PKCS11_DEVICE_ERROR
#define | GNUTLS_E_PKCS11_DATA_ERROR
#define | GNUTLS_E_PKCS11_UNSUPPORTED_FEATURE_ERROR
#define | GNUTLS_E_PKCS11_KEY_ERROR
#define | GNUTLS_E_PKCS11_PIN_EXPIRED
#define | GNUTLS_E_PKCS11_PIN_LOCKED
#define | GNUTLS_E_PKCS11_SESSION_ERROR
#define | GNUTLS_E_PKCS11_SIGNATURE_ERROR
#define | GNUTLS_E_PKCS11_TOKEN_ERROR
#define | GNUTLS_E_PKCS11_USER_ERROR
#define | GNUTLS_E_CRYPTO_INIT_FAILED
#define | GNUTLS_E_TIMEDOUT
#define | GNUTLS_E_USER_ERROR
#define | GNUTLS_E_ECC_NO_SUPPORTED_CURVES
#define | GNUTLS_E_ECC_UNSUPPORTED_CURVE
#define | GNUTLS_E_PKCS11_REQUESTED_OBJECT_NOT_AVAILBLE
#define | GNUTLS_E_CERTIFICATE_LIST_UNSORTED
#define | GNUTLS_E_ILLEGAL_PARAMETER
#define | GNUTLS_E_NO_PRIORITIES_WERE_SET
#define | GNUTLS_E_X509_UNSUPPORTED_EXTENSION
#define | GNUTLS_E_SESSION_EOF
#define | GNUTLS_E_TPM_ERROR
#define | GNUTLS_E_TPM_KEY_PASSWORD_ERROR
#define | GNUTLS_E_TPM_SRK_PASSWORD_ERROR
#define | GNUTLS_E_TPM_SESSION_ERROR
#define | GNUTLS_E_TPM_KEY_NOT_FOUND
#define | GNUTLS_E_TPM_UNINITIALIZED
#define | GNUTLS_E_TPM_NO_LIB
#define | GNUTLS_E_NO_CERTIFICATE_STATUS
#define | GNUTLS_E_OCSP_RESPONSE_ERROR
#define | GNUTLS_E_RANDOM_DEVICE_ERROR
#define | GNUTLS_E_AUTH_ERROR
#define | GNUTLS_E_NO_APPLICATION_PROTOCOL
#define | GNUTLS_E_SOCKETS_INIT_ERROR
#define | GNUTLS_E_KEY_IMPORT_FAILED
#define | GNUTLS_E_INAPPROPRIATE_FALLBACK
#define | GNUTLS_E_CERTIFICATE_VERIFICATION_ERROR
#define | GNUTLS_E_PRIVKEY_VERIFICATION_ERROR
#define | GNUTLS_E_UNEXPECTED_EXTENSIONS_LENGTH
#define | GNUTLS_E_ASN1_EMBEDDED_NULL_IN_STRING
#define | GNUTLS_E_SELF_TEST_ERROR
#define | GNUTLS_E_NO_SELF_TEST
#define | GNUTLS_E_LIB_IN_ERROR_STATE
#define | GNUTLS_E_PK_GENERATION_ERROR
#define | GNUTLS_E_IDNA_ERROR
#define | GNUTLS_E_NEED_FALLBACK
#define | GNUTLS_E_SESSION_USER_ID_CHANGED
#define | GNUTLS_E_HANDSHAKE_DURING_FALSE_START
#define | GNUTLS_E_UNAVAILABLE_DURING_HANDSHAKE
#define | GNUTLS_E_PK_INVALID_PUBKEY
#define | GNUTLS_E_PK_INVALID_PRIVKEY
#define | GNUTLS_E_NOT_YET_ACTIVATED
#define | GNUTLS_E_INVALID_UTF8_STRING
#define | GNUTLS_E_NO_EMBEDDED_DATA
#define | GNUTLS_E_INVALID_UTF8_EMAIL
#define | GNUTLS_E_INVALID_PASSWORD_STRING
#define | GNUTLS_E_CERTIFICATE_TIME_ERROR
#define | GNUTLS_E_RECORD_OVERFLOW
#define | GNUTLS_E_ASN1_TIME_ERROR
#define | GNUTLS_E_INCOMPATIBLE_SIG_WITH_KEY
#define | GNUTLS_E_PK_INVALID_PUBKEY_PARAMS
#define | GNUTLS_E_PK_NO_VALIDATION_PARAMS
#define | GNUTLS_E_OCSP_MISMATCH_WITH_CERTS
#define | GNUTLS_E_NO_COMMON_KEY_SHARE
#define | GNUTLS_E_REAUTH_REQUEST
#define | GNUTLS_E_TOO_MANY_MATCHES
#define | GNUTLS_E_CRL_VERIFICATION_ERROR
#define | GNUTLS_E_MISSING_EXTENSION
#define | GNUTLS_E_DB_ENTRY_EXISTS
#define | GNUTLS_E_EARLY_DATA_REJECTED
#define | GNUTLS_E_X509_DUPLICATE_EXTENSION
#define | GNUTLS_E_UNIMPLEMENTED_FEATURE
#define | GNUTLS_E_INT_RET_0
#define | GNUTLS_E_INT_CHECK_AGAIN
#define | GNUTLS_E_APPLICATION_ERROR_MAX
#define | GNUTLS_E_APPLICATION_ERROR_MIN
struct | gnutls_certificate_credentials_st
struct | gnutls_dh_params_int
struct | gnutls_openpgp_crt_int
struct | gnutls_openpgp_keyring_int
struct | gnutls_openpgp_privkey_int
struct | gnutls_pkcs11_privkey_st
struct | gnutls_priority_st
struct | gnutls_privkey_st
struct | gnutls_pubkey_st
struct | gnutls_session_int
struct | gnutls_tdb_int
| gnutls_x509_crl_int
| gnutls_x509_crq_int
| gnutls_x509_crt_int
| gnutls_x509_privkey_int

## Description

## Functions

### gnutls_handshake_description_get_name ()

    const char *
    gnutls_handshake_description_get_name (gnutls_handshake_description_t type);

Convert a gnutls_handshake_description_t value to a string.

#### Parameters

type | is a handshake message description |

#### Returns

a string that contains the name of the specified handshake message or `NULL`.

### gnutls_pk_algorithm_get_name ()

    const char *
    gnutls_pk_algorithm_get_name (gnutls_pk_algorithm_t algorithm);

Convert a gnutls_pk_algorithm_t value to a string.

#### Parameters

algorithm | is a pk algorithm |

#### Returns

a string that contains the name of the specified public key algorithm, or `NULL`.

### GNUTLS_CURVE_TO_BITS()

    #define             GNUTLS_CURVE_TO_BITS(curve)

### GNUTLS_BITS_TO_CURVE()

    #define GNUTLS_BITS_TO_CURVE(bits) (((unsigned int)(bits)) & 0x7FFFFFFF)

### GNUTLS_BITS_ARE_CURVE()

    #define GNUTLS_BITS_ARE_CURVE(bits) (((unsigned int)(bits)) & 0x80000000)

### gnutls_init ()

    int
    gnutls_init (gnutls_session_t *session,
                 unsigned int flags);

This function initializes the provided session. Every session must be initialized before use, and after successful initialization and use must be deinitialized by calling `gnutls_deinit()`.

`flags` can be any combination of flags from `gnutls_init_flags_t`.

Note that since version 3.1.2 this function enables some common TLS extensions such as session tickets and OCSP certificate status request in client side by default. To prevent that use the `GNUTLS_NO_DEFAULT_EXTENSIONS` flag.

Note that it is never mandatory to use `gnutls_deinit()` after this function fails. Since gnutls 3.8.0, it is safe to unconditionally use `gnutls_deinit()` even after failure regardless of whether the memory was initialized prior to `gnutls_init()`; however, clients wanting to be portable to older versions of the library should either skip deinitialization on failure, or pre-initialize the memory passed in to `gnutls_init()` to all zeroes via `memset()` or similar.

#### Parameters

session | is a pointer to a gnutls_session_t type. |
flags | indicate if this session is to be used for server or client. |

#### Returns

`GNUTLS_E_SUCCESS` on success, or an error code.

### gnutls_deinit ()

    void
    gnutls_deinit (gnutls_session_t session);

This function clears all buffers associated with the `session` . This function will also remove session data from the session database if the session was terminated abnormally.

#### Parameters

session | is a gnutls_session_t type. |

### gnutls_bye ()

    int
    gnutls_bye (gnutls_session_t session,
                gnutls_close_request_t how);

Terminates the current TLS/SSL connection. The connection should have been initiated using `gnutls_handshake()`. `how` should be one of `GNUTLS_SHUT_RDWR`, `GNUTLS_SHUT_WR`.

In case of `GNUTLS_SHUT_RDWR` the TLS session gets terminated and further receives and sends will be disallowed. If the return value is zero you may continue using the underlying transport layer. `GNUTLS_SHUT_RDWR` sends an alert containing a close request and waits for the peer to reply with the same message.

In case of `GNUTLS_SHUT_WR` the TLS session gets terminated and further sends will be disallowed. In order to reuse the connection you should wait for an EOF from the peer. `GNUTLS_SHUT_WR` sends an alert containing a close request.

Note that not all implementations will properly terminate a TLS connection. Some of them, usually for performance reasons, will terminate only the underlying transport layer, and thus not distinguishing between a malicious party prematurely terminating the connection and normal termination.

This function may also return `GNUTLS_E_AGAIN` or `GNUTLS_E_INTERRUPTED`; cf. `gnutls_record_get_direction()`.

#### Parameters

session | is a gnutls_session_t type. |
how | is an integer |

#### Returns

`GNUTLS_E_SUCCESS` on success, or an error code, see function documentation for entire semantics.

### gnutls_handshake ()

    int
    gnutls_handshake (gnutls_session_t session);

This function performs the handshake of the TLS/SSL protocol, and initializes the TLS session parameters.

The non-fatal errors expected by this function are: `GNUTLS_E_INTERRUPTED`, `GNUTLS_E_AGAIN`, `GNUTLS_E_WARNING_ALERT_RECEIVED`. When this function is called for re-handshake under TLS 1.2 or earlier, the non-fatal error code `GNUTLS_E_GOT_APPLICATION_DATA` may also be returned.

The former two interrupt the handshake procedure due to the transport layer being interrupted, and the latter because of a "warning" alert that was sent by the peer (it is always a good idea to check any received alerts). On these non-fatal errors call this function again, until it returns 0; cf. `gnutls_record_get_direction()` and `gnutls_error_is_fatal()`. In DTLS sessions the non-fatal error `GNUTLS_E_LARGE_PACKET` is also possible, and indicates that the MTU should be adjusted.

When this function is called by a server after a rehandshake request under TLS 1.2 or earlier the `GNUTLS_E_GOT_APPLICATION_DATA` error code indicates that some data were pending prior to peer initiating the handshake. Under TLS 1.3 this function when called after a successful handshake, is a no-op and always succeeds in server side; in client side this function is equivalent to `gnutls_session_key_update()` with `GNUTLS_KU_PEER` flag.

This function handles both full and abbreviated TLS handshakes (resumption). For abbreviated handshakes, in client side, the `gnutls_session_set_data()` should be called prior to this function to set parameters from a previous session. In server side, resumption is handled by either setting a DB back-end, or setting up keys for session tickets.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

`GNUTLS_E_SUCCESS` on a successful handshake, otherwise a negative error code.

### gnutls_reauth ()

    int
    gnutls_reauth (gnutls_session_t session,
                   unsigned int flags);

This function performs the post-handshake authentication for TLS 1.3. The post-handshake authentication is initiated by the server by calling this function. Clients respond when `GNUTLS_E_REAUTH_REQUEST` has been seen while receiving data.

The non-fatal errors expected by this function are: `GNUTLS_E_INTERRUPTED`, `GNUTLS_E_AGAIN`, as well as `GNUTLS_E_GOT_APPLICATION_DATA` when called on server side.

The former two interrupt the authentication procedure due to the transport layer being interrupted, and the latter because there were pending data prior to peer initiating the re-authentication. The server should read/process that data as unauthenticated and retry calling `gnutls_reauth()`.

When this function is called under TLS1.2 or earlier or the peer didn't advertise post-handshake auth, it always fails with `GNUTLS_E_INVALID_REQUEST`. The verification of the received peers certificate is delegated to the session or credentials verification callbacks. A server can check whether post handshake authentication is supported by the client by checking the session flags with `gnutls_session_get_flags()`.

Prior to calling this function in server side, the function `gnutls_certificate_server_set_request()` must be called setting expectations for the received certificate (request or require). If none are set this function will return with `GNUTLS_E_INVALID_REQUEST`.

Note that post handshake authentication is available irrespective of the initial negotiation type (PSK or certificate). In all cases however, certificate credentials must be set to the session prior to calling this function.

#### Parameters

session | is a gnutls_session_t type. |
flags | must be zero |

#### Returns

`GNUTLS_E_SUCCESS` on a successful authentication, otherwise a negative error code.

### gnutls_handshake_set_timeout ()

    void
    gnutls_handshake_set_timeout (gnutls_session_t session,
                                  unsigned int ms);

This function sets the timeout for the TLS handshake process to the provided value. Use an `ms` value of zero to disable timeout, or `GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT` for a reasonable default value. For the DTLS protocol, the more detailed `gnutls_dtls_set_timeouts()` is provided.

This function requires to set a pull timeout callback. See `gnutls_transport_set_pull_timeout_function()`.

#### Parameters

session | is a gnutls_session_t type. |
ms | is a timeout value in milliseconds |

Since: 3.1.0

### gnutls_rehandshake ()

    int
    gnutls_rehandshake (gnutls_session_t session);

This function can only be called in server side, and instructs a TLS 1.2 or earlier client to renegotiate parameters (perform a handshake), by sending a hello request message.

If this function succeeds, the calling application should call `gnutls_record_recv()` until `GNUTLS_E_REHANDSHAKE` is returned to clear any pending data. If the `GNUTLS_E_REHANDSHAKE` error code is not seen, then the handshake request was not followed by the peer (the TLS protocol does not require the client to do, and such compliance should be handled by the application protocol).

Once the `GNUTLS_E_REHANDSHAKE` error code is seen, the calling application should proceed to calling `gnutls_handshake()` to negotiate the new parameters.

If the client does not wish to renegotiate parameters he may reply with an alert message, and in that case the return code seen by subsequent `gnutls_record_recv()` will be `GNUTLS_E_WARNING_ALERT_RECEIVED` with the specific alert being `GNUTLS_A_NO_RENEGOTIATION`. A client may also choose to ignore this request.

Under TLS 1.3 this function is equivalent to `gnutls_session_key_update()` with the `GNUTLS_KU_PEER` flag. In that case subsequent calls to `gnutls_record_recv()` will not return `GNUTLS_E_REHANDSHAKE`, and calls to `gnutls_handshake()` in server side are a no-op.

This function always fails with `GNUTLS_E_INVALID_REQUEST` when called in client side.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

`GNUTLS_E_SUCCESS` on success, otherwise a negative error code.

### gnutls_session_key_update ()

    int
    gnutls_session_key_update (gnutls_session_t session,
                               unsigned  flags);

This function will update/refresh the session keys when the TLS protocol is 1.3 or better. The peer is notified of the update by sending a message, so this function should be treated similarly to `gnutls_record_send()` --i.e., it may return `GNUTLS_E_AGAIN` or `GNUTLS_E_INTERRUPTED`.

When this flag `GNUTLS_KU_PEER` is specified, this function in addition to updating the local keys, will ask the peer to refresh its keys too.

If the negotiated version is not TLS 1.3 or better this function will return `GNUTLS_E_INVALID_REQUEST`.

#### Parameters

session | is a gnutls_session_t type. |
flags | zero of `GNUTLS_KU_PEER` |

#### Returns

`GNUTLS_E_SUCCESS` on success, otherwise a negative error code.

Since: 3.6.3

### gnutls_handshake_update_receiving_key ()

    int
    gnutls_handshake_update_receiving_key (gnutls_session_t session);

This function will update/refresh the session receiving keys when the TLS protocol is 1.3 or better. Unlike `gnutls_session_key_update()` this function does not notify the peer, it will only update the local keys.

If the negotiated version is not TLS 1.3 or better this function will return `GNUTLS_E_INVALID_REQUEST`.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

`GNUTLS_E_SUCCESS` on success, otherwise a negative error code.

Since: 3.8.11

### gnutls_alert_get ()

    return
    gnutls_alert_get (s Param1);

This function will return the last alert number received. This function should be called when `GNUTLS_E_WARNING_ALERT_RECEIVED` or `GNUTLS_E_FATAL_ALERT_RECEIVED` errors are returned by a gnutls function. The peer may send alerts if he encounters an error. If no alert has been received the returned value is undefined.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

the last alert received, a gnutls_alert_description_t value.

### gnutls_alert_send ()

    int
    gnutls_alert_send (gnutls_session_t session,
                       gnutls_alert_level_t level,
                       gnutls_alert_description_t desc);

This function will send an alert to the peer in order to inform him of something important (eg. his Certificate could not be verified). If the alert level is Fatal then the peer is expected to close the connection, otherwise he may ignore the alert and continue.

The error code of the underlying record send function will be returned, so you may also receive `GNUTLS_E_INTERRUPTED` or `GNUTLS_E_AGAIN` as well.

#### Parameters

session | is a gnutls_session_t type. |
level | is the level of the alert |
desc | is the alert description |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

### gnutls_alert_send_appropriate ()

    int
    gnutls_alert_send_appropriate (gnutls_session_t session,
                                   int err);

Sends an alert to the peer depending on the error code returned by a gnutls function. This function will call `gnutls_error_to_alert()` to determine the appropriate alert to send.

This function may also return `GNUTLS_E_AGAIN`, or `GNUTLS_E_INTERRUPTED`.

This function historically was always sending an alert to the peer, even if `err` was inappropriate to respond with an alert (e.g., `GNUTLS_E_SUCCESS`). Since 3.6.6 this function returns success without transmitting any data on error codes that should not result to an alert.

#### Parameters

session | is a gnutls_session_t type. |
err | is an error code returned by another GnuTLS function |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

### gnutls_alert_get_name ()

    const char *
    gnutls_alert_get_name (gnutls_alert_description_t alert);

This function will return a string that describes the given alert number, or `NULL`. See `gnutls_alert_get()`.

#### Parameters

alert | is an alert number. |

#### Returns

string corresponding to gnutls_alert_description_t value.

### gnutls_alert_get_strname ()

    const char *
    gnutls_alert_get_strname (gnutls_alert_description_t alert);

This function will return a string of the name of the alert.

#### Parameters

alert | is an alert number. |

#### Returns

string corresponding to gnutls_alert_description_t value.

Since: 3.0

### gnutls_pk_bits_to_sec_param ()

    gnutls_sec_param_t
    gnutls_pk_bits_to_sec_param (gnutls_pk_algorithm_t algo,
                                 unsigned int bits);

This is the inverse of `gnutls_sec_param_to_pk_bits()`. Given an algorithm and the number of bits, it will return the security parameter. This is a rough indication.

#### Parameters

algo | is a public key algorithm |
bits | is the number of bits |

#### Returns

The security parameter.

Since: 2.12.0

### gnutls_sec_param_get_name ()

    const char *
    gnutls_sec_param_get_name (gnutls_sec_param_t param);

Convert a gnutls_sec_param_t value to a string.

#### Parameters

param | is a security parameter |

#### Returns

a pointer to a string that contains the name of the specified security level, or `NULL`.

Since: 2.12.0

### gnutls_sec_param_to_pk_bits ()

    unsigned int
    gnutls_sec_param_to_pk_bits (gnutls_pk_algorithm_t algo,
                                 gnutls_sec_param_t param);

When generating private and public key pairs a difficult question is which size of "bits" the modulus will be in RSA and the group size in DSA. The easy answer is 1024, which is also wrong. This function will convert a human understandable security parameter to an appropriate size for the specific algorithm.

#### Parameters

algo | is a public key algorithm |
param | is a security parameter |

#### Returns

The number of bits, or (0).

Since: 2.12.0

### gnutls_sec_param_to_symmetric_bits ()

    unsigned int
    gnutls_sec_param_to_symmetric_bits ();

This function will return the number of bits that correspond to symmetric cipher strength for the given security parameter.

#### Parameters

algo | is a public key algorithm |
param | is a security parameter |

#### Returns

The number of bits, or (0).

Since: 3.3.0

### gnutls_group_get ()

    gnutls_group_t
    gnutls_group_get (gnutls_session_t session);

Returns the currently used group for key exchange. Only valid when using an elliptic curve or DH ciphersuite.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

the currently used group, a gnutls_group_t type.

Since: 3.6.0

### gnutls_cipher_get ()

    return
    gnutls_cipher_get (s Param1);

Get the currently used cipher.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

the currently used cipher, a gnutls_cipher_algorithm_t type.

### gnutls_early_cipher_get ()

    gnutls_cipher_algorithm_t
    gnutls_early_cipher_get (gnutls_session_t session);

Get the cipher algorithm used for encrypting early data.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

the cipher used for early data, a gnutls_cipher_algorithm_t type.

Since: 3.7.2

### gnutls_kx_get ()

    return
    gnutls_kx_get (s Param1);

Get the currently used key exchange algorithm.

This function will return `GNUTLS_KX_ECDHE_RSA`, or `GNUTLS_KX_DHE_RSA` under TLS 1.3, to indicate an elliptic curve DH key exchange or a finite field one. The precise group used is available by calling `gnutls_group_get()` instead.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

the key exchange algorithm used in the last handshake, a gnutls_kx_algorithm_t value.

### gnutls_mac_get ()

    return
    gnutls_mac_get (s Param1);

Get the currently used MAC algorithm.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

the currently used mac algorithm, a gnutls_mac_algorithm_t value.

### gnutls_prf_hash_get ()

    gnutls_digest_algorithm_t
    gnutls_prf_hash_get (const gnutls_session_t session);

Get the currently used hash algorithm. In TLS 1.3, the hash algorithm is used for both the key derivation function and handshake message authentication code. In TLS 1.2, it matches the hash algorithm used for PRF.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

the currently used hash algorithm, a gnutls_digest_algorithm_t value.

Since: 3.6.13

### gnutls_early_prf_hash_get ()

    gnutls_digest_algorithm_t
    gnutls_early_prf_hash_get (const gnutls_session_t session);

Get the hash algorithm used as a PRF to derive keys for encrypting early data in TLS 1.3.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

the hash algorithm used for early data, a gnutls_digest_algorithm_t value.

Since: 3.7.2

### gnutls_certificate_type_get ()

    return
    gnutls_certificate_type_get (s Param1);

This function returns the type of the certificate that is negotiated for this side to send to the peer. The certificate type is by default X.509, unless an alternative certificate type is enabled by `gnutls_init()` and negotiated during the session.

Resumed sessions will return the certificate type that was negotiated and used in the original session.

As of version 3.6.4 it is recommended to use `gnutls_certificate_type_get2()` which is more fine-grained.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

the currently used gnutls_certificate_type_t certificate type as negotiated for 'our' side of the connection.

### gnutls_certificate_type_get2 ()

    gnutls_certificate_type_t
    gnutls_certificate_type_get2 (gnutls_session_t session,
                                  gnutls_ctype_target_t target);

This function returns the type of the certificate that a side is negotiated to use. The certificate type is by default X.509, unless an alternative certificate type is enabled by `gnutls_init()` and negotiated during the session.

The `target` parameter specifies whether to request the negotiated certificate type for the client (`GNUTLS_CTYPE_CLIENT`), or for the server (`GNUTLS_CTYPE_SERVER`). Additionally, in P2P mode connection set up where you don't know in advance who will be client and who will be server you can use the flag (`GNUTLS_CTYPE_OURS`) and (`GNUTLS_CTYPE_PEERS`) to retrieve the corresponding certificate types.

Resumed sessions will return the certificate type that was negotiated and used in the original session. That is, this function can be used to reliably determine the type of the certificate returned by `gnutls_certificate_get_peers()`.

#### Parameters

session | is a gnutls_session_t type. |
target | is a gnutls_ctype_target_t type. |

#### Returns

the currently used gnutls_certificate_type_t certificate type for the client or the server.

Since: 3.6.4

### gnutls_sign_algorithm_get ()

    int
    gnutls_sign_algorithm_get (gnutls_session_t session);

Returns the signature algorithm that is (or will be) used in this session by the server to sign data. This function should be used only with TLS 1.2 or later.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

The sign algorithm or `GNUTLS_SIGN_UNKNOWN`.

Since: 3.1.1

### gnutls_sign_algorithm_get_client ()

    int
    gnutls_sign_algorithm_get_client (gnutls_session_t session);

Returns the signature algorithm that is (or will be) used in this session by the client to sign data. This function should be used only with TLS 1.2 or later.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

The sign algorithm or `GNUTLS_SIGN_UNKNOWN`.

Since: 3.1.11

### gnutls_sign_algorithm_get_requested ()

    int
    gnutls_sign_algorithm_get_requested (gnutls_session_t session,
                                         size_t indx,
                                         gnutls_sign_algorithm_t *algo);

Returns the signature algorithm specified by index that was requested by the peer. If the specified index has no data available this function returns `GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE`. If the negotiated TLS version does not support signature algorithms then `GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE` will be returned even for the first index. The first index is 0.

This function is useful in the certificate callback functions to assist in selecting the correct certificate.

#### Parameters

session | is a gnutls_session_t type. |
indx | is an index of the signature algorithm to return |
algo | the returned certificate type will be stored there |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

Since: 2.10.0

### gnutls_cipher_get_name ()

    const char *
    gnutls_cipher_get_name ();

Convert a gnutls_cipher_algorithm_t type to a string.

#### Parameters

algorithm | is an encryption algorithm |

#### Returns

a pointer to a string that contains the name of the specified cipher, or `NULL`.

### gnutls_oid_to_digest ()

    gnutls_digest_algorithm_t
    gnutls_oid_to_digest ();

Converts a textual object identifier to a gnutls_digest_algorithm_t value.

#### Parameters

oid | is an object identifier |

#### Returns

a gnutls_digest_algorithm_t id of the specified digest algorithm, or `GNUTLS_DIG_UNKNOWN` on failure.

Since: 3.4.3

### gnutls_ecc_curve_set_enabled ()

    int
    gnutls_ecc_curve_set_enabled (gnutls_ecc_curve_t curve,
                                  unsigned int enabled);

Modify the previous system wide setting that marked `curve` as enabled or disabled. Calling this function is allowed only if allowlisting mode is set in the configuration file, and only if the system-wide TLS priority string has not been initialized yet. The intended usage is to provide applications with a way to expressly deviate from the distribution or site defaults inherited from the configuration file. The modification is composable with further modifications performed through the priority string mechanism.

This function is not thread-safe and is intended to be called in the main thread at the beginning of the process execution.

#### Parameters

curve | is an ECC curve |
enabled | whether to enable the curve |

#### Returns

0 on success or negative error code otherwise.

Since: 3.7.3

### gnutls_sign_set_secure ()

    int
    gnutls_sign_set_secure (gnutls_sign_algorithm_t sign,
                            unsigned int secure);

Modify the previous system wide setting that marked `sign` as secure or insecure. Calling this function is allowed only if allowlisting mode is set in the configuration file, and only if the system-wide TLS priority string has not been initialized yet. The intended usage is to provide applications with a way to expressly deviate from the distribution or site defaults inherited from the configuration file. The modification is composable with further modifications performed through the priority string mechanism.

This function is not thread-safe and is intended to be called in the main thread at the beginning of the process execution.

Even when `secure` is true, `sign` is not marked as secure for the use in certificates. Use `gnutls_sign_set_secure_for_certs()` to mark it secure as well for certificates.

#### Parameters

sign | the sign algorithm |
secure | whether to mark the sign algorithm secure |

#### Returns

0 on success or negative error code otherwise.

Since: 3.7.3

### gnutls_sign_set_secure_for_certs ()

    int
    gnutls_sign_set_secure_for_certs (gnutls_sign_algorithm_t sign,
                                      unsigned int secure);

Modify the previous system wide setting that marked `sign` as secure or insecure for the use in certificates. Calling this function is allowed only if allowlisting mode is set in the configuration file, and only if the system-wide TLS priority string has not been initialized yet. The intended usage is to provide applications with a way to expressly deviate from the distribution or site defaults inherited from the configuration file. The modification is composable with further modifications performed through the priority string mechanism.

This function is not thread-safe and is intended to be called in the main thread at the beginning of the process execution.

When `secure` is true, `sign` is marked as secure for any use unlike `gnutls_sign_set_secure()`. Otherwise, it is marked as insecure only for the use in certificates. Use `gnutls_sign_set_secure()` to mark it insecure for any uses.

#### Parameters

sign | the sign algorithm |
secure | whether to mark the sign algorithm secure for certificates |

#### Returns

0 on success or negative error code otherwise.

Since: 3.7.3

### gnutls_digest_set_secure ()

    int
    gnutls_digest_set_secure (gnutls_digest_algorithm_t dig,
                              unsigned int secure);

Modify the previous system wide setting that marked `dig` as secure or insecure. This only has effect when the algorithm is enabled through the allowlisting mode in the configuration file, or when the setting is modified with a prior call to this function.

#### Parameters

dig | is a digest algorithm |
secure | whether to mark the digest algorithm secure |

Since: 3.7.3

### gnutls_protocol_set_enabled ()

    int
    gnutls_protocol_set_enabled (gnutls_protocol_t version,
                                 unsigned int enabled);

Control the previous system-wide setting that marked `version` as enabled or disabled. Calling this function is allowed only if allowlisting mode is set in the configuration file, and only if the system-wide TLS priority string has not been initialized yet. The intended usage is to provide applications with a way to expressly deviate from the distribution or site defaults inherited from the configuration file. The modification is composable with further modifications performed through the priority string mechanism.

This function is not thread-safe and is intended to be called in the main thread at the beginning of the process execution.

#### Parameters

version | is a (gnutls) version number |
enabled | whether to enable the protocol |

#### Returns

0 on success or negative error code otherwise.

Since: 3.7.3

### gnutls_error_is_fatal ()

    int
    gnutls_error_is_fatal ();

If a GnuTLS function returns a negative error code you may feed that value to this function to see if the error condition is fatal to a TLS session (i.e., must be terminated).

Note that you may also want to check the error code manually, since some non-fatal errors to the protocol (such as a warning alert or a rehandshake request) may be fatal for your program.

This function is only useful if you are dealing with errors from functions that relate to a TLS session (e.g., record layer or handshake layer handling functions).

#### Parameters

error | is a GnuTLS error code, a negative error code |

#### Returns

Non-zero value on fatal errors or zero on non-fatal.

### gnutls_perror ()

    void
    gnutls_perror (int error);

This function is like `perror()`. The only difference is that it accepts an error number returned by a gnutls function.

#### Parameters

error | is a GnuTLS error code, a negative error code |

### gnutls_strerror ()

    return
    gnutls_strerror (retcode Param1);

This function is similar to strerror. The difference is that it accepts an error number returned by a gnutls function; In case of an unknown error a descriptive string is sent instead of `NULL`.

Error codes are always a negative error code.

#### Parameters

error | is a GnuTLS error code, a negative error code |

#### Returns

A string explaining the GnuTLS error message.

### gnutls_handshake_set_random ()

    int
    gnutls_handshake_set_random (gnutls_session_t session,
                                 const gnutls_datum_t *random);

This function will explicitly set the server or client hello random value in the subsequent TLS handshake. The random value should be a 32-byte value.

Note that this function should not normally be used as gnutls will select automatically a random value for the handshake.

This function should not be used when resuming a session.

#### Parameters

session | is a gnutls_session_t type. |
random | a random value of 32-bytes |

#### Returns

`GNUTLS_E_SUCCESS` on success, or an error code.

Since 3.1.9

### gnutls_handshake_get_last_out ()

    return
    gnutls_handshake_get_last_out (s Param1);

This function is only useful to check where the last performed handshake failed. If the previous handshake succeed or was not performed at all then no meaningful value will be returned.

Check `gnutls_handshake_description_t` in gnutls.h for the available handshake descriptions.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

the last handshake message type sent, a `gnutls_handshake_description_t`.

### gnutls_handshake_get_last_in ()

    return
    gnutls_handshake_get_last_in (s Param1);

This function is only useful to check where the last performed handshake failed. If the previous handshake succeed or was not performed at all then no meaningful value will be returned.

Check `gnutls_handshake_description_t` in gnutls.h for the available handshake descriptions.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

the last handshake message type received, a `gnutls_handshake_description_t`.

### gnutls_heartbeat_ping ()

    int
    gnutls_heartbeat_ping (gnutls_session_t session,
                           size_t data_size,
                           unsigned int max_tries,
                           unsigned int flags);

This function sends a ping to the peer. If the `flags` is set to `GNUTLS_HEARTBEAT_WAIT` then it waits for a reply from the peer.

Note that it is highly recommended to use this function with the flag `GNUTLS_HEARTBEAT_WAIT`, or you need to handle retransmissions and timeouts manually.

The total TLS data transmitted as part of the ping message are given by the following formula: MAX(16, `data_size` )+`gnutls_record_overhead_size()`+3.

#### Parameters

session | is a gnutls_session_t type. |
data_size | is the length of the ping payload. |
max_tries | if flags is `GNUTLS_HEARTBEAT_WAIT` then this sets the number of retransmissions. Use zero for indefinite (until timeout). |
flags | if `GNUTLS_HEARTBEAT_WAIT` then wait for pong or timeout instead of returning immediately. |

#### Returns

`GNUTLS_E_SUCCESS` on success, otherwise a negative error code.

Since: 3.1.2

### gnutls_heartbeat_pong ()

    int
    gnutls_heartbeat_pong (gnutls_session_t session,
                           unsigned int flags);

This function replies to a ping by sending a pong to the peer.

#### Parameters

session | is a gnutls_session_t type. |
flags | should be zero |

#### Returns

`GNUTLS_E_SUCCESS` on success, otherwise a negative error code.

Since: 3.1.2

### gnutls_record_set_timeout ()

    void
    gnutls_record_set_timeout (gnutls_session_t session,
                               unsigned int ms);

This function sets the receive timeout for the record layer to the provided value. Use an `ms` value of zero to disable timeout (the default), or `GNUTLS_INDEFINITE_TIMEOUT`, to set an indefinite timeout.

This function requires to set a pull timeout callback. See `gnutls_transport_set_pull_timeout_function()`.

#### Parameters

session | is a gnutls_session_t type. |
ms | is a timeout value in milliseconds |

Since: 3.1.7

### gnutls_record_disable_padding ()

    void
    gnutls_record_disable_padding (gnutls_session_t session);

Used to disabled padding in TLS 1.0 and above. Normally you do not need to use this function, but there are buggy clients that complain if a server pads the encrypted data. This of course will disable protection against statistical attacks on the data.

This function is defunct since 3.1.7. Random padding is disabled by default unless requested using `gnutls_record_send_range()`.

#### Parameters

session | is a gnutls_session_t type. |

### gnutls_record_cork ()

    void
    gnutls_record_cork (gnutls_session_t session);

If called, `gnutls_record_send()` will no longer send any records. Any sent records will be cached until `gnutls_record_uncork()` is called.

This function is safe to use with DTLS after GnuTLS 3.3.0.

#### Parameters

session | is a gnutls_session_t type. |

Since: 3.1.9

### gnutls_record_uncork ()

    int
    gnutls_record_uncork (gnutls_session_t session,
                          unsigned int flags);

This resets the effect of `gnutls_record_cork()`, and flushes any pending data. If the `GNUTLS_RECORD_WAIT` flag is specified then this function will block until the data is sent or a fatal error occurs (i.e., the function will retry on `GNUTLS_E_AGAIN` and `GNUTLS_E_INTERRUPTED`).

If the flag `GNUTLS_RECORD_WAIT` is not specified and the function is interrupted then the `GNUTLS_E_AGAIN` or `GNUTLS_E_INTERRUPTED` errors will be returned. To obtain the data left in the corked buffer use `gnutls_record_check_corked()`.

#### Parameters

session | is a gnutls_session_t type. |
flags | Could be zero or `GNUTLS_RECORD_WAIT` |

#### Returns

On success the number of transmitted data is returned, or otherwise a negative error code.

Since: 3.1.9

### gnutls_record_discard_queued ()

    size_t
    gnutls_record_discard_queued (gnutls_session_t session);

This function discards all queued to be sent packets in a DTLS session. These are the packets queued after an interrupted `gnutls_record_send()`.

This function can only be used with transports where `send()` is an all-or-nothing operation (e.g., UDP). When partial writes are allowed this function will cause session errors.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

The number of bytes discarded.

Since: 3.4.0

### gnutls_record_get_state ()

    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]);

This function will return the parameters of the current record state. These are only useful to be provided to an external off-loading device or subsystem. The returned values should be considered constant and valid for the lifetime of the session.

In that case, to sync the state back you must call `gnutls_record_set_state()`.

#### Parameters

session | is a gnutls_session_t type |
read | if non-zero the read parameters are returned, otherwise the write |
mac_key | the key used for MAC (if a MAC is used) |
IV | the initialization vector or nonce used |
cipher_key | the cipher key |
seq_number | A 64-bit sequence number |

#### Returns

`GNUTLS_E_SUCCESS` on success, or an error code.

Since 3.4.0

### gnutls_record_set_state ()

    int
    gnutls_record_set_state (gnutls_session_t session,
                             unsigned  read,
                             const unsigned char seq_number[8]);

This function will set the sequence number in the current record state. This function is useful if sending and receiving are offloaded from gnutls. That is, if `gnutls_record_get_state()` was used.

#### Parameters

session | is a gnutls_session_t type |
read | if non-zero the read parameters are returned, otherwise the write |
seq_number | A 64-bit sequence number |

#### Returns

`GNUTLS_E_SUCCESS` on success, or an error code.

Since 3.4.0

### gnutls_range_split ()

    int
    gnutls_range_split (gnutls_session_t session,
                        const gnutls_range_st *orig,
                        gnutls_range_st *small_range,
                        gnutls_range_st *rem_range);

This function should be used when it is required to hide the length of very long data that cannot be directly provided to `gnutls_record_send_range()`. In that case this function should be called with the desired length hiding range in `orig` . The returned `next` value should then be used in the next call to `gnutls_record_send_range()` with the partial data. That process should be repeated until `remainder` is (0,0).

#### Parameters

session | is a gnutls_session_t type |
orig | is the original range provided by the user |
next | is the returned range that can be conveyed in a TLS record |
remainder | is the returned remaining range |

#### Returns

0 in case splitting succeeds, non zero in case of error. Note that `orig` is not changed, while the values of `next` and `remainder` are modified to store the resulting values.

### gnutls_record_send ()

    ssize_t
    gnutls_record_send (gnutls_session_t session,
                        const void *data,
                        size_t data_size);

This function has the similar semantics with `send()`. The only difference is that it accepts a GnuTLS session, and uses different error codes. Note that if the send buffer is full, `send()` will block this function. See the `send()` documentation for more information.

You can replace the default push function which is `send()`, by using `gnutls_transport_set_push_function()`.

If the EINTR is returned by the internal push function then `GNUTLS_E_INTERRUPTED` will be returned. If `GNUTLS_E_INTERRUPTED` or `GNUTLS_E_AGAIN` is returned, you must call this function again with the exact same parameters, or provide a `NULL` pointer for `data` and 0 for `data_size` , in order to write the same data as before. If you wish to discard the previous data instead of retrying, you must call `gnutls_record_discard_queued()` before calling this function with different parameters. Note that the latter works only on special transports (e.g., UDP). cf. `gnutls_record_get_direction()`.

Note that in DTLS this function will return the `GNUTLS_E_LARGE_PACKET` error code if the send data exceed the data MTU value - as returned by `gnutls_dtls_get_data_mtu()`. The errno value EMSGSIZE also maps to `GNUTLS_E_LARGE_PACKET`. Note that since 3.2.13 this function can be called under cork in DTLS mode, and will refuse to send data over the MTU size by returning `GNUTLS_E_LARGE_PACKET`.

#### Parameters

session | is a gnutls_session_t type. |
data | contains the data to send |
data_size | is the length of the data |

#### Returns

The number of bytes sent, or a negative error code. The number of bytes sent might be less than `data_size` . The maximum number of bytes this function can send in a single call depends on the negotiated maximum record size.

### gnutls_record_send2 ()

    ssize_t
    gnutls_record_send2 (gnutls_session_t session,
                         const void *data,
                         size_t data_size,
                         size_t pad,
                         unsigned  flags);

This function is identical to `gnutls_record_send()` except that it takes an extra argument to specify padding to be added the record. To determine the maximum size of padding, use `gnutls_record_get_max_size()` and `gnutls_record_overhead_size()`.

Note that in order for GnuTLS to provide constant time processing of padding and data in TLS1.3, the flag `GNUTLS_SAFE_PADDING_CHECK` must be used in `gnutls_init()`.

#### Parameters

session | is a gnutls_session_t type. |
data | contains the data to send |
data_size | is the length of the data |
pad | padding to be added to the record |
flags | must be zero |

#### Returns

The number of bytes sent, or a negative error code. The number of bytes sent might be less than `data_size` . The maximum number of bytes this function can send in a single call depends on the negotiated maximum record size.

Since: 3.6.3

### gnutls_record_send_range ()

    ssize_t
    gnutls_record_send_range (gnutls_session_t session,
                              const void *data,
                              size_t data_size,
                              const gnutls_range_st *range);

This function operates like `gnutls_record_send()` but, while `gnutls_record_send()` adds minimal padding to each TLS record, this function uses the TLS extra-padding feature to conceal the real data size within the range of lengths provided. Some TLS sessions do not support extra padding (e.g. stream ciphers in standard TLS or SSL3 sessions). To know whether the current session supports extra padding, and hence length hiding, use the `gnutls_record_can_use_length_hiding()` function.

Note: This function currently is limited to blocking sockets.

#### Parameters

session | is a gnutls_session_t type. |
data | contains the data to send. |
data_size | is the length of the data. |
range | is the range of lengths in which the real data length must be hidden. |

#### Returns

The number of bytes sent (that is data_size in a successful invocation), or a negative error code.

### gnutls_record_send_file ()

    ssize_t
    gnutls_record_send_file (gnutls_session_t session,
                             int fd,
                             off_t *offset,
                             size_t count);

This function sends data from `fd` . If KTLS (kernel TLS) is enabled, it will use the `sendfile()` system call to avoid overhead of copying data between user space and the kernel. Otherwise, this functionality is merely emulated by calling `read()` and `gnutls_record_send()`. If this implementation is suboptimal, check whether KTLS is enabled using `gnutls_transport_is_ktls_enabled()`.

If `offset` is NULL then file offset is incremented by number of bytes send, otherwise file offset remains unchanged.

#### Parameters

session | is a gnutls_session_t type. |
fd | file descriptor from which to read data. |
offset | Is relative to file offset, denotes the starting location for reading. after function returns, it point to position following last read byte. |
count | is the length of the data in bytes to be read from file and send. |

#### Returns

The number of bytes sent, or a negative error code.

### gnutls_record_recv ()

    ssize_t
    gnutls_record_recv (gnutls_session_t session,
                        void *data,
                        size_t data_size);

This function has the similar semantics with `recv()`. The only difference is that it accepts a GnuTLS session, and uses different error codes. In the special case that the peer requests a renegotiation, the caller will receive an error code of `GNUTLS_E_REHANDSHAKE`. In case of a client, this message may be simply ignored, replied with an alert `GNUTLS_A_NO_RENEGOTIATION`, or replied with a new handshake, depending on the client's will. A server receiving this error code can only initiate a new handshake or terminate the session.

If `EINTR` is returned by the internal pull function (the default is `recv()`) then `GNUTLS_E_INTERRUPTED` will be returned. If `GNUTLS_E_INTERRUPTED` or `GNUTLS_E_AGAIN` is returned, you must call this function again to get the data. See also `gnutls_record_get_direction()`.

#### Parameters

session | is a gnutls_session_t type. |
data | the buffer that the data will be read into |
data_size | the number of requested bytes |

#### Returns

The number of bytes received and zero on EOF (for stream connections). A negative error code is returned in case of an error. The number of bytes received might be less than the requested `data_size` .

### gnutls_record_recv_packet ()

    ssize_t
    gnutls_record_recv_packet (gnutls_session_t session,
                               gnutls_packet_t *packet);

This is a lower-level function than `gnutls_record_recv()` and allows to directly receive the whole decrypted packet. That avoids a memory copy, and is intended to be used by applications seeking high performance.

The received packet is accessed using `gnutls_packet_get()` and must be deinitialized using `gnutls_packet_deinit()`. The returned packet will be `NULL` if the return value is zero (EOF).

#### Parameters

session | is a gnutls_session_t type. |
packet | the structure that will hold the packet data |

#### Returns

The number of bytes received and zero on EOF (for stream connections). A negative error code is returned in case of an error.

Since: 3.3.5

### gnutls_packet_get ()

    void
    gnutls_packet_get (gnutls_packet_t packet,
                       gnutls_datum_t *data,
                       unsigned char *sequence);

This function returns the data and sequence number associated with the received packet.

#### Parameters

packet | is a gnutls_packet_t type. |
data | will contain the data present in the `packet` structure (may be `NULL`) |
sequence | the 8-bytes of the packet sequence number (may be `NULL`) |

Since: 3.3.5

### gnutls_packet_deinit ()

    void
    gnutls_packet_deinit (gnutls_packet_t packet);

This function will deinitialize all data associated with the received packet.

#### Parameters

packet | is a pointer to a gnutls_packet_st structure. |

Since: 3.3.5

### gnutls_record_recv_seq ()

    ssize_t
    gnutls_record_recv_seq (gnutls_session_t session,
                            void *data,
                            size_t data_size,
                            unsigned char *seq);

This function is the same as `gnutls_record_recv()`, except that it returns in addition to data, the sequence number of the data. This is useful in DTLS where record packets might be received out-of-order. The returned 8-byte sequence number is an integer in big-endian format and should be treated as a unique message identification.

#### Parameters

session | is a gnutls_session_t type. |
data | the buffer that the data will be read into |
data_size | the number of requested bytes |
seq | is the packet's 64-bit sequence number. Should have space for 8 bytes. |

#### Returns

The number of bytes received and zero on EOF. A negative error code is returned in case of an error. The number of bytes received might be less than `data_size` .

Since: 3.0

### gnutls_record_overhead_size ()

    size_t
    gnutls_record_overhead_size (gnutls_session_t session);

This function will return the size in bytes of the overhead due to TLS (or DTLS) per record. On certain occasions (e.g., CBC ciphers) the returned value is the maximum possible overhead.

#### Parameters

session | is gnutls_session_t |

Since: 3.2.2

### gnutls_est_record_overhead_size ()

    size_t
    gnutls_est_record_overhead_size (gnutls_protocol_t version,
                                     gnutls_cipher_algorithm_t cipher,
                                     gnutls_mac_algorithm_t mac,
                                     gnutls_compression_method_t comp);

This function will return the set size in bytes of the overhead due to TLS (or DTLS) per record.

Note that this function may provide inaccurate values when TLS extensions that modify the record format are negotiated. In these cases a more accurate value can be obtained using `gnutls_record_overhead_size()` after a completed handshake.

#### Parameters

version | is a gnutls_protocol_t value |
cipher | is a gnutls_cipher_algorithm_t value |
mac | is a gnutls_mac_algorithm_t value |
comp | is a gnutls_compression_method_t value (ignored) |
flags | must be zero |

Since: 3.2.2

### gnutls_record_set_max_empty_records()

    #define gnutls_record_set_max_empty_records(session, x)

### gnutls_record_can_use_length_hiding ()

    unsigned
    gnutls_record_can_use_length_hiding (gnutls_session_t session);

If the session supports length-hiding padding, you can invoke `gnutls_record_send_range()` to send a message whose length is hidden in the given range. If the session does not support length hiding padding, you can use the standard `gnutls_record_send()` function, or `gnutls_record_send_range()` making sure that the range is the same as the length of the message you are trying to send.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

true (1) if the current session supports length-hiding padding, false (0) if the current session does not.

### gnutls_record_get_direction ()

    return
    gnutls_record_get_direction (s Param1);

This function is useful to determine whether a GnuTLS function was interrupted while sending or receiving, so that `select()` or `poll()` may be called appropriately.

It provides information about the internals of the record protocol and is only useful if a prior gnutls function call, e.g. `gnutls_handshake()`, was interrupted and returned `GNUTLS_E_INTERRUPTED` or `GNUTLS_E_AGAIN`. After such an interrupt applications may call `select()` or `poll()` before restoring the interrupted GnuTLS function.

This function's output is unreliable if you are using the same `session` in different threads for sending and receiving.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

0 if interrupted while trying to read data, or 1 while trying to write data.

### gnutls_record_get_max_size ()

    return
    gnutls_record_get_max_size (s Param1);

Get the record size. The maximum record size is negotiated by the client after the first handshake message.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

The maximum record packet size in this connection.

### gnutls_record_set_max_size ()

    ssize_t
    gnutls_record_set_max_size (gnutls_session_t session,
                                size_t size);

`gnutls_record_set_max_size` is deprecated and should not be used in newly-written code.

if the client can assume that the 'record size limit' extension is supported by the server, we recommend using `gnutls_record_set_max_recv_size()` instead.

This function sets the maximum amount of plaintext sent and received in a record in this connection.

Prior to 3.6.4, this function was implemented using a TLS extension called 'max fragment length', which limits the acceptable values to 512(=2^9), 1024(=2^10), 2048(=2^11) and 4096(=2^12).

Since 3.6.4, the limit is also negotiated through a new TLS extension called 'record size limit', which doesn't have the limitation, as long as the value ranges between 512 and 16384. Note that while the 'record size limit' extension is preferred, not all TLS implementations use or even understand the extension.

#### Parameters

session | is a gnutls_session_t type. |
size | is the new size |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

### gnutls_record_set_max_recv_size ()

    ssize_t
    gnutls_record_set_max_recv_size (gnutls_session_t session,
                                     size_t size);

This function sets the maximum amount of plaintext received in a record in this connection.

The limit is also negotiated through a TLS extension called 'record size limit'. Note that while the 'record size limit' extension is preferred, not all TLS implementations use or even understand the extension.

#### Parameters

session | is a gnutls_session_t type. |
size | is the new size |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

Since: 3.6.8

### gnutls_record_check_pending ()

    return
    gnutls_record_check_pending (s Param1);

This function checks if there are unread data in the gnutls buffers. If the return value is non-zero the next call to `gnutls_record_recv()` is guaranteed not to block.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

Returns the size of the data or zero.

### gnutls_record_check_corked ()

    size_t
    gnutls_record_check_corked (gnutls_session_t session);

This function checks if there pending corked data in the gnutls buffers --see `gnutls_record_cork()`.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

Returns the size of the corked data or zero.

Since: 3.2.8

### gnutls_record_get_max_early_data_size ()

    size_t
    gnutls_record_get_max_early_data_size (gnutls_session_t session);

This function returns the maximum early data size in this connection. This property can only be set to servers. The client may be provided with the maximum allowed size through the "early_data" extension of the NewSessionTicket handshake message.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

The maximum early data size in this connection.

Since: 3.6.5

### gnutls_record_set_max_early_data_size ()

    int
    gnutls_record_set_max_early_data_size (gnutls_session_t session,
                                           size_t size);

This function sets the maximum early data size in this connection. This property can only be set to servers. The client may be provided with the maximum allowed size through the "early_data" extension of the NewSessionTicket handshake message.

#### Parameters

session | is a gnutls_session_t type. |
size | is the new size |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

Since: 3.6.4

### gnutls_record_send_early_data ()

    ssize_t
    gnutls_record_send_early_data (gnutls_session_t session,
                                   const void *data,
                                   size_t length);

This function can be used by a client to send data early in the handshake processes when resuming a session. This is used to implement a zero-roundtrip (0-RTT) mode. It has the same semantics as `gnutls_record_send()`.

There may be a limit to the amount of data sent as early data. Use `gnutls_record_get_max_early_data_size()` to check the limit. If the limit exceeds, this function returns `GNUTLS_E_RECORD_LIMIT_REACHED`.

#### Parameters

session | is a gnutls_session_t type. |
data | contains the data to send |
data_size | is the length of the data |

#### Returns

The number of bytes sent, or a negative error code. The number of bytes sent might be less than `data_size` . The maximum number of bytes this function can send in a single call depends on the negotiated maximum record size.

Since: 3.6.5

### gnutls_record_recv_early_data ()

    ssize_t
    gnutls_record_recv_early_data (gnutls_session_t session,
                                   void *data,
                                   size_t data_size);

This function can be used by a server to retrieve data sent early in the handshake processes when resuming a session. This is used to implement a zero-roundtrip (0-RTT) mode. It has the same semantics as `gnutls_record_recv()`.

This function can be called either in a handshake hook, or after the handshake is complete.

#### Parameters

session | is a gnutls_session_t type. |
data | the buffer that the data will be read into |
data_size | the number of requested bytes |

#### Returns

The number of bytes received and zero when early data reading is complete. A negative error code is returned in case of an error. If no early data is received during the handshake, this function returns `GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE`. The number of bytes received might be less than the requested `data_size` .

Since: 3.6.5

### gnutls_record_get_max_send_size ()

    size_t
    gnutls_record_get_max_send_size (gnutls_session_t session);

Get the maximum plaintext send size. This maybe negotiated, or user specified.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

The maximum plaintext send size.

Since: 3.8.11

### gnutls_session_force_valid ()

    void
    gnutls_session_force_valid (gnutls_session_t session);

Clears the invalid flag in a session. That means that sessions were corrupt or invalid data were received can be re-used. Use only when debugging or experimenting with the TLS protocol. Should not be used in typical applications.

#### Parameters

session | is a gnutls_session_t type. |

### gnutls_prf ()

    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);

Applies the TLS Pseudo-Random-Function (PRF) on the master secret and the provided data, seeded with the client and server random fields. For the key expansion specified in RFC5705 see `gnutls_prf_rfc5705()`.

The `label` variable usually contains a string denoting the purpose for the generated data. The `server_random_first` indicates whether the client random field or the server random field should be first in the seed. Non-zero indicates that the server random field is first, 0 that the client random field is first.

The `extra` variable can be used to add more data to the seed, after the random variables. It can be used to make sure the generated output is strongly connected to some additional data (e.g., a string used in user authentication).

The output is placed in `out` , which must be pre-allocated.

Note: This function produces identical output with `gnutls_prf_rfc5705()` when `server_random_first` is set to 0 and `extra` is `NULL`. Under TLS1.3 this function will only operate when these conditions are true, or otherwise return `GNUTLS_E_INVALID_REQUEST`.

#### Parameters

session | is a gnutls_session_t type. |
label_size | length of the `label` variable. |
label | label used in PRF computation, typically a short string. |
server_random_first | non-zero if server random field should be first in seed |
extra_size | length of the `extra` variable. |
extra | optional extra data to seed the PRF with. |
outsize | size of pre-allocated output buffer to hold the output. |
out | pre-allocated buffer to hold the generated data. |

#### Returns

`GNUTLS_E_SUCCESS` on success, or an error code.

### gnutls_prf_rfc5705 ()

    int
    gnutls_prf_rfc5705 (gnutls_session_t session,
                        size_t label_size,
                        const char *label,
                        size_t context_size,
                        const char *context,
                        size_t outsize,
                        char *out);

Exports keying material from TLS/DTLS session to an application, as specified in RFC5705.

In the TLS versions prior to 1.3, it applies the TLS Pseudo-Random-Function (PRF) on the master secret and the provided data, seeded with the client and server random fields.

In TLS 1.3, it applies HKDF on the exporter master secret derived from the master secret.

The `label` variable usually contains a string denoting the purpose for the generated data.

The `context` variable can be used to add more data to the seed, after the random variables. It can be used to make sure the generated output is strongly connected to some additional data (e.g., a string used in user authentication).

The output is placed in `out` , which must be pre-allocated.

Note that, to provide the RFC5705 context, the `context` variable must be non-null.

#### Parameters

session | is a gnutls_session_t type. |
label_size | length of the `label` variable. |
label | label used in PRF computation, typically a short string. |
context_size | length of the `extra` variable. |
context | optional extra data to seed the PRF with. |
outsize | size of pre-allocated output buffer to hold the output. |
out | pre-allocated buffer to hold the generated data. |

#### Returns

`GNUTLS_E_SUCCESS` on success, or an error code.

Since: 3.4.4

### gnutls_prf_early ()

    int
    gnutls_prf_early (gnutls_session_t session,
                      size_t label_size,
                      const char *label,
                      size_t context_size,
                      const char *context,
                      size_t outsize,
                      char *out);

This function is similar to `gnutls_prf_rfc5705()`, but only works in TLS 1.3 or later to export early keying material.

Note that the keying material is only available after the ClientHello message is processed and before the application traffic keys are established. Therefore this function shall be called in a handshake hook function for `GNUTLS_HANDSHAKE_CLIENT_HELLO`.

The `label` variable usually contains a string denoting the purpose for the generated data.

The `context` variable can be used to add more data to the seed, after the random variables. It can be used to make sure the generated output is strongly connected to some additional data (e.g., a string used in user authentication).

The output is placed in `out` , which must be pre-allocated.

Note that, to provide the RFC5705 context, the `context` variable must be non-null.

#### Parameters

session | is a gnutls_session_t type. |
label_size | length of the `label` variable. |
label | label used in PRF computation, typically a short string. |
context_size | length of the `extra` variable. |
context | optional extra data to seed the PRF with. |
outsize | size of pre-allocated output buffer to hold the output. |
out | pre-allocated buffer to hold the generated data. |

#### Returns

`GNUTLS_E_SUCCESS` on success, or an error code.

Since: 3.6.8

### gnutls_prf_raw ()

    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);

Apply the TLS Pseudo-Random-Function (PRF) on the master secret and the provided data.

The `label` variable usually contains a string denoting the purpose for the generated data. The `seed` usually contains data such as the client and server random, perhaps together with some additional data that is added to guarantee uniqueness of the output for a particular purpose.

Because the output is not guaranteed to be unique for a particular session unless `seed` includes the client random and server random fields (the PRF would output the same data on another connection resumed from the first one), it is not recommended to use this function directly. The `gnutls_prf()` function seeds the PRF with the client and server random fields directly, and is recommended if you want to generate pseudo random data unique for each session.

Note: This function will only operate under TLS versions prior to 1.3. In TLS1.3 the use of PRF is replaced with HKDF and the generic exporters like `gnutls_prf_rfc5705()` should be used instead. Under TLS1.3 this function returns `GNUTLS_E_INVALID_REQUEST`.

#### Parameters

session | is a gnutls_session_t type. |
label_size | length of the `label` variable. |
label | label used in PRF computation, typically a short string. |
seed_size | length of the `seed` variable. |
seed | optional extra data to seed the PRF with. |
outsize | size of pre-allocated output buffer to hold the output. |
out | pre-allocated buffer to hold the generated data. |

#### Returns

`GNUTLS_E_SUCCESS` on success, or an error code.

### gnutls_server_name_set ()

    int
    gnutls_server_name_set (gnutls_session_t session,
                            gnutls_server_name_type_t type,
                            const void *name,
                            size_t name_length);

This function is to be used by clients that want to inform (via a TLS extension mechanism) the server of the name they connected to. This should be used by clients that connect to servers that do virtual hosting.

The value of `name` depends on the `type` type. In case of `GNUTLS_NAME_DNS`, a UTF-8 null-terminated domain name string, without the trailing dot, is expected.

IPv4 or IPv6 addresses are not permitted to be set by this function. If the function is called with a name of `name_length` zero it will clear all server names set.

#### Parameters

session | is a gnutls_session_t type. |
type | specifies the indicator type |
name | is a string that contains the server name. |
name_length | holds the length of name excluding the terminating null byte |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

### gnutls_server_name_get ()

    int
    gnutls_server_name_get (gnutls_session_t session,
                            void *data,
                            size_t *data_length,
                            unsigned int *type,
                            unsigned int indx);

This function will allow you to get the name indication (if any), a client has sent. The name indication may be any of the enumeration gnutls_server_name_type_t.

If `type` is GNUTLS_NAME_DNS, then this function is to be used by servers that support virtual hosting, and the data will be a null terminated IDNA ACE string (prior to GnuTLS 3.4.0 it was a UTF-8 string).

If `data` has not enough size to hold the server name GNUTLS_E_SHORT_MEMORY_BUFFER is returned, and `data_length` will hold the required size.

`indx` is used to retrieve more than one server names (if sent by the client). The first server name has an index of 0, the second 1 and so on. If no name with the given index exists GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE is returned.

#### Parameters

session | is a gnutls_session_t type. |
data | will hold the data |
data_length | will hold the data length. Must hold the maximum size of data. |
type | will hold the server name indicator type |
indx | is the index of the server_name |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, on UTF-8 decoding error `GNUTLS_E_IDNA_ERROR` is returned, otherwise a negative error code is returned.

### gnutls_heartbeat_get_timeout ()

    unsigned int
    gnutls_heartbeat_get_timeout (gnutls_session_t session);

This function will return the milliseconds remaining for a retransmission of the previously sent ping message. This function is useful when ping is used in non-blocking mode, to estimate when to call `gnutls_heartbeat_ping()` if no packets have been received.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

the remaining time in milliseconds.

Since: 3.1.2

### gnutls_heartbeat_set_timeouts ()

    void
    gnutls_heartbeat_set_timeouts (gnutls_session_t session,
                                   unsigned int retrans_timeout,
                                   unsigned int total_timeout);

This function will override the timeouts for the DTLS heartbeat protocol. The retransmission timeout is the time after which a message from the peer is not received, the previous request will be retransmitted. The total timeout is the time after which the handshake will be aborted with `GNUTLS_E_TIMEDOUT`.

#### Parameters

session | is a gnutls_session_t type. |
retrans_timeout | The time at which a retransmission will occur in milliseconds |
total_timeout | The time at which the connection will be aborted, in milliseconds. |

Since: 3.1.2

### gnutls_heartbeat_enable ()

    void
    gnutls_heartbeat_enable (gnutls_session_t session,
                             unsigned int type);

If this function is called with the `GNUTLS_HB_PEER_ALLOWED_TO_SEND` `type` , GnuTLS will allow heartbeat messages to be received. Moreover it also request the peer to accept heartbeat messages. This function must be called prior to TLS handshake.

If the `type` used is `GNUTLS_HB_LOCAL_ALLOWED_TO_SEND`, then the peer will be asked to accept heartbeat messages but not send ones.

The function `gnutls_heartbeat_allowed()` can be used to test Whether locally generated heartbeat messages can be accepted by the peer.

#### Parameters

session | is a gnutls_session_t type. |
type | one of the GNUTLS_HB_* flags |

Since: 3.1.2

### gnutls_heartbeat_allowed ()

    unsigned
    gnutls_heartbeat_allowed (gnutls_session_t session,
                              unsigned int type);

This function will check whether heartbeats are allowed to be sent or received in this session.

#### Parameters

session | is a gnutls_session_t type. |
type | one of `GNUTLS_HB_LOCAL_ALLOWED_TO_SEND` and `GNUTLS_HB_PEER_ALLOWED_TO_SEND` |

#### Returns

Non zero if heartbeats are allowed.

Since: 3.1.2

### gnutls_safe_renegotiation_status ()

    unsigned
    gnutls_safe_renegotiation_status (gnutls_session_t session);

Can be used to check whether safe renegotiation is being used in the current session.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

0 when safe renegotiation is not used and non (0) when safe renegotiation is used.

Since: 2.10.0

### gnutls_session_ext_master_secret_status ()

    unsigned
    gnutls_session_ext_master_secret_status
                                   (gnutls_session_t session);

Get the status of the extended master secret extension negotiation. This is in accordance to RFC7627. That information is also available to the more generic `gnutls_session_get_flags()`.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

Non-zero if the negotiation was successful or zero otherwise.

### gnutls_session_etm_status ()

    unsigned
    gnutls_session_etm_status (gnutls_session_t session);

Get the status of the encrypt-then-mac extension negotiation. This is in accordance to rfc7366

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

Non-zero if the negotiation was successful or zero otherwise.

### gnutls_session_get_flags ()

    unsigned
    gnutls_session_get_flags (gnutls_session_t session);

This function will return a series (ORed) of flags, applicable for the current session.

This replaces individual informational functions such as `gnutls_safe_renegotiation_status()`, `gnutls_session_ext_master_secret_status()`, etc.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

An ORed sequence of flags (see `gnutls_session_flags_t`)

Since: 3.5.0

### gnutls_supplemental_get_name ()

    const char *
    gnutls_supplemental_get_name (gnutls_supplemental_data_format_type_t type);

Convert a gnutls_supplemental_data_format_type_t value to a string.

#### Parameters

type | is a supplemental data format type |

#### Returns

a string that contains the name of the specified supplemental data format type, or `NULL` for unknown types.

### gnutls_session_ticket_key_generate ()

    int
    gnutls_session_ticket_key_generate (gnutls_datum_t *key);

Generate a random key to encrypt security parameters within SessionTicket.

#### Parameters

key | is a pointer to a gnutls_datum_t which will contain a newly created key. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, or an error code.

Since: 2.10.0

### gnutls_session_ticket_enable_client ()

    int
    gnutls_session_ticket_enable_client (gnutls_session_t session);

Request that the client should attempt session resumption using SessionTicket. This call is typically unnecessary as session tickets are enabled by default.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, or an error code.

Since: 2.10.0

### gnutls_session_ticket_enable_server ()

    int
    gnutls_session_ticket_enable_server (gnutls_session_t session,
                                         const gnutls_datum_t *key);

Request that the server should attempt session resumption using session tickets, i.e., by delegating storage to the client. `key` must be initialized using `gnutls_session_ticket_key_generate()`. To avoid leaking that key, use `gnutls_memset()` prior to releasing it.

The default ticket expiration time can be overridden using `gnutls_db_set_cache_expiration()`.

#### Parameters

session | is a gnutls_session_t type. |
key | key to encrypt session parameters. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, or an error code.

Since: 2.10.0

### gnutls_session_ticket_send ()

    int
    gnutls_session_ticket_send (gnutls_session_t session,
                                unsigned  nr,
                                unsigned  flags);

Sends a fresh session ticket to the peer. This is relevant only in server side under TLS1.3. This function may also return `GNUTLS_E_AGAIN` or `GNUTLS_E_INTERRUPTED` and in that case it must be called again.

#### Parameters

session | is a gnutls_session_t type. |
nr | the number of tickets to send |
flags | must be zero |

#### Returns

`GNUTLS_E_SUCCESS` on success, or a negative error code.

### gnutls_srtp_set_profile ()

    int
    gnutls_srtp_set_profile (gnutls_session_t session,
                             gnutls_srtp_profile_t profile);

This function is to be used by both clients and servers, to declare what SRTP profiles they support, to negotiate with the peer.

#### Parameters

session | is a gnutls_session_t type. |
profile | is the profile id to add. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

Since 3.1.4

### gnutls_srtp_set_profile_direct ()

    int
    gnutls_srtp_set_profile_direct (gnutls_session_t session,
                                    const char *profiles,
                                    const char **err_pos);

This function is to be used by both clients and servers, to declare what SRTP profiles they support, to negotiate with the peer.

#### Parameters

session | is a gnutls_session_t type. |
profiles | is a string that contains the supported SRTP profiles, separated by colons. |
err_pos | In case of an error this will have the position in the string the error occurred, may be NULL. |

#### Returns

On syntax error `GNUTLS_E_INVALID_REQUEST` is returned, `GNUTLS_E_SUCCESS` on success, or an error code.

Since 3.1.4

### gnutls_srtp_get_selected_profile ()

    int
    gnutls_srtp_get_selected_profile (gnutls_session_t session,
                                      gnutls_srtp_profile_t *profile);

This function allows you to get the negotiated SRTP profile.

#### Parameters

session | is a gnutls_session_t type. |
profile | will hold the profile |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

Since 3.1.4

### gnutls_srtp_get_profile_name ()

    const char *
    gnutls_srtp_get_profile_name (gnutls_srtp_profile_t profile);

This function allows you to get the corresponding name for a SRTP protection profile.

#### Parameters

profile | The profile to look up a string for |

#### Returns

On success, the name of a SRTP profile as a string, otherwise NULL.

Since 3.1.4

### gnutls_srtp_get_profile_id ()

    int
    gnutls_srtp_get_profile_id (const char *name,
                                gnutls_srtp_profile_t *profile);

This function allows you to look up a profile based on a string.

#### Parameters

name | The name of the profile to look up |
profile | Will hold the profile id |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

Since 3.1.4

### gnutls_srtp_get_keys ()

    int
    gnutls_srtp_get_keys (gnutls_session_t session,
                          void *key_material,
                          unsigned int key_material_size,
                          gnutls_datum_t *client_key,
                          gnutls_datum_t *client_salt,
                          gnutls_datum_t *server_key,
                          gnutls_datum_t *server_salt);

This is a helper function to generate the keying material for SRTP. It requires the space of the key material to be pre-allocated (should be at least 2x the maximum key size and salt size). The `client_key` , `client_salt` , `server_key` and `server_salt` are convenience datums that point inside the key material. They may be `NULL`.

#### Parameters

session | is a gnutls_session_t type. |
key_material | Space to hold the generated key material |
key_material_size | The maximum size of the key material |
client_key | The master client write key, pointing inside the key material |
server_key | The master server write key, pointing inside the key material |
client_salt | The master client write salt, pointing inside the key material |
server_salt | The master server write salt, pointing inside the key material |

#### Returns

On success the size of the key material is returned, otherwise, `GNUTLS_E_SHORT_MEMORY_BUFFER` if the buffer given is not sufficient, or a negative error code.

Since 3.1.4

### gnutls_srtp_set_mki ()

    int
    gnutls_srtp_set_mki (gnutls_session_t session,
                         const gnutls_datum_t *mki);

This function sets the Master Key Identifier, to be used by this session (if any).

#### Parameters

session | is a gnutls_session_t type. |
mki | holds the MKI |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

Since 3.1.4

### gnutls_srtp_get_mki ()

    int
    gnutls_srtp_get_mki (gnutls_session_t session,
                         gnutls_datum_t *mki);

This function exports the negotiated Master Key Identifier, received by the peer if any. The returned value in `mki` should be treated as constant and valid only during the session's lifetime.

#### Parameters

session | is a gnutls_session_t type. |
mki | will hold the MKI |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

Since 3.1.4

### gnutls_compress_certificate_get_selected_method ()

    gnutls_compression_method_t
    gnutls_compress_certificate_get_selected_method
                                   (gnutls_session_t session);

This function returns the certificate compression method that has been selected to compress the certificate before sending it to the peer. The selection is done based on the local list of supported compression methods and the peer's requested compression methods.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

selected certificate compression method.

Since 3.7.4

### gnutls_compress_certificate_set_methods ()

    int
    gnutls_compress_certificate_set_methods
                                   (gnutls_session_t session,
                                    const gnutls_compression_method_t *methods,
                                    size_t methods_len);

This function sets the supported compression methods for certificate compression for the given session. The list of supported compression methods will be used for a) requesting the compression of peer's certificate and b) selecting the method to compress the local certificate before sending it to the peer. The order of compression methods inside the list does matter as the method that appears earlier in the list will be preferred before the later ones. Note that even if you set the list of supported compression methods, the compression might not be used if the peer does not support any of your chosen compression methods.

The list of supported compression methods must meet the following criteria: Argument `methods` must be an array of valid compression methods of type gnutls_compression_method_t. Argument `methods_len` must contain the number of compression methods stored in the `methods` array and must be within range <1, 127>. The length constraints are defined by `MIN_COMPRESS_CERTIFICATE_METHODS` and `MAX_COMPRESS_CERTIFICATE_METHODS` macros located in the header file compress_certificate.h.

If either `methods` or `methods_len` is equal to 0, current list of supported compression methods will be unset.

#### Parameters

session | is a gnutls_session_t type. |
methods | is a list of supported compression methods. |
methods_len | number of compression methods in `methods` |

#### Returns

`GNUTLS_E_SUCCESS` on success, otherwise a negative error code.

Since 3.7.4

### gnutls_alpn_get_selected_protocol ()

    int
    gnutls_alpn_get_selected_protocol (gnutls_session_t session,
                                       gnutls_datum_t *protocol);

This function allows you to get the negotiated protocol name. The returned protocol should be treated as opaque, constant value and only valid during the session life.

The selected protocol is the first supported by the list sent by the client.

#### Parameters

session | is a gnutls_session_t type. |
protocol | will hold the protocol name |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

Since 3.2.0

### gnutls_alpn_set_protocols ()

    int
    gnutls_alpn_set_protocols (gnutls_session_t session,
                               const gnutls_datum_t *protocols,
                               unsigned  protocols_size,
                               unsigned  flags);

This function is to be used by both clients and servers, to declare the supported ALPN protocols, which are used during negotiation with peer.

See `gnutls_alpn_flags_t` description for the documentation of available flags.

#### Parameters

session | is a gnutls_session_t type. |
protocols | is the protocol names to add. |
protocols_size | the number of protocols to add. |
flags | zero or a sequence of `gnutls_alpn_flags_t` |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

Since 3.2.0

### gnutls_key_generate ()

    int
    gnutls_key_generate (gnutls_datum_t *key,
                         unsigned int key_size);

Generates a random key of `key_size` bytes.

#### Parameters

key | is a pointer to a gnutls_datum_t which will contain a newly created key |
key_size | the number of bytes of the key |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, or an error code.

Since: 3.0

### gnutls_priority_init ()

    int
    gnutls_priority_init (gnutls_priority_t *priority_cache,
                          const char *priorities,
                          const char **err_pos);

For applications that do not modify their crypto settings per release, consider using `gnutls_priority_init2()` with `GNUTLS_PRIORITY_INIT_DEF_APPEND` flag instead. We suggest to use centralized crypto settings handled by the GnuTLS library, and applications modifying the default settings to their needs.

This function is identical to `gnutls_priority_init2()` with zero flags.

A `NULL` `priorities` string indicates the default priorities to be used (this is available since GnuTLS 3.3.0).

#### Parameters

priority_cache | is a gnutls_priority_t type. |
priorities | is a string describing priorities (may be `NULL`) |
err_pos | In case of an error this will have the position in the string the error occurred |

#### Returns

On syntax error `GNUTLS_E_INVALID_REQUEST` is returned, `GNUTLS_E_SUCCESS` on success, or an error code.

### gnutls_priority_init2 ()

    int
    gnutls_priority_init2 (gnutls_priority_t *priority_cache,
                           const char *priorities,
                           const char **err_pos,
                           unsigned  flags);

Sets priorities for the ciphers, key exchange methods, and macs. The `priority_cache` should be deinitialized using `gnutls_priority_deinit()`.

The priorities option allows you to specify a colon separated list of the cipher priorities to enable. Some keywords are defined to provide quick access to common preferences.

When `flags` is set to `GNUTLS_PRIORITY_INIT_DEF_APPEND` then the `priorities` specified will be appended to the default options.

Unless there is a special need, use the "NORMAL" keyword to apply a reasonable security level, or "NORMAL:%`COMPAT`" for compatibility.

"PERFORMANCE" means all the "secure" ciphersuites are enabled, limited to 128 bit ciphers and sorted by terms of speed performance.

"LEGACY" the NORMAL settings for GnuTLS 3.2.x or earlier. There is no verification profile set, and the allowed DH primes are considered weak today.

"NORMAL" means all "secure" ciphersuites. The 256-bit ciphers are included as a fallback only. The ciphers are sorted by security margin.

"PFS" means all "secure" ciphersuites that support perfect forward secrecy. The 256-bit ciphers are included as a fallback only. The ciphers are sorted by security margin.

"SECURE128" means all "secure" ciphersuites of security level 128-bit or more.

"SECURE192" means all "secure" ciphersuites of security level 192-bit or more.

"SUITEB128" means all the NSA SuiteB ciphersuites with security level of 128.

"SUITEB192" means all the NSA SuiteB ciphersuites with security level of 192.

"NONE" means nothing is enabled. This disables everything, including protocols.

"@`KEYWORD1` ,KEYWORD2,..." The system administrator imposed settings. The provided keyword(s) will be expanded from a configuration-time provided file - default is: /etc/gnutls/config. Any attributes that follow it, will be appended to the expanded string. If multiple keywords are provided, separated by commas, then the first keyword that exists in the configuration file will be used. At least one of the keywords must exist, or this function will return an error. Typical usage would be to specify an application specified keyword first, followed by "SYSTEM" as a default fallback. e.g., "`LIBVIRT` ,SYSTEM:!-VERS-SSL3.0" will first try to find a config file entry matching "LIBVIRT", but if that does not exist will use the entry for "SYSTEM". If "SYSTEM" does not exist either, an error will be returned. In all cases, the SSL3.0 protocol will be disabled. The system priority file entries should be formatted as "KEYWORD=VALUE", e.g., "SYSTEM=NORMAL:+ARCFOUR-128".

Special keywords are "!", "-" and "+". "!" or "-" appended with an algorithm will remove this algorithm. "+" appended with an algorithm will add this algorithm.

Check the GnuTLS manual section "Priority strings" for detailed information.

Examples:

"NONE:+VERS-TLS-ALL:+MAC-ALL:+RSA:+AES-128-CBC:+SIGN-ALL:+COMP-NULL"

"NORMAL:+ARCFOUR-128" means normal ciphers plus ARCFOUR-128.

"SECURE128:-VERS-SSL3.0" means that only secure ciphers are and enabled, SSL3.0 is disabled.

"NONE:+VERS-TLS-ALL:+AES-128-CBC:+RSA:+SHA1:+COMP-NULL:+SIGN-RSA-SHA1",

"NONE:+VERS-TLS-ALL:+AES-128-CBC:+ECDHE-RSA:+SHA1:+COMP-NULL:+SIGN-RSA-SHA1:+CURVE-SECP256R1",

"SECURE256:+SECURE128",

Note that "NORMAL:%`COMPAT`" is the most compatible mode.

A `NULL` `priorities` string indicates the default priorities to be used (this is available since GnuTLS 3.3.0).

#### Parameters

priority_cache | is a gnutls_priority_t type. |
priorities | is a string describing priorities (may be `NULL`) |
err_pos | In case of an error this will have the position in the string the error occurred |
flags | zero or `GNUTLS_PRIORITY_INIT_DEF_APPEND` |

#### Returns

On syntax error `GNUTLS_E_INVALID_REQUEST` is returned, `GNUTLS_E_SUCCESS` on success, or an error code.

Since: 3.6.3

### gnutls_priority_deinit ()

    void
    gnutls_priority_deinit (gnutls_priority_t priority_cache);

Deinitializes the priority cache.

#### Parameters

priority_cache | is a gnutls_priority_t type. |

### gnutls_priority_get_cipher_suite_index ()

    int
    gnutls_priority_get_cipher_suite_index
                                   (gnutls_priority_t pcache,
                                    unsigned int idx,
                                    unsigned int *sidx);

Provides the internal ciphersuite index to be used with `gnutls_cipher_suite_info()`. The index `idx` provided is an index kept at the priorities structure. It might be that a valid priorities index does not correspond to a ciphersuite and in that case `GNUTLS_E_UNKNOWN_CIPHER_SUITE` will be returned. Once the last available index is crossed then `GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE` will be returned.

#### Parameters

pcache | is a gnutls_priority_t type. |
idx | is an index number. |
sidx | internal index of cipher suite to get information about. |

#### Returns

On success it returns `GNUTLS_E_SUCCESS` (0), or a negative error value otherwise.

Since: 3.0.9

### gnutls_priority_string_list ()

    const char *
    gnutls_priority_string_list (unsigned  iter,
                                 unsigned int flags);

Can be used to iterate all available priority strings. Due to internal implementation details, there are cases where this function can return the empty string. In that case that string should be ignored. When no strings are available it returns `NULL`.

#### Parameters

iter | an integer counter starting from zero |
flags | one of `GNUTLS_PRIORITY_LIST_INIT_KEYWORDS`, `GNUTLS_PRIORITY_LIST_SPECIAL` |

#### Returns

a priority string

Since: 3.4.0

### gnutls_priority_set ()

    int
    gnutls_priority_set (gnutls_session_t session,
                         gnutls_priority_t priority);

Sets the priorities to use on the ciphers, key exchange methods, and macs. Note that this function is expected to be called once per session; when called multiple times (e.g., before a re-handshake, the caller should make sure that any new settings are not incompatible with the original session).

#### Parameters

session | is a gnutls_session_t type. |
priority | is a gnutls_priority_t type. |

#### Returns

`GNUTLS_E_SUCCESS` on success, or an error code on error.

### gnutls_priority_set_direct ()

    int
    gnutls_priority_set_direct (gnutls_session_t session,
                                const char *priorities,
                                const char **err_pos);

Sets the priorities to use on the ciphers, key exchange methods, and macs. This function avoids keeping a priority cache and is used to directly set string priorities to a TLS session. For documentation check the `gnutls_priority_init()`.

To use a reasonable default, consider using `gnutls_set_default_priority()`, or `gnutls_set_default_priority_append()` instead of this function.

#### Parameters

session | is a gnutls_session_t type. |
priorities | is a string describing priorities |
err_pos | In case of an error this will have the position in the string the error occurred |

#### Returns

On syntax error `GNUTLS_E_INVALID_REQUEST` is returned, `GNUTLS_E_SUCCESS` on success, or an error code.

### gnutls_priority_certificate_type_list ()

    int
    gnutls_priority_certificate_type_list (gnutls_priority_t pcache,
                                           const unsigned int **list);

Get a list of available certificate types in the priority structure.

As of version 3.6.4 this function is an alias for gnutls_priority_certificate_type_list2 with the target parameter set to:

- GNUTLS_CTYPE_SERVER, if the `SERVER_PRECEDENCE` option is set

- GNUTLS_CTYPE_CLIENT, otherwise.

#### Parameters

pcache | is a gnutls_priority_t type. |
list | will point to an integer list |

#### Returns

the number of certificate types, or an error code.

Since: 3.0

### gnutls_priority_certificate_type_list2 ()

    int
    gnutls_priority_certificate_type_list2
                                   (gnutls_priority_t pcache,
                                    const unsigned int **list,
                                    gnutls_ctype_target_t target);

Get a list of available certificate types for the given target in the priority structure.

#### Parameters

pcache | is a gnutls_priority_t type. |
list | will point to an integer list. |
target | is a gnutls_ctype_target_t type. Valid arguments are GNUTLS_CTYPE_CLIENT and GNUTLS_CTYPE_SERVER |

#### Returns

the number of certificate types, or an error code.

Since: 3.6.4

### gnutls_priority_sign_list ()

    int
    gnutls_priority_sign_list (gnutls_priority_t pcache,
                               const unsigned int **list);

Get a list of available signature algorithms in the priority structure.

#### Parameters

pcache | is a gnutls_priority_t type. |
list | will point to an integer list |

#### Returns

the number of algorithms, or an error code.

Since: 3.0

### gnutls_priority_protocol_list ()

    int
    gnutls_priority_protocol_list (gnutls_priority_t pcache,
                                   const unsigned int **list);

Get a list of available TLS version numbers in the priority structure.

#### Parameters

pcache | is a gnutls_priority_t type. |
list | will point to an integer list |

#### Returns

the number of protocols, or an error code.

Since: 3.0

### gnutls_priority_ecc_curve_list ()

    int
    gnutls_priority_ecc_curve_list (gnutls_priority_t pcache,
                                    const unsigned int **list);

`gnutls_priority_ecc_curve_list` is deprecated and should not be used in newly-written code.

This function has been replaced by `gnutls_priority_group_list()` since 3.6.0.

Get a list of available elliptic curves in the priority structure.

#### Parameters

pcache | is a gnutls_priority_t type. |
list | will point to an integer list |

#### Returns

the number of items, or an error code.

Since: 3.0

### gnutls_priority_group_list ()

    int
    gnutls_priority_group_list (gnutls_priority_t pcache,
                                const unsigned int **list);

Get a list of available groups in the priority structure.

#### Parameters

pcache | is a gnutls_priority_t type. |
list | will point to an integer list |

#### Returns

the number of items, or an error code.

Since: 3.6.0

### gnutls_priority_kx_list ()

    int
    gnutls_priority_kx_list (gnutls_priority_t pcache,
                             const unsigned int **list);

Get a list of available key exchange methods in the priority structure.

#### Parameters

pcache | is a gnutls_priority_t type. |
list | will point to an integer list |

#### Returns

the number of items, or an error code.

Since: 3.2.3

### gnutls_priority_cipher_list ()

    int
    gnutls_priority_cipher_list (gnutls_priority_t pcache,
                                 const unsigned int **list);

Get a list of available ciphers in the priority structure.

#### Parameters

pcache | is a gnutls_priority_t type. |
list | will point to an integer list |

#### Returns

the number of items, or an error code.

Since: 3.2.3

### gnutls_priority_mac_list ()

    int
    gnutls_priority_mac_list (gnutls_priority_t pcache,
                              const unsigned int **list);

Get a list of available MAC algorithms in the priority structure.

#### Parameters

pcache | is a gnutls_priority_t type. |
list | will point to an integer list |

#### Returns

the number of items, or an error code.

Since: 3.2.3

### gnutls_get_system_config_file ()

    const char *
    gnutls_get_system_config_file (void);

Returns the filename of the system wide configuration file to be loaded by the library.

#### Returns

a constant pointer to the config file path

Since: 3.6.9

### gnutls_set_default_priority ()

    int
    gnutls_set_default_priority (gnutls_session_t session);

Sets the default priority on the ciphers, key exchange methods, and macs. This is the recommended method of setting the defaults, in order to promote consistency between applications using GnuTLS, and to allow GnuTLS using applications to update settings in par with the library. For client applications which require maximum compatibility consider calling `gnutls_session_enable_compatibility_mode()` after this function.

For an application to specify additional options to priority string consider using `gnutls_set_default_priority_append()`.

To allow a user to override the defaults (e.g., when a user interface or configuration file is available), the functions `gnutls_priority_set_direct()` or `gnutls_priority_set()` can be used.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

`GNUTLS_E_SUCCESS` on success, or an error code.

Since: 2.1.4

### gnutls_set_default_priority_append ()

    int
    gnutls_set_default_priority_append (gnutls_session_t session,
                                        const char *add_prio,
                                        const char **err_pos,
                                        unsigned  flags);

Sets the default priority on the ciphers, key exchange methods, and macs with the additional options in `add_prio` . This is the recommended method of setting the defaults when only few additional options are to be added. This promotes consistency between applications using GnuTLS, and allows GnuTLS using applications to update settings in par with the library.

The `add_prio` string should start as a normal priority string, e.g., '-VERS-TLS-ALL:+VERS-TLS1.3:%`COMPAT`' or '%`FORCE_ETM`'. That is, it must not start with ':'.

To allow a user to override the defaults (e.g., when a user interface or configuration file is available), the functions `gnutls_priority_set_direct()` or `gnutls_priority_set()` can be used.

#### Parameters

session | is a gnutls_session_t type. |
add_prio | is a string describing priorities to be appended to default |
err_pos | In case of an error this will have the position in the string the error occurred |
flags | must be zero |

#### Returns

`GNUTLS_E_SUCCESS` on success, or an error code.

Since: 3.6.3

### gnutls_cipher_suite_get_name ()

    const char *
    gnutls_cipher_suite_get_name (gnutls_kx_algorithm_t kx_algorithm,
                                  gnutls_cipher_algorithm_t cipher_algorithm);

This function returns the ciphersuite name under TLS1.2 or earlier versions when provided with individual algorithms. The full cipher suite name must be prepended by TLS or SSL depending of the protocol in use.

To get a description of the current ciphersuite across versions, it is recommended to use `gnutls_session_get_desc()`.

#### Parameters

kx_algorithm | is a Key exchange algorithm |
cipher_algorithm | is a cipher algorithm |
mac_algorithm | is a MAC algorithm |

#### Returns

a string that contains the name of a TLS cipher suite, specified by the given algorithms, or `NULL`.

### gnutls_protocol_get_name ()

    const char *
    gnutls_protocol_get_name ();

Convert a gnutls_protocol_t value to a string.

#### Parameters

version | is a (gnutls) version number |

#### Returns

a string that contains the name of the specified TLS version (e.g., "TLS1.0"), or `NULL`.

### gnutls_session_get_data ()

    int
    gnutls_session_get_data (gnutls_session_t session,
                             void *session_data,
                             size_t *session_data_size);

Returns all session parameters needed to be stored to support resumption, in a pre-allocated buffer.

See `gnutls_session_get_data2()` for more information.

#### Parameters

session | is a gnutls_session_t type. |
session_data | is a pointer to space to hold the session. |
session_data_size | is the session_data's size, or it will be set by the function. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

### gnutls_session_get_data2 ()

    int
    gnutls_session_get_data2 (gnutls_session_t session,
                              gnutls_datum_t *data);

Returns necessary parameters to support resumption. The client should call this function and store the returned session data. A session can be resumed later by calling `gnutls_session_set_data()` with the returned data. Note that under TLS 1.3, it is recommended for clients to use session parameters only once, to prevent passive-observers from correlating the different connections.

The returned `data` are allocated and must be released using `gnutls_free()`.

This function will fail if called prior to handshake completion. In case of false start TLS, the handshake completes only after data have been successfully received from the peer.

Under TLS1.3 session resumption is possible only after a session ticket is received by the client. To ensure that such a ticket has been received use `gnutls_session_get_flags()` and check for flag `GNUTLS_SFLAGS_SESSION_TICKET`; if this flag is not set, this function will wait for a new ticket within an estimated roundtrip, and if not received will return dummy data which cannot lead to resumption.

To get notified when new tickets are received by the server use `gnutls_handshake_set_hook_function()` to wait for `GNUTLS_HANDSHAKE_NEW_SESSION_TICKET` messages. Each call of `gnutls_session_get_data2()` after a ticket is received, will return session resumption data corresponding to the last received ticket.

Note that this function under TLS1.3 requires a callback to be set with `gnutls_transport_set_pull_timeout_function()` for successful operation. There was a bug before 3.6.10 which could make this function fail if that callback was not set. On later versions if not set, the function will return a successful error code, but will return dummy data that cannot lead to a resumption.

#### Parameters

session | is a gnutls_session_t type. |
data | is a pointer to a datum that will hold the session. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

### gnutls_session_get_random ()

    void
    gnutls_session_get_random (gnutls_session_t session,
                               gnutls_datum_t *client,
                               gnutls_datum_t *server);

This function returns pointers to the client and server random fields used in the TLS handshake. The pointers are not to be modified or deallocated.

If a client random value has not yet been established, the output will be garbage.

#### Parameters

session | is a gnutls_session_t type. |
client | the client part of the random |
server | the server part of the random |

Since: 3.0

### gnutls_session_get_master_secret ()

    void
    gnutls_session_get_master_secret (gnutls_session_t session,
                                      gnutls_datum_t *secret);

This function returns pointers to the master secret used in the TLS session. The pointers are not to be modified or deallocated.

This function is only applicable under TLS 1.2 or earlier versions.

#### Parameters

session | is a gnutls_session_t type. |
secret | the session's master secret |

Since: 3.5.0

### gnutls_session_get_desc ()

    char *
    gnutls_session_get_desc (gnutls_session_t session);

This function returns a string describing the current session. The string is null terminated and allocated using `gnutls_malloc()`.

If initial negotiation is not complete when this function is called, `NULL` will be returned.

#### Parameters

session | is a gnutls session |

#### Returns

a description of the protocols and algorithms in the current session.

Since: 3.1.10

### gnutls_session_set_verify_function ()

    void
    gnutls_session_set_verify_function (gnutls_session_t session,
                                        gnutls_certificate_verify_function *func);

This function sets a callback to be called when peer's certificate has been received in order to verify it on receipt rather than doing after the handshake is completed. This overrides any callback set using `gnutls_certificate_set_verify_function()`.

The callback's function prototype is: int (*callback)(gnutls_session_t);

If the callback function is provided then gnutls will call it, in the handshake, just after the certificate message has been received. To verify or obtain the certificate the `gnutls_certificate_verify_peers2()`, `gnutls_certificate_type_get()`, `gnutls_certificate_get_peers()` functions can be used.

The callback function should return 0 for the handshake to continue or non-zero to terminate.

#### Parameters

session | is a gnutls_session_t type. |
func | is the callback function |

Since: 3.4.6

### gnutls_session_set_verify_cert ()

    void
    gnutls_session_set_verify_cert (gnutls_session_t session,
                                    const char *hostname,
                                    unsigned  flags);

This function instructs GnuTLS to verify the peer's certificate using the provided hostname. If the verification fails the handshake will also fail with `GNUTLS_E_CERTIFICATE_VERIFICATION_ERROR`. In that case the verification result can be obtained using `gnutls_session_get_verify_cert_status()`.

The `hostname` pointer provided must remain valid for the lifetime of the session. More precisely it should be available during any subsequent handshakes. If no hostname is provided, no hostname verification will be performed. For a more advanced verification function check `gnutls_session_set_verify_cert2()`.

If `flags` is provided which contain a profile, this function should be called after any session priority setting functions.

The `gnutls_session_set_verify_cert()` function is intended to be used by TLS clients to verify the server's certificate.

#### Parameters

session | is a gnutls session |
hostname | is the expected name of the peer; may be `NULL` |
flags | flags for certificate verification -- gnutls_certificate_verify_flags |

Since: 3.4.6

### gnutls_session_set_verify_cert2 ()

    void
    gnutls_session_set_verify_cert2 (gnutls_session_t session,
                                     gnutls_typed_vdata_st *data,
                                     unsigned  elements,
                                     unsigned  flags);

This function instructs GnuTLS to verify the peer's certificate using the provided typed data information. If the verification fails the handshake will also fail with `GNUTLS_E_CERTIFICATE_VERIFICATION_ERROR`. In that case the verification result can be obtained using `gnutls_session_get_verify_cert_status()`.

The acceptable typed data are the same as in `gnutls_certificate_verify_peers()`, and once set must remain valid for the lifetime of the session. More precisely they should be available during any subsequent handshakes.

If `flags` is provided which contain a profile, this function should be called after any session priority setting functions.

#### Parameters

session | is a gnutls session |
data | an array of typed data |
elements | the number of data elements |
flags | flags for certificate verification -- gnutls_certificate_verify_flags |

Since: 3.4.6

### gnutls_session_get_verify_cert_status ()

    unsigned int
    gnutls_session_get_verify_cert_status (gnutls_session_t Param1);

This function returns the status of the verification when initiated via auto-verification, i.e., by `gnutls_session_set_verify_cert2()` or `gnutls_session_set_verify_cert()`. If no certificate verification was occurred then the return value would be set to ((unsigned int)-1).

The certificate verification status is the same as in `gnutls_certificate_verify_peers()`.

#### Parameters

session | is a gnutls session |

#### Returns

the certificate verification status.

Since: 3.4.6

### gnutls_session_set_premaster ()

    int
    gnutls_session_set_premaster (gnutls_session_t session,
                                  unsigned int entity,
                                  gnutls_protocol_t version,
                                  gnutls_kx_algorithm_t kx,
                                  gnutls_cipher_algorithm_t cipher,
                                  gnutls_mac_algorithm_t mac,
                                  gnutls_compression_method_t comp,
                                  const gnutls_datum_t *master,
                                  const gnutls_datum_t *session_id);

This function sets the premaster secret in a session. This is a function intended for exceptional uses. Do not use this function unless you are implementing a legacy protocol. Use `gnutls_session_set_data()` instead.

#### Parameters

session | is a gnutls_session_t type. |
entity | GNUTLS_SERVER or GNUTLS_CLIENT |
version | the TLS protocol version |
kx | the key exchange method |
cipher | the cipher |
mac | the MAC algorithm |
comp | the compression method (ignored) |
master | the master key to use |
session_id | the session identifier |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

### gnutls_session_get_id ()

    int
    gnutls_session_get_id (gnutls_session_t session,
                           void *session_id,
                           size_t *session_id_size);

Returns the TLS session identifier. The session ID is selected by the server, and in older versions of TLS was a unique identifier shared between client and server which was persistent across resumption. In the latest version of TLS (1.3) or TLS with session tickets, the notion of session identifiers is undefined and cannot be relied for uniquely identifying sessions across client and server.

In client side this function returns the identifier returned by the server, and cannot be assumed to have any relation to session resumption. In server side this function is guaranteed to return a persistent identifier of the session since GnuTLS 3.6.4, which may not necessarily map into the TLS session ID value. Prior to that version the value could only be considered a persistent identifier, under TLS1.2 or earlier and when no session tickets were in use.

The session identifier value returned is always less than `GNUTLS_MAX_SESSION_ID_SIZE`.

#### Parameters

session | is a gnutls_session_t type. |
session_id | is a pointer to space to hold the session id. |
session_id_size | initially should contain the maximum `session_id` size and will be updated. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

### gnutls_session_get_id2 ()

    int
    gnutls_session_get_id2 (gnutls_session_t session,
                            gnutls_datum_t *session_id);

Returns the TLS session identifier. The session ID is selected by the server, and in older versions of TLS was a unique identifier shared between client and server which was persistent across resumption. In the latest version of TLS (1.3) or TLS 1.2 with session tickets, the notion of session identifiers is undefined and cannot be relied for uniquely identifying sessions across client and server.

In client side this function returns the identifier returned by the server, and cannot be assumed to have any relation to session resumption. In server side this function is guaranteed to return a persistent identifier of the session since GnuTLS 3.6.4, which may not necessarily map into the TLS session ID value. Prior to that version the value could only be considered a persistent identifier, under TLS1.2 or earlier and when no session tickets were in use.

The session identifier value returned is always less than `GNUTLS_MAX_SESSION_ID_SIZE` and should be treated as constant.

#### Parameters

session | is a gnutls_session_t type. |
session_id | will point to the session ID. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

Since: 3.1.4

### gnutls_session_set_id ()

    int
    gnutls_session_set_id (gnutls_session_t session,
                           const gnutls_datum_t *sid);

This function sets the session ID to be used in a client hello. This is a function intended for exceptional uses. Do not use this function unless you are implementing a custom protocol.

To set session resumption parameters use `gnutls_session_set_data()` instead.

#### Parameters

session | is a gnutls_session_t type. |
sid | the session identifier |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

Since: 3.2.1

### gnutls_session_channel_binding ()

    int
    gnutls_session_channel_binding (gnutls_session_t session,
                                    gnutls_channel_binding_t cbtype,
                                    gnutls_datum_t *cb);

Extract given channel binding data of the `cbtype` (e.g., `GNUTLS_CB_TLS_UNIQUE`) type.

#### Parameters

session | is a gnutls_session_t type. |
cbtype | an gnutls_channel_binding_t enumeration type |
cb | output buffer array with data |

#### Returns

`GNUTLS_E_SUCCESS` on success, `GNUTLS_E_UNIMPLEMENTED_FEATURE` if the `cbtype` is unsupported, `GNUTLS_E_CHANNEL_BINDING_NOT_AVAILABLE` if the data is not currently available, or an error code.

Since: 2.12.0

### gnutls_session_is_resumed ()

    int
    gnutls_session_is_resumed (gnutls_session_t session);

Checks whether session is resumed or not. This is functional for both server and client side.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

non zero if this session is resumed, or a zero if this is a new session.

### gnutls_session_resumption_requested ()

    int
    gnutls_session_resumption_requested (gnutls_session_t session);

Check whether the client has asked for session resumption. This function is valid only on server side.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

non zero if session resumption was asked, or a zero if not.

### gnutls_db_store_func ()

    int
    (*gnutls_db_store_func) (void *Param1,
                             gnutls_datum_t key,
                             gnutls_datum_t data);

### gnutls_db_remove_func ()

    int
    (*gnutls_db_remove_func) (void *Param1,
                              gnutls_datum_t key);

### gnutls_db_retr_func ()

    gnutls_datum_t
    (*gnutls_db_retr_func) (void *Param1,
                            gnutls_datum_t key);

### gnutls_db_set_cache_expiration ()

    void
    gnutls_db_set_cache_expiration (gnutls_session_t session,
                                    int seconds);

Set the expiration time for resumed sessions. The default is 21600 (6 hours) at the time of writing.

The maximum value that can be set using this function is 604800 (7 days).

#### Parameters

session | is a gnutls_session_t type. |
seconds | is the number of seconds. |

### gnutls_db_get_default_cache_expiration ()

    unsigned
    gnutls_db_get_default_cache_expiration
                                   (void);

Returns the expiration time (in seconds) of stored sessions for resumption.

### gnutls_db_remove_session ()

    void
    gnutls_db_remove_session (gnutls_session_t session);

This function will remove the current session data from the session database. This will prevent future handshakes reusing these session data. This function should be called if a session was terminated abnormally, and before `gnutls_deinit()` is called.

Normally `gnutls_deinit()` will remove abnormally terminated sessions.

#### Parameters

session | is a gnutls_session_t type. |

### gnutls_db_set_retrieve_function ()

    void
    gnutls_db_set_retrieve_function (gnutls_session_t session,
                                     gnutls_db_retr_func retr_func);

Sets the function that will be used to retrieve data from the resumed sessions database. This function must return a gnutls_datum_t containing the data on success, or a gnutls_datum_t containing null and 0 on failure.

The datum's data must be allocated using the function `gnutls_malloc()`.

The first argument to `retr_func` will be null unless `gnutls_db_set_ptr()` has been called.

#### Parameters

session | is a gnutls_session_t type. |
retr_func | is the function. |

### gnutls_db_set_remove_function ()

    void
    gnutls_db_set_remove_function (gnutls_session_t session,
                                   gnutls_db_remove_func rem_func);

Sets the function that will be used to remove data from the resumed sessions database. This function must return 0 on success.

The first argument to `rem_func` will be null unless `gnutls_db_set_ptr()` has been called.

#### Parameters

session | is a gnutls_session_t type. |
rem_func | is the function. |

### gnutls_db_set_store_function ()

    void
    gnutls_db_set_store_function (gnutls_session_t session,
                                  gnutls_db_store_func store_func);

Sets the function that will be used to store data in the resumed sessions database. This function must return 0 on success.

The first argument to `store_func` will be null unless `gnutls_db_set_ptr()` has been called.

#### Parameters

session | is a gnutls_session_t type. |
store_func | is the function |

### gnutls_db_set_ptr ()

    void
    gnutls_db_set_ptr (gnutls_session_t session,
                       void *ptr);

Sets the pointer that will be provided to db store, retrieve and delete functions, as the first argument.

#### Parameters

session | is a gnutls_session_t type. |
ptr | is the pointer |

### gnutls_db_get_ptr ()

    void *
    gnutls_db_get_ptr (gnutls_session_t session);

Get db function pointer.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

the pointer that will be sent to db store, retrieve and delete functions, as the first argument.

### gnutls_db_check_entry ()

    int
    gnutls_db_check_entry (gnutls_session_t session,
                           gnutls_datum_t session_entry);

`gnutls_db_check_entry` is deprecated and should not be used in newly-written code.

This function is deprecated.

This function has no effect.

#### Parameters

session | is a gnutls_session_t type. |
session_entry | is the session data (not key) |

#### Returns

Returns `GNUTLS_E_EXPIRED`, if the database entry has expired or 0 otherwise.

### gnutls_db_check_entry_time ()

    time_t
    gnutls_db_check_entry_time (gnutls_datum_t *entry);

This function returns the time that this entry was active. It can be used for database entry expiration.

#### Parameters

entry | is a pointer to a gnutls_datum_t type. |

#### Returns

The time this entry was created, or zero on error.

### gnutls_db_check_entry_expire_time ()

    time_t
    gnutls_db_check_entry_expire_time (gnutls_datum_t *entry);

This function returns the time that this entry will expire. It can be used for database entry expiration.

#### Parameters

entry | is a pointer to a gnutls_datum_t type. |

#### Returns

The time this entry will expire, or zero on error.

Since: 3.6.5

### gnutls_handshake_hook_func ()

    int
    (*gnutls_handshake_hook_func) (gnutls_session_t Param1,
                                   unsigned int htype,
                                   unsigned  when,
                                   unsigned int incoming,
                                   const gnutls_datum_t *msg);

Function prototype for handshake hooks. It is set using `gnutls_handshake_set_hook_function()`.

#### Parameters

session | the current session |
htype | the type of the handshake message (`gnutls_handshake_description_t`) |
when | non zero if this is a post-process/generation call and zero otherwise |
incoming | non zero if this is an incoming message and zero if this is an outgoing message |
msg | the (const) data of the handshake message without the handshake headers. |

#### Returns

Non zero on error.

### gnutls_handshake_set_hook_function ()

    void
    gnutls_handshake_set_hook_function (gnutls_session_t session,
                                        unsigned int htype,
                                        int when,
                                        gnutls_handshake_hook_func func);

This function will set a callback to be called after or before the specified handshake message has been received or generated. This is a generalization of `gnutls_handshake_set_post_client_hello_function()`.

To call the hook function prior to the message being generated or processed use `GNUTLS_HOOK_PRE` as `when` parameter, `GNUTLS_HOOK_POST` to call after, and `GNUTLS_HOOK_BOTH` for both cases.

This callback must return 0 on success or a gnutls error code to terminate the handshake.

To hook at all handshake messages use an `htype` of `GNUTLS_HANDSHAKE_ANY`.

Warning: You should not use this function to terminate the handshake based on client input unless you know what you are doing. Before the handshake is finished there is no way to know if there is a man-in-the-middle attack being performed.

#### Parameters

session | is a gnutls_session_t type |
htype | the `gnutls_handshake_description_t` of the message to hook at |
when | `GNUTLS_HOOK_`* depending on when the hook function should be called |
func | is the function to be called |

### gnutls_handshake_simple_hook_func ()

    int
    (*gnutls_handshake_simple_hook_func) (gnutls_session_t Param1);

### gnutls_handshake_set_post_client_hello_function ()

    void
    gnutls_handshake_set_post_client_hello_function
                                   (gnutls_session_t session,
                                    gnutls_handshake_simple_hook_func func);

This function will set a callback to be called after the client hello has been received (callback valid in server side only). This allows the server to adjust settings based on received extensions.

Those settings could be ciphersuites, requesting certificate, or anything else except for version negotiation (this is done before the hello message is parsed).

This callback must return 0 on success or a gnutls error code to terminate the handshake.

Since GnuTLS 3.3.5 the callback is allowed to return `GNUTLS_E_AGAIN` or `GNUTLS_E_INTERRUPTED` to put the handshake on hold. In that case `gnutls_handshake()` will return `GNUTLS_E_INTERRUPTED` and can be resumed when needed.

Warning: You should not use this function to terminate the handshake based on client input unless you know what you are doing. Before the handshake is finished there is no way to know if there is a man-in-the-middle attack being performed.

#### Parameters

session | is a gnutls_session_t type. |
func | is the function to be called |

### gnutls_handshake_set_max_packet_length ()

    void
    gnutls_handshake_set_max_packet_length
                                   (gnutls_session_t session,
                                    size_t max);

This function will set the maximum size of all handshake messages. Handshakes over this size are rejected with `GNUTLS_E_HANDSHAKE_TOO_LARGE` error code. The default value is 128kb which is typically large enough. Set this to 0 if you do not want to set an upper limit.

The reason for restricting the handshake message sizes are to limit Denial of Service attacks.

Note that the maximum handshake size was increased to 128kb from 48kb in GnuTLS 3.5.5.

#### Parameters

session | is a gnutls_session_t type. |
max | is the maximum number. |

### gnutls_check_version ()

    const char *
    gnutls_check_version ();

Check the GnuTLS Library version against the provided string. See `GNUTLS_VERSION` for a suitable `req_version` string.

See also `gnutls_check_version_numeric()`, which provides this functionality as a macro.

#### Parameters

req_version | version string to compare with, or `NULL`. |

#### Returns

Check that the version of the library is at minimum the one given as a string in `req_version` and return the actual version string of the library; return `NULL` if the condition is not met. If `NULL` is passed to this function no check is done and only the version string is returned.

### gnutls_credentials_set ()

    int
    gnutls_credentials_set (gnutls_session_t session,
                            gnutls_credentials_type_t type,
                            void *cred);

Sets the needed credentials for the specified type. E.g. username, password - or public and private keys etc. The `cred` parameter is a structure that depends on the specified `type` and on the current session (client or server). Only a single `cred` may be set for each different `type` , subsequent calls with the same `type` will replace the previously set credentials.

In order to minimize memory usage, and share credentials between several threads gnutls keeps a pointer to `cred` , and not the whole cred structure. Thus you will have to keep the structure allocated until you call `gnutls_deinit()`, or a future call of `gnutls_credentials_set()` with the same `type` replaces the `cred` structure.

For `GNUTLS_CRD_ANON`, `cred` should be gnutls_anon_client_credentials_t in case of a client. In case of a server it should be gnutls_anon_server_credentials_t.

For `GNUTLS_CRD_SRP`, `cred` should be gnutls_srp_client_credentials_t in case of a client, and gnutls_srp_server_credentials_t, in case of a server.

For `GNUTLS_CRD_CERTIFICATE`, `cred` should be gnutls_certificate_credentials_t.

#### Parameters

session | is a gnutls_session_t type. |
type | is the type of the credentials |
cred | the credentials to set |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

### gnutls_credentials_get ()

    int
    gnutls_credentials_get (gnutls_session_t session,
                            gnutls_credentials_type_t type,
                            void **cred);

Returns the previously provided credentials structures.

For `GNUTLS_CRD_ANON`, `cred` will be gnutls_anon_client_credentials_t in case of a client. In case of a server it should be gnutls_anon_server_credentials_t.

For `GNUTLS_CRD_SRP`, `cred` will be gnutls_srp_client_credentials_t in case of a client, and gnutls_srp_server_credentials_t, in case of a server.

For `GNUTLS_CRD_PSK`, `cred` will be gnutls_psk_client_credentials_t in case of a client, and gnutls_psk_server_credentials_t, in case of a server.

For `GNUTLS_CRD_CERTIFICATE`, `cred` will be gnutls_certificate_credentials_t.

#### Parameters

session | is a gnutls_session_t type. |
type | is the type of the credentials to return |
cred | will contain the credentials. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

Since: 3.3.3

### gnutls_anon_free_server_credentials ()

    void
    gnutls_anon_free_server_credentials (gnutls_anon_server_credentials_t sc);

Free a gnutls_anon_server_credentials_t structure.

#### Parameters

sc | is a gnutls_anon_server_credentials_t type. |

### gnutls_anon_allocate_server_credentials ()

    int
    gnutls_anon_allocate_server_credentials
                                   (gnutls_anon_server_credentials_t *sc);

Allocate a gnutls_anon_server_credentials_t structure.

#### Parameters

sc | is a pointer to a gnutls_anon_server_credentials_t type. |

#### Returns

`GNUTLS_E_SUCCESS` on success, or an error code.

### gnutls_anon_set_server_dh_params ()

    void
    gnutls_anon_set_server_dh_params (gnutls_anon_server_credentials_t res,
                                      gnutls_dh_params_t dh_params);

`gnutls_anon_set_server_dh_params` is deprecated and should not be used in newly-written code.

This function is unnecessary and discouraged on GnuTLS 3.6.0 or later. Since 3.6.0, DH parameters are negotiated following RFC7919.

This function will set the Diffie-Hellman parameters for an anonymous server to use. These parameters will be used in Anonymous Diffie-Hellman cipher suites.

#### Parameters

res | is a gnutls_anon_server_credentials_t type |
dh_params | The Diffie-Hellman parameters. |

### gnutls_anon_set_server_known_dh_params ()

    int
    gnutls_anon_set_server_known_dh_params
                                   (gnutls_anon_server_credentials_t res,
                                    gnutls_sec_param_t sec_param);

`gnutls_anon_set_server_known_dh_params` is deprecated and should not be used in newly-written code.

This function is unnecessary and discouraged on GnuTLS 3.6.0 or later. Since 3.6.0, DH parameters are negotiated following RFC7919.

This function will set the Diffie-Hellman parameters for an anonymous server to use. These parameters will be used in Anonymous Diffie-Hellman cipher suites and will be selected from the FFDHE set of RFC7919 according to the security level provided.

#### Parameters

res | is a gnutls_anon_server_credentials_t type |
sec_param | is an option of the `gnutls_sec_param_t` enumeration |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error value.

Since: 3.5.6

### gnutls_anon_set_server_params_function ()

    void
    gnutls_anon_set_server_params_function
                                   (gnutls_anon_server_credentials_t res,
                                    gnutls_params_function *func);

`gnutls_anon_set_server_params_function` is deprecated and should not be used in newly-written code.

This function is unnecessary and discouraged on GnuTLS 3.6.0 or later. Since 3.6.0, DH parameters are negotiated following RFC7919.

This function will set a callback in order for the server to get the Diffie-Hellman parameters for anonymous authentication. The callback should return `GNUTLS_E_SUCCESS` (0) on success.

#### Parameters

res | is a gnutls_certificate_credentials_t type |
func | is the function to be called |

### gnutls_anon_free_client_credentials ()

    void
    gnutls_anon_free_client_credentials (gnutls_anon_client_credentials_t sc);

Free a gnutls_anon_client_credentials_t structure.

#### Parameters

sc | is a gnutls_anon_client_credentials_t type. |

### gnutls_anon_allocate_client_credentials ()

    int
    gnutls_anon_allocate_client_credentials
                                   (gnutls_anon_client_credentials_t *sc);

Allocate a gnutls_anon_client_credentials_t structure.

#### Parameters

sc | is a pointer to a gnutls_anon_client_credentials_t type. |

#### Returns

`GNUTLS_E_SUCCESS` on success, or an error code.

### gnutls_certificate_free_credentials ()

    void
    gnutls_certificate_free_credentials (gnutls_certificate_credentials_t sc);

Free a gnutls_certificate_credentials_t structure.

This function does not free any temporary parameters associated with this structure (ie RSA and DH parameters are not freed by this function).

#### Parameters

sc | is a gnutls_certificate_credentials_t type. |

### gnutls_certificate_allocate_credentials ()

    int
    gnutls_certificate_allocate_credentials
                                   (gnutls_certificate_credentials_t *res);

Allocate a gnutls_certificate_credentials_t structure.

#### Parameters

res | is a pointer to a gnutls_certificate_credentials_t type. |

#### Returns

`GNUTLS_E_SUCCESS` on success, or an error code.

### gnutls_certificate_get_issuer ()

    int
    gnutls_certificate_get_issuer (gnutls_certificate_credentials_t sc,
                                   gnutls_x509_crt_t cert,
                                   gnutls_x509_crt_t *issuer,
                                   unsigned int flags);

This function will return the issuer of a given certificate. If the flag `GNUTLS_TL_GET_COPY` is specified a copy of the issuer will be returned which must be freed using `gnutls_x509_crt_deinit()`. In that case the provided `issuer` must not be initialized.

As with `gnutls_x509_trust_list_get_issuer()` this function requires the `GNUTLS_TL_GET_COPY` flag in order to operate with PKCS11 trust lists in a thread-safe way.

#### Parameters

sc | is a gnutls_certificate_credentials_t type. |
cert | is the certificate to find issuer for |
issuer | Will hold the issuer if any. Should be treated as constant. |
flags | Use zero or `GNUTLS_TL_GET_COPY` |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error value.

Since: 3.0

### gnutls_certificate_get_crt_raw ()

    int
    gnutls_certificate_get_crt_raw (gnutls_certificate_credentials_t sc,
                                    unsigned  idx1,
                                    unsigned  idx2,
                                    gnutls_datum_t *cert);

This function will return the DER encoded certificate of the server or any other certificate on its certificate chain (based on `idx2` ). The returned data should be treated as constant and only accessible during the lifetime of `sc` . The `idx1` matches the value `gnutls_certificate_set_x509_key()` and friends functions.

#### Parameters

sc | is a gnutls_certificate_credentials_t type. |
idx1 | the index of the certificate chain if multiple are present |
idx2 | the index of the certificate in the chain. Zero gives the server's certificate. |
cert | Will hold the DER encoded certificate. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error value. In case the indexes are out of bounds `GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE` is returned.

Since: 3.2.5

### gnutls_certificate_free_keys ()

    void
    gnutls_certificate_free_keys (gnutls_certificate_credentials_t sc);

This function will delete all the keys and the certificates associated with the given credentials. This function must not be called when a TLS negotiation that uses the credentials is in progress.

#### Parameters

sc | is a gnutls_certificate_credentials_t type. |

### gnutls_certificate_free_cas ()

    void
    gnutls_certificate_free_cas (gnutls_certificate_credentials_t sc);

This function was operational on very early versions of gnutls. Due to internal refactorings and the fact that this was hardly ever used, it is currently a no-op.

#### Parameters

sc | is a gnutls_certificate_credentials_t type. |

### gnutls_certificate_free_ca_names ()

    void
    gnutls_certificate_free_ca_names (gnutls_certificate_credentials_t sc);

This function will delete all the CA name in the given credentials. Clients may call this to save some memory since in client side the CA names are not used. Servers might want to use this function if a large list of trusted CAs is present and sending the names of it would just consume bandwidth without providing information to client.

CA names are used by servers to advertise the CAs they support to clients.

#### Parameters

sc | is a gnutls_certificate_credentials_t type. |

### gnutls_certificate_free_crls ()

    void
    gnutls_certificate_free_crls (gnutls_certificate_credentials_t sc);

This function will delete all the CRLs associated with the given credentials.

#### Parameters

sc | is a gnutls_certificate_credentials_t type. |

### gnutls_certificate_set_dh_params ()

    void
    gnutls_certificate_set_dh_params (gnutls_certificate_credentials_t res,
                                      gnutls_dh_params_t dh_params);

`gnutls_certificate_set_dh_params` is deprecated and should not be used in newly-written code.

This function is unnecessary and discouraged on GnuTLS 3.6.0 or later. Since 3.6.0, DH parameters are negotiated following RFC7919.

This function will set the Diffie-Hellman parameters for a certificate server to use. These parameters will be used in Ephemeral Diffie-Hellman cipher suites. Note that only a pointer to the parameters are stored in the certificate handle, so you must not deallocate the parameters before the certificate is deallocated.

#### Parameters

res | is a gnutls_certificate_credentials_t type |
dh_params | the Diffie-Hellman parameters. |

### gnutls_certificate_set_known_dh_params ()

    int
    gnutls_certificate_set_known_dh_params
                                   (gnutls_certificate_credentials_t res,
                                    gnutls_sec_param_t sec_param);

`gnutls_certificate_set_known_dh_params` is deprecated and should not be used in newly-written code.

This function is unnecessary and discouraged on GnuTLS 3.6.0 or later. Since 3.6.0, DH parameters are negotiated following RFC7919.

This function will set the Diffie-Hellman parameters for a certificate server to use. These parameters will be used in Ephemeral Diffie-Hellman cipher suites and will be selected from the FFDHE set of RFC7919 according to the security level provided.

#### Parameters

res | is a gnutls_certificate_credentials_t type |
sec_param | is an option of the `gnutls_sec_param_t` enumeration |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error value.

Since: 3.5.6

### gnutls_certificate_set_verify_flags ()

    void
    gnutls_certificate_set_verify_flags (gnutls_certificate_credentials_t res,
                                         unsigned int flags);

This function will set the flags to be used for verification of certificates and override any defaults. The provided flags must be an OR of the gnutls_certificate_verify_flags enumerations.

#### Parameters

res | is a gnutls_certificate_credentials_t type |
flags | are the flags |

### gnutls_certificate_get_verify_flags ()

    unsigned int
    gnutls_certificate_get_verify_flags (gnutls_certificate_credentials_t res);

Returns the verification flags set with `gnutls_certificate_set_verify_flags()`.

#### Parameters

res | is a gnutls_certificate_credentials_t type |

#### Returns

The certificate verification flags used by `res` .

Since: 3.4.0

### gnutls_certificate_set_flags ()

    void
    gnutls_certificate_set_flags (gnutls_certificate_credentials_t Param1,
                                  unsigned  flags);

This function will set flags to tweak the operation of the credentials structure. See the gnutls_certificate_flags enumerations for more information on the available flags.

#### Parameters

res | is a gnutls_certificate_credentials_t type |
flags | are the flags of gnutls_certificate_flags type |

Since: 3.4.7

### gnutls_certificate_set_verify_limits ()

    void
    gnutls_certificate_set_verify_limits (gnutls_certificate_credentials_t res,
                                          unsigned int max_bits,
                                          unsigned int max_depth);

This function will set some upper limits for the default verification function, `gnutls_certificate_verify_peers2()`, to avoid denial of service attacks. You can set them to zero to disable limits.

#### Parameters

res | is a gnutls_certificate_credentials type |
max_bits | is the number of bits of an acceptable certificate (default 8200) |
max_depth | is maximum depth of the verification of a certificate chain (default 5) |

### gnutls_certificate_set_x509_system_trust ()

    int
    gnutls_certificate_set_x509_system_trust
                                   (gnutls_certificate_credentials_t cred);

This function adds the system's default trusted CAs in order to verify client or server certificates.

In the case the system is currently unsupported `GNUTLS_E_UNIMPLEMENTED_FEATURE` is returned.

#### Parameters

cred | is a gnutls_certificate_credentials_t type. |

#### Returns

the number of certificates processed or a negative error code on error.

Since: 3.0.20

### gnutls_certificate_set_x509_trust_file ()

    int
    gnutls_certificate_set_x509_trust_file
                                   (gnutls_certificate_credentials_t cred,
                                    const char *cafile,
                                    gnutls_x509_crt_fmt_t type);

This function adds the trusted CAs in order to verify client or server certificates. In case of a client this is not required to be called if the certificates are not verified using `gnutls_certificate_verify_peers2()`. This function may be called multiple times.

In case of a server the names of the CAs set here will be sent to the client if a certificate request is sent. This can be disabled using `gnutls_certificate_send_x509_rdn_sequence()`.

This function can also accept URLs. In that case it will import all certificates that are marked as trusted. Note that the supported URLs are the ones indicated by `gnutls_url_is_supported()`.

#### Parameters

cred | is a gnutls_certificate_credentials_t type. |
cafile | is a file containing the list of trusted CAs (DER or PEM list) |
type | is PEM or DER |

#### Returns

the number of certificates processed

### gnutls_certificate_set_x509_trust_dir ()

    int
    gnutls_certificate_set_x509_trust_dir (gnutls_certificate_credentials_t cred,
                                           const char *ca_dir,
                                           gnutls_x509_crt_fmt_t type);

This function adds the trusted CAs present in the directory in order to verify client or server certificates. This function is identical to `gnutls_certificate_set_x509_trust_file()` but loads all certificates in a directory.

#### Parameters

cred | is a gnutls_certificate_credentials_t type. |
ca_dir | is a directory containing the list of trusted CAs (DER or PEM list) |
type | is PEM or DER |

#### Returns

the number of certificates processed

Since: 3.3.6

### gnutls_certificate_set_x509_trust_mem ()

    int
    gnutls_certificate_set_x509_trust_mem (gnutls_certificate_credentials_t res,
                                           const gnutls_datum_t *ca,
                                           gnutls_x509_crt_fmt_t type);

This function adds the trusted CAs in order to verify client or server certificates. In case of a client this is not required to be called if the certificates are not verified using `gnutls_certificate_verify_peers2()`. This function may be called multiple times.

In case of a server the CAs set here will be sent to the client if a certificate request is sent. This can be disabled using `gnutls_certificate_send_x509_rdn_sequence()`.

#### Parameters

res | is a gnutls_certificate_credentials_t type. |
ca | is a list of trusted CAs or a DER certificate |
type | is DER or PEM |

#### Returns

the number of certificates processed or a negative error code on error.

### gnutls_certificate_set_x509_crl_file ()

    int
    gnutls_certificate_set_x509_crl_file (gnutls_certificate_credentials_t res,
                                          const char *crlfile,
                                          gnutls_x509_crt_fmt_t type);

This function adds the trusted CRLs in order to verify client or server certificates. In case of a client this is not required to be called if the certificates are not verified using `gnutls_certificate_verify_peers2()`. This function may be called multiple times.

#### Parameters

res | is a gnutls_certificate_credentials_t type. |
crlfile | is a file containing the list of verified CRLs (DER or PEM list) |
type | is PEM or DER |

#### Returns

number of CRLs processed or a negative error code on error.

### gnutls_certificate_set_x509_crl_mem ()

    int
    gnutls_certificate_set_x509_crl_mem (gnutls_certificate_credentials_t res,
                                         const gnutls_datum_t *CRL,
                                         gnutls_x509_crt_fmt_t type);

This function adds the trusted CRLs in order to verify client or server certificates. In case of a client this is not required to be called if the certificates are not verified using `gnutls_certificate_verify_peers2()`. This function may be called multiple times.

#### Parameters

res | is a gnutls_certificate_credentials_t type. |
CRL | is a list of trusted CRLs. They should have been verified before. |
type | is DER or PEM |

#### Returns

number of CRLs processed, or a negative error code on error.

### gnutls_certificate_set_x509_key_file ()

    int
    gnutls_certificate_set_x509_key_file (gnutls_certificate_credentials_t res,
                                          const char *certfile,
                                          const char *keyfile,
                                          gnutls_x509_crt_fmt_t type);

This function sets a certificate/private key pair in the gnutls_certificate_credentials_t type. This function may be called more than once, in case multiple keys/certificates exist for the server. For clients that need to send more than its own end entity certificate, e.g., also an intermediate CA cert, then the `certfile` must contain the ordered certificate chain.

Note that the names in the certificate provided will be considered when selecting the appropriate certificate to use (in case of multiple certificate/key pairs).

This function can also accept URLs at `keyfile` and `certfile` . In that case it will use the private key and certificate indicated by the URLs. Note that the supported URLs are the ones indicated by `gnutls_url_is_supported()`.

In case the `certfile` is provided as a PKCS 11 URL, then the certificate, and its present issuers in the token are imported (i.e., forming the required trust chain).

If that function fails to load the `res` structure is at an undefined state, it must not be reused to load other keys or certificates.

Note that, this function by default returns zero on success and a negative value on error. Since 3.5.6, when the flag `GNUTLS_CERTIFICATE_API_V2` is set using `gnutls_certificate_set_flags()` it returns an index (greater or equal to zero). That index can be used to other functions to refer to the added key-pair.

#### Parameters

res | is a gnutls_certificate_credentials_t type. |
certfile | is a file that containing the certificate list (path) for the specified private key, in PKCS7 format, or a list of certificates |
keyfile | is a file that contains the private key |
type | is PEM or DER |

#### Returns

On success this functions returns zero, and otherwise a negative value on error (see above for modifying that behavior).

Since: 3.1.11

### gnutls_certificate_set_x509_key_file2 ()

    int
    gnutls_certificate_set_x509_key_file2 (gnutls_certificate_credentials_t res,
                                           const char *certfile,
                                           const char *keyfile,
                                           gnutls_x509_crt_fmt_t type,
                                           const char *pass,
                                           unsigned int flags);

This function sets a certificate/private key pair in the gnutls_certificate_credentials_t type. This function may be called more than once, in case multiple keys/certificates exist for the server. For clients that need to send more than its own end entity certificate, e.g., also an intermediate CA cert, then the `certfile` must contain the ordered certificate chain.

Note that the names in the certificate provided will be considered when selecting the appropriate certificate to use (in case of multiple certificate/key pairs).

This function can also accept URLs at `keyfile` and `certfile` . In that case it will use the private key and certificate indicated by the URLs. Note that the supported URLs are the ones indicated by `gnutls_url_is_supported()`. Before GnuTLS 3.4.0 when a URL was specified, the `pass` part was ignored and a PIN callback had to be registered, this is no longer the case in current releases.

In case the `certfile` is provided as a PKCS 11 URL, then the certificate, and its present issuers in the token are imported (i.e., forming the required trust chain).

If that function fails to load the `res` structure is at an undefined state, it must not be reused to load other keys or certificates.

Note that, this function by default returns zero on success and a negative value on error. Since 3.5.6, when the flag `GNUTLS_CERTIFICATE_API_V2` is set using `gnutls_certificate_set_flags()` it returns an index (greater or equal to zero). That index can be used to other functions to refer to the added key-pair.

#### Parameters

res | is a gnutls_certificate_credentials_t type. |
certfile | is a file that containing the certificate list (path) for the specified private key, in PKCS7 format, or a list of certificates |
keyfile | is a file that contains the private key |
type | is PEM or DER |
pass | is the password of the key |
flags | an ORed sequence of gnutls_pkcs_encrypt_flags_t |

#### Returns

On success this functions returns zero, and otherwise a negative value on error (see above for modifying that behavior).

### gnutls_certificate_set_x509_key_mem ()

    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);

This function sets a certificate/private key pair in the gnutls_certificate_credentials_t type. This function may be called more than once, in case multiple keys/certificates exist for the server.

Note that the keyUsage (2.5.29.15) PKIX extension in X.509 certificates is supported. This means that certificates intended for signing cannot be used for ciphersuites that require encryption.

If the certificate and the private key are given in PEM encoding then the strings that hold their values must be null terminated.

The `key` may be `NULL` if you are using a sign callback, see `gnutls_sign_callback_set()`.

Note that, this function by default returns zero on success and a negative value on error. Since 3.5.6, when the flag `GNUTLS_CERTIFICATE_API_V2` is set using `gnutls_certificate_set_flags()` it returns an index (greater or equal to zero). That index can be used to other functions to refer to the added key-pair.

#### Parameters

res | is a gnutls_certificate_credentials_t type. |
cert | contains a certificate list (path) for the specified private key |
key | is the private key, or `NULL` |
type | is PEM or DER |

#### Returns

On success this functions returns zero, and otherwise a negative value on error (see above for modifying that behavior).

### gnutls_certificate_set_x509_key_mem2 ()

    int
    gnutls_certificate_set_x509_key_mem2 (gnutls_certificate_credentials_t res,
                                          const gnutls_datum_t *cert,
                                          const gnutls_datum_t *key,
                                          gnutls_x509_crt_fmt_t type,
                                          const char *pass,
                                          unsigned int flags);

This function sets a certificate/private key pair in the gnutls_certificate_credentials_t type. This function may be called more than once, in case multiple keys/certificates exist for the server.

Note that the keyUsage (2.5.29.15) PKIX extension in X.509 certificates is supported. This means that certificates intended for signing cannot be used for ciphersuites that require encryption.

If the certificate and the private key are given in PEM encoding then the strings that hold their values must be null terminated.

The `key` may be `NULL` if you are using a sign callback, see `gnutls_sign_callback_set()`.

Note that, this function by default returns zero on success and a negative value on error. Since 3.5.6, when the flag `GNUTLS_CERTIFICATE_API_V2` is set using `gnutls_certificate_set_flags()` it returns an index (greater or equal to zero). That index can be used to other functions to refer to the added key-pair.

#### Parameters

res | is a gnutls_certificate_credentials_t type. |
cert | contains a certificate list (path) for the specified private key |
key | is the private key, or `NULL` |
type | is PEM or DER |
pass | is the key's password |
flags | an ORed sequence of gnutls_pkcs_encrypt_flags_t |

#### Returns

On success this functions returns zero, and otherwise a negative value on error (see above for modifying that behavior).

### gnutls_certificate_send_x509_rdn_sequence ()

    void
    gnutls_certificate_send_x509_rdn_sequence
                                   (gnutls_session_t session,
                                    int status);

If status is non zero, this function will order gnutls not to send the rdnSequence in the certificate request message. That is the server will not advertise its trusted CAs to the peer. If status is zero then the default behaviour will take effect, which is to advertise the server's trusted CAs.

This function has no effect in clients, and in authentication methods other than certificate with X.509 certificates.

#### Parameters

session | a gnutls_session_t type. |
status | is 0 or 1 |

### gnutls_certificate_set_x509_simple_pkcs12_file ()

    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);

This function sets a certificate/private key pair and/or a CRL in the gnutls_certificate_credentials_t type. This function may be called more than once (in case multiple keys/certificates exist for the server).

PKCS12 files with a MAC, encrypted bags and PKCS #8 private keys are supported. However, only password based security, and the same password for all operations, are supported.

PKCS12 file may contain many keys and/or certificates, and this function will try to auto-detect based on the key ID the certificate and key pair to use. If the PKCS12 file contain the issuer of the selected certificate, it will be appended to the certificate to form a chain.

If more than one private keys are stored in the PKCS12 file, then only one key will be read (and it is undefined which one).

It is believed that the limitations of this function is acceptable for most usage, and that any more flexibility would introduce complexity that would make it harder to use this functionality at all.

Note that, this function by default returns zero on success and a negative value on error. Since 3.5.6, when the flag `GNUTLS_CERTIFICATE_API_V2` is set using `gnutls_certificate_set_flags()` it returns an index (greater or equal to zero). That index can be used to other functions to refer to the added key-pair.

#### Parameters

res | is a gnutls_certificate_credentials_t type. |
pkcs12file | filename of file containing PKCS12 blob. |
type | is PEM or DER of the `pkcs12file` . |
password | optional password used to decrypt PKCS12 file, bags and keys. |

#### Returns

On success this functions returns zero, and otherwise a negative value on error (see above for modifying that behavior).

### gnutls_certificate_set_x509_simple_pkcs12_mem ()

    int
    gnutls_certificate_set_x509_simple_pkcs12_mem
                                   (gnutls_certificate_credentials_t res,
                                    const gnutls_datum_t *p12blob,
                                    gnutls_x509_crt_fmt_t type,
                                    const char *password);

This function sets a certificate/private key pair and/or a CRL in the gnutls_certificate_credentials_t type. This function may be called more than once (in case multiple keys/certificates exist for the server).

Encrypted PKCS12 bags and PKCS#8 private keys are supported. However, only password based security, and the same password for all operations, are supported.

PKCS12 file may contain many keys and/or certificates, and this function will try to auto-detect based on the key ID the certificate and key pair to use. If the PKCS12 file contain the issuer of the selected certificate, it will be appended to the certificate to form a chain.

If more than one private keys are stored in the PKCS12 file, then only one key will be read (and it is undefined which one).

It is believed that the limitations of this function is acceptable for most usage, and that any more flexibility would introduce complexity that would make it harder to use this functionality at all.

Note that, this function by default returns zero on success and a negative value on error. Since 3.5.6, when the flag `GNUTLS_CERTIFICATE_API_V2` is set using `gnutls_certificate_set_flags()` it returns an index (greater or equal to zero). That index can be used to other functions to refer to the added key-pair.

#### Parameters

res | is a gnutls_certificate_credentials_t type. |
p12blob | the PKCS12 blob. |
type | is PEM or DER of the `pkcs12file` . |
password | optional password used to decrypt PKCS12 file, bags and keys. |

#### Returns

On success this functions returns zero, and otherwise a negative value on error (see above for modifying that behavior).

Since: 2.8.0

### gnutls_certificate_set_x509_key ()

    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);

This function sets a certificate/private key pair in the gnutls_certificate_credentials_t type. This function may be called more than once, in case multiple keys/certificates exist for the server. For clients that wants to send more than their own end entity certificate (e.g., also an intermediate CA cert) then put the certificate chain in `cert_list` .

Note that the certificates and keys provided, can be safely deinitialized after this function is called.

If that function fails to load the `res` type is at an undefined state, it must not be reused to load other keys or certificates.

Note that, this function by default returns zero on success and a negative value on error. Since 3.5.6, when the flag `GNUTLS_CERTIFICATE_API_V2` is set using `gnutls_certificate_set_flags()` it returns an index (greater or equal to zero). That index can be used to other functions to refer to the added key-pair.

#### Parameters

res | is a gnutls_certificate_credentials_t type. |
cert_list | contains a certificate list (path) for the specified private key |
cert_list_size | holds the size of the certificate list |
key | is a gnutls_x509_privkey_t key |

#### Returns

On success this functions returns zero, and otherwise a negative value on error (see above for modifying that behavior).

Since: 2.4.0

### gnutls_certificate_set_x509_trust ()

    int
    gnutls_certificate_set_x509_trust (gnutls_certificate_credentials_t res,
                                       gnutls_x509_crt_t *ca_list,
                                       int ca_list_size);

This function adds the trusted CAs in order to verify client or server certificates. In case of a client this is not required to be called if the certificates are not verified using `gnutls_certificate_verify_peers2()`. This function may be called multiple times.

In case of a server the CAs set here will be sent to the client if a certificate request is sent. This can be disabled using `gnutls_certificate_send_x509_rdn_sequence()`.

#### Parameters

res | is a gnutls_certificate_credentials_t type. |
ca_list | is a list of trusted CAs |
ca_list_size | holds the size of the CA list |

#### Returns

the number of certificates processed or a negative error code on error.

Since: 2.4.0

### gnutls_certificate_set_x509_crl ()

    int
    gnutls_certificate_set_x509_crl (gnutls_certificate_credentials_t res,
                                     gnutls_x509_crl_t *crl_list,
                                     int crl_list_size);

This function adds the trusted CRLs in order to verify client or server certificates. In case of a client this is not required to be called if the certificates are not verified using `gnutls_certificate_verify_peers2()`. This function may be called multiple times.

#### Parameters

res | is a gnutls_certificate_credentials_t type. |
crl_list | is a list of trusted CRLs. They should have been verified before. |
crl_list_size | holds the size of the crl_list |

#### Returns

number of CRLs processed, or a negative error code on error.

Since: 2.4.0

### gnutls_certificate_get_x509_key ()

    int
    gnutls_certificate_get_x509_key (gnutls_certificate_credentials_t res,
                                     unsigned  index,
                                     gnutls_x509_privkey_t *key);

Obtains a X.509 private key that has been stored in `res` with one of `gnutls_certificate_set_x509_key()`, `gnutls_certificate_set_key()`, `gnutls_certificate_set_x509_key_file()`, `gnutls_certificate_set_x509_key_file2()`, `gnutls_certificate_set_x509_key_mem()`, or `gnutls_certificate_set_x509_key_mem2()`. The returned key must be deallocated with `gnutls_x509_privkey_deinit()` when no longer needed.

The `index` matches the return value of `gnutls_certificate_set_x509_key()` and friends functions, when the `GNUTLS_CERTIFICATE_API_V2` flag is set.

If there is no key with the given index, `GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE` is returned. If the key with the given index is not a X.509 key, `GNUTLS_E_INVALID_REQUEST` is returned.

#### Parameters

res | is a gnutls_certificate_credentials_t type. |
index | The index of the key to obtain. |
key | Location to store the key. |

#### Returns

`GNUTLS_E_SUCCESS` (0) on success, or a negative error code.

Since: 3.4.0

### gnutls_certificate_get_x509_crt ()

    int
    gnutls_certificate_get_x509_crt (gnutls_certificate_credentials_t res,
                                     unsigned  index,
                                     gnutls_x509_crt_t **crt_list,
                                     unsigned *crt_list_size);

Obtains a X.509 certificate list that has been stored in `res` with one of `gnutls_certificate_set_x509_key()`, `gnutls_certificate_set_key()`, `gnutls_certificate_set_x509_key_file()`, `gnutls_certificate_set_x509_key_file2()`, `gnutls_certificate_set_x509_key_mem()`, or `gnutls_certificate_set_x509_key_mem2()`. Each certificate in the returned certificate list must be deallocated with `gnutls_x509_crt_deinit()`, and the list itself must be freed with `gnutls_free()`.

The `index` matches the return value of `gnutls_certificate_set_x509_key()` and friends functions, when the `GNUTLS_CERTIFICATE_API_V2` flag is set.

If there is no certificate with the given index, `GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE` is returned. If the certificate with the given index is not a X.509 certificate, `GNUTLS_E_INVALID_REQUEST` is returned. The returned certificates must be deinitialized after use, and the `crt_list` pointer must be freed using `gnutls_free()`.

#### Parameters

res | is a gnutls_certificate_credentials_t type. |
index | The index of the certificate list to obtain. |
crt_list | Where to store the certificate list. |
crt_list_size | Will hold the number of certificates. |

#### Returns

`GNUTLS_E_SUCCESS` (0) on success, or a negative error code.

Since: 3.4.0

### gnutls_status_request_ocsp_func ()

    int
    (*gnutls_status_request_ocsp_func) (gnutls_session_t session,
                                        void *ptr,
                                        gnutls_datum_t *ocsp_response);

### gnutls_certificate_set_ocsp_status_request_function ()

    void
    gnutls_certificate_set_ocsp_status_request_function
                                   (gnutls_certificate_credentials_t res,
                                    gnutls_status_request_ocsp_func ocsp_func,
                                    void *ptr);

This function is to be used by server to register a callback to handle OCSP status requests from the client. The callback will be invoked if the client supplied a status-request OCSP extension. The callback function prototype is:

typedef int (*gnutls_status_request_ocsp_func) (gnutls_session_t session, void *ptr, gnutls_datum_t *ocsp_response);

The callback will be invoked if the client requests an OCSP certificate status. The callback may return `GNUTLS_E_NO_CERTIFICATE_STATUS`, if there is no recent OCSP response. If the callback returns `GNUTLS_E_SUCCESS`, it is expected to have the `ocsp_response` field set with a valid (DER-encoded) OCSP response. The response must be a value allocated using `gnutls_malloc()`, and will be deinitialized by the caller.

It is possible to set a specific callback for each provided certificate using `gnutls_certificate_set_ocsp_status_request_function2()`.

#### Parameters

sc | is a gnutls_certificate_credentials_t type. |
ocsp_func | function pointer to OCSP status request callback. |
ptr | opaque pointer passed to callback function |

Since: 3.1.3

### gnutls_certificate_set_ocsp_status_request_function2 ()

    int
    gnutls_certificate_set_ocsp_status_request_function2
                                   (gnutls_certificate_credentials_t res,
                                    unsigned  idx,
                                    gnutls_status_request_ocsp_func ocsp_func,
                                    void *ptr);

This function is to be used by server to register a callback to provide OCSP status requests that correspond to the indexed certificate chain from the client. The callback will be invoked if the client supplied a status-request OCSP extension.

The callback function prototype is:

typedef int (*gnutls_status_request_ocsp_func) (gnutls_session_t session, void *ptr, gnutls_datum_t *ocsp_response);

The callback will be invoked if the client requests an OCSP certificate status. The callback may return `GNUTLS_E_NO_CERTIFICATE_STATUS`, if there is no recent OCSP response. If the callback returns `GNUTLS_E_SUCCESS`, it is expected to have the `ocsp_response` field set with a valid (DER-encoded) OCSP response. The response must be a value allocated using `gnutls_malloc()`, and will be deinitialized by the caller.

Note: the ability to set multiple OCSP responses per credential structure via the index `idx` was added in version 3.5.6. To keep backwards compatibility, it requires using `gnutls_certificate_set_flags()` with the `GNUTLS_CERTIFICATE_API_V2` flag to make the set certificate functions return an index usable by this function.

#### Parameters

sc | is a gnutls_certificate_credentials_t type. |
idx | is a certificate index as returned by `gnutls_certificate_set_key()` and friends |
ocsp_func | function pointer to OCSP status request callback. |
ptr | opaque pointer passed to callback function |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

Since: 3.5.5

### gnutls_certificate_set_ocsp_status_request_file ()

    int
    gnutls_certificate_set_ocsp_status_request_file
                                   (gnutls_certificate_credentials_t res,
                                    const char *response_file,
                                    unsigned  idx);

This function loads the provided OCSP response. It will be sent to the client if requests an OCSP certificate status for the certificate chain specified by `idx` .

Note: the ability to set multiple OCSP responses per credential structure via the index `idx` was added in version 3.5.6. To keep backwards compatibility, it requires using `gnutls_certificate_set_flags()` with the `GNUTLS_CERTIFICATE_API_V2` flag to make the set certificate functions return an index usable by this function.

This function can be called multiple times since GnuTLS 3.6.3 when multiple responses which apply to the chain are available. If the response provided does not match any certificates present in the chain, the code `GNUTLS_E_OCSP_MISMATCH_WITH_CERTS` is returned. To revert to the previous behavior set the flag `GNUTLS_CERTIFICATE_SKIP_OCSP_RESPONSE_CHECK` in the certificate credentials structure. In that case, only the end-certificate's OCSP response can be set. If the response is already expired at the time of loading the code `GNUTLS_E_EXPIRED` is returned.

To revert to the previous behavior of this function which does not return any errors, set the flag `GNUTLS_CERTIFICATE_SKIP_OCSP_RESPONSE_CHECK`

#### Parameters

sc | is a credentials structure. |
response_file | a filename of the OCSP response |
idx | is a certificate index as returned by `gnutls_certificate_set_key()` and friends |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

Since: 3.1.3

### gnutls_certificate_set_ocsp_status_request_file2 ()

    int
    gnutls_certificate_set_ocsp_status_request_file2
                                   (gnutls_certificate_credentials_t res,
                                    const char *response_file,
                                    unsigned  idx,
                                    gnutls_x509_crt_fmt_t fmt);

This function loads the OCSP responses to be sent to the peer for the certificate chain specified by `idx` . When `fmt` is set to PEM, multiple responses can be loaded.

This function must be called after setting any certificates, and cannot be used for certificates that are provided via a callback -- that is when `gnutls_certificate_set_retrieve_function()` is used. In that case consider using `gnutls_certificate_set_retrieve_function3()`.

This function can be called multiple times when multiple responses applicable to the certificate chain are available. If the response provided does not match any certificates present in the chain, the code `GNUTLS_E_OCSP_MISMATCH_WITH_CERTS` is returned. If the response is already expired at the time of loading the code `GNUTLS_E_EXPIRED` is returned.

#### Parameters

sc | is a credentials structure. |
response_file | a filename of the OCSP response |
idx | is a certificate index as returned by `gnutls_certificate_set_key()` and friends |
fmt | is PEM or DER |

#### Returns

On success, the number of loaded responses is returned, otherwise a negative error code.

Since: 3.1.3

### gnutls_certificate_set_ocsp_status_request_mem ()

    int
    gnutls_certificate_set_ocsp_status_request_mem
                                   (gnutls_certificate_credentials_t res,
                                    const gnutls_datum_t *resp,
                                    unsigned  idx,
                                    gnutls_x509_crt_fmt_t fmt);

This function sets the OCSP responses to be sent to the peer for the certificate chain specified by `idx` . When `fmt` is set to PEM, multiple responses can be loaded.

Note: the ability to set multiple OCSP responses per credential structure via the index `idx` was added in version 3.5.6. To keep backwards compatibility, it requires using `gnutls_certificate_set_flags()` with the `GNUTLS_CERTIFICATE_API_V2` flag to make the set certificate functions return an index usable by this function.

This function must be called after setting any certificates, and cannot be used for certificates that are provided via a callback -- that is when `gnutls_certificate_set_retrieve_function()` is used.

This function can be called multiple times when multiple responses which apply to the certificate chain are available. If the response provided does not match any certificates present in the chain, the code `GNUTLS_E_OCSP_MISMATCH_WITH_CERTS` is returned. If the response is already expired at the time of loading the code `GNUTLS_E_EXPIRED` is returned.

#### Parameters

sc | is a credentials structure. |
resp_data | a memory buffer holding an OCSP response |
idx | is a certificate index as returned by `gnutls_certificate_set_key()` and friends |
fmt | is PEM or DER |

#### Returns

On success, the number of loaded responses is returned, otherwise a negative error code.

Since: 3.6.3

### gnutls_certificate_get_ocsp_expiration ()

    time_t
    gnutls_certificate_get_ocsp_expiration
                                   (gnutls_certificate_credentials_t sc,
                                    unsigned  idx,
                                    int oidx,
                                    unsigned  flags);

This function returns the validity of the loaded OCSP responses, to provide information on when to reload/refresh them.

Note that the credentials structure should be read-only when in use, thus when reloading, either the credentials structure must not be in use by any sessions, or a new credentials structure should be allocated for new sessions.

When `oidx` is (-1) then the minimum refresh time for all responses is returned. Otherwise the index specifies the response corresponding to the `odix` certificate in the certificate chain.

#### Parameters

sc | is a credentials structure. |
idx | is a certificate chain index as returned by `gnutls_certificate_set_key()` and friends |
oidx | is an OCSP response index |
flags | should be zero |

#### Returns

On success, the expiration time of the OCSP response. Otherwise (time_t)(-1) on error, or (time_t)-2 on out of bounds.

Since: 3.6.3

### gnutls_ocsp_status_request_enable_client ()

    int
    gnutls_ocsp_status_request_enable_client
                                   (gnutls_session_t session,
                                    gnutls_datum_t *responder_id,
                                    size_t responder_id_size,
                                    gnutls_datum_t *request_extensions);

This function is to be used by clients to request OCSP response from the server, using the "status_request" TLS extension. Only OCSP status type is supported.

Previous versions of GnuTLS supported setting `responder_id` and `extensions` fields, but due to the difficult semantics of the parameter usage, and other issues, this support was removed since 3.6.0 and these parameters must be set to `NULL`.

#### Parameters

session | is a gnutls_session_t type. |
responder_id | ignored, must be `NULL` |
responder_id_size | ignored, must be zero |
extensions | ignored, must be `NULL` |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

Since: 3.1.3

### gnutls_ocsp_status_request_get ()

    int
    gnutls_ocsp_status_request_get (gnutls_session_t session,
                                    gnutls_datum_t *response);

This function returns the OCSP status response received from the TLS server. The `response` should be treated as constant. If no OCSP response is available then `GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE` is returned.

#### Parameters

session | is a gnutls_session_t type. |
response | a gnutls_datum_t with DER encoded OCSP response |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

Since: 3.1.3

### gnutls_ocsp_status_request_is_checked ()

    unsigned
    gnutls_ocsp_status_request_is_checked (gnutls_session_t session,
                                           unsigned int flags);

When flags are zero this function returns non-zero if a valid OCSP status response was included in the TLS handshake. That is, an OCSP status response which is not too old, superseded or marks the certificate as revoked. It returns zero otherwise.

When the flag `GNUTLS_OCSP_SR_IS_AVAIL` is specified, the function returns non-zero if an OCSP status response was included in the handshake even if it was invalid. Otherwise, if no OCSP status response was included, it returns zero. The `GNUTLS_OCSP_SR_IS_AVAIL` flag was introduced in GnuTLS 3.4.0.

This is a helper function when needing to decide whether to perform an explicit OCSP validity check on the peer's certificate. Should be called after any of gnutls_certificate_verify_peers*() are called.

This function is always usable on client side, but on server side only under TLS 1.3, which is the first version of TLS that allows clients to send OCSP responses.

#### Parameters

session | is a gnutls session |
flags | should be zero or `GNUTLS_OCSP_SR_IS_AVAIL` |

#### Returns

Non-zero if the response was valid, or a zero if it wasn't sent, or sent and was invalid.

Since: 3.1.4

### gnutls_ocsp_status_request_get2 ()

    int
    gnutls_ocsp_status_request_get2 (gnutls_session_t session,
                                     unsigned  idx,
                                     gnutls_datum_t *response);

This function returns the OCSP status response received from the TLS server for the certificate index provided. The index corresponds to certificates as returned by gnutls_certificate_get_peers. When index is zero this function operates identically to `gnutls_ocsp_status_request_get()`.

The returned `response` should be treated as constant. If no OCSP response is available for the given index then `GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE` is returned.

#### Parameters

session | is a gnutls_session_t type. |
idx | the index of peer's certificate |
response | a gnutls_datum_t with DER encoded OCSP response |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

Since: 3.6.3

### gnutls_certificate_set_rawpk_key_mem ()

    int
    gnutls_certificate_set_rawpk_key_mem (gnutls_certificate_credentials_t cred,
                                          const gnutls_datum_t *spki,
                                          const gnutls_datum_t *pkey,
                                          gnutls_x509_crt_fmt_t format,
                                          const char *pass,
                                          unsigned int key_usage,
                                          const char **names,
                                          unsigned int names_length,
                                          unsigned int flags);

This function sets a public/private keypair in the gnutls_certificate_credentials_t type to be used for authentication and/or encryption. `spki` and `privkey` should match otherwise set signatures cannot be validated. In case of no match this function returns `GNUTLS_E_CERTIFICATE_KEY_MISMATCH`. This function should be called once for the client because there is currently no mechanism to determine which raw public-key to select for the peer when there are multiple present. Multiple raw public keys for the server can be distinghuished by setting the `names` .

Note here that `spki` is a raw public-key as defined in RFC7250. It means that there is no surrounding certificate that holds the public key and that there is therefore no direct mechanism to prove the authenticity of this key. The keypair can be used during a TLS handshake but its authenticity should be established via a different mechanism (e.g. TOFU or known fingerprint).

The supported formats are basic unencrypted key, PKCS8, PKCS12, and the openssl format and will be autodetected.

If the raw public-key and the private key are given in PEM encoding then the strings that hold their values must be null terminated.

Key usage (as defined by X.509 extension (2.5.29.15)) can be explicitly set because there is no certificate structure around the key to define this value. See for more info `gnutls_x509_crt_get_key_usage()`.

Note that, this function by default returns zero on success and a negative value on error. Since 3.5.6, when the flag `GNUTLS_CERTIFICATE_API_V2` is set using `gnutls_certificate_set_flags()` it returns an index (greater or equal to zero). That index can be used in other functions to refer to the added key-pair.

#### Parameters

cred | is a gnutls_certificate_credentials_t type. |
spki | contains a raw public key in PKIX.SubjectPublicKeyInfo format. |
pkey | contains a raw private key. |
format | encoding of the keys. DER or PEM. |
pass | an optional password to unlock the private key pkey. |
key_usage | An ORed sequence of `GNUTLS_KEY_`* flags. |
names | is an array of DNS names belonging to the public-key (NULL if none). |
names_length | holds the length of the names list. |
flags | an ORed sequence of gnutls_pkcs_encrypt_flags_t. These apply to the private key pkey. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, in case the key pair does not match `GNUTLS_E_CERTIFICATE_KEY_MISMATCH` is returned, in other erroneous cases a different negative error code is returned.

Since: 3.6.6

### gnutls_certificate_set_rawpk_key_file ()

    int
    gnutls_certificate_set_rawpk_key_file (gnutls_certificate_credentials_t cred,
                                           const char *rawpkfile,
                                           const char *privkeyfile,
                                           gnutls_x509_crt_fmt_t format,
                                           const char *pass,
                                           unsigned int key_usage,
                                           const char **names,
                                           unsigned int names_length,
                                           unsigned int privkey_flags,
                                           unsigned int pkcs11_flags);

This function sets a public/private keypair read from file in the gnutls_certificate_credentials_t type to be used for authentication and/or encryption. `spki` and `privkey` should match otherwise set signatures cannot be validated. In case of no match this function returns `GNUTLS_E_CERTIFICATE_KEY_MISMATCH`. This function should be called once for the client because there is currently no mechanism to determine which raw public-key to select for the peer when there are multiple present. Multiple raw public keys for the server can be distinghuished by setting the `names` .

Note here that `spki` is a raw public-key as defined in RFC7250. It means that there is no surrounding certificate that holds the public key and that there is therefore no direct mechanism to prove the authenticity of this key. The keypair can be used during a TLS handshake but its authenticity should be established via a different mechanism (e.g. TOFU or known fingerprint).

The supported formats are basic unencrypted key, PKCS8, PKCS12, and the openssl format and will be autodetected.

If the raw public-key and the private key are given in PEM encoding then the strings that hold their values must be null terminated.

Key usage (as defined by X.509 extension (2.5.29.15)) can be explicitly set because there is no certificate structure around the key to define this value. See for more info `gnutls_x509_crt_get_key_usage()`.

Note that, this function by default returns zero on success and a negative value on error. Since 3.5.6, when the flag `GNUTLS_CERTIFICATE_API_V2` is set using `gnutls_certificate_set_flags()` it returns an index (greater or equal to zero). That index can be used in other functions to refer to the added key-pair.

#### Parameters

cred | is a gnutls_certificate_credentials_t type. |
rawpkfile | contains a raw public key in PKIX.SubjectPublicKeyInfo format. |
privkeyfile | contains a file path to a private key. |
format | encoding of the keys. DER or PEM. |
pass | an optional password to unlock the private key privkeyfile. |
key_usage | an ORed sequence of `GNUTLS_KEY_`* flags. |
names | is an array of DNS names belonging to the public-key (NULL if none). |
names_length | holds the length of the names list. |
privkey_flags | an ORed sequence of gnutls_pkcs_encrypt_flags_t. These apply to the private key pkey. |
pkcs11_flags | one of gnutls_pkcs11_obj_flags. These apply to URLs. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, in case the key pair does not match `GNUTLS_E_CERTIFICATE_KEY_MISMATCH` is returned, in other erroneous cases a different negative error code is returned.

Since: 3.6.6

### gnutls_global_init ()

    int
    gnutls_global_init (void);

Since GnuTLS 3.3.0 this function is no longer necessary to be explicitly called. To disable the implicit call (in a library constructor) of this function set the environment variable `GNUTLS_NO_IMPLICIT_INIT` to 1.

This function performs any required precalculations, detects the supported CPU capabilities and initializes the underlying cryptographic backend. In order to free any resources taken by this call you should `gnutls_global_deinit()` when gnutls usage is no longer needed.

This function increments a global counter, so that `gnutls_global_deinit()` only releases resources when it has been called as many times as `gnutls_global_init()`. This is useful when GnuTLS is used by more than one library in an application. This function can be called many times, but will only do something the first time. It is thread safe since GnuTLS 3.3.0.

A subsequent call of this function if the initial has failed will return the same error code.

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

### gnutls_global_deinit ()

    void
    gnutls_global_deinit (void);

This function deinitializes the global data, that were initialized using `gnutls_global_init()`.

Since GnuTLS 3.3.0 this function is no longer necessary to be explicitly called. GnuTLS will automatically deinitialize on library destructor. See `gnutls_global_init()` for disabling the implicit initialization/deinitialization.

### gnutls_get_library_config ()

    const gnutls_library_config_st *
    gnutls_get_library_config (void);

Returns the library configuration as key value pairs. Currently defined keys are:

- fips-module-name: the name of the FIPS140 module

- fips-module-version: the version of the FIPS140 module

- libgnutls-soname: the SONAME of the library itself

- libnettle-soname: the library SONAME of linked libnettle

- libhogweed-soname: the library SONAME of linked libhogweed

- libgmp-soname: the library SONAME of linked libgmp

- hardware-features: enabled hardware support features

- tls-features: enabled TLS protocol features

#### Returns

a NUL-terminated `gnutls_library_config_st` array

Since: 3.7.3

### gnutls_time_func ()

    time_t
    (*gnutls_time_func) (time_t *t);

Function prototype for `time()`-like function. Set with `gnutls_global_set_time_function()`.

#### Parameters

t | where to store time. |

#### Returns

Number of seconds since the epoch, or (time_t)-1 on errors.

### mutex_init_func ()

    int
    (*mutex_init_func) (void **mutex);

### mutex_lock_func ()

    int
    (*mutex_lock_func) (void **mutex);

### mutex_unlock_func ()

    int
    (*mutex_unlock_func) (void **mutex);

### mutex_deinit_func ()

    int
    (*mutex_deinit_func) (void **mutex);

### gnutls_global_set_mutex ()

    void
    gnutls_global_set_mutex (mutex_init_func init,
                             mutex_deinit_func deinit,
                             mutex_lock_func lock,
                             mutex_unlock_func unlock);

`gnutls_global_set_mutex` is deprecated and should not be used in newly-written code.

This function is discouraged on GnuTLS 3.7.3 or later.

With this function you are allowed to override the default mutex locks used in some parts of gnutls and dependent libraries. This function should be used if you have complete control of your program and libraries. Do not call this function from a library, or preferably from any application unless really needed to. GnuTLS will use the appropriate locks for the running system.

This function must be called prior to any other GnuTLS function; otherwise the behavior is undefined.

#### Parameters

init | mutex initialization function |
deinit | mutex deinitialization function |
lock | mutex locking function |
unlock | mutex unlocking function |

Since: 2.12.0

### gnutls_alloc_function ()

    void *
    (*gnutls_alloc_function) (size_t Param1);

### gnutls_calloc_function ()

    void *
    (*gnutls_calloc_function) (size_t Param1,
                               size_t Param2);

### gnutls_is_secure_function ()

    int
    (*gnutls_is_secure_function) (const void *Param1);

### gnutls_free_function ()

    void
    (*gnutls_free_function) (void *Param1);

### gnutls_realloc_function ()

    void *
    (*gnutls_realloc_function) (void *Param1,
                                size_t Param2);

### gnutls_global_set_time_function ()

    void
    gnutls_global_set_time_function (gnutls_time_func time_func);

This is the function where you can override the default system time function. The application provided function should behave the same as the standard function.

#### Parameters

time_func | it's the system time function, a `gnutls_time_func()` callback. |

Since: 2.12.0

### gnutls_free()

    #define gnutls_free(a) gnutls_free((void *)(a)), a = NULL

This function will free data pointed by ptr.

The deallocation function used is the one set by `gnutls_global_set_mem_functions()`.

#### Parameters

ptr | pointer to memory |

### gnutls_memset ()

    void
    gnutls_memset (void *data,
                   int c,
                   size_t size);

This function will operate similarly to `memset()`, but will not be optimized out by the compiler.

#### Parameters

data | the memory to set |
c | the constant byte to fill the memory with |
size | the size of memory |

Since: 3.4.0

### gnutls_memcmp ()

    if
    gnutls_memcmp ();

This function will operate similarly to `memcmp()`, but will operate on time that depends only on the size of the string. That is will not return early if the strings don't match on the first byte.

#### Parameters

s1 | the first address to compare |
s2 | the second address to compare |
n | the size of memory to compare |

#### Returns

non zero on difference and zero if the buffers are identical.

Since: 3.4.0

### gnutls_log_func ()

    void
    (*gnutls_log_func) (int Param1,
                        const char *Param2);

### gnutls_audit_log_func ()

    void
    (*gnutls_audit_log_func) (gnutls_session_t Param1,
                              const char *Param2);

### gnutls_global_set_log_function ()

    void
    gnutls_global_set_log_function (gnutls_log_func log_func);

This is the function where you set the logging function gnutls is going to use. This function only accepts a character array. Normally you may not use this function since it is only used for debugging purposes.

`gnutls_log_func` is of the form, void (*gnutls_log_func)( int level, const char*);

#### Parameters

log_func | it's a log function |

### gnutls_global_set_audit_log_function ()

    void
    gnutls_global_set_audit_log_function (gnutls_audit_log_func log_func);

This is the function to set the audit logging function. This is a function to report important issues, such as possible attacks in the protocol. This is different from `gnutls_global_set_log_function()` because it will report also session-specific events. The session parameter will be null if there is no corresponding TLS session.

`gnutls_audit_log_func` is of the form, void (*gnutls_audit_log_func)( gnutls_session_t, const char*);

#### Parameters

log_func | it is the audit log function |

Since: 3.0

### gnutls_global_set_log_level ()

    void
    gnutls_global_set_log_level (int level);

This is the function that allows you to set the log level. The level is an integer between 0 and 9. Higher values mean more verbosity. The default value is 0. Larger values should only be used with care, since they may reveal sensitive information.

Use a log level over 10 to enable all debugging options.

#### Parameters

level | it's an integer from 0 to 99. |

### gnutls_keylog_func ()

    int
    (*gnutls_keylog_func) (gnutls_session_t session,
                           const char *label,
                           const gnutls_datum_t *secret);

Function prototype for keylog hooks. It is set using `gnutls_session_set_keylog_function()`.

#### Parameters

session | the current session |
label | the keylog label |
secret | the (const) data of the derived secret. |

#### Returns

Non zero on error.

Since: 3.6.13

### gnutls_session_get_keylog_function ()

    gnutls_keylog_func
    gnutls_session_get_keylog_function (const gnutls_session_t session);

This function will return the callback function set using `gnutls_session_set_keylog_function()`.

#### Parameters

session | is gnutls_session_t type |

#### Returns

The function set or `NULL` otherwise.

Since: 3.6.13

### gnutls_session_set_keylog_function ()

    void
    gnutls_session_set_keylog_function (gnutls_session_t session,
                                        gnutls_keylog_func func);

This function will set a callback to be called when a new secret is derived and installed during handshake.

#### Parameters

session | is gnutls_session_t type |
func | is the function to be called |

Since: 3.6.13

### gnutls_dh_params_init ()

    int
    gnutls_dh_params_init (gnutls_dh_params_t *dh_params);

This function will initialize the DH parameters type.

#### Parameters

dh_params | The parameters |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

### gnutls_dh_params_deinit ()

    void
    gnutls_dh_params_deinit (gnutls_dh_params_t dh_params);

This function will deinitialize the DH parameters type.

#### Parameters

dh_params | The parameters |

### gnutls_dh_params_import_raw ()

    int
    gnutls_dh_params_import_raw (gnutls_dh_params_t dh_params,
                                 const gnutls_datum_t *prime,
                                 const gnutls_datum_t *generator);

This function will replace the pair of prime and generator for use in the Diffie-Hellman key exchange. The new parameters should be stored in the appropriate gnutls_datum.

#### Parameters

dh_params | The parameters |
prime | holds the new prime |
generator | holds the new generator |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

### gnutls_dh_params_import_dsa ()

    int
    gnutls_dh_params_import_dsa (gnutls_dh_params_t dh_params,
                                 gnutls_x509_privkey_t key);

This function will import the prime and generator of the DSA key for use in the Diffie-Hellman key exchange.

#### Parameters

dh_params | The parameters |
key | holds a DSA private key |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

### gnutls_dh_params_import_raw2 ()

    int
    gnutls_dh_params_import_raw2 (gnutls_dh_params_t dh_params,
                                  const gnutls_datum_t *prime,
                                  const gnutls_datum_t *generator,
                                  unsigned  key_bits);

This function will replace the pair of prime and generator for use in the Diffie-Hellman key exchange. The new parameters should be stored in the appropriate gnutls_datum.

#### Parameters

dh_params | The parameters |
prime | holds the new prime |
generator | holds the new generator |
key_bits | the private key bits (set to zero when unknown) |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

### gnutls_dh_params_import_raw3 ()

    int
    gnutls_dh_params_import_raw3 (gnutls_dh_params_t dh_params,
                                  const gnutls_datum_t *prime,
                                  const gnutls_datum_t *q,
                                  const gnutls_datum_t *generator);

This function will replace the pair of prime and generator for use in the Diffie-Hellman key exchange. The new parameters should be stored in the appropriate gnutls_datum.

#### Parameters

dh_params | The parameters |
prime | holds the new prime |
q | holds the subgroup if available, otherwise NULL |
generator | holds the new generator |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

### gnutls_dh_params_import_pkcs3 ()

    int
    gnutls_dh_params_import_pkcs3 (gnutls_dh_params_t params,
                                   const gnutls_datum_t *pkcs3_params,
                                   gnutls_x509_crt_fmt_t format);

This function will extract the DHParams found in a PKCS3 formatted structure. This is the format generated by "openssl dhparam" tool.

If the structure is PEM encoded, it should have a header of "BEGIN DH PARAMETERS".

#### Parameters

params | The parameters |
pkcs3_params | should contain a PKCS3 DHParams structure PEM or DER encoded |
format | the format of params. PEM or DER. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

### gnutls_dh_params_generate2 ()

    int
    gnutls_dh_params_generate2 (gnutls_dh_params_t params,
                                unsigned int bits);

This function will generate a new pair of prime and generator for use in the Diffie-Hellman key exchange. This may take long time.

It is recommended not to set the number of bits directly, but use `gnutls_sec_param_to_pk_bits()` instead.

Also note that the DH parameters are only useful to servers. Since clients use the parameters sent by the server, it's of no use to call this in client side.

The parameters generated are of the DSA form. It also is possible to generate provable parameters (following the Shawe-Taylor algorithm), using `gnutls_x509_privkey_generate2()` with DSA option and the `GNUTLS_PRIVKEY_FLAG_PROVABLE` flag set. These can the be imported with `gnutls_dh_params_import_dsa()`.

It is no longer recommended for applications to generate parameters. See the "Parameter generation" section in the manual.

#### Parameters

dparams | The parameters |
bits | is the prime's number of bits |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

### gnutls_dh_params_export_pkcs3 ()

    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);

This function will export the given dh parameters to a PKCS3 DHParams structure. This is the format generated by "openssl dhparam" tool. If the buffer provided is not long enough to hold the output, then GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.

If the structure is PEM encoded, it will have a header of "BEGIN DH PARAMETERS".

#### Parameters

params | Holds the DH parameters |
format | the format of output params. One of PEM or DER. |
params_data | will contain a PKCS3 DHParams structure PEM or DER encoded |
params_data_size | holds the size of params_data (and will be replaced by the actual size of parameters) |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

### gnutls_dh_params_export2_pkcs3 ()

    int
    gnutls_dh_params_export2_pkcs3 (gnutls_dh_params_t params,
                                    gnutls_x509_crt_fmt_t format,
                                    gnutls_datum_t *out);

This function will export the given dh parameters to a PKCS3 DHParams structure. This is the format generated by "openssl dhparam" tool. The data in `out` will be allocated using `gnutls_malloc()`.

If the structure is PEM encoded, it will have a header of "BEGIN DH PARAMETERS".

#### Parameters

params | Holds the DH parameters |
format | the format of output params. One of PEM or DER. |
out | will contain a PKCS3 DHParams structure PEM or DER encoded |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

Since: 3.1.3

### gnutls_dh_params_export_raw ()

    int
    gnutls_dh_params_export_raw (gnutls_dh_params_t params,
                                 gnutls_datum_t *prime,
                                 gnutls_datum_t *generator,
                                 unsigned int *bits);

This function will export the pair of prime and generator for use in the Diffie-Hellman key exchange. The new parameters will be allocated using `gnutls_malloc()` and will be stored in the appropriate datum.

#### Parameters

params | Holds the DH parameters |
prime | will hold the new prime |
generator | will hold the new generator |
bits | if non null will hold the secret key's number of bits |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

### gnutls_dh_params_cpy ()

    int
    gnutls_dh_params_cpy (gnutls_dh_params_t dst,
                          gnutls_dh_params_t src);

This function will copy the DH parameters structure from source to destination. The destination should be already initialized.

#### Parameters

dst | Is the destination parameters, which should be initialized. |
src | Is the source parameters |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error code is returned.

### gnutls_pull_func ()

    ssize_t
    (*gnutls_pull_func) (gnutls_transport_ptr_t Param1,
                         void *Param2,
                         size_t Param3);

### gnutls_push_func ()

    ssize_t
    (*gnutls_push_func) (gnutls_transport_ptr_t Param1,
                         const void *Param2,
                         size_t Param3);

### gnutls_system_recv_timeout ()

    int
    gnutls_system_recv_timeout (gnutls_transport_ptr_t ptr,
                                unsigned int ms);

Wait for data to be received from the provided socket (`ptr` ) within a timeout period in milliseconds, using `select()` on the provided `ptr` .

This function is provided as a helper for constructing custom callbacks for `gnutls_transport_set_pull_timeout_function()`, which can be used if you rely on socket file descriptors.

Returns -1 on error, 0 on timeout, positive value if data are available for reading.

#### Parameters

ptr | A file descriptor (wrapped in a gnutls_transport_ptr_t pointer) |
ms | The number of milliseconds to wait. |

Since: 3.4.0

### gnutls_pull_timeout_func ()

    int
    (*gnutls_pull_timeout_func) (gnutls_transport_ptr_t Param1,
                                 unsigned int ms);

### gnutls_vec_push_func ()

    ssize_t
    (*gnutls_vec_push_func) (gnutls_transport_ptr_t Param1,
                             const giovec_t *iov,
                             int iovcnt);

### gnutls_errno_func ()

    int
    (*gnutls_errno_func) (gnutls_transport_ptr_t Param1);

### gnutls_transport_set_int ()

    void
    gnutls_transport_set_int (gnutls_session_t session,
                              int r);

This function sets the first argument of the transport function, such as `send()` and `recv()` for the default callbacks using the system's socket API.

This function is equivalent to calling `gnutls_transport_set_ptr()` with the descriptor, but requires no casts.

#### Parameters

session | is a gnutls_session_t type. |
fd | is the socket descriptor for the connection. |

Since: 3.1.9

### gnutls_transport_set_int2 ()

    void
    gnutls_transport_set_int2 (gnutls_session_t session,
                               int r,
                               int s);

This function sets the first argument of the transport functions, such as `send()` and `recv()` for the default callbacks using the system's socket API. With this function you can set two different descriptors for receiving and sending.

This function is equivalent to calling `gnutls_transport_set_ptr2()` with the descriptors, but requires no casts.

#### Parameters

session | is a gnutls_session_t type. |
recv_fd | is socket descriptor for the pull function |
send_fd | is socket descriptor for the push function |

Since: 3.1.9

### gnutls_transport_get_int2 ()

    void
    gnutls_transport_get_int2 (gnutls_session_t session,
                               int *r,
                               int *s);

Used to get the arguments of the transport functions (like PUSH and PULL). These should have been set using `gnutls_transport_set_int2()`.

#### Parameters

session | is a gnutls_session_t type. |
recv_int | will hold the value for the pull function |
send_int | will hold the value for the push function |

Since: 3.1.9

### gnutls_transport_get_int ()

    int
    gnutls_transport_get_int (gnutls_session_t session);

Used to get the first argument of the transport function (like PUSH and PULL). This must have been set using `gnutls_transport_set_int()`.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

The first argument of the transport function.

Since: 3.1.9

### gnutls_transport_set_ptr ()

    void
    gnutls_transport_set_ptr (gnutls_session_t session,
                              gnutls_transport_ptr_t ptr);

Used to set the first argument of the transport function (for push and pull callbacks). In berkeley style sockets this function will set the connection descriptor.

#### Parameters

session | is a gnutls_session_t type. |
ptr | is the value. |

### gnutls_transport_set_ptr2 ()

    void
    gnutls_transport_set_ptr2 (gnutls_session_t session,
                               gnutls_transport_ptr_t recv_ptr,
                               gnutls_transport_ptr_t send_ptr);

Used to set the first argument of the transport function (for push and pull callbacks). In berkeley style sockets this function will set the connection descriptor. With this function you can use two different pointers for receiving and sending.

#### Parameters

session | is a gnutls_session_t type. |
recv_ptr | is the value for the pull function |
send_ptr | is the value for the push function |

### gnutls_transport_get_ptr ()

    return
    gnutls_transport_get_ptr (s Param1);

Used to get the first argument of the transport function (like PUSH and PULL). This must have been set using `gnutls_transport_set_ptr()`.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

The first argument of the transport function.

### gnutls_transport_get_ptr2 ()

    void
    gnutls_transport_get_ptr2 (gnutls_session_t session,
                               gnutls_transport_ptr_t *recv_ptr,
                               gnutls_transport_ptr_t *send_ptr);

Used to get the arguments of the transport functions (like PUSH and PULL). These should have been set using `gnutls_transport_set_ptr2()`.

#### Parameters

session | is a gnutls_session_t type. |
recv_ptr | will hold the value for the pull function |
send_ptr | will hold the value for the push function |

### gnutls_transport_set_vec_push_function ()

    void
    gnutls_transport_set_vec_push_function
                                   (gnutls_session_t session,
                                    gnutls_vec_push_func vec_func);

Using this function you can override the default writev(2) function for gnutls to send data. Setting this callback instead of `gnutls_transport_set_push_function()` is recommended since it introduces less overhead in the TLS handshake process.

`vec_func` is of the form, ssize_t (*gnutls_vec_push_func) (gnutls_transport_ptr_t, const giovec_t * iov, int iovcnt);

#### Parameters

session | is a gnutls_session_t type. |
vec_func | a callback function similar to `writev()` |

Since: 2.12.0

### gnutls_transport_set_push_function ()

    void
    gnutls_transport_set_push_function (gnutls_session_t session,
                                        gnutls_push_func push_func);

This is the function where you set a push function for gnutls to use in order to send data. If you are going to use berkeley style sockets, you do not need to use this function since the default send(2) will probably be ok. Otherwise you should specify this function for gnutls to be able to send data. The callback should return a positive number indicating the bytes sent, and -1 on error.

`push_func` is of the form, ssize_t (*gnutls_push_func)(gnutls_transport_ptr_t, const void*, size_t);

#### Parameters

session | is a gnutls_session_t type. |
push_func | a callback function similar to `write()` |

### gnutls_transport_set_pull_function ()

    void
    gnutls_transport_set_pull_function (gnutls_session_t session,
                                        gnutls_pull_func pull_func);

This is the function where you set a function for gnutls to receive data. Normally, if you use berkeley style sockets, do not need to use this function since the default recv(2) will probably be ok. The callback should return 0 on connection termination, a positive number indicating the number of bytes received, and -1 on error.

`gnutls_pull_func` is of the form, ssize_t (*gnutls_pull_func)(gnutls_transport_ptr_t, void*, size_t);

#### Parameters

session | is a gnutls_session_t type. |
pull_func | a callback function similar to `read()` |

### gnutls_transport_set_pull_timeout_function ()

    void
    gnutls_transport_set_pull_timeout_function
                                   (gnutls_session_t session,
                                    gnutls_pull_timeout_func func);

This is the function where you set a function for gnutls to know whether data are ready to be received. It should wait for data a given time frame in milliseconds. The callback should return 0 on timeout, a positive number if data can be received, and -1 on error. You'll need to override this function if `select()` is not suitable for the provided transport calls.

As with `select()`, if the timeout value is zero the callback should return zero if no data are immediately available. The special value `GNUTLS_INDEFINITE_TIMEOUT` indicates that the callback should wait indefinitely for data.

`gnutls_pull_timeout_func` is of the form, int (*gnutls_pull_timeout_func)(gnutls_transport_ptr_t, unsigned int ms);

This callback is necessary when `gnutls_handshake_set_timeout()` or `gnutls_record_set_timeout()` are set, under TLS1.3 and for enforcing the DTLS mode timeouts when in blocking mode.

For compatibility with future GnuTLS versions this callback must be set when a custom pull function is registered. The callback will not be used when the session is in TLS mode with non-blocking sockets. That is, when `GNUTLS_NONBLOCK` is specified for a TLS session in `gnutls_init()`.

The helper function `gnutls_system_recv_timeout()` is provided to simplify writing callbacks.

#### Parameters

session | is a gnutls_session_t type. |
func | a callback function |

Since: 3.0

### gnutls_transport_set_errno_function ()

    void
    gnutls_transport_set_errno_function (gnutls_session_t session,
                                         gnutls_errno_func errno_func);

This is the function where you set a function to retrieve errno after a failed push or pull operation.

`errno_func` is of the form, int (*gnutls_errno_func)(gnutls_transport_ptr_t); and should return the errno.

#### Parameters

session | is a gnutls_session_t type. |
errno_func | a callback function similar to `write()` |

Since: 2.12.0

### gnutls_transport_set_errno ()

    void
    gnutls_transport_set_errno (gnutls_session_t session,
                                int err);

Store `err` in the session-specific errno variable. Useful values for `err` are EINTR, EAGAIN and EMSGSIZE, other values are treated will be treated as real errors in the push/pull function.

This function is useful in replacement push and pull functions set by `gnutls_transport_set_push_function()` and `gnutls_transport_set_pull_function()` under Windows, where the replacements may not have access to the same `errno` variable that is used by GnuTLS (e.g., the application is linked to msvcr71.dll and gnutls is linked to msvcrt.dll).

This function is unreliable if you are using the same `session` in different threads for sending and receiving.

#### Parameters

session | is a gnutls_session_t type. |
err | error value to store in session-specific errno variable. |

### gnutls_session_set_ptr ()

    void
    gnutls_session_set_ptr (gnutls_session_t session,
                            void *ptr);

This function will set (associate) the user given pointer `ptr` to the session structure. This pointer can be accessed with `gnutls_session_get_ptr()`.

#### Parameters

session | is a gnutls_session_t type. |
ptr | is the user pointer |

### gnutls_session_get_ptr ()

    return
    gnutls_session_get_ptr (s Param1);

Get user pointer for session. Useful in callbacks. This is the pointer set with `gnutls_session_set_ptr()`.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

the user given pointer from the session structure, or `NULL` if it was never set.

### gnutls_openpgp_send_cert ()

    void
    gnutls_openpgp_send_cert (gnutls_session_t session,
                              gnutls_openpgp_crt_status_t status);

### gnutls_fingerprint ()

    int
    gnutls_fingerprint (gnutls_digest_algorithm_t algo,
                        const gnutls_datum_t *data,
                        void *result,
                        size_t *result_size);

This function will calculate a fingerprint (actually a hash), of the given data. The result is not printable data. You should convert it to hex, or to something else printable.

This is the usual way to calculate a fingerprint of an X.509 DER encoded certificate. Note however that the fingerprint of an OpenPGP certificate is not just a hash and cannot be calculated with this function.

#### Parameters

algo | is a digest algorithm |
data | is the data |
result | is the place where the result will be copied (may be null). |
result_size | should hold the size of the result. The actual size of the returned result will also be copied there. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

### gnutls_random_art ()

    int
    gnutls_random_art (gnutls_random_art_t type,
                       const char *key_type,
                       unsigned int key_size,
                       void *fpr,
                       size_t fpr_size,
                       gnutls_datum_t *art);

This function will convert a given fingerprint to an "artistic" image. The returned image is allocated using `gnutls_malloc()`, is null-terminated but art->size will not account the terminating null.

#### Parameters

type | The type of the random art (for now only `GNUTLS_RANDOM_ART_OPENSSH` is supported) |
key_type | The type of the key (RSA, DSA etc.) |
key_size | The size of the key in bits |
fpr | The fingerprint of the key |
fpr_size | The size of the fingerprint |
art | The returned random art |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

### gnutls_idna_map ()

    int
    gnutls_idna_map (const char *input,
                     unsigned  ilen,
                     gnutls_datum_t *out,
                     unsigned  flags);

This function will convert the provided UTF-8 domain name, to its IDNA mapping in an allocated variable. Note that depending on the flags the used gnutls library was compiled with, the output of this function may vary (i.e., may be IDNA2008, or IDNA2003).

To force IDNA2008 specify the flag `GNUTLS_IDNA_FORCE_2008`. In the case GnuTLS is not compiled with the necessary dependencies, `GNUTLS_E_UNIMPLEMENTED_FEATURE` will be returned to indicate that gnutls is unable to perform the requested conversion.

Note also, that this function will return an empty string if an empty string is provided as input.

#### Parameters

input | contain the UTF-8 formatted domain name |
ilen | the length of the provided string |
out | the result in an null-terminated allocated string |
flags | should be zero |

#### Returns

`GNUTLS_E_INVALID_UTF8_STRING` on invalid UTF-8 data, or 0 on success.

Since: 3.5.8

### gnutls_idna_reverse_map ()

    int
    gnutls_idna_reverse_map (const char *input,
                             unsigned  ilen,
                             gnutls_datum_t *out,
                             unsigned  flags);

This function will convert an ACE (ASCII-encoded) domain name to a UTF-8 domain name.

If GnuTLS is compiled without IDNA support, then this function will return `GNUTLS_E_UNIMPLEMENTED_FEATURE`.

Note also, that this function will return an empty string if an empty string is provided as input.

#### Parameters

input | contain the ACE (IDNA) formatted domain name |
ilen | the length of the provided string |
out | the result in an null-terminated allocated UTF-8 string |
flags | should be zero |

#### Returns

A negative error code on error, or 0 on success.

Since: 3.5.8

### gnutls_srp_free_client_credentials ()

    void
    gnutls_srp_free_client_credentials (gnutls_srp_client_credentials_t sc);

Free a gnutls_srp_client_credentials_t structure.

#### Parameters

sc | is a gnutls_srp_client_credentials_t type. |

### gnutls_srp_allocate_client_credentials ()

    int
    gnutls_srp_allocate_client_credentials
                                   (gnutls_srp_client_credentials_t *sc);

Allocate a gnutls_srp_client_credentials_t structure.

#### Parameters

sc | is a pointer to a gnutls_srp_server_credentials_t type. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, or an error code.

### gnutls_srp_set_client_credentials ()

    int
    gnutls_srp_set_client_credentials (gnutls_srp_client_credentials_t res,
                                       const char *username,
                                       const char *password);

This function sets the username and password, in a gnutls_srp_client_credentials_t type. Those will be used in SRP authentication. `username` should be an ASCII string or UTF-8 string. In case of a UTF-8 string it is recommended to be following the PRECIS framework for usernames (rfc8265). The password can be in ASCII format, or normalized using `gnutls_utf8_password_normalize()`.

#### Parameters

res | is a gnutls_srp_client_credentials_t type. |
username | is the user's userid |
password | is the user's password |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, or an error code.

### gnutls_srp_free_server_credentials ()

    void
    gnutls_srp_free_server_credentials (gnutls_srp_server_credentials_t sc);

Free a gnutls_srp_server_credentials_t structure.

#### Parameters

sc | is a gnutls_srp_server_credentials_t type. |

### gnutls_srp_allocate_server_credentials ()

    int
    gnutls_srp_allocate_server_credentials
                                   (gnutls_srp_server_credentials_t *sc);

Allocate a gnutls_srp_server_credentials_t structure.

#### Parameters

sc | is a pointer to a gnutls_srp_server_credentials_t type. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, or an error code.

### gnutls_srp_set_server_credentials_file ()

    int
    gnutls_srp_set_server_credentials_file
                                   (gnutls_srp_server_credentials_t res,
                                    const char *password_file,
                                    const char *password_conf_file);

This function sets the password files, in a gnutls_srp_server_credentials_t type. Those password files hold usernames and verifiers and will be used for SRP authentication.

#### Parameters

res | is a gnutls_srp_server_credentials_t type. |
password_file | is the SRP password file (tpasswd) |
password_conf_file | is the SRP password conf file (tpasswd.conf) |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, or an error code.

### gnutls_srp_server_get_username ()

    return
    gnutls_srp_server_get_username (s Param1);

This function will return the username of the peer. This should only be called in case of SRP authentication and in case of a server. Returns NULL in case of an error.

#### Parameters

session | is a gnutls session |

#### Returns

SRP username of the peer, or NULL in case of error.

### gnutls_srp_set_prime_bits ()

    void
    gnutls_srp_set_prime_bits (gnutls_session_t session,
                               unsigned int bits);

This function sets the minimum accepted number of bits, for use in an SRP key exchange. If zero, the default 2048 bits will be used.

In the client side it sets the minimum accepted number of bits. If a server sends a prime with less bits than that `GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER` will be returned by the handshake.

This function has no effect in server side.

#### Parameters

session | is a gnutls_session_t type. |
bits | is the number of bits |

Since: 2.6.0

### gnutls_srp_verifier ()

    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);

This function will create an SRP verifier, as specified in RFC2945. The `prime` and `generator` should be one of the static parameters defined in gnutls/gnutls.h or may be generated.

The verifier will be allocated with ``gnutls_malloc()`` and will be stored in `res` using binary format.

#### Parameters

username | is the user's name |
password | is the user's password |
salt | should be some randomly generated bytes |
generator | is the generator of the group |
prime | is the group's prime |
res | where the verifier will be stored. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, or an error code.

### gnutls_srp_set_server_credentials_function ()

    void
    gnutls_srp_set_server_credentials_function
                                   (gnutls_srp_server_credentials_t cred,
                                    gnutls_srp_server_credentials_function *func);

This function can be used to set a callback to retrieve the user's SRP credentials. The callback's function form is:

int (*callback)(gnutls_session_t, const char* username, gnutls_datum_t *salt, gnutls_datum_t *verifier, gnutls_datum_t *generator, gnutls_datum_t *prime);

`username` contains the actual username. The `salt` , `verifier` , `generator` and `prime` must be filled in using the `gnutls_malloc()`. For convenience `prime` and `generator` may also be one of the static parameters defined in gnutls.h.

Initially, the data field is NULL in every gnutls_datum_t structure that the callback has to fill in. When the callback is done GnuTLS deallocates all of those buffers which are non-NULL, regardless of the return value.

In order to prevent attackers from guessing valid usernames, if a user does not exist, g and n values should be filled in using a random user's parameters. In that case the callback must return the special value (1). See gnutls_srp_set_server_fake_salt_seed too. If this is not required for your application, return a negative number from the callback to abort the handshake.

The callback function will only be called once per handshake. The callback function should return 0 on success, while -1 indicates an error.

#### Parameters

cred | is a gnutls_srp_server_credentials_t type. |
func | is the callback function |

### gnutls_srp_set_client_credentials_function ()

    void
    gnutls_srp_set_client_credentials_function
                                   (gnutls_srp_client_credentials_t cred,
                                    gnutls_srp_client_credentials_function *func);

This function can be used to set a callback to retrieve the username and password for client SRP authentication. The callback's function form is:

int (*callback)(gnutls_session_t, char** username, char**password);

The `username` and `password` must be allocated using `gnutls_malloc()`.

The `username` should be an ASCII string or UTF-8 string. In case of a UTF-8 string it is recommended to be following the PRECIS framework for usernames (rfc8265). The password can be in ASCII format, or normalized using `gnutls_utf8_password_normalize()`.

The callback function will be called once per handshake before the initial hello message is sent.

The callback should not return a negative error code the second time called, since the handshake procedure will be aborted.

The callback function should return 0 on success. -1 indicates an error.

#### Parameters

cred | is a gnutls_srp_server_credentials_t type. |
func | is the callback function |

### gnutls_srp_base64_encode ()

    int
    gnutls_srp_base64_encode (const gnutls_datum_t *data,
                              char *result,
                              size_t *result_size);

This function will convert the given data to printable data, using the base64 encoding, as used in the libsrp. This is the encoding used in SRP password files. If the provided buffer is not long enough GNUTLS_E_SHORT_MEMORY_BUFFER is returned.

Warning! This base64 encoding is not the "standard" encoding, so do not use it for non-SRP purposes.

#### Parameters

data | contain the raw data |
result | the place where base64 data will be copied |
result_size | holds the size of the result |

#### Returns

`GNUTLS_E_SHORT_MEMORY_BUFFER` if the buffer given is not long enough, or 0 on success.

### gnutls_srp_base64_encode2 ()

    int
    gnutls_srp_base64_encode2 (const gnutls_datum_t *data,
                               gnutls_datum_t *result);

This function will convert the given data to printable data, using the base64 encoding. This is the encoding used in SRP password files. This function will allocate the required memory to hold the encoded data.

You should use `gnutls_free()` to free the returned data.

Warning! This base64 encoding is not the "standard" encoding, so do not use it for non-SRP purposes.

#### Parameters

data | contains the raw data |
result | will hold the newly allocated encoded data |

#### Returns

0 on success, or an error code.

### gnutls_srp_base64_decode ()

    int
    gnutls_srp_base64_decode (const gnutls_datum_t *b64_data,
                              char *result,
                              size_t *result_size);

This function will decode the given encoded data, using the base64 encoding found in libsrp.

Note that `b64_data` should be null terminated.

Warning! This base64 encoding is not the "standard" encoding, so do not use it for non-SRP purposes.

#### Parameters

b64_data | contain the encoded data |
result | the place where decoded data will be copied |
result_size | holds the size of the result |

#### Returns

`GNUTLS_E_SHORT_MEMORY_BUFFER` if the buffer given is not long enough, or 0 on success.

### gnutls_srp_base64_decode2 ()

    int
    gnutls_srp_base64_decode2 (const gnutls_datum_t *b64_data,
                               gnutls_datum_t *result);

This function will decode the given encoded data. The decoded data will be allocated, and stored into result. It will decode using the base64 algorithm as used in libsrp.

You should use `gnutls_free()` to free the returned data.

Warning! This base64 encoding is not the "standard" encoding, so do not use it for non-SRP purposes.

#### Parameters

b64_data | contains the encoded data |
result | the place where decoded data lie |

#### Returns

0 on success, or an error code.

### gnutls_srp_set_server_fake_salt_seed ()

    void
    gnutls_srp_set_server_fake_salt_seed (gnutls_srp_server_credentials_t sc,
                                          const gnutls_datum_t *seed,
                                          unsigned int salt_length);

This function sets the seed that is used to generate salts for invalid (non-existent) usernames.

In order to prevent attackers from guessing valid usernames, when a user does not exist gnutls generates a salt and a verifier and proceeds with the protocol as usual. The authentication will ultimately fail, but the client cannot tell whether the username is valid (exists) or invalid.

If an attacker learns the seed, given a salt (which is part of the handshake) which was generated when the seed was in use, it can tell whether or not the authentication failed because of an unknown username. This seed cannot be used to reveal application data or passwords.

`salt_length` should represent the salt length your application uses. Generating fake salts longer than 20 bytes is not supported.

By default the seed is a random value, different each time a gnutls_srp_server_credentials_t is allocated and fake salts are 16 bytes long.

#### Parameters

cred | is a gnutls_srp_server_credentials_t type |
seed | is the seed data, only needs to be valid until the function returns; size of the seed must be greater than zero |
salt_length | is the length of the generated fake salts |

Since: 3.3.0

### gnutls_psk_free_client_credentials ()

    void
    gnutls_psk_free_client_credentials (gnutls_psk_client_credentials_t sc);

Free a gnutls_psk_client_credentials_t structure.

#### Parameters

sc | is a gnutls_psk_client_credentials_t type. |

### gnutls_psk_allocate_client_credentials ()

    int
    gnutls_psk_allocate_client_credentials
                                   (gnutls_psk_client_credentials_t *sc);

Allocate a gnutls_psk_client_credentials_t structure.

#### Parameters

sc | is a pointer to a gnutls_psk_client_credentials_t type. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

### gnutls_psk_allocate_client_credentials2 ()

    int
    gnutls_psk_allocate_client_credentials2
                                   (gnutls_psk_client_credentials_t *sc,
                                    gnutls_mac_algorithm_t mac);

Allocate a gnutls_psk_client_credentials_t structure and initializes the HMAC binder algorithm to `mac` .

#### Parameters

sc | is a pointer to a gnutls_psk_client_credentials_t type. |
mac | encryption algorithm to use |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

### gnutls_psk_set_client_credentials ()

    int
    gnutls_psk_set_client_credentials (gnutls_psk_client_credentials_t res,
                                       const char *username,
                                       const gnutls_datum_t *key,
                                       gnutls_psk_key_flags flags);

This function sets the username and password, in a gnutls_psk_client_credentials_t type. Those will be used in PSK authentication. `username` should be an ASCII string or UTF-8 string. In case of a UTF-8 string it is recommended to be following the PRECIS framework for usernames (rfc8265). The key can be either in raw byte format or in Hex format (without the 0x prefix).

#### Parameters

res | is a gnutls_psk_client_credentials_t type. |
username | is the user's zero-terminated userid |
key | is the user's key |
flags | indicate the format of the key, either `GNUTLS_PSK_KEY_RAW` or `GNUTLS_PSK_KEY_HEX`. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

### gnutls_psk_set_client_credentials2 ()

    int
    gnutls_psk_set_client_credentials2 (gnutls_psk_client_credentials_t res,
                                        const gnutls_datum_t *username,
                                        const gnutls_datum_t *key,
                                        gnutls_psk_key_flags flags);

This function is identical to `gnutls_psk_set_client_credentials()`, except that it allows a non-null-terminated username to be introduced.

#### Parameters

res | is a gnutls_psk_client_credentials_t type. |
username | is the userid |
key | is the user's key |
flags | indicate the format of the key, either `GNUTLS_PSK_KEY_RAW` or `GNUTLS_PSK_KEY_HEX`. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

### gnutls_psk_free_server_credentials ()

    void
    gnutls_psk_free_server_credentials (gnutls_psk_server_credentials_t sc);

Free a gnutls_psk_server_credentials_t structure.

#### Parameters

sc | is a gnutls_psk_server_credentials_t type. |

### gnutls_psk_allocate_server_credentials ()

    int
    gnutls_psk_allocate_server_credentials
                                   (gnutls_psk_server_credentials_t *sc);

Allocate a gnutls_psk_server_credentials_t structure.

#### Parameters

sc | is a pointer to a gnutls_psk_server_credentials_t type. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

### gnutls_psk_allocate_server_credentials2 ()

    int
    gnutls_psk_allocate_server_credentials2
                                   (gnutls_psk_server_credentials_t *sc,
                                    gnutls_mac_algorithm_t mac);

Allocate a gnutls_psk_server_credentials_t structure and initializes the HMAC binder algorithm to `mac` . If `mac` is set to GNUTLS_MAC_UNKNOWN both possible algorithms SHA384 and SHA256 are applied to find a matching binder value.

#### Parameters

sc | is a pointer to a gnutls_psk_server_credentials_t type. |
mac | encryption algorithm to use |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

### gnutls_psk_set_server_credentials_file ()

    int
    gnutls_psk_set_server_credentials_file
                                   (gnutls_psk_server_credentials_t res,
                                    const char *password_file);

This function sets the password file, in a gnutls_psk_server_credentials_t type. This password file holds usernames and keys and will be used for PSK authentication.

Each entry in the file consists of a username, followed by a colon (':') and a hex-encoded key. If the username contains a colon or any other special character, it can be hex-encoded preceded by a '#'.

#### Parameters

res | is a gnutls_psk_server_credentials_t type. |
password_file | is the PSK password file (passwd.psk) |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

### gnutls_psk_set_server_credentials_hint ()

    int
    gnutls_psk_set_server_credentials_hint
                                   (gnutls_psk_server_credentials_t res,
                                    const char *hint);

This function sets the identity hint, in a gnutls_psk_server_credentials_t type. This hint is sent to the client to help it chose a good PSK credential (i.e., username and password).

#### Parameters

res | is a gnutls_psk_server_credentials_t type. |
hint | is the PSK identity hint string |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

Since: 2.4.0

### gnutls_psk_server_get_username ()

    return
    gnutls_psk_server_get_username (s Param1);

This should only be called in case of PSK authentication and in case of a server.

The returned pointer should be considered constant (do not free) and valid for the lifetime of the session.

This function will return `NULL` if the username has embedded NULL bytes. In that case, `gnutls_psk_server_get_username2()` should be used to retrieve the username.

#### Parameters

session | is a gnutls session |

#### Returns

the username of the peer, or `NULL` in case of an error, or if the username has embedded NULLs.

### gnutls_psk_server_get_username2 ()

    int
    gnutls_psk_server_get_username2 (gnutls_session_t session,
                                     gnutls_datum_t *out);

Return a pointer to the username of the peer in the supplied datum. Does not need to be null-terminated.

This should only be called in case of PSK authentication and in case of a server.

The returned pointer should be considered constant (do not free) and valid for the lifetime of the session.

#### Parameters

session | is a gnutls session |
username | a datum that will be filled in by this function |

#### Returns

`GNUTLS_E_SUCCESS`, or a negative value in case of an error.

### gnutls_psk_client_get_hint ()

    const char *
    gnutls_psk_client_get_hint (gnutls_session_t session);

The PSK identity hint may give the client help in deciding which username to use. This should only be called in case of PSK authentication and in case of a client.

Note: there is no hint in TLS 1.3, so this function will return `NULL` if TLS 1.3 has been negotiated.

#### Parameters

session | is a gnutls session |

#### Returns

the identity hint of the peer, or `NULL` in case of an error or if TLS 1.3 is being used.

Since: 2.4.0

### gnutls_psk_set_server_credentials_function ()

    void
    gnutls_psk_set_server_credentials_function
                                   (gnutls_psk_server_credentials_t cred,
                                    gnutls_psk_server_credentials_function *func);

This function can be used to set a callback to retrieve the user's PSK credentials. The callback's function form is: int (*callback)(gnutls_session_t, const char* username, gnutls_datum_t* key);

`username` contains the actual username. The `key` must be filled in using the `gnutls_malloc()`.

In case the callback returned a negative number then gnutls will assume that the username does not exist.

The callback function will only be called once per handshake. The callback function should return 0 on success, while -1 indicates an error.

#### Parameters

cred | is a gnutls_psk_server_credentials_t type. |
func | is the callback function |

### gnutls_psk_set_server_credentials_function2 ()

    void
    gnutls_psk_set_server_credentials_function2
                                   (gnutls_psk_server_credentials_t cred,
                                    gnutls_psk_server_credentials_function2 *func);

This function can be used to set a callback to retrieve the user's PSK credentials. The callback's function form is: int (*callback)(gnutls_session_t, const gnutls_datum_t* username, gnutls_datum_t* key);

This callback function has the same semantics as that of `gnutls_psk_set_server_credentials_function()`, but it allows non-string usernames to be used.

`username` contains the actual username. The `key` must be filled in using the `gnutls_malloc()`.

In case the callback returned a negative number then gnutls will assume that the username does not exist.

The callback function will only be called once per handshake. The callback function should return 0 on success, while -1 indicates an error.

#### Parameters

cred | is a gnutls_psk_server_credentials_t type. |
func | is the callback function |

### gnutls_psk_set_server_credentials_function3 ()

    void
    gnutls_psk_set_server_credentials_function3
                                   (gnutls_psk_server_credentials_t cred,
                                    gnutls_psk_server_credentials_function3 *func);

This function can be used to set a callback to retrieve the user's PSK credentials. The callback's function form is: int (*callback)(gnutls_session_t, const gnutls_datum_t* username, gnutls_datum_t* key, gnutls_psk_key_flags *flags);

This callback function has the same semantics as that of `gnutls_psk_set_server_credentials_function2()`, but it returns flags associated with the key. The callback may import external PSK using the method described in RFC 9258 by using `gnutls_psk_format_imported_identity()`.

`username` contains the actual username. The `key` must be filled in using the `gnutls_malloc()`.

In case the callback returned a negative number then gnutls will assume that the username does not exist.

The callback function will only be called once per handshake. The callback function should return 0 on success, while -1 indicates an error.

#### Parameters

cred | is a gnutls_psk_server_credentials_t type. |
func | is the callback function |

### gnutls_psk_format_imported_identity ()

    int
    gnutls_psk_format_imported_identity (const gnutls_datum_t *identity,
                                         const gnutls_datum_t *context,
                                         gnutls_protocol_t version,
                                         gnutls_digest_algorithm_t hash,
                                         gnutls_datum_t *imported_identity);

This formats an external PSK identity `identity` into an imported form, described in RFC 9258 as ImportedIdentity.

Upon success, the data field of `imported_identity` is allocated using `gnutls_malloc()` and the caller must free the memory after use.

#### Parameters

identity | external identity |
context | optional contextual information |
version | protocol version to which the PSK is imported |
hash | hash algorithm used for KDF |
imported_identity | where the imported identity is stored |

#### Returns

`GNUTLS_E_SUCCESS` (0) on success, otherwise a negative error code.

Since: 3.8.1

### gnutls_psk_set_client_credentials_function ()

    void
    gnutls_psk_set_client_credentials_function
                                   (gnutls_psk_client_credentials_t cred,
                                    gnutls_psk_client_credentials_function *func);

This function can be used to set a callback to retrieve the username and password for client PSK authentication. The callback's function form is: int (*callback)(gnutls_session_t, char** username, gnutls_datum_t* key);

The `username` and `key->data` must be allocated using `gnutls_malloc()`. The `username` should be an ASCII string or UTF-8 string. In case of a UTF-8 string it is recommended to be following the PRECIS framework for usernames (rfc8265).

The callback function will be called once per handshake.

The callback function should return 0 on success. -1 indicates an error.

#### Parameters

cred | is a gnutls_psk_server_credentials_t type. |
func | is the callback function |

### gnutls_psk_set_client_credentials_function2 ()

    void
    gnutls_psk_set_client_credentials_function2
                                   (gnutls_psk_client_credentials_t cred,
                                    gnutls_psk_client_credentials_function2 *func);

This function can be used to set a callback to retrieve the username and password for client PSK authentication. The callback's function form is: int (*callback)(gnutls_session_t, gnutls_datum_t* username, gnutls_datum_t* key);

This callback function has the same semantics as that of `gnutls_psk_set_client_credentials_function()`, but it allows non-string usernames to be used.

The `username` and `key->data` must be allocated using `gnutls_malloc()`. The `username` should be an ASCII string or UTF-8 string. In case of a UTF-8 string it is recommended to be following the PRECIS framework for usernames (rfc8265).

The callback function will be called once per handshake.

The callback function should return 0 on success. -1 indicates an error.

#### Parameters

cred | is a gnutls_psk_server_credentials_t type. |
func | is the callback function |

### gnutls_psk_set_client_credentials_function3 ()

    void
    gnutls_psk_set_client_credentials_function3
                                   (gnutls_psk_client_credentials_t cred,
                                    gnutls_psk_client_credentials_function3 *func);

This function can be used to set a callback to retrieve the username and password for client PSK authentication. The callback's function form is: int (*callback)(gnutls_session_t, gnutls_datum_t* username, gnutls_datum_t* key, gnutls_datum_t* context, gnutls_psk_key_flags *flags);

This callback function has the same semantics as that of `gnutls_psk_set_client_credentials_function2()`, but it returns flags associated with the key. The callback may import external PSK using the method described in RFC 9258 by using `gnutls_psk_format_imported_identity()`.

The data field of `username` , `key` , and `context` must be allocated using `gnutls_malloc()`. The `username` should be an ASCII string or UTF-8 string. In case of a UTF-8 string it is recommended to be following the PRECIS framework for usernames (rfc8265).

The callback function will be called once per handshake.

The callback function should return 0 on success. -1 indicates an error.

#### Parameters

cred | is a gnutls_psk_server_credentials_t type. |
func | is the callback function |

### gnutls_hex_encode ()

    int
    gnutls_hex_encode (const gnutls_datum_t *data,
                       char *result,
                       size_t *result_size);

This function will convert the given data to printable data, using the hex encoding, as used in the PSK password files.

Note that the size of the result includes the null terminator.

#### Parameters

data | contain the raw data |
result | the place where hex data will be copied |
result_size | holds the size of the result |

#### Returns

`GNUTLS_E_SHORT_MEMORY_BUFFER` if the buffer given is not long enough, or 0 on success.

### gnutls_hex_decode ()

    int
    gnutls_hex_decode (const gnutls_datum_t *hex_data,
                       void *result,
                       size_t *result_size);

This function will decode the given encoded data, using the hex encoding used by PSK password files.

Initially `result_size` must hold the maximum size available in `result` , and on return it will contain the number of bytes written.

#### Parameters

hex_data | contain the encoded data |
result | the place where decoded data will be copied |
result_size | holds the size of the result |

#### Returns

`GNUTLS_E_SHORT_MEMORY_BUFFER` if the buffer given is not long enough, `GNUTLS_E_PARSING_ERROR` on invalid hex data, or 0 on success.

### gnutls_hex_encode2 ()

    int
    gnutls_hex_encode2 (const gnutls_datum_t *data,
                        gnutls_datum_t *result);

This function will convert the given data to printable data, using the hex encoding, as used in the PSK password files.

Note that the size of the result does NOT include the null terminator.

#### Parameters

data | contain the raw data |
result | the result in an allocated string |

#### Returns

`GNUTLS_E_SUCCESS` on success, otherwise a negative error code.

### gnutls_hex_decode2 ()

    int
    gnutls_hex_decode2 (const gnutls_datum_t *data,
                        gnutls_datum_t *result);

This function will decode the given encoded data, using the hex encoding used by PSK password files.

#### Parameters

hex_data | contain the encoded data |
result | the result in an allocated string |

#### Returns

`GNUTLS_E_PARSING_ERROR` on invalid hex data, or 0 on success.

### gnutls_psk_set_server_dh_params ()

    void
    gnutls_psk_set_server_dh_params (gnutls_psk_server_credentials_t res,
                                     gnutls_dh_params_t dh_params);

`gnutls_psk_set_server_dh_params` is deprecated and should not be used in newly-written code.

This function is unnecessary and discouraged on GnuTLS 3.6.0 or later. Since 3.6.0, DH parameters are negotiated following RFC7919.

This function will set the Diffie-Hellman parameters for an anonymous server to use. These parameters will be used in Diffie-Hellman exchange with PSK cipher suites.

#### Parameters

res | is a gnutls_psk_server_credentials_t type |
dh_params | is a structure that holds Diffie-Hellman parameters. |

### gnutls_psk_set_server_known_dh_params ()

    int
    gnutls_psk_set_server_known_dh_params (gnutls_psk_server_credentials_t res,
                                           gnutls_sec_param_t sec_param);

`gnutls_psk_set_server_known_dh_params` is deprecated and should not be used in newly-written code.

This function is unnecessary and discouraged on GnuTLS 3.6.0 or later. Since 3.6.0, DH parameters are negotiated following RFC7919.

This function will set the Diffie-Hellman parameters for a PSK server to use. These parameters will be used in Ephemeral Diffie-Hellman cipher suites and will be selected from the FFDHE set of RFC7919 according to the security level provided.

#### Parameters

res | is a gnutls_psk_server_credentials_t type |
sec_param | is an option of the `gnutls_sec_param_t` enumeration |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error value.

Since: 3.5.6

### gnutls_psk_set_server_params_function ()

    void
    gnutls_psk_set_server_params_function (gnutls_psk_server_credentials_t res,
                                           gnutls_params_function *func);

`gnutls_psk_set_server_params_function` is deprecated and should not be used in newly-written code.

This function is unnecessary and discouraged on GnuTLS 3.6.0 or later. Since 3.6.0, DH parameters are negotiated following RFC7919.

This function will set a callback in order for the server to get the Diffie-Hellman parameters for PSK authentication. The callback should return `GNUTLS_E_SUCCESS` (0) on success.

#### Parameters

res | is a gnutls_certificate_credentials_t type |
func | is the function to be called |

### gnutls_dh_set_prime_bits ()

    void
    gnutls_dh_set_prime_bits (gnutls_session_t session,
                              unsigned int bits);

This function sets the number of bits, for use in a Diffie-Hellman key exchange. This is used both in DH ephemeral and DH anonymous cipher suites. This will set the minimum size of the prime that will be used for the handshake.

In the client side it sets the minimum accepted number of bits. If a server sends a prime with less bits than that `GNUTLS_E_DH_PRIME_UNACCEPTABLE` will be returned by the handshake.

Note that this function will warn via the audit log for value that are believed to be weak.

The function has no effect in server side.

Note that since 3.1.7 this function is deprecated. The minimum number of bits is set by the priority string level. Also this function must be called after `gnutls_priority_set_direct()` or the set value may be overridden by the selected priority options.

#### Parameters

session | is a gnutls_session_t type. |
bits | is the number of bits |

### gnutls_dh_get_secret_bits ()

    int
    gnutls_dh_get_secret_bits (gnutls_session_t session);

This function will return the bits used in the last Diffie-Hellman key exchange with the peer. Should be used for both anonymous and ephemeral Diffie-Hellman.

#### Parameters

session | is a gnutls session |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

### gnutls_dh_get_peers_public_bits ()

    int
    gnutls_dh_get_peers_public_bits (gnutls_session_t session);

Get the Diffie-Hellman public key bit size. Can be used for both anonymous and ephemeral Diffie-Hellman.

#### Parameters

session | is a gnutls session |

#### Returns

The public key bit size used in the last Diffie-Hellman key exchange with the peer, or a negative error code in case of error.

### gnutls_dh_get_prime_bits ()

    int
    gnutls_dh_get_prime_bits (gnutls_session_t session);

This function will return the bits of the prime used in the last Diffie-Hellman key exchange with the peer. Should be used for both anonymous and ephemeral Diffie-Hellman. Note that some ciphers, like RSA and DSA without DHE, do not use a Diffie-Hellman key exchange, and then this function will return 0.

#### Parameters

session | is a gnutls session |

#### Returns

The Diffie-Hellman bit strength is returned, or 0 if no Diffie-Hellman key exchange was done, or a negative error code on failure.

### gnutls_dh_get_group ()

    int
    gnutls_dh_get_group (gnutls_session_t session,
                         gnutls_datum_t *raw_gen,
                         gnutls_datum_t *raw_prime);

This function will return the group parameters used in the last Diffie-Hellman key exchange with the peer. These are the prime and the generator used. This function should be used for both anonymous and ephemeral Diffie-Hellman. The output parameters must be freed with `gnutls_free()`.

Note, that the prime and generator are exported as non-negative integers and may include a leading zero byte.

#### Parameters

session | is a gnutls session |
raw_gen | will hold the generator. |
raw_prime | will hold the prime. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

### gnutls_dh_get_pubkey ()

    int
    gnutls_dh_get_pubkey (gnutls_session_t session,
                          gnutls_datum_t *raw_key);

This function will return the peer's public key used in the last Diffie-Hellman key exchange. This function should be used for both anonymous and ephemeral Diffie-Hellman. The output parameters must be freed with `gnutls_free()`.

Note, that public key is exported as non-negative integer and may include a leading zero byte.

#### Parameters

session | is a gnutls session |
raw_key | will hold the public key. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

### gnutls_certificate_set_retrieve_function ()

    void
    gnutls_certificate_set_retrieve_function
                                   (gnutls_certificate_credentials_t cred,
                                    gnutls_certificate_retrieve_function *func);

This function sets a callback to be called in order to retrieve the certificate to be used in the handshake. The callback will take control only if a certificate is requested by the peer. You are advised to use `gnutls_certificate_set_retrieve_function2()` because it is much more efficient in the processing it requires from gnutls.

The callback's function prototype is: int (*callback)(gnutls_session_t, const gnutls_datum_t* req_ca_dn, int nreqs, const gnutls_pk_algorithm_t* pk_algos, int pk_algos_length, gnutls_retr2_st* st);

`req_ca_dn` is only used in X.509 certificates. Contains a list with the CA names that the server considers trusted. This is a hint and typically the client should send a certificate that is signed by one of these CAs. These names, when available, are DER encoded. To get a more meaningful value use the function `gnutls_x509_rdn_get()`.

`pk_algos` contains a list with server's acceptable public key algorithms. The certificate returned should support the server's given algorithms.

`st` should contain the certificates and private keys.

If the callback function is provided then gnutls will call it, in the handshake, after the certificate request message has been received.

In server side pk_algos and req_ca_dn are NULL.

The callback function should set the certificate list to be sent, and return 0 on success. If no certificate was selected then the number of certificates should be set to zero. The value (-1) indicates error and the handshake will be terminated. If both certificates are set in the credentials and a callback is available, the callback takes predence.

#### Parameters

cred | is a gnutls_certificate_credentials_t type. |
func | is the callback function |

Since: 3.0

### gnutls_certificate_set_verify_function ()

    void
    gnutls_certificate_set_verify_function
                                   (gnutls_certificate_credentials_t cred,
                                    gnutls_certificate_verify_function *func);

This function sets a callback to be called when peer's certificate has been received in order to verify it on receipt rather than doing after the handshake is completed.

The callback's function prototype is: int (*callback)(gnutls_session_t);

If the callback function is provided then gnutls will call it, in the handshake, just after the certificate message has been received. To verify or obtain the certificate the `gnutls_certificate_verify_peers2()`, `gnutls_certificate_type_get()`, `gnutls_certificate_get_peers()` functions can be used.

The callback function should return 0 for the handshake to continue or non-zero to terminate.

#### Parameters

cred | is a gnutls_certificate_credentials_t type. |
func | is the callback function |

Since: 2.10.0

### gnutls_certificate_server_set_request ()

    void
    gnutls_certificate_server_set_request (gnutls_session_t session,
                                           gnutls_certificate_request_t req);

This function specifies if we (in case of a server) are going to send a certificate request message to the client. If `req` is GNUTLS_CERT_REQUIRE then the server will return the `GNUTLS_E_NO_CERTIFICATE_FOUND` error if the peer does not provide a certificate. If you do not call this function then the client will not be asked to send a certificate. Invoking the function with `req` GNUTLS_CERT_IGNORE has the same effect.

#### Parameters

session | is a gnutls_session_t type. |
req | is one of GNUTLS_CERT_REQUEST, GNUTLS_CERT_REQUIRE, GNUTLS_CERT_IGNORE |

### gnutls_certificate_get_peers ()

    const gnutls_datum_t *
    gnutls_certificate_get_peers (gnutls_session_t session,
                                  unsigned int *list_size);

Get the peer's raw certificate (chain) as sent by the peer. These certificates are in raw format (DER encoded for X.509). In case of a X.509 then a certificate list may be present. The list is provided as sent by the server; the server must send as first certificate in the list its own certificate, following the issuer's certificate, then the issuer's issuer etc. However, there are servers which violate this principle and thus on certain occasions this may be an unsorted list.

In resumed sessions, this function will return the peer's certificate list as used in the first/original session.

#### Parameters

session | is a gnutls session |
list_size | is the length of the certificate list (may be `NULL`) |

#### Returns

a pointer to a gnutls_datum_t containing the peer's certificates, or `NULL` in case of an error or if no certificate was used.

### gnutls_certificate_get_ours ()

    const gnutls_datum_t *
    gnutls_certificate_get_ours (gnutls_session_t session);

Gets the certificate as sent to the peer in the last handshake. The certificate is in raw (DER) format. No certificate list is being returned. Only the first certificate.

This function returns the certificate that was sent in the current handshake. In subsequent resumed sessions this function will return `NULL`. That differs from `gnutls_certificate_get_peers()` which always returns the peer's certificate used in the original session.

#### Parameters

session | is a gnutls session |

#### Returns

a pointer to a gnutls_datum_t containing our certificate, or `NULL` in case of an error or if no certificate was used.

### gnutls_certificate_get_peers_subkey_id ()

    int
    gnutls_certificate_get_peers_subkey_id
                                   (gnutls_session_t session,
                                    gnutls_datum_t *id);

This function is no-op.

#### Parameters

session | is a gnutls session |
id | will contain the ID |

#### Returns

`GNUTLS_E_UNIMPLEMENTED_FEATURE`.

Since: 3.1.3

### gnutls_certificate_activation_time_peers ()

    return
    gnutls_certificate_activation_time_peers
                                   (s Param1);

`gnutls_certificate_activation_time_peers` is deprecated and should not be used in newly-written code.

gnutls_certificate_verify_peers2() now verifies activation times.

This function will return the peer's certificate activation time.

#### Parameters

session | is a gnutls session |

#### Returns

(time_t)-1 on error.

### gnutls_certificate_expiration_time_peers ()

    return
    gnutls_certificate_expiration_time_peers
                                   (s Param1);

`gnutls_certificate_expiration_time_peers` is deprecated and should not be used in newly-written code.

gnutls_certificate_verify_peers2() now verifies expiration times.

This function will return the peer's certificate expiration time.

#### Parameters

session | is a gnutls session |

#### Returns

(time_t)-1 on error.

### gnutls_certificate_client_get_request_status ()

    unsigned
    gnutls_certificate_client_get_request_status
                                   (gnutls_session_t session);

Get whether client certificate was requested on the last handshake or not.

#### Parameters

session | is a gnutls session |

#### Returns

0 if the peer (server) did not request client authentication or 1 otherwise.

### gnutls_certificate_verify_peers2 ()

    int
    gnutls_certificate_verify_peers2 (gnutls_session_t session,
                                      unsigned int *status);

This function will verify the peer's certificate and store the status in the `status` variable as a bitwise OR of gnutls_certificate_status_t values or zero if the certificate is trusted. Note that value in `status` is set only when the return value of this function is success (i.e, failure to trust a certificate does not imply a negative return value). The default verification flags used by this function can be overridden using `gnutls_certificate_set_verify_flags()`.

This function will take into account the stapled OCSP responses sent by the server, as well as the following X.509 certificate extensions: Name Constraints, Key Usage, and Basic Constraints (pathlen).

Note that you must also check the peer's name in order to check if the verified certificate belongs to the actual peer, see `gnutls_x509_crt_check_hostname()`, or use `gnutls_certificate_verify_peers3()`.

To avoid denial of service attacks some default upper limits regarding the certificate key size and chain size are set. To override them use `gnutls_certificate_set_verify_limits()`.

Note that when using raw public-keys verification will not work because there is no corresponding certificate body belonging to the raw key that can be verified. In that case this function will return `GNUTLS_E_INVALID_REQUEST`.

#### Parameters

session | is a gnutls session |
status | is the output of the verification |

#### Returns

`GNUTLS_E_SUCCESS` (0) when the validation is performed, or a negative error code otherwise. A successful error code means that the `status` parameter must be checked to obtain the validation status.

### gnutls_certificate_verify_peers3 ()

    int
    gnutls_certificate_verify_peers3 (gnutls_session_t session,
                                      const char *hostname,
                                      unsigned int *status);

This function will verify the peer's certificate and store the the status in the `status` variable as a bitwise OR of gnutls_certificate_status_t values or zero if the certificate is trusted. Note that value in `status` is set only when the return value of this function is success (i.e, failure to trust a certificate does not imply a negative return value). The default verification flags used by this function can be overridden using `gnutls_certificate_set_verify_flags()`. See the documentation of `gnutls_certificate_verify_peers2()` for details in the verification process.

This function will take into account the stapled OCSP responses sent by the server, as well as the following X.509 certificate extensions: Name Constraints, Key Usage, and Basic Constraints (pathlen).

If the `hostname` provided is non-NULL then this function will compare the hostname in the certificate against it. The comparison will follow the RFC6125 recommendations. If names do not match the `GNUTLS_CERT_UNEXPECTED_OWNER` status flag will be set.

In order to verify the purpose of the end-certificate (by checking the extended key usage), use `gnutls_certificate_verify_peers()`.

To avoid denial of service attacks some default upper limits regarding the certificate key size and chain size are set. To override them use `gnutls_certificate_set_verify_limits()`.

Note that when using raw public-keys verification will not work because there is no corresponding certificate body belonging to the raw key that can be verified. In that case this function will return `GNUTLS_E_INVALID_REQUEST`.

#### Parameters

session | is a gnutls session |
hostname | is the expected name of the peer; may be `NULL` |
status | is the output of the verification |

#### Returns

`GNUTLS_E_SUCCESS` (0) when the validation is performed, or a negative error code otherwise. A successful error code means that the `status` parameter must be checked to obtain the validation status.

Since: 3.1.4

### gnutls_certificate_verify_peers ()

    int
    gnutls_certificate_verify_peers (gnutls_session_t session,
                                     gnutls_typed_vdata_st *data,
                                     unsigned int elements,
                                     unsigned int *status);

This function will verify the peer's certificate and store the the status in the `status` variable as a bitwise OR of gnutls_certificate_status_t values or zero if the certificate is trusted. Note that value in `status` is set only when the return value of this function is success (i.e, failure to trust a certificate does not imply a negative return value). The default verification flags used by this function can be overridden using `gnutls_certificate_set_verify_flags()`. See the documentation of `gnutls_certificate_verify_peers2()` for details in the verification process.

This function will take into account the stapled OCSP responses sent by the server, as well as the following X.509 certificate extensions: Name Constraints, Key Usage, and Basic Constraints (pathlen).

The acceptable `data` types are `GNUTLS_DT_DNS_HOSTNAME`, `GNUTLS_DT_RFC822NAME` and `GNUTLS_DT_KEY_PURPOSE_OID`. The former two accept as data a null-terminated hostname or email address, and the latter a null-terminated object identifier (e.g., `GNUTLS_KP_TLS_WWW_SERVER`).

If a DNS hostname is provided then this function will compare the hostname in the certificate against the given. If names do not match the `GNUTLS_CERT_UNEXPECTED_OWNER` status flag will be set. If a key purpose OID is provided and the end-certificate contains the extended key usage PKIX extension, it will be required to be have the provided key purpose or be marked for any purpose, otherwise verification status will have the `GNUTLS_CERT_SIGNER_CONSTRAINTS_FAILURE` flag set.

To avoid denial of service attacks some default upper limits regarding the certificate key size and chain size are set. To override them use `gnutls_certificate_set_verify_limits()`.

Note that when using raw public-keys verification will not work because there is no corresponding certificate body belonging to the raw key that can be verified. In that case this function will return `GNUTLS_E_INVALID_REQUEST`.

#### Parameters

session | is a gnutls session |
data | an array of typed data |
elements | the number of data elements |
status | is the output of the verification |

#### Returns

`GNUTLS_E_SUCCESS` (0) when the validation is performed, or a negative error code otherwise. A successful error code means that the `status` parameter must be checked to obtain the validation status.

Since: 3.3.0

### gnutls_certificate_verification_status_print ()

    int
    gnutls_certificate_verification_status_print
                                   (unsigned int status,
                                    gnutls_certificate_type_t type,
                                    gnutls_datum_t *out,
                                    unsigned int flags);

This function will pretty print the status of a verification process -- eg. the one obtained by `gnutls_certificate_verify_peers3()`.

The output `out` needs to be deallocated using `gnutls_free()`.

#### Parameters

status | The status flags to be printed |
type | The certificate type |
out | Newly allocated datum with (0) terminated string. |
flags | should be zero |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error value.

Since: 3.1.4

### gnutls_pem_base64_encode ()

    int
    gnutls_pem_base64_encode (const char *msg,
                              const gnutls_datum_t *data,
                              char *result,
                              size_t *result_size);

This function will convert the given data to printable data, using the base64 encoding. This is the encoding used in PEM messages.

The output string will be null terminated, although the output size will not include the terminating null.

#### Parameters

msg | is a message to be put in the header (may be `NULL`) |
data | contain the raw data |
result | the place where base64 data will be copied |
result_size | holds the size of the result |

#### Returns

On success `GNUTLS_E_SUCCESS` (0) is returned, `GNUTLS_E_SHORT_MEMORY_BUFFER` is returned if the buffer given is not long enough, or 0 on success.

### gnutls_pem_base64_decode ()

    int
    gnutls_pem_base64_decode (const char *header,
                              const gnutls_datum_t *b64_data,
                              unsigned char *result,
                              size_t *result_size);

This function will decode the given encoded data. If the header given is non `NULL` this function will search for "-----BEGIN header" and decode only this part. Otherwise it will decode the first PEM packet found.

#### Parameters

header | A null terminated string with the PEM header (eg. CERTIFICATE) |
b64_data | contain the encoded data |
result | the place where decoded data will be copied |
result_size | holds the size of the result |

#### Returns

On success `GNUTLS_E_SUCCESS` (0) is returned, `GNUTLS_E_SHORT_MEMORY_BUFFER` is returned if the buffer given is not long enough, or 0 on success.

### gnutls_pem_base64_encode2 ()

    int
    gnutls_pem_base64_encode2 (const char *msg,
                               const gnutls_datum_t *data,
                               gnutls_datum_t *result);

This function will convert the given data to printable data, using the base64 encoding. This is the encoding used in PEM messages. This function will allocate the required memory to hold the encoded data.

You should use `gnutls_free()` to free the returned data.

Note, that prior to GnuTLS 3.4.0 this function was available under the name `gnutls_pem_base64_encode_alloc()`. There is compatibility macro pointing to this function.

#### Parameters

header | is a message to be put in the encoded header (may be `NULL`) |
data | contains the raw data |
result | will hold the newly allocated encoded data |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

Since: 3.4.0

### gnutls_pem_base64_decode2 ()

    int
    gnutls_pem_base64_decode2 (const char *header,
                               const gnutls_datum_t *b64_data,
                               gnutls_datum_t *result);

This function will decode the given encoded data. The decoded data will be allocated, and stored into result. If the header given is non null this function will search for "-----BEGIN header" and decode only this part. Otherwise it will decode the first PEM packet found.

You should use `gnutls_free()` to free the returned data.

Note, that prior to GnuTLS 3.4.0 this function was available under the name `gnutls_pem_base64_decode_alloc()`. There is compatibility macro pointing to this function.

#### Parameters

header | The PEM header (eg. CERTIFICATE) |
b64_data | contains the encoded data |
result | the location of decoded data |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

Since: 3.4.0

### gnutls_base64_encode2 ()

    int
    gnutls_base64_encode2 (const gnutls_datum_t *data,
                           gnutls_datum_t *result);

This function will convert the given data to printable data, using the base64 encoding. This function will allocate the required memory to hold the encoded data.

You should use `gnutls_free()` to free the returned data.

#### Parameters

data | contains the raw data |
result | will hold the newly allocated encoded data |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

Since: 3.6.0

### gnutls_base64_decode2 ()

    int
    gnutls_base64_decode2 (const gnutls_datum_t *b64_data,
                           gnutls_datum_t *result);

This function will decode the given base64 encoded data. The decoded data will be allocated, and stored into result.

You should use `gnutls_free()` to free the returned data.

#### Parameters

base64 | contains the encoded data |
result | the location of decoded data |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

Since: 3.6.0

### gnutls_certificate_set_params_function ()

    void
    gnutls_certificate_set_params_function
                                   (gnutls_certificate_credentials_t res,
                                    gnutls_params_function *func);

`gnutls_certificate_set_params_function` is deprecated and should not be used in newly-written code.

This function is unnecessary and discouraged on GnuTLS 3.6.0 or later. Since 3.6.0, DH parameters are negotiated following RFC7919.

This function will set a callback in order for the server to get the Diffie-Hellman or RSA parameters for certificate authentication. The callback should return `GNUTLS_E_SUCCESS` (0) on success.

#### Parameters

res | is a gnutls_certificate_credentials_t type |
func | is the function to be called |

### gnutls_anon_set_params_function ()

    void
    gnutls_anon_set_params_function (gnutls_anon_server_credentials_t res,
                                     gnutls_params_function *func);

`gnutls_anon_set_params_function` is deprecated and should not be used in newly-written code.

This function is unnecessary and discouraged on GnuTLS 3.6.0 or later. Since 3.6.0, DH parameters are negotiated following RFC7919.

This function will set a callback in order for the server to get the Diffie-Hellman or RSA parameters for anonymous authentication. The callback should return `GNUTLS_E_SUCCESS` (0) on success.

#### Parameters

res | is a gnutls_anon_server_credentials_t type |
func | is the function to be called |

### gnutls_psk_set_params_function ()

    void
    gnutls_psk_set_params_function (gnutls_psk_server_credentials_t res,
                                    gnutls_params_function *func);

`gnutls_psk_set_params_function` is deprecated and should not be used in newly-written code.

This function is unnecessary and discouraged on GnuTLS 3.6.0 or later. Since 3.6.0, DH parameters are negotiated following RFC7919.

This function will set a callback in order for the server to get the Diffie-Hellman or RSA parameters for PSK authentication. The callback should return `GNUTLS_E_SUCCESS` (0) on success.

#### Parameters

res | is a gnutls_psk_server_credentials_t type |
func | is the function to be called |

### gnutls_hex2bin ()

    int
    gnutls_hex2bin (const char *hex_data,
                    size_t hex_size,
                    void *bin_data,
                    size_t *bin_size);

Convert a buffer with hex data to binary data. This function unlike `gnutls_hex_decode()` can parse hex data with separators between numbers. That is, it ignores any non-hex characters.

#### Parameters

hex_data | string with data in hex format |
hex_size | size of hex data |
bin_data | output array with binary data |
bin_size | when calling should hold maximum size of `bin_data` , on return will hold actual length of `bin_data` . |

#### Returns

`GNUTLS_E_SUCCESS` on success, otherwise a negative error code.

Since: 2.4.0

### gnutls_tdb_store_func ()

    int
    (*gnutls_tdb_store_func) (const char *db_name,
                              const char *host,
                              const char *service,
                              time_t expiration,
                              const gnutls_datum_t *pubkey);

### gnutls_tdb_store_commitment_func ()

    int
    (*gnutls_tdb_store_commitment_func) (const char *db_name,
                                         const char *host,
                                         const char *service,
                                         time_t expiration,
                                         gnutls_digest_algorithm_t hash_algo,
                                         const gnutls_datum_t *hash);

### gnutls_tdb_verify_func ()

    int
    (*gnutls_tdb_verify_func) (const char *db_name,
                               const char *host,
                               const char *service,
                               const gnutls_datum_t *pubkey);

### gnutls_tdb_init ()

    int
    gnutls_tdb_init (gnutls_tdb_t *tdb);

This function will initialize a public key trust storage structure.

#### Parameters

tdb | A pointer to the type to be initialized |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error value.

### gnutls_tdb_set_store_func ()

    void
    gnutls_tdb_set_store_func (gnutls_tdb_t tdb,
                               gnutls_tdb_store_func store);

### gnutls_tdb_set_store_commitment_func ()

    void
    gnutls_tdb_set_store_commitment_func (gnutls_tdb_t tdb,
                                          gnutls_tdb_store_commitment_func cstore);

### gnutls_tdb_set_verify_func ()

    void
    gnutls_tdb_set_verify_func (gnutls_tdb_t tdb,
                                gnutls_tdb_verify_func verify);

### gnutls_tdb_deinit ()

    void
    gnutls_tdb_deinit (gnutls_tdb_t tdb);

This function will deinitialize a public key trust storage structure.

#### Parameters

tdb | The structure to be deinitialized |

### gnutls_verify_stored_pubkey ()

    int
    gnutls_verify_stored_pubkey (const char *db_name,
                                 gnutls_tdb_t tdb,
                                 const char *host,
                                 const char *service,
                                 gnutls_certificate_type_t cert_type,
                                 const gnutls_datum_t *cert,
                                 unsigned int flags);

This function will try to verify a raw public-key or a public-key provided via a raw (DER-encoded) certificate using a list of stored public keys. The `service` field if non-NULL should be a port number.

The `db_name` variable if non-null specifies a custom backend for the retrieval of entries. If it is NULL then the default file backend will be used. In POSIX-like systems the file backend uses the $HOME/.gnutls/known_hosts file.

Note that if the custom storage backend is provided the retrieval function should return `GNUTLS_E_CERTIFICATE_KEY_MISMATCH` if the host/service pair is found but key doesn't match, `GNUTLS_E_NO_CERTIFICATE_FOUND` if no such host/service with the given key is found, and 0 if it was found. The storage function should return 0 on success.

As of GnuTLS 3.6.6 this function also verifies raw public keys.

#### Parameters

db_name | A file specifying the stored keys (use NULL for the default) |
tdb | A storage structure or NULL to use the default |
host | The peer's name |
service | non-NULL if this key is specific to a service (e.g. http) |
cert_type | The type of the certificate |
cert | The raw (der) data of the certificate |
flags | should be 0. |

#### Returns

If no associated public key is found then `GNUTLS_E_NO_CERTIFICATE_FOUND` will be returned. If a key is found but does not match `GNUTLS_E_CERTIFICATE_KEY_MISMATCH` is returned. On success, `GNUTLS_E_SUCCESS` (0) is returned, or a negative error value on other errors.

Since: 3.0.13

### gnutls_store_commitment ()

    int
    gnutls_store_commitment (const char *db_name,
                             gnutls_tdb_t tdb,
                             const char *host,
                             const char *service,
                             gnutls_digest_algorithm_t hash_algo,
                             const gnutls_datum_t *hash,
                             time_t expiration,
                             unsigned int flags);

This function will store the provided hash commitment to the list of stored public keys. The key with the given hash will be considered valid until the provided expiration time.

The `tdb` variable if non-null specifies a custom backend for the storage of entries. If it is NULL then the default file backend will be used.

Note that this function is not thread safe with the default backend.

#### Parameters

db_name | A file specifying the stored keys (use NULL for the default) |
tdb | A storage structure or NULL to use the default |
host | The peer's name |
service | non-NULL if this key is specific to a service (e.g. http) |
hash_algo | The hash algorithm type |
hash | The raw hash |
expiration | The expiration time (use 0 to disable expiration) |
flags | should be 0 or `GNUTLS_SCOMMIT_FLAG_ALLOW_BROKEN`. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error value.

Since: 3.0

### gnutls_store_pubkey ()

    int
    gnutls_store_pubkey (const char *db_name,
                         gnutls_tdb_t tdb,
                         const char *host,
                         const char *service,
                         gnutls_certificate_type_t cert_type,
                         const gnutls_datum_t *cert,
                         time_t expiration,
                         unsigned int flags);

This function will store a raw public-key or a public-key provided via a raw (DER-encoded) certificate to the list of stored public keys. The key will be considered valid until the provided expiration time.

The `tdb` variable if non-null specifies a custom backend for the storage of entries. If it is NULL then the default file backend will be used.

Unless an alternative `tdb` is provided, the storage format is a textual format consisting of a line for each host with fields separated by '|'. The contents of the fields are a format-identifier which is set to 'g0', the hostname that the rest of the data applies to, the numeric port or host name, the expiration time in seconds since the epoch (0 for no expiration), and a base64 encoding of the raw (DER) public key information (SPKI) of the peer.

As of GnuTLS 3.6.6 this function also accepts raw public keys.

#### Parameters

db_name | A file specifying the stored keys (use NULL for the default) |
tdb | A storage structure or NULL to use the default |
host | The peer's name |
service | non-NULL if this key is specific to a service (e.g. http) |
cert_type | The type of the certificate |
cert | The data of the certificate |
expiration | The expiration time (use 0 to disable expiration) |
flags | should be 0. |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise a negative error value.

Since: 3.0.13

### gnutls_load_file ()

    int
    gnutls_load_file (const char *filename,
                      gnutls_datum_t *data);

This function will load a file into a datum. The data are zero terminated but the terminating null is not included in length. The returned data are allocated using `gnutls_malloc()`.

Note that this function is not designed for reading sensitive materials, such as private keys, on practical applications. When the reading fails in the middle, the partially loaded content might remain on memory.

#### Parameters

filename | the name of the file to load |
data | Where the file will be stored |

#### Returns

On success, `GNUTLS_E_SUCCESS` (0) is returned, otherwise an error code is returned.

Since 3.1.0

### gnutls_url_is_supported ()

    unsigned
    gnutls_url_is_supported (const char *url);

Check whether the provided `url` is supported. Depending on the system libraries GnuTLS may support pkcs11, tpmkey or other URLs.

#### Parameters

url | A URI to be tested |

#### Returns

return non-zero if the given URL is supported, and zero if it is not known.

Since: 3.1.0

### gnutls_pin_callback_t ()

    int
    (*gnutls_pin_callback_t) (void *userdata,
                              int attempt,
                              const char *token_url,
                              const char *token_label,
                              unsigned int flags,
                              char *pin,
                              size_t pin_max);

Callback function type for PKCS11 or TPM PIN entry. It is set by functions like `gnutls_pkcs11_set_pin_function()`.

The callback should provides the PIN code to unlock the token with label `token_label` , specified by the URL `token_url` .

The PIN code, as a NUL-terminated ASCII string, should be copied into the `pin` buffer (of maximum size `pin_max` ), and return 0 to indicate success. Alternatively, the callback may return a negative gnutls error code to indicate failure and cancel PIN entry (in which case, the contents of the `pin` parameter are ignored).

When a PIN is required, the callback will be invoked repeatedly (and indefinitely) until either the returned PIN code is correct, the callback returns failure, or the token refuses login (e.g. when the token is locked due to too many incorrect PINs!). For the first such invocation, the `attempt` counter will have value zero; it will increase by one for each subsequent attempt.

#### Parameters

userdata | user-controlled data from `gnutls_pkcs11_set_pin_function()`. |
attempt | pin-attempt counter, initially 0. |
token_url | URL of token. |
token_label | label of token. |
flags | a gnutls_pin_flag_t flag. |
pin | buffer to hold PIN, of size `pin_max` . |
pin_max | size of `pin` buffer. |

#### Returns

`GNUTLS_E_SUCCESS` (0) on success or a negative error code on error.

Since: 2.12.0

### gnutls_certificate_set_pin_function ()

    void
    gnutls_certificate_set_pin_function (gnutls_certificate_credentials_t Param1,
                                         gnutls_pin_callback_t fn,
                                         void *userdata);

### gnutls_buffer_append_data ()

    int
    gnutls_buffer_append_data (gnutls_buffer_t Param1,
                               const void *data,
                               size_t data_size);

Appends the provided `data` to the destination buffer.

#### Parameters

dest | the buffer to append to |
data | the data |
data_size | the size of `data` |

#### Returns

`GNUTLS_E_SUCCESS` on success, otherwise a negative error code.

Since: 3.4.0

### gnutls_utf8_password_normalize ()

    int
    gnutls_utf8_password_normalize (const uint8_t *password,
                                    unsigned  password_len,
                                    gnutls_datum_t *out,
                                    unsigned  flags);

This function will convert the provided UTF-8 password according to the normalization rules in RFC7613.

If the flag `GNUTLS_UTF8_IGNORE_ERRS` is specified, any UTF-8 encoding errors will be ignored, and in that case the output will be a copy of the input.

#### Parameters

password | contain the UTF-8 formatted password |
plen | the length of the provided password |
out | the result in an null-terminated allocated string |
flags | should be zero |

#### Returns

`GNUTLS_E_INVALID_UTF8_STRING` on invalid UTF-8 data, or 0 on success.

Since: 3.5.7

### gnutls_ext_set_data ()

    void
    gnutls_ext_set_data (gnutls_session_t session,
                         unsigned  type,
                         gnutls_ext_priv_data_t Param3);

This function allows an extension handler to store data in the current session and retrieve them later on. The set data will be deallocated using the gnutls_ext_deinit_data_func.

#### Parameters

session | a gnutls_session_t opaque pointer |
tls_id | the numeric id of the extension |
data | the private data to set |

Since: 3.4.0

### gnutls_ext_get_data ()

    int
    gnutls_ext_get_data (gnutls_session_t session,
                         unsigned  type,
                         gnutls_ext_priv_data_t *Param3);

This function retrieves any data previously stored with `gnutls_ext_set_data()`.

#### Parameters

session | a gnutls_session_t opaque pointer |
tls_id | the numeric id of the extension |
data | a pointer to the private data to retrieve |

#### Returns

`GNUTLS_E_SUCCESS` on success, otherwise a negative error code.

Since: 3.4.0

### gnutls_ext_get_current_msg ()

    unsigned
    gnutls_ext_get_current_msg (gnutls_session_t session);

This function allows an extension handler to obtain the message this extension is being called from. The returned value is a single entry of the `gnutls_ext_flags_t` enumeration. That is, if an extension was registered with the `GNUTLS_EXT_FLAG_HRR` and `GNUTLS_EXT_FLAG_EE` flags, the value when called during parsing of the encrypted extensions message will be `GNUTLS_EXT_FLAG_EE`.

If not called under an extension handler, its value is undefined.

#### Parameters

session | a gnutls_session_t opaque pointer |

Since: 3.6.3

### gnutls_ext_recv_func ()

    int
    (*gnutls_ext_recv_func) (gnutls_session_t session,
                             const unsigned char *data,
                             size_t len);

### gnutls_ext_send_func ()

    int
    (*gnutls_ext_send_func) (gnutls_session_t session,
                             gnutls_buffer_t extdata);

### gnutls_ext_deinit_data_func ()

    void
    (*gnutls_ext_deinit_data_func) (gnutls_ext_priv_data_t data);

### gnutls_ext_pack_func ()

    int
    (*gnutls_ext_pack_func) (gnutls_ext_priv_data_t data,
                             gnutls_buffer_t packed_data);

### gnutls_ext_unpack_func ()

    int
    (*gnutls_ext_unpack_func) (gnutls_buffer_t packed_data,
                               gnutls_ext_priv_data_t *data);

### gnutls_ext_raw_process_func ()

    int
    (*gnutls_ext_raw_process_func) (void *ctx,
                                    unsigned  tls_id,
                                    const unsigned char *data,
                                    unsigned  data_size);

### gnutls_ext_raw_parse ()

    int
    gnutls_ext_raw_parse (void *ctx,
                          gnutls_ext_raw_process_func cb,
                          const gnutls_datum_t *data,
                          unsigned int flags);

This function iterates through the TLS extensions as passed in `data` , passing the individual extension data to callback. The `data` must conform to Extension extensions<0..2^16-1> format.

If flags is `GNUTLS_EXT_RAW_TLS_FLAG_CLIENT_HELLO` then this function will parse the extension data from the position, as if the packet in `data` is a client hello (without record or handshake headers) - as provided by `gnutls_handshake_set_hook_function()`.

The return value of the callback will be propagated.

#### Parameters

ctx | a pointer to pass to callback function |
cb | callback function to process each extension found |
data | TLS extension data |
flags | should be zero or `GNUTLS_EXT_RAW_FLAG_TLS_CLIENT_HELLO` or `GNUTLS_EXT_RAW_FLAG_DTLS_CLIENT_HELLO` |

#### Returns

`GNUTLS_E_SUCCESS` on success, or an error code. On unknown flags it returns `GNUTLS_E_INVALID_REQUEST`.

Since: 3.6.3

### gnutls_ext_register ()

    int
    gnutls_ext_register (const char *name,
                         int type,
                         gnutls_ext_parse_type_t parse_point,
                         gnutls_ext_recv_func recv_func,
                         gnutls_ext_send_func send_func,
                         gnutls_ext_deinit_data_func deinit_func,
                         gnutls_ext_pack_func pack_func,
                         gnutls_ext_unpack_func unpack_func);

This function will register a new extension type. The extension will remain registered until `gnutls_global_deinit()` is called. If the extension type is already registered then `GNUTLS_E_ALREADY_REGISTERED` will be returned.

Each registered extension can store temporary data into the gnutls_session_t structure using `gnutls_ext_set_data()`, and they can be retrieved using `gnutls_ext_get_data()`.

Any extensions registered with this function are valid for the client and TLS1.2 server hello (or encrypted extensions for TLS1.3).

This function is not thread safe.

#### Parameters

name | the name of the extension to register |
id | the numeric TLS id of the extension |
parse_point | the parse type of the extension (see gnutls_ext_parse_type_t) |
recv_func | a function to receive the data |
send_func | a function to send the data |
deinit_func | a function deinitialize any private data |
pack_func | a function which serializes the extension's private data (used on session packing for resumption) |
unpack_func | a function which will deserialize the extension's private data |

#### Returns

`GNUTLS_E_SUCCESS` on success, otherwise a negative error code.

Since: 3.4.0

### gnutls_session_ext_register ()

    int
    gnutls_session_ext_register (gnutls_session_t Param1,
                                 const char *name,
                                 int type,
                                 gnutls_ext_parse_type_t parse_point,
                                 gnutls_ext_recv_func recv_func,
                                 gnutls_ext_send_func send_func,
                                 gnutls_ext_deinit_data_func deinit_func,
                                 gnutls_ext_pack_func pack_func,
                                 gnutls_ext_unpack_func unpack_func,
                                 unsigned  flags);

This function will register a new extension type. The extension will be only usable within the registered session. If the extension type is already registered then `GNUTLS_E_ALREADY_REGISTERED` will be returned, unless the flag `GNUTLS_EXT_FLAG_OVERRIDE_INTERNAL` is specified. The latter flag when specified can be used to override certain extensions introduced after 3.6.0. It is expected to be used by applications which handle custom extensions that are not currently supported in GnuTLS, but direct support for them may be added in the future.

Each registered extension can store temporary data into the gnutls_session_t structure using `gnutls_ext_set_data()`, and they can be retrieved using `gnutls_ext_get_data()`.

The validity of the extension registered can be given by the appropriate flags of `gnutls_ext_flags_t`. If no validity is given, then the registered extension will be valid for client and TLS1.2 server hello (or encrypted extensions for TLS1.3).

#### Parameters

session | the session for which this extension will be set |
name | the name of the extension to register |
id | the numeric id of the extension |
parse_point | the parse type of the extension (see gnutls_ext_parse_type_t) |
recv_func | a function to receive the data |
send_func | a function to send the data |
deinit_func | a function deinitialize any private data |
pack_func | a function which serializes the extension's private data (used on session packing for resumption) |
unpack_func | a function which will deserialize the extension's private data |
flags | must be zero or flags from `gnutls_ext_flags_t` |

#### Returns

`GNUTLS_E_SUCCESS` on success, otherwise a negative error code.

Since: 3.5.5

### gnutls_ext_get_name ()

    const char *
    gnutls_ext_get_name (unsigned int ext);

Convert a TLS extension numeric ID to a printable string.

#### Parameters

ext | is a TLS extension numeric ID |

#### Returns

a pointer to a string that contains the name of the specified cipher, or `NULL`.

### gnutls_ext_get_name2 ()

    const char *
    gnutls_ext_get_name2 (gnutls_session_t session,
                          unsigned int tls_id,
                          gnutls_ext_parse_type_t parse_point);

Convert a TLS extension numeric ID to a printable string.

#### Parameters

session | a gnutls_session_t opaque pointer |
tls_id | is a TLS extension numeric ID |
parse_point | the parse type of the extension |

#### Returns

a pointer to a string that contains the name of the specified cipher, or `NULL`.

### gnutls_supp_recv_func ()

    int
    (*gnutls_supp_recv_func) (gnutls_session_t session,
                              const unsigned char *data,
                              size_t data_size);

### gnutls_supp_send_func ()

    int
    (*gnutls_supp_send_func) (gnutls_session_t session,
                              gnutls_buffer_t buf);

### gnutls_supplemental_register ()

    int
    gnutls_supplemental_register (const char *name,
                                  gnutls_supplemental_data_format_type_t type,
                                  gnutls_supp_recv_func supp_recv_func,
                                  gnutls_supp_send_func supp_send_func);

This function will register a new supplemental data type (rfc4680). The registered data will remain until `gnutls_global_deinit()` is called. The provided `type` must be an unassigned type in `gnutls_supplemental_data_format_type_t`. If the type is already registered or handled by GnuTLS internally `GNUTLS_E_ALREADY_REGISTERED` will be returned.

This function is not thread safe. As supplemental data are not defined under TLS 1.3, this function will disable TLS 1.3 support globally.

#### Parameters

name | the name of the supplemental data to register |
type | the type of the supplemental data format |
recv_func | the function to receive the data |
send_func | the function to send the data |

#### Returns

`GNUTLS_E_SUCCESS` on success, otherwise a negative error code.

Since: 3.4.0

### gnutls_session_supplemental_register ()

    int
    gnutls_session_supplemental_register (gnutls_session_t session,
                                          const char *name,
                                          gnutls_supplemental_data_format_type_t type,
                                          gnutls_supp_recv_func supp_recv_func,
                                          gnutls_supp_send_func supp_send_func,
                                          unsigned int flags);

This function will register a new supplemental data type (rfc4680). The registered supplemental functions will be used for that specific session. The provided `type` must be an unassigned type in `gnutls_supplemental_data_format_type_t`.

If the type is already registered or handled by GnuTLS internally `GNUTLS_E_ALREADY_REGISTERED` will be returned.

As supplemental data are not defined under TLS 1.3, this function will disable TLS 1.3 support for the given session.

#### Parameters

session | the session for which this will be registered |
name | the name of the supplemental data to register |
type | the type of the supplemental data format |
recv_func | the function to receive the data |
send_func | the function to send the data |
flags | must be zero |

#### Returns

`GNUTLS_E_SUCCESS` on success, otherwise a negative error code.

Since: 3.5.5

### gnutls_supplemental_recv ()

    void
    gnutls_supplemental_recv (gnutls_session_t session,
                              unsigned  do_recv_supplemental);

This function is to be called by an extension handler to instruct gnutls to attempt to receive supplemental data during the handshake process.

#### Parameters

session | is a gnutls_session_t type. |
do_recv_supplemental | non-zero in order to expect supplemental data |

Since: 3.4.0

### gnutls_supplemental_send ()

    void
    gnutls_supplemental_send (gnutls_session_t session,
                              unsigned  do_send_supplemental);

This function is to be called by an extension handler to instruct gnutls to send supplemental data during the handshake process.

#### Parameters

session | is a gnutls_session_t type. |
do_send_supplemental | non-zero in order to send supplemental data |

Since: 3.4.0

### gnutls_anti_replay_init ()

    int
    gnutls_anti_replay_init (gnutls_anti_replay_t *anti_replay);

This function will allocate and initialize the `anti_replay` context to be usable for detect replay attacks. The context can then be attached to a `gnutls_session_t` with `gnutls_anti_replay_enable()`.

#### Parameters

anti_replay | is a pointer to gnutls_anti_replay_t type |

#### Returns

Zero or a negative error code on error.

Since: 3.6.5

### gnutls_anti_replay_deinit ()

    void
    gnutls_anti_replay_deinit (gnutls_anti_replay_t anti_replay);

This function will deinitialize all resources occupied by the given anti-replay context.

#### Parameters

anti_replay | is a gnutls_anti_replay type |

Since: 3.6.5

### gnutls_anti_replay_set_window ()

    void
    gnutls_anti_replay_set_window (gnutls_anti_replay_t anti_replay,
                                   unsigned int window);

Sets the time window used for ClientHello recording. In order to protect against replay attacks, the server records ClientHello messages within this time period from the last update, and considers it a replay when a ClientHello outside of the period; if a ClientHello arrives within this period, the server checks the database and detects duplicates.

For the details of the algorithm, see RFC 8446, section 8.2.

#### Parameters

anti_replay | is a gnutls_anti_replay_t type. |
window | is the time window recording ClientHello, in milliseconds |

Since: 3.6.5

### gnutls_anti_replay_enable ()

    void
    gnutls_anti_replay_enable (gnutls_session_t session,
                               gnutls_anti_replay_t anti_replay);

Request that the server should use anti-replay mechanism.

#### Parameters

session | is a gnutls_session_t type. |
anti_replay | is a gnutls_anti_replay_t type. |

Since: 3.6.5

### gnutls_db_add_func ()

    int
    (*gnutls_db_add_func) (void *Param1,
                           time_t exp_time,
                           const gnutls_datum_t *key,
                           const gnutls_datum_t *data);

### gnutls_anti_replay_set_add_function ()

    void
    gnutls_anti_replay_set_add_function (gnutls_anti_replay_t Param1,
                                         gnutls_db_add_func add_func);

Sets the function that will be used to store an entry if it is not already present in the resumed sessions database. This function returns 0 if the entry is successfully stored, and a negative error code otherwise. In particular, if the entry is found in the database, it returns `GNUTLS_E_DB_ENTRY_EXISTS`.

The arguments to the `add_func` are:

- `ptr`: the pointer set with `gnutls_anti_replay_set_ptr()`

- `exp_time`: the expiration time of the entry

- `key`: a pointer to the key

- `data`: a pointer to data to store

The data set by this function can be examined using `gnutls_db_check_entry_expire_time()` and `gnutls_db_check_entry_time()`.

#### Parameters

anti_replay | is a gnutls_anti_replay_t type. |
add_func | is the function. |

Since: 3.6.5

### gnutls_anti_replay_set_ptr ()

    void
    gnutls_anti_replay_set_ptr (gnutls_anti_replay_t Param1,
                                void *ptr);

Sets the pointer that will be provided to db add function as the first argument.

#### Parameters

anti_replay | is a gnutls_anti_replay_t type. |
ptr | is the pointer |

### gnutls_handshake_read_func ()

    int
    (*gnutls_handshake_read_func) (gnutls_session_t session,
                                   gnutls_record_encryption_level_t level,
                                   gnutls_handshake_description_t htype,
                                   const void *data,
                                   size_t data_size);

Function prototype for handshake intercepting hooks. It is set using `gnutls_handshake_set_read_function()`.

#### Parameters

session | the current session |
htype | the type of the handshake message (gnutls_handshake_description_t) |
level | gnutls_record_encryption_level_t |
data | the (const) data that was being sent |
data_size | the size of data |

#### Returns

Non zero on error.

Since: 3.7.0

### gnutls_handshake_set_read_function ()

    void
    gnutls_handshake_set_read_function (gnutls_session_t session,
                                        gnutls_handshake_read_func func);

This function will set a callback to be called when a handshake message is being sent.

#### Parameters

session | is gnutls_session_t type |
func | is the function to be called |

Since: 3.7.0

### gnutls_handshake_write ()

    int
    gnutls_handshake_write (gnutls_session_t session,
                            gnutls_record_encryption_level_t level,
                            const void *data,
                            size_t data_size);

This function processes a handshake message in the encryption level specified with `level` . Prior to calling this function, a handshake read callback must be set on `session` . Use `gnutls_handshake_set_read_function()` to do this.

#### Parameters

session | is a gnutls_session_t type. |
level | the current encryption level for reading a handshake message |
data | the (const) handshake data to be processed |
data_size | the size of data |

Since: 3.7.0

### gnutls_handshake_secret_func ()

    int
    (*gnutls_handshake_secret_func) (gnutls_session_t session,
                                     gnutls_record_encryption_level_t level,
                                     const void *secret_read,
                                     const void *secret_write,
                                     size_t secret_size);

Function prototype for secret hooks. It is set using `gnutls_handshake_set_secret_function()`.

#### Parameters

session | the current session |
level | the encryption level |
secret_read | the secret used for reading, can be `NULL` if not set |
secret_write | the secret used for writing, can be `NULL` if not set |
secret_size | the size of the secrets |

#### Returns

Non zero on error.

Since: 3.7.0

### gnutls_handshake_set_secret_function ()

    void
    gnutls_handshake_set_secret_function (gnutls_session_t session,
                                          gnutls_handshake_secret_func func);

This function will set a callback to be called when a new traffic secret is installed.

#### Parameters

session | is a gnutls_session_t type. |
func | the secret func |

Since: 3.7.0

### gnutls_alert_read_func ()

    int
    (*gnutls_alert_read_func) (gnutls_session_t session,
                               gnutls_record_encryption_level_t level,
                               gnutls_alert_level_t alert_level,
                               gnutls_alert_description_t alert_desc);

Function prototype for alert intercepting hooks. It is set using `gnutls_alert_set_read_function()`.

#### Parameters

session | the current session |
level | gnutls_record_encryption_level_t |
alert_level | the level of the alert |
alert_desc | the alert description |

#### Returns

Non zero on error.

Since: 3.7.0

### gnutls_alert_set_read_function ()

    void
    gnutls_alert_set_read_function (gnutls_session_t session,
                                    gnutls_alert_read_func func);

This function will set a callback to be called when an alert message is being sent.

#### Parameters

session | is gnutls_session_t type |
func | is the function to be called |

Since: 3.7.0

### gnutls_fips140_mode_enabled ()

    unsigned
    gnutls_fips140_mode_enabled (void);

Checks whether this library is in FIPS140 mode. The returned value corresponds to the library mode as set with `gnutls_fips140_set_mode()`.

If `gnutls_fips140_set_mode()` was called with `GNUTLS_FIPS140_SET_MODE_THREAD` then this function will return the current thread's FIPS140 mode, otherwise the global value is returned.

#### Returns

return non-zero if true or zero if false.

Since: 3.3.0

### gnutls_fips140_set_mode ()

    void
    gnutls_fips140_set_mode (gnutls_fips_mode_t mode,
                             unsigned  flags);

That function is not thread-safe when changing the mode with no flags (globally), and should be called prior to creating any threads. Its behavior with no flags after threads are created is undefined.

When the flag `GNUTLS_FIPS140_SET_MODE_THREAD` is specified then this call will change the FIPS140-2 mode for this particular thread and not for the whole process. That way an application can utilize this function to set and reset mode for specific operations.

This function never fails but will be a no-op if used when the library is not in FIPS140-2 mode. When asked to switch to unknown values for `mode` or to `GNUTLS_FIPS140_SELFTESTS` mode, the library switches to `GNUTLS_FIPS140_STRICT` mode.

#### Parameters

mode | the FIPS140-2 mode to switch to |
flags | should be zero or `GNUTLS_FIPS140_SET_MODE_THREAD` |

Since: 3.6.2

### GNUTLS_FIPS140_SET_LAX_MODE

    #define             GNUTLS_FIPS140_SET_LAX_MODE()

### GNUTLS_FIPS140_SET_STRICT_MODE

    #define             GNUTLS_FIPS140_SET_STRICT_MODE()

### gnutls_fips140_context_init ()

    int
    gnutls_fips140_context_init (gnutls_fips140_context_t *context);

Create and initialize the FIPS context object.

#### Parameters

context | location to store `gnutls_fips140_context_t` |

#### Returns

0 upon success, a negative error code otherwise

Since: 3.7.3

### gnutls_fips140_context_deinit ()

    void
    gnutls_fips140_context_deinit (gnutls_fips140_context_t context);

Uninitialize and release the FIPS context `context` .

#### Parameters

context | a gnutls_fips140_context_t |

Since: 3.7.3

### gnutls_fips140_get_operation_state ()

    gnutls_fips140_operation_state_t
    gnutls_fips140_get_operation_state (gnutls_fips140_context_t context);

Get the previous operation state of `context` in terms of FIPS.

#### Parameters

context | a gnutls_fips140_context_t |

#### Returns

a gnutls_fips140_operation_state_t

Since: 3.7.3

### gnutls_fips140_push_context ()

    int
    gnutls_fips140_push_context (gnutls_fips140_context_t context);

Associate the FIPS `context` to the current thread, diverting the currently active context. If a cryptographic operation is ongoing in the current thread, e.g., `gnutls_aead_cipher_init()` is called but `gnutls_aead_cipher_deinit()` is not yet called, it returns an error `GNUTLS_E_INVALID_REQUEST`.

The operation state of `context` will be reset to `GNUTLS_FIPS140_OP_INITIAL`.

This function is no-op if FIPS140 is not compiled in nor enabled at run-time.

#### Parameters

context | a gnutls_fips140_context_t |

#### Returns

0 upon success, a negative error code otherwise

Since: 3.7.3

### gnutls_fips140_pop_context ()

    int
    gnutls_fips140_pop_context (void);

Dissociate the FIPS context currently active on the current thread, reverting to the previously active context. If a cryptographic operation is ongoing in the current thread, e.g., `gnutls_aead_cipher_init()` is called but `gnutls_aead_cipher_deinit()` is not yet called, it returns an error `GNUTLS_E_INVALID_REQUEST`.

This function is no-op if FIPS140 is not compiled in nor enabled at run-time.

#### Returns

0 upon success, a negative error code otherwise

Since: 3.7.3

### gnutls_fips140_run_self_tests ()

    int
    gnutls_fips140_run_self_tests (void);

Manually perform the second round of the FIPS140 self-tests, including:

- Known answer tests (KAT) for the selected set of symmetric cipher, MAC, public key, KDF, and DRBG

- Library integrity checks

Upon failure with FIPS140 mode enabled, it makes the library unusable. This function is not thread-safe.

#### Returns

0 upon success, a negative error code otherwise

Since: 3.7.7

### gnutls_audit_push_context ()

    void
    gnutls_audit_push_context (long context Param1);

Push a new crypto-auditing context to the thread-local context stack. The call must match the following `gnutls_audit_pop_context()` call. This is useful for the applications that define their own probe points for application level protocols.

#### Parameters

context | an opaque context |

Since: 3.8.11

### gnutls_audit_pop_context ()

    void
    gnutls_audit_pop_context (void);

Pop the current crypto-auditing context from the thread-local context stack. This is useful for the applications that define their own probe points for application level protocols.

Since: 3.8.11

### gnutls_audit_current_context ()

    long
    gnutls_audit_current_context (void);

Return the current crypto-auditing context from the thread-local context stack. This is useful for the applications that define their own probe points for application level protocols.

#### Returns

an opaque context

Since: 3.8.11

### gnutls_transport_is_ktls_enabled ()

    gnutls_transport_ktls_enable_flags_t
    gnutls_transport_is_ktls_enabled (gnutls_session_t session);

Checks if KTLS is now enabled and was properly inicialized.

#### Parameters

session | is a gnutls_session_t type. |

#### Returns

`GNUTLS_KTLS_RECV`, `GNUTLS_KTLS_SEND`, `GNUTLS_KTLS_DUPLEX`, otherwise 0

Since: 3.7.3

## Types and Values

### GNUTLS_VERSION

    #define GNUTLS_VERSION "3.8.13"

### GNUTLS_VERSION_MAJOR

    #define GNUTLS_VERSION_MAJOR 3

### GNUTLS_VERSION_MINOR

    #define GNUTLS_VERSION_MINOR 8

### GNUTLS_VERSION_PATCH

    #define GNUTLS_VERSION_PATCH 13

### GNUTLS_VERSION_NUMBER

    #define GNUTLS_VERSION_NUMBER 0x03080d

### GNUTLS_CIPHER_RIJNDAEL_128_CBC

    #define GNUTLS_CIPHER_RIJNDAEL_128_CBC GNUTLS_CIPHER_AES_128_CBC

### GNUTLS_CIPHER_RIJNDAEL_256_CBC

    #define GNUTLS_CIPHER_RIJNDAEL_256_CBC GNUTLS_CIPHER_AES_256_CBC

### GNUTLS_CIPHER_RIJNDAEL_CBC

    #define GNUTLS_CIPHER_RIJNDAEL_CBC GNUTLS_CIPHER_AES_128_CBC

### GNUTLS_CIPHER_ARCFOUR

    #define GNUTLS_CIPHER_ARCFOUR GNUTLS_CIPHER_ARCFOUR_128

### GNUTLS_SKIP_GLOBAL_INIT

    #define             GNUTLS_SKIP_GLOBAL_INIT

### enum gnutls_cipher_algorithm_t

Enumeration of different symmetric encryption algorithms.

#### Members

GNUTLS_CIPHER_UNKNOWN | Value to identify an unknown/unsupported algorithm. |
GNUTLS_CIPHER_NULL | The NULL (identity) encryption algorithm. |
GNUTLS_CIPHER_ARCFOUR_128 | ARCFOUR stream cipher with 128-bit keys. |
GNUTLS_CIPHER_3DES_CBC | 3DES in CBC mode. |
GNUTLS_CIPHER_AES_128_CBC | AES in CBC mode with 128-bit keys. |
GNUTLS_CIPHER_AES_256_CBC | AES in CBC mode with 256-bit keys. |
GNUTLS_CIPHER_ARCFOUR_40 | ARCFOUR stream cipher with 40-bit keys. |
GNUTLS_CIPHER_CAMELLIA_128_CBC | Camellia in CBC mode with 128-bit keys. |
GNUTLS_CIPHER_CAMELLIA_256_CBC | Camellia in CBC mode with 256-bit keys. |
GNUTLS_CIPHER_AES_192_CBC | AES in CBC mode with 192-bit keys. |
GNUTLS_CIPHER_AES_128_GCM | AES in GCM mode with 128-bit keys (AEAD). |
GNUTLS_CIPHER_AES_256_GCM | AES in GCM mode with 256-bit keys (AEAD). |
GNUTLS_CIPHER_CAMELLIA_192_CBC | Camellia in CBC mode with 192-bit keys. |
GNUTLS_CIPHER_SALSA20_256 | Salsa20 with 256-bit keys. |
GNUTLS_CIPHER_ESTREAM_SALSA20_256 | Estream's Salsa20 variant with 256-bit keys. |
GNUTLS_CIPHER_CAMELLIA_128_GCM | CAMELLIA in GCM mode with 128-bit keys (AEAD). |
GNUTLS_CIPHER_CAMELLIA_256_GCM | CAMELLIA in GCM mode with 256-bit keys (AEAD). |
GNUTLS_CIPHER_RC2_40_CBC | RC2 in CBC mode with 40-bit keys. |
GNUTLS_CIPHER_DES_CBC | DES in CBC mode (56-bit keys). |
GNUTLS_CIPHER_AES_128_CCM | AES in CCM mode with 128-bit keys (AEAD). |
GNUTLS_CIPHER_AES_256_CCM | AES in CCM mode with 256-bit keys (AEAD). |
GNUTLS_CIPHER_AES_128_CCM_8 | AES in CCM mode with 64-bit tag and 128-bit keys (AEAD). |
GNUTLS_CIPHER_AES_256_CCM_8 | AES in CCM mode with 64-bit tag and 256-bit keys (AEAD). |
GNUTLS_CIPHER_CHACHA20_POLY1305 | The Chacha20 cipher with the Poly1305 authenticator (AEAD). |
GNUTLS_CIPHER_GOST28147_TC26Z_CFB | GOST 28147-89 (Magma) cipher in CFB mode with TC26 Z S-box. |
GNUTLS_CIPHER_GOST28147_CPA_CFB | GOST 28147-89 (Magma) cipher in CFB mode with CryptoPro A S-box. |
GNUTLS_CIPHER_GOST28147_CPB_CFB | GOST 28147-89 (Magma) cipher in CFB mode with CryptoPro B S-box. |
GNUTLS_CIPHER_GOST28147_CPC_CFB | GOST 28147-89 (Magma) cipher in CFB mode with CryptoPro C S-box. |
GNUTLS_CIPHER_GOST28147_CPD_CFB | GOST 28147-89 (Magma) cipher in CFB mode with CryptoPro D S-box. |
GNUTLS_CIPHER_AES_128_CFB8 | AES in CFB8 mode with 128-bit keys. |
GNUTLS_CIPHER_AES_192_CFB8 | AES in CFB8 mode with 192-bit keys. |
GNUTLS_CIPHER_AES_256_CFB8 | AES in CFB8 mode with 256-bit keys. |
GNUTLS_CIPHER_AES_128_XTS | AES in XTS mode with 128-bit key + 128bit tweak key. |
GNUTLS_CIPHER_AES_256_XTS | AES in XTS mode with 256-bit key + 256bit tweak key. Note that the XTS ciphers are message oriented. The whole message needs to be provided with a single call, because cipher-stealing requires to know where the message actually terminates in order to be able to compute where the stealing occurs. |
GNUTLS_CIPHER_GOST28147_TC26Z_CNT | GOST 28147-89 (Magma) cipher in CNT mode with TC26 Z S-box. |
GNUTLS_CIPHER_CHACHA20_64 | Chacha20 cipher with 64-bit nonces and 64-bit block counters. |
GNUTLS_CIPHER_CHACHA20_32 | Chacha20 cipher with 96-bit nonces and 32-bit block counters. |
GNUTLS_CIPHER_AES_128_SIV | AES in SIV mode with 128-bit key. |
GNUTLS_CIPHER_AES_256_SIV | AES in SIV mode with 256-bit key. Note that the SIV ciphers can only be used with the AEAD interface, and the IV plays a role as the authentication tag while it is prepended to the cipher text. |
GNUTLS_CIPHER_AES_192_GCM | AES in GCM mode with 192-bit keys (AEAD). |
GNUTLS_CIPHER_MAGMA_CTR_ACPKM | GOST R 34.12-2015 (Magma) cipher in CTR-ACPKM mode. |
GNUTLS_CIPHER_KUZNYECHIK_CTR_ACPKM | GOST R 34.12-2015 (Kuznyechik) cipher in CTR-ACPKM mode. |
GNUTLS_CIPHER_AES_128_SIV_GCM | AES in SIV-GCM mode with 128-bit key. |
GNUTLS_CIPHER_AES_256_SIV_GCM | AES in SIV-GCM mode with 256-bit key. |
GNUTLS_CIPHER_AES_128_CFB | AES in CFB mode with 128-bit keys. |
GNUTLS_CIPHER_AES_192_CFB | AES in CFB mode with 192-bit keys. |
GNUTLS_CIPHER_AES_256_CFB | AES in CFB mode with 256-bit keys. |
GNUTLS_CIPHER_IDEA_PGP_CFB | IDEA in CFB mode (placeholder - unsupported). |
GNUTLS_CIPHER_3DES_PGP_CFB | 3DES in CFB mode (placeholder - unsupported). |
GNUTLS_CIPHER_CAST5_PGP_CFB | CAST5 in CFB mode (placeholder - unsupported). |
GNUTLS_CIPHER_BLOWFISH_PGP_CFB | Blowfish in CFB mode (placeholder - unsupported). |
GNUTLS_CIPHER_SAFER_SK128_PGP_CFB | Safer-SK in CFB mode with 128-bit keys (placeholder - unsupported). |
GNUTLS_CIPHER_AES128_PGP_CFB | AES in CFB mode with 128-bit keys (placeholder - unsupported). |
GNUTLS_CIPHER_AES192_PGP_CFB | AES in CFB mode with 192-bit keys (placeholder - unsupported). |
GNUTLS_CIPHER_AES256_PGP_CFB | AES in CFB mode with 256-bit keys (placeholder - unsupported). |
GNUTLS_CIPHER_TWOFISH_PGP_CFB | Twofish in CFB mode (placeholder - unsupported). |

### enum gnutls_kx_algorithm_t

Enumeration of different key exchange algorithms.

#### Members

GNUTLS_KX_UNKNOWN | Unknown key-exchange algorithm. |
GNUTLS_KX_RSA | RSA key-exchange algorithm. |
GNUTLS_KX_DHE_DSS | DHE-DSS key-exchange algorithm. |
GNUTLS_KX_DHE_RSA | DHE-RSA key-exchange algorithm. |
GNUTLS_KX_ANON_DH | Anon-DH key-exchange algorithm. |
GNUTLS_KX_SRP | SRP key-exchange algorithm. |
GNUTLS_KX_RSA_EXPORT | RSA-EXPORT key-exchange algorithm (defunc). |
GNUTLS_KX_SRP_RSA | SRP-RSA key-exchange algorithm. |
GNUTLS_KX_SRP_DSS | SRP-DSS key-exchange algorithm. |
GNUTLS_KX_PSK | PSK key-exchange algorithm. |
GNUTLS_KX_DHE_PSK | DHE-PSK key-exchange algorithm. |
GNUTLS_KX_ANON_ECDH | Anon-ECDH key-exchange algorithm. |
GNUTLS_KX_ECDHE_RSA | ECDHE-RSA key-exchange algorithm. |
GNUTLS_KX_ECDHE_ECDSA | ECDHE-ECDSA key-exchange algorithm. |
GNUTLS_KX_ECDHE_PSK | ECDHE-PSK key-exchange algorithm. |
GNUTLS_KX_RSA_PSK | RSA-PSK key-exchange algorithm. |
GNUTLS_KX_VKO_GOST_12 | VKO GOST R 34.10-2012 key-exchange algorithm. |

### enum gnutls_params_type_t

Enumeration of different TLS session parameter types.

#### Members

GNUTLS_PARAMS_RSA_EXPORT | Session RSA-EXPORT parameters (defunc). |
GNUTLS_PARAMS_DH | Session Diffie-Hellman parameters. |
GNUTLS_PARAMS_ECDH | Session Elliptic-Curve Diffie-Hellman parameters. |

### enum gnutls_credentials_type_t

Enumeration of different credential types.

#### Members

GNUTLS_CRD_CERTIFICATE | Certificate credential. |
GNUTLS_CRD_ANON | Anonymous credential. |
GNUTLS_CRD_SRP | SRP credential. |
GNUTLS_CRD_PSK | PSK credential. |
GNUTLS_CRD_IA | IA credential. |

### GNUTLS_MAC_SHA

    #define GNUTLS_MAC_SHA GNUTLS_MAC_SHA1

### GNUTLS_DIG_SHA

    #define GNUTLS_DIG_SHA GNUTLS_DIG_SHA1

### enum gnutls_mac_algorithm_t

Enumeration of different Message Authentication Code (MAC) algorithms.

#### Members

GNUTLS_MAC_UNKNOWN | Unknown MAC algorithm. |
GNUTLS_MAC_NULL | NULL MAC algorithm (empty output). |
GNUTLS_MAC_MD5 | HMAC-MD5 algorithm. |
GNUTLS_MAC_SHA1 | HMAC-SHA-1 algorithm. |
GNUTLS_MAC_RMD160 | HMAC-RMD160 algorithm. |
GNUTLS_MAC_MD2 | HMAC-MD2 algorithm. |
GNUTLS_MAC_SHA256 | HMAC-SHA-256 algorithm. |
GNUTLS_MAC_SHA384 | HMAC-SHA-384 algorithm. |
GNUTLS_MAC_SHA512 | HMAC-SHA-512 algorithm. |
GNUTLS_MAC_SHA224 | HMAC-SHA-224 algorithm. |
GNUTLS_MAC_SHA3_224 | Reserved; unimplemented. |
GNUTLS_MAC_SHA3_256 | Reserved; unimplemented. |
GNUTLS_MAC_SHA3_384 | Reserved; unimplemented. |
GNUTLS_MAC_SHA3_512 | Reserved; unimplemented. |
GNUTLS_MAC_MD5_SHA1 | Combined MD5+SHA1 MAC placeholder. |
GNUTLS_MAC_GOSTR_94 | HMAC GOST R 34.11-94 algorithm. |
GNUTLS_MAC_STREEBOG_256 | HMAC GOST R 34.11-2001 (Streebog) algorithm, 256 bit. |
GNUTLS_MAC_STREEBOG_512 | HMAC GOST R 34.11-2001 (Streebog) algorithm, 512 bit. |
GNUTLS_MAC_AEAD | MAC implicit through AEAD cipher. |
GNUTLS_MAC_UMAC_96 | The UMAC-96 MAC algorithm (requires nonce). |
GNUTLS_MAC_UMAC_128 | The UMAC-128 MAC algorithm (requires nonce). |
GNUTLS_MAC_AES_CMAC_128 | The AES-CMAC-128 MAC algorithm. |
GNUTLS_MAC_AES_CMAC_256 | The AES-CMAC-256 MAC algorithm. |
GNUTLS_MAC_AES_GMAC_128 | The AES-GMAC-128 MAC algorithm (requires nonce). |
GNUTLS_MAC_AES_GMAC_192 | The AES-GMAC-192 MAC algorithm (requires nonce). |
GNUTLS_MAC_AES_GMAC_256 | The AES-GMAC-256 MAC algorithm (requires nonce). |
GNUTLS_MAC_GOST28147_TC26Z_IMIT | The GOST 28147-89 working in IMIT mode with TC26 Z S-box. |
GNUTLS_MAC_SHAKE_128 | The SHAKE128 extendable output function. |
GNUTLS_MAC_SHAKE_256 | The SHAKE256 extendable output function. |
GNUTLS_MAC_MAGMA_OMAC | GOST R 34.12-2015 (Magma) in OMAC (CMAC) mode. |
GNUTLS_MAC_KUZNYECHIK_OMAC | GOST R 34.12-2015 (Kuznyechik) in OMAC (CMAC) mode. |
GNUTLS_MAC_PBMAC1 |  |

### enum gnutls_digest_algorithm_t

Enumeration of different digest (hash) algorithms.

#### Members

GNUTLS_DIG_UNKNOWN | Unknown hash algorithm. |
GNUTLS_DIG_NULL | NULL hash algorithm (empty output). |
GNUTLS_DIG_MD5 | MD5 algorithm. |
GNUTLS_DIG_SHA1 | SHA-1 algorithm. |
GNUTLS_DIG_RMD160 | RMD160 algorithm. |
GNUTLS_DIG_MD2 | MD2 algorithm. |
GNUTLS_DIG_SHA256 | SHA-256 algorithm. |
GNUTLS_DIG_SHA384 | SHA-384 algorithm. |
GNUTLS_DIG_SHA512 | SHA-512 algorithm. |
GNUTLS_DIG_SHA224 | SHA-224 algorithm. |
GNUTLS_DIG_SHA3_224 | SHA3-224 algorithm. |
GNUTLS_DIG_SHA3_256 | SHA3-256 algorithm. |
GNUTLS_DIG_SHA3_384 | SHA3-384 algorithm. |
GNUTLS_DIG_SHA3_512 | SHA3-512 algorithm. |
GNUTLS_DIG_MD5_SHA1 | Combined MD5+SHA1 algorithm. |
GNUTLS_DIG_GOSTR_94 | GOST R 34.11-94 algorithm. |
GNUTLS_DIG_STREEBOG_256 | GOST R 34.11-2001 (Streebog) algorithm, 256 bit. |
GNUTLS_DIG_STREEBOG_512 | GOST R 34.11-2001 (Streebog) algorithm, 512 bit. |
GNUTLS_DIG_SHAKE_128 | The SHAKE128 extendable output function. |
GNUTLS_DIG_SHAKE_256 | The SHAKE256 extendable output function. |

### GNUTLS_MAX_ALGORITHM_NUM

    #define GNUTLS_MAX_ALGORITHM_NUM 128

### GNUTLS_MAX_SESSION_ID_SIZE

    #define GNUTLS_MAX_SESSION_ID_SIZE 32

### enum gnutls_compression_method_t

Enumeration of different TLS compression methods.

#### Members

GNUTLS_COMP_UNKNOWN | Unknown compression method. |
GNUTLS_COMP_NULL | The NULL compression method (no compression). |
GNUTLS_COMP_DEFLATE | The DEFLATE compression method from zlib. |
GNUTLS_COMP_ZLIB | Same as `GNUTLS_COMP_DEFLATE`. |
GNUTLS_COMP_BROTLI | Brotli compression method. |
GNUTLS_COMP_ZSTD | Zstandard compression method. |

### enum gnutls_init_flags_t

`GNUTLS_SERVER` : Connection end is a server. `GNUTLS_CLIENT` : Connection end is a client. `GNUTLS_DATAGRAM` : Connection is datagram oriented (DTLS). Since 3.0.0. `GNUTLS_NONBLOCK` : Connection should not block. Since 3.0.0. `GNUTLS_NO_SIGNAL` : In systems where SIGPIPE is delivered on send, it will be disabled. That flag has effect in systems which support the MSG_NOSIGNAL sockets flag (since 3.4.2). `GNUTLS_NO_DEFAULT_EXTENSIONS` : Do not enable any TLS extensions by default such as session tickets and OCSP certificate status request (since 3.1.2). As TLS 1.2 and later require extensions this option is considered obsolete and should not be used. `GNUTLS_NO_REPLAY_PROTECTION` : Disable any replay protection in DTLS. This must only be used if replay protection is achieved using other means. Since 3.2.2. `GNUTLS_ALLOW_ID_CHANGE` : Allow the peer to replace its certificate, or change its ID during a rehandshake. This change is often used in attacks and thus prohibited by default. Since 3.5.0. `GNUTLS_ENABLE_FALSE_START` : Enable the TLS false start on client side if the negotiated ciphersuites allow it. This will enable sending data prior to the handshake being complete, and may introduce a risk of crypto failure when combined with certain key exchanged; for that GnuTLS may not enable that option in ciphersuites that are known to be not safe for false start. Since 3.5.0. `GNUTLS_ENABLE_EARLY_START` : Under TLS1.3 allow the server to return earlier than the full handshake finish; similarly to false start the handshake will be completed once data are received by the client, while the server is able to transmit sooner. This is not enabled by default as it could break certain existing server assumptions and use-cases. Since 3.6.4. `GNUTLS_ENABLE_EARLY_DATA` : Under TLS1.3 allow the server to receive early data sent as part of the initial ClientHello (0-RTT). This can also be used to explicitly indicate that the client will send early data. This is not enabled by default as early data has weaker security properties than other data. Since 3.6.5. `GNUTLS_FORCE_CLIENT_CERT` : When in client side and only a single cert is specified, send that certificate irrespective of the issuers expected by the server. Since 3.5.0. `GNUTLS_NO_TICKETS` : Flag to indicate that the session should not use resumption with session tickets. `GNUTLS_NO_TICKETS_TLS12` : Flag to indicate that the session should not use resumption with session tickets. This flag only has effect if TLS 1.2 is used. `GNUTLS_KEY_SHARE_TOP3` : Generate key shares for the top-3 different groups which are enabled. That is, as each group is associated with a key type (EC, finite field, x25519), generate three keys using `GNUTLS_PK_DH`, `GNUTLS_PK_EC`, `GNUTLS_PK_ECDH_X25519` if all of them are enabled. `GNUTLS_KEY_SHARE_TOP2` : Generate key shares for the top-2 different groups which are enabled. For example (ECDH + x25519). This is the default. `GNUTLS_KEY_SHARE_TOP` : Generate key share for the first group which is enabled. For example x25519. This option is the most performant for client (less CPU spent generating keys), but if the server doesn't support the advertised option it may result to more roundtrips needed to discover the server's choice. `GNUTLS_NO_AUTO_REKEY` : Disable auto-rekeying under TLS1.3. If this option is not specified gnutls will force a rekey after 2^24 records have been sent. `GNUTLS_POST_HANDSHAKE_AUTH` : Enable post handshake authentication for server and client. When set and a server requests authentication after handshake `GNUTLS_E_REAUTH_REQUEST` will be returned by `gnutls_record_recv()`. A client should then call `gnutls_reauth()` to re-authenticate. `GNUTLS_SAFE_PADDING_CHECK` : Flag to indicate that the TLS 1.3 padding check will be done in a safe way which doesn't leak the pad size based on GnuTLS processing time. This is of use to applications which hide the length of transferred data via the TLS1.3 padding mechanism and are already taking steps to hide the data processing time. This comes at a performance penalty. `GNUTLS_AUTO_REAUTH` : Enable transparent re-authentication in client side when the server requests to. That is, reauthentication is handled within `gnutls_record_recv()`, and the `GNUTLS_E_REHANDSHAKE` or `GNUTLS_E_REAUTH_REQUEST` are not returned. This must be enabled with `GNUTLS_POST_HANDSHAKE_AUTH` for TLS1.3. Enabling this flag requires to restore interrupted calls to `gnutls_record_recv()` based on the output of `gnutls_record_get_direction()`, since `gnutls_record_recv()` could be interrupted when sending when this flag is enabled. Note this flag may not be used if you are using the same session for sending and receiving in different threads. `GNUTLS_ENABLE_RAWPK` : Allows raw public-keys to be negotiated during the handshake. Since 3.6.6. `GNUTLS_NO_AUTO_SEND_TICKET` : Under TLS1.3 disable auto-sending of session tickets during the handshake. `GNUTLS_NO_END_OF_EARLY_DATA` : Under TLS1.3 suppress sending EndOfEarlyData message. Since 3.7.2. `GNUTLS_NO_STATUS_REQUEST` : Prevents client from including the "status_request" TLS extension in the client hello, thus disabling the receival of certificate status information. Since 3.8.0.

Enumeration of different flags for `gnutls_init()` function. All the flags can be combined except `GNUTLS_SERVER` and `GNUTLS_CLIENT` which are mutually exclusive.

The key share options relate to the TLS 1.3 key share extension which is a speculative key generation expecting that the server would support the generated key.

#### Members

GNUTLS_SERVER |  |
GNUTLS_CLIENT |  |
GNUTLS_DATAGRAM |  |
GNUTLS_NONBLOCK |  |
GNUTLS_NO_DEFAULT_EXTENSIONS |  |
GNUTLS_NO_REPLAY_PROTECTION |  |
GNUTLS_NO_SIGNAL |  |
GNUTLS_ALLOW_ID_CHANGE |  |
GNUTLS_ENABLE_FALSE_START |  |
GNUTLS_FORCE_CLIENT_CERT |  |
GNUTLS_NO_TICKETS |  |
GNUTLS_KEY_SHARE_TOP |  |
GNUTLS_KEY_SHARE_TOP2 |  |
GNUTLS_KEY_SHARE_TOP3 |  |
GNUTLS_POST_HANDSHAKE_AUTH |  |
GNUTLS_NO_AUTO_REKEY |  |
GNUTLS_SAFE_PADDING_CHECK |  |
GNUTLS_ENABLE_EARLY_START |  |
GNUTLS_ENABLE_RAWPK |  |
GNUTLS_AUTO_REAUTH |  |
GNUTLS_ENABLE_EARLY_DATA |  |
GNUTLS_NO_AUTO_SEND_TICKET |  |
GNUTLS_NO_END_OF_EARLY_DATA |  |
GNUTLS_NO_TICKETS_TLS12 |  |
GNUTLS_NO_STATUS_REQUEST |  |

### GNUTLS_SERVER

    #define GNUTLS_SERVER (1)

### GNUTLS_CLIENT

    #define GNUTLS_CLIENT (1 << 1)

### GNUTLS_DATAGRAM

    #define GNUTLS_DATAGRAM (1 << 2)

### GNUTLS_NONBLOCK

    #define GNUTLS_NONBLOCK (1 << 3)

### GNUTLS_NO_DEFAULT_EXTENSIONS

    #define GNUTLS_NO_DEFAULT_EXTENSIONS (1 << 4)

### GNUTLS_NO_REPLAY_PROTECTION

    #define GNUTLS_NO_REPLAY_PROTECTION (1 << 5)

### GNUTLS_NO_SIGNAL

    #define GNUTLS_NO_SIGNAL (1 << 6)

### GNUTLS_ALLOW_ID_CHANGE

    #define GNUTLS_ALLOW_ID_CHANGE (1 << 7)

### GNUTLS_ENABLE_FALSE_START

    #define GNUTLS_ENABLE_FALSE_START (1 << 8)

### GNUTLS_FORCE_CLIENT_CERT

    #define GNUTLS_FORCE_CLIENT_CERT (1 << 9)

### GNUTLS_NO_TICKETS

    #define GNUTLS_NO_TICKETS (1 << 10)

### GNUTLS_ENABLE_CERT_TYPE_NEG

    #define GNUTLS_ENABLE_CERT_TYPE_NEG 0

### GNUTLS_NO_EXTENSIONS

    #define GNUTLS_NO_EXTENSIONS GNUTLS_NO_DEFAULT_EXTENSIONS

### enum gnutls_alert_level_t

Enumeration of different TLS alert severities.

#### Members

GNUTLS_AL_WARNING | Alert of warning severity. |
GNUTLS_AL_FATAL | Alert of fatal severity. |

### enum gnutls_alert_description_t

Enumeration of different TLS alerts.

#### Members

GNUTLS_A_CLOSE_NOTIFY | Close notify. |
GNUTLS_A_UNEXPECTED_MESSAGE | Unexpected message. |
GNUTLS_A_BAD_RECORD_MAC | Bad record MAC. |
GNUTLS_A_DECRYPTION_FAILED | Decryption failed. |
GNUTLS_A_RECORD_OVERFLOW | Record overflow. |
GNUTLS_A_DECOMPRESSION_FAILURE | Decompression failed. |
GNUTLS_A_HANDSHAKE_FAILURE | Handshake failed. |
GNUTLS_A_SSL3_NO_CERTIFICATE | No certificate. |
GNUTLS_A_BAD_CERTIFICATE | Certificate is bad. |
GNUTLS_A_UNSUPPORTED_CERTIFICATE | Certificate is not supported. |
GNUTLS_A_CERTIFICATE_REVOKED | Certificate was revoked. |
GNUTLS_A_CERTIFICATE_EXPIRED | Certificate is expired. |
GNUTLS_A_CERTIFICATE_UNKNOWN | Unknown certificate. |
GNUTLS_A_ILLEGAL_PARAMETER | Illegal parameter. |
GNUTLS_A_UNKNOWN_CA | CA is unknown. |
GNUTLS_A_ACCESS_DENIED | Access was denied. |
GNUTLS_A_DECODE_ERROR | Decode error. |
GNUTLS_A_DECRYPT_ERROR | Decrypt error. |
GNUTLS_A_EXPORT_RESTRICTION | Export restriction. |
GNUTLS_A_PROTOCOL_VERSION | Error in protocol version. |
GNUTLS_A_INSUFFICIENT_SECURITY | Insufficient security. |
GNUTLS_A_INTERNAL_ERROR | Internal error. |
GNUTLS_A_INAPPROPRIATE_FALLBACK | Inappropriate fallback, |
GNUTLS_A_USER_CANCELED | User canceled. |
GNUTLS_A_NO_RENEGOTIATION | No renegotiation is allowed. |
GNUTLS_A_MISSING_EXTENSION | An extension was expected but was not seen |
GNUTLS_A_UNSUPPORTED_EXTENSION | An unsupported extension was sent. |
GNUTLS_A_CERTIFICATE_UNOBTAINABLE | Could not retrieve the specified certificate. |
GNUTLS_A_UNRECOGNIZED_NAME | The server name sent was not recognized. |
GNUTLS_A_UNKNOWN_PSK_IDENTITY | The SRP/PSK username is missing or not known. |
GNUTLS_A_CERTIFICATE_REQUIRED | Certificate is required. |
GNUTLS_A_NO_APPLICATION_PROTOCOL | The ALPN protocol requested is not supported by the peer. |
GNUTLS_A_MAX |  |

### enum gnutls_handshake_description_t

Enumeration of different TLS handshake packets.

#### Members

GNUTLS_HANDSHAKE_HELLO_REQUEST | Hello request. |
GNUTLS_HANDSHAKE_CLIENT_HELLO | Client hello. |
GNUTLS_HANDSHAKE_SERVER_HELLO | Server hello. |
GNUTLS_HANDSHAKE_HELLO_VERIFY_REQUEST | DTLS Hello verify request. |
GNUTLS_HANDSHAKE_NEW_SESSION_TICKET | New session ticket. |
GNUTLS_HANDSHAKE_END_OF_EARLY_DATA | End of early data. |
GNUTLS_HANDSHAKE_ENCRYPTED_EXTENSIONS | Encrypted extensions message. |
GNUTLS_HANDSHAKE_CERTIFICATE_PKT | Certificate packet. |
GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE | Server key exchange. |
GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST | Certificate request. |
GNUTLS_HANDSHAKE_SERVER_HELLO_DONE | Server hello done. |
GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY | Certificate verify. |
GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE | Client key exchange. |
GNUTLS_HANDSHAKE_FINISHED | Finished. |
GNUTLS_HANDSHAKE_CERTIFICATE_STATUS | Certificate status (OCSP). |
GNUTLS_HANDSHAKE_SUPPLEMENTAL | Supplemental. |
GNUTLS_HANDSHAKE_KEY_UPDATE | TLS1.3 key update message. |
GNUTLS_HANDSHAKE_COMPRESSED_CERTIFICATE_PKT | Compressed certificate packet. |
GNUTLS_HANDSHAKE_CHANGE_CIPHER_SPEC | Change Cipher Spec. |
GNUTLS_HANDSHAKE_CLIENT_HELLO_V2 | SSLv2 Client Hello. |
GNUTLS_HANDSHAKE_HELLO_RETRY_REQUEST | Hello retry request. |

### GNUTLS_HANDSHAKE_ANY

    #define GNUTLS_HANDSHAKE_ANY ((unsigned int)-1)

### enum gnutls_certificate_status_t

Enumeration of certificate status codes. Note that the status bits may have different meanings in OpenPGP keys and X.509 certificate verification.

#### Members

GNUTLS_CERT_INVALID | The certificate is not signed by one of the known authorities or the signature is invalid (deprecated by the flags `GNUTLS_CERT_SIGNATURE_FAILURE` and `GNUTLS_CERT_SIGNER_NOT_FOUND`). |
GNUTLS_CERT_REVOKED | Certificate is revoked by its authority. In X.509 this will be set only if CRLs are checked. |
GNUTLS_CERT_SIGNER_NOT_FOUND | The certificate's issuer is not known. This is the case if the issuer is not included in the trusted certificate list. |
GNUTLS_CERT_SIGNER_NOT_CA | The certificate's signer was not a CA. This may happen if this was a version 1 certificate, which is common with some CAs, or a version 3 certificate without the basic constrains extension. |
GNUTLS_CERT_INSECURE_ALGORITHM | The certificate was signed using an insecure algorithm such as MD2 or MD5. These algorithms have been broken and should not be trusted. |
GNUTLS_CERT_NOT_ACTIVATED | The certificate is not yet activated. |
GNUTLS_CERT_EXPIRED | The certificate has expired. |
GNUTLS_CERT_SIGNATURE_FAILURE | The signature verification failed. |
GNUTLS_CERT_REVOCATION_DATA_SUPERSEDED | The revocation data are old and have been superseded. |
GNUTLS_CERT_UNEXPECTED_OWNER | The owner is not the expected one. |
GNUTLS_CERT_REVOCATION_DATA_ISSUED_IN_FUTURE | The revocation data have a future issue date. |
GNUTLS_CERT_SIGNER_CONSTRAINTS_FAILURE | The certificate's signer constraints were violated. |
GNUTLS_CERT_MISMATCH | The certificate presented isn't the expected one (TOFU) |
GNUTLS_CERT_PURPOSE_MISMATCH | The certificate or an intermediate does not match the intended purpose (extended key usage). |
GNUTLS_CERT_MISSING_OCSP_STATUS | The certificate requires the server to send the certificate status, but no status was received. |
GNUTLS_CERT_INVALID_OCSP_STATUS | The received OCSP status response is invalid. |
GNUTLS_CERT_UNKNOWN_CRIT_EXTENSIONS | The certificate has extensions marked as critical which are not supported. |

### enum gnutls_certificate_request_t

Enumeration of certificate request types.

#### Members

GNUTLS_CERT_IGNORE | Ignore certificate. |
GNUTLS_CERT_REQUEST | Request certificate. |
GNUTLS_CERT_REQUIRE | Require certificate. |

### enum gnutls_openpgp_crt_status_t

Enumeration of ways to send OpenPGP certificate.

#### Members

GNUTLS_OPENPGP_CERT | Send entire certificate. |
GNUTLS_OPENPGP_CERT_FINGERPRINT | Send only certificate fingerprint. |

### enum gnutls_close_request_t

Enumeration of how TLS session should be terminated. See `gnutls_bye()`.

#### Members

GNUTLS_SHUT_RDWR | Disallow further receives/sends. |
GNUTLS_SHUT_WR | Disallow further sends. |

### enum gnutls_protocol_t

Enumeration of different SSL/TLS protocol versions.

#### Members

GNUTLS_SSL3 | SSL version 3.0. |
GNUTLS_TLS1_0 | TLS version 1.0. |
GNUTLS_TLS1 | Same as `GNUTLS_TLS1_0`. |
GNUTLS_TLS1_1 | TLS version 1.1. |
GNUTLS_TLS1_2 | TLS version 1.2. |
GNUTLS_TLS1_3 | TLS version 1.3. |
GNUTLS_DTLS0_9 | DTLS version 0.9 (Cisco AnyConnect / OpenSSL 0.9.8e). |
GNUTLS_DTLS1_0 | DTLS version 1.0. |
GNUTLS_DTLS1_2 | DTLS version 1.2. |
GNUTLS_DTLS_VERSION_MIN |  |
GNUTLS_DTLS_VERSION_MAX | Maps to the highest supported DTLS version. |
GNUTLS_TLS_VERSION_MAX | Maps to the highest supported TLS version. |
GNUTLS_VERSION_UNKNOWN | Unknown SSL/TLS version. |

### GNUTLS_CRT_RAW

    #define GNUTLS_CRT_RAW GNUTLS_CRT_RAWPK

### enum gnutls_certificate_type_t

Enumeration of different certificate types.

#### Members

GNUTLS_CRT_UNKNOWN | Unknown certificate type. |
GNUTLS_CRT_X509 | X.509 Certificate. |
GNUTLS_CRT_OPENPGP | OpenPGP certificate. |
GNUTLS_CRT_RAWPK | Raw public-key (SubjectPublicKeyInfo) |
GNUTLS_CRT_MAX |  |

### enum gnutls_x509_crt_fmt_t

Enumeration of different certificate encoding formats.

#### Members

GNUTLS_X509_FMT_DER | X.509 certificate in DER format (binary). |
GNUTLS_X509_FMT_PEM | X.509 certificate in PEM format (text). |

### enum gnutls_certificate_print_formats_t

Enumeration of different certificate printing variants.

#### Members

GNUTLS_CRT_PRINT_FULL | Full information about certificate. |
GNUTLS_CRT_PRINT_ONELINE | Information about certificate in one line. |
GNUTLS_CRT_PRINT_UNSIGNED_FULL | All info for an unsigned certificate. |
GNUTLS_CRT_PRINT_COMPACT | Information about certificate name in one line, plus identification of the public key. |
GNUTLS_CRT_PRINT_FULL_NUMBERS | Full information about certificate and include easy to parse public key parameters. |

### GNUTLS_PK_ECC

    #define GNUTLS_PK_ECC GNUTLS_PK_ECDSA

### GNUTLS_PK_EC

    #define GNUTLS_PK_EC GNUTLS_PK_ECDSA

### GNUTLS_PK_ECDHX

    #define GNUTLS_PK_ECDHX GNUTLS_PK_ECDH_X25519

### enum gnutls_pk_algorithm_t

Enumeration of different public-key algorithms.

#### Members

GNUTLS_PK_UNKNOWN | Unknown public-key algorithm. |
GNUTLS_PK_RSA | RSA public-key algorithm. |
GNUTLS_PK_DSA | DSA public-key algorithm. |
GNUTLS_PK_DH | Diffie-Hellman algorithm. Used to generate parameters. |
GNUTLS_PK_ECDSA | Elliptic curve algorithm. These parameters are compatible with the ECDSA and ECDH algorithm. |
GNUTLS_PK_ECDH_X25519 | Elliptic curve algorithm, restricted to ECDH as per rfc7748. |
GNUTLS_PK_RSA_PSS | RSA public-key algorithm, with PSS padding. |
GNUTLS_PK_EDDSA_ED25519 | Edwards curve Digital signature algorithm. Used with SHA512 on signatures. |
GNUTLS_PK_GOST_01 | GOST R 34.10-2001 algorithm per rfc5832. |
GNUTLS_PK_GOST_12_256 | GOST R 34.10-2012 algorithm, 256-bit key per rfc7091. |
GNUTLS_PK_GOST_12_512 | GOST R 34.10-2012 algorithm, 512-bit key per rfc7091. |
GNUTLS_PK_ECDH_X448 | Elliptic curve algorithm, restricted to ECDH as per rfc7748. |
GNUTLS_PK_EDDSA_ED448 | Edwards curve Digital signature algorithm. Used with SHAKE256 on signatures. |
GNUTLS_PK_RSA_OAEP | RSA public-key algorithm, with OAEP padding. |
GNUTLS_PK_MLKEM768 | ML-KEM-768 key encapsulation algorithm as per FIPS 203. |
GNUTLS_PK_MLDSA44 | ML-DSA-44 digital signature algorithm as per FIPS 204. |
GNUTLS_PK_MLDSA65 | ML-DSA-65 digital signature algorithm as per FIPS 204. |
GNUTLS_PK_MLDSA87 | ML-DSA-87 digital signature algorithm as per FIPS 204. |
GNUTLS_PK_MLKEM1024 | ML-KEM-1024 key encapsulation algorithm as per FIPS 203. |
GNUTLS_PK_MAX |  |
GNUTLS_PK_EXP_KYBER768 |  |
GNUTLS_PK_EXP_MAX |  |

### enum gnutls_sign_algorithm_t

Enumeration of different digital signature algorithms.

#### Members

GNUTLS_SIGN_UNKNOWN | Unknown signature algorithm. |
GNUTLS_SIGN_RSA_SHA1 | Digital signature algorithm RSA with SHA-1 |
GNUTLS_SIGN_RSA_SHA | Same as `GNUTLS_SIGN_RSA_SHA1`. |
GNUTLS_SIGN_DSA_SHA1 | Digital signature algorithm DSA with SHA-1 |
GNUTLS_SIGN_DSA_SHA | Same as `GNUTLS_SIGN_DSA_SHA1`. |
GNUTLS_SIGN_RSA_MD5 | Digital signature algorithm RSA with MD5. |
GNUTLS_SIGN_RSA_MD2 | Digital signature algorithm RSA with MD2. |
GNUTLS_SIGN_RSA_RMD160 | Digital signature algorithm RSA with RMD-160. |
GNUTLS_SIGN_RSA_SHA256 | Digital signature algorithm RSA with SHA-256. |
GNUTLS_SIGN_RSA_SHA384 | Digital signature algorithm RSA with SHA-384. |
GNUTLS_SIGN_RSA_SHA512 | Digital signature algorithm RSA with SHA-512. |
GNUTLS_SIGN_RSA_SHA224 | Digital signature algorithm RSA with SHA-224. |
GNUTLS_SIGN_DSA_SHA224 | Digital signature algorithm DSA with SHA-224 |
GNUTLS_SIGN_DSA_SHA256 | Digital signature algorithm DSA with SHA-256 |
GNUTLS_SIGN_ECDSA_SHA1 | ECDSA with SHA1. |
GNUTLS_SIGN_ECDSA_SHA224 | Digital signature algorithm ECDSA with SHA-224. |
GNUTLS_SIGN_ECDSA_SHA256 | Digital signature algorithm ECDSA with SHA-256. |
GNUTLS_SIGN_ECDSA_SHA384 | Digital signature algorithm ECDSA with SHA-384. |
GNUTLS_SIGN_ECDSA_SHA512 | Digital signature algorithm ECDSA with SHA-512. |
GNUTLS_SIGN_DSA_SHA384 | Digital signature algorithm DSA with SHA-384 |
GNUTLS_SIGN_DSA_SHA512 | Digital signature algorithm DSA with SHA-512 |
GNUTLS_SIGN_ECDSA_SHA3_224 | Digital signature algorithm ECDSA with SHA3-224. |
GNUTLS_SIGN_ECDSA_SHA3_256 | Digital signature algorithm ECDSA with SHA3-256. |
GNUTLS_SIGN_ECDSA_SHA3_384 | Digital signature algorithm ECDSA with SHA3-384. |
GNUTLS_SIGN_ECDSA_SHA3_512 | Digital signature algorithm ECDSA with SHA3-512. |
GNUTLS_SIGN_DSA_SHA3_224 | Digital signature algorithm DSA with SHA3-224. |
GNUTLS_SIGN_DSA_SHA3_256 | Digital signature algorithm DSA with SHA3-256. |
GNUTLS_SIGN_DSA_SHA3_384 | Digital signature algorithm DSA with SHA3-384. |
GNUTLS_SIGN_DSA_SHA3_512 | Digital signature algorithm DSA with SHA3-512. |
GNUTLS_SIGN_RSA_SHA3_224 | Digital signature algorithm RSA with SHA3-224. |
GNUTLS_SIGN_RSA_SHA3_256 | Digital signature algorithm RSA with SHA3-256. |
GNUTLS_SIGN_RSA_SHA3_384 | Digital signature algorithm RSA with SHA3-384. |
GNUTLS_SIGN_RSA_SHA3_512 | Digital signature algorithm RSA with SHA3-512. |
GNUTLS_SIGN_RSA_PSS_SHA256 | Digital signature algorithm RSA with SHA-256, with PSS padding (RSA-PSS certificate). |
GNUTLS_SIGN_RSA_PSS_SHA384 | Digital signature algorithm RSA with SHA-384, with PSS padding (RSA-PSS certificate). |
GNUTLS_SIGN_RSA_PSS_SHA512 | Digital signature algorithm RSA with SHA-512, with PSS padding (RSA-PSS certificate). |
GNUTLS_SIGN_EDDSA_ED25519 | Digital signature algorithm EdDSA with Ed25519 curve. |
GNUTLS_SIGN_RSA_RAW | Digital signature algorithm RSA with DigestInfo formatted data |
GNUTLS_SIGN_ECDSA_SECP256R1_SHA256 | Digital signature algorithm ECDSA-SECP256R1 with SHA-256 (used in TLS 1.3 but not PKIX). |
GNUTLS_SIGN_ECDSA_SECP384R1_SHA384 | Digital signature algorithm ECDSA-SECP384R1 with SHA-384 (used in TLS 1.3 but not PKIX). |
GNUTLS_SIGN_ECDSA_SECP521R1_SHA512 | Digital signature algorithm ECDSA-SECP521R1 with SHA-512 (used in TLS 1.3 but not PKIX). |
GNUTLS_SIGN_RSA_PSS_RSAE_SHA256 | Digital signature algorithm RSA with SHA-256, with PSS padding (RSA PKCS#1 1.5 certificate). This signature is identical to GNUTLS_SIGN_RSA_PSS_SHA256, but they are distinct as the TLS1.3 protocol treats them differently. |
GNUTLS_SIGN_RSA_PSS_RSAE_SHA384 | Digital signature algorithm RSA with SHA-384, with PSS padding (RSA PKCS#1 1.5 certificate). This signature is identical to GNUTLS_SIGN_RSA_PSS_SHA384, but they are distinct as the TLS1.3 protocol treats them differently. |
GNUTLS_SIGN_RSA_PSS_RSAE_SHA512 | Digital signature algorithm RSA with SHA-512, with PSS padding (RSA PKCS#1 1.5 certificate). This signature is identical to GNUTLS_SIGN_RSA_PSS_SHA512, but they are distinct as the TLS1.3 protocol treats them differently. |
GNUTLS_SIGN_GOST_94 | Digital signature algorithm GOST R 34.10-2001 with GOST R 34.11-94 |
GNUTLS_SIGN_GOST_256 | Digital signature algorithm GOST R 34.10-2012 with GOST R 34.11-2012 256 bit |
GNUTLS_SIGN_GOST_512 | Digital signature algorithm GOST R 34.10-2012 with GOST R 34.11-2012 512 bit |
GNUTLS_SIGN_EDDSA_ED448 | Digital signature algorithm EdDSA with Ed448 curve. |
GNUTLS_SIGN_MLDSA44 | Digital signature algorithm ML-DSA-44. |
GNUTLS_SIGN_MLDSA65 | Digital signature algorithm ML-DSA-65. |
GNUTLS_SIGN_MLDSA87 | Digital signature algorithm ML-DSA-87. |
GNUTLS_SIGN_MAX |  |

### enum gnutls_ecc_curve_t

Enumeration of ECC curves.

#### Members

GNUTLS_ECC_CURVE_INVALID | Cannot be known |
GNUTLS_ECC_CURVE_SECP224R1 | the SECP224R1 curve |
GNUTLS_ECC_CURVE_SECP256R1 | the SECP256R1 curve |
GNUTLS_ECC_CURVE_SECP384R1 | the SECP384R1 curve |
GNUTLS_ECC_CURVE_SECP521R1 | the SECP521R1 curve |
GNUTLS_ECC_CURVE_SECP192R1 | the SECP192R1 curve |
GNUTLS_ECC_CURVE_X25519 | the X25519 curve (ECDH only) |
GNUTLS_ECC_CURVE_ED25519 | the Ed25519 curve |
GNUTLS_ECC_CURVE_GOST256CPA | GOST R 34.10 CryptoPro 256 A curve |
GNUTLS_ECC_CURVE_GOST256CPB | GOST R 34.10 CryptoPro 256 B curve |
GNUTLS_ECC_CURVE_GOST256CPC | GOST R 34.10 CryptoPro 256 C curve |
GNUTLS_ECC_CURVE_GOST256CPXA | GOST R 34.10 CryptoPro 256 XchA curve |
GNUTLS_ECC_CURVE_GOST256CPXB | GOST R 34.10 CryptoPro 256 XchB curve |
GNUTLS_ECC_CURVE_GOST512A | GOST R 34.10 TC26 512 A curve |
GNUTLS_ECC_CURVE_GOST512B | GOST R 34.10 TC26 512 B curve |
GNUTLS_ECC_CURVE_GOST512C | GOST R 34.10 TC26 512 C curve |
GNUTLS_ECC_CURVE_GOST256A | GOST R 34.10 TC26 256 A curve |
GNUTLS_ECC_CURVE_GOST256B | GOST R 34.10 TC26 256 B curve |
GNUTLS_ECC_CURVE_GOST256C | GOST R 34.10 TC26 256 C curve |
GNUTLS_ECC_CURVE_GOST256D | GOST R 34.10 TC26 256 D curve |
GNUTLS_ECC_CURVE_X448 | the X448 curve (ECDH only) |
GNUTLS_ECC_CURVE_ED448 | the Ed448 curve |
GNUTLS_ECC_CURVE_MAX |  |

### enum gnutls_group_t

Enumeration of supported groups. It is intended to be backwards compatible with the enumerations in `gnutls_ecc_curve_t` for the groups which are valid elliptic curves.

#### Members

GNUTLS_GROUP_INVALID | Indicates unknown/invalid group |
GNUTLS_GROUP_SECP192R1 | the SECP192R1 curve group (legacy, only for TLS 1.2 compatibility) |
GNUTLS_GROUP_SECP224R1 | the SECP224R1 curve group (legacy, only for TLS 1.2 compatibility) |
GNUTLS_GROUP_SECP256R1 | the SECP256R1 curve group |
GNUTLS_GROUP_SECP384R1 | the SECP384R1 curve group |
GNUTLS_GROUP_SECP521R1 | the SECP521R1 curve group |
GNUTLS_GROUP_X25519 | the X25519 curve group |
GNUTLS_GROUP_X448 | the X448 curve group |
GNUTLS_GROUP_GC256A | the GOST R 34.10 TC26 256 A curve group |
GNUTLS_GROUP_GC256B | the GOST R 34.10 TC26 256 B curve group |
GNUTLS_GROUP_GC256C | the GOST R 34.10 TC26 256 C curve group |
GNUTLS_GROUP_GC256D | the GOST R 34.10 TC26 256 D curve group |
GNUTLS_GROUP_GC512A | the GOST R 34.10 TC26 512 A curve group |
GNUTLS_GROUP_GC512B | the GOST R 34.10 TC26 512 B curve group |
GNUTLS_GROUP_GC512C | the GOST R 34.10 TC26 512 C curve group |
GNUTLS_GROUP_FFDHE2048 | the FFDHE2048 group |
GNUTLS_GROUP_FFDHE3072 | the FFDHE3072 group |
GNUTLS_GROUP_FFDHE4096 | the FFDHE4096 group |
GNUTLS_GROUP_FFDHE8192 | the FFDHE8192 group |
GNUTLS_GROUP_FFDHE6144 | the FFDHE6144 group |
GNUTLS_GROUP_MAX |  |
GNUTLS_GROUP_EXP_X25519_KYBER768 |  |
GNUTLS_GROUP_EXP_SECP256R1_MLKEM768 |  |
GNUTLS_GROUP_EXP_SECP384R1_MLKEM1024 |  |
GNUTLS_GROUP_EXP_X25519_MLKEM768 |  |
GNUTLS_GROUP_EXP_KYBER768 |  |
GNUTLS_GROUP_EXP_MLKEM768 |  |
GNUTLS_GROUP_EXP_MLKEM1024 |  |
GNUTLS_GROUP_EXP_MIN |  |
GNUTLS_GROUP_EXP_MAX |  |

### enum gnutls_sec_param_t

Enumeration of security parameters for passive attacks.

#### Members

GNUTLS_SEC_PARAM_UNKNOWN | Cannot be known |
GNUTLS_SEC_PARAM_INSECURE | Less than 42 bits of security |
GNUTLS_SEC_PARAM_EXPORT | 42 bits of security |
GNUTLS_SEC_PARAM_VERY_WEAK | 64 bits of security |
GNUTLS_SEC_PARAM_WEAK | 72 bits of security |
GNUTLS_SEC_PARAM_LOW | 80 bits of security |
GNUTLS_SEC_PARAM_LEGACY | 96 bits of security |
GNUTLS_SEC_PARAM_MEDIUM | 112 bits of security (used to be `GNUTLS_SEC_PARAM_NORMAL`) |
GNUTLS_SEC_PARAM_HIGH | 128 bits of security |
GNUTLS_SEC_PARAM_ULTRA | 192 bits of security |
GNUTLS_SEC_PARAM_FUTURE | 256 bits of security |
GNUTLS_SEC_PARAM_MAX |  |

### GNUTLS_SEC_PARAM_NORMAL

    #define GNUTLS_SEC_PARAM_NORMAL GNUTLS_SEC_PARAM_MEDIUM

### enum gnutls_channel_binding_t

Enumeration of supported channel binding types.

#### Members

GNUTLS_CB_TLS_UNIQUE | "tls-unique" (RFC 5929) channel binding |
GNUTLS_CB_TLS_SERVER_END_POINT | "tls-server-end-point" (RFC 5929) channel binding |
GNUTLS_CB_TLS_EXPORTER | "tls-exporter" (RFC 9266) channel binding |

### enum gnutls_gost_paramset_t

Enumeration of different GOST 28147 parameter sets.

#### Members

GNUTLS_GOST_PARAMSET_UNKNOWN | Unknown/default parameter set |
GNUTLS_GOST_PARAMSET_TC26_Z | Specified by TC26, see rfc7836 |
GNUTLS_GOST_PARAMSET_CP_A | CryptoPro-A, see rfc4357 |
GNUTLS_GOST_PARAMSET_CP_B | CryptoPro-B, see rfc4357 |
GNUTLS_GOST_PARAMSET_CP_C | CryptoPro-C, see rfc4357 |
GNUTLS_GOST_PARAMSET_CP_D | CryptoPro-D, see rfc4357 |

### enum gnutls_ctype_target_t

Enumeration of certificate type targets with respect to asymmetric certificate types as specified in RFC7250 and P2P connection set up as specified in draft-vanrein-tls-symmetry-02.

#### Members

GNUTLS_CTYPE_CLIENT | for requesting client certificate type values. |
GNUTLS_CTYPE_SERVER | for requesting server certificate type values. |
GNUTLS_CTYPE_OURS | for requesting our certificate type values. |
GNUTLS_CTYPE_PEERS | for requesting the peers' certificate type values. |

### gnutls_transport_ptr_t

    typedef void *gnutls_transport_ptr_t;

### gnutls_session_t

    typedef struct gnutls_session_int *gnutls_session_t;

### gnutls_dh_params_t

    typedef struct gnutls_dh_params_int *gnutls_dh_params_t;

### gnutls_rsa_params_t

    typedef struct gnutls_x509_privkey_int *gnutls_rsa_params_t;

### gnutls_priority_t

    typedef struct gnutls_priority_st *gnutls_priority_t;

### gnutls_datum_t

    typedef struct {
    	unsigned char *data;
    	unsigned int size;
    } gnutls_datum_t;

### gnutls_library_config_st

    typedef struct {
    	const char *name;
    	const char *value;
    } gnutls_library_config_st;

### gnutls_params_st

    typedef struct {
    	gnutls_params_type_t type;
    	union params {
    		gnutls_dh_params_t dh;
    		gnutls_rsa_params_t rsa_export;
    	} params;
    	int deinit;
    } gnutls_params_st;

### GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT

    #define GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT ((unsigned int)-1)

### GNUTLS_INDEFINITE_TIMEOUT

    #define GNUTLS_INDEFINITE_TIMEOUT ((unsigned int)-2)

### GNUTLS_KU_PEER

    #define GNUTLS_KU_PEER 1

### GNUTLS_HEARTBEAT_WAIT

    #define GNUTLS_HEARTBEAT_WAIT 1

### GNUTLS_RECORD_WAIT

    #define GNUTLS_RECORD_WAIT 1

### gnutls_range_st

    typedef struct {
    	size_t low;
    	size_t high;
    } gnutls_range_st;

### gnutls_packet_t

    typedef struct mbuffer_st *gnutls_packet_t;

### gnutls_read

    #define gnutls_read gnutls_record_recv

### gnutls_write

    #define gnutls_write gnutls_record_send

### enum gnutls_server_name_type_t

Enumeration of different server name types.

#### Members

GNUTLS_NAME_DNS | Domain Name System name type. |

### GNUTLS_HB_PEER_ALLOWED_TO_SEND

    #define GNUTLS_HB_PEER_ALLOWED_TO_SEND (1)

### GNUTLS_HB_PEER_NOT_ALLOWED_TO_SEND

    #define GNUTLS_HB_PEER_NOT_ALLOWED_TO_SEND (1 << 1)

### GNUTLS_HB_LOCAL_ALLOWED_TO_SEND

    #define GNUTLS_HB_LOCAL_ALLOWED_TO_SEND (1 << 2)

### enum gnutls_session_flags_t

Enumeration of different session parameters.

#### Members

GNUTLS_SFLAGS_SAFE_RENEGOTIATION | Safe renegotiation (RFC5746) was used |
GNUTLS_SFLAGS_EXT_MASTER_SECRET | The extended master secret (RFC7627) extension was used |
GNUTLS_SFLAGS_ETM | The encrypt then MAC (RFC7366) extension was used |
GNUTLS_SFLAGS_HB_LOCAL_SEND | The heartbeat negotiation allows the local side to send heartbeat messages |
GNUTLS_SFLAGS_HB_PEER_SEND | The heartbeat negotiation allows the peer to send heartbeat messages |
GNUTLS_SFLAGS_FALSE_START | False start was used in this client session. |
GNUTLS_SFLAGS_RFC7919 | The RFC7919 Diffie-Hellman parameters were negotiated |
GNUTLS_SFLAGS_SESSION_TICKET | A session ticket has been received by the server. |
GNUTLS_SFLAGS_POST_HANDSHAKE_AUTH | Indicates client capability for post-handshake auth; set only on server side. |
GNUTLS_SFLAGS_EARLY_START | The TLS1.3 server session returned early. |
GNUTLS_SFLAGS_EARLY_DATA | The TLS1.3 early data has been received by the server. |
GNUTLS_SFLAGS_CLI_REQUESTED_OCSP | Set when the client has requested OCSP staple during handshake. |
GNUTLS_SFLAGS_SERV_REQUESTED_OCSP | Set when the server has requested OCSP staple during handshake. |

### enum gnutls_supplemental_data_format_type_t

Enumeration of different supplemental data types (RFC 4680).

#### Members

GNUTLS_SUPPLEMENTAL_UNKNOWN | Unknown data format |

### enum gnutls_srtp_profile_t

Enumeration of different SRTP protection profiles.

#### Members

GNUTLS_SRTP_AES128_CM_HMAC_SHA1_80 | 128 bit AES with a 80 bit HMAC-SHA1 |
GNUTLS_SRTP_AES128_CM_HMAC_SHA1_32 | 128 bit AES with a 32 bit HMAC-SHA1 |
GNUTLS_SRTP_NULL_HMAC_SHA1_80 | NULL cipher with a 80 bit HMAC-SHA1 |
GNUTLS_SRTP_NULL_HMAC_SHA1_32 | NULL cipher with a 32 bit HMAC-SHA1 |
GNUTLS_SRTP_AEAD_AES_128_GCM | 128 bit AES with GCM |
GNUTLS_SRTP_AEAD_AES_256_GCM | 256 bit AES with GCM |

### enum gnutls_alpn_flags_t

Enumeration of different ALPN flags. These are used by `gnutls_alpn_set_protocols()`.

#### Members

GNUTLS_ALPN_MANDATORY | Require ALPN negotiation. The connection will be aborted if no matching ALPN protocol is found. |
GNUTLS_ALPN_SERVER_PRECEDENCE | The choices set by the server will take precedence over the client's. |

### GNUTLS_ALPN_MAND

    #define GNUTLS_ALPN_MAND GNUTLS_ALPN_MANDATORY

### GNUTLS_PRIORITY_INIT_DEF_APPEND

    #define GNUTLS_PRIORITY_INIT_DEF_APPEND 1

### GNUTLS_PRIORITY_LIST_INIT_KEYWORDS

    #define GNUTLS_PRIORITY_LIST_INIT_KEYWORDS 1

### GNUTLS_PRIORITY_LIST_SPECIAL

    #define GNUTLS_PRIORITY_LIST_SPECIAL 2

### enum gnutls_vdata_types_t

Enumeration of different typed-data options. They are used as input to certificate verification functions to provide information about the name and purpose of the certificate. Only a single option of a type can be provided to the relevant functions (i.e., options `GNUTLS_DT_DNS_HOSTNAME`, `GNUTLS_DT_IP_ADDRESS` and `GNUTLS_DT_RFC822NAME` cannot be combined).

#### Members

GNUTLS_DT_UNKNOWN | Unknown data type. |
GNUTLS_DT_DNS_HOSTNAME | The data contain a null-terminated DNS hostname; the hostname will be matched using the RFC6125 rules. If the data contain a textual IP (v4 or v6) address it will be marched against the IPAddress Alternative name, unless the verification flag `GNUTLS_VERIFY_DO_NOT_ALLOW_IP_MATCHES` is specified. |
GNUTLS_DT_KEY_PURPOSE_OID | The data contain a null-terminated key purpose OID. It will be matched against the certificate's Extended Key Usage extension. |
GNUTLS_DT_RFC822NAME | The data contain a null-terminated email address; the email will be matched against the RFC822Name Alternative name of the certificate, or the EMAIL DN component if the former isn't available. Prior to matching the email address will be converted to ACE (ASCII-compatible-encoding). |
GNUTLS_DT_IP_ADDRESS | The data contain a raw IP address (4 or 16 bytes). If will be matched against the IPAddress Alternative name; option available since 3.6.0. |

### gnutls_typed_vdata_st

    typedef struct {
    	gnutls_vdata_types_t type;
    	unsigned char *data;
    	unsigned int size;
    } gnutls_typed_vdata_st;

### GNUTLS_MAX_SESSION_ID

    #define GNUTLS_MAX_SESSION_ID 32

### GNUTLS_HOOK_POST

    #define GNUTLS_HOOK_POST (1)

### GNUTLS_HOOK_PRE

    #define GNUTLS_HOOK_PRE (0)

### GNUTLS_HOOK_BOTH

    #define GNUTLS_HOOK_BOTH (-1)

### gnutls_handshake_post_client_hello_func

    #define             gnutls_handshake_post_client_hello_func

### gnutls_cred_set

    #define gnutls_cred_set gnutls_credentials_set

### gnutls_pubkey_t

    typedef struct gnutls_pubkey_st *gnutls_pubkey_t;

### gnutls_privkey_t

    typedef struct gnutls_privkey_st *gnutls_privkey_t;

### gnutls_x509_privkey_t

    typedef struct gnutls_x509_privkey_int *gnutls_x509_privkey_t;

### gnutls_x509_crl_t

    typedef struct gnutls_x509_crl_int *gnutls_x509_crl_t;

### gnutls_x509_crt_t

    typedef struct gnutls_x509_crt_int *gnutls_x509_crt_t;

### gnutls_x509_crq_t

    typedef struct gnutls_x509_crq_int *gnutls_x509_crq_t;

### gnutls_openpgp_keyring_t

    typedef struct gnutls_openpgp_keyring_int *gnutls_openpgp_keyring_t;

### gnutls_certificate_server_credentials

    typedef gnutls_certificate_credentials_t gnutls_certificate_server_credentials;

### gnutls_certificate_client_credentials

    typedef gnutls_certificate_credentials_t gnutls_certificate_client_credentials;

### enum gnutls_certificate_flags

Enumeration of different certificate credentials flags.

#### Members

GNUTLS_CERTIFICATE_SKIP_KEY_CERT_MATCH | Skip the key and certificate matching check. |
GNUTLS_CERTIFICATE_API_V2 | If set the gnutls_certificate_set_*key* functions will return an index of the added key pair instead of zero. |
GNUTLS_CERTIFICATE_SKIP_OCSP_RESPONSE_CHECK | If set, the gnutls_certificate_set_ocsp_status_request_file function, will not check whether the response set matches any of the certificates. |
GNUTLS_CERTIFICATE_VERIFY_CRLS | This will enable CRL verification when added in the certificate structure. When used, it requires CAs to be added before CRLs. |

### gnutls_ocsp_data_st

    typedef struct {
    	unsigned int version; /* must be zero */
    	gnutls_datum_t response;
    	time_t exptime;
    	unsigned char padding[32];
    } gnutls_ocsp_data_st;

### giovec_t

    typedef struct iovec giovec_t;

### enum gnutls_random_art_t

Enumeration of different random art types.

#### Members

GNUTLS_RANDOM_ART_OPENSSH | OpenSSH-style random art. |

### GNUTLS_IDNA_FORCE_2008

    #define GNUTLS_IDNA_FORCE_2008 (1 << 1)

### gnutls_srp_server_credentials_t

    typedef struct gnutls_srp_server_credentials_st *gnutls_srp_server_credentials_t;

### gnutls_srp_client_credentials_t

    typedef struct gnutls_srp_client_credentials_st *gnutls_srp_client_credentials_t;

### gnutls_srp_base64_encode_alloc

    #define gnutls_srp_base64_encode_alloc gnutls_srp_base64_encode2

### gnutls_srp_base64_decode_alloc

    #define gnutls_srp_base64_decode_alloc gnutls_srp_base64_decode2

### gnutls_psk_server_credentials_t

    typedef struct gnutls_psk_server_credentials_st *gnutls_psk_server_credentials_t;

### gnutls_psk_client_credentials_t

    typedef struct gnutls_psk_client_credentials_st *gnutls_psk_client_credentials_t;

### enum gnutls_psk_key_flags

Enumeration of different PSK key flags.

#### Members

GNUTLS_PSK_KEY_RAW | PSK-key in raw format. |
GNUTLS_PSK_KEY_HEX | PSK-key in hex format. |
GNUTLS_PSK_KEY_EXT | PSK-key is external and to be imported. |

### enum gnutls_x509_subject_alt_name_t

Enumeration of different subject alternative names types.

#### Members

GNUTLS_SAN_DNSNAME | DNS-name SAN. |
GNUTLS_SAN_RFC822NAME | E-mail address SAN. |
GNUTLS_SAN_URI | URI SAN. |
GNUTLS_SAN_IPADDRESS | IP address SAN. |
GNUTLS_SAN_OTHERNAME | OtherName SAN. |
GNUTLS_SAN_DN | DN SAN. |
GNUTLS_SAN_REGISTERED_ID | RegisteredID. |
GNUTLS_SAN_MAX |  |
GNUTLS_SAN_OTHERNAME_XMPP | Virtual SAN, used by certain functions for convenience. |
GNUTLS_SAN_OTHERNAME_KRB5PRINCIPAL | Virtual SAN, used by certain functions for convenience. |
GNUTLS_SAN_OTHERNAME_MSUSERPRINCIPAL | Virtual SAN, used by certain functions for convenience. |
GNUTLS_SAN_OTHERNAME_SRV | Virtual SAN, used by certain functions for convenience. |

### gnutls_openpgp_crt_t

    typedef struct gnutls_openpgp_crt_int *gnutls_openpgp_crt_t;

### gnutls_openpgp_privkey_t

    typedef struct gnutls_openpgp_privkey_int *gnutls_openpgp_privkey_t;

### gnutls_pkcs11_privkey_t

    typedef struct gnutls_pkcs11_privkey_st *gnutls_pkcs11_privkey_t;

### enum gnutls_privkey_type_t

Enumeration of different private key types.

#### Members

GNUTLS_PRIVKEY_X509 | X.509 private key, gnutls_x509_privkey_t. |
GNUTLS_PRIVKEY_OPENPGP | OpenPGP private key, gnutls_openpgp_privkey_t. |
GNUTLS_PRIVKEY_PKCS11 | PKCS11 private key, gnutls_pkcs11_privkey_t. |
GNUTLS_PRIVKEY_EXT | External private key, operating using callbacks. |

### gnutls_retr2_st

    typedef struct {
    	gnutls_certificate_type_t cert_type;
    	gnutls_privkey_type_t key_type;

    	union {
    		gnutls_x509_crt_t *x509;
    		gnutls_openpgp_crt_t pgp;
    	} cert;
    	unsigned int ncerts; /* one for pgp keys */

    	union {
    		gnutls_x509_privkey_t x509;
    		gnutls_openpgp_privkey_t pgp;
    		gnutls_pkcs11_privkey_t pkcs11;
    	} key;

    	unsigned int deinit_all; /* if non zero all keys will be deinited */
    } gnutls_retr2_st;

### gnutls_pem_base64_encode_alloc

    #define gnutls_pem_base64_encode_alloc gnutls_pem_base64_encode2

### gnutls_pem_base64_decode_alloc

    #define gnutls_pem_base64_decode_alloc gnutls_pem_base64_decode2

### GNUTLS_KEY_DIGITAL_SIGNATURE

    #define GNUTLS_KEY_DIGITAL_SIGNATURE 128

### GNUTLS_KEY_NON_REPUDIATION

    #define GNUTLS_KEY_NON_REPUDIATION 64

### GNUTLS_KEY_KEY_ENCIPHERMENT

    #define GNUTLS_KEY_KEY_ENCIPHERMENT 32

### GNUTLS_KEY_DATA_ENCIPHERMENT

    #define GNUTLS_KEY_DATA_ENCIPHERMENT 16

### GNUTLS_KEY_KEY_AGREEMENT

    #define GNUTLS_KEY_KEY_AGREEMENT 8

### GNUTLS_KEY_KEY_CERT_SIGN

    #define GNUTLS_KEY_KEY_CERT_SIGN 4

### GNUTLS_KEY_CRL_SIGN

    #define GNUTLS_KEY_CRL_SIGN 2

### GNUTLS_KEY_ENCIPHER_ONLY

    #define GNUTLS_KEY_ENCIPHER_ONLY 1

### GNUTLS_KEY_DECIPHER_ONLY

    #define GNUTLS_KEY_DECIPHER_ONLY 32768

### gnutls_tdb_t

    typedef struct gnutls_tdb_int *gnutls_tdb_t;

### GNUTLS_SCOMMIT_FLAG_ALLOW_BROKEN

    #define GNUTLS_SCOMMIT_FLAG_ALLOW_BROKEN 1

### enum gnutls_pin_flag_t

Enumeration of different flags that are input to the PIN function.

#### Members

GNUTLS_PIN_USER | The PIN for the user. |
GNUTLS_PIN_SO | The PIN for the security officer (admin). |
GNUTLS_PIN_FINAL_TRY | This is the final try before blocking. |
GNUTLS_PIN_COUNT_LOW | Few tries remain before token blocks. |
GNUTLS_PIN_CONTEXT_SPECIFIC | The PIN is for a specific action and key like signing. |
GNUTLS_PIN_WRONG | Last given PIN was not correct. |

### GNUTLS_PKCS11_PIN_USER

    #define GNUTLS_PKCS11_PIN_USER GNUTLS_PIN_USER

### GNUTLS_PKCS11_PIN_SO

    #define GNUTLS_PKCS11_PIN_SO GNUTLS_PIN_SO

### GNUTLS_PKCS11_PIN_FINAL_TRY

    #define GNUTLS_PKCS11_PIN_FINAL_TRY GNUTLS_PIN_FINAL_TRY

### GNUTLS_PKCS11_PIN_COUNT_LOW

    #define GNUTLS_PKCS11_PIN_COUNT_LOW GNUTLS_PIN_COUNT_LOW

### GNUTLS_PKCS11_PIN_CONTEXT_SPECIFIC

    #define GNUTLS_PKCS11_PIN_CONTEXT_SPECIFIC GNUTLS_PIN_CONTEXT_SPECIFIC

### GNUTLS_PKCS11_PIN_WRONG

    #define GNUTLS_PKCS11_PIN_WRONG GNUTLS_PIN_WRONG

### gnutls_buffer_t

    typedef struct gnutls_buffer_st *gnutls_buffer_t;

### GNUTLS_UTF8_IGNORE_ERRS

    #define GNUTLS_UTF8_IGNORE_ERRS 1

### gnutls_ext_priv_data_t

    typedef void *gnutls_ext_priv_data_t;

### GNUTLS_EXT_RAW_FLAG_TLS_CLIENT_HELLO

    #define GNUTLS_EXT_RAW_FLAG_TLS_CLIENT_HELLO 1

### GNUTLS_EXT_RAW_FLAG_DTLS_CLIENT_HELLO

    #define GNUTLS_EXT_RAW_FLAG_DTLS_CLIENT_HELLO (1 << 1)

### enum gnutls_ext_parse_type_t

Enumeration of different TLS extension parsing phases. The `gnutls_ext_parse_type_t` indicates the time/phase an extension is parsed during Client or Server hello parsing.

#### Members

GNUTLS_EXT_ANY | Any extension type (should not be used as it is used only internally). |
GNUTLS_EXT_APPLICATION | Parsed after `GNUTLS_EXT_MANDATORY` |
GNUTLS_EXT_TLS | TLS-internal extensions, parsed after `GNUTLS_EXT_APPLICATION` . |
GNUTLS_EXT_MANDATORY | Parsed after `GNUTLS_EXT_VERSION_NEG` and even when resuming. |
GNUTLS_EXT_NONE | Never to be parsed |
GNUTLS_EXT_VERSION_NEG | Extensions to be parsed first for TLS version negotiation. |

### enum gnutls_ext_flags_t

Enumeration of different TLS extension registration flags.

#### Members

GNUTLS_EXT_FLAG_OVERRIDE_INTERNAL | If specified the extension registered will override the internal; this does not work with extensions existing prior to 3.6.0. |
GNUTLS_EXT_FLAG_CLIENT_HELLO | This extension can be present in a client hello |
GNUTLS_EXT_FLAG_TLS12_SERVER_HELLO | This extension can be present in a TLS1.2 or earlier server hello |
GNUTLS_EXT_FLAG_TLS13_SERVER_HELLO | This extension can be present in a TLS1.3 server hello |
GNUTLS_EXT_FLAG_EE | This extension can be present in encrypted extensions message |
GNUTLS_EXT_FLAG_HRR | This extension can be present in hello retry request message |
GNUTLS_EXT_FLAG_IGNORE_CLIENT_REQUEST | When flag is present, this extension will be send even if the client didn't advertise it. An extension of this type is the Cookie TLS1.3 extension. |
GNUTLS_EXT_FLAG_TLS | This extension can be present under TLS; otherwise ignored. |
GNUTLS_EXT_FLAG_DTLS | This extension can be present under DTLS; otherwise ignored. |

### gnutls_anti_replay_t

    typedef struct gnutls_anti_replay_st *gnutls_anti_replay_t;

### enum gnutls_record_encryption_level_t

Enumeration of different levels of record encryption currently in place. This is used by `gnutls_handshake_set_read_function()` and `gnutls_handshake_write()`.

#### Members

GNUTLS_ENCRYPTION_LEVEL_INITIAL | initial level that doesn't involve any encryption |
GNUTLS_ENCRYPTION_LEVEL_EARLY | early traffic secret is installed |
GNUTLS_ENCRYPTION_LEVEL_HANDSHAKE | handshake traffic secret is installed |
GNUTLS_ENCRYPTION_LEVEL_APPLICATION | application traffic secret is installed |

Since: 3.7.0

### enum gnutls_fips_mode_t

Enumeration of different operational modes under FIPS140-2.

#### Members

GNUTLS_FIPS140_DISABLED | The FIPS140-2 mode is disabled. |
GNUTLS_FIPS140_STRICT | The default mode; all forbidden operations will cause an operation failure via error code. |
GNUTLS_FIPS140_SELFTESTS | A transient state during library initialization. That state cannot be set or seen by applications. |
GNUTLS_FIPS140_LAX | The library still uses the FIPS140-2 relevant algorithms but all forbidden by FIPS140-2 operations are allowed; this is useful when the application is aware of the followed security policy, and needs to utilize disallowed operations for other reasons (e.g., compatibility). |
GNUTLS_FIPS140_LOG | Similarly to `GNUTLS_FIPS140_LAX`, it allows forbidden operations; any use of them results to a message to the audit callback functions. |

### GNUTLS_FIPS140_SET_MODE_THREAD

    #define GNUTLS_FIPS140_SET_MODE_THREAD 1

### gnutls_fips140_context_t

    typedef struct gnutls_fips140_context_st *gnutls_fips140_context_t;

### enum gnutls_fips140_operation_state_t

The FIPS operation state set by the preceding operation.

There are state transition rules among the enum values:

- When the context is attached to a thread, it will be set to reset to the `GNUTLS_FIPS140_OP_INITIAL` state

- From the `GNUTLS_FIPS140_OP_INITIAL` state, the context can transition to either `GNUTLS_FIPS140_OP_APPROVED`, `GNUTLS_FIPS140_OP_NOT_APPROVED`, or `GNUTLS_FIPS140_OP_ERROR`

- From the `GNUTLS_FIPS140_OP_APPROVED` state, the context can transition to `GNUTLS_FIPS140_OP_NOT_APPROVED`

- All other transitions are prohibited.

#### Members

GNUTLS_FIPS140_OP_INITIAL | no previous operation has done |
GNUTLS_FIPS140_OP_APPROVED | the previous operation was FIPS approved |
GNUTLS_FIPS140_OP_NOT_APPROVED | the previous operation was not FIPS approved |
GNUTLS_FIPS140_OP_ERROR | the previous operation caused an error regardless of FIPS |

Since: 3.7.3

### enum gnutls_transport_ktls_enable_flags_t

Flag enumeration of ktls enable status for recv and send functions. This is used by `gnutls_transport_is_ktls_enabled()`.

#### Members

GNUTLS_KTLS_RECV | ktls enabled for recv function. |
GNUTLS_KTLS_SEND | ktls enabled for send function. |
GNUTLS_KTLS_DUPLEX | ktls enabled for both recv and send functions. |

Since: 3.7.3

### GNUTLS_E_SUCCESS

    #define GNUTLS_E_SUCCESS 0

### GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM

    #define GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM -3

### GNUTLS_E_UNKNOWN_CIPHER_TYPE

    #define GNUTLS_E_UNKNOWN_CIPHER_TYPE -6

### GNUTLS_E_LARGE_PACKET

    #define GNUTLS_E_LARGE_PACKET -7

### GNUTLS_E_UNSUPPORTED_VERSION_PACKET

    #define GNUTLS_E_UNSUPPORTED_VERSION_PACKET -8 /* GNUTLS_A_PROTOCOL_VERSION */

### GNUTLS_E_TLS_PACKET_DECODING_ERROR

    #define GNUTLS_E_TLS_PACKET_DECODING_ERROR GNUTLS_E_UNEXPECTED_PACKET_LENGTH

### GNUTLS_E_UNEXPECTED_PACKET_LENGTH

    #define GNUTLS_E_UNEXPECTED_PACKET_LENGTH -9 /* GNUTLS_A_DECODE_ERROR */

### GNUTLS_E_INVALID_SESSION

    #define GNUTLS_E_INVALID_SESSION -10

### GNUTLS_E_FATAL_ALERT_RECEIVED

    #define GNUTLS_E_FATAL_ALERT_RECEIVED -12

### GNUTLS_E_UNEXPECTED_PACKET

    #define GNUTLS_E_UNEXPECTED_PACKET -15 /* GNUTLS_A_UNEXPECTED_MESSAGE */

### GNUTLS_E_WARNING_ALERT_RECEIVED

    #define GNUTLS_E_WARNING_ALERT_RECEIVED -16

### GNUTLS_E_ERROR_IN_FINISHED_PACKET

    #define GNUTLS_E_ERROR_IN_FINISHED_PACKET -18

### GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET

    #define GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET -19

### GNUTLS_E_UNKNOWN_CIPHER_SUITE

    #define GNUTLS_E_UNKNOWN_CIPHER_SUITE -21

### GNUTLS_E_UNWANTED_ALGORITHM

    #define GNUTLS_E_UNWANTED_ALGORITHM -22

### GNUTLS_E_MPI_SCAN_FAILED

    #define GNUTLS_E_MPI_SCAN_FAILED -23

### GNUTLS_E_DECRYPTION_FAILED

    #define             GNUTLS_E_DECRYPTION_FAILED

### GNUTLS_E_MEMORY_ERROR

    #define GNUTLS_E_MEMORY_ERROR -25

### GNUTLS_E_DECOMPRESSION_FAILED

    #define GNUTLS_E_DECOMPRESSION_FAILED -26 /* GNUTLS_A_DECOMPRESSION_FAILURE */

### GNUTLS_E_COMPRESSION_FAILED

    #define GNUTLS_E_COMPRESSION_FAILED -27

### GNUTLS_E_AGAIN

    #define GNUTLS_E_AGAIN -28

### GNUTLS_E_EXPIRED

    #define GNUTLS_E_EXPIRED -29

### GNUTLS_E_DB_ERROR

    #define GNUTLS_E_DB_ERROR -30

### GNUTLS_E_SRP_PWD_ERROR

    #define GNUTLS_E_SRP_PWD_ERROR GNUTLS_E_KEYFILE_ERROR

### GNUTLS_E_KEYFILE_ERROR

    #define GNUTLS_E_KEYFILE_ERROR -31

### GNUTLS_E_INSUFFICIENT_CREDENTIALS

    #define GNUTLS_E_INSUFFICIENT_CREDENTIALS -32

### GNUTLS_E_INSUFICIENT_CREDENTIALS

    #define             GNUTLS_E_INSUFICIENT_CREDENTIALS

### GNUTLS_E_INSUFFICIENT_CRED

    #define GNUTLS_E_INSUFFICIENT_CRED GNUTLS_E_INSUFFICIENT_CREDENTIALS

### GNUTLS_E_INSUFICIENT_CRED

    #define             GNUTLS_E_INSUFICIENT_CRED

### GNUTLS_E_HASH_FAILED

    #define GNUTLS_E_HASH_FAILED -33

### GNUTLS_E_BASE64_DECODING_ERROR

    #define GNUTLS_E_BASE64_DECODING_ERROR -34

### GNUTLS_E_MPI_PRINT_FAILED

    #define GNUTLS_E_MPI_PRINT_FAILED -35

### GNUTLS_E_REHANDSHAKE

    #define GNUTLS_E_REHANDSHAKE -37 /* GNUTLS_A_NO_RENEGOTIATION */

### GNUTLS_E_GOT_APPLICATION_DATA

    #define GNUTLS_E_GOT_APPLICATION_DATA -38

### GNUTLS_E_RECORD_LIMIT_REACHED

    #define GNUTLS_E_RECORD_LIMIT_REACHED -39

### GNUTLS_E_ENCRYPTION_FAILED

    #define GNUTLS_E_ENCRYPTION_FAILED -40

### GNUTLS_E_PK_ENCRYPTION_FAILED

    #define GNUTLS_E_PK_ENCRYPTION_FAILED -44

### GNUTLS_E_PK_DECRYPTION_FAILED

    #define GNUTLS_E_PK_DECRYPTION_FAILED -45

### GNUTLS_E_PK_SIGN_FAILED

    #define GNUTLS_E_PK_SIGN_FAILED -46

### GNUTLS_E_X509_UNSUPPORTED_CRITICAL_EXTENSION

    #define GNUTLS_E_X509_UNSUPPORTED_CRITICAL_EXTENSION -47

### GNUTLS_E_KEY_USAGE_VIOLATION

    #define GNUTLS_E_KEY_USAGE_VIOLATION -48

### GNUTLS_E_NO_CERTIFICATE_FOUND

    #define GNUTLS_E_NO_CERTIFICATE_FOUND -49 /* GNUTLS_A_BAD_CERTIFICATE */

### GNUTLS_E_INVALID_REQUEST

    #define GNUTLS_E_INVALID_REQUEST -50

### GNUTLS_E_SHORT_MEMORY_BUFFER

    #define GNUTLS_E_SHORT_MEMORY_BUFFER -51

### GNUTLS_E_INTERRUPTED

    #define GNUTLS_E_INTERRUPTED -52

### GNUTLS_E_PUSH_ERROR

    #define GNUTLS_E_PUSH_ERROR -53

### GNUTLS_E_PULL_ERROR

    #define GNUTLS_E_PULL_ERROR -54

### GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER

    #define GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER -55 /* GNUTLS_A_ILLEGAL_PARAMETER */

### GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE

    #define GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE -56

### GNUTLS_E_PKCS1_WRONG_PAD

    #define GNUTLS_E_PKCS1_WRONG_PAD -57

### GNUTLS_E_RECEIVED_ILLEGAL_EXTENSION

    #define GNUTLS_E_RECEIVED_ILLEGAL_EXTENSION -58

### GNUTLS_E_INTERNAL_ERROR

    #define GNUTLS_E_INTERNAL_ERROR -59

### GNUTLS_E_DH_PRIME_UNACCEPTABLE

    #define GNUTLS_E_DH_PRIME_UNACCEPTABLE -63

### GNUTLS_E_FILE_ERROR

    #define GNUTLS_E_FILE_ERROR -64

### GNUTLS_E_TOO_MANY_EMPTY_PACKETS

    #define GNUTLS_E_TOO_MANY_EMPTY_PACKETS -78

### GNUTLS_E_UNKNOWN_PK_ALGORITHM

    #define GNUTLS_E_UNKNOWN_PK_ALGORITHM -80

### GNUTLS_E_TOO_MANY_HANDSHAKE_PACKETS

    #define GNUTLS_E_TOO_MANY_HANDSHAKE_PACKETS -81

### GNUTLS_E_RECEIVED_DISALLOWED_NAME

    #define GNUTLS_E_RECEIVED_DISALLOWED_NAME -82 /* GNUTLS_A_ILLEGAL_PARAMETER */

### GNUTLS_E_CERTIFICATE_REQUIRED

    #define GNUTLS_E_CERTIFICATE_REQUIRED -112 /* GNUTLS_A_CERTIFICATE_REQUIRED */

### GNUTLS_E_UNSUPPORTED_ENCRYPTION_ALGORITHM

    #define GNUTLS_E_UNSUPPORTED_ENCRYPTION_ALGORITHM -113

### GNUTLS_E_NO_TEMPORARY_RSA_PARAMS

    #define GNUTLS_E_NO_TEMPORARY_RSA_PARAMS -84

### GNUTLS_E_NO_COMPRESSION_ALGORITHMS

    #define GNUTLS_E_NO_COMPRESSION_ALGORITHMS -86

### GNUTLS_E_NO_CIPHER_SUITES

    #define GNUTLS_E_NO_CIPHER_SUITES -87

### GNUTLS_E_OPENPGP_GETKEY_FAILED

    #define GNUTLS_E_OPENPGP_GETKEY_FAILED -88

### GNUTLS_E_PK_SIG_VERIFY_FAILED

    #define GNUTLS_E_PK_SIG_VERIFY_FAILED -89

### GNUTLS_E_ILLEGAL_SRP_USERNAME

    #define GNUTLS_E_ILLEGAL_SRP_USERNAME -90

### GNUTLS_E_SRP_PWD_PARSING_ERROR

    #define GNUTLS_E_SRP_PWD_PARSING_ERROR GNUTLS_E_KEYFILE_PARSING_ERROR

### GNUTLS_E_KEYFILE_PARSING_ERROR

    #define GNUTLS_E_KEYFILE_PARSING_ERROR -91

### GNUTLS_E_NO_TEMPORARY_DH_PARAMS

    #define GNUTLS_E_NO_TEMPORARY_DH_PARAMS -93

### GNUTLS_E_ASN1_ELEMENT_NOT_FOUND

    #define GNUTLS_E_ASN1_ELEMENT_NOT_FOUND -67

### GNUTLS_E_ASN1_IDENTIFIER_NOT_FOUND

    #define GNUTLS_E_ASN1_IDENTIFIER_NOT_FOUND -68

### GNUTLS_E_ASN1_DER_ERROR

    #define GNUTLS_E_ASN1_DER_ERROR -69

### GNUTLS_E_ASN1_VALUE_NOT_FOUND

    #define GNUTLS_E_ASN1_VALUE_NOT_FOUND -70

### GNUTLS_E_ASN1_GENERIC_ERROR

    #define GNUTLS_E_ASN1_GENERIC_ERROR -71

### GNUTLS_E_ASN1_VALUE_NOT_VALID

    #define GNUTLS_E_ASN1_VALUE_NOT_VALID -72

### GNUTLS_E_ASN1_TAG_ERROR

    #define GNUTLS_E_ASN1_TAG_ERROR -73

### GNUTLS_E_ASN1_TAG_IMPLICIT

    #define GNUTLS_E_ASN1_TAG_IMPLICIT -74

### GNUTLS_E_ASN1_TYPE_ANY_ERROR

    #define GNUTLS_E_ASN1_TYPE_ANY_ERROR -75

### GNUTLS_E_ASN1_SYNTAX_ERROR

    #define GNUTLS_E_ASN1_SYNTAX_ERROR -76

### GNUTLS_E_ASN1_DER_OVERFLOW

    #define GNUTLS_E_ASN1_DER_OVERFLOW -77

### GNUTLS_E_OPENPGP_UID_REVOKED

    #define GNUTLS_E_OPENPGP_UID_REVOKED -79

### GNUTLS_E_CERTIFICATE_ERROR

    #define GNUTLS_E_CERTIFICATE_ERROR -43

### GNUTLS_E_X509_CERTIFICATE_ERROR

    #define GNUTLS_E_X509_CERTIFICATE_ERROR GNUTLS_E_CERTIFICATE_ERROR

### GNUTLS_E_CERTIFICATE_KEY_MISMATCH

    #define GNUTLS_E_CERTIFICATE_KEY_MISMATCH -60

### GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE

    #define             GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE

### GNUTLS_E_X509_UNKNOWN_SAN

    #define GNUTLS_E_X509_UNKNOWN_SAN -62

### GNUTLS_E_OPENPGP_FINGERPRINT_UNSUPPORTED

    #define GNUTLS_E_OPENPGP_FINGERPRINT_UNSUPPORTED -94

### GNUTLS_E_X509_UNSUPPORTED_ATTRIBUTE

    #define GNUTLS_E_X509_UNSUPPORTED_ATTRIBUTE -95

### GNUTLS_E_UNKNOWN_HASH_ALGORITHM

    #define GNUTLS_E_UNKNOWN_HASH_ALGORITHM -96

### GNUTLS_E_UNKNOWN_PKCS_CONTENT_TYPE

    #define GNUTLS_E_UNKNOWN_PKCS_CONTENT_TYPE -97

### GNUTLS_E_UNKNOWN_PKCS_BAG_TYPE

    #define GNUTLS_E_UNKNOWN_PKCS_BAG_TYPE -98

### GNUTLS_E_INVALID_PASSWORD

    #define GNUTLS_E_INVALID_PASSWORD -99

### GNUTLS_E_MAC_VERIFY_FAILED

    #define GNUTLS_E_MAC_VERIFY_FAILED -100 /* for PKCS #12 MAC */

### GNUTLS_E_CONSTRAINT_ERROR

    #define GNUTLS_E_CONSTRAINT_ERROR -101

### GNUTLS_E_WARNING_IA_IPHF_RECEIVED

    #define GNUTLS_E_WARNING_IA_IPHF_RECEIVED -102

### GNUTLS_E_WARNING_IA_FPHF_RECEIVED

    #define GNUTLS_E_WARNING_IA_FPHF_RECEIVED -103

### GNUTLS_E_IA_VERIFY_FAILED

    #define GNUTLS_E_IA_VERIFY_FAILED -104

### GNUTLS_E_UNKNOWN_ALGORITHM

    #define GNUTLS_E_UNKNOWN_ALGORITHM -105

### GNUTLS_E_UNSUPPORTED_SIGNATURE_ALGORITHM

    #define GNUTLS_E_UNSUPPORTED_SIGNATURE_ALGORITHM -106

### GNUTLS_E_SAFE_RENEGOTIATION_FAILED

    #define GNUTLS_E_SAFE_RENEGOTIATION_FAILED -107

### GNUTLS_E_UNSAFE_RENEGOTIATION_DENIED

    #define GNUTLS_E_UNSAFE_RENEGOTIATION_DENIED -108

### GNUTLS_E_UNKNOWN_SRP_USERNAME

    #define GNUTLS_E_UNKNOWN_SRP_USERNAME -109

### GNUTLS_E_PREMATURE_TERMINATION

    #define GNUTLS_E_PREMATURE_TERMINATION -110

### GNUTLS_E_MALFORMED_CIDR

    #define GNUTLS_E_MALFORMED_CIDR -111

### GNUTLS_E_BASE64_ENCODING_ERROR

    #define GNUTLS_E_BASE64_ENCODING_ERROR -201

### GNUTLS_E_INCOMPATIBLE_GCRYPT_LIBRARY

    #define GNUTLS_E_INCOMPATIBLE_GCRYPT_LIBRARY -202 /* obsolete */

### GNUTLS_E_INCOMPATIBLE_CRYPTO_LIBRARY

    #define GNUTLS_E_INCOMPATIBLE_CRYPTO_LIBRARY -202

### GNUTLS_E_INCOMPATIBLE_LIBTASN1_LIBRARY

    #define GNUTLS_E_INCOMPATIBLE_LIBTASN1_LIBRARY -203

### GNUTLS_E_OPENPGP_KEYRING_ERROR

    #define GNUTLS_E_OPENPGP_KEYRING_ERROR -204

### GNUTLS_E_X509_UNSUPPORTED_OID

    #define GNUTLS_E_X509_UNSUPPORTED_OID -205

### GNUTLS_E_RANDOM_FAILED

    #define GNUTLS_E_RANDOM_FAILED -206

### GNUTLS_E_BASE64_UNEXPECTED_HEADER_ERROR

    #define GNUTLS_E_BASE64_UNEXPECTED_HEADER_ERROR -207

### GNUTLS_E_OPENPGP_SUBKEY_ERROR

    #define GNUTLS_E_OPENPGP_SUBKEY_ERROR -208

### GNUTLS_E_CRYPTO_ALREADY_REGISTERED

    #define GNUTLS_E_CRYPTO_ALREADY_REGISTERED GNUTLS_E_ALREADY_REGISTERED

### GNUTLS_E_ALREADY_REGISTERED

    #define GNUTLS_E_ALREADY_REGISTERED -209

### GNUTLS_E_HANDSHAKE_TOO_LARGE

    #define GNUTLS_E_HANDSHAKE_TOO_LARGE -210

### GNUTLS_E_CRYPTODEV_IOCTL_ERROR

    #define GNUTLS_E_CRYPTODEV_IOCTL_ERROR -211

### GNUTLS_E_CRYPTODEV_DEVICE_ERROR

    #define GNUTLS_E_CRYPTODEV_DEVICE_ERROR -212

### GNUTLS_E_CHANNEL_BINDING_NOT_AVAILABLE

    #define GNUTLS_E_CHANNEL_BINDING_NOT_AVAILABLE -213

### GNUTLS_E_BAD_COOKIE

    #define GNUTLS_E_BAD_COOKIE -214

### GNUTLS_E_OPENPGP_PREFERRED_KEY_ERROR

    #define GNUTLS_E_OPENPGP_PREFERRED_KEY_ERROR -215

### GNUTLS_E_INCOMPAT_DSA_KEY_WITH_TLS_PROTOCOL

    #define GNUTLS_E_INCOMPAT_DSA_KEY_WITH_TLS_PROTOCOL -216

### GNUTLS_E_INSUFFICIENT_SECURITY

    #define GNUTLS_E_INSUFFICIENT_SECURITY -217

### GNUTLS_E_HEARTBEAT_PONG_RECEIVED

    #define GNUTLS_E_HEARTBEAT_PONG_RECEIVED -292

### GNUTLS_E_HEARTBEAT_PING_RECEIVED

    #define GNUTLS_E_HEARTBEAT_PING_RECEIVED -293

### GNUTLS_E_UNRECOGNIZED_NAME

    #define GNUTLS_E_UNRECOGNIZED_NAME -294

### GNUTLS_E_PKCS11_ERROR

    #define GNUTLS_E_PKCS11_ERROR -300

### GNUTLS_E_PKCS11_LOAD_ERROR

    #define GNUTLS_E_PKCS11_LOAD_ERROR -301

### GNUTLS_E_PARSING_ERROR

    #define GNUTLS_E_PARSING_ERROR -302

### GNUTLS_E_PKCS11_PIN_ERROR

    #define GNUTLS_E_PKCS11_PIN_ERROR -303

### GNUTLS_E_PKCS11_SLOT_ERROR

    #define GNUTLS_E_PKCS11_SLOT_ERROR -305

### GNUTLS_E_LOCKING_ERROR

    #define GNUTLS_E_LOCKING_ERROR -306

### GNUTLS_E_PKCS11_ATTRIBUTE_ERROR

    #define GNUTLS_E_PKCS11_ATTRIBUTE_ERROR -307

### GNUTLS_E_PKCS11_DEVICE_ERROR

    #define GNUTLS_E_PKCS11_DEVICE_ERROR -308

### GNUTLS_E_PKCS11_DATA_ERROR

    #define GNUTLS_E_PKCS11_DATA_ERROR -309

### GNUTLS_E_PKCS11_UNSUPPORTED_FEATURE_ERROR

    #define GNUTLS_E_PKCS11_UNSUPPORTED_FEATURE_ERROR -310

### GNUTLS_E_PKCS11_KEY_ERROR

    #define GNUTLS_E_PKCS11_KEY_ERROR -311

### GNUTLS_E_PKCS11_PIN_EXPIRED

    #define GNUTLS_E_PKCS11_PIN_EXPIRED -312

### GNUTLS_E_PKCS11_PIN_LOCKED

    #define GNUTLS_E_PKCS11_PIN_LOCKED -313

### GNUTLS_E_PKCS11_SESSION_ERROR

    #define GNUTLS_E_PKCS11_SESSION_ERROR -314

### GNUTLS_E_PKCS11_SIGNATURE_ERROR

    #define GNUTLS_E_PKCS11_SIGNATURE_ERROR -315

### GNUTLS_E_PKCS11_TOKEN_ERROR

    #define GNUTLS_E_PKCS11_TOKEN_ERROR -316

### GNUTLS_E_PKCS11_USER_ERROR

    #define GNUTLS_E_PKCS11_USER_ERROR -317

### GNUTLS_E_CRYPTO_INIT_FAILED

    #define GNUTLS_E_CRYPTO_INIT_FAILED -318

### GNUTLS_E_TIMEDOUT

    #define GNUTLS_E_TIMEDOUT -319

### GNUTLS_E_USER_ERROR

    #define GNUTLS_E_USER_ERROR -320

### GNUTLS_E_ECC_NO_SUPPORTED_CURVES

    #define GNUTLS_E_ECC_NO_SUPPORTED_CURVES -321

### GNUTLS_E_ECC_UNSUPPORTED_CURVE

    #define GNUTLS_E_ECC_UNSUPPORTED_CURVE -322

### GNUTLS_E_PKCS11_REQUESTED_OBJECT_NOT_AVAILBLE

    #define GNUTLS_E_PKCS11_REQUESTED_OBJECT_NOT_AVAILBLE -323

### GNUTLS_E_CERTIFICATE_LIST_UNSORTED

    #define GNUTLS_E_CERTIFICATE_LIST_UNSORTED -324

### GNUTLS_E_ILLEGAL_PARAMETER

    #define GNUTLS_E_ILLEGAL_PARAMETER -325 /* GNUTLS_A_ILLEGAL_PARAMETER */

### GNUTLS_E_NO_PRIORITIES_WERE_SET

    #define GNUTLS_E_NO_PRIORITIES_WERE_SET -326

### GNUTLS_E_X509_UNSUPPORTED_EXTENSION

    #define GNUTLS_E_X509_UNSUPPORTED_EXTENSION -327

### GNUTLS_E_SESSION_EOF

    #define GNUTLS_E_SESSION_EOF -328

### GNUTLS_E_TPM_ERROR

    #define GNUTLS_E_TPM_ERROR -329

### GNUTLS_E_TPM_KEY_PASSWORD_ERROR

    #define GNUTLS_E_TPM_KEY_PASSWORD_ERROR -330

### GNUTLS_E_TPM_SRK_PASSWORD_ERROR

    #define GNUTLS_E_TPM_SRK_PASSWORD_ERROR -331

### GNUTLS_E_TPM_SESSION_ERROR

    #define GNUTLS_E_TPM_SESSION_ERROR -332

### GNUTLS_E_TPM_KEY_NOT_FOUND

    #define GNUTLS_E_TPM_KEY_NOT_FOUND -333

### GNUTLS_E_TPM_UNINITIALIZED

    #define GNUTLS_E_TPM_UNINITIALIZED -334

### GNUTLS_E_TPM_NO_LIB

    #define GNUTLS_E_TPM_NO_LIB -335

### GNUTLS_E_NO_CERTIFICATE_STATUS

    #define GNUTLS_E_NO_CERTIFICATE_STATUS -340

### GNUTLS_E_OCSP_RESPONSE_ERROR

    #define GNUTLS_E_OCSP_RESPONSE_ERROR -341

### GNUTLS_E_RANDOM_DEVICE_ERROR

    #define GNUTLS_E_RANDOM_DEVICE_ERROR -342

### GNUTLS_E_AUTH_ERROR

    #define GNUTLS_E_AUTH_ERROR -343

### GNUTLS_E_NO_APPLICATION_PROTOCOL

    #define GNUTLS_E_NO_APPLICATION_PROTOCOL -344

### GNUTLS_E_SOCKETS_INIT_ERROR

    #define GNUTLS_E_SOCKETS_INIT_ERROR -345

### GNUTLS_E_KEY_IMPORT_FAILED

    #define GNUTLS_E_KEY_IMPORT_FAILED -346

### GNUTLS_E_INAPPROPRIATE_FALLBACK

    #define             GNUTLS_E_INAPPROPRIATE_FALLBACK

### GNUTLS_E_CERTIFICATE_VERIFICATION_ERROR

    #define GNUTLS_E_CERTIFICATE_VERIFICATION_ERROR -348

### GNUTLS_E_PRIVKEY_VERIFICATION_ERROR

    #define GNUTLS_E_PRIVKEY_VERIFICATION_ERROR -349

### GNUTLS_E_UNEXPECTED_EXTENSIONS_LENGTH

    #define GNUTLS_E_UNEXPECTED_EXTENSIONS_LENGTH -350 /*GNUTLS_A_DECODE_ERROR */

### GNUTLS_E_ASN1_EMBEDDED_NULL_IN_STRING

    #define GNUTLS_E_ASN1_EMBEDDED_NULL_IN_STRING -351

### GNUTLS_E_SELF_TEST_ERROR

    #define GNUTLS_E_SELF_TEST_ERROR -400

### GNUTLS_E_NO_SELF_TEST

    #define GNUTLS_E_NO_SELF_TEST -401

### GNUTLS_E_LIB_IN_ERROR_STATE

    #define GNUTLS_E_LIB_IN_ERROR_STATE -402

### GNUTLS_E_PK_GENERATION_ERROR

    #define GNUTLS_E_PK_GENERATION_ERROR -403

### GNUTLS_E_IDNA_ERROR

    #define GNUTLS_E_IDNA_ERROR -404

### GNUTLS_E_NEED_FALLBACK

    #define GNUTLS_E_NEED_FALLBACK -405

### GNUTLS_E_SESSION_USER_ID_CHANGED

    #define GNUTLS_E_SESSION_USER_ID_CHANGED -406

### GNUTLS_E_HANDSHAKE_DURING_FALSE_START

    #define GNUTLS_E_HANDSHAKE_DURING_FALSE_START -407

### GNUTLS_E_UNAVAILABLE_DURING_HANDSHAKE

    #define GNUTLS_E_UNAVAILABLE_DURING_HANDSHAKE -408

### GNUTLS_E_PK_INVALID_PUBKEY

    #define GNUTLS_E_PK_INVALID_PUBKEY -409

### GNUTLS_E_PK_INVALID_PRIVKEY

    #define GNUTLS_E_PK_INVALID_PRIVKEY -410

### GNUTLS_E_NOT_YET_ACTIVATED

    #define GNUTLS_E_NOT_YET_ACTIVATED -411

### GNUTLS_E_INVALID_UTF8_STRING

    #define GNUTLS_E_INVALID_UTF8_STRING -412

### GNUTLS_E_NO_EMBEDDED_DATA

    #define GNUTLS_E_NO_EMBEDDED_DATA -413

### GNUTLS_E_INVALID_UTF8_EMAIL

    #define GNUTLS_E_INVALID_UTF8_EMAIL -414

### GNUTLS_E_INVALID_PASSWORD_STRING

    #define GNUTLS_E_INVALID_PASSWORD_STRING -415

### GNUTLS_E_CERTIFICATE_TIME_ERROR

    #define GNUTLS_E_CERTIFICATE_TIME_ERROR -416

### GNUTLS_E_RECORD_OVERFLOW

    #define GNUTLS_E_RECORD_OVERFLOW -417 /* GNUTLS_A_RECORD_OVERFLOW */

### GNUTLS_E_ASN1_TIME_ERROR

    #define GNUTLS_E_ASN1_TIME_ERROR -418

### GNUTLS_E_INCOMPATIBLE_SIG_WITH_KEY

    #define GNUTLS_E_INCOMPATIBLE_SIG_WITH_KEY -419

### GNUTLS_E_PK_INVALID_PUBKEY_PARAMS

    #define GNUTLS_E_PK_INVALID_PUBKEY_PARAMS -420

### GNUTLS_E_PK_NO_VALIDATION_PARAMS

    #define GNUTLS_E_PK_NO_VALIDATION_PARAMS -421

### GNUTLS_E_OCSP_MISMATCH_WITH_CERTS

    #define GNUTLS_E_OCSP_MISMATCH_WITH_CERTS -422

### GNUTLS_E_NO_COMMON_KEY_SHARE

    #define GNUTLS_E_NO_COMMON_KEY_SHARE -423

### GNUTLS_E_REAUTH_REQUEST

    #define GNUTLS_E_REAUTH_REQUEST -424

### GNUTLS_E_TOO_MANY_MATCHES

    #define GNUTLS_E_TOO_MANY_MATCHES -425

### GNUTLS_E_CRL_VERIFICATION_ERROR

    #define GNUTLS_E_CRL_VERIFICATION_ERROR -426

### GNUTLS_E_MISSING_EXTENSION

    #define GNUTLS_E_MISSING_EXTENSION -427

### GNUTLS_E_DB_ENTRY_EXISTS

    #define GNUTLS_E_DB_ENTRY_EXISTS -428

### GNUTLS_E_EARLY_DATA_REJECTED

    #define GNUTLS_E_EARLY_DATA_REJECTED -429

### GNUTLS_E_X509_DUPLICATE_EXTENSION

    #define GNUTLS_E_X509_DUPLICATE_EXTENSION -430

### GNUTLS_E_UNIMPLEMENTED_FEATURE

    #define GNUTLS_E_UNIMPLEMENTED_FEATURE -1250

### GNUTLS_E_INT_RET_0

    #define GNUTLS_E_INT_RET_0 -1251

### GNUTLS_E_INT_CHECK_AGAIN

    #define GNUTLS_E_INT_CHECK_AGAIN -1252

### GNUTLS_E_APPLICATION_ERROR_MAX

    #define GNUTLS_E_APPLICATION_ERROR_MAX -65000

### GNUTLS_E_APPLICATION_ERROR_MIN

    #define GNUTLS_E_APPLICATION_ERROR_MIN -65500

### struct gnutls_certificate_credentials_st

    struct gnutls_certificate_credentials_st;

### struct gnutls_dh_params_int

    struct gnutls_dh_params_int;

### struct gnutls_openpgp_crt_int

    struct gnutls_openpgp_crt_int;

### struct gnutls_openpgp_keyring_int

    struct gnutls_openpgp_keyring_int;

### struct gnutls_openpgp_privkey_int

    struct gnutls_openpgp_privkey_int;

### struct gnutls_pkcs11_privkey_st

    struct gnutls_pkcs11_privkey_st {
    	gnutls_pk_algorithm_t pk_algorithm;
    	unsigned int rsa_pss_ok; /* if it is an RSA key, it can do RSA-PSS */
    	unsigned int bits;

    	unsigned int flags;
    	struct p11_kit_uri *uinfo;
    	char *url;

    	struct pkcs11_session_info sinfo;
    	ck_object_handle_t ref; /* the key in the session */
    	unsigned reauth; /* whether we need to login on each operation */

    	void *mutex; /* lock for operations requiring co-ordination */

    	struct pin_info_st pin;
    };

### struct gnutls_priority_st

    struct gnutls_priority_st {
    	priority_st protocol;
    	priority_st client_ctype;
    	priority_st server_ctype;

    	/* The following are not necessary to be stored in
    	 * the structure; however they are required by the
    	 * external APIs: gnutls_priority_*_list() */
    	priority_st _cipher;
    	priority_st _mac;
    	priority_st _kx;
    	priority_st _sign_algo;
    	priority_st _supported_ecc;

    	/* the supported groups */
    	group_list_st groups;

    	/* the supported signature algorithms */
    	sign_algo_list_st sigalg;

    	/* the supported ciphersuites */
    	ciphersuite_list_st cs;

    	/* to disable record padding */
    	bool no_extensions;

    	/* to disable extensions shuffling */
    	bool no_shuffle_extensions;

    	safe_renegotiation_t sr;
    	bool min_record_version;
    	bool server_precedence;
    	bool allow_server_key_usage_violation; /* for test suite purposes only */
    	bool no_status_request;
    	bool no_tickets;
    	bool no_tickets_tls12;
    	bool have_cbc;
    	bool have_psk;
    	bool force_etm;
    	unsigned int additional_verify_flags;
    	bool tls13_compat_mode;
    	ext_master_secret_t force_ext_master_secret;

    	/* TLS_FALLBACK_SCSV */
    	bool fallback;

    	/* The session's expected security level.
    	 * Will be used to determine the minimum DH bits,
    	 * (or the acceptable certificate security level).
    	 */
    	gnutls_sec_param_t level;

    	/* these should be accessed from
    	 * session->internals.VAR names */
    	bool _allow_large_records;
    	bool _allow_small_records;
    	bool _no_etm;
    	bool _no_ext_master_secret;
    	bool _allow_key_usage_violation;
    	bool _dumbfw;
    	unsigned int _dh_prime_bits; /* old (deprecated) variable */

    	DEF_ATOMIC_INT(usage_cnt);
    };

### struct gnutls_privkey_st

    struct gnutls_privkey_st {
    	gnutls_privkey_type_t type;
    	gnutls_pk_algorithm_t pk_algorithm;

    	union {
    		gnutls_x509_privkey_t x509;
    #ifdef ENABLE_PKCS11
    		gnutls_pkcs11_privkey_t pkcs11;
    #endif
    		struct {
    			gnutls_privkey_sign_func sign_func; /* raw like TLS 1.x */
    			gnutls_privkey_sign_data_func sign_data_func;
    			gnutls_privkey_sign_hash_func sign_hash_func;
    			gnutls_privkey_decrypt_func decrypt_func;
    			gnutls_privkey_decrypt_func2 decrypt_func2;
    			gnutls_privkey_deinit_func deinit_func;
    			gnutls_privkey_info_func info_func;
    			gnutls_privkey_pk_params_func pk_params_func;
    			void *userdata;
    			unsigned bits;
    		} ext;
    	} key;

    	unsigned int flags;
    	struct pin_info_st pin;
    };

### struct gnutls_pubkey_st

    struct gnutls_pubkey_st {
    	unsigned int bits; /* an indication of the security parameter */

    	/* the size of params depends on the public
    	 * key algorithm
    	 * RSA: [0] is modulus
    	 *      [1] is public exponent
    	 * DSA: [0] is p
    	 *      [1] is q
    	 *      [2] is g
    	 *      [3] is public key
    	 */
    	gnutls_pk_params_st params;

    	unsigned int key_usage; /* bits from GNUTLS_KEY_* */

    	struct pin_info_st pin;
    };

### struct gnutls_session_int

    struct gnutls_session_int {
    	security_parameters_st security_parameters;
    	record_parameters_st *record_parameters[MAX_EPOCH_INDEX];
    	internals_st internals;
    	gnutls_key_st key;
    };

### struct gnutls_tdb_int

    struct gnutls_tdb_int;

### gnutls_x509_crl_int

    typedef struct {
    	asn1_node crl;

    	unsigned expanded;
    	/* This is used to optimize reads by gnutls_x509_crl_get_crt_serial2() */
    	asn1_node rcache;
    	unsigned rcache_idx;
    	int use_extensions;

    	gnutls_datum_t der;
    	gnutls_datum_t raw_issuer_dn;
    } gnutls_x509_crl_int;

### gnutls_x509_crq_int

    typedef struct {
    	asn1_node crq;
    } gnutls_x509_crq_int;

### gnutls_x509_crt_int

    typedef struct {
    	asn1_node cert;
    	int use_extensions;
    	unsigned expanded; /* a certificate has been expanded */
    	unsigned modified; /* the cached values below may no longer be valid */
    	unsigned flags;

    	struct pin_info_st pin;

    	/* These two cached values allow fast calls to
    	 * get_raw_*_dn(). */
    	gnutls_datum_t raw_dn;
    	gnutls_datum_t raw_issuer_dn;
    	gnutls_datum_t raw_spki;

    	gnutls_datum_t der;

    	/* this cached value allows fast access to alt names */
    	gnutls_subject_alt_names_t san;
    	gnutls_subject_alt_names_t ian;

    	/* backwards compatibility for gnutls_x509_crt_get_subject()
    	 * and gnutls_x509_crt_get_issuer() */
    	gnutls_x509_dn_st dn;
    	gnutls_x509_dn_st idn;
    } gnutls_x509_crt_int;

### gnutls_x509_privkey_int

    typedef struct {
    	/* the size of params depends on the public
    	 * key algorithm
    	 */
    	gnutls_pk_params_st params;

    	unsigned expanded;
    	unsigned flags;

    	asn1_node key;
    	struct pin_info_st pin;
    } gnutls_x509_privkey_int;