This is gnutls.info, produced by makeinfo version 6.3 from gnutls.texi. This manual is last updated 23 March 2015 for version 3.3.27 of GnuTLS. Copyright (C) 2001-2013 Free Software Foundation, Inc.\\ Copyright (C) 2001-2013 Nikos Mavrogiannopoulos Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". INFO-DIR-SECTION Software libraries START-INFO-DIR-ENTRY * GnuTLS: (gnutls). GNU Transport Layer Security Library. END-INFO-DIR-ENTRY INFO-DIR-SECTION System Administration START-INFO-DIR-ENTRY * certtool: (gnutls)Invoking certtool. Manipulate certificates and keys. * gnutls-serv: (gnutls)Invoking gnutls-serv. GnuTLS test server. * gnutls-cli: (gnutls)Invoking gnutls-cli. GnuTLS test client. * gnutls-cli-debug: (gnutls)Invoking gnutls-cli-debug. GnuTLS debug client. * psktool: (gnutls)Invoking psktool. Simple TLS-Pre-Shared-Keys manager. * srptool: (gnutls)Invoking srptool. Simple SRP password tool. END-INFO-DIR-ENTRY  File: gnutls.info, Node: Supported ciphersuites, Next: API reference, Prev: Error codes, Up: Top Appendix D Supported Ciphersuites ********************************* Ciphersuites ============ Ciphersuite name TLS ID Since -------------------------------------------------------------------------- TLS_RSA_NULL_MD5 0x00 0x01 SSL3.0 TLS_RSA_NULL_SHA1 0x00 0x02 SSL3.0 TLS_RSA_NULL_SHA256 0x00 0x3B TLS1.2 TLS_RSA_ARCFOUR_128_SHA1 0x00 0x05 SSL3.0 TLS_RSA_ARCFOUR_128_MD5 0x00 0x04 SSL3.0 TLS_RSA_3DES_EDE_CBC_SHA1 0x00 0x0A SSL3.0 TLS_RSA_AES_128_CBC_SHA1 0x00 0x2F SSL3.0 TLS_RSA_AES_256_CBC_SHA1 0x00 0x35 SSL3.0 TLS_RSA_CAMELLIA_128_CBC_SHA256 0x00 0xBA TLS1.2 TLS_RSA_CAMELLIA_256_CBC_SHA256 0x00 0xC0 TLS1.2 TLS_RSA_CAMELLIA_128_CBC_SHA1 0x00 0x41 SSL3.0 TLS_RSA_CAMELLIA_256_CBC_SHA1 0x00 0x84 SSL3.0 TLS_RSA_AES_128_CBC_SHA256 0x00 0x3C TLS1.2 TLS_RSA_AES_256_CBC_SHA256 0x00 0x3D TLS1.2 TLS_RSA_AES_128_GCM_SHA256 0x00 0x9C TLS1.2 TLS_RSA_AES_256_GCM_SHA384 0x00 0x9D TLS1.2 TLS_RSA_CAMELLIA_128_GCM_SHA256 0xC0 0x7A TLS1.2 TLS_RSA_CAMELLIA_256_GCM_SHA384 0xC0 0x7B TLS1.2 TLS_RSA_SALSA20_256_SHA1 0xE4 0x11 SSL3.0 TLS_RSA_ESTREAM_SALSA20_256_SHA1 0xE4 0x10 SSL3.0 TLS_DHE_DSS_ARCFOUR_128_SHA1 0x00 0x66 SSL3.0 TLS_DHE_DSS_3DES_EDE_CBC_SHA1 0x00 0x13 SSL3.0 TLS_DHE_DSS_AES_128_CBC_SHA1 0x00 0x32 SSL3.0 TLS_DHE_DSS_AES_256_CBC_SHA1 0x00 0x38 SSL3.0 TLS_DHE_DSS_CAMELLIA_128_CBC_SHA256 0x00 0xBD TLS1.2 TLS_DHE_DSS_CAMELLIA_256_CBC_SHA256 0x00 0xC3 TLS1.2 TLS_DHE_DSS_CAMELLIA_128_CBC_SHA1 0x00 0x44 SSL3.0 TLS_DHE_DSS_CAMELLIA_256_CBC_SHA1 0x00 0x87 SSL3.0 TLS_DHE_DSS_AES_128_CBC_SHA256 0x00 0x40 TLS1.2 TLS_DHE_DSS_AES_256_CBC_SHA256 0x00 0x6A TLS1.2 TLS_DHE_DSS_AES_128_GCM_SHA256 0x00 0xA2 TLS1.2 TLS_DHE_DSS_AES_256_GCM_SHA384 0x00 0xA3 TLS1.2 TLS_DHE_DSS_CAMELLIA_128_GCM_SHA256 0xC0 0x80 TLS1.2 TLS_DHE_DSS_CAMELLIA_256_GCM_SHA384 0xC0 0x81 TLS1.2 TLS_DHE_RSA_3DES_EDE_CBC_SHA1 0x00 0x16 SSL3.0 TLS_DHE_RSA_AES_128_CBC_SHA1 0x00 0x33 SSL3.0 TLS_DHE_RSA_AES_256_CBC_SHA1 0x00 0x39 SSL3.0 TLS_DHE_RSA_CAMELLIA_128_CBC_SHA256 0x00 0xBE TLS1.2 TLS_DHE_RSA_CAMELLIA_256_CBC_SHA256 0x00 0xC4 TLS1.2 TLS_DHE_RSA_CAMELLIA_128_CBC_SHA1 0x00 0x45 SSL3.0 TLS_DHE_RSA_CAMELLIA_256_CBC_SHA1 0x00 0x88 SSL3.0 TLS_DHE_RSA_AES_128_CBC_SHA256 0x00 0x67 TLS1.2 TLS_DHE_RSA_AES_256_CBC_SHA256 0x00 0x6B TLS1.2 TLS_DHE_RSA_AES_128_GCM_SHA256 0x00 0x9E TLS1.2 TLS_DHE_RSA_AES_256_GCM_SHA384 0x00 0x9F TLS1.2 TLS_DHE_RSA_CAMELLIA_128_GCM_SHA256 0xC0 0x7C TLS1.2 TLS_DHE_RSA_CAMELLIA_256_GCM_SHA384 0xC0 0x7D TLS1.2 TLS_ECDHE_RSA_NULL_SHA1 0xC0 0x10 SSL3.0 TLS_ECDHE_RSA_3DES_EDE_CBC_SHA1 0xC0 0x12 SSL3.0 TLS_ECDHE_RSA_AES_128_CBC_SHA1 0xC0 0x13 SSL3.0 TLS_ECDHE_RSA_AES_256_CBC_SHA1 0xC0 0x14 SSL3.0 TLS_ECDHE_RSA_AES_256_CBC_SHA384 0xC0 0x28 TLS1.2 TLS_ECDHE_RSA_ARCFOUR_128_SHA1 0xC0 0x11 SSL3.0 TLS_ECDHE_RSA_CAMELLIA_128_CBC_SHA256 0xC0 0x76 TLS1.2 TLS_ECDHE_RSA_CAMELLIA_256_CBC_SHA384 0xC0 0x77 TLS1.2 TLS_ECDHE_ECDSA_NULL_SHA1 0xC0 0x06 SSL3.0 TLS_ECDHE_ECDSA_3DES_EDE_CBC_SHA1 0xC0 0x08 SSL3.0 TLS_ECDHE_ECDSA_AES_128_CBC_SHA1 0xC0 0x09 SSL3.0 TLS_ECDHE_ECDSA_AES_256_CBC_SHA1 0xC0 0x0A SSL3.0 TLS_ECDHE_ECDSA_ARCFOUR_128_SHA1 0xC0 0x07 SSL3.0 TLS_ECDHE_ECDSA_CAMELLIA_128_CBC_SHA256 0xC0 0x72 TLS1.2 TLS_ECDHE_ECDSA_CAMELLIA_256_CBC_SHA384 0xC0 0x73 TLS1.2 TLS_ECDHE_ECDSA_AES_128_CBC_SHA256 0xC0 0x23 TLS1.2 TLS_ECDHE_RSA_AES_128_CBC_SHA256 0xC0 0x27 TLS1.2 TLS_ECDHE_ECDSA_CAMELLIA_128_GCM_SHA256 0xC0 0x86 TLS1.2 TLS_ECDHE_ECDSA_CAMELLIA_256_GCM_SHA384 0xC0 0x87 TLS1.2 TLS_ECDHE_ECDSA_AES_128_GCM_SHA256 0xC0 0x2B TLS1.2 TLS_ECDHE_ECDSA_AES_256_GCM_SHA384 0xC0 0x2C TLS1.2 TLS_ECDHE_RSA_AES_128_GCM_SHA256 0xC0 0x2F TLS1.2 TLS_ECDHE_RSA_AES_256_GCM_SHA384 0xC0 0x30 TLS1.2 TLS_ECDHE_ECDSA_AES_256_CBC_SHA384 0xC0 0x24 TLS1.2 TLS_ECDHE_RSA_CAMELLIA_128_GCM_SHA256 0xC0 0x8A TLS1.2 TLS_ECDHE_RSA_CAMELLIA_256_GCM_SHA384 0xC0 0x8B TLS1.2 TLS_ECDHE_RSA_SALSA20_256_SHA1 0xE4 0x13 SSL3.0 TLS_ECDHE_ECDSA_SALSA20_256_SHA1 0xE4 0x15 SSL3.0 TLS_ECDHE_RSA_ESTREAM_SALSA20_256_SHA1 0xE4 0x12 SSL3.0 TLS_ECDHE_ECDSA_ESTREAM_SALSA20_256_SHA1 0xE4 0x14 SSL3.0 TLS_ECDHE_PSK_3DES_EDE_CBC_SHA1 0xC0 0x34 SSL3.0 TLS_ECDHE_PSK_AES_128_CBC_SHA1 0xC0 0x35 SSL3.0 TLS_ECDHE_PSK_AES_256_CBC_SHA1 0xC0 0x36 SSL3.0 TLS_ECDHE_PSK_AES_128_CBC_SHA256 0xC0 0x37 TLS1.2 TLS_ECDHE_PSK_AES_256_CBC_SHA384 0xC0 0x38 TLS1.2 TLS_ECDHE_PSK_ARCFOUR_128_SHA1 0xC0 0x33 SSL3.0 TLS_ECDHE_PSK_NULL_SHA1 0xC0 0x39 SSL3.0 TLS_ECDHE_PSK_NULL_SHA256 0xC0 0x3A TLS1.2 TLS_ECDHE_PSK_NULL_SHA384 0xC0 0x3B TLS1.0 TLS_ECDHE_PSK_CAMELLIA_128_CBC_SHA256 0xC0 0x9A TLS1.2 TLS_ECDHE_PSK_CAMELLIA_256_CBC_SHA384 0xC0 0x9B TLS1.2 TLS_ECDHE_PSK_SALSA20_256_SHA1 0xE4 0x19 SSL3.0 TLS_ECDHE_PSK_ESTREAM_SALSA20_256_SHA1 0xE4 0x18 SSL3.0 TLS_PSK_ARCFOUR_128_SHA1 0x00 0x8A SSL3.0 TLS_PSK_3DES_EDE_CBC_SHA1 0x00 0x8B SSL3.0 TLS_PSK_AES_128_CBC_SHA1 0x00 0x8C SSL3.0 TLS_PSK_AES_256_CBC_SHA1 0x00 0x8D SSL3.0 TLS_PSK_AES_128_CBC_SHA256 0x00 0xAE TLS1.2 TLS_PSK_AES_256_GCM_SHA384 0x00 0xA9 TLS1.2 TLS_PSK_CAMELLIA_128_GCM_SHA256 0xC0 0x8E TLS1.2 TLS_PSK_CAMELLIA_256_GCM_SHA384 0xC0 0x8F TLS1.2 TLS_PSK_AES_128_GCM_SHA256 0x00 0xA8 TLS1.2 TLS_PSK_NULL_SHA1 0x00 0x2C SSL3.0 TLS_PSK_NULL_SHA256 0x00 0xB0 TLS1.2 TLS_PSK_CAMELLIA_128_CBC_SHA256 0xC0 0x94 TLS1.2 TLS_PSK_CAMELLIA_256_CBC_SHA384 0xC0 0x95 TLS1.2 TLS_PSK_SALSA20_256_SHA1 0xE4 0x17 SSL3.0 TLS_PSK_ESTREAM_SALSA20_256_SHA1 0xE4 0x16 SSL3.0 TLS_PSK_AES_256_CBC_SHA384 0x00 0xAF TLS1.2 TLS_PSK_NULL_SHA384 0x00 0xB1 TLS1.2 TLS_RSA_PSK_ARCFOUR_128_SHA1 0x00 0x92 TLS1.0 TLS_RSA_PSK_3DES_EDE_CBC_SHA1 0x00 0x93 TLS1.0 TLS_RSA_PSK_AES_128_CBC_SHA1 0x00 0x94 TLS1.0 TLS_RSA_PSK_AES_256_CBC_SHA1 0x00 0x95 TLS1.0 TLS_RSA_PSK_CAMELLIA_128_GCM_SHA256 0xC0 0x92 TLS1.2 TLS_RSA_PSK_CAMELLIA_256_GCM_SHA384 0xC0 0x93 TLS1.2 TLS_RSA_PSK_AES_128_GCM_SHA256 0x00 0xAC TLS1.2 TLS_RSA_PSK_AES_128_CBC_SHA256 0x00 0xB6 TLS1.2 TLS_RSA_PSK_NULL_SHA1 0x00 0x2E TLS1.0 TLS_RSA_PSK_NULL_SHA256 0x00 0xB8 TLS1.2 TLS_RSA_PSK_AES_256_GCM_SHA384 0x00 0xAD TLS1.2 TLS_RSA_PSK_AES_256_CBC_SHA384 0x00 0xB7 TLS1.2 TLS_RSA_PSK_NULL_SHA384 0x00 0xB9 TLS1.2 TLS_RSA_PSK_CAMELLIA_128_CBC_SHA256 0xC0 0x98 TLS1.2 TLS_RSA_PSK_CAMELLIA_256_CBC_SHA384 0xC0 0x99 TLS1.2 TLS_DHE_PSK_ARCFOUR_128_SHA1 0x00 0x8E SSL3.0 TLS_DHE_PSK_3DES_EDE_CBC_SHA1 0x00 0x8F SSL3.0 TLS_DHE_PSK_AES_128_CBC_SHA1 0x00 0x90 SSL3.0 TLS_DHE_PSK_AES_256_CBC_SHA1 0x00 0x91 SSL3.0 TLS_DHE_PSK_AES_128_CBC_SHA256 0x00 0xB2 TLS1.2 TLS_DHE_PSK_AES_128_GCM_SHA256 0x00 0xAA TLS1.2 TLS_DHE_PSK_NULL_SHA1 0x00 0x2D SSL3.0 TLS_DHE_PSK_NULL_SHA256 0x00 0xB4 TLS1.2 TLS_DHE_PSK_NULL_SHA384 0x00 0xB5 TLS1.2 TLS_DHE_PSK_AES_256_CBC_SHA384 0x00 0xB3 TLS1.2 TLS_DHE_PSK_AES_256_GCM_SHA384 0x00 0xAB TLS1.2 TLS_DHE_PSK_CAMELLIA_128_CBC_SHA256 0xC0 0x96 TLS1.2 TLS_DHE_PSK_CAMELLIA_256_CBC_SHA384 0xC0 0x97 TLS1.2 TLS_DHE_PSK_CAMELLIA_128_GCM_SHA256 0xC0 0x90 TLS1.2 TLS_DHE_PSK_CAMELLIA_256_GCM_SHA384 0xC0 0x91 TLS1.2 TLS_DH_ANON_ARCFOUR_128_MD5 0x00 0x18 SSL3.0 TLS_DH_ANON_3DES_EDE_CBC_SHA1 0x00 0x1B SSL3.0 TLS_DH_ANON_AES_128_CBC_SHA1 0x00 0x34 SSL3.0 TLS_DH_ANON_AES_256_CBC_SHA1 0x00 0x3A SSL3.0 TLS_DH_ANON_CAMELLIA_128_CBC_SHA256 0x00 0xBF TLS1.2 TLS_DH_ANON_CAMELLIA_256_CBC_SHA256 0x00 0xC5 TLS1.2 TLS_DH_ANON_CAMELLIA_128_CBC_SHA1 0x00 0x46 SSL3.0 TLS_DH_ANON_CAMELLIA_256_CBC_SHA1 0x00 0x89 SSL3.0 TLS_DH_ANON_AES_128_CBC_SHA256 0x00 0x6C TLS1.2 TLS_DH_ANON_AES_256_CBC_SHA256 0x00 0x6D TLS1.2 TLS_DH_ANON_AES_128_GCM_SHA256 0x00 0xA6 TLS1.2 TLS_DH_ANON_AES_256_GCM_SHA384 0x00 0xA7 TLS1.2 TLS_DH_ANON_CAMELLIA_128_GCM_SHA256 0xC0 0x84 TLS1.2 TLS_DH_ANON_CAMELLIA_256_GCM_SHA384 0xC0 0x85 TLS1.2 TLS_ECDH_ANON_NULL_SHA1 0xC0 0x15 SSL3.0 TLS_ECDH_ANON_3DES_EDE_CBC_SHA1 0xC0 0x17 SSL3.0 TLS_ECDH_ANON_AES_128_CBC_SHA1 0xC0 0x18 SSL3.0 TLS_ECDH_ANON_AES_256_CBC_SHA1 0xC0 0x19 SSL3.0 TLS_ECDH_ANON_ARCFOUR_128_SHA1 0xC0 0x16 SSL3.0 TLS_SRP_SHA_3DES_EDE_CBC_SHA1 0xC0 0x1A SSL3.0 TLS_SRP_SHA_AES_128_CBC_SHA1 0xC0 0x1D SSL3.0 TLS_SRP_SHA_AES_256_CBC_SHA1 0xC0 0x20 SSL3.0 TLS_SRP_SHA_DSS_3DES_EDE_CBC_SHA1 0xC0 0x1C SSL3.0 TLS_SRP_SHA_RSA_3DES_EDE_CBC_SHA1 0xC0 0x1B SSL3.0 TLS_SRP_SHA_DSS_AES_128_CBC_SHA1 0xC0 0x1F SSL3.0 TLS_SRP_SHA_RSA_AES_128_CBC_SHA1 0xC0 0x1E SSL3.0 TLS_SRP_SHA_DSS_AES_256_CBC_SHA1 0xC0 0x22 SSL3.0 TLS_SRP_SHA_RSA_AES_256_CBC_SHA1 0xC0 0x21 SSL3.0 Certificate types ================= 'X.509' 'OPENPGP' Protocols ========= 'SSL3.0' 'TLS1.0' 'TLS1.1' 'TLS1.2' 'DTLS0.9' 'DTLS1.0' 'DTLS1.2' Ciphers ======= 'AES-256-CBC' 'AES-192-CBC' 'AES-128-CBC' 'AES-128-GCM' 'AES-256-GCM' 'ARCFOUR-128' 'ESTREAM-SALSA20-256' 'SALSA20-256' 'CAMELLIA-256-CBC' 'CAMELLIA-192-CBC' 'CAMELLIA-128-CBC' 'CAMELLIA-128-GCM' 'CAMELLIA-256-GCM' '3DES-CBC' 'DES-CBC' 'ARCFOUR-40' 'RC2-40' 'NULL' MAC algorithms ============== 'SHA1' 'MD5' 'SHA256' 'SHA384' 'SHA512' 'SHA224' 'UMAC-96' 'UMAC-128' 'AEAD' Key exchange methods ==================== 'ANON-DH' 'ANON-ECDH' 'RSA' 'DHE-RSA' 'DHE-DSS' 'ECDHE-RSA' 'ECDHE-ECDSA' 'SRP-DSS' 'SRP-RSA' 'SRP' 'PSK' 'RSA-PSK' 'DHE-PSK' 'ECDHE-PSK' 'RSA-EXPORT' Public key algorithms ===================== 'RSA' 'DSA' 'EC' Public key signature algorithms =============================== 'RSA-SHA1' 'RSA-SHA1' 'RSA-SHA224' 'RSA-SHA256' 'RSA-SHA384' 'RSA-SHA512' 'RSA-RMD160' 'DSA-SHA1' 'DSA-SHA1' 'DSA-SHA224' 'DSA-SHA256' 'RSA-MD5' 'RSA-MD5' 'RSA-MD2' 'ECDSA-SHA1' 'ECDSA-SHA224' 'ECDSA-SHA256' 'ECDSA-SHA384' 'ECDSA-SHA512' Elliptic curves =============== 'SECP192R1' 'SECP224R1' 'SECP256R1' 'SECP384R1' 'SECP521R1' Compression methods =================== 'DEFLATE' 'NULL'  File: gnutls.info, Node: API reference, Next: Copying Information, Prev: Supported ciphersuites, Up: Top Appendix E API reference ************************ * Menu: * Core TLS API:: * Datagram TLS API:: * X509 certificate API:: * OCSP API:: * OpenPGP API:: * PKCS 12 API:: * PKCS 11 API:: * TPM API:: * Abstract key API:: * DANE API:: * Cryptographic API:: * Compatibility API::  File: gnutls.info, Node: Core TLS API, Next: Datagram TLS API, Up: API reference E.1 Core TLS API ================ The prototypes for the following functions lie in 'gnutls/gnutls.h'. gnutls_alert_get ---------------- -- Function: gnutls_alert_description_t gnutls_alert_get (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. 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. *Returns:* the last alert received, a 'gnutls_alert_description_t' value. gnutls_alert_get_name --------------------- -- Function: const char * gnutls_alert_get_name (gnutls_alert_description_t ALERT) ALERT: is an alert number. This function will return a string that describes the given alert number, or 'NULL' . See 'gnutls_alert_get()' . *Returns:* string corresponding to 'gnutls_alert_description_t' value. gnutls_alert_get_strname ------------------------ -- Function: const char * gnutls_alert_get_strname (gnutls_alert_description_t ALERT) ALERT: is an alert number. This function will return a string of the name of the alert. *Returns:* string corresponding to 'gnutls_alert_description_t' value. *Since:* 3.0 gnutls_alert_send ----------------- -- Function: int gnutls_alert_send (gnutls_session_t SESSION, gnutls_alert_level_t LEVEL, gnutls_alert_description_t DESC) SESSION: is a 'gnutls_session_t' structure. LEVEL: is the level of the alert DESC: is the alert description 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. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_alert_send_appropriate ----------------------------- -- Function: int gnutls_alert_send_appropriate (gnutls_session_t SESSION, int ERR) SESSION: is a 'gnutls_session_t' structure. ERR: is an integer Sends an alert to the peer depending on the error code returned by a gnutls function. This function will call 'gnutls_error_to_alert()' to determine the appropriate alert to send. This function may also return 'GNUTLS_E_AGAIN' , or 'GNUTLS_E_INTERRUPTED' . If the return value is 'GNUTLS_E_INVALID_REQUEST' , then no alert has been sent to the peer. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_alpn_get_selected_protocol --------------------------------- -- Function: int gnutls_alpn_get_selected_protocol (gnutls_session_t SESSION, gnutls_datum_t * PROTOCOL) SESSION: is a 'gnutls_session_t' structure. PROTOCOL: will hold the protocol name 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. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. Since 3.2.0 gnutls_alpn_set_protocols ------------------------- -- Function: int gnutls_alpn_set_protocols (gnutls_session_t SESSION, const gnutls_datum_t * PROTOCOLS, unsigned PROTOCOLS_SIZE, unsigned int FLAGS) SESSION: is a 'gnutls_session_t' structure. PROTOCOLS: is the protocol names to add. PROTOCOLS_SIZE: the number of protocols to add. FLAGS: zero or 'GNUTLS_ALPN_' * This function is to be used by both clients and servers, to declare the supported ALPN protocols, which are used during negotiation with peer. If 'GNUTLS_ALPN_MAND' is specified the connection will be aborted if no matching ALPN protocol is found. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. Since 3.2.0 gnutls_anon_allocate_client_credentials --------------------------------------- -- Function: int gnutls_anon_allocate_client_credentials (gnutls_anon_client_credentials_t * SC) SC: is a pointer to a 'gnutls_anon_client_credentials_t' structure. This structure is complex enough to manipulate directly thus this helper function is provided in order to allocate it. *Returns:* 'GNUTLS_E_SUCCESS' on success, or an error code. gnutls_anon_allocate_server_credentials --------------------------------------- -- Function: int gnutls_anon_allocate_server_credentials (gnutls_anon_server_credentials_t * SC) SC: is a pointer to a 'gnutls_anon_server_credentials_t' structure. This structure is complex enough to manipulate directly thus this helper function is provided in order to allocate it. *Returns:* 'GNUTLS_E_SUCCESS' on success, or an error code. gnutls_anon_free_client_credentials ----------------------------------- -- Function: void gnutls_anon_free_client_credentials (gnutls_anon_client_credentials_t SC) SC: is a 'gnutls_anon_client_credentials_t' structure. This structure is complex enough to manipulate directly thus this helper function is provided in order to free (deallocate) it. gnutls_anon_free_server_credentials ----------------------------------- -- Function: void gnutls_anon_free_server_credentials (gnutls_anon_server_credentials_t SC) SC: is a 'gnutls_anon_server_credentials_t' structure. This structure is complex enough to manipulate directly thus this helper function is provided in order to free (deallocate) it. gnutls_anon_set_params_function ------------------------------- -- Function: void gnutls_anon_set_params_function (gnutls_anon_server_credentials_t RES, gnutls_params_function * FUNC) RES: is a gnutls_anon_server_credentials_t structure FUNC: is the function to be called 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. gnutls_anon_set_server_dh_params -------------------------------- -- Function: void gnutls_anon_set_server_dh_params (gnutls_anon_server_credentials_t RES, gnutls_dh_params_t DH_PARAMS) RES: is a gnutls_anon_server_credentials_t structure DH_PARAMS: is a structure that holds Diffie-Hellman parameters. This function will set the Diffie-Hellman parameters for an anonymous server to use. These parameters will be used in Anonymous Diffie-Hellman cipher suites. gnutls_anon_set_server_params_function -------------------------------------- -- Function: void gnutls_anon_set_server_params_function (gnutls_anon_server_credentials_t RES, gnutls_params_function * FUNC) RES: is a gnutls_certificate_credentials_t structure FUNC: is the function to be called 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. gnutls_auth_client_get_type --------------------------- -- Function: gnutls_credentials_type_t gnutls_auth_client_get_type (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Returns the type of credentials that were used for client authentication. The returned information is to be used to distinguish the function used to access authentication data. *Returns:* The type of credentials for the client authentication schema, a 'gnutls_credentials_type_t' type. gnutls_auth_get_type -------------------- -- Function: gnutls_credentials_type_t gnutls_auth_get_type (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Returns type of credentials for the current authentication schema. The returned information is to be used to distinguish the function used to access authentication data. Eg. for CERTIFICATE ciphersuites (key exchange algorithms: 'GNUTLS_KX_RSA' , 'GNUTLS_KX_DHE_RSA' ), the same function are to be used to access the authentication data. *Returns:* The type of credentials for the current authentication schema, a 'gnutls_credentials_type_t' type. gnutls_auth_server_get_type --------------------------- -- Function: gnutls_credentials_type_t gnutls_auth_server_get_type (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Returns the type of credentials that were used for server authentication. The returned information is to be used to distinguish the function used to access authentication data. *Returns:* The type of credentials for the server authentication schema, a 'gnutls_credentials_type_t' type. gnutls_bye ---------- -- Function: int gnutls_bye (gnutls_session_t SESSION, gnutls_close_request_t HOW) SESSION: is a 'gnutls_session_t' structure. HOW: is an integer Terminates the current TLS/SSL connection. The connection should have been initiated using 'gnutls_handshake()' . 'how' should be one 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()' . *Returns:* 'GNUTLS_E_SUCCESS' on success, or an error code, see function documentation for entire semantics. gnutls_certificate_activation_time_peers ---------------------------------------- -- Function: time_t gnutls_certificate_activation_time_peers (gnutls_session_t SESSION) SESSION: is a gnutls session This function will return the peer's certificate activation time. This is the creation time for openpgp keys. *Returns:* (time_t)-1 on error. *Deprecated:* 'gnutls_certificate_verify_peers2()' now verifies activation times. gnutls_certificate_allocate_credentials --------------------------------------- -- Function: int gnutls_certificate_allocate_credentials (gnutls_certificate_credentials_t * RES) RES: is a pointer to a 'gnutls_certificate_credentials_t' structure. This structure is complex enough to manipulate directly thus this helper function is provided in order to allocate it. *Returns:* 'GNUTLS_E_SUCCESS' on success, or an error code. gnutls_certificate_client_get_request_status -------------------------------------------- -- Function: int gnutls_certificate_client_get_request_status (gnutls_session_t SESSION) SESSION: is a gnutls session Get whether client certificate is requested or not. *Returns:* 0 if the peer (server) did not request client authentication or 1 otherwise. gnutls_certificate_expiration_time_peers ---------------------------------------- -- Function: time_t gnutls_certificate_expiration_time_peers (gnutls_session_t SESSION) SESSION: is a gnutls session This function will return the peer's certificate expiration time. *Returns:* (time_t)-1 on error. *Deprecated:* 'gnutls_certificate_verify_peers2()' now verifies expiration times. gnutls_certificate_free_ca_names -------------------------------- -- Function: void gnutls_certificate_free_ca_names (gnutls_certificate_credentials_t SC) SC: is a 'gnutls_certificate_credentials_t' structure. 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. gnutls_certificate_free_cas --------------------------- -- Function: void gnutls_certificate_free_cas (gnutls_certificate_credentials_t SC) SC: is a 'gnutls_certificate_credentials_t' structure. This function will delete all the CAs associated with the given credentials. Servers that do not use 'gnutls_certificate_verify_peers2()' may call this to save some memory. gnutls_certificate_free_credentials ----------------------------------- -- Function: void gnutls_certificate_free_credentials (gnutls_certificate_credentials_t SC) SC: is a 'gnutls_certificate_credentials_t' structure. This structure is complex enough to manipulate directly thus this helper function is provided in order to free (deallocate) it. This function does not free any temporary parameters associated with this structure (ie RSA and DH parameters are not freed by this function). gnutls_certificate_free_crls ---------------------------- -- Function: void gnutls_certificate_free_crls (gnutls_certificate_credentials_t SC) SC: is a 'gnutls_certificate_credentials_t' structure. This function will delete all the CRLs associated with the given credentials. gnutls_certificate_free_keys ---------------------------- -- Function: void gnutls_certificate_free_keys (gnutls_certificate_credentials_t SC) SC: is a 'gnutls_certificate_credentials_t' structure. This function will delete all the keys and the certificates associated with the given credentials. This function must not be called when a TLS negotiation that uses the credentials is in progress. gnutls_certificate_get_crt_raw ------------------------------ -- Function: int gnutls_certificate_get_crt_raw (gnutls_certificate_credentials_t SC, unsigned IDX1, unsigned IDX2, gnutls_datum_t * CERT) SC: is a 'gnutls_certificate_credentials_t' structure. IDX1: the index of the certificate if multiple are present IDX2: the index in the certificate list. Zero gives the server's certificate. CERT: Will hold the DER encoded certificate. 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' . *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_get_issuer ----------------------------- -- Function: int gnutls_certificate_get_issuer (gnutls_certificate_credentials_t SC, gnutls_x509_crt_t CERT, gnutls_x509_crt_t * ISSUER, unsigned int FLAGS) SC: is a 'gnutls_certificate_credentials_t' structure. 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' This function will return the issuer of a given certificate. As with 'gnutls_x509_trust_list_get_issuer()' this function requires the 'GNUTLS_TL_GET_COPY' flag in order to operate with PKCS '11' trust lists. In that case the issuer must be freed using 'gnutls_x509_crt_deinit()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.0 gnutls_certificate_get_ours --------------------------- -- Function: const gnutls_datum_t * gnutls_certificate_get_ours (gnutls_session_t SESSION) SESSION: is a gnutls 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. *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 ---------------------------- -- Function: const gnutls_datum_t * gnutls_certificate_get_peers (gnutls_session_t SESSION, unsigned int * LIST_SIZE) SESSION: is a gnutls session LIST_SIZE: is the length of the certificate list (may be 'NULL' ) 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 first certificate in the list is the peer's certificate, following the issuer's certificate, then the issuer's issuer etc. In case of OpenPGP keys a single key will be returned in raw format. *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_peers_subkey_id -------------------------------------- -- Function: int gnutls_certificate_get_peers_subkey_id (gnutls_session_t SESSION, gnutls_datum_t * ID) SESSION: is a gnutls session ID: will contain the ID Get the peer's subkey ID when OpenPGP certificates are used. The returned 'id' should be treated as constant. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. *Since:* 3.1.3 gnutls_certificate_send_x509_rdn_sequence ----------------------------------------- -- Function: void gnutls_certificate_send_x509_rdn_sequence (gnutls_session_t SESSION, int STATUS) SESSION: is a pointer to a 'gnutls_session_t' structure. STATUS: is 0 or 1 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. gnutls_certificate_server_set_request ------------------------------------- -- Function: void gnutls_certificate_server_set_request (gnutls_session_t SESSION, gnutls_certificate_request_t REQ) SESSION: is a 'gnutls_session_t' structure. REQ: is one of GNUTLS_CERT_REQUEST, GNUTLS_CERT_REQUIRE This function specifies if we (in case of a server) are going to send a certificate request message to the client. If 'req' is GNUTLS_CERT_REQUIRE then the server will return an 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. gnutls_certificate_set_dh_params -------------------------------- -- Function: void gnutls_certificate_set_dh_params (gnutls_certificate_credentials_t RES, gnutls_dh_params_t DH_PARAMS) RES: is a gnutls_certificate_credentials_t structure DH_PARAMS: is a structure that holds Diffie-Hellman parameters. 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. gnutls_certificate_set_ocsp_status_request_file ----------------------------------------------- -- Function: int gnutls_certificate_set_ocsp_status_request_file (gnutls_certificate_credentials_t SC, const char * RESPONSE_FILE, unsigned int FLAGS) SC: is a credentials structure. RESPONSE_FILE: a filename of the OCSP response FLAGS: should be zero This function sets the filename of an OCSP response, that will be sent to the client if requests an OCSP certificate status. This is a convenience function which is inefficient on busy servers since the file is opened on every access. Use 'gnutls_certificate_set_ocsp_status_request_function()' to fine-tune file accesses. *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_function --------------------------------------------------- -- Function: void gnutls_certificate_set_ocsp_status_request_function (gnutls_certificate_credentials_t SC, gnutls_status_request_ocsp_func OCSP_FUNC, void * PTR) SC: is a 'gnutls_certificate_credentials_t' structure. OCSP_FUNC: function pointer to OCSP status request callback. PTR: opaque pointer passed to callback function 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' , the server will provide the client with the ocsp_response. The response must be a value allocated using 'gnutls_malloc()' , and will be deinitialized when needed. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. *Since:* 3.1.3 gnutls_certificate_set_params_function -------------------------------------- -- Function: void gnutls_certificate_set_params_function (gnutls_certificate_credentials_t RES, gnutls_params_function * FUNC) RES: is a gnutls_certificate_credentials_t structure FUNC: is the function to be called 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. gnutls_certificate_set_pin_function ----------------------------------- -- Function: void gnutls_certificate_set_pin_function (gnutls_certificate_credentials_t CRED, gnutls_pin_callback_t FN, void * USERDATA) CRED: is a 'gnutls_certificate_credentials_t' structure. FN: A PIN callback USERDATA: Data to be passed in the callback This function will set a callback function to be used when required to access a protected object. This function overrides any other global PIN functions. Note that this function must be called right after initialization to have effect. *Since:* 3.1.0 gnutls_certificate_set_retrieve_function ---------------------------------------- -- Function: void gnutls_certificate_set_retrieve_function (gnutls_certificate_credentials_t CRED, gnutls_certificate_retrieve_function * FUNC) CRED: is a 'gnutls_certificate_credentials_t' structure. FUNC: is the callback function This function sets a callback to be called in order to retrieve the certificate to be used in the handshake. 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. Normally we should send a certificate that is signed by one of these CAs. These names 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 signature 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. *Since:* 3.0 gnutls_certificate_set_verify_flags ----------------------------------- -- Function: void gnutls_certificate_set_verify_flags (gnutls_certificate_credentials_t RES, unsigned int FLAGS) RES: is a gnutls_certificate_credentials_t structure FLAGS: are the 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. gnutls_certificate_set_verify_function -------------------------------------- -- Function: void gnutls_certificate_set_verify_function (gnutls_certificate_credentials_t CRED, gnutls_certificate_verify_function * FUNC) CRED: is a 'gnutls_certificate_credentials_t' structure. FUNC: is the callback function 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. *Since:* 2.10.0 gnutls_certificate_set_verify_limits ------------------------------------ -- Function: void gnutls_certificate_set_verify_limits (gnutls_certificate_credentials_t RES, unsigned int MAX_BITS, unsigned int MAX_DEPTH) RES: is a gnutls_certificate_credentials structure 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) 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. gnutls_certificate_set_x509_crl ------------------------------- -- Function: int gnutls_certificate_set_x509_crl (gnutls_certificate_credentials_t RES, gnutls_x509_crl_t * CRL_LIST, int CRL_LIST_SIZE) RES: is a 'gnutls_certificate_credentials_t' structure. CRL_LIST: is a list of trusted CRLs. They should have been verified before. CRL_LIST_SIZE: holds the size of the crl_list 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. *Returns:* number of CRLs processed, or a negative error code on error. *Since:* 2.4.0 gnutls_certificate_set_x509_crl_file ------------------------------------ -- Function: int gnutls_certificate_set_x509_crl_file (gnutls_certificate_credentials_t RES, const char * CRLFILE, gnutls_x509_crt_fmt_t TYPE) RES: is a 'gnutls_certificate_credentials_t' structure. CRLFILE: is a file containing the list of verified CRLs (DER or PEM list) TYPE: is PEM or DER 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. *Returns:* number of CRLs processed or a negative error code on error. gnutls_certificate_set_x509_crl_mem ----------------------------------- -- Function: int gnutls_certificate_set_x509_crl_mem (gnutls_certificate_credentials_t RES, const gnutls_datum_t * CRL, gnutls_x509_crt_fmt_t TYPE) RES: is a 'gnutls_certificate_credentials_t' structure. CRL: is a list of trusted CRLs. They should have been verified before. TYPE: is DER or PEM 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. *Returns:* number of CRLs processed, or a negative error code on error. gnutls_certificate_set_x509_key ------------------------------- -- Function: 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) RES: is a 'gnutls_certificate_credentials_t' structure. 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 This function sets a certificate/private key pair in the gnutls_certificate_credentials_t structure. 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' structure is at an undefined state, it must not be reused to load other keys or certificates. *Returns:* 'GNUTLS_E_SUCCESS' (0) on success, or a negative error code. *Since:* 2.4.0 gnutls_certificate_set_x509_key_file ------------------------------------ -- Function: int gnutls_certificate_set_x509_key_file (gnutls_certificate_credentials_t RES, const char * CERTFILE, const char * KEYFILE, gnutls_x509_crt_fmt_t TYPE) RES: is a 'gnutls_certificate_credentials_t' structure. 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 This function sets a certificate/private key pair in the gnutls_certificate_credentials_t structure. 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 import 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 are imported (i.e., 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. *Returns:* 'GNUTLS_E_SUCCESS' (0) on success, or a negative error code. gnutls_certificate_set_x509_key_file2 ------------------------------------- -- Function: 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) RES: is a 'gnutls_certificate_credentials_t' structure. 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 This function sets a certificate/private key pair in the gnutls_certificate_credentials_t structure. 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 import 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 are imported (i.e., 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. *Returns:* 'GNUTLS_E_SUCCESS' (0) on success, or a negative error code. gnutls_certificate_set_x509_key_mem ----------------------------------- -- Function: 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) RES: is a 'gnutls_certificate_credentials_t' structure. CERT: contains a certificate list (path) for the specified private key KEY: is the private key, or 'NULL' TYPE: is PEM or DER This function sets a certificate/private key pair in the gnutls_certificate_credentials_t structure. 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()' . *Returns:* 'GNUTLS_E_SUCCESS' (0) on success, or a negative error code. gnutls_certificate_set_x509_key_mem2 ------------------------------------ -- Function: 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) RES: is a 'gnutls_certificate_credentials_t' structure. 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 This function sets a certificate/private key pair in the gnutls_certificate_credentials_t structure. 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()' . *Returns:* 'GNUTLS_E_SUCCESS' (0) on success, or a negative error code. gnutls_certificate_set_x509_simple_pkcs12_file ---------------------------------------------- -- Function: 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) RES: is a 'gnutls_certificate_credentials_t' structure. PKCS12FILE: filename of file containing PKCS'12' blob. TYPE: is PEM or DER of the 'pkcs12file' . PASSWORD: optional password used to decrypt PKCS'12' file, bags and keys. This function sets a certificate/private key pair and/or a CRL in the gnutls_certificate_credentials_t structure. This function may be called more than once (in case multiple keys/certificates exist for the server). PKCS'12' 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. PKCS'12' 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 PKCS'12' 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 PKCS'12' 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. *Returns:* 'GNUTLS_E_SUCCESS' (0) on success, or a negative error code. gnutls_certificate_set_x509_simple_pkcs12_mem --------------------------------------------- -- Function: 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) RES: is a 'gnutls_certificate_credentials_t' structure. P12BLOB: the PKCS'12' blob. TYPE: is PEM or DER of the 'pkcs12file' . PASSWORD: optional password used to decrypt PKCS'12' file, bags and keys. This function sets a certificate/private key pair and/or a CRL in the gnutls_certificate_credentials_t structure. This function may be called more than once (in case multiple keys/certificates exist for the server). Encrypted PKCS'12' bags and PKCS'8' private keys are supported. However, only password based security, and the same password for all operations, are supported. PKCS'12' 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 PKCS'12' 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 PKCS'12' 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. *Returns:* 'GNUTLS_E_SUCCESS' (0) on success, or a negative error code. *Since:* 2.8.0 gnutls_certificate_set_x509_system_trust ---------------------------------------- -- Function: int gnutls_certificate_set_x509_system_trust (gnutls_certificate_credentials_t CRED) CRED: is a 'gnutls_certificate_credentials_t' structure. 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. *Returns:* the number of certificates processed or a negative error code on error. *Since:* 3.0.20 gnutls_certificate_set_x509_trust --------------------------------- -- Function: int gnutls_certificate_set_x509_trust (gnutls_certificate_credentials_t RES, gnutls_x509_crt_t * CA_LIST, int CA_LIST_SIZE) RES: is a 'gnutls_certificate_credentials_t' structure. CA_LIST: is a list of trusted CAs CA_LIST_SIZE: holds the size of the CA list 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()' . *Returns:* the number of certificates processed or a negative error code on error. *Since:* 2.4.0 gnutls_certificate_set_x509_trust_dir ------------------------------------- -- Function: int gnutls_certificate_set_x509_trust_dir (gnutls_certificate_credentials_t CRED, const char * CA_DIR, gnutls_x509_crt_fmt_t TYPE) CRED: is a 'gnutls_certificate_credentials_t' structure. CA_DIR: is a directory containing the list of trusted CAs (DER or PEM list) TYPE: is PEM or DER 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. *Returns:* the number of certificates processed *Since:* 3.3.6 gnutls_certificate_set_x509_trust_file -------------------------------------- -- Function: int gnutls_certificate_set_x509_trust_file (gnutls_certificate_credentials_t CRED, const char * CAFILE, gnutls_x509_crt_fmt_t TYPE) CRED: is a 'gnutls_certificate_credentials_t' structure. CAFILE: is a file containing the list of trusted CAs (DER or PEM list) TYPE: is PEM or DER 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()' . *Returns:* the number of certificates processed gnutls_certificate_set_x509_trust_mem ------------------------------------- -- Function: int gnutls_certificate_set_x509_trust_mem (gnutls_certificate_credentials_t RES, const gnutls_datum_t * CA, gnutls_x509_crt_fmt_t TYPE) RES: is a 'gnutls_certificate_credentials_t' structure. CA: is a list of trusted CAs or a DER certificate TYPE: is DER or PEM 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()' . *Returns:* the number of certificates processed or a negative error code on error. gnutls_certificate_type_get --------------------------- -- Function: gnutls_certificate_type_t gnutls_certificate_type_get (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. The certificate type is by default X.509, unless it is negotiated as a TLS extension. *Returns:* the currently used 'gnutls_certificate_type_t' certificate type. gnutls_certificate_type_get_id ------------------------------ -- Function: gnutls_certificate_type_t gnutls_certificate_type_get_id (const char * NAME) NAME: is a certificate type name The names are compared in a case insensitive way. *Returns:* a 'gnutls_certificate_type_t' for the specified in a string certificate type, or 'GNUTLS_CRT_UNKNOWN' on error. gnutls_certificate_type_get_name -------------------------------- -- Function: const char * gnutls_certificate_type_get_name (gnutls_certificate_type_t TYPE) TYPE: is a certificate type Convert a 'gnutls_certificate_type_t' type to a string. *Returns:* a string that contains the name of the specified certificate type, or 'NULL' in case of unknown types. gnutls_certificate_type_list ---------------------------- -- Function: const gnutls_certificate_type_t * gnutls_certificate_type_list ( VOID) Get a list of certificate types. *Returns:* a (0)-terminated list of 'gnutls_certificate_type_t' integers indicating the available certificate types. gnutls_certificate_verification_status_print -------------------------------------------- -- Function: int gnutls_certificate_verification_status_print (unsigned int STATUS, gnutls_certificate_type_t TYPE, gnutls_datum_t * OUT, unsigned int FLAGS) STATUS: The status flags to be printed TYPE: The certificate type OUT: Newly allocated datum with (0) terminated string. FLAGS: should be zero 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()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.1.4 gnutls_certificate_verify_peers ------------------------------- -- Function: int gnutls_certificate_verify_peers (gnutls_session_t SESSION, gnutls_typed_vdata_st * DATA, unsigned int ELEMENTS, unsigned int * STATUS) SESSION: is a gnutls session DATA: an array of typed data ELEMENTS: the number of data elements STATUS: is the output of the verification This function will verify the peer's certificate and store the status in the 'status' variable as a bitwise or'd 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. The acceptable 'data' types are 'GNUTLS_DT_DNS_HOSTNAME' and 'GNUTLS_DT_KEY_PURPOSE_OID' . The former accepts as data a null-terminated hostname, 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 will fail with 'GNUTLS_CERT_SIGNER_CONSTRAINTS_FAILURE' status. *Returns:* a negative error code on error and 'GNUTLS_E_SUCCESS' (0) when the peer's certificate was successfully parsed, irrespective of whether it was verified. *Since:* 3.3.0 gnutls_certificate_verify_peers2 -------------------------------- -- Function: int gnutls_certificate_verify_peers2 (gnutls_session_t SESSION, unsigned int * STATUS) SESSION: is a gnutls session STATUS: is the output of the verification This function will verify the peer's certificate and store the status in the 'status' variable as a bitwise or'd 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 OCSP Certificate Status TLS extension, as well as the following X.509 certificate extensions: Name Constraints, Key Usage, and Basic Constraints (pathlen). 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 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()' . *Returns:* a negative error code on error and 'GNUTLS_E_SUCCESS' (0) when the peer's certificate was successfully parsed, irrespective of whether it was verified. gnutls_certificate_verify_peers3 -------------------------------- -- Function: int gnutls_certificate_verify_peers3 (gnutls_session_t SESSION, const char * HOSTNAME, unsigned int * STATUS) SESSION: is a gnutls session HOSTNAME: is the expected name of the peer; may be 'NULL' STATUS: is the output of the verification This function will verify the peer's certificate and store the status in the 'status' variable as a bitwise or'd 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. If the 'hostname' provided is non-NULL then this function will compare the hostname in the certificate against the given. The comparison will be accurate for ascii names; non-ascii names are compared byte-by-byte. 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()' . *Returns:* a negative error code on error and 'GNUTLS_E_SUCCESS' (0) when the peer's certificate was successfully parsed, irrespective of whether it was verified. *Since:* 3.1.4 gnutls_check_version -------------------- -- Function: const char * gnutls_check_version (const char * REQ_VERSION) REQ_VERSION: version string to compare with, or 'NULL' . Check GnuTLS Library version. See 'GNUTLS_VERSION' for a suitable 'req_version' string. *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_cipher_get ----------------- -- Function: gnutls_cipher_algorithm_t gnutls_cipher_get (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Get currently used cipher. *Returns:* the currently used cipher, a 'gnutls_cipher_algorithm_t' type. gnutls_cipher_get_id -------------------- -- Function: gnutls_cipher_algorithm_t gnutls_cipher_get_id (const char * NAME) NAME: is a cipher algorithm name The names are compared in a case insensitive way. *Returns:* return a 'gnutls_cipher_algorithm_t' value corresponding to the specified cipher, or 'GNUTLS_CIPHER_UNKNOWN' on error. gnutls_cipher_get_key_size -------------------------- -- Function: size_t gnutls_cipher_get_key_size (gnutls_cipher_algorithm_t ALGORITHM) ALGORITHM: is an encryption algorithm Get key size for cipher. *Returns:* length (in bytes) of the given cipher's key size, or 0 if the given cipher is invalid. gnutls_cipher_get_name ---------------------- -- Function: const char * gnutls_cipher_get_name (gnutls_cipher_algorithm_t ALGORITHM) ALGORITHM: is an encryption algorithm Convert a 'gnutls_cipher_algorithm_t' type to a string. *Returns:* a pointer to a string that contains the name of the specified cipher, or 'NULL' . gnutls_cipher_list ------------------ -- Function: const gnutls_cipher_algorithm_t * gnutls_cipher_list ( VOID) Get a list of supported cipher algorithms. Note that not necessarily all ciphers are supported as TLS cipher suites. For example, DES is not supported as a cipher suite, but is supported for other purposes (e.g., PKCS'8' or similar). This function is not thread safe. *Returns:* a (0)-terminated list of 'gnutls_cipher_algorithm_t' integers indicating the available ciphers. gnutls_cipher_suite_get_name ---------------------------- -- Function: const char * gnutls_cipher_suite_get_name (gnutls_kx_algorithm_t KX_ALGORITHM, gnutls_cipher_algorithm_t CIPHER_ALGORITHM, gnutls_mac_algorithm_t MAC_ALGORITHM) KX_ALGORITHM: is a Key exchange algorithm CIPHER_ALGORITHM: is a cipher algorithm MAC_ALGORITHM: is a MAC algorithm Note that the full cipher suite name must be prepended by TLS or SSL depending of the protocol in use. *Returns:* a string that contains the name of a TLS cipher suite, specified by the given algorithms, or 'NULL' . gnutls_cipher_suite_info ------------------------ -- Function: const char * gnutls_cipher_suite_info (size_t IDX, unsigned char * CS_ID, gnutls_kx_algorithm_t * KX, gnutls_cipher_algorithm_t * CIPHER, gnutls_mac_algorithm_t * MAC, gnutls_protocol_t * MIN_VERSION) IDX: index of cipher suite to get information about, starts on 0. CS_ID: output buffer with room for 2 bytes, indicating cipher suite value KX: output variable indicating key exchange algorithm, or 'NULL' . CIPHER: output variable indicating cipher, or 'NULL' . MAC: output variable indicating MAC algorithm, or 'NULL' . MIN_VERSION: output variable indicating TLS protocol version, or 'NULL' . Get information about supported cipher suites. Use the function iteratively to get information about all supported cipher suites. Call with idx=0 to get information about first cipher suite, then idx=1 and so on until the function returns NULL. *Returns:* the name of 'idx' cipher suite, and set the information about the cipher suite in the output variables. If 'idx' is out of bounds, 'NULL' is returned. gnutls_compression_get ---------------------- -- Function: gnutls_compression_method_t gnutls_compression_get (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Get currently used compression algorithm. *Returns:* the currently used compression method, a 'gnutls_compression_method_t' value. gnutls_compression_get_id ------------------------- -- Function: gnutls_compression_method_t gnutls_compression_get_id (const char * NAME) NAME: is a compression method name The names are compared in a case insensitive way. *Returns:* an id of the specified in a string compression method, or 'GNUTLS_COMP_UNKNOWN' on error. gnutls_compression_get_name --------------------------- -- Function: const char * gnutls_compression_get_name (gnutls_compression_method_t ALGORITHM) ALGORITHM: is a Compression algorithm Convert a 'gnutls_compression_method_t' value to a string. *Returns:* a pointer to a string that contains the name of the specified compression algorithm, or 'NULL' . gnutls_compression_list ----------------------- -- Function: const gnutls_compression_method_t * gnutls_compression_list ( VOID) Get a list of compression methods. *Returns:* a zero-terminated list of 'gnutls_compression_method_t' integers indicating the available compression methods. gnutls_credentials_clear ------------------------ -- Function: void gnutls_credentials_clear (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Clears all the credentials previously set in this session. gnutls_credentials_get ---------------------- -- Function: int gnutls_credentials_get (gnutls_session_t SESSION, gnutls_credentials_type_t TYPE, void ** CRED) SESSION: is a 'gnutls_session_t' structure. TYPE: is the type of the credentials to return CRED: will contain the pointer to the credentials structure. 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_CERTIFICATE' , 'cred' will be 'gnutls_certificate_credentials_t' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. gnutls_credentials_set ---------------------- -- Function: int gnutls_credentials_set (gnutls_session_t SESSION, gnutls_credentials_type_t TYPE, void * CRED) SESSION: is a 'gnutls_session_t' structure. TYPE: is the type of the credentials CRED: is a pointer to a structure. Sets the needed credentials for the specified type. Eg 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). 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()' . 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' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. gnutls_db_check_entry --------------------- -- Function: int gnutls_db_check_entry (gnutls_session_t SESSION, gnutls_datum_t SESSION_ENTRY) SESSION: is a 'gnutls_session_t' structure. SESSION_ENTRY: is the session data (not key) This function has no effect. *Returns:* Returns 'GNUTLS_E_EXPIRED' , if the database entry has expired or 0 otherwise. gnutls_db_check_entry_time -------------------------- -- Function: time_t gnutls_db_check_entry_time (gnutls_datum_t * ENTRY) ENTRY: is a pointer to a 'gnutls_datum_t' structure. This function returns the time that this entry was active. It can be used for database entry expiration. *Returns:* The time this entry was created, or zero on error. gnutls_db_get_default_cache_expiration -------------------------------------- -- Function: unsigned gnutls_db_get_default_cache_expiration ( VOID) Returns the expiration time (in seconds) of stored sessions for resumption. gnutls_db_get_ptr ----------------- -- Function: void * gnutls_db_get_ptr (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Get db function pointer. *Returns:* the pointer that will be sent to db store, retrieve and delete functions, as the first argument. gnutls_db_remove_session ------------------------ -- Function: void gnutls_db_remove_session (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. 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. gnutls_db_set_cache_expiration ------------------------------ -- Function: void gnutls_db_set_cache_expiration (gnutls_session_t SESSION, int SECONDS) SESSION: is a 'gnutls_session_t' structure. SECONDS: is the number of seconds. Set the expiration time for resumed sessions. The default is 3600 (one hour) at the time of this writing. gnutls_db_set_ptr ----------------- -- Function: void gnutls_db_set_ptr (gnutls_session_t SESSION, void * PTR) SESSION: is a 'gnutls_session_t' structure. PTR: is the pointer Sets the pointer that will be provided to db store, retrieve and delete functions, as the first argument. gnutls_db_set_remove_function ----------------------------- -- Function: void gnutls_db_set_remove_function (gnutls_session_t SESSION, gnutls_db_remove_func REM_FUNC) SESSION: is a 'gnutls_session_t' structure. REM_FUNC: is the function. 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. gnutls_db_set_retrieve_function ------------------------------- -- Function: void gnutls_db_set_retrieve_function (gnutls_session_t SESSION, gnutls_db_retr_func RETR_FUNC) SESSION: is a 'gnutls_session_t' structure. RETR_FUNC: is the function. 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. gnutls_db_set_store_function ---------------------------- -- Function: void gnutls_db_set_store_function (gnutls_session_t SESSION, gnutls_db_store_func STORE_FUNC) SESSION: is a 'gnutls_session_t' structure. STORE_FUNC: is the function 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. gnutls_deinit ------------- -- Function: void gnutls_deinit (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. This function clears all buffers associated with the 'session' . This function will also remove session data from the session database if the session was terminated abnormally. gnutls_dh_get_group ------------------- -- Function: int gnutls_dh_get_group (gnutls_session_t SESSION, gnutls_datum_t * RAW_GEN, gnutls_datum_t * RAW_PRIME) SESSION: is a gnutls session RAW_GEN: will hold the generator. RAW_PRIME: will hold the 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. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_dh_get_peers_public_bits ------------------------------- -- Function: int gnutls_dh_get_peers_public_bits (gnutls_session_t SESSION) SESSION: is a gnutls session Get the Diffie-Hellman public key bit size. Can be used for both anonymous and ephemeral Diffie-Hellman. *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 ------------------------ -- Function: int gnutls_dh_get_prime_bits (gnutls_session_t SESSION) SESSION: is a gnutls 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. *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_pubkey -------------------- -- Function: int gnutls_dh_get_pubkey (gnutls_session_t SESSION, gnutls_datum_t * RAW_KEY) SESSION: is a gnutls session RAW_KEY: will hold the public 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. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_dh_get_secret_bits ------------------------- -- Function: int gnutls_dh_get_secret_bits (gnutls_session_t SESSION) SESSION: is a gnutls 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. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_dh_params_cpy -------------------- -- Function: int gnutls_dh_params_cpy (gnutls_dh_params_t DST, gnutls_dh_params_t SRC) DST: Is the destination structure, which should be initialized. SRC: Is the source structure This function will copy the DH parameters structure from source to destination. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. gnutls_dh_params_deinit ----------------------- -- Function: void gnutls_dh_params_deinit (gnutls_dh_params_t DH_PARAMS) DH_PARAMS: Is a structure that holds the prime numbers This function will deinitialize the DH parameters structure. gnutls_dh_params_export2_pkcs3 ------------------------------ -- Function: int gnutls_dh_params_export2_pkcs3 (gnutls_dh_params_t PARAMS, gnutls_x509_crt_fmt_t FORMAT, gnutls_datum_t * OUT) 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 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". *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. *Since:* 3.1.3 gnutls_dh_params_export_pkcs3 ----------------------------- -- Function: 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) PARAMS: Holds the DH parameters FORMAT: the format of output params. One of PEM or DER. PARAMS_DATA: will contain a PKCS3 DHParams structure PEM or DER encoded PARAMS_DATA_SIZE: holds the size of params_data (and will be replaced by the actual size of parameters) This function will export the given dh parameters to a PKCS3 DHParams structure. This is the format generated by "openssl dhparam" tool. If the buffer provided is not long enough to hold the output, then GNUTLS_E_SHORT_MEMORY_BUFFER will be returned. If the structure is PEM encoded, it will have a header of "BEGIN DH PARAMETERS". *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. gnutls_dh_params_export_raw --------------------------- -- Function: int gnutls_dh_params_export_raw (gnutls_dh_params_t PARAMS, gnutls_datum_t * PRIME, gnutls_datum_t * GENERATOR, unsigned int * BITS) 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 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. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. gnutls_dh_params_generate2 -------------------------- -- Function: int gnutls_dh_params_generate2 (gnutls_dh_params_t DPARAMS, unsigned int BITS) DPARAMS: Is the structure that the DH parameters will be stored BITS: is the prime's number of bits This function will generate a new pair of prime and generator for use in the Diffie-Hellman key exchange. The new parameters will be allocated using 'gnutls_malloc()' and will be stored in the appropriate datum. This function is normally slow. Do not set the number of bits directly, use 'gnutls_sec_param_to_pk_bits()' to get bits for 'GNUTLS_PK_DSA' . 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. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. gnutls_dh_params_import_pkcs3 ----------------------------- -- Function: int gnutls_dh_params_import_pkcs3 (gnutls_dh_params_t PARAMS, const gnutls_datum_t * PKCS3_PARAMS, gnutls_x509_crt_fmt_t FORMAT) PARAMS: A structure where the parameters will be copied to PKCS3_PARAMS: should contain a PKCS3 DHParams structure PEM or DER encoded FORMAT: the format of params. PEM or DER. This function will extract the DHParams found in a PKCS3 formatted structure. This is the format generated by "openssl dhparam" tool. If the structure is PEM encoded, it should have a header of "BEGIN DH PARAMETERS". *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. gnutls_dh_params_import_raw --------------------------- -- Function: int gnutls_dh_params_import_raw (gnutls_dh_params_t DH_PARAMS, const gnutls_datum_t * PRIME, const gnutls_datum_t * GENERATOR) DH_PARAMS: Is a structure that will hold the prime numbers PRIME: holds the new prime GENERATOR: holds the new generator This function will replace the pair of prime and generator for use in the Diffie-Hellman key exchange. The new parameters should be stored in the appropriate gnutls_datum. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. gnutls_dh_params_init --------------------- -- Function: int gnutls_dh_params_init (gnutls_dh_params_t * DH_PARAMS) DH_PARAMS: Is a structure that will hold the prime numbers This function will initialize the DH parameters structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. gnutls_dh_set_prime_bits ------------------------ -- Function: void gnutls_dh_set_prime_bits (gnutls_session_t SESSION, unsigned int BITS) SESSION: is a 'gnutls_session_t' structure. BITS: is the number of 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. gnutls_digest_get_id -------------------- -- Function: gnutls_digest_algorithm_t gnutls_digest_get_id (const char * NAME) NAME: is a digest algorithm name Convert a string to a 'gnutls_digest_algorithm_t' value. The names are compared in a case insensitive way. *Returns:* a 'gnutls_digest_algorithm_t' id of the specified MAC algorithm string, or 'GNUTLS_DIG_UNKNOWN' on failures. gnutls_digest_get_name ---------------------- -- Function: const char * gnutls_digest_get_name (gnutls_digest_algorithm_t ALGORITHM) ALGORITHM: is a digest algorithm Convert a 'gnutls_digest_algorithm_t' value to a string. *Returns:* a string that contains the name of the specified digest algorithm, or 'NULL' . gnutls_digest_list ------------------ -- Function: const gnutls_digest_algorithm_t * gnutls_digest_list ( VOID) Get a list of hash (digest) algorithms supported by GnuTLS. This function is not thread safe. *Returns:* Return a (0)-terminated list of 'gnutls_digest_algorithm_t' integers indicating the available digests. gnutls_ecc_curve_get -------------------- -- Function: gnutls_ecc_curve_t gnutls_ecc_curve_get (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Returns the currently used elliptic curve. Only valid when using an elliptic curve ciphersuite. *Returns:* the currently used curve, a 'gnutls_ecc_curve_t' type. *Since:* 3.0 gnutls_ecc_curve_get_name ------------------------- -- Function: const char * gnutls_ecc_curve_get_name (gnutls_ecc_curve_t CURVE) CURVE: is an ECC curve Convert a 'gnutls_ecc_curve_t' value to a string. *Returns:* a string that contains the name of the specified curve or 'NULL' . *Since:* 3.0 gnutls_ecc_curve_get_size ------------------------- -- Function: int gnutls_ecc_curve_get_size (gnutls_ecc_curve_t CURVE) CURVE: is an ECC curve Returns the size in bytes of the curve. *Returns:* a the size or (0). *Since:* 3.0 gnutls_ecc_curve_list --------------------- -- Function: const gnutls_ecc_curve_t * gnutls_ecc_curve_list ( VOID) Get the list of supported elliptic curves. This function is not thread safe. *Returns:* Return a (0)-terminated list of 'gnutls_ecc_curve_t' integers indicating the available curves. gnutls_error_is_fatal --------------------- -- Function: int gnutls_error_is_fatal (int ERROR) ERROR: is a GnuTLS error code, a negative error code 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). *Returns:* Non-zero value on fatal errors or zero on non-fatal. gnutls_error_to_alert --------------------- -- Function: int gnutls_error_to_alert (int ERR, int * LEVEL) ERR: is a negative integer LEVEL: the alert level will be stored there Get an alert depending on the error code returned by a gnutls function. All alerts sent by this function should be considered fatal. The only exception is when 'err' is 'GNUTLS_E_REHANDSHAKE' , where a warning alert should be sent to the peer indicating that no renegotiation will be performed. If there is no mapping to a valid alert the alert to indicate internal error is returned. *Returns:* the alert code to use for a particular error code. gnutls_est_record_overhead_size ------------------------------- -- Function: 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, unsigned int FLAGS) 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 FLAGS: must be zero 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 inacurate 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. *Since:* 3.2.2 gnutls_fingerprint ------------------ -- Function: int gnutls_fingerprint (gnutls_digest_algorithm_t ALGO, const gnutls_datum_t * DATA, void * RESULT, size_t * RESULT_SIZE) 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. 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. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_fips140_mode_enabled --------------------------- -- Function: int gnutls_fips140_mode_enabled ( VOID) Checks whether this library is in FIPS140 mode. *Returns:* return non-zero if true or zero if false. *Since:* 3.3.0 gnutls_global_deinit -------------------- -- Function: void gnutls_global_deinit ( VOID) This function deinitializes the global data, that were initialized using 'gnutls_global_init()' . gnutls_global_init ------------------ -- Function: int gnutls_global_init ( VOID) 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. Since GnuTLS 3.3.0 this function is only required in systems that do not support library constructors and static linking. This function also became thread safe. 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_set_audit_log_function ------------------------------------ -- Function: void gnutls_global_set_audit_log_function (gnutls_audit_log_func LOG_FUNC) LOG_FUNC: it is the audit log function 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*); *Since:* 3.0 gnutls_global_set_log_function ------------------------------ -- Function: void gnutls_global_set_log_function (gnutls_log_func LOG_FUNC) LOG_FUNC: it's a log function 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*); gnutls_global_set_log_level --------------------------- -- Function: void gnutls_global_set_log_level (int LEVEL) LEVEL: it's an integer from 0 to 99. 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. gnutls_global_set_mutex ----------------------- -- Function: void gnutls_global_set_mutex (mutex_init_func INIT, mutex_deinit_func DEINIT, mutex_lock_func LOCK, mutex_unlock_func UNLOCK) INIT: mutex initialization function DEINIT: mutex deinitialization function LOCK: mutex locking function UNLOCK: mutex unlocking function 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 preferrably 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. *Since:* 2.12.0 gnutls_global_set_time_function ------------------------------- -- Function: void gnutls_global_set_time_function (gnutls_time_func TIME_FUNC) TIME_FUNC: it's the system time function, a 'gnutls_time_func()' callback. 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. *Since:* 2.12.0 gnutls_handshake ---------------- -- Function: int gnutls_handshake (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. This function does the handshake of the TLS/SSL protocol, and initializes the TLS connection. This function will fail if any problem is encountered, and will return a negative error code. In case of a client, if the client has asked to resume a session, but the server couldn't, then a full handshake will be performed. The non-fatal errors expected by this function are: 'GNUTLS_E_INTERRUPTED' , 'GNUTLS_E_AGAIN' , 'GNUTLS_E_WARNING_ALERT_RECEIVED' , and 'GNUTLS_E_GOT_APPLICATION_DATA' , the latter only in a case of rehandshake. The former two interrupt the handshake procedure due to the lower layer being interrupted, and the latter because of an alert that may be sent by a server (it is always a good idea to check any received alerts). On these 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. If this function is called by a server after a rehandshake request then 'GNUTLS_E_GOT_APPLICATION_DATA' or 'GNUTLS_E_WARNING_ALERT_RECEIVED' may be returned. Note that these are non fatal errors, only in the specific case of a rehandshake. Their meaning is that the client rejected the rehandshake request or in the case of 'GNUTLS_E_GOT_APPLICATION_DATA' it could also mean that some data were pending. *Returns:* 'GNUTLS_E_SUCCESS' on success, otherwise a negative error code. gnutls_handshake_description_get_name ------------------------------------- -- Function: const char * gnutls_handshake_description_get_name (gnutls_handshake_description_t TYPE) TYPE: is a handshake message description Convert a 'gnutls_handshake_description_t' value to a string. *Returns:* a string that contains the name of the specified handshake message or 'NULL' . gnutls_handshake_get_last_in ---------------------------- -- Function: gnutls_handshake_description_t gnutls_handshake_get_last_in (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. 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. *Returns:* the last handshake message type received, a 'gnutls_handshake_description_t' . gnutls_handshake_get_last_out ----------------------------- -- Function: gnutls_handshake_description_t gnutls_handshake_get_last_out (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. 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. *Returns:* the last handshake message type sent, a 'gnutls_handshake_description_t' . gnutls_handshake_set_hook_function ---------------------------------- -- Function: void gnutls_handshake_set_hook_function (gnutls_session_t SESSION, unsigned int HTYPE, int POST, gnutls_handshake_hook_func FUNC) SESSION: is a 'gnutls_session_t' structure HTYPE: the 'gnutls_handshake_description_t' of the message to hook at POST: 'GNUTLS_HOOK_' * depending on when the hook function should be called FUNC: is the function to be called 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 sent/generated use 'GNUTLS_HOOK_PRE' as 'post' 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. Note 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. gnutls_handshake_set_max_packet_length -------------------------------------- -- Function: void gnutls_handshake_set_max_packet_length (gnutls_session_t SESSION, size_t MAX) SESSION: is a 'gnutls_session_t' structure. MAX: is the maximum number. 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.3.25. gnutls_handshake_set_post_client_hello_function ----------------------------------------------- -- Function: void gnutls_handshake_set_post_client_hello_function (gnutls_session_t SESSION, gnutls_handshake_post_client_hello_func FUNC) SESSION: is a 'gnutls_session_t' structure. FUNC: is the function to be called 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. gnutls_handshake_set_private_extensions --------------------------------------- -- Function: void gnutls_handshake_set_private_extensions (gnutls_session_t SESSION, int ALLOW) SESSION: is a 'gnutls_session_t' structure. ALLOW: is an integer (0 or 1) This function will enable or disable the use of private cipher suites (the ones that start with 0xFF). By default or if 'allow' is 0 then these cipher suites will not be advertised nor used. Currently GnuTLS does not include such cipher-suites or compression algorithms. Enabling the private ciphersuites when talking to other than gnutls servers and clients may cause interoperability problems. gnutls_handshake_set_random --------------------------- -- Function: int gnutls_handshake_set_random (gnutls_session_t SESSION, const gnutls_datum_t * RANDOM) SESSION: is a 'gnutls_session_t' structure. RANDOM: a random value of 32-bytes 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. *Returns:* 'GNUTLS_E_SUCCESS' on success, or an error code. Since 3.1.9 gnutls_handshake_set_timeout ---------------------------- -- Function: void gnutls_handshake_set_timeout (gnutls_session_t SESSION, unsigned int MS) SESSION: is a 'gnutls_session_t' structure. MS: is a timeout value in milliseconds This function sets the timeout for the 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. *Since:* 3.1.0 gnutls_heartbeat_allowed ------------------------ -- Function: int gnutls_heartbeat_allowed (gnutls_session_t SESSION, unsigned int TYPE) SESSION: is a 'gnutls_session_t' structure. TYPE: one of 'GNUTLS_HB_LOCAL_ALLOWED_TO_SEND' and 'GNUTLS_HB_PEER_ALLOWED_TO_SEND' This function will check whether heartbeats are allowed to be sent or received in this session. *Returns:* Non zero if heartbeats are allowed. *Since:* 3.1.2 gnutls_heartbeat_enable ----------------------- -- Function: void gnutls_heartbeat_enable (gnutls_session_t SESSION, unsigned int TYPE) SESSION: is a 'gnutls_session_t' structure. TYPE: one of the GNUTLS_HB_* flags 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. 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. *Since:* 3.1.2 gnutls_heartbeat_get_timeout ---------------------------- -- Function: unsigned int gnutls_heartbeat_get_timeout (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. 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. *Returns:* the remaining time in milliseconds. *Since:* 3.1.2 gnutls_heartbeat_ping --------------------- -- Function: int gnutls_heartbeat_ping (gnutls_session_t SESSION, size_t DATA_SIZE, unsigned int MAX_TRIES, unsigned int FLAGS) SESSION: is a 'gnutls_session_t' structure. 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. 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. *Returns:* 'GNUTLS_E_SUCCESS' on success, otherwise a negative error code. *Since:* 3.1.2 gnutls_heartbeat_pong --------------------- -- Function: int gnutls_heartbeat_pong (gnutls_session_t SESSION, unsigned int FLAGS) SESSION: is a 'gnutls_session_t' structure. FLAGS: should be zero This function replies to a ping by sending a pong to the peer. *Returns:* 'GNUTLS_E_SUCCESS' on success, otherwise a negative error code. *Since:* 3.1.2 gnutls_heartbeat_set_timeouts ----------------------------- -- Function: void gnutls_heartbeat_set_timeouts (gnutls_session_t SESSION, unsigned int RETRANS_TIMEOUT, unsigned int TOTAL_TIMEOUT) SESSION: is a 'gnutls_session_t' structure. 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. 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' . If the retransmission timeout is zero then the handshake will operate in a non-blocking way, i.e., return 'GNUTLS_E_AGAIN' . *Since:* 3.1.2 gnutls_hex2bin -------------- -- Function: int gnutls_hex2bin (const char * HEX_DATA, size_t HEX_SIZE, void * BIN_DATA, size_t * BIN_SIZE) 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' . Convert a buffer with hex data to binary data. *Returns:* 'GNUTLS_E_SUCCESS' on success, otherwise a negative error code. *Since:* 2.4.0 gnutls_hex_decode ----------------- -- Function: int gnutls_hex_decode (const gnutls_datum_t * HEX_DATA, void * RESULT, size_t * RESULT_SIZE) HEX_DATA: contain the encoded data RESULT: the place where decoded data will be copied RESULT_SIZE: holds the size of the result This function will decode the given encoded data, using the hex encoding used by PSK password files. Note that hex_data should be null terminated. *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' if the buffer given is not long enough, or 0 on success. gnutls_hex_encode ----------------- -- Function: int gnutls_hex_encode (const gnutls_datum_t * DATA, char * RESULT, size_t * RESULT_SIZE) DATA: contain the raw data RESULT: the place where hex data will be copied RESULT_SIZE: holds the size of the 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 includes the null terminator. *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' if the buffer given is not long enough, or 0 on success. gnutls_init ----------- -- Function: int gnutls_init (gnutls_session_t * SESSION, unsigned int FLAGS) SESSION: is a pointer to a 'gnutls_session_t' structure. FLAGS: indicate if this session is to be used for server or client. This function initializes the current session to null. Every session must be initialized before use, so internal structures can be allocated. This function allocates structures which can only be free'd by calling 'gnutls_deinit()' . Returns 'GNUTLS_E_SUCCESS' (0) on success. 'flags' can be one of 'GNUTLS_CLIENT' and 'GNUTLS_SERVER' . For a DTLS entity, the flags 'GNUTLS_DATAGRAM' and 'GNUTLS_NONBLOCK' are also available. The latter flag will enable a non-blocking operation of the DTLS timers. The flag 'GNUTLS_NO_REPLAY_PROTECTION' will disable any replay protection in DTLS mode. That must only used when replay protection is achieved using other means. 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_EXTENSIONS' flag. *Returns:* 'GNUTLS_E_SUCCESS' on success, or an error code. gnutls_key_generate ------------------- -- Function: int gnutls_key_generate (gnutls_datum_t * KEY, unsigned int KEY_SIZE) 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. Generates a random key of 'key_size' bytes. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, or an error code. *Since:* 3.0 gnutls_kx_get ------------- -- Function: gnutls_kx_algorithm_t gnutls_kx_get (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Get currently used key exchange algorithm. *Returns:* the key exchange algorithm used in the last handshake, a 'gnutls_kx_algorithm_t' value. gnutls_kx_get_id ---------------- -- Function: gnutls_kx_algorithm_t gnutls_kx_get_id (const char * NAME) NAME: is a KX name Convert a string to a 'gnutls_kx_algorithm_t' value. The names are compared in a case insensitive way. *Returns:* an id of the specified KX algorithm, or 'GNUTLS_KX_UNKNOWN' on error. gnutls_kx_get_name ------------------ -- Function: const char * gnutls_kx_get_name (gnutls_kx_algorithm_t ALGORITHM) ALGORITHM: is a key exchange algorithm Convert a 'gnutls_kx_algorithm_t' value to a string. *Returns:* a pointer to a string that contains the name of the specified key exchange algorithm, or 'NULL' . gnutls_kx_list -------------- -- Function: const gnutls_kx_algorithm_t * gnutls_kx_list ( VOID) Get a list of supported key exchange algorithms. This function is not thread safe. *Returns:* a (0)-terminated list of 'gnutls_kx_algorithm_t' integers indicating the available key exchange algorithms. gnutls_load_file ---------------- -- Function: int gnutls_load_file (const char * FILENAME, gnutls_datum_t * DATA) FILENAME: the name of the file to load DATA: Where the file will be stored 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()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. Since 3.1.0 gnutls_mac_get -------------- -- Function: gnutls_mac_algorithm_t gnutls_mac_get (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Get currently used MAC algorithm. *Returns:* the currently used mac algorithm, a 'gnutls_mac_algorithm_t' value. gnutls_mac_get_id ----------------- -- Function: gnutls_mac_algorithm_t gnutls_mac_get_id (const char * NAME) NAME: is a MAC algorithm name Convert a string to a 'gnutls_mac_algorithm_t' value. The names are compared in a case insensitive way. *Returns:* a 'gnutls_mac_algorithm_t' id of the specified MAC algorithm string, or 'GNUTLS_MAC_UNKNOWN' on failures. gnutls_mac_get_key_size ----------------------- -- Function: size_t gnutls_mac_get_key_size (gnutls_mac_algorithm_t ALGORITHM) ALGORITHM: is an encryption algorithm Returns the size of the MAC key used in TLS. *Returns:* length (in bytes) of the given MAC key size, or 0 if the given MAC algorithm is invalid. gnutls_mac_get_name ------------------- -- Function: const char * gnutls_mac_get_name (gnutls_mac_algorithm_t ALGORITHM) ALGORITHM: is a MAC algorithm Convert a 'gnutls_mac_algorithm_t' value to a string. *Returns:* a string that contains the name of the specified MAC algorithm, or 'NULL' . gnutls_mac_list --------------- -- Function: const gnutls_mac_algorithm_t * gnutls_mac_list ( VOID) Get a list of hash algorithms for use as MACs. Note that not necessarily all MACs are supported in TLS cipher suites. This function is not thread safe. *Returns:* Return a (0)-terminated list of 'gnutls_mac_algorithm_t' integers indicating the available MACs. gnutls_ocsp_status_request_enable_client ---------------------------------------- -- Function: int gnutls_ocsp_status_request_enable_client (gnutls_session_t SESSION, gnutls_datum_t * RESPONDER_ID, size_t RESPONDER_ID_SIZE, gnutls_datum_t * EXTENSIONS) SESSION: is a 'gnutls_session_t' structure. RESPONDER_ID: array with 'gnutls_datum_t' with DER data of responder id RESPONDER_ID_SIZE: number of members in 'responder_id' array EXTENSIONS: a 'gnutls_datum_t' with DER encoded OCSP 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. A typical server has a single OCSP response cached, so 'responder_id' and 'extensions' should 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 ------------------------------ -- Function: int gnutls_ocsp_status_request_get (gnutls_session_t SESSION, gnutls_datum_t * RESPONSE) SESSION: is a 'gnutls_session_t' structure. RESPONSE: a 'gnutls_datum_t' with DER encoded OCSP 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. *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 ------------------------------------- -- Function: int gnutls_ocsp_status_request_is_checked (gnutls_session_t SESSION, unsigned int FLAGS) SESSION: is a gnutls session FLAGS: should be zero Check whether an OCSP status response was included in the handshake and whether it was checked and valid (not too old or superseded). This is a helper function when needing to decide whether to perform an OCSP validity check on the peer's certificate. Must be called after 'gnutls_certificate_verify_peers3()' is called. *Returns:* non zero it was valid, or a zero if it wasn't sent, or sent and was invalid. gnutls_openpgp_send_cert ------------------------ -- Function: void gnutls_openpgp_send_cert (gnutls_session_t SESSION, gnutls_openpgp_crt_status_t STATUS) SESSION: is a pointer to a 'gnutls_session_t' structure. STATUS: is one of GNUTLS_OPENPGP_CERT, or GNUTLS_OPENPGP_CERT_FINGERPRINT This function will order gnutls to send the key fingerprint instead of the key in the initial handshake procedure. This should be used with care and only when there is indication or knowledge that the server can obtain the client's key. gnutls_packet_deinit -------------------- -- Function: void gnutls_packet_deinit (gnutls_packet_t PACKET) PACKET: is a pointer to a 'gnutls_packet_st' structure. This function will deinitialize all data associated with the received packet. *Since:* 3.3.5 gnutls_packet_get ----------------- -- Function: void gnutls_packet_get (gnutls_packet_t PACKET, gnutls_datum_t * DATA, unsigned char * SEQUENCE) PACKET: is a 'gnutls_packet_t' structure. 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' ) This function returns the data and sequence number associated with the received packet. *Since:* 3.3.5 gnutls_pem_base64_decode ------------------------ -- Function: int gnutls_pem_base64_decode (const char * HEADER, const gnutls_datum_t * B64_DATA, unsigned char * RESULT, size_t * RESULT_SIZE) 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 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. *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_alloc ------------------------------ -- Function: int gnutls_pem_base64_decode_alloc (const char * HEADER, const gnutls_datum_t * B64_DATA, gnutls_datum_t * RESULT) HEADER: The PEM header (eg. CERTIFICATE) B64_DATA: contains the encoded data RESULT: the place where decoded data lie 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. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_pem_base64_encode ------------------------ -- Function: int gnutls_pem_base64_encode (const char * MSG, const gnutls_datum_t * DATA, char * RESULT, size_t * RESULT_SIZE) MSG: is a message to be put in the header DATA: contain the raw data RESULT: the place where base64 data will be copied RESULT_SIZE: holds the size of the result 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 size will not include the terminating null. *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_encode_alloc ------------------------------ -- Function: int gnutls_pem_base64_encode_alloc (const char * MSG, const gnutls_datum_t * DATA, gnutls_datum_t * RESULT) MSG: is a message to be put in the encoded header DATA: contains the raw data RESULT: will hold the newly allocated encoded data 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. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_perror ------------- -- Function: void gnutls_perror (int ERROR) ERROR: is a GnuTLS error code, a negative error code This function is like 'perror()' . The only difference is that it accepts an error number returned by a gnutls function. gnutls_pk_algorithm_get_name ---------------------------- -- Function: const char * gnutls_pk_algorithm_get_name (gnutls_pk_algorithm_t ALGORITHM) ALGORITHM: is a pk algorithm Convert a 'gnutls_pk_algorithm_t' value to a string. *Returns:* a string that contains the name of the specified public key algorithm, or 'NULL' . gnutls_pk_bits_to_sec_param --------------------------- -- Function: gnutls_sec_param_t gnutls_pk_bits_to_sec_param (gnutls_pk_algorithm_t ALGO, unsigned int BITS) ALGO: is a public key algorithm BITS: is the number of 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. *Returns:* The security parameter. *Since:* 2.12.0 gnutls_pk_get_id ---------------- -- Function: gnutls_pk_algorithm_t gnutls_pk_get_id (const char * NAME) NAME: is a string containing a public key algorithm name. Convert a string to a 'gnutls_pk_algorithm_t' value. The names are compared in a case insensitive way. For example, gnutls_pk_get_id("RSA") will return 'GNUTLS_PK_RSA' . *Returns:* a 'gnutls_pk_algorithm_t' id of the specified public key algorithm string, or 'GNUTLS_PK_UNKNOWN' on failures. *Since:* 2.6.0 gnutls_pk_get_name ------------------ -- Function: const char * gnutls_pk_get_name (gnutls_pk_algorithm_t ALGORITHM) ALGORITHM: is a public key algorithm Convert a 'gnutls_pk_algorithm_t' value to a string. *Returns:* a pointer to a string that contains the name of the specified public key algorithm, or 'NULL' . *Since:* 2.6.0 gnutls_pk_list -------------- -- Function: const gnutls_pk_algorithm_t * gnutls_pk_list ( VOID) Get a list of supported public key algorithms. This function is not thread safe. *Returns:* a (0)-terminated list of 'gnutls_pk_algorithm_t' integers indicating the available ciphers. *Since:* 2.6.0 gnutls_pk_to_sign ----------------- -- Function: gnutls_sign_algorithm_t gnutls_pk_to_sign (gnutls_pk_algorithm_t PK, gnutls_digest_algorithm_t HASH) PK: is a public key algorithm HASH: a hash algorithm This function maps public key and hash algorithms combinations to signature algorithms. *Returns:* return a 'gnutls_sign_algorithm_t' value, or 'GNUTLS_SIGN_UNKNOWN' on error. gnutls_prf ---------- -- Function: 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) SESSION: is a 'gnutls_session_t' structure. 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. Applies the TLS Pseudo-Random-Function (PRF) on the master secret and the provided data, seeded with the client and server random fields. The output of this function is identical to RFC5705 extractor if 'extra' and 'extra_size' are set to zero. Otherwise, 'extra' should contain the context value prefixed by a two-byte length. 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. *Returns:* 'GNUTLS_E_SUCCESS' on success, or an error code. gnutls_prf_raw -------------- -- Function: 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) SESSION: is a 'gnutls_session_t' structure. LABEL_SIZE: length of the 'label' variable. LABEL: label used in PRF computation, typically a short string. SEED_SIZE: length of the 'seed' variable. 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. 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. *Returns:* 'GNUTLS_E_SUCCESS' on success, or an error code. gnutls_priority_certificate_type_list ------------------------------------- -- Function: int gnutls_priority_certificate_type_list (gnutls_priority_t PCACHE, const unsigned int ** LIST) PCACHE: is a 'gnutls_prioritity_t' structure. LIST: will point to an integer list Get a list of available certificate types in the priority structure. *Returns:* the number of certificate types, or an error code. *Since:* 3.0 gnutls_priority_cipher_list --------------------------- -- Function: int gnutls_priority_cipher_list (gnutls_priority_t PCACHE, const unsigned int ** LIST) PCACHE: is a 'gnutls_prioritity_t' structure. LIST: will point to an integer list Get a list of available ciphers in the priority structure. *Returns:* the number of curves, or an error code. *Since:* 3.2.3 gnutls_priority_compression_list -------------------------------- -- Function: int gnutls_priority_compression_list (gnutls_priority_t PCACHE, const unsigned int ** LIST) PCACHE: is a 'gnutls_prioritity_t' structure. LIST: will point to an integer list Get a list of available compression method in the priority structure. *Returns:* the number of methods, or an error code. *Since:* 3.0 gnutls_priority_deinit ---------------------- -- Function: void gnutls_priority_deinit (gnutls_priority_t PRIORITY_CACHE) PRIORITY_CACHE: is a 'gnutls_prioritity_t' structure. Deinitializes the priority cache. gnutls_priority_ecc_curve_list ------------------------------ -- Function: int gnutls_priority_ecc_curve_list (gnutls_priority_t PCACHE, const unsigned int ** LIST) PCACHE: is a 'gnutls_prioritity_t' structure. LIST: will point to an integer list Get a list of available elliptic curves in the priority structure. *Returns:* the number of curves, or an error code. *Since:* 3.0 gnutls_priority_get_cipher_suite_index -------------------------------------- -- Function: int gnutls_priority_get_cipher_suite_index (gnutls_priority_t PCACHE, unsigned int IDX, unsigned int * SIDX) PCACHE: is a 'gnutls_prioritity_t' structure. IDX: is an index number. SIDX: internal index of cipher suite to get information about. 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. *Returns:* On success it returns 'GNUTLS_E_SUCCESS' (0), or a negative error value otherwise. gnutls_priority_init -------------------- -- Function: int gnutls_priority_init (gnutls_priority_t * PRIORITY_CACHE, const char * PRIORITIES, const char ** ERR_POS) PRIORITY_CACHE: is a 'gnutls_prioritity_t' structure. 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 Sets priorities for the ciphers, key exchange methods, macs and compression methods. 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. 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. "EXPORT" means all ciphersuites are enabled, including the low-security 40 bit ciphers. "NONE" means nothing is enabled. This disables even protocols and compression methods. " 'KEYWORD' " The system administrator imposed settings. The provided keywords will be expanded from a configuration-time provided file - default is: /etc/gnutls/default-priorities. Any keywords that follow it, will be appended to the expanded string. If there is no system string, then the function will fail. The system file 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 except for ARCFOUR-128. "SECURE128:-VERS-SSL3.0:+COMP-DEFLATE" means that only secure ciphers are enabled, SSL3.0 is disabled, and libz compression enabled. "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). *Returns:* On syntax error 'GNUTLS_E_INVALID_REQUEST' is returned, 'GNUTLS_E_SUCCESS' on success, or an error code. gnutls_priority_kx_list ----------------------- -- Function: int gnutls_priority_kx_list (gnutls_priority_t PCACHE, const unsigned int ** LIST) PCACHE: is a 'gnutls_prioritity_t' structure. LIST: will point to an integer list Get a list of available key exchange methods in the priority structure. *Returns:* the number of curves, or an error code. *Since:* 3.2.3 gnutls_priority_mac_list ------------------------ -- Function: int gnutls_priority_mac_list (gnutls_priority_t PCACHE, const unsigned int ** LIST) PCACHE: is a 'gnutls_prioritity_t' structure. LIST: will point to an integer list Get a list of available MAC algorithms in the priority structure. *Returns:* the number of curves, or an error code. *Since:* 3.2.3 gnutls_priority_protocol_list ----------------------------- -- Function: int gnutls_priority_protocol_list (gnutls_priority_t PCACHE, const unsigned int ** LIST) PCACHE: is a 'gnutls_prioritity_t' structure. LIST: will point to an integer list Get a list of available TLS version numbers in the priority structure. *Returns:* the number of protocols, or an error code. *Since:* 3.0 gnutls_priority_set ------------------- -- Function: int gnutls_priority_set (gnutls_session_t SESSION, gnutls_priority_t PRIORITY) SESSION: is a 'gnutls_session_t' structure. PRIORITY: is a 'gnutls_priority_t' structure. Sets the priorities to use on the ciphers, key exchange methods, macs and compression methods. *Returns:* 'GNUTLS_E_SUCCESS' on success, or an error code. gnutls_priority_set_direct -------------------------- -- Function: int gnutls_priority_set_direct (gnutls_session_t SESSION, const char * PRIORITIES, const char ** ERR_POS) SESSION: is a 'gnutls_session_t' structure. PRIORITIES: is a string describing priorities ERR_POS: In case of an error this will have the position in the string the error occured Sets the priorities to use on the ciphers, key exchange methods, macs and compression methods. This function avoids keeping a priority cache and is used to directly set string priorities to a TLS session. For documentation check the 'gnutls_priority_init()' . To simply use a reasonable default, consider using 'gnutls_set_default_priority()' . *Returns:* On syntax error 'GNUTLS_E_INVALID_REQUEST' is returned, 'GNUTLS_E_SUCCESS' on success, or an error code. gnutls_priority_sign_list ------------------------- -- Function: int gnutls_priority_sign_list (gnutls_priority_t PCACHE, const unsigned int ** LIST) PCACHE: is a 'gnutls_prioritity_t' structure. LIST: will point to an integer list Get a list of available signature algorithms in the priority structure. *Returns:* the number of algorithms, or an error code. *Since:* 3.0 gnutls_protocol_get_id ---------------------- -- Function: gnutls_protocol_t gnutls_protocol_get_id (const char * NAME) NAME: is a protocol name The names are compared in a case insensitive way. *Returns:* an id of the specified protocol, or 'GNUTLS_VERSION_UNKNOWN' on error. gnutls_protocol_get_name ------------------------ -- Function: const char * gnutls_protocol_get_name (gnutls_protocol_t VERSION) VERSION: is a (gnutls) version number Convert a 'gnutls_protocol_t' value to a string. *Returns:* a string that contains the name of the specified TLS version (e.g., "TLS1.0"), or 'NULL' . gnutls_protocol_get_version --------------------------- -- Function: gnutls_protocol_t gnutls_protocol_get_version (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Get TLS version, a 'gnutls_protocol_t' value. *Returns:* The version of the currently used protocol. gnutls_protocol_list -------------------- -- Function: const gnutls_protocol_t * gnutls_protocol_list ( VOID) Get a list of supported protocols, e.g. SSL 3.0, TLS 1.0 etc. This function is not thread safe. *Returns:* a (0)-terminated list of 'gnutls_protocol_t' integers indicating the available protocols. gnutls_psk_allocate_client_credentials -------------------------------------- -- Function: int gnutls_psk_allocate_client_credentials (gnutls_psk_client_credentials_t * SC) SC: is a pointer to a 'gnutls_psk_server_credentials_t' structure. This structure is complex enough to manipulate directly thus this helper function is provided in order to allocate it. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_psk_allocate_server_credentials -------------------------------------- -- Function: int gnutls_psk_allocate_server_credentials (gnutls_psk_server_credentials_t * SC) SC: is a pointer to a 'gnutls_psk_server_credentials_t' structure. This structure is complex enough to manipulate directly thus this helper function is provided in order to allocate it. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_psk_client_get_hint -------------------------- -- Function: const char * gnutls_psk_client_get_hint (gnutls_session_t SESSION) SESSION: is a gnutls 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. *Returns:* the identity hint of the peer, or 'NULL' in case of an error. *Since:* 2.4.0 gnutls_psk_free_client_credentials ---------------------------------- -- Function: void gnutls_psk_free_client_credentials (gnutls_psk_client_credentials_t SC) SC: is a 'gnutls_psk_client_credentials_t' structure. This structure is complex enough to manipulate directly thus this helper function is provided in order to free (deallocate) it. gnutls_psk_free_server_credentials ---------------------------------- -- Function: void gnutls_psk_free_server_credentials (gnutls_psk_server_credentials_t SC) SC: is a 'gnutls_psk_server_credentials_t' structure. This structure is complex enough to manipulate directly thus this helper function is provided in order to free (deallocate) it. gnutls_psk_server_get_username ------------------------------ -- Function: const char * gnutls_psk_server_get_username (gnutls_session_t SESSION) SESSION: is a gnutls session This should only be called in case of PSK authentication and in case of a server. *Returns:* the username of the peer, or 'NULL' in case of an error. gnutls_psk_set_client_credentials --------------------------------- -- Function: 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) RES: is a 'gnutls_psk_client_credentials_t' structure. 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' . This function sets the username and password, in a gnutls_psk_client_credentials_t structure. Those will be used in PSK authentication. 'username' should be an ASCII string or UTF-8 strings prepared using the "SASLprep" profile of "stringprep". The key can be either in raw byte format or in Hex format (without the 0x prefix). *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_psk_set_client_credentials_function ------------------------------------------ -- Function: void gnutls_psk_set_client_credentials_function (gnutls_psk_client_credentials_t CRED, gnutls_psk_client_credentials_function * FUNC) CRED: is a 'gnutls_psk_server_credentials_t' structure. FUNC: is the callback function 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()' . 'username' should be ASCII strings or UTF-8 strings prepared using the "SASLprep" profile of "stringprep". The callback function will be called once per handshake. The callback function should return 0 on success. -1 indicates an error. gnutls_psk_set_params_function ------------------------------ -- Function: void gnutls_psk_set_params_function (gnutls_psk_server_credentials_t RES, gnutls_params_function * FUNC) RES: is a gnutls_psk_server_credentials_t structure FUNC: is the function to be called 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. gnutls_psk_set_server_credentials_file -------------------------------------- -- Function: int gnutls_psk_set_server_credentials_file (gnutls_psk_server_credentials_t RES, const char * PASSWORD_FILE) RES: is a 'gnutls_psk_server_credentials_t' structure. PASSWORD_FILE: is the PSK password file (passwd.psk) This function sets the password file, in a 'gnutls_psk_server_credentials_t' structure. This password file holds usernames and keys and will be used for PSK authentication. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_psk_set_server_credentials_function ------------------------------------------ -- Function: void gnutls_psk_set_server_credentials_function (gnutls_psk_server_credentials_t CRED, gnutls_psk_server_credentials_function * FUNC) CRED: is a 'gnutls_psk_server_credentials_t' structure. FUNC: is the callback function 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. gnutls_psk_set_server_credentials_hint -------------------------------------- -- Function: int gnutls_psk_set_server_credentials_hint (gnutls_psk_server_credentials_t RES, const char * HINT) RES: is a 'gnutls_psk_server_credentials_t' structure. HINT: is the PSK identity hint string This function sets the identity hint, in a 'gnutls_psk_server_credentials_t' structure. This hint is sent to the client to help it chose a good PSK credential (i.e., username and password). *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. *Since:* 2.4.0 gnutls_psk_set_server_dh_params ------------------------------- -- Function: void gnutls_psk_set_server_dh_params (gnutls_psk_server_credentials_t RES, gnutls_dh_params_t DH_PARAMS) RES: is a gnutls_psk_server_credentials_t structure DH_PARAMS: is a structure that holds Diffie-Hellman parameters. 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. gnutls_psk_set_server_params_function ------------------------------------- -- Function: void gnutls_psk_set_server_params_function (gnutls_psk_server_credentials_t RES, gnutls_params_function * FUNC) RES: is a 'gnutls_certificate_credentials_t' structure FUNC: is the function to be called 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. gnutls_random_art ----------------- -- Function: 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) 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 This function will convert a given fingerprint to an "artistic" image. The returned image is allocated using 'gnutls_malloc()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_range_split ------------------ -- Function: int gnutls_range_split (gnutls_session_t SESSION, const gnutls_range_st * ORIG, gnutls_range_st * NEXT, gnutls_range_st * REMAINDER) SESSION: is a 'gnutls_session_t' structure 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 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). *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_can_use_length_hiding ----------------------------------- -- Function: int gnutls_record_can_use_length_hiding (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. If the session supports length-hiding padding, you can invoke 'gnutls_range_send_message()' 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_range_send_message()' making sure that the range is the same as the length of the message you are trying to send. *Returns:* true (1) if the current session supports length-hiding padding, false (0) if the current session does not. gnutls_record_check_corked -------------------------- -- Function: size_t gnutls_record_check_corked (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. This function checks if there pending corked data in the gnutls buffers -see 'gnutls_record_cork()' . *Returns:* Returns the size of the corked data or zero. *Since:* 3.2.8 gnutls_record_check_pending --------------------------- -- Function: size_t gnutls_record_check_pending (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. 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. *Returns:* Returns the size of the data or zero. gnutls_record_cork ------------------ -- Function: void gnutls_record_cork (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. 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. *Since:* 3.1.9 gnutls_record_disable_padding ----------------------------- -- Function: void gnutls_record_disable_padding (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Used to disabled padding in TLS 1.0 and above. Normally you do not need to use this function, but there are buggy clients that complain if a server pads the encrypted data. This of course will disable protection against statistical attacks on the data. This functions is defunt since 3.1.7. Random padding is disabled by default unless requested using 'gnutls_range_send_message()' . gnutls_record_get_direction --------------------------- -- Function: int gnutls_record_get_direction (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. This function provides information about the internals of the record protocol and is only useful if a prior gnutls function call (e.g. 'gnutls_handshake()' ) was interrupted for some reason, that is, if a function returned 'GNUTLS_E_INTERRUPTED' or 'GNUTLS_E_AGAIN' . In such a case, you might want to call 'select()' or 'poll()' before calling the interrupted gnutls function again. To tell you whether a file descriptor should be selected for either reading or writing, 'gnutls_record_get_direction()' returns 0 if the interrupted function was trying to read data, and 1 if it was trying to write data. This function's output is unreliable if you are using the 'session' in different threads, for sending and receiving. *Returns:* 0 if trying to read data, 1 if trying to write data. gnutls_record_get_max_size -------------------------- -- Function: size_t gnutls_record_get_max_size (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Get the record size. The maximum record size is negotiated by the client after the first handshake message. *Returns:* The maximum record packet size in this connection. gnutls_record_overhead_size --------------------------- -- Function: size_t gnutls_record_overhead_size (gnutls_session_t SESSION) SESSION: is 'gnutls_session_t' This function will return the set size in bytes of the overhead due to TLS (or DTLS) per record. *Since:* 3.2.2 gnutls_record_recv ------------------ -- Function: ssize_t gnutls_record_recv (gnutls_session_t SESSION, void * DATA, size_t DATA_SIZE) SESSION: is a 'gnutls_session_t' structure. DATA: the buffer that the data will be read into DATA_SIZE: the number of requested bytes 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 a server requests a renegotiation, the client may receive an error code of 'GNUTLS_E_REHANDSHAKE' . 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. If 'EINTR' is returned by the internal push 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()' . A server may also receive 'GNUTLS_E_REHANDSHAKE' when a client has initiated a handshake. In that case the server can only initiate a handshake or terminate the connection. *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 ------------------------- -- Function: ssize_t gnutls_record_recv_packet (gnutls_session_t SESSION, gnutls_packet_t * PACKET) SESSION: is a 'gnutls_session_t' structure. PACKET: the structure that will hold the packet data This is a lower-level function thatn 'gnutls_record_recv()' and allows to directly receive the whole decrypted packet. That avoids a memory copy, and is mostly applicable to 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). *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_record_recv_seq ---------------------- -- Function: ssize_t gnutls_record_recv_seq (gnutls_session_t SESSION, void * DATA, size_t DATA_SIZE, unsigned char * SEQ) SESSION: is a 'gnutls_session_t' structure. 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. 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. *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_send ------------------ -- Function: ssize_t gnutls_record_send (gnutls_session_t SESSION, const void * DATA, size_t DATA_SIZE) SESSION: is a 'gnutls_session_t' structure. DATA: contains the data to send DATA_SIZE: is the length of the data 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; alternatively you could provide a 'NULL' pointer for data, and 0 for size. 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' . *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_send_range ------------------------ -- Function: ssize_t gnutls_record_send_range (gnutls_session_t SESSION, const void * DATA, size_t DATA_SIZE, const gnutls_range_st * RANGE) SESSION: is a 'gnutls_session_t' structure. 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. 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 only limited to blocking sockets. *Returns:* The number of bytes sent (that is data_size in a successful invocation), or a negative error code. gnutls_record_set_max_empty_records ----------------------------------- -- Function: void gnutls_record_set_max_empty_records (gnutls_session_t SESSION, const unsigned int I) SESSION: is a 'gnutls_session_t' structure. I: is the desired value of maximum empty records that can be accepted in a row. Used to set the maximum number of empty fragments that can be accepted in a row. Accepting many empty fragments is useful for receiving length-hidden content, where empty fragments filled with pad are sent to hide the real length of a message. However, a malicious peer could send empty fragments to mount a DoS attack, so as a safety measure, a maximum number of empty fragments is accepted by default. If you know your application must accept a given number of empty fragments in a row, you can use this function to set the desired value. gnutls_record_set_max_size -------------------------- -- Function: ssize_t gnutls_record_set_max_size (gnutls_session_t SESSION, size_t SIZE) SESSION: is a 'gnutls_session_t' structure. SIZE: is the new size This function sets the maximum record packet size in this connection. This property can only be set to clients. The server may choose not to accept the requested size. Acceptable values are 512(=2^9), 1024(=2^10), 2048(=2^11) and 4096(=2^12). The requested record size does get in effect immediately only while sending data. The receive part will take effect after a successful handshake. This function uses a TLS extension called 'max record size'. Not all TLS implementations use or even understand this extension. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. gnutls_record_set_timeout ------------------------- -- Function: void gnutls_record_set_timeout (gnutls_session_t SESSION, unsigned int MS) SESSION: is a 'gnutls_session_t' structure. MS: is a timeout value in milliseconds 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). *Since:* 3.1.7 gnutls_record_uncork -------------------- -- Function: int gnutls_record_uncork (gnutls_session_t SESSION, unsigned int FLAGS) SESSION: is a 'gnutls_session_t' structure. FLAGS: Could be zero or 'GNUTLS_RECORD_WAIT' 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()' . *Returns:* On success the number of transmitted data is returned, or otherwise a negative error code. *Since:* 3.1.9 gnutls_rehandshake ------------------ -- Function: int gnutls_rehandshake (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. This function will renegotiate security parameters with the client. This should only be called in case of a server. This message informs the peer that we want to renegotiate parameters (perform a handshake). If this function succeeds (returns 0), you must call the 'gnutls_handshake()' function in order to negotiate the new parameters. Since TLS is full duplex some application data might have been sent during peer's processing of this message. In that case one should call 'gnutls_record_recv()' until GNUTLS_E_REHANDSHAKE is returned to clear any pending data. Care must be taken if rehandshake is mandatory to terminate if it does not start after some threshold. If the client does not wish to renegotiate parameters he should reply with an alert message, thus the return code will be 'GNUTLS_E_WARNING_ALERT_RECEIVED' and the alert will be 'GNUTLS_A_NO_RENEGOTIATION' . A client may also choose to ignore this message. *Returns:* 'GNUTLS_E_SUCCESS' on success, otherwise a negative error code. gnutls_safe_renegotiation_status -------------------------------- -- Function: int gnutls_safe_renegotiation_status (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Can be used to check whether safe renegotiation is being used in the current session. *Returns:* 0 when safe renegotiation is not used and non (0) when safe renegotiation is used. *Since:* 2.10.0 gnutls_sec_param_get_name ------------------------- -- Function: const char * gnutls_sec_param_get_name (gnutls_sec_param_t PARAM) PARAM: is a security parameter Convert a 'gnutls_sec_param_t' value to a string. *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 --------------------------- -- Function: unsigned int gnutls_sec_param_to_pk_bits (gnutls_pk_algorithm_t ALGO, gnutls_sec_param_t PARAM) ALGO: is a public key algorithm PARAM: is a security parameter 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. *Returns:* The number of bits, or (0). *Since:* 2.12.0 gnutls_sec_param_to_symmetric_bits ---------------------------------- -- Function: unsigned int gnutls_sec_param_to_symmetric_bits (gnutls_sec_param_t PARAM) PARAM: is a security parameter This function will return the number of bits that correspond to symmetric cipher strength for the given security parameter. *Returns:* The number of bits, or (0). *Since:* 3.3.0 gnutls_server_name_get ---------------------- -- Function: int gnutls_server_name_get (gnutls_session_t SESSION, void * DATA, size_t * DATA_LENGTH, unsigned int * TYPE, unsigned int INDX) SESSION: is a 'gnutls_session_t' structure. DATA: will hold the data DATA_LENGTH: will hold the data length. Must hold the maximum size of data. TYPE: will hold the server name indicator type INDX: is the index of the server_name 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 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. 'index' 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. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. gnutls_server_name_set ---------------------- -- Function: int gnutls_server_name_set (gnutls_session_t SESSION, gnutls_server_name_type_t TYPE, const void * NAME, size_t NAME_LENGTH) SESSION: is a 'gnutls_session_t' structure. TYPE: specifies the indicator type NAME: is a string that contains the server name. NAME_LENGTH: holds the length of name 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' , an ASCII (0)-terminated domain name string, without the trailing dot, is expected. IPv4 or IPv6 addresses are not permitted. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. gnutls_session_channel_binding ------------------------------ -- Function: int gnutls_session_channel_binding (gnutls_session_t SESSION, gnutls_channel_binding_t CBTYPE, gnutls_datum_t * CB) SESSION: is a 'gnutls_session_t' structure. CBTYPE: an 'gnutls_channel_binding_t' enumeration type CB: output buffer array with data Extract given channel binding data of the 'cbtype' (e.g., 'GNUTLS_CB_TLS_UNIQUE' ) type. *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_enable_compatibility_mode ---------------------------------------- -- Function: void gnutls_session_enable_compatibility_mode (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. This function can be used to disable certain (security) features in TLS in order to maintain maximum compatibility with buggy clients. Because several trade-offs with security are enabled, if required they will be reported through the audit subsystem. Normally only servers that require maximum compatibility with everything out there, need to call this function. Note that this function must be called after any call to gnutls_priority functions. gnutls_session_force_valid -------------------------- -- Function: void gnutls_session_force_valid (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. 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. gnutls_session_get_data ----------------------- -- Function: int gnutls_session_get_data (gnutls_session_t SESSION, void * SESSION_DATA, size_t * SESSION_DATA_SIZE) SESSION: is a 'gnutls_session_t' structure. SESSION_DATA: is a pointer to space to hold the session. SESSION_DATA_SIZE: is the session_data's size, or it will be set by the function. Returns all session parameters needed to be stored to support resumption. The client should call this, and store the returned session data. A session may be resumed later by calling 'gnutls_session_set_data()' . This function must be called after a successful (full) handshake. It should not be used in resumed sessions -see 'gnutls_session_is_resumed()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_session_get_data2 ------------------------ -- Function: int gnutls_session_get_data2 (gnutls_session_t SESSION, gnutls_datum_t * DATA) SESSION: is a 'gnutls_session_t' structure. DATA: is a pointer to a datum that will hold the session. Returns all session parameters needed to be stored to support resumption. The client should call this, and store the returned session data. A session may be resumed later by calling 'gnutls_session_set_data()' . This function must be called after a successful (full) handshake. It should not be used in resumed sessions -see 'gnutls_session_is_resumed()' . The returned 'data' are allocated and must be released using 'gnutls_free()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_session_get_desc ----------------------- -- Function: char * gnutls_session_get_desc (gnutls_session_t SESSION) SESSION: is a gnutls session This function returns a string describing the current session. The string is null terminated and allocated using 'gnutls_malloc()' . *Returns:* a description of the protocols and algorithms in the current session. *Since:* 3.1.10 gnutls_session_get_id --------------------- -- Function: int gnutls_session_get_id (gnutls_session_t SESSION, void * SESSION_ID, size_t * SESSION_ID_SIZE) SESSION: is a 'gnutls_session_t' structure. 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 the current session ID. This can be used if you want to check if the next session you tried to resume was actually resumed. That is because resumed sessions share the same session ID with the original session. The session ID is selected by the server, that identify the current session. In TLS 1.0 and SSL 3.0 session id is always less than 32 bytes. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_session_get_id2 ---------------------- -- Function: int gnutls_session_get_id2 (gnutls_session_t SESSION, gnutls_datum_t * SESSION_ID) SESSION: is a 'gnutls_session_t' structure. SESSION_ID: will point to the session ID. Returns the current session ID. The returned data should be treated as constant. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. *Since:* 3.1.4 gnutls_session_get_ptr ---------------------- -- Function: void * gnutls_session_get_ptr (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Get user pointer for session. Useful in callbacks. This is the pointer set with 'gnutls_session_set_ptr()' . *Returns:* the user given pointer from the session structure, or 'NULL' if it was never set. gnutls_session_get_random ------------------------- -- Function: void gnutls_session_get_random (gnutls_session_t SESSION, gnutls_datum_t * CLIENT, gnutls_datum_t * SERVER) SESSION: is a 'gnutls_session_t' structure. CLIENT: the client part of the random SERVER: the server part of the random 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. *Since:* 3.0 gnutls_session_is_resumed ------------------------- -- Function: int gnutls_session_is_resumed (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Check whether session is resumed or not. *Returns:* non zero if this session is resumed, or a zero if this is a new session. gnutls_session_resumption_requested ----------------------------------- -- Function: int gnutls_session_resumption_requested (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Check whether the client has asked for session resumption. This function is valid only on server side. *Returns:* non zero if session resumption was asked, or a zero if not. gnutls_session_set_data ----------------------- -- Function: int gnutls_session_set_data (gnutls_session_t SESSION, const void * SESSION_DATA, size_t SESSION_DATA_SIZE) SESSION: is a 'gnutls_session_t' structure. SESSION_DATA: is a pointer to space to hold the session. SESSION_DATA_SIZE: is the session's size Sets all session parameters, in order to resume a previously established session. The session data given must be the one returned by 'gnutls_session_get_data()' . This function should be called before 'gnutls_handshake()' . Keep in mind that session resuming is advisory. The server may choose not to resume the session, thus a full handshake will be performed. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_session_set_id --------------------- -- Function: int gnutls_session_set_id (gnutls_session_t SESSION, const gnutls_datum_t * SID) SESSION: is a 'gnutls_session_t' structure. SID: the session identifier 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. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_session_set_premaster ---------------------------- -- Function: 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) SESSION: is a 'gnutls_session_t' structure. 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 MASTER: the master key to use SESSION_ID: the session identifier 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. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. gnutls_session_set_ptr ---------------------- -- Function: void gnutls_session_set_ptr (gnutls_session_t SESSION, void * PTR) SESSION: is a 'gnutls_session_t' structure. PTR: is the user pointer This function will set (associate) the user given pointer 'ptr' to the session structure. This pointer can be accessed with 'gnutls_session_get_ptr()' . gnutls_session_ticket_enable_client ----------------------------------- -- Function: int gnutls_session_ticket_enable_client (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Request that the client should attempt session resumption using SessionTicket. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, or an error code. *Since:* 2.10.0 gnutls_session_ticket_enable_server ----------------------------------- -- Function: int gnutls_session_ticket_enable_server (gnutls_session_t SESSION, const gnutls_datum_t * KEY) SESSION: is a 'gnutls_session_t' structure. KEY: key to encrypt session parameters. Request that the server should attempt session resumption using SessionTicket. 'key' must be initialized with 'gnutls_session_ticket_key_generate()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, or an error code. *Since:* 2.10.0 gnutls_session_ticket_key_generate ---------------------------------- -- Function: int gnutls_session_ticket_key_generate (gnutls_datum_t * KEY) KEY: is a pointer to a 'gnutls_datum_t' which will contain a newly created key. Generate a random key to encrypt security parameters within SessionTicket. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, or an error code. *Since:* 2.10.0 gnutls_set_default_priority --------------------------- -- Function: int gnutls_set_default_priority (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Sets the default priority on the ciphers, key exchange methods, macs and compression methods. For more fine-tuning you could use 'gnutls_priority_set_direct()' or 'gnutls_priority_set()' instead. *Returns:* 'GNUTLS_E_SUCCESS' on success, or an error code. gnutls_sign_algorithm_get ------------------------- -- Function: int gnutls_sign_algorithm_get (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Returns the signature algorithm that is (or will be) used in this session by the server to sign data. *Returns:* The sign algorithm or 'GNUTLS_SIGN_UNKNOWN' . *Since:* 3.1.1 gnutls_sign_algorithm_get_client -------------------------------- -- Function: int gnutls_sign_algorithm_get_client (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Returns the signature algorithm that is (or will be) used in this session by the client to sign data. *Returns:* The sign algorithm or 'GNUTLS_SIGN_UNKNOWN' . *Since:* 3.1.11 gnutls_sign_algorithm_get_requested ----------------------------------- -- Function: int gnutls_sign_algorithm_get_requested (gnutls_session_t SESSION, size_t INDX, gnutls_sign_algorithm_t * ALGO) SESSION: is a 'gnutls_session_t' structure. INDX: is an index of the signature algorithm to return ALGO: the returned certificate type will be stored there 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. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise an error code is returned. *Since:* 2.10.0 gnutls_sign_get_hash_algorithm ------------------------------ -- Function: gnutls_digest_algorithm_t gnutls_sign_get_hash_algorithm (gnutls_sign_algorithm_t SIGN) SIGN: is a signature algorithm This function returns the digest algorithm corresponding to the given signature algorithms. *Since:* 3.1.1 *Returns:* return a 'gnutls_digest_algorithm_t' value, or 'GNUTLS_DIG_UNKNOWN' on error. gnutls_sign_get_id ------------------ -- Function: gnutls_sign_algorithm_t gnutls_sign_get_id (const char * NAME) NAME: is a sign algorithm name The names are compared in a case insensitive way. *Returns:* return a 'gnutls_sign_algorithm_t' value corresponding to the specified algorithm, or 'GNUTLS_SIGN_UNKNOWN' on error. gnutls_sign_get_name -------------------- -- Function: const char * gnutls_sign_get_name (gnutls_sign_algorithm_t ALGORITHM) ALGORITHM: is a sign algorithm Convert a 'gnutls_sign_algorithm_t' value to a string. *Returns:* a string that contains the name of the specified sign algorithm, or 'NULL' . gnutls_sign_get_pk_algorithm ---------------------------- -- Function: gnutls_pk_algorithm_t gnutls_sign_get_pk_algorithm (gnutls_sign_algorithm_t SIGN) SIGN: is a signature algorithm This function returns the public key algorithm corresponding to the given signature algorithms. *Since:* 3.1.1 *Returns:* return a 'gnutls_pk_algorithm_t' value, or 'GNUTLS_PK_UNKNOWN' on error. gnutls_sign_is_secure --------------------- -- Function: int gnutls_sign_is_secure (gnutls_sign_algorithm_t ALGORITHM) ALGORITHM: is a sign algorithm *Returns:* Non-zero if the provided signature algorithm is considered to be secure. gnutls_sign_list ---------------- -- Function: const gnutls_sign_algorithm_t * gnutls_sign_list ( VOID) Get a list of supported public key signature algorithms. *Returns:* a (0)-terminated list of 'gnutls_sign_algorithm_t' integers indicating the available ciphers. gnutls_srp_allocate_client_credentials -------------------------------------- -- Function: int gnutls_srp_allocate_client_credentials (gnutls_srp_client_credentials_t * SC) SC: is a pointer to a 'gnutls_srp_server_credentials_t' structure. This structure is complex enough to manipulate directly thus this helper function is provided in order to allocate it. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, or an error code. gnutls_srp_allocate_server_credentials -------------------------------------- -- Function: int gnutls_srp_allocate_server_credentials (gnutls_srp_server_credentials_t * SC) SC: is a pointer to a 'gnutls_srp_server_credentials_t' structure. This structure is complex enough to manipulate directly thus this helper function is provided in order to allocate it. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, or an error code. gnutls_srp_base64_decode ------------------------ -- Function: int gnutls_srp_base64_decode (const gnutls_datum_t * B64_DATA, char * RESULT, size_t * RESULT_SIZE) B64_DATA: contain the encoded data RESULT: the place where decoded data will be copied RESULT_SIZE: holds the size of the result 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. *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' if the buffer given is not long enough, or 0 on success. gnutls_srp_base64_decode_alloc ------------------------------ -- Function: int gnutls_srp_base64_decode_alloc (const gnutls_datum_t * B64_DATA, gnutls_datum_t * RESULT) B64_DATA: contains the encoded data RESULT: the place where decoded data lie 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. *Returns:* 0 on success, or an error code. gnutls_srp_base64_encode ------------------------ -- Function: int gnutls_srp_base64_encode (const gnutls_datum_t * DATA, char * RESULT, size_t * RESULT_SIZE) DATA: contain the raw data RESULT: the place where base64 data will be copied RESULT_SIZE: holds the size of the result 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. *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' if the buffer given is not long enough, or 0 on success. gnutls_srp_base64_encode_alloc ------------------------------ -- Function: int gnutls_srp_base64_encode_alloc (const gnutls_datum_t * DATA, gnutls_datum_t * RESULT) DATA: contains the raw data RESULT: will hold the newly allocated encoded data 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. *Returns:* 0 on success, or an error code. gnutls_srp_free_client_credentials ---------------------------------- -- Function: void gnutls_srp_free_client_credentials (gnutls_srp_client_credentials_t SC) SC: is a 'gnutls_srp_client_credentials_t' structure. This structure is complex enough to manipulate directly thus this helper function is provided in order to free (deallocate) it. gnutls_srp_free_server_credentials ---------------------------------- -- Function: void gnutls_srp_free_server_credentials (gnutls_srp_server_credentials_t SC) SC: is a 'gnutls_srp_server_credentials_t' structure. This structure is complex enough to manipulate directly thus this helper function is provided in order to free (deallocate) it. gnutls_srp_server_get_username ------------------------------ -- Function: const char * gnutls_srp_server_get_username (gnutls_session_t SESSION) SESSION: is a gnutls session 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. *Returns:* SRP username of the peer, or NULL in case of error. gnutls_srp_set_client_credentials --------------------------------- -- Function: int gnutls_srp_set_client_credentials (gnutls_srp_client_credentials_t RES, const char * USERNAME, const char * PASSWORD) RES: is a 'gnutls_srp_client_credentials_t' structure. USERNAME: is the user's userid PASSWORD: is the user's password This function sets the username and password, in a 'gnutls_srp_client_credentials_t' structure. Those will be used in SRP authentication. 'username' and 'password' should be ASCII strings or UTF-8 strings prepared using the "SASLprep" profile of "stringprep". *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, or an error code. gnutls_srp_set_client_credentials_function ------------------------------------------ -- Function: void gnutls_srp_set_client_credentials_function (gnutls_srp_client_credentials_t CRED, gnutls_srp_client_credentials_function * FUNC) CRED: is a 'gnutls_srp_server_credentials_t' structure. FUNC: is the callback function 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()' . 'username' and 'password' should be ASCII strings or UTF-8 strings prepared using the "SASLprep" profile of "stringprep". 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. gnutls_srp_set_prime_bits ------------------------- -- Function: void gnutls_srp_set_prime_bits (gnutls_session_t SESSION, unsigned int BITS) SESSION: is a 'gnutls_session_t' structure. BITS: is the number of 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. *Since:* 2.6.0 gnutls_srp_set_server_credentials_file -------------------------------------- -- Function: int gnutls_srp_set_server_credentials_file (gnutls_srp_server_credentials_t RES, const char * PASSWORD_FILE, const char * PASSWORD_CONF_FILE) RES: is a 'gnutls_srp_server_credentials_t' structure. PASSWORD_FILE: is the SRP password file (tpasswd) PASSWORD_CONF_FILE: is the SRP password conf file (tpasswd.conf) This function sets the password files, in a 'gnutls_srp_server_credentials_t' structure. Those password files hold usernames and verifiers and will be used for SRP authentication. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, or an error code. gnutls_srp_set_server_credentials_function ------------------------------------------ -- Function: void gnutls_srp_set_server_credentials_function (gnutls_srp_server_credentials_t CRED, gnutls_srp_server_credentials_function * FUNC) CRED: is a 'gnutls_srp_server_credentials_t' structure. FUNC: is the callback function 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. gnutls_srp_set_server_fake_salt_seed ------------------------------------ -- Function: void gnutls_srp_set_server_fake_salt_seed (gnutls_srp_server_credentials_t CRED, const gnutls_datum_t * SEED, unsigned int SALT_LENGTH) CRED: is a 'gnutls_srp_server_credentials_t' structure 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 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. *Since:* 3.3.0 gnutls_srp_verifier ------------------- -- Function: 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) 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. 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. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, or an error code. gnutls_srtp_get_keys -------------------- -- Function: 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) SESSION: is a 'gnutls_session_t' structure. 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 CLIENT_SALT: The master client write salt, pointing inside the key material SERVER_KEY: The master server write key, pointing inside the key material SERVER_SALT: The master server write salt, pointing inside the key material 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' . *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_get_mki ------------------- -- Function: int gnutls_srtp_get_mki (gnutls_session_t SESSION, gnutls_datum_t * MKI) SESSION: is a 'gnutls_session_t' structure. MKI: will hold the 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. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. Since 3.1.4 gnutls_srtp_get_profile_id -------------------------- -- Function: int gnutls_srtp_get_profile_id (const char * NAME, gnutls_srtp_profile_t * PROFILE) NAME: The name of the profile to look up PROFILE: Will hold the profile id This function allows you to look up a profile based on a string. *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 ---------------------------- -- Function: const char * gnutls_srtp_get_profile_name (gnutls_srtp_profile_t PROFILE) PROFILE: The profile to look up a string for This function allows you to get the corresponding name for a SRTP protection profile. *Returns:* On success, the name of a SRTP profile as a string, otherwise NULL. Since 3.1.4 gnutls_srtp_get_selected_profile -------------------------------- -- Function: int gnutls_srtp_get_selected_profile (gnutls_session_t SESSION, gnutls_srtp_profile_t * PROFILE) SESSION: is a 'gnutls_session_t' structure. PROFILE: will hold the profile This function allows you to get the negotiated SRTP profile. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. Since 3.1.4 gnutls_srtp_set_mki ------------------- -- Function: int gnutls_srtp_set_mki (gnutls_session_t SESSION, const gnutls_datum_t * MKI) SESSION: is a 'gnutls_session_t' structure. MKI: holds the MKI This function sets the Master Key Identifier, to be used by this session (if any). *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. Since 3.1.4 gnutls_srtp_set_profile ----------------------- -- Function: int gnutls_srtp_set_profile (gnutls_session_t SESSION, gnutls_srtp_profile_t PROFILE) SESSION: is a 'gnutls_session_t' structure. PROFILE: is the profile id to add. This function is to be used by both clients and servers, to declare what SRTP profiles they support, to negotiate with the peer. *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 ------------------------------ -- Function: int gnutls_srtp_set_profile_direct (gnutls_session_t SESSION, const char * PROFILES, const char ** ERR_POS) SESSION: is a 'gnutls_session_t' structure. 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 occured, may be NULL. This function is to be used by both clients and servers, to declare what SRTP profiles they support, to negotiate with the peer. *Returns:* On syntax error 'GNUTLS_E_INVALID_REQUEST' is returned, 'GNUTLS_E_SUCCESS' on success, or an error code. Since 3.1.4 gnutls_store_commitment ----------------------- -- Function: 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) 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. 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 'store' 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. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.0 gnutls_store_pubkey ------------------- -- Function: 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) 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. This function will store the provided (raw or DER-encoded) certificate to the list of stored public keys. The key will be considered valid until the provided expiration time. The 'store' 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. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.0.13 gnutls_strerror --------------- -- Function: const char * gnutls_strerror (int ERROR) ERROR: is a GnuTLS error code, a negative error code 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. *Returns:* A string explaining the GnuTLS error message. gnutls_strerror_name -------------------- -- Function: const char * gnutls_strerror_name (int ERROR) ERROR: is an error returned by a gnutls function. Return the GnuTLS error code define as a string. For example, gnutls_strerror_name (GNUTLS_E_DH_PRIME_UNACCEPTABLE) will return the string "GNUTLS_E_DH_PRIME_UNACCEPTABLE". *Returns:* A string corresponding to the symbol name of the error code. *Since:* 2.6.0 gnutls_supplemental_get_name ---------------------------- -- Function: const char * gnutls_supplemental_get_name (gnutls_supplemental_data_format_type_t TYPE) TYPE: is a supplemental data format type Convert a 'gnutls_supplemental_data_format_type_t' value to a string. *Returns:* a string that contains the name of the specified supplemental data format type, or 'NULL' for unknown types. gnutls_tdb_deinit ----------------- -- Function: void gnutls_tdb_deinit (gnutls_tdb_t TDB) TDB: The structure to be deinitialized This function will deinitialize a public key trust storage structure. gnutls_tdb_init --------------- -- Function: int gnutls_tdb_init (gnutls_tdb_t * TDB) TDB: The structure to be initialized This function will initialize a public key trust storage structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_tdb_set_store_commitment_func ------------------------------------ -- Function: void gnutls_tdb_set_store_commitment_func (gnutls_tdb_t TDB, gnutls_tdb_store_commitment_func CSTORE) TDB: The trust storage CSTORE: The commitment storage function This function will associate a commitment (hash) storage function with the trust storage structure. The function is of the following form. int gnutls_tdb_store_commitment_func(const char* db_name, const char* host, const char* service, time_t expiration, gnutls_digest_algorithm_t, const gnutls_datum_t* hash); The 'db_name' should be used to pass any private data to this function. gnutls_tdb_set_store_func ------------------------- -- Function: void gnutls_tdb_set_store_func (gnutls_tdb_t TDB, gnutls_tdb_store_func STORE) TDB: The trust storage STORE: The storage function This function will associate a storage function with the trust storage structure. The function is of the following form. int gnutls_tdb_store_func(const char* db_name, const char* host, const char* service, time_t expiration, const gnutls_datum_t* pubkey); The 'db_name' should be used to pass any private data to this function. gnutls_tdb_set_verify_func -------------------------- -- Function: void gnutls_tdb_set_verify_func (gnutls_tdb_t TDB, gnutls_tdb_verify_func VERIFY) TDB: The trust storage VERIFY: The verification function This function will associate a retrieval function with the trust storage structure. The function is of the following form. int gnutls_tdb_verify_func(const char* db_name, const char* host, const char* service, const gnutls_datum_t* pubkey); The verify function should return zero on a match, 'GNUTLS_E_CERTIFICATE_KEY_MISMATCH' if there is a mismatch and any other negative error code otherwise. The 'db_name' should be used to pass any private data to this function. gnutls_transport_get_int ------------------------ -- Function: int gnutls_transport_get_int (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Used to get the first argument of the transport function (like PUSH and PULL). This must have been set using 'gnutls_transport_set_int()' . *Returns:* The first argument of the transport function. *Since:* 3.1.9 gnutls_transport_get_int2 ------------------------- -- Function: void gnutls_transport_get_int2 (gnutls_session_t SESSION, int * RECV_INT, int * SEND_INT) SESSION: is a 'gnutls_session_t' structure. RECV_INT: will hold the value for the pull function SEND_INT: will hold the value for the push function Used to get the arguments of the transport functions (like PUSH and PULL). These should have been set using 'gnutls_transport_set_int2()' . *Since:* 3.1.9 gnutls_transport_get_ptr ------------------------ -- Function: gnutls_transport_ptr_t gnutls_transport_get_ptr (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Used to get the first argument of the transport function (like PUSH and PULL). This must have been set using 'gnutls_transport_set_ptr()' . *Returns:* The first argument of the transport function. gnutls_transport_get_ptr2 ------------------------- -- Function: void gnutls_transport_get_ptr2 (gnutls_session_t SESSION, gnutls_transport_ptr_t * RECV_PTR, gnutls_transport_ptr_t * SEND_PTR) SESSION: is a 'gnutls_session_t' structure. RECV_PTR: will hold the value for the pull function SEND_PTR: will hold the value for the push function Used to get the arguments of the transport functions (like PUSH and PULL). These should have been set using 'gnutls_transport_set_ptr2()' . gnutls_transport_set_errno -------------------------- -- Function: void gnutls_transport_set_errno (gnutls_session_t SESSION, int ERR) SESSION: is a 'gnutls_session_t' structure. ERR: error value to store in session-specific errno variable. 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). gnutls_transport_set_errno_function ----------------------------------- -- Function: void gnutls_transport_set_errno_function (gnutls_session_t SESSION, gnutls_errno_func ERRNO_FUNC) SESSION: is a 'gnutls_session_t' structure. ERRNO_FUNC: a callback function similar to 'write()' 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. *Since:* 2.12.0 gnutls_transport_set_int ------------------------ -- Function: void gnutls_transport_set_int (gnutls_session_t SESSION, int I) SESSION: is a 'gnutls_session_t' structure. I: is the value. Used to set the first argument of the transport function (for push and pull callbacks) for berkeley style sockets. *Since:* 3.1.9 gnutls_transport_set_int2 ------------------------- -- Function: void gnutls_transport_set_int2 (gnutls_session_t SESSION, int RECV_INT, int SEND_INT) SESSION: is a 'gnutls_session_t' structure. RECV_INT: is the value for the pull function SEND_INT: is the value for the push function Used to set the first argument of the transport function (for push and pull callbacks), when using the berkeley style sockets. With this function you can set two different pointers for receiving and sending. *Since:* 3.1.9 gnutls_transport_set_ptr ------------------------ -- Function: void gnutls_transport_set_ptr (gnutls_session_t SESSION, gnutls_transport_ptr_t PTR) SESSION: is a 'gnutls_session_t' structure. PTR: is the value. 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. gnutls_transport_set_ptr2 ------------------------- -- Function: void gnutls_transport_set_ptr2 (gnutls_session_t SESSION, gnutls_transport_ptr_t RECV_PTR, gnutls_transport_ptr_t SEND_PTR) SESSION: is a 'gnutls_session_t' structure. RECV_PTR: is the value for the pull function SEND_PTR: is the value for the push function 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. gnutls_transport_set_pull_function ---------------------------------- -- Function: void gnutls_transport_set_pull_function (gnutls_session_t SESSION, gnutls_pull_func PULL_FUNC) SESSION: is a 'gnutls_session_t' structure. PULL_FUNC: a callback function similar to 'read()' 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); gnutls_transport_set_pull_timeout_function ------------------------------------------ -- Function: void gnutls_transport_set_pull_timeout_function (gnutls_session_t SESSION, gnutls_pull_timeout_func FUNC) SESSION: is a 'gnutls_session_t' structure. FUNC: a callback function 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. 'gnutls_pull_timeout_func' is of the form, int (*gnutls_pull_timeout_func)(gnutls_transport_ptr_t, unsigned int ms); *Since:* 3.0 gnutls_transport_set_push_function ---------------------------------- -- Function: void gnutls_transport_set_push_function (gnutls_session_t SESSION, gnutls_push_func PUSH_FUNC) SESSION: is a 'gnutls_session_t' structure. PUSH_FUNC: a callback function similar to 'write()' 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); gnutls_transport_set_vec_push_function -------------------------------------- -- Function: void gnutls_transport_set_vec_push_function (gnutls_session_t SESSION, gnutls_vec_push_func VEC_FUNC) SESSION: is a 'gnutls_session_t' structure. VEC_FUNC: a callback function similar to 'writev()' 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); *Since:* 2.12.0 gnutls_url_is_supported ----------------------- -- Function: int gnutls_url_is_supported (const char * URL) URL: A PKCS 11 url Check whether url is supported. Depending on the system libraries GnuTLS may support pkcs11 or tpmkey URLs. *Returns:* return non-zero if the given URL is supported, and zero if it is not known. *Since:* 3.1.0 gnutls_verify_stored_pubkey --------------------------- -- Function: 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) 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. This function will try to verify the provided (raw or DER-encoded) certificate using a list of stored public keys. The 'service' field if non-NULL should be a port number. The 'retrieve' 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. *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  File: gnutls.info, Node: Datagram TLS API, Next: X509 certificate API, Prev: Core TLS API, Up: API reference E.2 Datagram TLS API ==================== The prototypes for the following functions lie in 'gnutls/dtls.h'. gnutls_dtls_cookie_send ----------------------- -- Function: int gnutls_dtls_cookie_send (gnutls_datum_t * KEY, void * CLIENT_DATA, size_t CLIENT_DATA_SIZE, gnutls_dtls_prestate_st * PRESTATE, gnutls_transport_ptr_t PTR, gnutls_push_func PUSH_FUNC) KEY: is a random key to be used at cookie generation CLIENT_DATA: contains data identifying the client (i.e. address) CLIENT_DATA_SIZE: The size of client's data PRESTATE: The previous cookie returned by 'gnutls_dtls_cookie_verify()' PTR: A transport pointer to be used by 'push_func' PUSH_FUNC: A function that will be used to reply This function can be used to prevent denial of service attacks to a DTLS server by requiring the client to reply using a cookie sent by this function. That way it can be ensured that a client we allocated resources for (i.e. 'gnutls_session_t' ) is the one that the original incoming packet was originated from. This function must be called at the first incoming packet, prior to allocating any resources and must be succeeded by 'gnutls_dtls_cookie_verify()' . *Returns:* the number of bytes sent, or a negative error code. *Since:* 3.0 gnutls_dtls_cookie_verify ------------------------- -- Function: int gnutls_dtls_cookie_verify (gnutls_datum_t * KEY, void * CLIENT_DATA, size_t CLIENT_DATA_SIZE, void * _MSG, size_t MSG_SIZE, gnutls_dtls_prestate_st * PRESTATE) KEY: is a random key to be used at cookie generation CLIENT_DATA: contains data identifying the client (i.e. address) CLIENT_DATA_SIZE: The size of client's data _MSG: An incoming message that initiates a connection. MSG_SIZE: The size of the message. PRESTATE: The cookie of this client. This function will verify the received message for a valid cookie. If a valid cookie is returned then it should be associated with the session using 'gnutls_dtls_prestate_set()' ; This function must be called after 'gnutls_dtls_cookie_send()' . *Returns:* 'GNUTLS_E_SUCCESS' (0) on success, or a negative error code. *Since:* 3.0 gnutls_dtls_get_data_mtu ------------------------ -- Function: unsigned int gnutls_dtls_get_data_mtu (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. This function will return the actual maximum transfer unit for application data. I.e. DTLS headers are subtracted from the actual MTU which is set using 'gnutls_dtls_set_mtu()' . *Returns:* the maximum allowed transfer unit. *Since:* 3.0 gnutls_dtls_get_mtu ------------------- -- Function: unsigned int gnutls_dtls_get_mtu (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. This function will return the MTU size as set with 'gnutls_dtls_set_mtu()' . This is not the actual MTU of data you can transmit. Use 'gnutls_dtls_get_data_mtu()' for that reason. *Returns:* the set maximum transfer unit. *Since:* 3.0 gnutls_dtls_get_timeout ----------------------- -- Function: unsigned int gnutls_dtls_get_timeout (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. This function will return the milliseconds remaining for a retransmission of the previously sent handshake message. This function is useful when DTLS is used in non-blocking mode, to estimate when to call 'gnutls_handshake()' if no packets have been received. *Returns:* the remaining time in milliseconds. *Since:* 3.0 gnutls_dtls_prestate_set ------------------------ -- Function: void gnutls_dtls_prestate_set (gnutls_session_t SESSION, gnutls_dtls_prestate_st * PRESTATE) SESSION: a new session PRESTATE: contains the client's prestate This function will associate the prestate acquired by the cookie authentication with the client, with the newly established session. This functions must be called after a successful 'gnutls_dtls_cookie_verify()' and should be succeeded by the actual DTLS handshake using 'gnutls_handshake()' . *Since:* 3.0 gnutls_dtls_set_data_mtu ------------------------ -- Function: int gnutls_dtls_set_data_mtu (gnutls_session_t SESSION, unsigned int MTU) SESSION: is a 'gnutls_session_t' structure. MTU: The maximum unencrypted transfer unit of the session This function will set the maximum size of the *unencrypted* records which will be sent over a DTLS session. It is equivalent to calculating the DTLS packet overhead with the current encryption parameters, and calling 'gnutls_dtls_set_mtu()' with that value. In particular, this means that you may need to call this function again after any negotiation or renegotiation, in order to ensure that the MTU is still sufficient to account for the new protocol overhead. In most cases you only need to call 'gnutls_dtls_set_mtu()' with the maximum MTU of your transport layer. *Returns:* 'GNUTLS_E_SUCCESS' (0) on success, or a negative error code. *Since:* 3.1 gnutls_dtls_set_mtu ------------------- -- Function: void gnutls_dtls_set_mtu (gnutls_session_t SESSION, unsigned int MTU) SESSION: is a 'gnutls_session_t' structure. MTU: The maximum transfer unit of the transport This function will set the maximum transfer unit of the transport that DTLS packets are sent over. Note that this should exclude the IP (or IPv6) and UDP headers. So for DTLS over IPv6 on an Ethenet device with MTU 1500, the DTLS MTU set with this function would be 1500 - 40 (IPV6 header) - 8 (UDP header) = 1452. *Since:* 3.0 gnutls_dtls_set_timeouts ------------------------ -- Function: void gnutls_dtls_set_timeouts (gnutls_session_t SESSION, unsigned int RETRANS_TIMEOUT, unsigned int TOTAL_TIMEOUT) SESSION: is a 'gnutls_session_t' structure. 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. This function will set the timeouts required for the DTLS handshake protocol. The retransmission timeout is the time after which a message from the peer is not received, the previous messages will be retransmitted. The total timeout is the time after which the handshake will be aborted with 'GNUTLS_E_TIMEDOUT' . The DTLS protocol recommends the values of 1 sec and 60 seconds respectively. To disable retransmissions set a 'retrans_timeout' larger than the 'total_timeout' . *Since:* 3.0 gnutls_record_get_discarded --------------------------- -- Function: unsigned int gnutls_record_get_discarded (gnutls_session_t SESSION) SESSION: is a 'gnutls_session_t' structure. Returns the number of discarded packets in a DTLS connection. *Returns:* The number of discarded packets. *Since:* 3.0  File: gnutls.info, Node: X509 certificate API, Next: OCSP API, Prev: Datagram TLS API, Up: API reference E.3 X.509 certificate API ========================= The following functions are to be used for X.509 certificate handling. Their prototypes lie in 'gnutls/x509.h'. gnutls_certificate_set_trust_list --------------------------------- -- Function: void gnutls_certificate_set_trust_list (gnutls_certificate_credentials_t RES, gnutls_x509_trust_list_t TLIST, unsigned FLAGS) RES: is a 'gnutls_certificate_credentials_t' structure. TLIST: is a 'gnutls_x509_trust_list_t' structure FLAGS: must be zero This function sets a trust list in the gnutls_certificate_credentials_t structure. Note that the 'tlist' will become part of the credentials structure and must not be deallocated. It will be automatically deallocated when the 'res' structure is deinitialized. *Returns:* 'GNUTLS_E_SUCCESS' (0) on success, or a negative error code. *Since:* 3.2.2 gnutls_pkcs7_deinit ------------------- -- Function: void gnutls_pkcs7_deinit (gnutls_pkcs7_t PKCS7) PKCS7: The structure to be initialized This function will deinitialize a PKCS7 structure. gnutls_pkcs7_delete_crl ----------------------- -- Function: int gnutls_pkcs7_delete_crl (gnutls_pkcs7_t PKCS7, int INDX) PKCS7: should contain a 'gnutls_pkcs7_t' structure INDX: the index of the crl to delete This function will delete a crl from a PKCS7 or RFC2630 crl set. Index starts from 0. Returns 0 on success. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_pkcs7_delete_crt ----------------------- -- Function: int gnutls_pkcs7_delete_crt (gnutls_pkcs7_t PKCS7, int INDX) PKCS7: should contain a gnutls_pkcs7_t structure INDX: the index of the certificate to delete This function will delete a certificate from a PKCS7 or RFC2630 certificate set. Index starts from 0. Returns 0 on success. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_pkcs7_export ------------------- -- Function: int gnutls_pkcs7_export (gnutls_pkcs7_t PKCS7, gnutls_x509_crt_fmt_t FORMAT, void * OUTPUT_DATA, size_t * OUTPUT_DATA_SIZE) PKCS7: Holds the pkcs7 structure FORMAT: the format of output params. One of PEM or DER. OUTPUT_DATA: will contain a structure PEM or DER encoded OUTPUT_DATA_SIZE: holds the size of output_data (and will be replaced by the actual size of parameters) This function will export the pkcs7 structure to DER or PEM format. If the buffer provided is not long enough to hold the output, then * 'output_data_size' is updated and 'GNUTLS_E_SHORT_MEMORY_BUFFER' will be returned. If the structure is PEM encoded, it will have a header of "BEGIN PKCS7". *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_pkcs7_export2 -------------------- -- Function: int gnutls_pkcs7_export2 (gnutls_pkcs7_t PKCS7, gnutls_x509_crt_fmt_t FORMAT, gnutls_datum_t * OUT) PKCS7: Holds the pkcs7 structure FORMAT: the format of output params. One of PEM or DER. OUT: will contain a structure PEM or DER encoded This function will export the pkcs7 structure to DER or PEM format. The output buffer is allocated using 'gnutls_malloc()' . If the structure is PEM encoded, it will have a header of "BEGIN PKCS7". *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.1.3 gnutls_pkcs7_get_crl_count -------------------------- -- Function: int gnutls_pkcs7_get_crl_count (gnutls_pkcs7_t PKCS7) PKCS7: should contain a gnutls_pkcs7_t structure This function will return the number of certifcates in the PKCS7 or RFC2630 crl set. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_pkcs7_get_crl_raw ------------------------ -- Function: int gnutls_pkcs7_get_crl_raw (gnutls_pkcs7_t PKCS7, int INDX, void * CRL, size_t * CRL_SIZE) PKCS7: should contain a 'gnutls_pkcs7_t' structure INDX: contains the index of the crl to extract CRL: the contents of the crl will be copied there (may be null) CRL_SIZE: should hold the size of the crl This function will return a crl of the PKCS7 or RFC2630 crl set. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. If the provided buffer is not long enough, then 'crl_size' is updated and 'GNUTLS_E_SHORT_MEMORY_BUFFER' is returned. After the last crl has been read 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. gnutls_pkcs7_get_crt_count -------------------------- -- Function: int gnutls_pkcs7_get_crt_count (gnutls_pkcs7_t PKCS7) PKCS7: should contain a 'gnutls_pkcs7_t' structure This function will return the number of certifcates in the PKCS7 or RFC2630 certificate set. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_pkcs7_get_crt_raw ------------------------ -- Function: int gnutls_pkcs7_get_crt_raw (gnutls_pkcs7_t PKCS7, int INDX, void * CERTIFICATE, size_t * CERTIFICATE_SIZE) PKCS7: should contain a gnutls_pkcs7_t structure INDX: contains the index of the certificate to extract CERTIFICATE: the contents of the certificate will be copied there (may be null) CERTIFICATE_SIZE: should hold the size of the certificate This function will return a certificate of the PKCS7 or RFC2630 certificate set. After the last certificate has been read 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. If the provided buffer is not long enough, then 'certificate_size' is updated and 'GNUTLS_E_SHORT_MEMORY_BUFFER' is returned. gnutls_pkcs7_import ------------------- -- Function: int gnutls_pkcs7_import (gnutls_pkcs7_t PKCS7, const gnutls_datum_t * DATA, gnutls_x509_crt_fmt_t FORMAT) PKCS7: The structure to store the parsed PKCS7. DATA: The DER or PEM encoded PKCS7. FORMAT: One of DER or PEM This function will convert the given DER or PEM encoded PKCS7 to the native 'gnutls_pkcs7_t' format. The output will be stored in 'pkcs7' . If the PKCS7 is PEM encoded it should have a header of "PKCS7". *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_pkcs7_init ----------------- -- Function: int gnutls_pkcs7_init (gnutls_pkcs7_t * PKCS7) PKCS7: The structure to be initialized This function will initialize a PKCS7 structure. PKCS7 structures usually contain lists of X.509 Certificates and X.509 Certificate revocation lists. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_pkcs7_set_crl -------------------- -- Function: int gnutls_pkcs7_set_crl (gnutls_pkcs7_t PKCS7, gnutls_x509_crl_t CRL) PKCS7: should contain a 'gnutls_pkcs7_t' structure CRL: the DER encoded crl to be added This function will add a parsed CRL to the PKCS7 or RFC2630 crl set. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_pkcs7_set_crl_raw ------------------------ -- Function: int gnutls_pkcs7_set_crl_raw (gnutls_pkcs7_t PKCS7, const gnutls_datum_t * CRL) PKCS7: should contain a 'gnutls_pkcs7_t' structure CRL: the DER encoded crl to be added This function will add a crl to the PKCS7 or RFC2630 crl set. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_pkcs7_set_crt -------------------- -- Function: int gnutls_pkcs7_set_crt (gnutls_pkcs7_t PKCS7, gnutls_x509_crt_t CRT) PKCS7: should contain a 'gnutls_pkcs7_t' structure CRT: the certificate to be copied. This function will add a parsed certificate to the PKCS7 or RFC2630 certificate set. This is a wrapper function over 'gnutls_pkcs7_set_crt_raw()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_pkcs7_set_crt_raw ------------------------ -- Function: int gnutls_pkcs7_set_crt_raw (gnutls_pkcs7_t PKCS7, const gnutls_datum_t * CRT) PKCS7: should contain a 'gnutls_pkcs7_t' structure CRT: the DER encoded certificate to be added This function will add a certificate to the PKCS7 or RFC2630 certificate set. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_subject_alt_names_deinit ------------------------------- -- Function: void gnutls_subject_alt_names_deinit (gnutls_subject_alt_names_t SANS) SANS: The alternative names structure This function will deinitialize an alternative names structure. *Since:* 3.3.0 gnutls_subject_alt_names_get ---------------------------- -- Function: int gnutls_subject_alt_names_get (gnutls_subject_alt_names_t SANS, unsigned int SEQ, unsigned int * SAN_TYPE, gnutls_datum_t * SAN, gnutls_datum_t * OTHERNAME_OID) SANS: The alternative names structure SEQ: The index of the name to get SAN_TYPE: Will hold the type of the name (of 'gnutls_subject_alt_names_t' ) SAN: The alternative name data (should be treated as constant) OTHERNAME_OID: The object identifier if 'san_type' is 'GNUTLS_SAN_OTHERNAME' (should be treated as constant) This function will return a specific alternative name as stored in the 'sans' structure. The returned values should be treated as constant and valid for the lifetime of 'sans' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if the index is out of bounds, otherwise a negative error value. *Since:* 3.3.0 gnutls_subject_alt_names_init ----------------------------- -- Function: int gnutls_subject_alt_names_init (gnutls_subject_alt_names_t * SANS) SANS: The alternative names structure This function will initialize an alternative names structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_subject_alt_names_set ---------------------------- -- Function: int gnutls_subject_alt_names_set (gnutls_subject_alt_names_t SANS, unsigned int SAN_TYPE, const gnutls_datum_t * SAN, const char * OTHERNAME_OID) SANS: The alternative names structure SAN_TYPE: The type of the name (of 'gnutls_subject_alt_names_t' ) SAN: The alternative name data OTHERNAME_OID: The object identifier if 'san_type' is 'GNUTLS_SAN_OTHERNAME' This function will store the specified alternative name in the 'sans' structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0), otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_aia_deinit ---------------------- -- Function: void gnutls_x509_aia_deinit (gnutls_x509_aia_t AIA) AIA: The authority info access structure This function will deinitialize a CRL distribution points structure. *Since:* 3.3.0 gnutls_x509_aia_get ------------------- -- Function: int gnutls_x509_aia_get (gnutls_x509_aia_t AIA, unsigned int SEQ, gnutls_datum_t * OID, unsigned * SAN_TYPE, gnutls_datum_t * SAN) AIA: The authority info access structure SEQ: specifies the sequence number of the access descriptor (0 for the first one, 1 for the second etc.) OID: the type of available data; to be treated as constant. SAN_TYPE: Will hold the type of the name of 'gnutls_subject_alt_names_t' (may be null). SAN: the access location name; to be treated as constant (may be null). This function reads from the Authority Information Access structure. The 'seq' input parameter is used to indicate which member of the sequence the caller is interested in. The first member is 0, the second member 1 and so on. When the 'seq' value is out of bounds, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' is returned. Typically 'oid' is 'GNUTLS_OID_AD_CAISSUERS' or 'GNUTLS_OID_AD_OCSP' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_aia_init -------------------- -- Function: int gnutls_x509_aia_init (gnutls_x509_aia_t * AIA) AIA: The authority info access structure This function will initialize a CRL distribution points structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_aia_set ------------------- -- Function: int gnutls_x509_aia_set (gnutls_x509_aia_t AIA, const char * OID, unsigned SAN_TYPE, const gnutls_datum_t * SAN) AIA: The authority info access structure OID: the type of data. SAN_TYPE: The type of the name (of 'gnutls_subject_alt_names_t' ) SAN: The alternative name data This function will store the specified alternative name in the 'aia' structure. Typically the value for 'oid' should be 'GNUTLS_OID_AD_OCSP' , or 'GNUTLS_OID_AD_CAISSUERS' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0), otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_aki_deinit ---------------------- -- Function: void gnutls_x509_aki_deinit (gnutls_x509_aki_t AKI) AKI: The authority key identifier structure This function will deinitialize an authority key identifier structure. *Since:* 3.3.0 gnutls_x509_aki_get_cert_issuer ------------------------------- -- Function: int gnutls_x509_aki_get_cert_issuer (gnutls_x509_aki_t AKI, unsigned int SEQ, unsigned int * SAN_TYPE, gnutls_datum_t * SAN, gnutls_datum_t * OTHERNAME_OID, gnutls_datum_t * SERIAL) AKI: The authority key ID structure SEQ: The index of the name to get SAN_TYPE: Will hold the type of the name (of 'gnutls_subject_alt_names_t' ) SAN: The alternative name data OTHERNAME_OID: The object identifier if 'san_type' is 'GNUTLS_SAN_OTHERNAME' SERIAL: The authorityCertSerialNumber number This function will return a specific authorityCertIssuer name as stored in the 'aki' structure, as well as the authorityCertSerialNumber. All the returned values should be treated as constant, and may be set to 'NULL' when are not required. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if the index is out of bounds, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_aki_get_id ---------------------- -- Function: int gnutls_x509_aki_get_id (gnutls_x509_aki_t AKI, gnutls_datum_t * ID) AKI: The authority key ID structure ID: Will hold the identifier This function will return the key identifier as stored in the 'aki' structure. The identifier should be treated as constant. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if the index is out of bounds, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_aki_init -------------------- -- Function: int gnutls_x509_aki_init (gnutls_x509_aki_t * AKI) AKI: The authority key ID structure This function will initialize an authority key ID structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_aki_set_cert_issuer ------------------------------- -- Function: int gnutls_x509_aki_set_cert_issuer (gnutls_x509_aki_t AKI, unsigned int SAN_TYPE, const gnutls_datum_t * SAN, const char * OTHERNAME_OID, const gnutls_datum_t * SERIAL) AKI: The authority key ID structure SAN_TYPE: the type of the name (of 'gnutls_subject_alt_names_t' ), may be null SAN: The alternative name data OTHERNAME_OID: The object identifier if 'san_type' is 'GNUTLS_SAN_OTHERNAME' SERIAL: The authorityCertSerialNumber number (may be null) This function will set the authorityCertIssuer name and the authorityCertSerialNumber to be stored in the 'aki' structure. When storing multiple names, the serial should be set on the first call, and subsequent calls should use a 'NULL' serial. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_aki_set_id ---------------------- -- Function: int gnutls_x509_aki_set_id (gnutls_x509_aki_t AKI, const gnutls_datum_t * ID) AKI: The authority key ID structure ID: the key identifier This function will set the keyIdentifier to be stored in the 'aki' structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_crl_check_issuer ---------------------------- -- Function: int gnutls_x509_crl_check_issuer (gnutls_x509_crl_t CRL, gnutls_x509_crt_t ISSUER) CRL: is the CRL to be checked ISSUER: is the certificate of a possible issuer This function will check if the given CRL was issued by the given issuer certificate. *Returns:* true (1) if the given CRL was issued by the given issuer, and false (0) if not. gnutls_x509_crl_deinit ---------------------- -- Function: void gnutls_x509_crl_deinit (gnutls_x509_crl_t CRL) CRL: The structure to be deinitialized This function will deinitialize a CRL structure. gnutls_x509_crl_dist_points_deinit ---------------------------------- -- Function: void gnutls_x509_crl_dist_points_deinit (gnutls_x509_crl_dist_points_t CDP) CDP: The CRL distribution points structure This function will deinitialize a CRL distribution points structure. *Since:* 3.3.0 gnutls_x509_crl_dist_points_get ------------------------------- -- Function: int gnutls_x509_crl_dist_points_get (gnutls_x509_crl_dist_points_t CDP, unsigned int SEQ, unsigned int * TYPE, gnutls_datum_t * SAN, unsigned int * REASONS) CDP: The CRL distribution points structure SEQ: specifies the sequence number of the distribution point (0 for the first one, 1 for the second etc.) TYPE: The name type of the corresponding name (gnutls_x509_subject_alt_name_t) SAN: The distribution point names (to be treated as constant) REASONS: Revocation reasons. An ORed sequence of flags from 'gnutls_x509_crl_reason_flags_t' . This function retrieves the individual CRL distribution points (2.5.29.31), contained in provided structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if the index is out of bounds, otherwise a negative error value. gnutls_x509_crl_dist_points_init -------------------------------- -- Function: int gnutls_x509_crl_dist_points_init (gnutls_x509_crl_dist_points_t * CDP) CDP: The CRL distribution points structure This function will initialize a CRL distribution points structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_crl_dist_points_set ------------------------------- -- Function: int gnutls_x509_crl_dist_points_set (gnutls_x509_crl_dist_points_t CDP, gnutls_x509_subject_alt_name_t TYPE, const gnutls_datum_t * SAN, unsigned int REASONS) CDP: The CRL distribution points structure TYPE: The type of the name (of 'gnutls_subject_alt_names_t' ) SAN: The point name data REASONS: Revocation reasons. An ORed sequence of flags from 'gnutls_x509_crl_reason_flags_t' . This function will store the specified CRL distibution point value the 'cdp' structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0), otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_crl_export ---------------------- -- Function: int gnutls_x509_crl_export (gnutls_x509_crl_t CRL, gnutls_x509_crt_fmt_t FORMAT, void * OUTPUT_DATA, size_t * OUTPUT_DATA_SIZE) CRL: Holds the revocation list FORMAT: the format of output params. One of PEM or DER. OUTPUT_DATA: will contain a private key PEM or DER encoded OUTPUT_DATA_SIZE: holds the size of output_data (and will be replaced by the actual size of parameters) This function will export the revocation list to DER or PEM format. 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 X509 CRL". *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crl_export2 ----------------------- -- Function: int gnutls_x509_crl_export2 (gnutls_x509_crl_t CRL, gnutls_x509_crt_fmt_t FORMAT, gnutls_datum_t * OUT) CRL: Holds the revocation list FORMAT: the format of output params. One of PEM or DER. OUT: will contain a private key PEM or DER encoded This function will export the revocation list to DER or PEM format. The output buffer is allocated using 'gnutls_malloc()' . If the structure is PEM encoded, it will have a header of "BEGIN X509 CRL". *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. Since 3.1.3 gnutls_x509_crl_get_authority_key_gn_serial ------------------------------------------- -- Function: int gnutls_x509_crl_get_authority_key_gn_serial (gnutls_x509_crl_t CRL, unsigned int SEQ, void * ALT, size_t * ALT_SIZE, unsigned int * ALT_TYPE, void * SERIAL, size_t * SERIAL_SIZE, unsigned int * CRITICAL) CRL: should contain a 'gnutls_x509_crl_t' structure SEQ: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) ALT: is the place where the alternative name will be copied to ALT_SIZE: holds the size of alt. ALT_TYPE: holds the type of the alternative name (one of gnutls_x509_subject_alt_name_t). SERIAL: buffer to store the serial number (may be null) SERIAL_SIZE: Holds the size of the serial field (may be null) CRITICAL: will be non-zero if the extension is marked as critical (may be null) This function will return the X.509 authority key identifier when stored as a general name (authorityCertIssuer) and serial number. Because more than one general names might be stored 'seq' can be used as a counter to request them all until 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' is returned. *Returns:* Returns 0 on success, or an error code. *Since:* 3.0 gnutls_x509_crl_get_authority_key_id ------------------------------------ -- Function: int gnutls_x509_crl_get_authority_key_id (gnutls_x509_crl_t CRL, void * ID, size_t * ID_SIZE, unsigned int * CRITICAL) CRL: should contain a 'gnutls_x509_crl_t' structure ID: The place where the identifier will be copied ID_SIZE: Holds the size of the result field. CRITICAL: will be non-zero if the extension is marked as critical (may be null) This function will return the CRL authority's key identifier. This is obtained by the X.509 Authority Key identifier extension field (2.5.29.35). Note that this function only returns the keyIdentifier field of the extension and 'GNUTLS_E_X509_UNSUPPORTED_EXTENSION' , if the extension contains the name and serial number of the certificate. In that case 'gnutls_x509_crl_get_authority_key_gn_serial()' may be used. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code in case of an error. *Since:* 2.8.0 gnutls_x509_crl_get_crt_count ----------------------------- -- Function: int gnutls_x509_crl_get_crt_count (gnutls_x509_crl_t CRL) CRL: should contain a 'gnutls_x509_crl_t' structure This function will return the number of revoked certificates in the given CRL. *Returns:* number of certificates, a negative error code on failure. gnutls_x509_crl_get_crt_serial ------------------------------ -- Function: int gnutls_x509_crl_get_crt_serial (gnutls_x509_crl_t CRL, int INDX, unsigned char * SERIAL, size_t * SERIAL_SIZE, time_t * T) CRL: should contain a 'gnutls_x509_crl_t' structure INDX: the index of the certificate to extract (starting from 0) SERIAL: where the serial number will be copied SERIAL_SIZE: initially holds the size of serial T: if non null, will hold the time this certificate was revoked This function will retrieve the serial number of the specified, by the index, revoked certificate. Note that this function will have performance issues in large sequences of revoked certificates. In that case use 'gnutls_x509_crl_iter_crt_serial()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crl_get_dn_oid -------------------------- -- Function: int gnutls_x509_crl_get_dn_oid (gnutls_x509_crl_t CRL, int INDX, void * OID, size_t * SIZEOF_OID) CRL: should contain a gnutls_x509_crl_t structure INDX: Specifies which DN OID to send. Use (0) to get the first one. OID: a pointer to a structure to hold the name (may be null) SIZEOF_OID: initially holds the size of 'oid' This function will extract the requested OID of the name of the CRL issuer, specified by the given index. If oid is null then only the size will be filled. *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' if the provided buffer is not long enough, and in that case the sizeof_oid will be updated with the required size. On success 0 is returned. gnutls_x509_crl_get_extension_data ---------------------------------- -- Function: int gnutls_x509_crl_get_extension_data (gnutls_x509_crl_t CRL, int INDX, void * DATA, size_t * SIZEOF_DATA) CRL: should contain a 'gnutls_x509_crl_t' structure INDX: Specifies which extension OID to send. Use (0) to get the first one. DATA: a pointer to a structure to hold the data (may be null) SIZEOF_DATA: initially holds the size of 'oid' This function will return the requested extension data in the CRL. The extension data will be stored as a string in the provided buffer. Use 'gnutls_x509_crl_get_extension_info()' to extract the OID and critical flag. Use 'gnutls_x509_crl_get_extension_info()' instead, if you want to get data indexed by the extension OID rather than sequence. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code in case of an error. If your have reached the last extension available 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. *Since:* 2.8.0 gnutls_x509_crl_get_extension_data2 ----------------------------------- -- Function: int gnutls_x509_crl_get_extension_data2 (gnutls_x509_crl_t CRL, unsigned INDX, gnutls_datum_t * DATA) CRL: should contain a 'gnutls_x509_crl_t' structure INDX: Specifies which extension OID to read. Use (0) to get the first one. DATA: will contain the extension DER-encoded data This function will return the requested by the index extension data in the certificate revocation list. The extension data will be allocated using 'gnutls_malloc()' . Use 'gnutls_x509_crt_get_extension_info()' to extract the OID. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. If you have reached the last extension available 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. gnutls_x509_crl_get_extension_info ---------------------------------- -- Function: int gnutls_x509_crl_get_extension_info (gnutls_x509_crl_t CRL, int INDX, void * OID, size_t * SIZEOF_OID, unsigned int * CRITICAL) CRL: should contain a 'gnutls_x509_crl_t' structure INDX: Specifies which extension OID to send, use (0) to get the first one. OID: a pointer to a structure to hold the OID SIZEOF_OID: initially holds the maximum size of 'oid' , on return holds actual size of 'oid' . CRITICAL: output variable with critical flag, may be NULL. This function will return the requested extension OID in the CRL, and the critical flag for it. The extension OID will be stored as a string in the provided buffer. Use 'gnutls_x509_crl_get_extension_data()' to extract the data. If the buffer provided is not long enough to hold the output, then * 'sizeof_oid' is updated and 'GNUTLS_E_SHORT_MEMORY_BUFFER' will be returned. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code in case of an error. If your have reached the last extension available 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. *Since:* 2.8.0 gnutls_x509_crl_get_extension_oid --------------------------------- -- Function: int gnutls_x509_crl_get_extension_oid (gnutls_x509_crl_t CRL, int INDX, void * OID, size_t * SIZEOF_OID) CRL: should contain a 'gnutls_x509_crl_t' structure INDX: Specifies which extension OID to send, use (0) to get the first one. OID: a pointer to a structure to hold the OID (may be null) SIZEOF_OID: initially holds the size of 'oid' This function will return the requested extension OID in the CRL. The extension OID will be stored as a string in the provided buffer. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code in case of an error. If your have reached the last extension available 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. *Since:* 2.8.0 gnutls_x509_crl_get_issuer_dn ----------------------------- -- Function: int gnutls_x509_crl_get_issuer_dn (const gnutls_x509_crl_t CRL, char * BUF, size_t * SIZEOF_BUF) CRL: should contain a gnutls_x509_crl_t structure BUF: a pointer to a structure to hold the peer's name (may be null) SIZEOF_BUF: initially holds the size of 'buf' This function will copy the name of the CRL issuer in the provided buffer. The name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in RFC4514. The output string will be ASCII or UTF-8 encoded, depending on the certificate data. If buf is 'NULL' then only the size will be filled. *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' if the provided buffer is not long enough, and in that case the sizeof_buf will be updated with the required size, and 0 on success. gnutls_x509_crl_get_issuer_dn2 ------------------------------ -- Function: int gnutls_x509_crl_get_issuer_dn2 (gnutls_x509_crl_t CRL, gnutls_datum_t * DN) CRL: should contain a 'gnutls_x509_crl_t' structure DN: a pointer to a structure to hold the name This function will allocate buffer and copy the name of the CRL issuer. The name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in RFC4514. The output string will be ASCII or UTF-8 encoded, depending on the certificate data. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.1.10 gnutls_x509_crl_get_issuer_dn_by_oid ------------------------------------ -- Function: int gnutls_x509_crl_get_issuer_dn_by_oid (gnutls_x509_crl_t CRL, const char * OID, int INDX, unsigned int RAW_FLAG, void * BUF, size_t * SIZEOF_BUF) CRL: should contain a gnutls_x509_crl_t structure OID: holds an Object Identified in null terminated string INDX: In case multiple same OIDs exist in the RDN, this specifies which to send. Use (0) to get the first one. RAW_FLAG: If non-zero returns the raw DER data of the DN part. BUF: a pointer to a structure to hold the peer's name (may be null) SIZEOF_BUF: initially holds the size of 'buf' This function will extract the part of the name of the CRL issuer specified by the given OID. The output will be encoded as described in RFC4514. The output string will be ASCII or UTF-8 encoded, depending on the certificate data. Some helper macros with popular OIDs can be found in gnutls/x509.h If raw flag is (0), this function will only return known OIDs as text. Other OIDs will be DER encoded, as described in RFC4514 - in hex format with a '#' prefix. You can check about known OIDs using 'gnutls_x509_dn_oid_known()' . If buf is null then only the size will be filled. *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' if the provided buffer is not long enough, and in that case the sizeof_buf will be updated with the required size, and 0 on success. gnutls_x509_crl_get_next_update ------------------------------- -- Function: time_t gnutls_x509_crl_get_next_update (gnutls_x509_crl_t CRL) CRL: should contain a 'gnutls_x509_crl_t' structure This function will return the time the next CRL will be issued. This field is optional in a CRL so it might be normal to get an error instead. *Returns:* when the next CRL will be issued, or (time_t)-1 on error. gnutls_x509_crl_get_number -------------------------- -- Function: int gnutls_x509_crl_get_number (gnutls_x509_crl_t CRL, void * RET, size_t * RET_SIZE, unsigned int * CRITICAL) CRL: should contain a 'gnutls_x509_crl_t' structure RET: The place where the number will be copied RET_SIZE: Holds the size of the result field. CRITICAL: will be non-zero if the extension is marked as critical (may be null) This function will return the CRL number extension. This is obtained by the CRL Number extension field (2.5.29.20). *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code in case of an error. *Since:* 2.8.0 gnutls_x509_crl_get_raw_issuer_dn --------------------------------- -- Function: int gnutls_x509_crl_get_raw_issuer_dn (gnutls_x509_crl_t CRL, gnutls_datum_t * DN) CRL: should contain a gnutls_x509_crl_t structure DN: will hold the starting point of the DN This function will return a pointer to the DER encoded DN structure and the length. *Returns:* a negative error code on error, and (0) on success. *Since:* 2.12.0 gnutls_x509_crl_get_signature ----------------------------- -- Function: int gnutls_x509_crl_get_signature (gnutls_x509_crl_t CRL, char * SIG, size_t * SIZEOF_SIG) CRL: should contain a gnutls_x509_crl_t structure SIG: a pointer where the signature part will be copied (may be null). SIZEOF_SIG: initially holds the size of 'sig' This function will extract the signature field of a CRL. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crl_get_signature_algorithm --------------------------------------- -- Function: int gnutls_x509_crl_get_signature_algorithm (gnutls_x509_crl_t CRL) CRL: should contain a 'gnutls_x509_crl_t' structure This function will return a value of the 'gnutls_sign_algorithm_t' enumeration that is the signature algorithm. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crl_get_this_update ------------------------------- -- Function: time_t gnutls_x509_crl_get_this_update (gnutls_x509_crl_t CRL) CRL: should contain a 'gnutls_x509_crl_t' structure This function will return the time this CRL was issued. *Returns:* when the CRL was issued, or (time_t)-1 on error. gnutls_x509_crl_get_version --------------------------- -- Function: int gnutls_x509_crl_get_version (gnutls_x509_crl_t CRL) CRL: should contain a 'gnutls_x509_crl_t' structure This function will return the version of the specified CRL. *Returns:* The version number, or a negative error code on error. gnutls_x509_crl_import ---------------------- -- Function: int gnutls_x509_crl_import (gnutls_x509_crl_t CRL, const gnutls_datum_t * DATA, gnutls_x509_crt_fmt_t FORMAT) CRL: The structure to store the parsed CRL. DATA: The DER or PEM encoded CRL. FORMAT: One of DER or PEM This function will convert the given DER or PEM encoded CRL to the native 'gnutls_x509_crl_t' format. The output will be stored in 'crl'. If the CRL is PEM encoded it should have a header of "X509 CRL". *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crl_init -------------------- -- Function: int gnutls_x509_crl_init (gnutls_x509_crl_t * CRL) CRL: The structure to be initialized This function will initialize a CRL structure. CRL stands for Certificate Revocation List. A revocation list usually contains lists of certificate serial numbers that have been revoked by an Authority. The revocation lists are always signed with the authority's private key. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crl_iter_crt_serial ------------------------------- -- Function: int gnutls_x509_crl_iter_crt_serial (gnutls_x509_crl_t CRL, gnutls_x509_crl_iter_t * ITER, unsigned char * SERIAL, size_t * SERIAL_SIZE, time_t * T) CRL: should contain a 'gnutls_x509_crl_t' structure ITER: A pointer to an iterator (initially the iterator should be 'NULL' ) SERIAL: where the serial number will be copied SERIAL_SIZE: initially holds the size of serial T: if non null, will hold the time this certificate was revoked This function performs the same as 'gnutls_x509_crl_get_crt_serial()' , but reads sequentially and keeps state in the iterator between calls. That allows it to provide better performance in sequences with many elements (50000+). When past the last element is accessed 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' is returned and the iterator is reset. After use, the iterator must be deinitialized using 'gnutls_x509_crl_iter_deinit()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crl_iter_deinit --------------------------- -- Function: void gnutls_x509_crl_iter_deinit (gnutls_x509_crl_iter_t ITER) ITER: The iterator structure to be deinitialized This function will deinitialize an iterator structure. gnutls_x509_crl_list_import --------------------------- -- Function: int gnutls_x509_crl_list_import (gnutls_x509_crl_t * CRLS, unsigned int * CRL_MAX, const gnutls_datum_t * DATA, gnutls_x509_crt_fmt_t FORMAT, unsigned int FLAGS) CRLS: The structures to store the parsed CRLs. Must not be initialized. CRL_MAX: Initially must hold the maximum number of crls. It will be updated with the number of crls available. DATA: The PEM encoded CRLs FORMAT: One of DER or PEM. FLAGS: must be (0) or an OR'd sequence of gnutls_certificate_import_flags. This function will convert the given PEM encoded CRL list to the native gnutls_x509_crl_t format. The output will be stored in 'crls' . They will be automatically initialized. If the Certificate is PEM encoded it should have a header of "X509 CRL". *Returns:* the number of certificates read or a negative error value. *Since:* 3.0 gnutls_x509_crl_list_import2 ---------------------------- -- Function: int gnutls_x509_crl_list_import2 (gnutls_x509_crl_t ** CRLS, unsigned int * SIZE, const gnutls_datum_t * DATA, gnutls_x509_crt_fmt_t FORMAT, unsigned int FLAGS) CRLS: The structures to store the parsed crl list. Must not be initialized. SIZE: It will contain the size of the list. DATA: The PEM encoded CRL. FORMAT: One of DER or PEM. FLAGS: must be (0) or an OR'd sequence of gnutls_certificate_import_flags. This function will convert the given PEM encoded CRL list to the native gnutls_x509_crl_t format. The output will be stored in 'crls' . They will be automatically initialized. If the Certificate is PEM encoded it should have a header of "X509 CRL". *Returns:* the number of certificates read or a negative error value. *Since:* 3.0 gnutls_x509_crl_print --------------------- -- Function: int gnutls_x509_crl_print (gnutls_x509_crl_t CRL, gnutls_certificate_print_formats_t FORMAT, gnutls_datum_t * OUT) CRL: The structure to be printed FORMAT: Indicate the format to use OUT: Newly allocated datum with null terminated string. This function will pretty print a X.509 certificate revocation list, suitable for display to a human. The output 'out' needs to be deallocated using 'gnutls_free()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crl_set_authority_key_id ------------------------------------ -- Function: int gnutls_x509_crl_set_authority_key_id (gnutls_x509_crl_t CRL, const void * ID, size_t ID_SIZE) CRL: a CRL of type 'gnutls_x509_crl_t' ID: The key ID ID_SIZE: Holds the size of the serial field. This function will set the CRL's authority key ID extension. Only the keyIdentifier field can be set with this function. This may be used by an authority that holds multiple private keys, to distinguish the used key. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 2.8.0 gnutls_x509_crl_set_crt ----------------------- -- Function: int gnutls_x509_crl_set_crt (gnutls_x509_crl_t CRL, gnutls_x509_crt_t CRT, time_t REVOCATION_TIME) CRL: should contain a gnutls_x509_crl_t structure CRT: a certificate of type 'gnutls_x509_crt_t' with the revoked certificate REVOCATION_TIME: The time this certificate was revoked This function will set a revoked certificate's serial number to the CRL. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crl_set_crt_serial ------------------------------ -- Function: int gnutls_x509_crl_set_crt_serial (gnutls_x509_crl_t CRL, const void * SERIAL, size_t SERIAL_SIZE, time_t REVOCATION_TIME) CRL: should contain a gnutls_x509_crl_t structure SERIAL: The revoked certificate's serial number SERIAL_SIZE: Holds the size of the serial field. REVOCATION_TIME: The time this certificate was revoked This function will set a revoked certificate's serial number to the CRL. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crl_set_next_update ------------------------------- -- Function: int gnutls_x509_crl_set_next_update (gnutls_x509_crl_t CRL, time_t EXP_TIME) CRL: should contain a gnutls_x509_crl_t structure EXP_TIME: The actual time This function will set the time this CRL will be updated. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crl_set_number -------------------------- -- Function: int gnutls_x509_crl_set_number (gnutls_x509_crl_t CRL, const void * NR, size_t NR_SIZE) CRL: a CRL of type 'gnutls_x509_crl_t' NR: The CRL number NR_SIZE: Holds the size of the nr field. This function will set the CRL's number extension. This is to be used as a unique and monotonic number assigned to the CRL by the authority. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 2.8.0 gnutls_x509_crl_set_this_update ------------------------------- -- Function: int gnutls_x509_crl_set_this_update (gnutls_x509_crl_t CRL, time_t ACT_TIME) CRL: should contain a gnutls_x509_crl_t structure ACT_TIME: The actual time This function will set the time this CRL was issued. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crl_set_version --------------------------- -- Function: int gnutls_x509_crl_set_version (gnutls_x509_crl_t CRL, unsigned int VERSION) CRL: should contain a gnutls_x509_crl_t structure VERSION: holds the version number. For CRLv1 crls must be 1. This function will set the version of the CRL. This must be one for CRL version 1, and so on. The CRLs generated by gnutls should have a version number of 2. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crl_sign2 --------------------- -- Function: int gnutls_x509_crl_sign2 (gnutls_x509_crl_t CRL, gnutls_x509_crt_t ISSUER, gnutls_x509_privkey_t ISSUER_KEY, gnutls_digest_algorithm_t DIG, unsigned int FLAGS) CRL: should contain a gnutls_x509_crl_t structure ISSUER: is the certificate of the certificate issuer ISSUER_KEY: holds the issuer's private key DIG: The message digest to use. GNUTLS_DIG_SHA1 is the safe choice unless you know what you're doing. FLAGS: must be 0 This function will sign the CRL with the issuer's private key, and will copy the issuer's information into the CRL. This must be the last step in a certificate CRL since all the previously set parameters are now signed. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crl_verify ---------------------- -- Function: int gnutls_x509_crl_verify (gnutls_x509_crl_t CRL, const gnutls_x509_crt_t * TRUSTED_CAS, int TCAS_SIZE, unsigned int FLAGS, unsigned int * VERIFY) CRL: is the crl to be verified TRUSTED_CAS: is a certificate list that is considered to be trusted one TCAS_SIZE: holds the number of CA certificates in CA_list FLAGS: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations. VERIFY: will hold the crl verification output. This function will try to verify the given crl and return its verification status. See 'gnutls_x509_crt_list_verify()' for a detailed description of return values. Note that since GnuTLS 3.1.4 this function includes the time checks. Note that value in 'verify' is set only when the return value of this function is success (i.e, failure to trust a CRL a certificate does not imply a negative return value). *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crq_deinit ---------------------- -- Function: void gnutls_x509_crq_deinit (gnutls_x509_crq_t CRQ) CRQ: The structure to be initialized This function will deinitialize a PKCS'10' certificate request structure. gnutls_x509_crq_export ---------------------- -- Function: int gnutls_x509_crq_export (gnutls_x509_crq_t CRQ, gnutls_x509_crt_fmt_t FORMAT, void * OUTPUT_DATA, size_t * OUTPUT_DATA_SIZE) CRQ: should contain a 'gnutls_x509_crq_t' structure FORMAT: the format of output params. One of PEM or DER. OUTPUT_DATA: will contain a certificate request PEM or DER encoded OUTPUT_DATA_SIZE: holds the size of output_data (and will be replaced by the actual size of parameters) This function will export the certificate request to a PEM or DER encoded PKCS10 structure. If the buffer provided is not long enough to hold the output, then 'GNUTLS_E_SHORT_MEMORY_BUFFER' will be returned and * 'output_data_size' will be updated. If the structure is PEM encoded, it will have a header of "BEGIN NEW CERTIFICATE REQUEST". *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crq_export2 ----------------------- -- Function: int gnutls_x509_crq_export2 (gnutls_x509_crq_t CRQ, gnutls_x509_crt_fmt_t FORMAT, gnutls_datum_t * OUT) CRQ: should contain a 'gnutls_x509_crq_t' structure FORMAT: the format of output params. One of PEM or DER. OUT: will contain a certificate request PEM or DER encoded This function will export the certificate request to a PEM or DER encoded PKCS10 structure. The output buffer is allocated using 'gnutls_malloc()' . If the structure is PEM encoded, it will have a header of "BEGIN NEW CERTIFICATE REQUEST". *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. Since 3.1.3 gnutls_x509_crq_get_attribute_by_oid ------------------------------------ -- Function: int gnutls_x509_crq_get_attribute_by_oid (gnutls_x509_crq_t CRQ, const char * OID, int INDX, void * BUF, size_t * BUF_SIZE) CRQ: should contain a 'gnutls_x509_crq_t' structure OID: holds an Object Identifier in null-terminated string INDX: In case multiple same OIDs exist in the attribute list, this specifies which to get, use (0) to get the first one BUF: a pointer to a structure to hold the attribute data (may be 'NULL' ) BUF_SIZE: initially holds the size of 'buf' This function will return the attribute in the certificate request specified by the given Object ID. The attribute will be DER encoded. Attributes in a certificate request is an optional set of data appended to the request. Their interpretation depends on the CA policy. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crq_get_attribute_data ---------------------------------- -- Function: int gnutls_x509_crq_get_attribute_data (gnutls_x509_crq_t CRQ, int INDX, void * DATA, size_t * SIZEOF_DATA) CRQ: should contain a 'gnutls_x509_crq_t' structure INDX: Specifies which attribute number to get. Use (0) to get the first one. DATA: a pointer to a structure to hold the data (may be null) SIZEOF_DATA: initially holds the size of 'oid' This function will return the requested attribute data in the certificate request. The attribute data will be stored as a string in the provided buffer. Use 'gnutls_x509_crq_get_attribute_info()' to extract the OID. Use 'gnutls_x509_crq_get_attribute_by_oid()' instead, if you want to get data indexed by the attribute OID rather than sequence. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code in case of an error. If your have reached the last extension available 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. *Since:* 2.8.0 gnutls_x509_crq_get_attribute_info ---------------------------------- -- Function: int gnutls_x509_crq_get_attribute_info (gnutls_x509_crq_t CRQ, int INDX, void * OID, size_t * SIZEOF_OID) CRQ: should contain a 'gnutls_x509_crq_t' structure INDX: Specifies which attribute number to get. Use (0) to get the first one. OID: a pointer to a structure to hold the OID SIZEOF_OID: initially holds the maximum size of 'oid' , on return holds actual size of 'oid' . This function will return the requested attribute OID in the certificate, and the critical flag for it. The attribute OID will be stored as a string in the provided buffer. Use 'gnutls_x509_crq_get_attribute_data()' to extract the data. If the buffer provided is not long enough to hold the output, then * 'sizeof_oid' is updated and 'GNUTLS_E_SHORT_MEMORY_BUFFER' will be returned. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code in case of an error. If your have reached the last extension available 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. *Since:* 2.8.0 gnutls_x509_crq_get_basic_constraints ------------------------------------- -- Function: int gnutls_x509_crq_get_basic_constraints (gnutls_x509_crq_t CRQ, unsigned int * CRITICAL, unsigned int * CA, int * PATHLEN) CRQ: should contain a 'gnutls_x509_crq_t' structure CRITICAL: will be non-zero if the extension is marked as critical CA: pointer to output integer indicating CA status, may be NULL, value is 1 if the certificate CA flag is set, 0 otherwise. PATHLEN: pointer to output integer indicating path length (may be NULL), non-negative error codes indicate a present pathLenConstraint field and the actual value, -1 indicate that the field is absent. This function will read the certificate's basic constraints, and return the certificates CA status. It reads the basicConstraints X.509 extension (2.5.29.19). *Returns:* If the certificate is a CA a positive value will be returned, or (0) if the certificate does not have CA flag set. A negative error code may be returned in case of errors. If the certificate does not contain the basicConstraints extension 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. *Since:* 2.8.0 gnutls_x509_crq_get_challenge_password -------------------------------------- -- Function: int gnutls_x509_crq_get_challenge_password (gnutls_x509_crq_t CRQ, char * PASS, size_t * PASS_SIZE) CRQ: should contain a 'gnutls_x509_crq_t' structure PASS: will hold a (0)-terminated password string PASS_SIZE: Initially holds the size of 'pass' . This function will return the challenge password in the request. The challenge password is intended to be used for requesting a revocation of the certificate. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crq_get_dn ---------------------- -- Function: int gnutls_x509_crq_get_dn (gnutls_x509_crq_t CRQ, char * BUF, size_t * BUF_SIZE) CRQ: should contain a 'gnutls_x509_crq_t' structure BUF: a pointer to a structure to hold the name (may be 'NULL' ) BUF_SIZE: initially holds the size of 'buf' This function will copy the name of the Certificate request subject to the provided buffer. The name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in RFC 2253. The output string 'buf' will be ASCII or UTF-8 encoded, depending on the certificate data. *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' if the provided buffer is not long enough, and in that case the * 'buf_size' will be updated with the required size. On success 0 is returned. gnutls_x509_crq_get_dn2 ----------------------- -- Function: int gnutls_x509_crq_get_dn2 (gnutls_x509_crq_t CRQ, gnutls_datum_t * DN) CRQ: should contain a 'gnutls_x509_crq_t' structure DN: a pointer to a structure to hold the name This function will allocate buffer and copy the name of the Certificate request. The name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in RFC4514. The output string will be ASCII or UTF-8 encoded, depending on the certificate data. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. and a negative error code on error. *Since:* 3.1.10 gnutls_x509_crq_get_dn_by_oid ----------------------------- -- Function: int gnutls_x509_crq_get_dn_by_oid (gnutls_x509_crq_t CRQ, const char * OID, int INDX, unsigned int RAW_FLAG, void * BUF, size_t * BUF_SIZE) CRQ: should contain a gnutls_x509_crq_t structure OID: holds an Object Identifier in a null terminated string INDX: In case multiple same OIDs exist in the RDN, this specifies which to get. Use (0) to get the first one. RAW_FLAG: If non-zero returns the raw DER data of the DN part. BUF: a pointer to a structure to hold the name (may be 'NULL' ) BUF_SIZE: initially holds the size of 'buf' This function will extract the part of the name of the Certificate request subject, specified by the given OID. The output will be encoded as described in RFC2253. The output string will be ASCII or UTF-8 encoded, depending on the certificate data. Some helper macros with popular OIDs can be found in gnutls/x509.h If raw flag is (0), this function will only return known OIDs as text. Other OIDs will be DER encoded, as described in RFC2253 - in hex format with a '\#' prefix. You can check about known OIDs using 'gnutls_x509_dn_oid_known()' . *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' if the provided buffer is not long enough, and in that case the * 'buf_size' will be updated with the required size. On success 0 is returned. gnutls_x509_crq_get_dn_oid -------------------------- -- Function: int gnutls_x509_crq_get_dn_oid (gnutls_x509_crq_t CRQ, int INDX, void * OID, size_t * SIZEOF_OID) CRQ: should contain a gnutls_x509_crq_t structure INDX: Specifies which DN OID to get. Use (0) to get the first one. OID: a pointer to a structure to hold the name (may be 'NULL' ) SIZEOF_OID: initially holds the size of 'oid' This function will extract the requested OID of the name of the certificate request subject, specified by the given index. *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' if the provided buffer is not long enough, and in that case the * 'sizeof_oid' will be updated with the required size. On success 0 is returned. gnutls_x509_crq_get_extension_by_oid ------------------------------------ -- Function: int gnutls_x509_crq_get_extension_by_oid (gnutls_x509_crq_t CRQ, const char * OID, int INDX, void * BUF, size_t * BUF_SIZE, unsigned int * CRITICAL) CRQ: should contain a 'gnutls_x509_crq_t' structure OID: holds an Object Identifier in a null terminated string INDX: In case multiple same OIDs exist in the extensions, this specifies which to get. Use (0) to get the first one. BUF: a pointer to a structure to hold the name (may be null) BUF_SIZE: initially holds the size of 'buf' CRITICAL: will be non-zero if the extension is marked as critical This function will return the extension specified by the OID in the certificate. The extensions will be returned as binary data DER encoded, in the provided buffer. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code in case of an error. If the certificate does not contain the specified extension 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. *Since:* 2.8.0 gnutls_x509_crq_get_extension_by_oid2 ------------------------------------- -- Function: int gnutls_x509_crq_get_extension_by_oid2 (gnutls_x509_crq_t CRQ, const char * OID, int INDX, gnutls_datum_t * OUTPUT, unsigned int * CRITICAL) CRQ: should contain a 'gnutls_x509_crq_t' structure OID: holds an Object Identifier in a null terminated string INDX: In case multiple same OIDs exist in the extensions, this specifies which to get. Use (0) to get the first one. OUTPUT: will hold the allocated extension data CRITICAL: will be non-zero if the extension is marked as critical This function will return the extension specified by the OID in the certificate. The extensions will be returned as binary data DER encoded, in the provided buffer. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code in case of an error. If the certificate does not contain the specified extension 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. *Since:* 3.3.8 gnutls_x509_crq_get_extension_data ---------------------------------- -- Function: int gnutls_x509_crq_get_extension_data (gnutls_x509_crq_t CRQ, int INDX, void * DATA, size_t * SIZEOF_DATA) CRQ: should contain a 'gnutls_x509_crq_t' structure INDX: Specifies which extension number to get. Use (0) to get the first one. DATA: a pointer to a structure to hold the data (may be null) SIZEOF_DATA: initially holds the size of 'oid' This function will return the requested extension data in the certificate. The extension data will be stored as a string in the provided buffer. Use 'gnutls_x509_crq_get_extension_info()' to extract the OID and critical flag. Use 'gnutls_x509_crq_get_extension_by_oid()' instead, if you want to get data indexed by the extension OID rather than sequence. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code in case of an error. If your have reached the last extension available 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. *Since:* 2.8.0 gnutls_x509_crq_get_extension_data2 ----------------------------------- -- Function: int gnutls_x509_crq_get_extension_data2 (gnutls_x509_crq_t CRQ, unsigned INDX, gnutls_datum_t * DATA) CRQ: should contain a 'gnutls_x509_crq_t' structure INDX: Specifies which extension OID to read. Use (0) to get the first one. DATA: will contain the extension DER-encoded data This function will return the requested extension data in the certificate request. The extension data will be allocated using 'gnutls_malloc()' . Use 'gnutls_x509_crq_get_extension_info()' to extract the OID. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. If you have reached the last extension available 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. *Since:* 3.3.0 gnutls_x509_crq_get_extension_info ---------------------------------- -- Function: int gnutls_x509_crq_get_extension_info (gnutls_x509_crq_t CRQ, int INDX, void * OID, size_t * SIZEOF_OID, unsigned int * CRITICAL) CRQ: should contain a 'gnutls_x509_crq_t' structure INDX: Specifies which extension number to get. Use (0) to get the first one. OID: a pointer to a structure to hold the OID SIZEOF_OID: initially holds the maximum size of 'oid' , on return holds actual size of 'oid' . CRITICAL: output variable with critical flag, may be NULL. This function will return the requested extension OID in the certificate, and the critical flag for it. The extension OID will be stored as a string in the provided buffer. Use 'gnutls_x509_crq_get_extension_data()' to extract the data. If the buffer provided is not long enough to hold the output, then * 'sizeof_oid' is updated and 'GNUTLS_E_SHORT_MEMORY_BUFFER' will be returned. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code in case of an error. If your have reached the last extension available 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. *Since:* 2.8.0 gnutls_x509_crq_get_key_id -------------------------- -- Function: int gnutls_x509_crq_get_key_id (gnutls_x509_crq_t CRQ, unsigned int FLAGS, unsigned char * OUTPUT_DATA, size_t * OUTPUT_DATA_SIZE) CRQ: a certificate of type 'gnutls_x509_crq_t' FLAGS: should be 0 for now OUTPUT_DATA: will contain the key ID OUTPUT_DATA_SIZE: holds the size of output_data (and will be replaced by the actual size of parameters) This function will return a unique ID that depends on the public key parameters. This ID can be used in checking whether a certificate corresponds to the given private key. If the buffer provided is not long enough to hold the output, then * 'output_data_size' is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will be returned. The output will normally be a SHA-1 hash output, which is 20 bytes. *Returns:* In case of failure a negative error code will be returned, and 0 on success. *Since:* 2.8.0 gnutls_x509_crq_get_key_purpose_oid ----------------------------------- -- Function: int gnutls_x509_crq_get_key_purpose_oid (gnutls_x509_crq_t CRQ, int INDX, void * OID, size_t * SIZEOF_OID, unsigned int * CRITICAL) CRQ: should contain a 'gnutls_x509_crq_t' structure INDX: This specifies which OID to return, use (0) to get the first one OID: a pointer to a buffer to hold the OID (may be 'NULL' ) SIZEOF_OID: initially holds the size of 'oid' CRITICAL: output variable with critical flag, may be 'NULL' . This function will extract the key purpose OIDs of the Certificate specified by the given index. These are stored in the Extended Key Usage extension (2.5.29.37). See the GNUTLS_KP_* definitions for human readable names. *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' if the provided buffer is not long enough, and in that case the * 'sizeof_oid' will be updated with the required size. On success 0 is returned. *Since:* 2.8.0 gnutls_x509_crq_get_key_rsa_raw ------------------------------- -- Function: int gnutls_x509_crq_get_key_rsa_raw (gnutls_x509_crq_t CRQ, gnutls_datum_t * M, gnutls_datum_t * E) CRQ: Holds the certificate M: will hold the modulus E: will hold the public exponent This function will export the RSA public key's parameters found in the given structure. The new parameters will be allocated using 'gnutls_malloc()' and will be stored in the appropriate datum. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 2.8.0 gnutls_x509_crq_get_key_usage ----------------------------- -- Function: int gnutls_x509_crq_get_key_usage (gnutls_x509_crq_t CRQ, unsigned int * KEY_USAGE, unsigned int * CRITICAL) CRQ: should contain a 'gnutls_x509_crq_t' structure KEY_USAGE: where the key usage bits will be stored CRITICAL: will be non-zero if the extension is marked as critical This function will return certificate's key usage, by reading the keyUsage X.509 extension (2.5.29.15). The key usage value will ORed values of the: 'GNUTLS_KEY_DIGITAL_SIGNATURE' , 'GNUTLS_KEY_NON_REPUDIATION' , 'GNUTLS_KEY_KEY_ENCIPHERMENT' , 'GNUTLS_KEY_DATA_ENCIPHERMENT' , 'GNUTLS_KEY_KEY_AGREEMENT' , 'GNUTLS_KEY_KEY_CERT_SIGN' , 'GNUTLS_KEY_CRL_SIGN' , 'GNUTLS_KEY_ENCIPHER_ONLY' , 'GNUTLS_KEY_DECIPHER_ONLY' . *Returns:* the certificate key usage, or a negative error code in case of parsing error. If the certificate does not contain the keyUsage extension 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. *Since:* 2.8.0 gnutls_x509_crq_get_pk_algorithm -------------------------------- -- Function: int gnutls_x509_crq_get_pk_algorithm (gnutls_x509_crq_t CRQ, unsigned int * BITS) CRQ: should contain a 'gnutls_x509_crq_t' structure BITS: if bits is non-'NULL' it will hold the size of the parameters' in bits This function will return the public key algorithm of a PKCS'10' certificate request. If bits is non-'NULL' , it should have enough size to hold the parameters size in bits. For RSA the bits returned is the modulus. For DSA the bits returned are of the public exponent. *Returns:* a member of the 'gnutls_pk_algorithm_t' enumeration on success, or a negative error code on error. gnutls_x509_crq_get_private_key_usage_period -------------------------------------------- -- Function: int gnutls_x509_crq_get_private_key_usage_period (gnutls_x509_crq_t CRQ, time_t * ACTIVATION, time_t * EXPIRATION, unsigned int * CRITICAL) CRQ: should contain a 'gnutls_x509_crq_t' structure ACTIVATION: The activation time EXPIRATION: The expiration time CRITICAL: the extension status This function will return the expiration and activation times of the private key of the certificate. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if the extension is not present, otherwise a negative error value. gnutls_x509_crq_get_subject_alt_name ------------------------------------ -- Function: int gnutls_x509_crq_get_subject_alt_name (gnutls_x509_crq_t CRQ, unsigned int SEQ, void * RET, size_t * RET_SIZE, unsigned int * RET_TYPE, unsigned int * CRITICAL) CRQ: should contain a 'gnutls_x509_crq_t' structure SEQ: specifies the sequence number of the alt name, 0 for the first one, 1 for the second etc. RET: is the place where the alternative name will be copied to RET_SIZE: holds the size of ret. RET_TYPE: holds the 'gnutls_x509_subject_alt_name_t' name type CRITICAL: will be non-zero if the extension is marked as critical (may be null) This function will return the alternative names, contained in the given certificate. It is the same as 'gnutls_x509_crq_get_subject_alt_name()' except for the fact that it will return the type of the alternative name in 'ret_type' even if the function fails for some reason (i.e. the buffer provided is not enough). *Returns:* the alternative subject name type on success, one of the enumerated 'gnutls_x509_subject_alt_name_t' . It will return 'GNUTLS_E_SHORT_MEMORY_BUFFER' if 'ret_size' is not large enough to hold the value. In that case 'ret_size' will be updated with the required size. If the certificate request does not have an Alternative name with the specified sequence number then 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' is returned. *Since:* 2.8.0 gnutls_x509_crq_get_subject_alt_othername_oid --------------------------------------------- -- Function: int gnutls_x509_crq_get_subject_alt_othername_oid (gnutls_x509_crq_t CRQ, unsigned int SEQ, void * RET, size_t * RET_SIZE) CRQ: should contain a 'gnutls_x509_crq_t' structure SEQ: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) RET: is the place where the otherName OID will be copied to RET_SIZE: holds the size of ret. This function will extract the type OID of an otherName Subject Alternative Name, contained in the given certificate, and return the type as an enumerated element. This function is only useful if 'gnutls_x509_crq_get_subject_alt_name()' returned 'GNUTLS_SAN_OTHERNAME' . *Returns:* the alternative subject name type on success, one of the enumerated gnutls_x509_subject_alt_name_t. For supported OIDs, it will return one of the virtual (GNUTLS_SAN_OTHERNAME_*) types, e.g. 'GNUTLS_SAN_OTHERNAME_XMPP' , and 'GNUTLS_SAN_OTHERNAME' for unknown OIDs. It will return 'GNUTLS_E_SHORT_MEMORY_BUFFER' if 'ret_size' is not large enough to hold the value. In that case 'ret_size' will be updated with the required size. If the certificate does not have an Alternative name with the specified sequence number and with the otherName type then 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' is returned. *Since:* 2.8.0 gnutls_x509_crq_get_version --------------------------- -- Function: int gnutls_x509_crq_get_version (gnutls_x509_crq_t CRQ) CRQ: should contain a 'gnutls_x509_crq_t' structure This function will return the version of the specified Certificate request. *Returns:* version of certificate request, or a negative error code on error. gnutls_x509_crq_import ---------------------- -- Function: int gnutls_x509_crq_import (gnutls_x509_crq_t CRQ, const gnutls_datum_t * DATA, gnutls_x509_crt_fmt_t FORMAT) CRQ: The structure to store the parsed certificate request. DATA: The DER or PEM encoded certificate. FORMAT: One of DER or PEM This function will convert the given DER or PEM encoded certificate request to a 'gnutls_x509_crq_t' structure. The output will be stored in 'crq' . If the Certificate is PEM encoded it should have a header of "NEW CERTIFICATE REQUEST". *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crq_init -------------------- -- Function: int gnutls_x509_crq_init (gnutls_x509_crq_t * CRQ) CRQ: The structure to be initialized This function will initialize a PKCS'10' certificate request structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crq_print --------------------- -- Function: int gnutls_x509_crq_print (gnutls_x509_crq_t CRQ, gnutls_certificate_print_formats_t FORMAT, gnutls_datum_t * OUT) CRQ: The structure to be printed FORMAT: Indicate the format to use OUT: Newly allocated datum with null terminated string. This function will pretty print a certificate request, suitable for display to a human. The output 'out' needs to be deallocated using 'gnutls_free()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 2.8.0 gnutls_x509_crq_set_attribute_by_oid ------------------------------------ -- Function: int gnutls_x509_crq_set_attribute_by_oid (gnutls_x509_crq_t CRQ, const char * OID, void * BUF, size_t BUF_SIZE) CRQ: should contain a 'gnutls_x509_crq_t' structure OID: holds an Object Identifier in a null-terminated string BUF: a pointer to a structure that holds the attribute data BUF_SIZE: holds the size of 'buf' This function will set the attribute in the certificate request specified by the given Object ID. The provided attribute must be be DER encoded. Attributes in a certificate request is an optional set of data appended to the request. Their interpretation depends on the CA policy. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crq_set_basic_constraints ------------------------------------- -- Function: int gnutls_x509_crq_set_basic_constraints (gnutls_x509_crq_t CRQ, unsigned int CA, int PATHLENCONSTRAINT) CRQ: a certificate request of type 'gnutls_x509_crq_t' CA: true(1) or false(0) depending on the Certificate authority status. PATHLENCONSTRAINT: non-negative error codes indicate maximum length of path, and negative error codes indicate that the pathLenConstraints field should not be present. This function will set the basicConstraints certificate extension. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 2.8.0 gnutls_x509_crq_set_challenge_password -------------------------------------- -- Function: int gnutls_x509_crq_set_challenge_password (gnutls_x509_crq_t CRQ, const char * PASS) CRQ: should contain a 'gnutls_x509_crq_t' structure PASS: holds a (0)-terminated password This function will set a challenge password to be used when revoking the request. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crq_set_dn ---------------------- -- Function: int gnutls_x509_crq_set_dn (gnutls_x509_crq_t CRQ, const char * DN, const char ** ERR) CRQ: a certificate of type 'gnutls_x509_crq_t' DN: a comma separated DN string (RFC4514) ERR: indicates the error position (if any) This function will set the DN on the provided certificate. The input string should be plain ASCII or UTF-8 encoded. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crq_set_dn_by_oid ----------------------------- -- Function: int gnutls_x509_crq_set_dn_by_oid (gnutls_x509_crq_t CRQ, const char * OID, unsigned int RAW_FLAG, const void * DATA, unsigned int SIZEOF_DATA) CRQ: should contain a 'gnutls_x509_crq_t' structure OID: holds an Object Identifier in a (0)-terminated string RAW_FLAG: must be 0, or 1 if the data are DER encoded DATA: a pointer to the input data SIZEOF_DATA: holds the size of 'data' This function will set the part of the name of the Certificate request subject, specified by the given OID. The input string should be ASCII or UTF-8 encoded. Some helper macros with popular OIDs can be found in gnutls/x509.h With this function you can only set the known OIDs. You can test for known OIDs using 'gnutls_x509_dn_oid_known()' . For OIDs that are not known (by gnutls) you should properly DER encode your data, and call this function with raw_flag set. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crq_set_key ----------------------- -- Function: int gnutls_x509_crq_set_key (gnutls_x509_crq_t CRQ, gnutls_x509_privkey_t KEY) CRQ: should contain a 'gnutls_x509_crq_t' structure KEY: holds a private key This function will set the public parameters from the given private key to the request. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crq_set_key_purpose_oid ----------------------------------- -- Function: int gnutls_x509_crq_set_key_purpose_oid (gnutls_x509_crq_t CRQ, const void * OID, unsigned int CRITICAL) CRQ: a certificate of type 'gnutls_x509_crq_t' OID: a pointer to a (0)-terminated string that holds the OID CRITICAL: Whether this extension will be critical or not This function will set the key purpose OIDs of the Certificate. These are stored in the Extended Key Usage extension (2.5.29.37) See the GNUTLS_KP_* definitions for human readable names. Subsequent calls to this function will append OIDs to the OID list. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 2.8.0 gnutls_x509_crq_set_key_rsa_raw ------------------------------- -- Function: int gnutls_x509_crq_set_key_rsa_raw (gnutls_x509_crq_t CRQ, const gnutls_datum_t * M, const gnutls_datum_t * E) CRQ: should contain a 'gnutls_x509_crq_t' structure M: holds the modulus E: holds the public exponent This function will set the public parameters from the given private key to the request. Only RSA keys are currently supported. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 2.6.0 gnutls_x509_crq_set_key_usage ----------------------------- -- Function: int gnutls_x509_crq_set_key_usage (gnutls_x509_crq_t CRQ, unsigned int USAGE) CRQ: a certificate request of type 'gnutls_x509_crq_t' USAGE: an ORed sequence of the GNUTLS_KEY_* elements. This function will set the keyUsage certificate extension. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 2.8.0 gnutls_x509_crq_set_private_key_usage_period -------------------------------------------- -- Function: int gnutls_x509_crq_set_private_key_usage_period (gnutls_x509_crq_t CRQ, time_t ACTIVATION, time_t EXPIRATION) CRQ: a certificate of type 'gnutls_x509_crq_t' ACTIVATION: The activation time EXPIRATION: The expiration time This function will set the private key usage period extension (2.5.29.16). *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crq_set_subject_alt_name ------------------------------------ -- Function: int gnutls_x509_crq_set_subject_alt_name (gnutls_x509_crq_t CRQ, gnutls_x509_subject_alt_name_t NT, const void * DATA, unsigned int DATA_SIZE, unsigned int FLAGS) CRQ: a certificate request of type 'gnutls_x509_crq_t' NT: is one of the 'gnutls_x509_subject_alt_name_t' enumerations DATA: The data to be set DATA_SIZE: The size of data to be set FLAGS: 'GNUTLS_FSAN_SET' to clear previous data or 'GNUTLS_FSAN_APPEND' to append. This function will set the subject alternative name certificate extension. It can set the following types: *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 2.8.0 gnutls_x509_crq_set_version --------------------------- -- Function: int gnutls_x509_crq_set_version (gnutls_x509_crq_t CRQ, unsigned int VERSION) CRQ: should contain a 'gnutls_x509_crq_t' structure VERSION: holds the version number, for v1 Requests must be 1 This function will set the version of the certificate request. For version 1 requests this must be one. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crq_sign2 --------------------- -- Function: int gnutls_x509_crq_sign2 (gnutls_x509_crq_t CRQ, gnutls_x509_privkey_t KEY, gnutls_digest_algorithm_t DIG, unsigned int FLAGS) CRQ: should contain a 'gnutls_x509_crq_t' structure KEY: holds a private key DIG: The message digest to use, i.e., 'GNUTLS_DIG_SHA1' FLAGS: must be 0 This function will sign the certificate request with a private key. This must be the same key as the one used in 'gnutls_x509_crt_set_key()' since a certificate request is self signed. This must be the last step in a certificate request generation since all the previously set parameters are now signed. *Returns:* 'GNUTLS_E_SUCCESS' on success, otherwise a negative error code. 'GNUTLS_E_ASN1_VALUE_NOT_FOUND' is returned if you didn't set all information in the certificate request (e.g., the version using 'gnutls_x509_crq_set_version()' ). gnutls_x509_crq_verify ---------------------- -- Function: int gnutls_x509_crq_verify (gnutls_x509_crq_t CRQ, unsigned int FLAGS) CRQ: is the crq to be verified FLAGS: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations. This function will verify self signature in the certificate request and return its status. *Returns:* In case of a verification failure 'GNUTLS_E_PK_SIG_VERIFY_FAILED' is returned, and zero or positive code on success. Since 2.12.0 gnutls_x509_crt_check_hostname ------------------------------ -- Function: int gnutls_x509_crt_check_hostname (gnutls_x509_crt_t CERT, const char * HOSTNAME) CERT: should contain an gnutls_x509_crt_t structure HOSTNAME: A null terminated string that contains a DNS name This function will check if the given certificate's subject matches the given hostname. This is a basic implementation of the matching described in RFC6125, and takes into account wildcards, and the DNSName/IPAddress subject alternative name PKIX extension. For details see also 'gnutls_x509_crt_check_hostname2()' . *Returns:* non-zero for a successful match, and zero on failure. gnutls_x509_crt_check_hostname2 ------------------------------- -- Function: int gnutls_x509_crt_check_hostname2 (gnutls_x509_crt_t CERT, const char * HOSTNAME, unsigned int FLAGS) CERT: should contain an gnutls_x509_crt_t structure HOSTNAME: A null terminated string that contains a DNS name FLAGS: gnutls_certificate_verify_flags This function will check if the given certificate's subject matches the given hostname. This is a basic implementation of the matching described in RFC6125, and takes into account wildcards, and the DNSName/IPAddress subject alternative name PKIX extension. IPv4 addresses are accepted by this function in the dotted-decimal format (e.g, ddd.ddd.ddd.ddd), and IPv6 addresses in the hexadecimal x:x:x:x:x:x:x:x format. For them the IPAddress subject alternative name extension is consulted, as well as the DNSNames in case of a non-match. The latter fallback exists due to misconfiguration of many servers which place an IPAddress inside the DNSName extension. The comparison of dns names may have false-negatives as it is done byte by byte in non-ascii names. When the flag 'GNUTLS_VERIFY_DO_NOT_ALLOW_WILDCARDS' is specified no wildcards are considered. Otherwise they are only considered if the domain name consists of three components or more, and the wildcard starts at the leftmost position. *Returns:* non-zero for a successful match, and zero on failure. gnutls_x509_crt_check_issuer ---------------------------- -- Function: int gnutls_x509_crt_check_issuer (gnutls_x509_crt_t CERT, gnutls_x509_crt_t ISSUER) CERT: is the certificate to be checked ISSUER: is the certificate of a possible issuer This function will check if the given certificate was issued by the given issuer. It checks the DN fields and the authority key identifier and subject key identifier fields match. If the same certificate is provided at the 'cert' and 'issuer' fields, it will check whether the certificate is self-signed. *Returns:* It will return true (1) if the given certificate is issued by the given issuer, and false (0) if not. gnutls_x509_crt_check_revocation -------------------------------- -- Function: int gnutls_x509_crt_check_revocation (gnutls_x509_crt_t CERT, const gnutls_x509_crl_t * CRL_LIST, int CRL_LIST_LENGTH) CERT: should contain a 'gnutls_x509_crt_t' structure CRL_LIST: should contain a list of gnutls_x509_crl_t structures CRL_LIST_LENGTH: the length of the crl_list This function will return check if the given certificate is revoked. It is assumed that the CRLs have been verified before. *Returns:* 0 if the certificate is NOT revoked, and 1 if it is. A negative error code is returned on error. gnutls_x509_crt_cpy_crl_dist_points ----------------------------------- -- Function: int gnutls_x509_crt_cpy_crl_dist_points (gnutls_x509_crt_t DST, gnutls_x509_crt_t SRC) DST: a certificate of type 'gnutls_x509_crt_t' SRC: the certificate where the dist points will be copied from This function will copy the CRL distribution points certificate extension, from the source to the destination certificate. This may be useful to copy from a CA certificate to issued ones. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_deinit ---------------------- -- Function: void gnutls_x509_crt_deinit (gnutls_x509_crt_t CERT) CERT: The structure to be deinitialized This function will deinitialize a certificate structure. gnutls_x509_crt_export ---------------------- -- Function: int gnutls_x509_crt_export (gnutls_x509_crt_t CERT, gnutls_x509_crt_fmt_t FORMAT, void * OUTPUT_DATA, size_t * OUTPUT_DATA_SIZE) CERT: Holds the certificate FORMAT: the format of output params. One of PEM or DER. OUTPUT_DATA: will contain a certificate PEM or DER encoded OUTPUT_DATA_SIZE: holds the size of output_data (and will be replaced by the actual size of parameters) This function will export the certificate to DER or PEM format. If the buffer provided is not long enough to hold the output, then *output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will be returned. If the structure is PEM encoded, it will have a header of "BEGIN CERTIFICATE". *Returns:* In case of failure a negative error code will be returned, and 0 on success. gnutls_x509_crt_export2 ----------------------- -- Function: int gnutls_x509_crt_export2 (gnutls_x509_crt_t CERT, gnutls_x509_crt_fmt_t FORMAT, gnutls_datum_t * OUT) CERT: Holds the certificate FORMAT: the format of output params. One of PEM or DER. OUT: will contain a certificate PEM or DER encoded This function will export the certificate to DER or PEM format. The output buffer is allocated using 'gnutls_malloc()' . If the structure is PEM encoded, it will have a header of "BEGIN CERTIFICATE". *Returns:* In case of failure a negative error code will be returned, and 0 on success. *Since:* 3.1.3 gnutls_x509_crt_get_activation_time ----------------------------------- -- Function: time_t gnutls_x509_crt_get_activation_time (gnutls_x509_crt_t CERT) CERT: should contain a 'gnutls_x509_crt_t' structure This function will return the time this Certificate was or will be activated. *Returns:* activation time, or (time_t)-1 on error. gnutls_x509_crt_get_authority_info_access ----------------------------------------- -- Function: int gnutls_x509_crt_get_authority_info_access (gnutls_x509_crt_t CRT, unsigned int SEQ, int WHAT, gnutls_datum_t * DATA, unsigned int * CRITICAL) CRT: Holds the certificate SEQ: specifies the sequence number of the access descriptor (0 for the first one, 1 for the second etc.) WHAT: what data to get, a 'gnutls_info_access_what_t' type. DATA: output data to be freed with 'gnutls_free()' . CRITICAL: pointer to output integer that is set to non-zero if the extension is marked as critical (may be 'NULL' ) Note that a simpler API to access the authority info data is provided by 'gnutls_x509_aia_get()' and 'gnutls_x509_ext_import_aia()' . This function extracts the Authority Information Access (AIA) extension, see RFC 5280 section 4.2.2.1 for more information. The AIA extension holds a sequence of AccessDescription (AD) data. The 'seq' input parameter is used to indicate which member of the sequence the caller is interested in. The first member is 0, the second member 1 and so on. When the 'seq' value is out of bounds, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' is returned. The type of data returned in 'data' is specified via 'what' which should be 'gnutls_info_access_what_t' values. If 'what' is 'GNUTLS_IA_ACCESSMETHOD_OID' then 'data' will hold the accessMethod OID (e.g., "1.3.6.1.5.5.7.48.1"). If 'what' is 'GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE' , 'data' will hold the accessLocation GeneralName type (e.g., "uniformResourceIdentifier"). If 'what' is 'GNUTLS_IA_URI' , 'data' will hold the accessLocation URI data. Requesting this 'what' value leads to an error if the accessLocation is not of the "uniformResourceIdentifier" type. If 'what' is 'GNUTLS_IA_OCSP_URI' , 'data' will hold the OCSP URI. Requesting this 'what' value leads to an error if the accessMethod is not 1.3.6.1.5.5.7.48.1 aka OSCP, or if accessLocation is not of the "uniformResourceIdentifier" type. In that case 'GNUTLS_E_UNKNOWN_ALGORITHM' will be returned, and 'seq' should be increased and this function called again. If 'what' is 'GNUTLS_IA_CAISSUERS_URI' , 'data' will hold the caIssuers URI. Requesting this 'what' value leads to an error if the accessMethod is not 1.3.6.1.5.5.7.48.2 aka caIssuers, or if accessLocation is not of the "uniformResourceIdentifier" type. In that case handle as in 'GNUTLS_IA_OCSP_URI' . More 'what' values may be allocated in the future as needed. If 'data' is NULL, the function does the same without storing the output data, that is, it will set 'critical' and do error checking as usual. The value of the critical flag is returned in * 'critical' . Supply a NULL 'critical' if you want the function to make sure the extension is non-critical, as required by RFC 5280. *Returns:* 'GNUTLS_E_SUCCESS' on success, 'GNUTLS_E_INVALID_REQUEST' on invalid 'crt' , 'GNUTLS_E_CONSTRAINT_ERROR' if the extension is incorrectly marked as critical (use a non-NULL 'critical' to override), 'GNUTLS_E_UNKNOWN_ALGORITHM' if the requested OID does not match (e.g., when using 'GNUTLS_IA_OCSP_URI' ), otherwise a negative error code. *Since:* 3.0 gnutls_x509_crt_get_authority_key_gn_serial ------------------------------------------- -- Function: int gnutls_x509_crt_get_authority_key_gn_serial (gnutls_x509_crt_t CERT, unsigned int SEQ, void * ALT, size_t * ALT_SIZE, unsigned int * ALT_TYPE, void * SERIAL, size_t * SERIAL_SIZE, unsigned int * CRITICAL) CERT: should contain a 'gnutls_x509_crt_t' structure SEQ: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) ALT: is the place where the alternative name will be copied to ALT_SIZE: holds the size of alt. ALT_TYPE: holds the type of the alternative name (one of gnutls_x509_subject_alt_name_t). SERIAL: buffer to store the serial number (may be null) SERIAL_SIZE: Holds the size of the serial field (may be null) CRITICAL: will be non-zero if the extension is marked as critical (may be null) This function will return the X.509 authority key identifier when stored as a general name (authorityCertIssuer) and serial number. Because more than one general names might be stored 'seq' can be used as a counter to request them all until 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' is returned. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if the extension is not present, otherwise a negative error value. *Since:* 3.0 gnutls_x509_crt_get_authority_key_id ------------------------------------ -- Function: int gnutls_x509_crt_get_authority_key_id (gnutls_x509_crt_t CERT, void * ID, size_t * ID_SIZE, unsigned int * CRITICAL) CERT: should contain a 'gnutls_x509_crt_t' structure ID: The place where the identifier will be copied ID_SIZE: Holds the size of the id field. CRITICAL: will be non-zero if the extension is marked as critical (may be null) This function will return the X.509v3 certificate authority's key identifier. This is obtained by the X.509 Authority Key identifier extension field (2.5.29.35). Note that this function only returns the keyIdentifier field of the extension and 'GNUTLS_E_X509_UNSUPPORTED_EXTENSION' , if the extension contains the name and serial number of the certificate. In that case 'gnutls_x509_crt_get_authority_key_gn_serial()' may be used. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if the extension is not present, otherwise a negative error value. gnutls_x509_crt_get_basic_constraints ------------------------------------- -- Function: int gnutls_x509_crt_get_basic_constraints (gnutls_x509_crt_t CERT, unsigned int * CRITICAL, unsigned int * CA, int * PATHLEN) CERT: should contain a 'gnutls_x509_crt_t' structure CRITICAL: will be non-zero if the extension is marked as critical CA: pointer to output integer indicating CA status, may be NULL, value is 1 if the certificate CA flag is set, 0 otherwise. PATHLEN: pointer to output integer indicating path length (may be NULL), non-negative error codes indicate a present pathLenConstraint field and the actual value, -1 indicate that the field is absent. This function will read the certificate's basic constraints, and return the certificates CA status. It reads the basicConstraints X.509 extension (2.5.29.19). *Returns:* If the certificate is a CA a positive value will be returned, or (0) if the certificate does not have CA flag set. A negative error code may be returned in case of errors. If the certificate does not contain the basicConstraints extension GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned. gnutls_x509_crt_get_ca_status ----------------------------- -- Function: int gnutls_x509_crt_get_ca_status (gnutls_x509_crt_t CERT, unsigned int * CRITICAL) CERT: should contain a 'gnutls_x509_crt_t' structure CRITICAL: will be non-zero if the extension is marked as critical This function will return certificates CA status, by reading the basicConstraints X.509 extension (2.5.29.19). If the certificate is a CA a positive value will be returned, or (0) if the certificate does not have CA flag set. Use 'gnutls_x509_crt_get_basic_constraints()' if you want to read the pathLenConstraint field too. *Returns:* If the certificate is a CA a positive value will be returned, or (0) if the certificate does not have CA flag set. A negative error code may be returned in case of errors. If the certificate does not contain the basicConstraints extension GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned. gnutls_x509_crt_get_crl_dist_points ----------------------------------- -- Function: int gnutls_x509_crt_get_crl_dist_points (gnutls_x509_crt_t CERT, unsigned int SEQ, void * SAN, size_t * SAN_SIZE, unsigned int * REASON_FLAGS, unsigned int * CRITICAL) CERT: should contain a 'gnutls_x509_crt_t' structure SEQ: specifies the sequence number of the distribution point (0 for the first one, 1 for the second etc.) SAN: is the place where the distribution point will be copied to SAN_SIZE: holds the size of ret. REASON_FLAGS: Revocation reasons. An ORed sequence of flags from 'gnutls_x509_crl_reason_flags_t' . CRITICAL: will be non-zero if the extension is marked as critical (may be null) This function retrieves the CRL distribution points (2.5.29.31), contained in the given certificate in the X509v3 Certificate Extensions. *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' and updates 'ret_size' if 'ret_size' is not enough to hold the distribution point, or the type of the distribution point if everything was ok. The type is one of the enumerated 'gnutls_x509_subject_alt_name_t' . If the certificate does not have an Alternative name with the specified sequence number then 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' is returned. gnutls_x509_crt_get_dn ---------------------- -- Function: int gnutls_x509_crt_get_dn (gnutls_x509_crt_t CERT, char * BUF, size_t * BUF_SIZE) CERT: should contain a 'gnutls_x509_crt_t' structure BUF: a pointer to a structure to hold the name (may be null) BUF_SIZE: initially holds the size of 'buf' This function will copy the name of the Certificate in the provided buffer. The name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in RFC4514. The output string will be ASCII or UTF-8 encoded, depending on the certificate data. If 'buf' is null then only the size will be filled. *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' if the provided buffer is not long enough, and in that case the 'buf_size' will be updated with the required size. On success 0 is returned. gnutls_x509_crt_get_dn2 ----------------------- -- Function: int gnutls_x509_crt_get_dn2 (gnutls_x509_crt_t CERT, gnutls_datum_t * DN) CERT: should contain a 'gnutls_x509_crt_t' structure DN: a pointer to a structure to hold the name This function will allocate buffer and copy the name of the Certificate. The name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in RFC4514. The output string will be ASCII or UTF-8 encoded, depending on the certificate data. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. and a negative error code on error. *Since:* 3.1.10 gnutls_x509_crt_get_dn_by_oid ----------------------------- -- Function: int gnutls_x509_crt_get_dn_by_oid (gnutls_x509_crt_t CERT, const char * OID, int INDX, unsigned int RAW_FLAG, void * BUF, size_t * BUF_SIZE) CERT: should contain a 'gnutls_x509_crt_t' structure OID: holds an Object Identified in null terminated string INDX: In case multiple same OIDs exist in the RDN, this specifies which to send. Use (0) to get the first one. RAW_FLAG: If non-zero returns the raw DER data of the DN part. BUF: a pointer where the DN part will be copied (may be null). BUF_SIZE: initially holds the size of 'buf' This function will extract the part of the name of the Certificate subject specified by the given OID. The output, if the raw flag is not used, will be encoded as described in RFC4514. Thus a string that is ASCII or UTF-8 encoded, depending on the certificate data. Some helper macros with popular OIDs can be found in gnutls/x509.h If raw flag is (0), this function will only return known OIDs as text. Other OIDs will be DER encoded, as described in RFC4514 - in hex format with a '#' prefix. You can check about known OIDs using 'gnutls_x509_dn_oid_known()' . If 'buf' is null then only the size will be filled. If the 'raw_flag' is not specified the output is always null terminated, although the 'buf_size' will not include the null character. *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' if the provided buffer is not long enough, and in that case the 'buf_size' will be updated with the required size. 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if there are no data in the current index. On success 0 is returned. gnutls_x509_crt_get_dn_oid -------------------------- -- Function: int gnutls_x509_crt_get_dn_oid (gnutls_x509_crt_t CERT, int INDX, void * OID, size_t * OID_SIZE) CERT: should contain a 'gnutls_x509_crt_t' structure INDX: This specifies which OID to return. Use (0) to get the first one. OID: a pointer to a buffer to hold the OID (may be null) OID_SIZE: initially holds the size of 'oid' This function will extract the OIDs of the name of the Certificate subject specified by the given index. If 'oid' is null then only the size will be filled. The 'oid' returned will be null terminated, although 'oid_size' will not account for the trailing null. *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' if the provided buffer is not long enough, and in that case the 'buf_size' will be updated with the required size. 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if there are no data in the current index. On success 0 is returned. gnutls_x509_crt_get_expiration_time ----------------------------------- -- Function: time_t gnutls_x509_crt_get_expiration_time (gnutls_x509_crt_t CERT) CERT: should contain a 'gnutls_x509_crt_t' structure This function will return the time this Certificate was or will be expired. The no well defined expiration time can be checked against with the 'GNUTLS_X509_NO_WELL_DEFINED_EXPIRATION' macro. *Returns:* expiration time, or (time_t)-1 on error. gnutls_x509_crt_get_extension_by_oid ------------------------------------ -- Function: int gnutls_x509_crt_get_extension_by_oid (gnutls_x509_crt_t CERT, const char * OID, int INDX, void * BUF, size_t * BUF_SIZE, unsigned int * CRITICAL) CERT: should contain a 'gnutls_x509_crt_t' structure OID: holds an Object Identified in null terminated string INDX: In case multiple same OIDs exist in the extensions, this specifies which to send. Use (0) to get the first one. BUF: a pointer to a structure to hold the name (may be null) BUF_SIZE: initially holds the size of 'buf' CRITICAL: will be non-zero if the extension is marked as critical This function will return the extension specified by the OID in the certificate. The extensions will be returned as binary data DER encoded, in the provided buffer. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. If the certificate does not contain the specified extension GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned. gnutls_x509_crt_get_extension_by_oid2 ------------------------------------- -- Function: int gnutls_x509_crt_get_extension_by_oid2 (gnutls_x509_crt_t CERT, const char * OID, int INDX, gnutls_datum_t * OUTPUT, unsigned int * CRITICAL) CERT: should contain a 'gnutls_x509_crt_t' structure OID: holds an Object Identified in null terminated string INDX: In case multiple same OIDs exist in the extensions, this specifies which to send. Use (0) to get the first one. OUTPUT: will hold the allocated extension data CRITICAL: will be non-zero if the extension is marked as critical This function will return the extension specified by the OID in the certificate. The extensions will be returned as binary data DER encoded, in the provided buffer. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. If the certificate does not contain the specified extension GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned. *Since:* 3.3.8 gnutls_x509_crt_get_extension_data ---------------------------------- -- Function: int gnutls_x509_crt_get_extension_data (gnutls_x509_crt_t CERT, int INDX, void * DATA, size_t * SIZEOF_DATA) CERT: should contain a 'gnutls_x509_crt_t' structure INDX: Specifies which extension OID to send. Use (0) to get the first one. DATA: a pointer to a structure to hold the data (may be null) SIZEOF_DATA: initially holds the size of 'data' This function will return the requested extension data in the certificate. The extension data will be stored in the provided buffer. Use 'gnutls_x509_crt_get_extension_info()' to extract the OID and critical flag. Use 'gnutls_x509_crt_get_extension_by_oid()' instead, if you want to get data indexed by the extension OID rather than sequence. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. If you have reached the last extension available 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. gnutls_x509_crt_get_extension_data2 ----------------------------------- -- Function: int gnutls_x509_crt_get_extension_data2 (gnutls_x509_crt_t CERT, unsigned INDX, gnutls_datum_t * DATA) CERT: should contain a 'gnutls_x509_crt_t' structure INDX: Specifies which extension OID to read. Use (0) to get the first one. DATA: will contain the extension DER-encoded data This function will return the requested by the index extension data in the certificate. The extension data will be allocated using 'gnutls_malloc()' . Use 'gnutls_x509_crt_get_extension_info()' to extract the OID. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. If you have reached the last extension available 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. gnutls_x509_crt_get_extension_info ---------------------------------- -- Function: int gnutls_x509_crt_get_extension_info (gnutls_x509_crt_t CERT, int INDX, void * OID, size_t * OID_SIZE, unsigned int * CRITICAL) CERT: should contain a 'gnutls_x509_crt_t' structure INDX: Specifies which extension OID to send. Use (0) to get the first one. OID: a pointer to a structure to hold the OID OID_SIZE: initially holds the maximum size of 'oid' , on return holds actual size of 'oid' . CRITICAL: output variable with critical flag, may be NULL. This function will return the requested extension OID in the certificate, and the critical flag for it. The extension OID will be stored as a string in the provided buffer. Use 'gnutls_x509_crt_get_extension()' to extract the data. If the buffer provided is not long enough to hold the output, then 'oid_size' is updated and 'GNUTLS_E_SHORT_MEMORY_BUFFER' will be returned. The 'oid' returned will be null terminated, although 'oid_size' will not account for the trailing null. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. If you have reached the last extension available 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. gnutls_x509_crt_get_extension_oid --------------------------------- -- Function: int gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t CERT, int INDX, void * OID, size_t * OID_SIZE) CERT: should contain a 'gnutls_x509_crt_t' structure INDX: Specifies which extension OID to send. Use (0) to get the first one. OID: a pointer to a structure to hold the OID (may be null) OID_SIZE: initially holds the size of 'oid' This function will return the requested extension OID in the certificate. The extension OID will be stored as a string in the provided buffer. The 'oid' returned will be null terminated, although 'oid_size' will not account for the trailing null. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. If you have reached the last extension available 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. gnutls_x509_crt_get_fingerprint ------------------------------- -- Function: int gnutls_x509_crt_get_fingerprint (gnutls_x509_crt_t CERT, gnutls_digest_algorithm_t ALGO, void * BUF, size_t * BUF_SIZE) CERT: should contain a 'gnutls_x509_crt_t' structure ALGO: is a digest algorithm BUF: a pointer to a structure to hold the fingerprint (may be null) BUF_SIZE: initially holds the size of 'buf' This function will calculate and copy the certificate's fingerprint in the provided buffer. The fingerprint is a hash of the DER-encoded data of the certificate. If the buffer is null then only the size will be filled. *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' if the provided buffer is not long enough, and in that case the *buf_size will be updated with the required size. On success 0 is returned. gnutls_x509_crt_get_issuer -------------------------- -- Function: int gnutls_x509_crt_get_issuer (gnutls_x509_crt_t CERT, gnutls_x509_dn_t * DN) CERT: should contain a 'gnutls_x509_crt_t' structure DN: output variable with pointer to uint8_t DN Return the Certificate's Issuer DN as a 'gnutls_x509_dn_t' data type, that can be decoded using 'gnutls_x509_dn_get_rdn_ava()' . Note that 'dn' should be treated as constant. Because it points into the 'cert' object, you should not use 'dn' after 'cert' is deallocated. *Returns:* Returns 0 on success, or an error code. gnutls_x509_crt_get_issuer_alt_name ----------------------------------- -- Function: int gnutls_x509_crt_get_issuer_alt_name (gnutls_x509_crt_t CERT, unsigned int SEQ, void * IAN, size_t * IAN_SIZE, unsigned int * CRITICAL) CERT: should contain a 'gnutls_x509_crt_t' structure SEQ: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) IAN: is the place where the alternative name will be copied to IAN_SIZE: holds the size of ian. CRITICAL: will be non-zero if the extension is marked as critical (may be null) This function retrieves the Issuer Alternative Name (2.5.29.18), contained in the given certificate in the X509v3 Certificate Extensions. When the SAN type is otherName, it will extract the data in the otherName's value field, and 'GNUTLS_SAN_OTHERNAME' is returned. You may use 'gnutls_x509_crt_get_subject_alt_othername_oid()' to get the corresponding OID and the "virtual" SAN types (e.g., 'GNUTLS_SAN_OTHERNAME_XMPP' ). If an otherName OID is known, the data will be decoded. Otherwise the returned data will be DER encoded, and you will have to decode it yourself. Currently, only the RFC 3920 id-on-xmppAddr Issuer AltName is recognized. *Returns:* the alternative issuer name type on success, one of the enumerated 'gnutls_x509_subject_alt_name_t' . It will return 'GNUTLS_E_SHORT_MEMORY_BUFFER' if 'ian_size' is not large enough to hold the value. In that case 'ian_size' will be updated with the required size. If the certificate does not have an Alternative name with the specified sequence number then 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' is returned. *Since:* 2.10.0 gnutls_x509_crt_get_issuer_alt_name2 ------------------------------------ -- Function: int gnutls_x509_crt_get_issuer_alt_name2 (gnutls_x509_crt_t CERT, unsigned int SEQ, void * IAN, size_t * IAN_SIZE, unsigned int * IAN_TYPE, unsigned int * CRITICAL) CERT: should contain a 'gnutls_x509_crt_t' structure SEQ: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) IAN: is the place where the alternative name will be copied to IAN_SIZE: holds the size of ret. IAN_TYPE: holds the type of the alternative name (one of gnutls_x509_subject_alt_name_t). CRITICAL: will be non-zero if the extension is marked as critical (may be null) This function will return the alternative names, contained in the given certificate. It is the same as 'gnutls_x509_crt_get_issuer_alt_name()' except for the fact that it will return the type of the alternative name in 'ian_type' even if the function fails for some reason (i.e. the buffer provided is not enough). *Returns:* the alternative issuer name type on success, one of the enumerated 'gnutls_x509_subject_alt_name_t' . It will return 'GNUTLS_E_SHORT_MEMORY_BUFFER' if 'ian_size' is not large enough to hold the value. In that case 'ian_size' will be updated with the required size. If the certificate does not have an Alternative name with the specified sequence number then 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' is returned. *Since:* 2.10.0 gnutls_x509_crt_get_issuer_alt_othername_oid -------------------------------------------- -- Function: int gnutls_x509_crt_get_issuer_alt_othername_oid (gnutls_x509_crt_t CERT, unsigned int SEQ, void * RET, size_t * RET_SIZE) CERT: should contain a 'gnutls_x509_crt_t' structure SEQ: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) RET: is the place where the otherName OID will be copied to RET_SIZE: holds the size of ret. This function will extract the type OID of an otherName Subject Alternative Name, contained in the given certificate, and return the type as an enumerated element. If 'oid' is null then only the size will be filled. The 'oid' returned will be null terminated, although 'oid_size' will not account for the trailing null. This function is only useful if 'gnutls_x509_crt_get_issuer_alt_name()' returned 'GNUTLS_SAN_OTHERNAME' . *Returns:* the alternative issuer name type on success, one of the enumerated gnutls_x509_subject_alt_name_t. For supported OIDs, it will return one of the virtual (GNUTLS_SAN_OTHERNAME_*) types, e.g. 'GNUTLS_SAN_OTHERNAME_XMPP' , and 'GNUTLS_SAN_OTHERNAME' for unknown OIDs. It will return 'GNUTLS_E_SHORT_MEMORY_BUFFER' if 'ret_size' is not large enough to hold the value. In that case 'ret_size' will be updated with the required size. If the certificate does not have an Alternative name with the specified sequence number and with the otherName type then 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' is returned. *Since:* 2.10.0 gnutls_x509_crt_get_issuer_dn ----------------------------- -- Function: int gnutls_x509_crt_get_issuer_dn (gnutls_x509_crt_t CERT, char * BUF, size_t * BUF_SIZE) CERT: should contain a 'gnutls_x509_crt_t' structure BUF: a pointer to a structure to hold the name (may be null) BUF_SIZE: initially holds the size of 'buf' This function will copy the name of the Certificate issuer in the provided buffer. The name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in RFC4514. The output string will be ASCII or UTF-8 encoded, depending on the certificate data. If 'buf' is null then only the size will be filled. *Returns:* GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not long enough, and in that case the 'buf_size' will be updated with the required size. On success 0 is returned. gnutls_x509_crt_get_issuer_dn2 ------------------------------ -- Function: int gnutls_x509_crt_get_issuer_dn2 (gnutls_x509_crt_t CERT, gnutls_datum_t * DN) CERT: should contain a 'gnutls_x509_crt_t' structure DN: a pointer to a structure to hold the name This function will allocate buffer and copy the name of issuer of the Certificate. The name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in RFC4514. The output string will be ASCII or UTF-8 encoded, depending on the certificate data. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. and a negative error code on error. *Since:* 3.1.10 gnutls_x509_crt_get_issuer_dn_by_oid ------------------------------------ -- Function: int gnutls_x509_crt_get_issuer_dn_by_oid (gnutls_x509_crt_t CERT, const char * OID, int INDX, unsigned int RAW_FLAG, void * BUF, size_t * BUF_SIZE) CERT: should contain a 'gnutls_x509_crt_t' structure OID: holds an Object Identified in null terminated string INDX: In case multiple same OIDs exist in the RDN, this specifies which to send. Use (0) to get the first one. RAW_FLAG: If non-zero returns the raw DER data of the DN part. BUF: a pointer to a structure to hold the name (may be null) BUF_SIZE: initially holds the size of 'buf' This function will extract the part of the name of the Certificate issuer specified by the given OID. The output, if the raw flag is not used, will be encoded as described in RFC4514. Thus a string that is ASCII or UTF-8 encoded, depending on the certificate data. Some helper macros with popular OIDs can be found in gnutls/x509.h If raw flag is (0), this function will only return known OIDs as text. Other OIDs will be DER encoded, as described in RFC4514 - in hex format with a '#' prefix. You can check about known OIDs using 'gnutls_x509_dn_oid_known()' . If 'buf' is null then only the size will be filled. If the 'raw_flag' is not specified the output is always null terminated, although the 'buf_size' will not include the null character. *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' if the provided buffer is not long enough, and in that case the 'buf_size' will be updated with the required size. 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if there are no data in the current index. On success 0 is returned. gnutls_x509_crt_get_issuer_dn_oid --------------------------------- -- Function: int gnutls_x509_crt_get_issuer_dn_oid (gnutls_x509_crt_t CERT, int INDX, void * OID, size_t * OID_SIZE) CERT: should contain a 'gnutls_x509_crt_t' structure INDX: This specifies which OID to return. Use (0) to get the first one. OID: a pointer to a buffer to hold the OID (may be null) OID_SIZE: initially holds the size of 'oid' This function will extract the OIDs of the name of the Certificate issuer specified by the given index. If 'oid' is null then only the size will be filled. The 'oid' returned will be null terminated, although 'oid_size' will not account for the trailing null. *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' if the provided buffer is not long enough, and in that case the 'buf_size' will be updated with the required size. 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if there are no data in the current index. On success 0 is returned. gnutls_x509_crt_get_issuer_unique_id ------------------------------------ -- Function: int gnutls_x509_crt_get_issuer_unique_id (gnutls_x509_crt_t CRT, char * BUF, size_t * BUF_SIZE) CRT: Holds the certificate BUF: user allocated memory buffer, will hold the unique id BUF_SIZE: size of user allocated memory buffer (on input), will hold actual size of the unique ID on return. This function will extract the issuerUniqueID value (if present) for the given certificate. If the user allocated memory buffer is not large enough to hold the full subjectUniqueID, then a GNUTLS_E_SHORT_MEMORY_BUFFER error will be returned, and buf_size will be set to the actual length. *Returns:* 'GNUTLS_E_SUCCESS' on success, otherwise a negative error code. *Since:* 2.12.0 gnutls_x509_crt_get_key_id -------------------------- -- Function: int gnutls_x509_crt_get_key_id (gnutls_x509_crt_t CRT, unsigned int FLAGS, unsigned char * OUTPUT_DATA, size_t * OUTPUT_DATA_SIZE) CRT: Holds the certificate FLAGS: should be 0 for now OUTPUT_DATA: will contain the key ID OUTPUT_DATA_SIZE: holds the size of output_data (and will be replaced by the actual size of parameters) This function will return a unique ID that depends on the public key parameters. This ID can be used in checking whether a certificate corresponds to the given private key. If the buffer provided is not long enough to hold the output, then *output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will be returned. The output will normally be a SHA-1 hash output, which is 20 bytes. *Returns:* In case of failure a negative error code will be returned, and 0 on success. gnutls_x509_crt_get_key_purpose_oid ----------------------------------- -- Function: int gnutls_x509_crt_get_key_purpose_oid (gnutls_x509_crt_t CERT, int INDX, void * OID, size_t * OID_SIZE, unsigned int * CRITICAL) CERT: should contain a 'gnutls_x509_crt_t' structure INDX: This specifies which OID to return. Use (0) to get the first one. OID: a pointer to a buffer to hold the OID (may be null) OID_SIZE: initially holds the size of 'oid' CRITICAL: output flag to indicate criticality of extension This function will extract the key purpose OIDs of the Certificate specified by the given index. These are stored in the Extended Key Usage extension (2.5.29.37) See the GNUTLS_KP_* definitions for human readable names. If 'oid' is null then only the size will be filled. The 'oid' returned will be null terminated, although 'oid_size' will not account for the trailing null. *Returns:* 'GNUTLS_E_SHORT_MEMORY_BUFFER' if the provided buffer is not long enough, and in that case the *oid_size will be updated with the required size. On success 0 is returned. gnutls_x509_crt_get_key_usage ----------------------------- -- Function: int gnutls_x509_crt_get_key_usage (gnutls_x509_crt_t CERT, unsigned int * KEY_USAGE, unsigned int * CRITICAL) CERT: should contain a 'gnutls_x509_crt_t' structure KEY_USAGE: where the key usage bits will be stored CRITICAL: will be non-zero if the extension is marked as critical This function will return certificate's key usage, by reading the keyUsage X.509 extension (2.5.29.15). The key usage value will ORed values of the: 'GNUTLS_KEY_DIGITAL_SIGNATURE' , 'GNUTLS_KEY_NON_REPUDIATION' , 'GNUTLS_KEY_KEY_ENCIPHERMENT' , 'GNUTLS_KEY_DATA_ENCIPHERMENT' , 'GNUTLS_KEY_KEY_AGREEMENT' , 'GNUTLS_KEY_KEY_CERT_SIGN' , 'GNUTLS_KEY_CRL_SIGN' , 'GNUTLS_KEY_ENCIPHER_ONLY' , 'GNUTLS_KEY_DECIPHER_ONLY' . *Returns:* the certificate key usage, or a negative error code in case of parsing error. If the certificate does not contain the keyUsage extension 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. gnutls_x509_crt_get_name_constraints ------------------------------------ -- Function: int gnutls_x509_crt_get_name_constraints (gnutls_x509_crt_t CRT, gnutls_x509_name_constraints_t NC, unsigned int FLAGS, unsigned int * CRITICAL) CRT: should contain a 'gnutls_x509_crt_t' structure NC: The nameconstraints intermediate structure FLAGS: zero or 'GNUTLS_NAME_CONSTRAINTS_FLAG_APPEND' CRITICAL: the extension status This function will return an intermediate structure containing the name constraints of the provided CA certificate. That structure can be used in combination with 'gnutls_x509_name_constraints_check()' to verify whether a server's name is in accordance with the constraints. When the 'flags' is set to 'GNUTLS_NAME_CONSTRAINTS_FLAG_APPEND' , then if the 'nc' structure is empty this function will behave identically as if the flag was not set. Otherwise if there are elements in the 'nc' structure then only the excluded constraints will be appended to the constraints. Note that 'nc' must be initialized prior to calling this function. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if the extension is not present, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_crt_get_pk_algorithm -------------------------------- -- Function: int gnutls_x509_crt_get_pk_algorithm (gnutls_x509_crt_t CERT, unsigned int * BITS) CERT: should contain a 'gnutls_x509_crt_t' structure BITS: if bits is non null it will hold the size of the parameters' in bits This function will return the public key algorithm of an X.509 certificate. If bits is non null, it should have enough size to hold the parameters size in bits. For RSA the bits returned is the modulus. For DSA the bits returned are of the public exponent. *Returns:* a member of the 'gnutls_pk_algorithm_t' enumeration on success, or a negative error code on error. gnutls_x509_crt_get_pk_dsa_raw ------------------------------ -- Function: int gnutls_x509_crt_get_pk_dsa_raw (gnutls_x509_crt_t CRT, gnutls_datum_t * P, gnutls_datum_t * Q, gnutls_datum_t * G, gnutls_datum_t * Y) CRT: Holds the certificate P: will hold the p Q: will hold the q G: will hold the g Y: will hold the y This function will export the DSA public key's parameters found in the given certificate. The new parameters will be allocated using 'gnutls_malloc()' and will be stored in the appropriate datum. *Returns:* 'GNUTLS_E_SUCCESS' on success, otherwise a negative error code. gnutls_x509_crt_get_pk_rsa_raw ------------------------------ -- Function: int gnutls_x509_crt_get_pk_rsa_raw (gnutls_x509_crt_t CRT, gnutls_datum_t * M, gnutls_datum_t * E) CRT: Holds the certificate M: will hold the modulus E: will hold the public exponent This function will export the RSA public key's parameters found in the given structure. The new parameters will be allocated using 'gnutls_malloc()' and will be stored in the appropriate datum. *Returns:* 'GNUTLS_E_SUCCESS' on success, otherwise a negative error code. gnutls_x509_crt_get_policy -------------------------- -- Function: int gnutls_x509_crt_get_policy (gnutls_x509_crt_t CRT, int INDX, struct gnutls_x509_policy_st * POLICY, unsigned int * CRITICAL) CRT: should contain a 'gnutls_x509_crt_t' structure INDX: This specifies which policy to return. Use (0) to get the first one. POLICY: A pointer to a policy structure. CRITICAL: will be non-zero if the extension is marked as critical This function will extract the certificate policy (extension 2.5.29.32) specified by the given index. The policy returned by this function must be deinitialized by using 'gnutls_x509_policy_release()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if the extension is not present, otherwise a negative error value. *Since:* 3.1.5 gnutls_x509_crt_get_private_key_usage_period -------------------------------------------- -- Function: int gnutls_x509_crt_get_private_key_usage_period (gnutls_x509_crt_t CERT, time_t * ACTIVATION, time_t * EXPIRATION, unsigned int * CRITICAL) CERT: should contain a 'gnutls_x509_crt_t' structure ACTIVATION: The activation time EXPIRATION: The expiration time CRITICAL: the extension status This function will return the expiration and activation times of the private key of the certificate. It relies on the PKIX extension 2.5.29.16 being present. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if the extension is not present, otherwise a negative error value. gnutls_x509_crt_get_proxy ------------------------- -- Function: int gnutls_x509_crt_get_proxy (gnutls_x509_crt_t CERT, unsigned int * CRITICAL, int * PATHLEN, char ** POLICYLANGUAGE, char ** POLICY, size_t * SIZEOF_POLICY) CERT: should contain a 'gnutls_x509_crt_t' structure CRITICAL: will be non-zero if the extension is marked as critical PATHLEN: pointer to output integer indicating path length (may be NULL), non-negative error codes indicate a present pCPathLenConstraint field and the actual value, -1 indicate that the field is absent. POLICYLANGUAGE: output variable with OID of policy language POLICY: output variable with policy data SIZEOF_POLICY: output variable size of policy data This function will get information from a proxy certificate. It reads the ProxyCertInfo X.509 extension (1.3.6.1.5.5.7.1.14). *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. gnutls_x509_crt_get_raw_dn -------------------------- -- Function: int gnutls_x509_crt_get_raw_dn (gnutls_x509_crt_t CERT, gnutls_datum_t * DN) CERT: should contain a 'gnutls_x509_crt_t' structure DN: will hold the starting point of the DN This function will return a pointer to the DER encoded DN structure and the length. This points to allocated data that must be free'd using 'gnutls_free()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. or a negative error code on error. gnutls_x509_crt_get_raw_issuer_dn --------------------------------- -- Function: int gnutls_x509_crt_get_raw_issuer_dn (gnutls_x509_crt_t CERT, gnutls_datum_t * DN) CERT: should contain a 'gnutls_x509_crt_t' structure DN: will hold the starting point of the DN This function will return a pointer to the DER encoded DN structure and the length. This points to allocated data that must be free'd using 'gnutls_free()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value.or a negative error code on error. gnutls_x509_crt_get_serial -------------------------- -- Function: int gnutls_x509_crt_get_serial (gnutls_x509_crt_t CERT, void * RESULT, size_t * RESULT_SIZE) CERT: should contain a 'gnutls_x509_crt_t' structure RESULT: The place where the serial number will be copied RESULT_SIZE: Holds the size of the result field. This function will return the X.509 certificate's serial number. This is obtained by the X509 Certificate serialNumber field. Serial is not always a 32 or 64bit number. Some CAs use large serial numbers, thus it may be wise to handle it as something uint8_t. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_get_signature ----------------------------- -- Function: int gnutls_x509_crt_get_signature (gnutls_x509_crt_t CERT, char * SIG, size_t * SIG_SIZE) CERT: should contain a 'gnutls_x509_crt_t' structure SIG: a pointer where the signature part will be copied (may be null). SIG_SIZE: initially holds the size of 'sig' This function will extract the signature field of a certificate. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. and a negative error code on error. gnutls_x509_crt_get_signature_algorithm --------------------------------------- -- Function: int gnutls_x509_crt_get_signature_algorithm (gnutls_x509_crt_t CERT) CERT: should contain a 'gnutls_x509_crt_t' structure This function will return a value of the 'gnutls_sign_algorithm_t' enumeration that is the signature algorithm that has been used to sign this certificate. *Returns:* a 'gnutls_sign_algorithm_t' value, or a negative error code on error. gnutls_x509_crt_get_subject --------------------------- -- Function: int gnutls_x509_crt_get_subject (gnutls_x509_crt_t CERT, gnutls_x509_dn_t * DN) CERT: should contain a 'gnutls_x509_crt_t' structure DN: output variable with pointer to uint8_t DN. Return the Certificate's Subject DN as a 'gnutls_x509_dn_t' data type, that can be decoded using 'gnutls_x509_dn_get_rdn_ava()' . Note that 'dn' should be treated as constant. Because it points into the 'cert' object, you should not use 'dn' after 'cert' is deallocated. *Returns:* Returns 0 on success, or an error code. gnutls_x509_crt_get_subject_alt_name ------------------------------------ -- Function: int gnutls_x509_crt_get_subject_alt_name (gnutls_x509_crt_t CERT, unsigned int SEQ, void * SAN, size_t * SAN_SIZE, unsigned int * CRITICAL) CERT: should contain a 'gnutls_x509_crt_t' structure SEQ: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) SAN: is the place where the alternative name will be copied to SAN_SIZE: holds the size of san. CRITICAL: will be non-zero if the extension is marked as critical (may be null) This function retrieves the Alternative Name (2.5.29.17), contained in the given certificate in the X509v3 Certificate Extensions. When the SAN type is otherName, it will extract the data in the otherName's value field, and 'GNUTLS_SAN_OTHERNAME' is returned. You may use 'gnutls_x509_crt_get_subject_alt_othername_oid()' to get the corresponding OID and the "virtual" SAN types (e.g., 'GNUTLS_SAN_OTHERNAME_XMPP' ). If an otherName OID is known, the data will be decoded. Otherwise the returned data will be DER encoded, and you will have to decode it yourself. Currently, only the RFC 3920 id-on-xmppAddr SAN is recognized. *Returns:* the alternative subject name type on success, one of the enumerated 'gnutls_x509_subject_alt_name_t' . It will return 'GNUTLS_E_SHORT_MEMORY_BUFFER' if 'san_size' is not large enough to hold the value. In that case 'san_size' will be updated with the required size. If the certificate does not have an Alternative name with the specified sequence number then 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' is returned. gnutls_x509_crt_get_subject_alt_name2 ------------------------------------- -- Function: int gnutls_x509_crt_get_subject_alt_name2 (gnutls_x509_crt_t CERT, unsigned int SEQ, void * SAN, size_t * SAN_SIZE, unsigned int * SAN_TYPE, unsigned int * CRITICAL) CERT: should contain a 'gnutls_x509_crt_t' structure SEQ: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) SAN: is the place where the alternative name will be copied to SAN_SIZE: holds the size of ret. SAN_TYPE: holds the type of the alternative name (one of gnutls_x509_subject_alt_name_t). CRITICAL: will be non-zero if the extension is marked as critical (may be null) This function will return the alternative names, contained in the given certificate. It is the same as 'gnutls_x509_crt_get_subject_alt_name()' except for the fact that it will return the type of the alternative name in 'san_type' even if the function fails for some reason (i.e. the buffer provided is not enough). *Returns:* the alternative subject name type on success, one of the enumerated 'gnutls_x509_subject_alt_name_t' . It will return 'GNUTLS_E_SHORT_MEMORY_BUFFER' if 'san_size' is not large enough to hold the value. In that case 'san_size' will be updated with the required size. If the certificate does not have an Alternative name with the specified sequence number then 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' is returned. gnutls_x509_crt_get_subject_alt_othername_oid --------------------------------------------- -- Function: int gnutls_x509_crt_get_subject_alt_othername_oid (gnutls_x509_crt_t CERT, unsigned int SEQ, void * OID, size_t * OID_SIZE) CERT: should contain a 'gnutls_x509_crt_t' structure SEQ: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) OID: is the place where the otherName OID will be copied to OID_SIZE: holds the size of ret. This function will extract the type OID of an otherName Subject Alternative Name, contained in the given certificate, and return the type as an enumerated element. This function is only useful if 'gnutls_x509_crt_get_subject_alt_name()' returned 'GNUTLS_SAN_OTHERNAME' . If 'oid' is null then only the size will be filled. The 'oid' returned will be null terminated, although 'oid_size' will not account for the trailing null. *Returns:* the alternative subject name type on success, one of the enumerated gnutls_x509_subject_alt_name_t. For supported OIDs, it will return one of the virtual (GNUTLS_SAN_OTHERNAME_*) types, e.g. 'GNUTLS_SAN_OTHERNAME_XMPP' , and 'GNUTLS_SAN_OTHERNAME' for unknown OIDs. It will return 'GNUTLS_E_SHORT_MEMORY_BUFFER' if 'ian_size' is not large enough to hold the value. In that case 'ian_size' will be updated with the required size. If the certificate does not have an Alternative name with the specified sequence number and with the otherName type then 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' is returned. gnutls_x509_crt_get_subject_key_id ---------------------------------- -- Function: int gnutls_x509_crt_get_subject_key_id (gnutls_x509_crt_t CERT, void * RET, size_t * RET_SIZE, unsigned int * CRITICAL) CERT: should contain a 'gnutls_x509_crt_t' structure RET: The place where the identifier will be copied RET_SIZE: Holds the size of the result field. CRITICAL: will be non-zero if the extension is marked as critical (may be null) This function will return the X.509v3 certificate's subject key identifier. This is obtained by the X.509 Subject Key identifier extension field (2.5.29.14). *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if the extension is not present, otherwise a negative error value. gnutls_x509_crt_get_subject_unique_id ------------------------------------- -- Function: int gnutls_x509_crt_get_subject_unique_id (gnutls_x509_crt_t CRT, char * BUF, size_t * BUF_SIZE) CRT: Holds the certificate BUF: user allocated memory buffer, will hold the unique id BUF_SIZE: size of user allocated memory buffer (on input), will hold actual size of the unique ID on return. This function will extract the subjectUniqueID value (if present) for the given certificate. If the user allocated memory buffer is not large enough to hold the full subjectUniqueID, then a GNUTLS_E_SHORT_MEMORY_BUFFER error will be returned, and buf_size will be set to the actual length. *Returns:* 'GNUTLS_E_SUCCESS' on success, otherwise a negative error code. gnutls_x509_crt_get_version --------------------------- -- Function: int gnutls_x509_crt_get_version (gnutls_x509_crt_t CERT) CERT: should contain a 'gnutls_x509_crt_t' structure This function will return the version of the specified Certificate. *Returns:* version of certificate, or a negative error code on error. gnutls_x509_crt_import ---------------------- -- Function: int gnutls_x509_crt_import (gnutls_x509_crt_t CERT, const gnutls_datum_t * DATA, gnutls_x509_crt_fmt_t FORMAT) CERT: The structure to store the parsed certificate. DATA: The DER or PEM encoded certificate. FORMAT: One of DER or PEM This function will convert the given DER or PEM encoded Certificate to the native gnutls_x509_crt_t format. The output will be stored in 'cert' . If the Certificate is PEM encoded it should have a header of "X509 CERTIFICATE", or "CERTIFICATE". *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_init -------------------- -- Function: int gnutls_x509_crt_init (gnutls_x509_crt_t * CERT) CERT: The structure to be initialized This function will initialize an X.509 certificate structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_list_import --------------------------- -- Function: int gnutls_x509_crt_list_import (gnutls_x509_crt_t * CERTS, unsigned int * CERT_MAX, const gnutls_datum_t * DATA, gnutls_x509_crt_fmt_t FORMAT, unsigned int FLAGS) CERTS: The structures to store the parsed certificate. Must not be initialized. CERT_MAX: Initially must hold the maximum number of certs. It will be updated with the number of certs available. DATA: The PEM encoded certificate. FORMAT: One of DER or PEM. FLAGS: must be (0) or an OR'd sequence of gnutls_certificate_import_flags. This function will convert the given PEM encoded certificate list to the native gnutls_x509_crt_t format. The output will be stored in 'certs' . They will be automatically initialized. The flag 'GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED' will cause import to fail if the certificates in the provided buffer are more than the available structures. The 'GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED' flag will cause the function to fail if the provided list is not sorted from subject to issuer. If the Certificate is PEM encoded it should have a header of "X509 CERTIFICATE", or "CERTIFICATE". *Returns:* the number of certificates read or a negative error value. gnutls_x509_crt_list_import2 ---------------------------- -- Function: int gnutls_x509_crt_list_import2 (gnutls_x509_crt_t ** CERTS, unsigned int * SIZE, const gnutls_datum_t * DATA, gnutls_x509_crt_fmt_t FORMAT, unsigned int FLAGS) CERTS: The structures to store the parsed certificate. Must not be initialized. SIZE: It will contain the size of the list. DATA: The PEM encoded certificate. FORMAT: One of DER or PEM. FLAGS: must be (0) or an OR'd sequence of gnutls_certificate_import_flags. This function will convert the given PEM encoded certificate list to the native gnutls_x509_crt_t format. The output will be stored in 'certs' which will allocated and initialized. If the Certificate is PEM encoded it should have a header of "X509 CERTIFICATE", or "CERTIFICATE". To deinitialize 'certs' , you need to deinitialize each crt structure independently, and use 'gnutls_free()' at *Returns:* the number of certificates read or a negative error value. *Since:* 3.0 gnutls_x509_crt_list_verify --------------------------- -- Function: int gnutls_x509_crt_list_verify (const gnutls_x509_crt_t * CERT_LIST, int CERT_LIST_LENGTH, const gnutls_x509_crt_t * CA_LIST, int CA_LIST_LENGTH, const gnutls_x509_crl_t * CRL_LIST, int CRL_LIST_LENGTH, unsigned int FLAGS, unsigned int * VERIFY) CERT_LIST: is the certificate list to be verified CERT_LIST_LENGTH: holds the number of certificate in cert_list CA_LIST: is the CA list which will be used in verification CA_LIST_LENGTH: holds the number of CA certificate in CA_list CRL_LIST: holds a list of CRLs. CRL_LIST_LENGTH: the length of CRL list. FLAGS: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations. VERIFY: will hold the certificate verification output. This function will try to verify the given certificate list and return its status. If no flags are specified (0), this function will use the basicConstraints (2.5.29.19) PKIX extension. This means that only a certificate authority is allowed to sign a certificate. You must also check the peer's name in order to check if the verified certificate belongs to the actual peer. The certificate verification output will be put in 'verify' and will be one or more of the gnutls_certificate_status_t enumerated elements bitwise or'd. For a more detailed verification status use 'gnutls_x509_crt_verify()' per list element. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_print --------------------- -- Function: int gnutls_x509_crt_print (gnutls_x509_crt_t CERT, gnutls_certificate_print_formats_t FORMAT, gnutls_datum_t * OUT) CERT: The structure to be printed FORMAT: Indicate the format to use OUT: Newly allocated datum with null terminated string. This function will pretty print a X.509 certificate, suitable for display to a human. If the format is 'GNUTLS_CRT_PRINT_FULL' then all fields of the certificate will be output, on multiple lines. The 'GNUTLS_CRT_PRINT_ONELINE' format will generate one line with some selected fields, which is useful for logging purposes. The output 'out' needs to be deallocated using 'gnutls_free()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_activation_time ----------------------------------- -- Function: int gnutls_x509_crt_set_activation_time (gnutls_x509_crt_t CERT, time_t ACT_TIME) CERT: a certificate of type 'gnutls_x509_crt_t' ACT_TIME: The actual time This function will set the time this Certificate was or will be activated. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_authority_info_access ----------------------------------------- -- Function: int gnutls_x509_crt_set_authority_info_access (gnutls_x509_crt_t CRT, int WHAT, gnutls_datum_t * DATA) CRT: Holds the certificate WHAT: what data to get, a 'gnutls_info_access_what_t' type. DATA: output data to be freed with 'gnutls_free()' . This function sets the Authority Information Access (AIA) extension, see RFC 5280 section 4.2.2.1 for more information. The type of data stored in 'data' is specified via 'what' which should be 'gnutls_info_access_what_t' values. If 'what' is 'GNUTLS_IA_OCSP_URI' , 'data' will hold the OCSP URI. If 'what' is 'GNUTLS_IA_CAISSUERS_URI' , 'data' will hold the caIssuers URI. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.0 gnutls_x509_crt_set_authority_key_id ------------------------------------ -- Function: int gnutls_x509_crt_set_authority_key_id (gnutls_x509_crt_t CERT, const void * ID, size_t ID_SIZE) CERT: a certificate of type 'gnutls_x509_crt_t' ID: The key ID ID_SIZE: Holds the size of the key ID field. This function will set the X.509 certificate's authority key ID extension. Only the keyIdentifier field can be set with this function. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_basic_constraints ------------------------------------- -- Function: int gnutls_x509_crt_set_basic_constraints (gnutls_x509_crt_t CRT, unsigned int CA, int PATHLENCONSTRAINT) CRT: a certificate of type 'gnutls_x509_crt_t' CA: true(1) or false(0). Depending on the Certificate authority status. PATHLENCONSTRAINT: non-negative error codes indicate maximum length of path, and negative error codes indicate that the pathLenConstraints field should not be present. This function will set the basicConstraints certificate extension. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_ca_status ----------------------------- -- Function: int gnutls_x509_crt_set_ca_status (gnutls_x509_crt_t CRT, unsigned int CA) CRT: a certificate of type 'gnutls_x509_crt_t' CA: true(1) or false(0). Depending on the Certificate authority status. This function will set the basicConstraints certificate extension. Use 'gnutls_x509_crt_set_basic_constraints()' if you want to control the pathLenConstraint field too. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_crl_dist_points ----------------------------------- -- Function: int gnutls_x509_crt_set_crl_dist_points (gnutls_x509_crt_t CRT, gnutls_x509_subject_alt_name_t TYPE, const void * DATA_STRING, unsigned int REASON_FLAGS) CRT: a certificate of type 'gnutls_x509_crt_t' TYPE: is one of the gnutls_x509_subject_alt_name_t enumerations DATA_STRING: The data to be set REASON_FLAGS: revocation reasons This function will set the CRL distribution points certificate extension. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_crl_dist_points2 ------------------------------------ -- Function: int gnutls_x509_crt_set_crl_dist_points2 (gnutls_x509_crt_t CRT, gnutls_x509_subject_alt_name_t TYPE, const void * DATA, unsigned int DATA_SIZE, unsigned int REASON_FLAGS) CRT: a certificate of type 'gnutls_x509_crt_t' TYPE: is one of the gnutls_x509_subject_alt_name_t enumerations DATA: The data to be set DATA_SIZE: The data size REASON_FLAGS: revocation reasons This function will set the CRL distribution points certificate extension. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 2.6.0 gnutls_x509_crt_set_crq ----------------------- -- Function: int gnutls_x509_crt_set_crq (gnutls_x509_crt_t CRT, gnutls_x509_crq_t CRQ) CRT: a certificate of type 'gnutls_x509_crt_t' CRQ: holds a certificate request This function will set the name and public parameters as well as the extensions from the given certificate request to the certificate. Only RSA keys are currently supported. Note that this function will only set the 'crq' if it is self signed and the signature is correct. See 'gnutls_x509_crq_sign2()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_crq_extensions ---------------------------------- -- Function: int gnutls_x509_crt_set_crq_extensions (gnutls_x509_crt_t CRT, gnutls_x509_crq_t CRQ) CRT: a certificate of type 'gnutls_x509_crt_t' CRQ: holds a certificate request This function will set extensions from the given request to the certificate. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 2.8.0 gnutls_x509_crt_set_dn ---------------------- -- Function: int gnutls_x509_crt_set_dn (gnutls_x509_crt_t CRT, const char * DN, const char ** ERR) CRT: a certificate of type 'gnutls_x509_crt_t' DN: a comma separated DN string (RFC4514) ERR: indicates the error position (if any) This function will set the DN on the provided certificate. The input string should be plain ASCII or UTF-8 encoded. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_dn_by_oid ----------------------------- -- Function: int gnutls_x509_crt_set_dn_by_oid (gnutls_x509_crt_t CRT, const char * OID, unsigned int RAW_FLAG, const void * NAME, unsigned int SIZEOF_NAME) CRT: a certificate of type 'gnutls_x509_crt_t' OID: holds an Object Identifier in a null terminated string RAW_FLAG: must be 0, or 1 if the data are DER encoded NAME: a pointer to the name SIZEOF_NAME: holds the size of 'name' This function will set the part of the name of the Certificate subject, specified by the given OID. The input string should be ASCII or UTF-8 encoded. Some helper macros with popular OIDs can be found in gnutls/x509.h With this function you can only set the known OIDs. You can test for known OIDs using 'gnutls_x509_dn_oid_known()' . For OIDs that are not known (by gnutls) you should properly DER encode your data, and call this function with 'raw_flag' set. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_expiration_time ----------------------------------- -- Function: int gnutls_x509_crt_set_expiration_time (gnutls_x509_crt_t CERT, time_t EXP_TIME) CERT: a certificate of type 'gnutls_x509_crt_t' EXP_TIME: The actual time This function will set the time this Certificate will expire. Setting an expiration time to (time_t)-1 or to 'GNUTLS_X509_NO_WELL_DEFINED_EXPIRATION' will set to the no well-defined expiration date value. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_extension_by_oid ------------------------------------ -- Function: int gnutls_x509_crt_set_extension_by_oid (gnutls_x509_crt_t CRT, const char * OID, const void * BUF, size_t SIZEOF_BUF, unsigned int CRITICAL) CRT: a certificate of type 'gnutls_x509_crt_t' OID: holds an Object Identified in null terminated string BUF: a pointer to a DER encoded data SIZEOF_BUF: holds the size of 'buf' CRITICAL: should be non-zero if the extension is to be marked as critical This function will set an the extension, by the specified OID, in the certificate. The extension data should be binary data DER encoded. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_issuer_alt_name ----------------------------------- -- Function: int gnutls_x509_crt_set_issuer_alt_name (gnutls_x509_crt_t CRT, gnutls_x509_subject_alt_name_t TYPE, const void * DATA, unsigned int DATA_SIZE, unsigned int FLAGS) CRT: a certificate of type 'gnutls_x509_crt_t' TYPE: is one of the gnutls_x509_subject_alt_name_t enumerations DATA: The data to be set DATA_SIZE: The size of data to be set FLAGS: GNUTLS_FSAN_SET to clear previous data or GNUTLS_FSAN_APPEND to append. This function will set the issuer alternative name certificate extension. It can set the same types as 'gnutls_x509_crt_set_subject_alt_name()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_crt_set_issuer_dn ----------------------------- -- Function: int gnutls_x509_crt_set_issuer_dn (gnutls_x509_crt_t CRT, const char * DN, const char ** ERR) CRT: a certificate of type 'gnutls_x509_crt_t' DN: a comma separated DN string (RFC4514) ERR: indicates the error position (if any) This function will set the DN on the provided certificate. The input string should be plain ASCII or UTF-8 encoded. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_issuer_dn_by_oid ------------------------------------ -- Function: int gnutls_x509_crt_set_issuer_dn_by_oid (gnutls_x509_crt_t CRT, const char * OID, unsigned int RAW_FLAG, const void * NAME, unsigned int SIZEOF_NAME) CRT: a certificate of type 'gnutls_x509_crt_t' OID: holds an Object Identifier in a null terminated string RAW_FLAG: must be 0, or 1 if the data are DER encoded NAME: a pointer to the name SIZEOF_NAME: holds the size of 'name' This function will set the part of the name of the Certificate issuer, specified by the given OID. The input string should be ASCII or UTF-8 encoded. Some helper macros with popular OIDs can be found in gnutls/x509.h With this function you can only set the known OIDs. You can test for known OIDs using 'gnutls_x509_dn_oid_known()' . For OIDs that are not known (by gnutls) you should properly DER encode your data, and call this function with 'raw_flag' set. Normally you do not need to call this function, since the signing operation will copy the signer's name as the issuer of the certificate. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_issuer_unique_id ------------------------------------ -- Function: int gnutls_x509_crt_set_issuer_unique_id (gnutls_x509_crt_t CERT, const void * ID, size_t ID_SIZE) CERT: a certificate of type 'gnutls_x509_crt_t' ID: The unique ID ID_SIZE: Holds the size of the unique ID. This function will set the X.509 certificate's issuer unique ID field. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_key ----------------------- -- Function: int gnutls_x509_crt_set_key (gnutls_x509_crt_t CRT, gnutls_x509_privkey_t KEY) CRT: a certificate of type 'gnutls_x509_crt_t' KEY: holds a private key This function will set the public parameters from the given private key to the certificate. Only RSA keys are currently supported. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_key_purpose_oid ----------------------------------- -- Function: int gnutls_x509_crt_set_key_purpose_oid (gnutls_x509_crt_t CERT, const void * OID, unsigned int CRITICAL) CERT: a certificate of type 'gnutls_x509_crt_t' OID: a pointer to a null terminated string that holds the OID CRITICAL: Whether this extension will be critical or not This function will set the key purpose OIDs of the Certificate. These are stored in the Extended Key Usage extension (2.5.29.37) See the GNUTLS_KP_* definitions for human readable names. Subsequent calls to this function will append OIDs to the OID list. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error code is returned. gnutls_x509_crt_set_key_usage ----------------------------- -- Function: int gnutls_x509_crt_set_key_usage (gnutls_x509_crt_t CRT, unsigned int USAGE) CRT: a certificate of type 'gnutls_x509_crt_t' USAGE: an ORed sequence of the GNUTLS_KEY_* elements. This function will set the keyUsage certificate extension. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_name_constraints ------------------------------------ -- Function: int gnutls_x509_crt_set_name_constraints (gnutls_x509_crt_t CRT, gnutls_x509_name_constraints_t NC, unsigned int CRITICAL) CRT: The certificate structure NC: The nameconstraints structure CRITICAL: whether this extension will be critical This function will set the provided name constraints to the certificate extension list. This extension is always marked as critical. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_crt_set_pin_function -------------------------------- -- Function: void gnutls_x509_crt_set_pin_function (gnutls_x509_crt_t CRT, gnutls_pin_callback_t FN, void * USERDATA) CRT: The certificate structure FN: the callback USERDATA: data associated with the callback This function will set a callback function to be used when it is required to access a protected object. This function overrides the global function set using 'gnutls_pkcs11_set_pin_function()' . Note that this callback is currently used only during the import of a PKCS '11' certificate with 'gnutls_x509_crt_import_pkcs11_url()' . *Since:* 3.1.0 gnutls_x509_crt_set_policy -------------------------- -- Function: int gnutls_x509_crt_set_policy (gnutls_x509_crt_t CRT, const struct gnutls_x509_policy_st * POLICY, unsigned int CRITICAL) CRT: should contain a 'gnutls_x509_crt_t' structure POLICY: A pointer to a policy structure. CRITICAL: use non-zero if the extension is marked as critical This function will set the certificate policy extension (2.5.29.32). Multiple calls to this function append a new policy. Note the maximum text size for the qualifier 'GNUTLS_X509_QUALIFIER_NOTICE' is 200 characters. This function will fail with 'GNUTLS_E_INVALID_REQUEST' if this is exceeded. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.1.5 gnutls_x509_crt_set_private_key_usage_period -------------------------------------------- -- Function: int gnutls_x509_crt_set_private_key_usage_period (gnutls_x509_crt_t CRT, time_t ACTIVATION, time_t EXPIRATION) CRT: a certificate of type 'gnutls_x509_crt_t' ACTIVATION: The activation time EXPIRATION: The expiration time This function will set the private key usage period extension (2.5.29.16). *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_proxy ------------------------- -- Function: int gnutls_x509_crt_set_proxy (gnutls_x509_crt_t CRT, int PATHLENCONSTRAINT, const char * POLICYLANGUAGE, const char * POLICY, size_t SIZEOF_POLICY) CRT: a certificate of type 'gnutls_x509_crt_t' PATHLENCONSTRAINT: non-negative error codes indicate maximum length of path, and negative error codes indicate that the pathLenConstraints field should not be present. POLICYLANGUAGE: OID describing the language of 'policy' . POLICY: uint8_t byte array with policy language, can be 'NULL' SIZEOF_POLICY: size of 'policy' . This function will set the proxyCertInfo extension. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_proxy_dn ---------------------------- -- Function: int gnutls_x509_crt_set_proxy_dn (gnutls_x509_crt_t CRT, gnutls_x509_crt_t EECRT, unsigned int RAW_FLAG, const void * NAME, unsigned int SIZEOF_NAME) CRT: a gnutls_x509_crt_t structure with the new proxy cert EECRT: the end entity certificate that will be issuing the proxy RAW_FLAG: must be 0, or 1 if the CN is DER encoded NAME: a pointer to the CN name, may be NULL (but MUST then be added later) SIZEOF_NAME: holds the size of 'name' This function will set the subject in 'crt' to the end entity's 'eecrt' subject name, and add a single Common Name component 'name' of size 'sizeof_name' . This corresponds to the required proxy certificate naming style. Note that if 'name' is 'NULL' , you MUST set it later by using 'gnutls_x509_crt_set_dn_by_oid()' or similar. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_serial -------------------------- -- Function: int gnutls_x509_crt_set_serial (gnutls_x509_crt_t CERT, const void * SERIAL, size_t SERIAL_SIZE) CERT: a certificate of type 'gnutls_x509_crt_t' SERIAL: The serial number SERIAL_SIZE: Holds the size of the serial field. This function will set the X.509 certificate's serial number. While the serial number is an integer, it is often handled as an opaque field by several CAs. For this reason this function accepts any kind of data as a serial number. To be consistent with the X.509/PKIX specifications the provided 'serial' should be a big-endian positive number (i.e. it's leftmost bit should be zero). *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_subject_alt_name ------------------------------------ -- Function: int gnutls_x509_crt_set_subject_alt_name (gnutls_x509_crt_t CRT, gnutls_x509_subject_alt_name_t TYPE, const void * DATA, unsigned int DATA_SIZE, unsigned int FLAGS) CRT: a certificate of type 'gnutls_x509_crt_t' TYPE: is one of the gnutls_x509_subject_alt_name_t enumerations DATA: The data to be set DATA_SIZE: The size of data to be set FLAGS: GNUTLS_FSAN_SET to clear previous data or GNUTLS_FSAN_APPEND to append. This function will set the subject alternative name certificate extension. It can set the following types: *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 2.6.0 gnutls_x509_crt_set_subject_alternative_name -------------------------------------------- -- Function: int gnutls_x509_crt_set_subject_alternative_name (gnutls_x509_crt_t CRT, gnutls_x509_subject_alt_name_t TYPE, const char * DATA_STRING) CRT: a certificate of type 'gnutls_x509_crt_t' TYPE: is one of the gnutls_x509_subject_alt_name_t enumerations DATA_STRING: The data to be set, a (0) terminated string This function will set the subject alternative name certificate extension. This function assumes that data can be expressed as a null terminated string. The name of the function is unfortunate since it is incosistent with 'gnutls_x509_crt_get_subject_alt_name()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_subject_key_id ---------------------------------- -- Function: int gnutls_x509_crt_set_subject_key_id (gnutls_x509_crt_t CERT, const void * ID, size_t ID_SIZE) CERT: a certificate of type 'gnutls_x509_crt_t' ID: The key ID ID_SIZE: Holds the size of the subject key ID field. This function will set the X.509 certificate's subject key ID extension. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_subject_unique_id ------------------------------------- -- Function: int gnutls_x509_crt_set_subject_unique_id (gnutls_x509_crt_t CERT, const void * ID, size_t ID_SIZE) CERT: a certificate of type 'gnutls_x509_crt_t' ID: The unique ID ID_SIZE: Holds the size of the unique ID. This function will set the X.509 certificate's subject unique ID field. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_set_version --------------------------- -- Function: int gnutls_x509_crt_set_version (gnutls_x509_crt_t CRT, unsigned int VERSION) CRT: a certificate of type 'gnutls_x509_crt_t' VERSION: holds the version number. For X.509v1 certificates must be 1. This function will set the version of the certificate. This must be one for X.509 version 1, and so on. Plain certificates without extensions must have version set to one. To create well-formed certificates, you must specify version 3 if you use any certificate extensions. Extensions are created by functions such as 'gnutls_x509_crt_set_subject_alt_name()' or 'gnutls_x509_crt_set_key_usage()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_sign -------------------- -- Function: int gnutls_x509_crt_sign (gnutls_x509_crt_t CRT, gnutls_x509_crt_t ISSUER, gnutls_x509_privkey_t ISSUER_KEY) CRT: a certificate of type 'gnutls_x509_crt_t' ISSUER: is the certificate of the certificate issuer ISSUER_KEY: holds the issuer's private key This function is the same a 'gnutls_x509_crt_sign2()' with no flags, and SHA1 as the hash algorithm. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_sign2 --------------------- -- Function: int gnutls_x509_crt_sign2 (gnutls_x509_crt_t CRT, gnutls_x509_crt_t ISSUER, gnutls_x509_privkey_t ISSUER_KEY, gnutls_digest_algorithm_t DIG, unsigned int FLAGS) CRT: a certificate of type 'gnutls_x509_crt_t' ISSUER: is the certificate of the certificate issuer ISSUER_KEY: holds the issuer's private key DIG: The message digest to use, 'GNUTLS_DIG_SHA1' is a safe choice FLAGS: must be 0 This function will sign the certificate with the issuer's private key, and will copy the issuer's information into the certificate. This must be the last step in a certificate generation since all the previously set parameters are now signed. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_crt_verify ---------------------- -- Function: int gnutls_x509_crt_verify (gnutls_x509_crt_t CERT, const gnutls_x509_crt_t * CA_LIST, int CA_LIST_LENGTH, unsigned int FLAGS, unsigned int * VERIFY) CERT: is the certificate to be verified CA_LIST: is one certificate that is considered to be trusted one CA_LIST_LENGTH: holds the number of CA certificate in CA_list FLAGS: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations. VERIFY: will hold the certificate verification output. This function will try to verify the given certificate and return its status. Note that a verification error does not imply a negative return status. In that case the 'verify' status is set. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_dn_deinit --------------------- -- Function: void gnutls_x509_dn_deinit (gnutls_x509_dn_t DN) DN: a DN uint8_t object pointer. This function deallocates the DN object as returned by 'gnutls_x509_dn_import()' . *Since:* 2.4.0 gnutls_x509_dn_export --------------------- -- Function: int gnutls_x509_dn_export (gnutls_x509_dn_t DN, gnutls_x509_crt_fmt_t FORMAT, void * OUTPUT_DATA, size_t * OUTPUT_DATA_SIZE) DN: Holds the uint8_t DN object FORMAT: the format of output params. One of PEM or DER. OUTPUT_DATA: will contain a DN PEM or DER encoded OUTPUT_DATA_SIZE: holds the size of output_data (and will be replaced by the actual size of parameters) This function will export the DN to DER or PEM format. If the buffer provided is not long enough to hold the output, then * 'output_data_size' is updated and 'GNUTLS_E_SHORT_MEMORY_BUFFER' will be returned. If the structure is PEM encoded, it will have a header of "BEGIN NAME". *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_dn_export2 ---------------------- -- Function: int gnutls_x509_dn_export2 (gnutls_x509_dn_t DN, gnutls_x509_crt_fmt_t FORMAT, gnutls_datum_t * OUT) DN: Holds the uint8_t DN object FORMAT: the format of output params. One of PEM or DER. OUT: will contain a DN PEM or DER encoded This function will export the DN to DER or PEM format. The output buffer is allocated using 'gnutls_malloc()' . If the structure is PEM encoded, it will have a header of "BEGIN NAME". *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.1.3 gnutls_x509_dn_get_rdn_ava -------------------------- -- Function: int gnutls_x509_dn_get_rdn_ava (gnutls_x509_dn_t DN, int IRDN, int IAVA, gnutls_x509_ava_st * AVA) DN: a pointer to DN IRDN: index of RDN IAVA: index of AVA. AVA: Pointer to structure which will hold output information. Get pointers to data within the DN. The format of the 'ava' structure is shown below. struct gnutls_x509_ava_st { gnutls_datum_t oid; gnutls_datum_t value; unsigned long value_tag; }; The X.509 distinguished name is a sequence of sequences of strings and this is what the 'irdn' and 'iava' indexes model. Note that 'ava' will contain pointers into the 'dn' structure which in turns points to the original certificate. Thus you should not modify any data or deallocate any of those. This is a low-level function that requires the caller to do the value conversions when necessary (e.g. from UCS-2). *Returns:* Returns 0 on success, or an error code. gnutls_x509_dn_import --------------------- -- Function: int gnutls_x509_dn_import (gnutls_x509_dn_t DN, const gnutls_datum_t * DATA) DN: the structure that will hold the imported DN DATA: should contain a DER encoded RDN sequence This function parses an RDN sequence and stores the result to a 'gnutls_x509_dn_t' structure. The structure must have been initialized with 'gnutls_x509_dn_init()' . You may use 'gnutls_x509_dn_get_rdn_ava()' to decode the DN. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 2.4.0 gnutls_x509_dn_init ------------------- -- Function: int gnutls_x509_dn_init (gnutls_x509_dn_t * DN) DN: the object to be initialized This function initializes a 'gnutls_x509_dn_t' structure. The object returned must be deallocated using 'gnutls_x509_dn_deinit()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 2.4.0 gnutls_x509_dn_oid_known ------------------------ -- Function: int gnutls_x509_dn_oid_known (const char * OID) OID: holds an Object Identifier in a null terminated string This function will inform about known DN OIDs. This is useful since functions like 'gnutls_x509_crt_set_dn_by_oid()' use the information on known OIDs to properly encode their input. Object Identifiers that are not known are not encoded by these functions, and their input is stored directly into the ASN.1 structure. In that case of unknown OIDs, you have the responsibility of DER encoding your data. *Returns:* 1 on known OIDs and 0 otherwise. gnutls_x509_dn_oid_name ----------------------- -- Function: const char * gnutls_x509_dn_oid_name (const char * OID, unsigned int FLAGS) OID: holds an Object Identifier in a null terminated string FLAGS: 0 or GNUTLS_X509_DN_OID_* This function will return the name of a known DN OID. If 'GNUTLS_X509_DN_OID_RETURN_OID' is specified this function will return the given OID if no descriptive name has been found. *Returns:* A null terminated string or NULL otherwise. *Since:* 3.0 gnutls_x509_ext_deinit ---------------------- -- Function: void gnutls_x509_ext_deinit (gnutls_x509_ext_st * EXT) EXT: The extensions structure This function will deinitialize an extensions structure. *Since:* 3.3.8 gnutls_x509_ext_export_aia -------------------------- -- Function: int gnutls_x509_ext_export_aia (gnutls_x509_aia_t AIA, gnutls_datum_t * EXT) AIA: The authority info access structure EXT: The DER-encoded extension data; must be freed using 'gnutls_free()' . This function will DER encode the Authority Information Access (AIA) extension; see RFC 5280 section 4.2.2.1 for more information on the extension. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_export_authority_key_id --------------------------------------- -- Function: int gnutls_x509_ext_export_authority_key_id (gnutls_x509_aki_t AKI, gnutls_datum_t * EXT) AKI: An initialized authority key identifier structure EXT: The DER-encoded extension data; must be freed using 'gnutls_free()' . This function will convert the provided key identifier to a DER-encoded PKIX AuthorityKeyIdentifier extension. The output data in 'ext' will be allocated using 'gnutls_malloc()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_export_basic_constraints ---------------------------------------- -- Function: int gnutls_x509_ext_export_basic_constraints (unsigned int CA, int PATHLEN, gnutls_datum_t * EXT) CA: non-zero for a CA PATHLEN: The path length constraint (set to -1 for no constraint) EXT: The DER-encoded extension data; must be freed using 'gnutls_free()' . This function will convert the parameters provided to a basic constraints DER encoded extension (2.5.29.19). The 'ext' data will be allocated using 'gnutls_malloc()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_export_crl_dist_points -------------------------------------- -- Function: int gnutls_x509_ext_export_crl_dist_points (gnutls_x509_crl_dist_points_t CDP, gnutls_datum_t * EXT) CDP: A pointer to an initialized CRL distribution points structure. EXT: The DER-encoded extension data; must be freed using 'gnutls_free()' . This function will convert the provided policies, to a certificate policy DER encoded extension (2.5.29.31). The 'ext' data will be allocated using 'gnutls_malloc()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_export_key_purposes ----------------------------------- -- Function: int gnutls_x509_ext_export_key_purposes (gnutls_x509_key_purposes_t P, gnutls_datum_t * EXT) P: The key purposes structure EXT: The DER-encoded extension data; must be freed using 'gnutls_free()' . This function will convert the key purposes structure to a DER-encoded PKIX ExtKeyUsageSyntax (2.5.29.37) extension. The output data in 'ext' will be allocated usin 'gnutls_malloc()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_export_key_usage -------------------------------- -- Function: int gnutls_x509_ext_export_key_usage (unsigned int USAGE, gnutls_datum_t * EXT) USAGE: an ORed sequence of the GNUTLS_KEY_* elements. EXT: The DER-encoded extension data; must be freed using 'gnutls_free()' . This function will convert the keyUsage bit string to a DER encoded PKIX extension. The 'ext' data will be allocated using 'gnutls_malloc()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_export_name_constraints --------------------------------------- -- Function: int gnutls_x509_ext_export_name_constraints (gnutls_x509_name_constraints_t NC, gnutls_datum_t * EXT) NC: The nameconstraints structure EXT: The DER-encoded extension data; must be freed using 'gnutls_free()' . This function will convert the provided name constraints structure to a DER-encoded PKIX NameConstraints (2.5.29.30) extension. The output data in 'ext' will be allocated usin 'gnutls_malloc()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_export_policies ------------------------------- -- Function: int gnutls_x509_ext_export_policies (gnutls_x509_policies_t POLICIES, gnutls_datum_t * EXT) POLICIES: A pointer to an initialized policies structure. EXT: The DER-encoded extension data; must be freed using 'gnutls_free()' . This function will convert the provided policies, to a certificate policy DER encoded extension (2.5.29.32). The 'ext' data will be allocated using 'gnutls_malloc()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_export_private_key_usage_period ----------------------------------------------- -- Function: int gnutls_x509_ext_export_private_key_usage_period (time_t ACTIVATION, time_t EXPIRATION, gnutls_datum_t * EXT) ACTIVATION: The activation time EXPIRATION: The expiration time EXT: The DER-encoded extension data; must be freed using 'gnutls_free()' . This function will convert the periods provided to a private key usage DER encoded extension (2.5.29.16). The 'ext' data will be allocated using 'gnutls_malloc()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_export_proxy ---------------------------- -- Function: int gnutls_x509_ext_export_proxy (int PATHLENCONSTRAINT, const char * POLICYLANGUAGE, const char * POLICY, size_t SIZEOF_POLICY, gnutls_datum_t * EXT) PATHLENCONSTRAINT: non-negative error codes indicate maximum length of path, and negative error codes indicate that the pathLenConstraints field should not be present. POLICYLANGUAGE: OID describing the language of 'policy' . POLICY: uint8_t byte array with policy language, can be 'NULL' SIZEOF_POLICY: size of 'policy' . EXT: The DER-encoded extension data; must be freed using 'gnutls_free()' . This function will convert the parameters provided to a proxyCertInfo extension. The 'ext' data will be allocated using 'gnutls_malloc()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_export_subject_alt_names ---------------------------------------- -- Function: int gnutls_x509_ext_export_subject_alt_names (gnutls_subject_alt_names_t SANS, gnutls_datum_t * EXT) SANS: The alternative names structure EXT: The DER-encoded extension data; must be freed using 'gnutls_free()' . This function will convert the provided alternative names structure to a DER-encoded SubjectAltName PKIX extension. The output data in 'ext' will be allocated using 'gnutls_malloc()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_export_subject_key_id ------------------------------------- -- Function: int gnutls_x509_ext_export_subject_key_id (const gnutls_datum_t * ID, gnutls_datum_t * EXT) ID: The key identifier EXT: The DER-encoded extension data; must be freed using 'gnutls_free()' . This function will convert the provided key identifier to a DER-encoded PKIX SubjectKeyIdentifier extension. The output data in 'ext' will be allocated using 'gnutls_malloc()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_import_aia -------------------------- -- Function: int gnutls_x509_ext_import_aia (const gnutls_datum_t * EXT, gnutls_x509_aia_t AIA, unsigned int FLAGS) EXT: The DER-encoded extension data AIA: The authority info access structure FLAGS: should be zero This function extracts the Authority Information Access (AIA) extension from the provided DER-encoded data; see RFC 5280 section 4.2.2.1 for more information on the extension. The AIA extension holds a sequence of AccessDescription (AD) data. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_import_authority_key_id --------------------------------------- -- Function: int gnutls_x509_ext_import_authority_key_id (const gnutls_datum_t * EXT, gnutls_x509_aki_t AKI, unsigned int FLAGS) EXT: a DER encoded extension AKI: An initialized authority key identifier structure FLAGS: should be zero This function will return the subject key ID stored in the provided AuthorityKeyIdentifier extension. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if the extension is not present, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_import_basic_constraints ---------------------------------------- -- Function: int gnutls_x509_ext_import_basic_constraints (const gnutls_datum_t * EXT, unsigned int * CA, int * PATHLEN) EXT: the DER encoded extension data CA: will be non zero if the CA status is true PATHLEN: the path length constraint; will be set to -1 for no limit This function will return the CA status and path length constraint as written in the PKIX extension 2.5.29.19. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_import_crl_dist_points -------------------------------------- -- Function: int gnutls_x509_ext_import_crl_dist_points (const gnutls_datum_t * EXT, gnutls_x509_crl_dist_points_t CDP, unsigned int FLAGS) EXT: the DER encoded extension data CDP: A pointer to an initialized CRL distribution points structure. FLAGS: should be zero This function will extract the CRL distribution points extension (2.5.29.31) and store it into the provided structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_import_key_purposes ----------------------------------- -- Function: int gnutls_x509_ext_import_key_purposes (const gnutls_datum_t * EXT, gnutls_x509_key_purposes_t P, unsigned int FLAGS) EXT: The DER-encoded extension data P: The key purposes structure FLAGS: should be zero This function will extract the key purposes in the provided DER-encoded ExtKeyUsageSyntax PKIX extension, to a 'gnutls_x509_key_purposes_t' structure. The structure must be initialized. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_import_key_usage -------------------------------- -- Function: int gnutls_x509_ext_import_key_usage (const gnutls_datum_t * EXT, unsigned int * KEY_USAGE) EXT: the DER encoded extension data KEY_USAGE: where the key usage bits will be stored This function will return certificate's key usage, by reading the DER data of the keyUsage X.509 extension (2.5.29.15). The key usage value will ORed values of the: 'GNUTLS_KEY_DIGITAL_SIGNATURE' , 'GNUTLS_KEY_NON_REPUDIATION' , 'GNUTLS_KEY_KEY_ENCIPHERMENT' , 'GNUTLS_KEY_DATA_ENCIPHERMENT' , 'GNUTLS_KEY_KEY_AGREEMENT' , 'GNUTLS_KEY_KEY_CERT_SIGN' , 'GNUTLS_KEY_CRL_SIGN' , 'GNUTLS_KEY_ENCIPHER_ONLY' , 'GNUTLS_KEY_DECIPHER_ONLY' . *Returns:* the certificate key usage, or a negative error code in case of parsing error. If the certificate does not contain the keyUsage extension 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' will be returned. *Since:* 3.3.0 gnutls_x509_ext_import_name_constraints --------------------------------------- -- Function: int gnutls_x509_ext_import_name_constraints (const gnutls_datum_t * EXT, gnutls_x509_name_constraints_t NC, unsigned int FLAGS) EXT: a DER encoded extension NC: The nameconstraints intermediate structure FLAGS: zero or 'GNUTLS_NAME_CONSTRAINTS_FLAG_APPEND' This function will return an intermediate structure containing the name constraints of the provided NameConstraints extension. That structure can be used in combination with 'gnutls_x509_name_constraints_check()' to verify whether a server's name is in accordance with the constraints. When the 'flags' is set to 'GNUTLS_NAME_CONSTRAINTS_FLAG_APPEND' , then if the 'nc' structure is empty this function will behave identically as if the flag was not set. Otherwise if there are elements in the 'nc' structure then only the excluded constraints will be appended to the constraints. Note that 'nc' must be initialized prior to calling this function. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if the extension is not present, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_import_policies ------------------------------- -- Function: int gnutls_x509_ext_import_policies (const gnutls_datum_t * EXT, gnutls_x509_policies_t POLICIES, unsigned int FLAGS) EXT: the DER encoded extension data POLICIES: A pointer to an initialized policies structures. FLAGS: should be zero This function will extract the certificate policy extension (2.5.29.32) and store it the provided structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_import_private_key_usage_period ----------------------------------------------- -- Function: int gnutls_x509_ext_import_private_key_usage_period (const gnutls_datum_t * EXT, time_t * ACTIVATION, time_t * EXPIRATION) EXT: the DER encoded extension data ACTIVATION: Will hold the activation time EXPIRATION: Will hold the expiration time This function will return the expiration and activation times of the private key as written in the PKIX extension 2.5.29.16. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_import_proxy ---------------------------- -- Function: int gnutls_x509_ext_import_proxy (const gnutls_datum_t * EXT, int * PATHLEN, char ** POLICYLANGUAGE, char ** POLICY, size_t * SIZEOF_POLICY) EXT: the DER encoded extension data PATHLEN: pointer to output integer indicating path length (may be NULL), non-negative error codes indicate a present pCPathLenConstraint field and the actual value, -1 indicate that the field is absent. POLICYLANGUAGE: output variable with OID of policy language POLICY: output variable with policy data SIZEOF_POLICY: output variable size of policy data This function will return the information from a proxy certificate extension. It reads the ProxyCertInfo X.509 extension (1.3.6.1.5.5.7.1.14). The 'policyLanguage' and 'policy' values must be deinitialized using 'gnutls_free()' after use. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_import_subject_alt_names ---------------------------------------- -- Function: int gnutls_x509_ext_import_subject_alt_names (const gnutls_datum_t * EXT, gnutls_subject_alt_names_t SANS, unsigned int FLAGS) EXT: The DER-encoded extension data SANS: The alternative names structure FLAGS: should be zero This function will export the alternative names in the provided DER-encoded SubjectAltName PKIX extension, to a 'gnutls_subject_alt_names_t' structure. The structure must have been initialized. This function will succeed even if there no subject alternative names in the structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_import_subject_key_id ------------------------------------- -- Function: int gnutls_x509_ext_import_subject_key_id (const gnutls_datum_t * EXT, gnutls_datum_t * ID) EXT: a DER encoded extension ID: will contain the subject key ID This function will return the subject key ID stored in the provided SubjectKeyIdentifier extension. The ID will be allocated using 'gnutls_malloc()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if the extension is not present, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_ext_print --------------------- -- Function: int gnutls_x509_ext_print (gnutls_x509_ext_st * EXTS, unsigned int EXTS_SIZE, gnutls_certificate_print_formats_t FORMAT, gnutls_datum_t * OUT) EXTS: The structures to be printed EXTS_SIZE: the number of available structures FORMAT: Indicate the format to use OUT: Newly allocated datum with null terminated string. This function will pretty print X.509 certificate extensions, suitable for display to a human. The output 'out' needs to be deallocated using 'gnutls_free()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_key_purpose_deinit ------------------------------ -- Function: void gnutls_x509_key_purpose_deinit (gnutls_x509_key_purposes_t P) P: The key purposes structure This function will deinitialize an alternative names structure. *Since:* 3.3.0 gnutls_x509_key_purpose_get --------------------------- -- Function: int gnutls_x509_key_purpose_get (gnutls_x509_key_purposes_t P, unsigned IDX, gnutls_datum_t * OID) P: The key purposes structure IDX: The index of the key purpose to retrieve OID: Will hold the object identifier of the key purpose (to be treated as constant) This function will retrieve the specified by the index key purpose in the purposes structure. The object identifier will be a null terminated string. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if the index is out of bounds, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_key_purpose_init ---------------------------- -- Function: int gnutls_x509_key_purpose_init (gnutls_x509_key_purposes_t * P) P: The key purposes structure This function will initialize an alternative names structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_key_purpose_set --------------------------- -- Function: int gnutls_x509_key_purpose_set (gnutls_x509_key_purposes_t P, const char * OID) P: The key purposes structure OID: The object identifier of the key purpose This function will store the specified key purpose in the purposes structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0), otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_name_constraints_add_excluded ----------------------------------------- -- Function: int gnutls_x509_name_constraints_add_excluded (gnutls_x509_name_constraints_t NC, gnutls_x509_subject_alt_name_t TYPE, const gnutls_datum_t * NAME) NC: The nameconstraints structure TYPE: The type of the constraints NAME: The data of the constraints This function will add a name constraint to the list of excluded constraints. The constraints 'type' can be any of the following types: 'GNUTLS_SAN_DNSNAME' , 'GNUTLS_SAN_RFC822NAME' , 'GNUTLS_SAN_DN' , 'GNUTLS_SAN_URI' , 'GNUTLS_SAN_IPADDRESS' . For the latter, an IP address in network byte order is expected, followed by its network mask (which is 4 bytes in IPv4 or 16-bytes in IPv6). *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_name_constraints_add_permitted ------------------------------------------ -- Function: int gnutls_x509_name_constraints_add_permitted (gnutls_x509_name_constraints_t NC, gnutls_x509_subject_alt_name_t TYPE, const gnutls_datum_t * NAME) NC: The nameconstraints structure TYPE: The type of the constraints NAME: The data of the constraints This function will add a name constraint to the list of permitted constraints. The constraints 'type' can be any of the following types: 'GNUTLS_SAN_DNSNAME' , 'GNUTLS_SAN_RFC822NAME' , 'GNUTLS_SAN_DN' , 'GNUTLS_SAN_URI' , 'GNUTLS_SAN_IPADDRESS' . For the latter, an IP address in network byte order is expected, followed by its network mask. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_name_constraints_check ---------------------------------- -- Function: unsigned gnutls_x509_name_constraints_check (gnutls_x509_name_constraints_t NC, gnutls_x509_subject_alt_name_t TYPE, const gnutls_datum_t * NAME) NC: the extracted name constraints structure TYPE: the type of the constraint to check (of type gnutls_x509_subject_alt_name_t) NAME: the name to be checked This function will check the provided name against the constraints in 'nc' using the RFC5280 rules. Currently this function is limited to DNS names and emails (of type 'GNUTLS_SAN_DNSNAME' and 'GNUTLS_SAN_RFC822NAME' ). *Returns:* zero if the provided name is not acceptable, and non-zero otherwise. *Since:* 3.3.0 gnutls_x509_name_constraints_check_crt -------------------------------------- -- Function: unsigned gnutls_x509_name_constraints_check_crt (gnutls_x509_name_constraints_t NC, gnutls_x509_subject_alt_name_t TYPE, gnutls_x509_crt_t CERT) NC: the extracted name constraints structure TYPE: the type of the constraint to check (of type gnutls_x509_subject_alt_name_t) CERT: the certificate to be checked This function will check the provided certificate names against the constraints in 'nc' using the RFC5280 rules. It will traverse all the certificate's names and alternative names. Currently this function is limited to DNS names and emails (of type 'GNUTLS_SAN_DNSNAME' and 'GNUTLS_SAN_RFC822NAME' ). *Returns:* zero if the provided name is not acceptable, and non-zero otherwise. *Since:* 3.3.0 gnutls_x509_name_constraints_deinit ----------------------------------- -- Function: void gnutls_x509_name_constraints_deinit (gnutls_x509_name_constraints_t NC) NC: The nameconstraints structure This function will deinitialize a name constraints structure. *Since:* 3.3.0 gnutls_x509_name_constraints_get_excluded ----------------------------------------- -- Function: int gnutls_x509_name_constraints_get_excluded (gnutls_x509_name_constraints_t NC, unsigned IDX, unsigned * TYPE, gnutls_datum_t * NAME) NC: the extracted name constraints structure IDX: the index of the constraint TYPE: the type of the constraint (of type gnutls_x509_subject_alt_name_t) NAME: the name in the constraint (of the specific type) This function will return an intermediate structure containing the name constraints of the provided CA certificate. That structure can be used in combination with 'gnutls_x509_name_constraints_check()' to verify whether a server's name is in accordance with the constraints. The name should be treated as constant and valid for the lifetime of 'nc' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if the extension is not present, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_name_constraints_get_permitted ------------------------------------------ -- Function: int gnutls_x509_name_constraints_get_permitted (gnutls_x509_name_constraints_t NC, unsigned IDX, unsigned * TYPE, gnutls_datum_t * NAME) NC: the extracted name constraints structure IDX: the index of the constraint TYPE: the type of the constraint (of type gnutls_x509_subject_alt_name_t) NAME: the name in the constraint (of the specific type) This function will return an intermediate structure containing the name constraints of the provided CA certificate. That structure can be used in combination with 'gnutls_x509_name_constraints_check()' to verify whether a server's name is in accordance with the constraints. The name should be treated as constant and valid for the lifetime of 'nc' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if the extension is not present, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_name_constraints_init --------------------------------- -- Function: int gnutls_x509_name_constraints_init (gnutls_x509_name_constraints_t * NC) NC: The nameconstraints structure This function will initialize a name constraints structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_othername_to_virtual -------------------------------- -- Function: int gnutls_x509_othername_to_virtual (const char * OID, const gnutls_datum_t * OTHERNAME, unsigned int * VIRT_TYPE, gnutls_datum_t * VIRT) OID: The othername object identifier OTHERNAME: - undescribed - VIRT_TYPE: GNUTLS_SAN_OTHERNAME_XXX VIRT: allocated printable data This function will parse and convert the othername data to a virtual type supported by gnutls. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.8 gnutls_x509_policies_deinit --------------------------- -- Function: void gnutls_x509_policies_deinit (gnutls_x509_policies_t POLICIES) POLICIES: The authority key identifier structure This function will deinitialize an authority key identifier structure. *Since:* 3.3.0 gnutls_x509_policies_get ------------------------ -- Function: int gnutls_x509_policies_get (gnutls_x509_policies_t POLICIES, unsigned int SEQ, struct gnutls_x509_policy_st * POLICY) POLICIES: The policies structure SEQ: The index of the name to get POLICY: Will hold the policy This function will return a specific policy as stored in the 'policies' structure. The returned values should be treated as constant and valid for the lifetime of 'policies' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, 'GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE' if the index is out of bounds, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_policies_init ------------------------- -- Function: int gnutls_x509_policies_init (gnutls_x509_policies_t * POLICIES) POLICIES: The authority key ID structure This function will initialize an authority key ID structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_policies_set ------------------------ -- Function: int gnutls_x509_policies_set (gnutls_x509_policies_t POLICIES, const struct gnutls_x509_policy_st * POLICY) POLICIES: An initialized policies structure POLICY: Contains the policy to set This function will store the specified policy in the provided 'policies' structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0), otherwise a negative error value. *Since:* 3.3.0 gnutls_x509_policy_release -------------------------- -- Function: void gnutls_x509_policy_release (struct gnutls_x509_policy_st * POLICY) POLICY: a certificate policy This function will deinitialize all memory associated with the provided 'policy' . The policy is allocated using 'gnutls_x509_crt_get_policy()' . *Since:* 3.1.5 gnutls_x509_privkey_cpy ----------------------- -- Function: int gnutls_x509_privkey_cpy (gnutls_x509_privkey_t DST, gnutls_x509_privkey_t SRC) DST: The destination key, which should be initialized. SRC: The source key This function will copy a private key from source to destination key. Destination has to be initialized. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_privkey_deinit -------------------------- -- Function: void gnutls_x509_privkey_deinit (gnutls_x509_privkey_t KEY) KEY: The structure to be deinitialized This function will deinitialize a private key structure. gnutls_x509_privkey_export -------------------------- -- Function: int gnutls_x509_privkey_export (gnutls_x509_privkey_t KEY, gnutls_x509_crt_fmt_t FORMAT, void * OUTPUT_DATA, size_t * OUTPUT_DATA_SIZE) KEY: Holds the key FORMAT: the format of output params. One of PEM or DER. OUTPUT_DATA: will contain a private key PEM or DER encoded OUTPUT_DATA_SIZE: holds the size of output_data (and will be replaced by the actual size of parameters) This function will export the private key to a PKCS1 structure for RSA keys, or an integer sequence for DSA keys. The DSA keys are in the same format with the parameters used by openssl. If the buffer provided is not long enough to hold the output, then * 'output_data_size' is updated and 'GNUTLS_E_SHORT_MEMORY_BUFFER' will be returned. If the structure is PEM encoded, it will have a header of "BEGIN RSA PRIVATE KEY". *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_privkey_export2 --------------------------- -- Function: int gnutls_x509_privkey_export2 (gnutls_x509_privkey_t KEY, gnutls_x509_crt_fmt_t FORMAT, gnutls_datum_t * OUT) KEY: Holds the key FORMAT: the format of output params. One of PEM or DER. OUT: will contain a private key PEM or DER encoded This function will export the private key to a PKCS1 structure for RSA keys, or an integer sequence for DSA keys. The DSA keys are in the same format with the parameters used by openssl. The output buffer is allocated using 'gnutls_malloc()' . If the structure is PEM encoded, it will have a header of "BEGIN RSA PRIVATE KEY". *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. Since 3.1.3 gnutls_x509_privkey_export2_pkcs8 --------------------------------- -- Function: int gnutls_x509_privkey_export2_pkcs8 (gnutls_x509_privkey_t KEY, gnutls_x509_crt_fmt_t FORMAT, const char * PASSWORD, unsigned int FLAGS, gnutls_datum_t * OUT) KEY: Holds the key FORMAT: the format of output params. One of PEM or DER. PASSWORD: the password that will be used to encrypt the key. FLAGS: an ORed sequence of gnutls_pkcs_encrypt_flags_t OUT: will contain a private key PEM or DER encoded This function will export the private key to a PKCS8 structure. Both RSA and DSA keys can be exported. For DSA keys we use PKCS '11' definitions. If the flags do not specify the encryption cipher, then the default 3DES (PBES2) will be used. The 'password' can be either ASCII or UTF-8 in the default PBES2 encryption schemas, or ASCII for the PKCS12 schemas. The output buffer is allocated using 'gnutls_malloc()' . If the structure is PEM encoded, it will have a header of "BEGIN ENCRYPTED PRIVATE KEY" or "BEGIN PRIVATE KEY" if encryption is not used. *Returns:* In case of failure a negative error code will be returned, and 0 on success. Since 3.1.3 gnutls_x509_privkey_export_dsa_raw ---------------------------------- -- Function: int gnutls_x509_privkey_export_dsa_raw (gnutls_x509_privkey_t KEY, gnutls_datum_t * P, gnutls_datum_t * Q, gnutls_datum_t * G, gnutls_datum_t * Y, gnutls_datum_t * X) KEY: a structure that holds the DSA parameters P: will hold the p Q: will hold the q G: will hold the g Y: will hold the y X: will hold the x This function will export the DSA private key's parameters found in the given structure. The new parameters will be allocated using 'gnutls_malloc()' and will be stored in the appropriate datum. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_privkey_export_ecc_raw ---------------------------------- -- Function: int gnutls_x509_privkey_export_ecc_raw (gnutls_x509_privkey_t KEY, gnutls_ecc_curve_t * CURVE, gnutls_datum_t * X, gnutls_datum_t * Y, gnutls_datum_t * K) KEY: a structure that holds the rsa parameters CURVE: will hold the curve X: will hold the x coordinate Y: will hold the y coordinate K: will hold the private key This function will export the ECC private key's parameters found in the given structure. The new parameters will be allocated using 'gnutls_malloc()' and will be stored in the appropriate datum. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.0 gnutls_x509_privkey_export_pkcs8 -------------------------------- -- Function: int gnutls_x509_privkey_export_pkcs8 (gnutls_x509_privkey_t KEY, gnutls_x509_crt_fmt_t FORMAT, const char * PASSWORD, unsigned int FLAGS, void * OUTPUT_DATA, size_t * OUTPUT_DATA_SIZE) KEY: Holds the key FORMAT: the format of output params. One of PEM or DER. PASSWORD: the password that will be used to encrypt the key. FLAGS: an ORed sequence of gnutls_pkcs_encrypt_flags_t OUTPUT_DATA: will contain a private key PEM or DER encoded OUTPUT_DATA_SIZE: holds the size of output_data (and will be replaced by the actual size of parameters) This function will export the private key to a PKCS8 structure. Both RSA and DSA keys can be exported. For DSA keys we use PKCS '11' definitions. If the flags do not specify the encryption cipher, then the default 3DES (PBES2) will be used. The 'password' can be either ASCII or UTF-8 in the default PBES2 encryption schemas, or ASCII for the PKCS12 schemas. If the buffer provided is not long enough to hold the output, then *output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will be returned. If the structure is PEM encoded, it will have a header of "BEGIN ENCRYPTED PRIVATE KEY" or "BEGIN PRIVATE KEY" if encryption is not used. *Returns:* In case of failure a negative error code will be returned, and 0 on success. gnutls_x509_privkey_export_rsa_raw ---------------------------------- -- Function: int gnutls_x509_privkey_export_rsa_raw (gnutls_x509_privkey_t KEY, gnutls_datum_t * M, gnutls_datum_t * E, gnutls_datum_t * D, gnutls_datum_t * P, gnutls_datum_t * Q, gnutls_datum_t * U) KEY: a structure that holds the rsa parameters M: will hold the modulus E: will hold the public exponent D: will hold the private exponent P: will hold the first prime (p) Q: will hold the second prime (q) U: will hold the coefficient This function will export the RSA private key's parameters found in the given structure. The new parameters will be allocated using 'gnutls_malloc()' and will be stored in the appropriate datum. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_privkey_export_rsa_raw2 ----------------------------------- -- Function: int gnutls_x509_privkey_export_rsa_raw2 (gnutls_x509_privkey_t KEY, gnutls_datum_t * M, gnutls_datum_t * E, gnutls_datum_t * D, gnutls_datum_t * P, gnutls_datum_t * Q, gnutls_datum_t * U, gnutls_datum_t * E1, gnutls_datum_t * E2) KEY: a structure that holds the rsa parameters M: will hold the modulus E: will hold the public exponent D: will hold the private exponent P: will hold the first prime (p) Q: will hold the second prime (q) U: will hold the coefficient E1: will hold e1 = d mod (p-1) E2: will hold e2 = d mod (q-1) This function will export the RSA private key's parameters found in the given structure. The new parameters will be allocated using 'gnutls_malloc()' and will be stored in the appropriate datum. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 2.12.0 gnutls_x509_privkey_fix ----------------------- -- Function: int gnutls_x509_privkey_fix (gnutls_x509_privkey_t KEY) KEY: Holds the key This function will recalculate the secondary parameters in a key. In RSA keys, this can be the coefficient and exponent1,2. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_privkey_generate ---------------------------- -- Function: int gnutls_x509_privkey_generate (gnutls_x509_privkey_t KEY, gnutls_pk_algorithm_t ALGO, unsigned int BITS, unsigned int FLAGS) KEY: should contain a 'gnutls_x509_privkey_t' structure ALGO: is one of the algorithms in 'gnutls_pk_algorithm_t' . BITS: the size of the modulus FLAGS: unused for now. Must be 0. This function will generate a random private key. Note that this function must be called on an empty private key. Note that when generating an elliptic curve key, the curve can be substituted in the place of the bits parameter using the 'GNUTLS_CURVE_TO_BITS()' macro. For DSA keys, if the subgroup size needs to be specified check the 'GNUTLS_SUBGROUP_TO_BITS()' macro. Do not set the number of bits directly, use 'gnutls_sec_param_to_pk_bits()' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_privkey_get_key_id ------------------------------ -- Function: int gnutls_x509_privkey_get_key_id (gnutls_x509_privkey_t KEY, unsigned int FLAGS, unsigned char * OUTPUT_DATA, size_t * OUTPUT_DATA_SIZE) KEY: Holds the key FLAGS: should be 0 for now OUTPUT_DATA: will contain the key ID OUTPUT_DATA_SIZE: holds the size of output_data (and will be replaced by the actual size of parameters) This function will return a unique ID that depends on the public key parameters. This ID can be used in checking whether a certificate corresponds to the given key. If the buffer provided is not long enough to hold the output, then * 'output_data_size' is updated and 'GNUTLS_E_SHORT_MEMORY_BUFFER' will be returned. The output will normally be a SHA-1 hash output, which is 20 bytes. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_privkey_get_pk_algorithm ------------------------------------ -- Function: int gnutls_x509_privkey_get_pk_algorithm (gnutls_x509_privkey_t KEY) KEY: should contain a 'gnutls_x509_privkey_t' structure This function will return the public key algorithm of a private key. *Returns:* a member of the 'gnutls_pk_algorithm_t' enumeration on success, or a negative error code on error. gnutls_x509_privkey_get_pk_algorithm2 ------------------------------------- -- Function: int gnutls_x509_privkey_get_pk_algorithm2 (gnutls_x509_privkey_t KEY, unsigned int * BITS) KEY: should contain a 'gnutls_x509_privkey_t' structure BITS: The number of bits in the public key algorithm This function will return the public key algorithm of a private key. *Returns:* a member of the 'gnutls_pk_algorithm_t' enumeration on success, or a negative error code on error. gnutls_x509_privkey_import -------------------------- -- Function: int gnutls_x509_privkey_import (gnutls_x509_privkey_t KEY, const gnutls_datum_t * DATA, gnutls_x509_crt_fmt_t FORMAT) KEY: The structure to store the parsed key DATA: The DER or PEM encoded certificate. FORMAT: One of DER or PEM This function will convert the given DER or PEM encoded key to the native 'gnutls_x509_privkey_t' format. The output will be stored in 'key' . If the key is PEM encoded it should have a header that contains "PRIVATE KEY". Note that this function falls back to PKCS '8' decoding without password, if the default format fails to import. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_privkey_import2 --------------------------- -- Function: int gnutls_x509_privkey_import2 (gnutls_x509_privkey_t KEY, const gnutls_datum_t * DATA, gnutls_x509_crt_fmt_t FORMAT, const char * PASSWORD, unsigned int FLAGS) KEY: The structure to store the parsed key DATA: The DER or PEM encoded key. FORMAT: One of DER or PEM PASSWORD: A password (optional) FLAGS: an ORed sequence of gnutls_pkcs_encrypt_flags_t This function will import the given DER or PEM encoded key, to the native 'gnutls_x509_privkey_t' format, irrespective of the input format. The input format is auto-detected. The supported formats are basic unencrypted key, PKCS8, PKCS12, and the openssl format. If the provided key is encrypted but no password was given, then 'GNUTLS_E_DECRYPTION_FAILED' is returned. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_privkey_import_dsa_raw ---------------------------------- -- Function: int gnutls_x509_privkey_import_dsa_raw (gnutls_x509_privkey_t KEY, const gnutls_datum_t * P, const gnutls_datum_t * Q, const gnutls_datum_t * G, const gnutls_datum_t * Y, const gnutls_datum_t * X) KEY: The structure to store the parsed key P: holds the p Q: holds the q G: holds the g Y: holds the y X: holds the x This function will convert the given DSA raw parameters to the native 'gnutls_x509_privkey_t' format. The output will be stored in 'key' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_privkey_import_ecc_raw ---------------------------------- -- Function: int gnutls_x509_privkey_import_ecc_raw (gnutls_x509_privkey_t KEY, gnutls_ecc_curve_t CURVE, const gnutls_datum_t * X, const gnutls_datum_t * Y, const gnutls_datum_t * K) KEY: The structure to store the parsed key CURVE: holds the curve X: holds the x Y: holds the y K: holds the k This function will convert the given elliptic curve parameters to the native 'gnutls_x509_privkey_t' format. The output will be stored in 'key' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.0 gnutls_x509_privkey_import_openssl ---------------------------------- -- Function: int gnutls_x509_privkey_import_openssl (gnutls_x509_privkey_t KEY, const gnutls_datum_t * DATA, const char * PASSWORD) KEY: The structure to store the parsed key DATA: The DER or PEM encoded key. PASSWORD: the password to decrypt the key (if it is encrypted). This function will convert the given PEM encrypted to the native gnutls_x509_privkey_t format. The output will be stored in 'key' . The 'password' should be in ASCII. If the password is not provided or wrong then 'GNUTLS_E_DECRYPTION_FAILED' will be returned. If the Certificate is PEM encoded it should have a header of "PRIVATE KEY" and the "DEK-Info" header. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_privkey_import_pkcs8 -------------------------------- -- Function: int gnutls_x509_privkey_import_pkcs8 (gnutls_x509_privkey_t KEY, const gnutls_datum_t * DATA, gnutls_x509_crt_fmt_t FORMAT, const char * PASSWORD, unsigned int FLAGS) KEY: The structure to store the parsed key DATA: The DER or PEM encoded key. FORMAT: One of DER or PEM PASSWORD: the password to decrypt the key (if it is encrypted). FLAGS: 0 if encrypted or GNUTLS_PKCS_PLAIN if not encrypted. This function will convert the given DER or PEM encoded PKCS8 2.0 encrypted key to the native gnutls_x509_privkey_t format. The output will be stored in 'key' . Both RSA and DSA keys can be imported, and flags can only be used to indicate an unencrypted key. The 'password' can be either ASCII or UTF-8 in the default PBES2 encryption schemas, or ASCII for the PKCS12 schemas. If the Certificate is PEM encoded it should have a header of "ENCRYPTED PRIVATE KEY", or "PRIVATE KEY". You only need to specify the flags if the key is DER encoded, since in that case the encryption status cannot be auto-detected. If the 'GNUTLS_PKCS_PLAIN' flag is specified and the supplied data are encrypted then 'GNUTLS_E_DECRYPTION_FAILED' is returned. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_privkey_import_rsa_raw ---------------------------------- -- Function: int gnutls_x509_privkey_import_rsa_raw (gnutls_x509_privkey_t KEY, const gnutls_datum_t * M, const gnutls_datum_t * E, const gnutls_datum_t * D, const gnutls_datum_t * P, const gnutls_datum_t * Q, const gnutls_datum_t * U) KEY: The structure to store the parsed key M: holds the modulus E: holds the public exponent D: holds the private exponent P: holds the first prime (p) Q: holds the second prime (q) U: holds the coefficient This function will convert the given RSA raw parameters to the native 'gnutls_x509_privkey_t' format. The output will be stored in 'key' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_privkey_import_rsa_raw2 ----------------------------------- -- Function: int gnutls_x509_privkey_import_rsa_raw2 (gnutls_x509_privkey_t KEY, const gnutls_datum_t * M, const gnutls_datum_t * E, const gnutls_datum_t * D, const gnutls_datum_t * P, const gnutls_datum_t * Q, const gnutls_datum_t * U, const gnutls_datum_t * E1, const gnutls_datum_t * E2) KEY: The structure to store the parsed key M: holds the modulus E: holds the public exponent D: holds the private exponent P: holds the first prime (p) Q: holds the second prime (q) U: holds the coefficient (optional) E1: holds e1 = d mod (p-1) (optional) E2: holds e2 = d mod (q-1) (optional) This function will convert the given RSA raw parameters to the native 'gnutls_x509_privkey_t' format. The output will be stored in 'key' . *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_privkey_init ------------------------ -- Function: int gnutls_x509_privkey_init (gnutls_x509_privkey_t * KEY) KEY: The structure to be initialized This function will initialize an private key structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_privkey_sec_param ----------------------------- -- Function: gnutls_sec_param_t gnutls_x509_privkey_sec_param (gnutls_x509_privkey_t KEY) KEY: a key structure This function will return the security parameter appropriate with this private key. *Returns:* On success, a valid security parameter is returned otherwise 'GNUTLS_SEC_PARAM_UNKNOWN' is returned. *Since:* 2.12.0 gnutls_x509_privkey_verify_params --------------------------------- -- Function: int gnutls_x509_privkey_verify_params (gnutls_x509_privkey_t KEY) KEY: should contain a 'gnutls_x509_privkey_t' structure This function will verify the private key parameters. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. gnutls_x509_rdn_get ------------------- -- Function: int gnutls_x509_rdn_get (const gnutls_datum_t * IDN, char * BUF, size_t * BUF_SIZE) IDN: should contain a DER encoded RDN sequence BUF: a pointer to a structure to hold the peer's name BUF_SIZE: holds the size of 'buf' This function will return the name of the given RDN sequence. The name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in RFC4514. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, or 'GNUTLS_E_SHORT_MEMORY_BUFFER' is returned and * 'buf_size' is updated if the provided buffer is not long enough, otherwise a negative error value. gnutls_x509_rdn_get_by_oid -------------------------- -- Function: int gnutls_x509_rdn_get_by_oid (const gnutls_datum_t * IDN, const char * OID, int INDX, unsigned int RAW_FLAG, void * BUF, size_t * BUF_SIZE) IDN: should contain a DER encoded RDN sequence OID: an Object Identifier INDX: In case multiple same OIDs exist in the RDN indicates which to send. Use 0 for the first one. RAW_FLAG: If non-zero then the raw DER data are returned. BUF: a pointer to a structure to hold the peer's name BUF_SIZE: holds the size of 'buf' This function will return the name of the given Object identifier, of the RDN sequence. The name will be encoded using the rules from RFC4514. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, or 'GNUTLS_E_SHORT_MEMORY_BUFFER' is returned and * 'buf_size' is updated if the provided buffer is not long enough, otherwise a negative error value. gnutls_x509_rdn_get_oid ----------------------- -- Function: int gnutls_x509_rdn_get_oid (const gnutls_datum_t * IDN, int INDX, void * BUF, size_t * BUF_SIZE) IDN: should contain a DER encoded RDN sequence INDX: Indicates which OID to return. Use 0 for the first one. BUF: a pointer to a structure to hold the peer's name OID BUF_SIZE: holds the size of 'buf' This function will return the specified Object identifier, of the RDN sequence. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, or 'GNUTLS_E_SHORT_MEMORY_BUFFER' is returned and * 'buf_size' is updated if the provided buffer is not long enough, otherwise a negative error value. *Since:* 2.4.0 gnutls_x509_trust_list_add_cas ------------------------------ -- Function: int gnutls_x509_trust_list_add_cas (gnutls_x509_trust_list_t LIST, const gnutls_x509_crt_t * CLIST, unsigned CLIST_SIZE, unsigned int FLAGS) LIST: The structure of the list CLIST: A list of CAs CLIST_SIZE: The length of the CA list FLAGS: should be 0 or an or'ed sequence of 'GNUTLS_TL' options. This function will add the given certificate authorities to the trusted list. The list of CAs must not be deinitialized during this structure's lifetime. If the flag 'GNUTLS_TL_NO_DUPLICATES' is specified, then the provided 'clist' entries that are duplicates will not be added to the list and will be deinitialized. *Returns:* The number of added elements is returned. *Since:* 3.0.0 gnutls_x509_trust_list_add_crls ------------------------------- -- Function: int gnutls_x509_trust_list_add_crls (gnutls_x509_trust_list_t LIST, const gnutls_x509_crl_t * CRL_LIST, int CRL_SIZE, unsigned int FLAGS, unsigned int VERIFICATION_FLAGS) LIST: The structure of the list CRL_LIST: A list of CRLs CRL_SIZE: The length of the CRL list FLAGS: if GNUTLS_TL_VERIFY_CRL is given the CRLs will be verified before being added. VERIFICATION_FLAGS: gnutls_certificate_verify_flags if flags specifies GNUTLS_TL_VERIFY_CRL This function will add the given certificate revocation lists to the trusted list. The list of CRLs must not be deinitialized during this structure's lifetime. This function must be called after 'gnutls_x509_trust_list_add_cas()' to allow verifying the CRLs for validity. If the flag 'GNUTLS_TL_NO_DUPLICATES' is given, then any provided CRLs that are a duplicate, will be deinitialized and not added to the list (that assumes that 'gnutls_x509_trust_list_deinit()' will be called with all=1). *Returns:* The number of added elements is returned. *Since:* 3.0 gnutls_x509_trust_list_add_named_crt ------------------------------------ -- Function: int gnutls_x509_trust_list_add_named_crt (gnutls_x509_trust_list_t LIST, gnutls_x509_crt_t CERT, const void * NAME, size_t NAME_SIZE, unsigned int FLAGS) LIST: The structure of the list CERT: A certificate NAME: An identifier for the certificate NAME_SIZE: The size of the identifier FLAGS: should be 0. This function will add the given certificate to the trusted list and associate it with a name. The certificate will not be be used for verification with 'gnutls_x509_trust_list_verify_crt()' but only with 'gnutls_x509_trust_list_verify_named_crt()' . In principle this function can be used to set individual "server" certificates that are trusted by the user for that specific server but for no other purposes. The certificate must not be deinitialized during the lifetime of the trusted list. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.0.0 gnutls_x509_trust_list_add_system_trust --------------------------------------- -- Function: int gnutls_x509_trust_list_add_system_trust (gnutls_x509_trust_list_t LIST, unsigned int TL_FLAGS, unsigned int TL_VFLAGS) LIST: The structure of the list TL_FLAGS: GNUTLS_TL_* TL_VFLAGS: gnutls_certificate_verify_flags if flags specifies GNUTLS_TL_VERIFY_CRL This function adds the system's default trusted certificate authorities to the trusted list. Note that on unsupported systems this function returns 'GNUTLS_E_UNIMPLEMENTED_FEATURE' . This function implies the flag 'GNUTLS_TL_NO_DUPLICATES' . *Returns:* The number of added elements or a negative error code on error. *Since:* 3.1 gnutls_x509_trust_list_add_trust_dir ------------------------------------ -- Function: int gnutls_x509_trust_list_add_trust_dir (gnutls_x509_trust_list_t LIST, const char * CA_DIR, const char * CRL_DIR, gnutls_x509_crt_fmt_t TYPE, unsigned int TL_FLAGS, unsigned int TL_VFLAGS) LIST: The structure of the list CA_DIR: A directory containing the CAs (optional) CRL_DIR: A directory containing a list of CRLs (optional) TYPE: The format of the certificates TL_FLAGS: GNUTLS_TL_* TL_VFLAGS: gnutls_certificate_verify_flags if flags specifies GNUTLS_TL_VERIFY_CRL This function will add the given certificate authorities to the trusted list. Only directories are accepted by this function. *Returns:* The number of added elements is returned. *Since:* 3.3.6 gnutls_x509_trust_list_add_trust_file ------------------------------------- -- Function: int gnutls_x509_trust_list_add_trust_file (gnutls_x509_trust_list_t LIST, const char * CA_FILE, const char * CRL_FILE, gnutls_x509_crt_fmt_t TYPE, unsigned int TL_FLAGS, unsigned int TL_VFLAGS) LIST: The structure of the list CA_FILE: A file containing a list of CAs (optional) CRL_FILE: A file containing a list of CRLs (optional) TYPE: The format of the certificates TL_FLAGS: GNUTLS_TL_* TL_VFLAGS: gnutls_certificate_verify_flags if flags specifies GNUTLS_TL_VERIFY_CRL This function will add the given certificate authorities to the trusted list. PKCS '11' URLs are also accepted, instead of files, by this function. A PKCS '11' URL implies a trust database (a specially marked module in p11-kit); the URL "pkcs11:" implies all trust databases in the system. Only a single URL specifying trust databases can be set; they cannot be stacked with multiple calls. *Returns:* The number of added elements is returned. *Since:* 3.1 gnutls_x509_trust_list_add_trust_mem ------------------------------------ -- Function: int gnutls_x509_trust_list_add_trust_mem (gnutls_x509_trust_list_t LIST, const gnutls_datum_t * CAS, const gnutls_datum_t * CRLS, gnutls_x509_crt_fmt_t TYPE, unsigned int TL_FLAGS, unsigned int TL_VFLAGS) LIST: The structure of the list CAS: A buffer containing a list of CAs (optional) CRLS: A buffer containing a list of CRLs (optional) TYPE: The format of the certificates TL_FLAGS: GNUTLS_TL_* TL_VFLAGS: gnutls_certificate_verify_flags if flags specifies GNUTLS_TL_VERIFY_CRL This function will add the given certificate authorities to the trusted list. *Returns:* The number of added elements is returned. *Since:* 3.1 gnutls_x509_trust_list_deinit ----------------------------- -- Function: void gnutls_x509_trust_list_deinit (gnutls_x509_trust_list_t LIST, unsigned int ALL) LIST: The structure to be deinitialized ALL: if non-zero it will deinitialize all the certificates and CRLs contained in the structure. This function will deinitialize a trust list. Note that the 'all' flag should be typically non-zero unless you have specified your certificates using 'gnutls_x509_trust_list_add_cas()' and you want to prevent them from being deinitialized by this function. *Since:* 3.0.0 gnutls_x509_trust_list_get_issuer --------------------------------- -- Function: int gnutls_x509_trust_list_get_issuer (gnutls_x509_trust_list_t LIST, gnutls_x509_crt_t CERT, gnutls_x509_crt_t * ISSUER, unsigned int FLAGS) LIST: The structure of the list 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' This function will find the issuer of the 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()' . Note that the flag 'GNUTLS_TL_GET_COPY' is required for this function to work with PKCS '11' trust lists in a thread-safe way. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.0 gnutls_x509_trust_list_init --------------------------- -- Function: int gnutls_x509_trust_list_init (gnutls_x509_trust_list_t * LIST, unsigned int SIZE) LIST: The structure to be initialized SIZE: The size of the internal hash table. Use (0) for default size. This function will initialize an X.509 trust list structure. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.0.0 gnutls_x509_trust_list_remove_cas --------------------------------- -- Function: int gnutls_x509_trust_list_remove_cas (gnutls_x509_trust_list_t LIST, const gnutls_x509_crt_t * CLIST, int CLIST_SIZE) LIST: The structure of the list CLIST: A list of CAs CLIST_SIZE: The length of the CA list This function will remove the given certificate authorities from the trusted list. Note that this function can accept certificates and authorities not yet known. In that case they will be kept in a separate black list that will be used during certificate verification. Unlike 'gnutls_x509_trust_list_add_cas()' there is no deinitialization restriction for certificate list provided in this function. *Returns:* The number of removed elements is returned. *Since:* 3.1.10 gnutls_x509_trust_list_remove_trust_file ---------------------------------------- -- Function: int gnutls_x509_trust_list_remove_trust_file (gnutls_x509_trust_list_t LIST, const char * CA_FILE, gnutls_x509_crt_fmt_t TYPE) LIST: The structure of the list CA_FILE: A file containing a list of CAs TYPE: The format of the certificates This function will remove the given certificate authorities from the trusted list, and add them into a black list when needed. PKCS 11 URLs are also accepted, instead of files, by this function. See also 'gnutls_x509_trust_list_remove_cas()' . *Returns:* The number of added elements is returned. *Since:* 3.1.10 gnutls_x509_trust_list_remove_trust_mem --------------------------------------- -- Function: int gnutls_x509_trust_list_remove_trust_mem (gnutls_x509_trust_list_t LIST, const gnutls_datum_t * CAS, gnutls_x509_crt_fmt_t TYPE) LIST: The structure of the list CAS: A buffer containing a list of CAs (optional) TYPE: The format of the certificates This function will remove the provided certificate authorities from the trusted list, and add them into a black list when needed. See also 'gnutls_x509_trust_list_remove_cas()' . *Returns:* The number of removed elements is returned. *Since:* 3.1.10 gnutls_x509_trust_list_verify_crt --------------------------------- -- Function: int gnutls_x509_trust_list_verify_crt (gnutls_x509_trust_list_t LIST, gnutls_x509_crt_t * CERT_LIST, unsigned int CERT_LIST_SIZE, unsigned int FLAGS, unsigned int * VOUTPUT, gnutls_verify_output_function FUNC) LIST: The structure of the list CERT_LIST: is the certificate list to be verified CERT_LIST_SIZE: is the certificate list size FLAGS: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations. VOUTPUT: will hold the certificate verification output. FUNC: If non-null will be called on each chain element verification with the output. This function will try to verify the given certificate and return its status. The 'verify' parameter will hold an OR'ed sequence of 'gnutls_certificate_status_t' flags. Additionally a certificate verification profile can be specified from the ones in 'gnutls_certificate_verification_profiles_t' by ORing the result of 'GNUTLS_PROFILE_TO_VFLAGS()' to the verification flags. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.0 gnutls_x509_trust_list_verify_crt2 ---------------------------------- -- Function: int gnutls_x509_trust_list_verify_crt2 (gnutls_x509_trust_list_t LIST, gnutls_x509_crt_t * CERT_LIST, unsigned int CERT_LIST_SIZE, gnutls_typed_vdata_st * DATA, unsigned int ELEMENTS, unsigned int FLAGS, unsigned int * VOUTPUT, gnutls_verify_output_function FUNC) LIST: The structure of the list CERT_LIST: is the certificate list to be verified CERT_LIST_SIZE: is the certificate list size DATA: an array of typed data ELEMENTS: the number of data elements FLAGS: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations. VOUTPUT: will hold the certificate verification output. FUNC: If non-null will be called on each chain element verification with the output. This function will try to verify the given certificate and return its status. The 'verify' parameter will hold an OR'ed sequence of 'gnutls_certificate_status_t' flags. Additionally a certificate verification profile can be specified from the ones in 'gnutls_certificate_verification_profiles_t' by ORing the result of 'GNUTLS_PROFILE_TO_VFLAGS()' to the verification flags. The acceptable 'data' types are 'GNUTLS_DT_DNS_HOSTNAME' and 'GNUTLS_DT_KEY_PURPOSE_OID' . The former accepts as data a null-terminated hostname, 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 will fail with 'GNUTLS_CERT_SIGNER_CONSTRAINTS_FAILURE' status. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. Note that verification failure will not result to an error code, only 'voutput' will be updated. *Since:* 3.3.8 gnutls_x509_trust_list_verify_named_crt --------------------------------------- -- Function: int gnutls_x509_trust_list_verify_named_crt (gnutls_x509_trust_list_t LIST, gnutls_x509_crt_t CERT, const void * NAME, size_t NAME_SIZE, unsigned int FLAGS, unsigned int * VOUTPUT, gnutls_verify_output_function FUNC) LIST: The structure of the list CERT: is the certificate to be verified NAME: is the certificate's name NAME_SIZE: is the certificate's name size FLAGS: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations. VOUTPUT: will hold the certificate verification output. FUNC: If non-null will be called on each chain element verification with the output. This function will try to find a certificate that is associated with the provided name -see 'gnutls_x509_trust_list_add_named_crt()' . If a match is found the certificate is considered valid. In addition to that this function will also check CRLs. The 'voutput' parameter will hold an OR'ed sequence of 'gnutls_certificate_status_t' flags. Additionally a certificate verification profile can be specified from the ones in 'gnutls_certificate_verification_profiles_t' by ORing the result of 'GNUTLS_PROFILE_TO_VFLAGS()' to the verification flags. *Returns:* On success, 'GNUTLS_E_SUCCESS' (0) is returned, otherwise a negative error value. *Since:* 3.0.0