![]() | ![]() | ![]() | GNU TLS API Reference Manual | ![]() |
---|
x509x509 — |
#define GNUTLS_OID_X520_COUNTRY_NAME #define GNUTLS_OID_X520_ORGANIZATION_NAME #define GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME #define GNUTLS_OID_X520_COMMON_NAME #define GNUTLS_OID_X520_LOCALITY_NAME #define GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME #define GNUTLS_OID_X520_INITIALS #define GNUTLS_OID_X520_GENERATION_QUALIFIER #define GNUTLS_OID_X520_SURNAME #define GNUTLS_OID_X520_GIVEN_NAME #define GNUTLS_OID_X520_TITLE #define GNUTLS_OID_X520_DN_QUALIFIER #define GNUTLS_OID_X520_PSEUDONYM #define GNUTLS_OID_LDAP_DC #define GNUTLS_OID_LDAP_UID #define GNUTLS_OID_PKCS9_EMAIL #define GNUTLS_OID_PKIX_DATE_OF_BIRTH #define GNUTLS_OID_PKIX_PLACE_OF_BIRTH #define GNUTLS_OID_PKIX_GENDER #define GNUTLS_OID_PKIX_COUNTRY_OF_CITIZENSHIP #define GNUTLS_OID_PKIX_COUNTRY_OF_RESIDENCE #define GNUTLS_KP_TLS_WWW_SERVER #define GNUTLS_KP_TLS_WWW_CLIENT #define GNUTLS_KP_CODE_SIGNING #define GNUTLS_KP_EMAIL_PROTECTION #define GNUTLS_KP_TIME_STAMPING #define GNUTLS_KP_OCSP_SIGNING #define GNUTLS_KP_ANY int gnutls_x509_crt_init (gnutls_x509_crt_t *cert); void gnutls_x509_crt_deinit (gnutls_x509_crt_t cert); int gnutls_x509_crt_import (gnutls_x509_crt_t cert, const gnutls_datum_t *data, gnutls_x509_crt_fmt_t format); int gnutls_x509_crt_export (gnutls_x509_crt_t cert, gnutls_x509_crt_fmt_t format, void *output_data, size_t *output_data_size); int gnutls_x509_crt_get_issuer_dn (gnutls_x509_crt_t cert, char *buf, size_t *sizeof_buf); int gnutls_x509_crt_get_issuer_dn_oid (gnutls_x509_crt_t cert, int indx, void *oid, size_t *sizeof_oid); 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 *sizeof_buf); int gnutls_x509_crt_get_dn (gnutls_x509_crt_t cert, char *buf, size_t *sizeof_buf); int gnutls_x509_crt_get_dn_oid (gnutls_x509_crt_t cert, int indx, void *oid, size_t *sizeof_oid); 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 *sizeof_buf); int gnutls_x509_crt_check_hostname (gnutls_x509_crt_t cert, const char *hostname); int gnutls_x509_crt_get_signature_algorithm (gnutls_x509_crt_t cert); int gnutls_x509_crt_get_version (gnutls_x509_crt_t cert); int gnutls_x509_crt_get_key_id (gnutls_x509_crt_t crt, unsigned int flags, unsigned char *output_data, size_t *output_data_size); int gnutls_x509_crt_set_authority_key_id (gnutls_x509_crt_t cert, const void *id, size_t id_size); int gnutls_x509_crt_get_authority_key_id (gnutls_x509_crt_t cert, void *ret, size_t *ret_size, unsigned int *critical); int gnutls_x509_crt_get_subject_key_id (gnutls_x509_crt_t cert, void *ret, size_t *ret_size, unsigned int *critical); #define GNUTLS_CRL_REASON_UNUSED #define GNUTLS_CRL_REASON_KEY_COMPROMISE #define GNUTLS_CRL_REASON_CA_COMPROMISE #define GNUTLS_CRL_REASON_AFFILIATION_CHANGED #define GNUTLS_CRL_REASON_SUPERSEEDED #define GNUTLS_CRL_REASON_CESSATION_OF_OPERATION #define GNUTLS_CRL_REASON_CERTIFICATE_HOLD #define GNUTLS_CRL_REASON_PRIVILEGE_WITHDRAWN #define GNUTLS_CRL_REASON_AA_COMPROMISE int gnutls_x509_crt_get_crl_dist_points (gnutls_x509_crt_t cert, unsigned int seq, void *ret, size_t *ret_size, unsigned int *reason_flags, unsigned int *critical); 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); int gnutls_x509_crt_cpy_crl_dist_points (gnutls_x509_crt_t dst, gnutls_x509_crt_t src); time_t gnutls_x509_crt_get_activation_time (gnutls_x509_crt_t cert); time_t gnutls_x509_crt_get_expiration_time (gnutls_x509_crt_t cert); int gnutls_x509_crt_get_serial (gnutls_x509_crt_t cert, void *result, size_t *result_size); int gnutls_x509_crt_get_pk_algorithm (gnutls_x509_crt_t cert, unsigned int *bits); int gnutls_x509_crt_get_pk_rsa_raw (gnutls_x509_crt_t crt, gnutls_datum_t *m, gnutls_datum_t *e); 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); int gnutls_x509_crt_get_subject_alt_name (gnutls_x509_crt_t cert, unsigned int seq, void *ret, size_t *ret_size, unsigned int *critical); int gnutls_x509_crt_get_ca_status (gnutls_x509_crt_t cert, unsigned int *critical); int gnutls_x509_crt_get_key_usage (gnutls_x509_crt_t cert, unsigned int *key_usage, unsigned int *critical); int gnutls_x509_crt_set_key_usage (gnutls_x509_crt_t crt, unsigned int usage); int gnutls_x509_dn_oid_known (const char *oid); int gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert, int indx, void *oid, size_t *sizeof_oid); int gnutls_x509_crt_get_extension_by_oid (gnutls_x509_crt_t cert, const char *oid, int indx, void *buf, size_t *sizeof_buf, unsigned int *critical); int gnutls_x509_crt_to_xml (gnutls_x509_crt_t cert, gnutls_datum_t *res, int detail); #define GNUTLS_XML_SHOW_ALL #define GNUTLS_XML_NORMAL 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); 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); int gnutls_x509_crt_set_version (gnutls_x509_crt_t crt, unsigned int version); int gnutls_x509_crt_set_key (gnutls_x509_crt_t crt, gnutls_x509_privkey_t key); int gnutls_x509_crt_set_ca_status (gnutls_x509_crt_t crt, unsigned int ca); int gnutls_x509_crt_set_subject_alternative_name (gnutls_x509_crt_t crt, gnutls_x509_subject_alt_name_t type, const char *data_string); int gnutls_x509_crt_sign (gnutls_x509_crt_t crt, gnutls_x509_crt_t issuer, gnutls_x509_privkey_t issuer_key); int gnutls_x509_crt_set_activation_time (gnutls_x509_crt_t cert, time_t act_time); int gnutls_x509_crt_set_expiration_time (gnutls_x509_crt_t cert, time_t exp_time); int gnutls_x509_crt_set_serial (gnutls_x509_crt_t cert, const void *serial, size_t serial_size); int gnutls_x509_crt_set_subject_key_id (gnutls_x509_crt_t cert, const void *id, size_t id_size); int gnutls_x509_rdn_get (const gnutls_datum_t *idn, char *buf, size_t *sizeof_buf); int gnutls_x509_rdn_get_oid (const gnutls_datum_t *idn, int indx, void *buf, size_t *sizeof_buf); 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 *sizeof_buf); int gnutls_x509_crl_init (gnutls_x509_crl_t *crl); void gnutls_x509_crl_deinit (gnutls_x509_crl_t crl); int gnutls_x509_crl_import (gnutls_x509_crl_t crl, const gnutls_datum_t *data, gnutls_x509_crt_fmt_t format); int gnutls_x509_crl_export (gnutls_x509_crl_t crl, gnutls_x509_crt_fmt_t format, void *output_data, size_t *output_data_size); int gnutls_x509_crl_get_issuer_dn (const gnutls_x509_crl_t crl, char *buf, size_t *sizeof_buf); 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); int gnutls_x509_crl_get_dn_oid (gnutls_x509_crl_t crl, int indx, void *oid, size_t *sizeof_oid); int gnutls_x509_crl_get_signature_algorithm (gnutls_x509_crl_t crl); int gnutls_x509_crl_get_version (gnutls_x509_crl_t crl); time_t gnutls_x509_crl_get_this_update (gnutls_x509_crl_t crl); time_t gnutls_x509_crl_get_next_update (gnutls_x509_crl_t crl); int gnutls_x509_crl_get_crt_count (gnutls_x509_crl_t crl); int gnutls_x509_crl_get_crt_serial (gnutls_x509_crl_t crl, int index, unsigned char *serial, size_t *serial_size, time_t *time); #define gnutls_x509_crl_get_certificate_count #define gnutls_x509_crl_get_certificate int gnutls_x509_crl_check_issuer (gnutls_x509_crl_t crl, gnutls_x509_crt_t issuer); int gnutls_x509_crl_set_version (gnutls_x509_crl_t crl, unsigned int version); int gnutls_x509_crl_sign (gnutls_x509_crl_t crl, gnutls_x509_crt_t issuer, gnutls_x509_privkey_t issuer_key); int gnutls_x509_crl_set_this_update (gnutls_x509_crl_t crl, time_t act_time); int gnutls_x509_crl_set_next_update (gnutls_x509_crl_t crl, time_t exp_time); int gnutls_x509_crl_set_crt_serial (gnutls_x509_crl_t crl, const void *serial, size_t serial_size, time_t revocation_time); int gnutls_x509_crl_set_crt (gnutls_x509_crl_t crl, gnutls_x509_crt_t crt, time_t revocation_time); struct gnutls_pkcs7_int; int gnutls_pkcs7_init (gnutls_pkcs7_t *pkcs7); void gnutls_pkcs7_deinit (gnutls_pkcs7_t pkcs7); int gnutls_pkcs7_import (gnutls_pkcs7_t pkcs7, const gnutls_datum_t *data, gnutls_x509_crt_fmt_t format); int gnutls_pkcs7_export (gnutls_pkcs7_t pkcs7, gnutls_x509_crt_fmt_t format, void *output_data, size_t *output_data_size); int gnutls_pkcs7_get_crt_count (gnutls_pkcs7_t pkcs7); int gnutls_pkcs7_get_crt_raw (gnutls_pkcs7_t pkcs7, int indx, void *certificate, size_t *certificate_size); int gnutls_pkcs7_set_crt_raw (gnutls_pkcs7_t pkcs7, const gnutls_datum_t *crt); int gnutls_pkcs7_set_crt (gnutls_pkcs7_t pkcs7, gnutls_x509_crt_t crt); int gnutls_pkcs7_delete_crt (gnutls_pkcs7_t pkcs7, int indx); int gnutls_pkcs7_get_crl_raw (gnutls_pkcs7_t pkcs7, int indx, void *crl, size_t *crl_size); int gnutls_pkcs7_get_crl_count (gnutls_pkcs7_t pkcs7); int gnutls_pkcs7_set_crl_raw (gnutls_pkcs7_t pkcs7, const gnutls_datum_t *crt); int gnutls_pkcs7_set_crl (gnutls_pkcs7_t pkcs7, gnutls_x509_crl_t crl); int gnutls_pkcs7_delete_crl (gnutls_pkcs7_t pkcs7, int indx); enum gnutls_certificate_verify_flags; int gnutls_x509_crt_check_issuer (gnutls_x509_crt_t cert, gnutls_x509_crt_t issuer); int gnutls_x509_crt_list_verify (gnutls_x509_crt_t *cert_list, int cert_list_length, const gnutls_x509_crt_t *CA_list, int CA_list_length, const gnutls_x509_crl_t *CRL_list, int CRL_list_length, unsigned int flags, unsigned int *verify); int gnutls_x509_crt_verify (gnutls_x509_crt_t cert, const gnutls_x509_crt_t *CA_list, int CA_list_length, unsigned int flags, unsigned int *verify); int gnutls_x509_crl_verify (gnutls_x509_crl_t crl, const gnutls_x509_crt_t *CA_list, int CA_list_length, unsigned int flags, unsigned int *verify); int gnutls_x509_crt_check_revocation (gnutls_x509_crt_t cert, const gnutls_x509_crl_t *crl_list, int crl_list_length); int gnutls_x509_crt_get_fingerprint (gnutls_x509_crt_t cert, gnutls_digest_algorithm_t algo, void *buf, size_t *sizeof_buf); int gnutls_x509_crt_get_key_purpose_oid (gnutls_x509_crt_t cert, int indx, void *oid, size_t *sizeof_oid, unsigned int *critical); int gnutls_x509_crt_set_key_purpose_oid (gnutls_x509_crt_t cert, const void *oid, unsigned int critical); enum gnutls_pkcs_encrypt_flags_t; #define GNUTLS_PKCS8_PLAIN #define GNUTLS_PKCS8_USE_PKCS12_3DES #define GNUTLS_PKCS8_USE_PKCS12_ARCFOUR #define GNUTLS_PKCS8_USE_PKCS12_RC2_40 int gnutls_x509_privkey_init (gnutls_x509_privkey_t *key); void gnutls_x509_privkey_deinit (gnutls_x509_privkey_t key); int gnutls_x509_privkey_cpy (gnutls_x509_privkey_t dst, gnutls_x509_privkey_t src); int gnutls_x509_privkey_import (gnutls_x509_privkey_t key, const gnutls_datum_t *data, gnutls_x509_crt_fmt_t format); int gnutls_x509_privkey_import_pkcs8 (gnutls_x509_privkey_t key, const gnutls_datum_t *data, gnutls_x509_crt_fmt_t format, const char *pass, unsigned int flags); 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); 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); 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); int gnutls_x509_privkey_get_pk_algorithm (gnutls_x509_privkey_t key); int gnutls_x509_privkey_get_key_id (gnutls_x509_privkey_t key, unsigned int flags, unsigned char *output_data, size_t *output_data_size); int gnutls_x509_privkey_generate (gnutls_x509_privkey_t key, gnutls_pk_algorithm_t algo, unsigned int bits, unsigned int flags); int gnutls_x509_privkey_export (gnutls_x509_privkey_t key, gnutls_x509_crt_fmt_t format, void *output_data, size_t *output_data_size); 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); 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); int gnutls_x509_privkey_sign_data (gnutls_x509_privkey_t key, gnutls_digest_algorithm_t digest, unsigned int flags, const gnutls_datum_t *data, void *signature, size_t *signature_size); int gnutls_x509_privkey_verify_data (gnutls_x509_privkey_t key, unsigned int flags, const gnutls_datum_t *data, const gnutls_datum_t *signature); int gnutls_x509_crt_verify_data (gnutls_x509_crt_t crt, unsigned int flags, const gnutls_datum_t *data, const gnutls_datum_t *signature); struct gnutls_x509_crq_int; int gnutls_x509_crq_init (gnutls_x509_crq_t *crq); void gnutls_x509_crq_deinit (gnutls_x509_crq_t crq); int gnutls_x509_crq_import (gnutls_x509_crq_t crq, const gnutls_datum_t *data, gnutls_x509_crt_fmt_t format); int gnutls_x509_crq_get_pk_algorithm (gnutls_x509_crq_t crq, unsigned int *bits); int gnutls_x509_crq_get_dn (gnutls_x509_crq_t crq, char *buf, size_t *sizeof_buf); int gnutls_x509_crq_get_dn_oid (gnutls_x509_crq_t crq, int indx, void *oid, size_t *sizeof_oid); 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 *sizeof_buf); int gnutls_x509_crq_set_dn_by_oid (gnutls_x509_crq_t crq, const char *oid, unsigned int raw_flag, const void *name, unsigned int sizeof_name); int gnutls_x509_crq_set_version (gnutls_x509_crq_t crq, unsigned int version); int gnutls_x509_crq_set_key (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key); int gnutls_x509_crq_sign (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key); int gnutls_x509_crq_set_challenge_password (gnutls_x509_crq_t crq, const char *pass); int gnutls_x509_crq_get_challenge_password (gnutls_x509_crq_t crq, const char *pass, size_t *sizeof_pass); int gnutls_x509_crq_export (gnutls_x509_crq_t crq, gnutls_x509_crt_fmt_t format, void *output_data, size_t *output_data_size); int gnutls_x509_crt_set_crq (gnutls_x509_crt_t crt, gnutls_x509_crq_t crq);
#define GNUTLS_OID_PKIX_COUNTRY_OF_CITIZENSHIP "1.3.6.1.5.5.7.9.4"
#define GNUTLS_OID_PKIX_COUNTRY_OF_RESIDENCE "1.3.6.1.5.5.7.9.5"
int gnutls_x509_crt_init (gnutls_x509_crt_t *cert);
This function will initialize an X.509 certificate structure.
cert : | |
Returns : |
void gnutls_x509_crt_deinit (gnutls_x509_crt_t cert);
This function will deinitialize a CRL structure.
cert : |
int gnutls_x509_crt_import (gnutls_x509_crt_t cert, const gnutls_datum_t *data, gnutls_x509_crt_fmt_t format);
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".
cert : | |
data : | |
format : | |
Returns : |
int gnutls_x509_crt_export (gnutls_x509_crt_t cert, gnutls_x509_crt_fmt_t format, void *output_data, size_t *output_data_size);
This function will export the certificate 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 CERTIFICATE".
In case of failure a negative value will be returned, and 0 on success.
cert : | |
format : | |
output_data : | |
output_data_size : | |
Returns : |
int gnutls_x509_crt_get_issuer_dn (gnutls_x509_crt_t cert, char *buf, size_t *sizeof_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 RFC2253. 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.
cert : | |
buf : | |
sizeof_buf : | |
Returns : |
int gnutls_x509_crt_get_issuer_dn_oid (gnutls_x509_crt_t cert, int indx, void *oid, size_t *sizeof_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.
cert : | |
indx : | |
oid : | |
sizeof_oid : | |
Returns : |
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 *sizeof_buf);
This function will extract the part of the name of the Certificate issuer 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 zero, 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().
If buf is null then only the size will be filled.
cert : | |
oid : | |
indx : | |
raw_flag : | |
buf : | |
sizeof_buf : | |
Returns : |
int gnutls_x509_crt_get_dn (gnutls_x509_crt_t cert, char *buf, size_t *sizeof_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 RFC2253. 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.
cert : | |
buf : | |
sizeof_buf : | |
Returns : |
int gnutls_x509_crt_get_dn_oid (gnutls_x509_crt_t cert, int indx, void *oid, size_t *sizeof_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.
cert : | |
indx : | |
oid : | |
sizeof_oid : | |
Returns : |
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 *sizeof_buf);
This function will extract the part of the name of the Certificate subject, specified by the given OID. 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 zero, 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().
If buf is null then only the size will be filled.
cert : | |
oid : | |
indx : | |
raw_flag : | |
buf : | |
sizeof_buf : | |
Returns : |
int gnutls_x509_crt_check_hostname (gnutls_x509_crt_t cert, const char *hostname);
This function will check if the given certificate's subject matches the given hostname. This is a basic implementation of the matching described in RFC2818 (HTTPS), which takes into account wildcards, and the subject alternative name PKIX extension.
cert : | |
hostname : | |
Returns : |
int gnutls_x509_crt_get_signature_algorithm (gnutls_x509_crt_t cert);
This function will return a value of the gnutls_sign_algorithm_t enumeration that is the signature algorithm.
cert : | |
Returns : |
int gnutls_x509_crt_get_version (gnutls_x509_crt_t cert);
This function will return the version of the specified Certificate.
cert : | |
Returns : |
int gnutls_x509_crt_get_key_id (gnutls_x509_crt_t crt, unsigned int flags, unsigned char *output_data, size_t *output_data_size);
This function will return a unique ID the 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 GNUTLS_E_SHORT_MEMORY_BUFFER will be returned. The output will normally be a SHA-1 hash output, which is 20 bytes.
In case of failure a negative value will be returned, and 0 on success.
crt : | |
flags : | |
output_data : | |
output_data_size : | |
Returns : |
int gnutls_x509_crt_set_authority_key_id (gnutls_x509_crt_t cert, const void *id, size_t id_size);
This function will set the X.509 certificate's authority key ID extension. Only the keyIdentifier field can be set with this function.
cert : | |
id : | |
id_size : | |
Returns : |
int gnutls_x509_crt_get_authority_key_id (gnutls_x509_crt_t cert, void *ret, size_t *ret_size, unsigned int *critical);
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.
cert : | |
ret : | |
ret_size : | |
critical : | |
Returns : |
int gnutls_x509_crt_get_subject_key_id (gnutls_x509_crt_t cert, void *ret, size_t *ret_size, unsigned int *critical);
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).
cert : | |
ret : | |
ret_size : | |
critical : | |
Returns : |
int gnutls_x509_crt_get_crl_dist_points (gnutls_x509_crt_t cert, unsigned int seq, void *ret, size_t *ret_size, unsigned int *reason_flags, unsigned int *critical);
This function will return the CRL distribution points (2.5.29.31), contained in the given certificate.
reason_flags should be an ORed sequence of GNUTLS_CRL_REASON_UNUSED, GNUTLS_CRL_REASON_KEY_COMPROMISE, GNUTLS_CRL_REASON_CA_COMPROMISE, GNUTLS_CRL_REASON_AFFILIATION_CHANGED, GNUTLS_CRL_REASON_SUPERSEEDED, GNUTLS_CRL_REASON_CESSATION_OF_OPERATION, GNUTLS_CRL_REASON_CERTIFICATE_HOLD, GNUTLS_CRL_REASON_PRIVILEGE_WITHDRAWN, GNUTLS_CRL_REASON_AA_COMPROMISE, or zero for all possible reasons.
This is specified in X509v3 Certificate Extensions. GNUTLS will return the distribution point type, or a negative error code on error.
cert : | |
seq : | |
ret : | |
ret_size : | |
reason_flags : | |
critical : | |
Returns : |
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);
This function will set the CRL distribution points certificate extension.
crt : | |
type : | |
data_string : | |
reason_flags : | |
Returns : |
int gnutls_x509_crt_cpy_crl_dist_points (gnutls_x509_crt_t dst, gnutls_x509_crt_t src);
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.
dst : | |
src : | |
Returns : |
time_t gnutls_x509_crt_get_activation_time (gnutls_x509_crt_t cert);
This function will return the time this Certificate was or will be activated.
cert : | |
Returns : |
time_t gnutls_x509_crt_get_expiration_time (gnutls_x509_crt_t cert);
This function will return the time this Certificate was or will be expired.
cert : | |
Returns : |
int gnutls_x509_crt_get_serial (gnutls_x509_crt_t cert, void *result, size_t *result_size);
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 opaque.
cert : | |
result : | |
result_size : | |
Returns : |
int gnutls_x509_crt_get_pk_algorithm (gnutls_x509_crt_t cert, unsigned int *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.
cert : | |
bits : | |
Returns : |
int gnutls_x509_crt_get_pk_rsa_raw (gnutls_x509_crt_t crt, gnutls_datum_t *m, gnutls_datum_t *e);
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.
crt : | |
m : | |
e : | |
Returns : |
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);
This function will export the DSA private 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.
crt : | |
p : | |
q : | |
g : | |
y : | |
Returns : |
int gnutls_x509_crt_get_subject_alt_name (gnutls_x509_crt_t cert, unsigned int seq, void *ret, size_t *ret_size, unsigned int *critical);
This function will return the alternative names, contained in the given certificate.
This is specified in X509v3 Certificate Extensions. GNUTLS will return the Alternative name (2.5.29.17), or a negative error code.
cert : | |
seq : | |
ret : | |
ret_size : | |
critical : | |
Returns : |
int gnutls_x509_crt_get_ca_status (gnutls_x509_crt_t cert, unsigned int *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 zero if the certificate does not have CA flag set.
A negative value may be returned in case of parsing error. If the certificate does not contain the basicConstraints extension GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
cert : | |
critical : | |
Returns : |
int gnutls_x509_crt_get_key_usage (gnutls_x509_crt_t cert, unsigned int *key_usage, unsigned int *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.
A negative value may be returned in case of parsing error. If the certificate does not contain the keyUsage extension GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
cert : | |
key_usage : | |
critical : | |
Returns : |
int gnutls_x509_crt_set_key_usage (gnutls_x509_crt_t crt, unsigned int usage);
This function will set the keyUsage certificate extension.
crt : | |
usage : | |
Returns : |
int gnutls_x509_dn_oid_known (const char *oid);
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.
oid : | |
Returns : |
int gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert, int indx, void *oid, size_t *sizeof_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.
A negative value may be returned in case of parsing error. If your have reached the last extension available GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
cert : | |
indx : | |
oid : | |
sizeof_oid : | |
Returns : |
int gnutls_x509_crt_get_extension_by_oid (gnutls_x509_crt_t cert, const char *oid, int indx, void *buf, size_t *sizeof_buf, unsigned int *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.
A negative value may be returned in case of parsing error. If the certificate does not contain the specified extension GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
cert : | |
oid : | |
indx : | |
buf : | |
sizeof_buf : | |
critical : | |
Returns : |
int gnutls_x509_crt_to_xml (gnutls_x509_crt_t cert, gnutls_datum_t *res, int detail);
This function will return the XML structures of the given X.509 certificate. The XML structures are allocated internally (with malloc) and stored into res.
cert : | |
res : | |
detail : | |
Returns : |
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);
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.
crt : | |
oid : | |
raw_flag : | |
name : | |
sizeof_name : | |
Returns : |
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);
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.
crt : | |
oid : | |
raw_flag : | |
name : | |
sizeof_name : | |
Returns : |
int gnutls_x509_crt_set_version (gnutls_x509_crt_t crt, unsigned int version);
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.
crt : | |
version : | |
Returns : |
int gnutls_x509_crt_set_key (gnutls_x509_crt_t crt, gnutls_x509_privkey_t key);
This function will set the public parameters from the given private key to the certificate. Only RSA keys are currently supported.
crt : | |
key : | |
Returns : |
int gnutls_x509_crt_set_ca_status (gnutls_x509_crt_t crt, unsigned int ca);
This function will set the basicConstraints certificate extension.
crt : | |
ca : | |
Returns : |
int gnutls_x509_crt_set_subject_alternative_name (gnutls_x509_crt_t crt, gnutls_x509_subject_alt_name_t type, const char *data_string);
This function will set the subject alternative name certificate extension.
crt : | |
type : | |
data_string : | |
Returns : |
int gnutls_x509_crt_sign (gnutls_x509_crt_t crt, gnutls_x509_crt_t issuer, gnutls_x509_privkey_t issuer_key);
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.
crt : | |
issuer : | |
issuer_key : | |
Returns : |
int gnutls_x509_crt_set_activation_time (gnutls_x509_crt_t cert, time_t act_time);
This function will set the time this Certificate was or will be activated.
cert : | |
act_time : | |
Returns : |
int gnutls_x509_crt_set_expiration_time (gnutls_x509_crt_t cert, time_t exp_time);
This function will set the time this Certificate will expire.
cert : | |
exp_time : | |
Returns : |
int gnutls_x509_crt_set_serial (gnutls_x509_crt_t cert, const void *serial, size_t serial_size);
This function will set the X.509 certificate's serial number. 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 opaque.
cert : | |
serial : | |
serial_size : | |
Returns : |
int gnutls_x509_crt_set_subject_key_id (gnutls_x509_crt_t cert, const void *id, size_t id_size);
This function will set the X.509 certificate's subject key ID extension.
cert : | |
id : | |
id_size : | |
Returns : |
int gnutls_x509_rdn_get (const gnutls_datum_t *idn, char *buf, size_t *sizeof_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 RFC2253.
idn : | |
buf : | |
sizeof_buf : | |
Returns : |
int gnutls_x509_rdn_get_oid (const gnutls_datum_t *idn, int indx, void *buf, size_t *sizeof_buf);
This function will return the specified Object identifier, of the RDN sequence.
idn : | |
indx : | |
buf : | |
sizeof_buf : | |
Returns : |
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 *sizeof_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 RFC2253.
idn : | |
oid : | |
indx : | |
raw_flag : | |
buf : | |
sizeof_buf : | |
Returns : |
int gnutls_x509_crl_init (gnutls_x509_crl_t *crl);
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.
crl : | |
Returns : |
void gnutls_x509_crl_deinit (gnutls_x509_crl_t crl);
This function will deinitialize a CRL structure.
crl : |
int gnutls_x509_crl_import (gnutls_x509_crl_t crl, const gnutls_datum_t *data, gnutls_x509_crt_fmt_t format);
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".
crl : | |
data : | |
format : | |
Returns : |
int gnutls_x509_crl_export (gnutls_x509_crl_t crl, gnutls_x509_crt_fmt_t format, void *output_data, size_t *output_data_size);
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".
crl : | |
format : | |
output_data : | |
output_data_size : | |
Returns : |
int gnutls_x509_crl_get_issuer_dn (const gnutls_x509_crl_t crl, char *buf, size_t *sizeof_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 RFC2253. 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.
crl : | |
buf : | |
sizeof_buf : | |
Returns : |
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);
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 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 zero, 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().
If buf is null then only the size will be filled.
crl : | |
oid : | |
indx : | |
raw_flag : | |
buf : | |
sizeof_buf : | |
Returns : |
int gnutls_x509_crl_get_dn_oid (gnutls_x509_crl_t crl, int indx, void *oid, size_t *sizeof_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.
crl : | |
indx : | |
oid : | |
sizeof_oid : | |
Returns : |
int gnutls_x509_crl_get_signature_algorithm (gnutls_x509_crl_t crl);
This function will return a value of the gnutls_sign_algorithm_t enumeration that is the signature algorithm.
crl : | |
Returns : |
int gnutls_x509_crl_get_version (gnutls_x509_crl_t crl);
This function will return the version of the specified CRL.
crl : | |
Returns : |
time_t gnutls_x509_crl_get_this_update (gnutls_x509_crl_t crl);
This function will return the time this CRL was issued.
crl : | |
Returns : |
time_t gnutls_x509_crl_get_next_update (gnutls_x509_crl_t crl);
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.
crl : | |
Returns : |
int gnutls_x509_crl_get_crt_count (gnutls_x509_crl_t crl);
This function will return the number of revoked certificates in the given CRL.
crl : | |
Returns : |
int gnutls_x509_crl_get_crt_serial (gnutls_x509_crl_t crl, int index, unsigned char *serial, size_t *serial_size, time_t *time);
This function will return the serial number of the specified, by the index, revoked certificate.
crl : | |
index : | |
serial : | |
serial_size : | |
time : | |
Returns : |
#define gnutls_x509_crl_get_certificate_count gnutls_x509_crl_get_crt_count
#define gnutls_x509_crl_get_certificate gnutls_x509_crl_get_crt_serial
int gnutls_x509_crl_check_issuer (gnutls_x509_crl_t crl, gnutls_x509_crt_t issuer);
This function will check if the given CRL was issued by the given issuer certificate. It will return true (1) if the given CRL was issued by the given issuer, and false (0) if not.
A negative value is returned in case of an error.
crl : | |
issuer : | |
Returns : |
int gnutls_x509_crl_set_version (gnutls_x509_crl_t crl, unsigned int version);
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.
crl : | |
version : | |
Returns : |
int gnutls_x509_crl_sign (gnutls_x509_crl_t crl, gnutls_x509_crt_t issuer, gnutls_x509_privkey_t issuer_key);
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.
crl : | |
issuer : | |
issuer_key : | |
Returns : |
int gnutls_x509_crl_set_this_update (gnutls_x509_crl_t crl, time_t act_time);
This function will set the time this CRL was issued.
crl : | |
act_time : | |
Returns : |
int gnutls_x509_crl_set_next_update (gnutls_x509_crl_t crl, time_t exp_time);
This function will set the time this CRL will be updated.
crl : | |
exp_time : | |
Returns : |
int gnutls_x509_crl_set_crt_serial (gnutls_x509_crl_t crl, const void *serial, size_t serial_size, time_t revocation_time);
This function will set a revoked certificate's serial number to the CRL.
crl : | |
serial : | |
serial_size : | |
revocation_time : | |
Returns : |
int gnutls_x509_crl_set_crt (gnutls_x509_crl_t crl, gnutls_x509_crt_t crt, time_t revocation_time);
This function will set a revoked certificate's serial number to the CRL.
crl : | |
crt : | |
revocation_time : | |
Returns : |
int gnutls_pkcs7_init (gnutls_pkcs7_t *pkcs7);
This function will initialize a PKCS7 structure. PKCS7 structures usually contain lists of X.509 Certificates and X.509 Certificate revocation lists.
pkcs7 : | |
Returns : |
void gnutls_pkcs7_deinit (gnutls_pkcs7_t pkcs7);
This function will deinitialize a PKCS7 structure.
pkcs7 : |
int gnutls_pkcs7_import (gnutls_pkcs7_t pkcs7, const gnutls_datum_t *data, gnutls_x509_crt_fmt_t format);
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".
pkcs7 : | |
data : | |
format : | |
Returns : |
int gnutls_pkcs7_export (gnutls_pkcs7_t pkcs7, gnutls_x509_crt_fmt_t format, void *output_data, size_t *output_data_size);
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 GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.
If the structure is PEM encoded, it will have a header of "BEGIN PKCS7".
In case of failure a negative value will be returned, and 0 on success.
pkcs7 : | |
format : | |
output_data : | |
output_data_size : | |
Returns : |
int gnutls_pkcs7_get_crt_count (gnutls_pkcs7_t pkcs7);
This function will return the number of certifcates in the PKCS7 or RFC2630 certificate set.
pkcs7 : | |
Returns : |
int gnutls_pkcs7_get_crt_raw (gnutls_pkcs7_t pkcs7, int indx, void *certificate, size_t *certificate_size);
This function will return a certificate of the PKCS7 or RFC2630 certificate set.
pkcs7 : | |
indx : | |
certificate : | |
certificate_size : | |
Returns : |
int gnutls_pkcs7_set_crt_raw (gnutls_pkcs7_t pkcs7, const gnutls_datum_t *crt);
This function will add a certificate to the PKCS7 or RFC2630 certificate set.
pkcs7 : | |
crt : | |
Returns : |
int gnutls_pkcs7_set_crt (gnutls_pkcs7_t pkcs7, gnutls_x509_crt_t crt);
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() .
pkcs7 : | |
crt : | |
Returns : |
int gnutls_pkcs7_delete_crt (gnutls_pkcs7_t pkcs7, int indx);
This function will delete a certificate from a PKCS7 or RFC2630 certificate set. Index starts from 0. Returns 0 on success.
pkcs7 : | |
indx : | |
Returns : |
int gnutls_pkcs7_get_crl_raw (gnutls_pkcs7_t pkcs7, int indx, void *crl, size_t *crl_size);
This function will return a crl of the PKCS7 or RFC2630 crl set.
pkcs7 : | |
indx : | |
crl : | |
crl_size : | |
Returns : |
int gnutls_pkcs7_get_crl_count (gnutls_pkcs7_t pkcs7);
This function will return the number of certifcates in the PKCS7 or RFC2630 crl set.
pkcs7 : | |
Returns : |
int gnutls_pkcs7_set_crl_raw (gnutls_pkcs7_t pkcs7, const gnutls_datum_t *crt);
This function will add a crl to the PKCS7 or RFC2630 crl set.
pkcs7 : | |
crt : | |
Returns : |
int gnutls_pkcs7_set_crl (gnutls_pkcs7_t pkcs7, gnutls_x509_crl_t crl);
This function will add a parsed crl to the PKCS7 or RFC2630 crl set.
pkcs7 : | |
crl : | |
Returns : |
int gnutls_pkcs7_delete_crl (gnutls_pkcs7_t pkcs7, int indx);
This function will delete a crl from a PKCS7 or RFC2630 crl set. Index starts from 0. Returns 0 on success.
pkcs7 : | |
indx : | |
Returns : |
typedef enum gnutls_certificate_verify_flags { GNUTLS_VERIFY_DISABLE_CA_SIGN=1, /* if set a signer does not have to be * a certificate authority. */ GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT=2,/* Allow CA certificates that have version 1. * This might be dangerous since those haven't * the basicConstraints extension. */ GNUTLS_VERIFY_DO_NOT_ALLOW_SAME=4 /* If a certificate is not signed by anyone * trusted but exists in the trusted ca list * do not treat it as trusted. */ } gnutls_certificate_verify_flags;
int gnutls_x509_crt_check_issuer (gnutls_x509_crt_t cert, gnutls_x509_crt_t issuer);
This function will check if the given certificate was issued by the given issuer. It will return true (1) if the given certificate is issued by the given issuer, and false (0) if not.
A negative value is returned in case of an error.
cert : | |
issuer : | |
Returns : |
int gnutls_x509_crt_list_verify (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);
This function will try to verify the given certificate list and return its status. Note that expiration and activation dates are not checked by this function, you should check them using the appropriate functions.
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.
GNUTLS_CERT_INVALID\: the certificate chain is not valid.
GNUTLS_CERT_REVOKED\: a certificate in the chain has been revoked.
cert_list : | |
cert_list_length : | |
CA_list : | |
CA_list_length : | |
CRL_list : | |
CRL_list_length : | |
flags : | |
verify : | |
Returns : |
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);
This function will try to verify the given certificate and return its status. The verification output in this functions cannot be GNUTLS_CERT_NOT_VALID.
cert : | |
CA_list : | |
CA_list_length : | |
flags : | |
verify : | |
Returns : |
int gnutls_x509_crl_verify (gnutls_x509_crl_t crl, const gnutls_x509_crt_t *CA_list, int CA_list_length, unsigned int flags, unsigned int *verify);
This function will try to verify the given crl and return its status. See gnutls_x509_crt_list_verify() for a detailed description of return values.
crl : | |
CA_list : | |
CA_list_length : | |
flags : | |
verify : | |
Returns : |
int gnutls_x509_crt_check_revocation (gnutls_x509_crt_t cert, const gnutls_x509_crl_t *crl_list, int crl_list_length);
This function will return check if the given certificate is revoked. It is assumed that the CRLs have been verified before.
cert : | |
crl_list : | |
crl_list_length : | |
Returns : |
int gnutls_x509_crt_get_fingerprint (gnutls_x509_crt_t cert, gnutls_digest_algorithm_t algo, void *buf, size_t *sizeof_buf);
This function will calculate and copy the certificate's fingerprint in the provided buffer.
If the buffer is null then only the size will be filled.
cert : | |
algo : | |
buf : | |
sizeof_buf : | |
Returns : |
int gnutls_x509_crt_get_key_purpose_oid (gnutls_x509_crt_t cert, int indx, void *oid, size_t *sizeof_oid, unsigned int *critical);
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.
cert : | |
indx : | |
oid : | |
sizeof_oid : | |
critical : | |
Returns : |
int gnutls_x509_crt_set_key_purpose_oid (gnutls_x509_crt_t cert, const void *oid, unsigned int critical);
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.
On success 0 is returned.
cert : | |
oid : | |
critical : | |
Returns : |
typedef enum gnutls_pkcs_encrypt_flags_t { GNUTLS_PKCS_PLAIN=1, /* if set the private key will not * be encrypted. */ GNUTLS_PKCS_USE_PKCS12_3DES=2, GNUTLS_PKCS_USE_PKCS12_ARCFOUR=4, GNUTLS_PKCS_USE_PKCS12_RC2_40=8, GNUTLS_PKCS_USE_PBES2_3DES=16 } gnutls_pkcs_encrypt_flags_t;
#define GNUTLS_PKCS8_USE_PKCS12_ARCFOUR GNUTLS_PKCS_USE_PKCS12_ARCFOUR
int gnutls_x509_privkey_init (gnutls_x509_privkey_t *key);
This function will initialize an private key structure.
key : | |
Returns : |
void gnutls_x509_privkey_deinit (gnutls_x509_privkey_t key);
This function will deinitialize a private key structure.
key : |
int gnutls_x509_privkey_cpy (gnutls_x509_privkey_t dst, gnutls_x509_privkey_t src);
This function will copy a private key from source to destination key.
dst : | |
src : | |
Returns : |
int gnutls_x509_privkey_import (gnutls_x509_privkey_t key, const gnutls_datum_t *data, gnutls_x509_crt_fmt_t format);
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 of "RSA PRIVATE KEY", or "DSA PRIVATE KEY".
key : | |
data : | |
format : | |
Returns : |
int gnutls_x509_privkey_import_pkcs8 (gnutls_x509_privkey_t key, const gnutls_datum_t *data, gnutls_x509_crt_fmt_t format, const char *pass, unsigned int flags);
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. Currently only RSA 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.
key : | |
data : | |
format : | |
pass : | |
flags : | |
Returns : |
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);
This function will convert the given RSA raw parameters to the native gnutls_x509_privkey_t format. The output will be stored in key.
key : | |
m : | |
e : | |
d : | |
p : | |
q : | |
u : | |
Returns : |
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);
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.
key : | |
p : | |
q : | |
g : | |
y : | |
x : | |
Returns : |
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);
This function will convert the given DSA raw parameters to the native gnutls_x509_privkey_t format. The output will be stored in key.
key : | |
p : | |
q : | |
g : | |
y : | |
x : | |
Returns : |
int gnutls_x509_privkey_get_pk_algorithm (gnutls_x509_privkey_t key);
This function will return the public key algorithm of a private key.
key : | |
Returns : |
int gnutls_x509_privkey_get_key_id (gnutls_x509_privkey_t key, unsigned int flags, unsigned char *output_data, size_t *output_data_size);
This function will return a unique ID the 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 GNUTLS_E_SHORT_MEMORY_BUFFER will be returned. The output will normally be a SHA-1 hash output, which is 20 bytes.
In case of failure a negative value will be returned, and 0 on success.
key : | |
flags : | |
output_data : | |
output_data_size : | |
Returns : |
int gnutls_x509_privkey_generate (gnutls_x509_privkey_t key, gnutls_pk_algorithm_t algo, unsigned int bits, unsigned int flags);
This function will generate a random private key. Note that this function must be called on an empty private key.
key : | |
algo : | |
bits : | |
flags : | |
Returns : |
int gnutls_x509_privkey_export (gnutls_x509_privkey_t key, gnutls_x509_crt_fmt_t format, void *output_data, size_t *output_data_size);
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 GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.
If the structure is PEM encoded, it will have a header of "BEGIN RSA PRIVATE KEY".
In case of failure a negative value will be returned, and 0 on success.
key : | |
format : | |
output_data : | |
output_data_size : | |
Returns : |
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);
This function will export the private key to a PKCS8 structure. Currently only RSA keys can be exported. 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 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.
In case of failure a negative value will be returned, and 0 on success.
key : | |
format : | |
password : | |
flags : | |
output_data : | |
output_data_size : | |
Returns : |
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);
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.
key : | |
m : | |
e : | |
d : | |
p : | |
q : | |
u : | |
Returns : |
int gnutls_x509_privkey_sign_data (gnutls_x509_privkey_t key, gnutls_digest_algorithm_t digest, unsigned int flags, const gnutls_datum_t *data, void *signature, size_t *signature_size);
This function will sign the given data using a signature algorithm supported by the private key. Signature algorithms are always used together with a hash functions. Different hash functions may be used for the RSA algorithm, but only SHA-1 for the DSA keys.
If the buffer provided is not long enough to hold the output, then GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.
In case of failure a negative value will be returned, and 0 on success.
key : | |
digest : | |
flags : | |
data : | |
signature : | |
signature_size : | |
Returns : |
int gnutls_x509_privkey_verify_data (gnutls_x509_privkey_t key, unsigned int flags, const gnutls_datum_t *data, const gnutls_datum_t *signature);
This function will verify the given signed data, using the parameters in the private key.
In case of a verification failure 0 is returned, and 1 on success.
key : | |
flags : | |
data : | |
signature : | |
Returns : |
int gnutls_x509_crt_verify_data (gnutls_x509_crt_t crt, unsigned int flags, const gnutls_datum_t *data, const gnutls_datum_t *signature);
This function will verify the given signed data, using the parameters from the certificate.
In case of a verification failure 0 is returned, and 1 on success.
crt : | |
flags : | |
data : | |
signature : | |
Returns : |
int gnutls_x509_crq_init (gnutls_x509_crq_t *crq);
This function will initialize a PKCS10 certificate request structure.
crq : | |
Returns : |
void gnutls_x509_crq_deinit (gnutls_x509_crq_t crq);
This function will deinitialize a CRL structure.
crq : |
int gnutls_x509_crq_import (gnutls_x509_crq_t crq, const gnutls_datum_t *data, gnutls_x509_crt_fmt_t format);
This function will convert the given DER or PEM encoded Certificate to the native gnutls_x509_crq_t format. The output will be stored in cert.
If the Certificate is PEM encoded it should have a header of "NEW CERTIFICATE REQUEST".
crq : | |
data : | |
format : | |
Returns : |
int gnutls_x509_crq_get_pk_algorithm (gnutls_x509_crq_t crq, unsigned int *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.
crq : | |
bits : | |
Returns : |
int gnutls_x509_crq_get_dn (gnutls_x509_crq_t crq, char *buf, size_t *sizeof_buf);
This function will copy the name of the Certificate request subject in the provided buffer. The name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in RFC2253. 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.
crq : | |
buf : | |
sizeof_buf : | |
Returns : |
int gnutls_x509_crq_get_dn_oid (gnutls_x509_crq_t crq, int indx, void *oid, size_t *sizeof_oid);
This function will extract the requested OID of the name of the Certificate request subject, specified by the given index.
If oid is null then only the size will be filled.
crq : | |
indx : | |
oid : | |
sizeof_oid : | |
Returns : |
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 *sizeof_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 zero, 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().
If buf is null then only the size will be filled.
crq : | |
oid : | |
indx : | |
raw_flag : | |
buf : | |
sizeof_buf : | |
Returns : |
int gnutls_x509_crq_set_dn_by_oid (gnutls_x509_crq_t crq, const char *oid, unsigned int raw_flag, const void *name, unsigned int sizeof_name);
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.
crq : | |
oid : | |
raw_flag : | |
name : | |
sizeof_name : | |
Returns : |
int gnutls_x509_crq_set_version (gnutls_x509_crq_t crq, unsigned int version);
This function will set the version of the certificate request. For version 1 requests this must be one.
crq : | |
version : | |
Returns : |
int gnutls_x509_crq_set_key (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key);
This function will set the public parameters from the given private key to the request. Only RSA keys are currently supported.
crq : | |
key : | |
Returns : |
int gnutls_x509_crq_sign (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key);
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.
crq : | |
key : | |
Returns : |
int gnutls_x509_crq_set_challenge_password (gnutls_x509_crq_t crq, const char *pass);
This function will set a challenge password to be used when revoking the request.
crq : | |
pass : | |
Returns : |
int gnutls_x509_crq_get_challenge_password (gnutls_x509_crq_t crq, const char *pass, size_t *sizeof_pass);
This function will return the challenge password in the request.
crq : | |
pass : | |
sizeof_pass : | |
Returns : |
int gnutls_x509_crq_export (gnutls_x509_crq_t crq, gnutls_x509_crt_fmt_t format, void *output_data, size_t *output_data_size);
This function will export the certificate request to a PKCS10
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 NEW CERTIFICATE REQUEST".
In case of failure a negative value will be returned, and 0 on success.
crq : | |
format : | |
output_data : | |
output_data_size : | |
Returns : |
<< extra | pkcs12 >> |