GnuTLS API Reference Manual | ||||
---|---|---|---|---|
Top | Description |
#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_X520_POSTALCODE #define GNUTLS_OID_X520_NAME #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 #define GNUTLS_FSAN_SET #define GNUTLS_FSAN_APPEND enum gnutls_certificate_import_flags; 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_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
); 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 *buf_size
); int gnutls_x509_crt_get_issuer_dn_oid (gnutls_x509_crt_t cert
,int indx
,void *oid
,size_t *oid_size
); 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
); int gnutls_x509_crt_get_dn (gnutls_x509_crt_t cert
,char *buf
,size_t *buf_size
); int gnutls_x509_crt_get_dn_oid (gnutls_x509_crt_t cert
,int indx
,void *oid
,size_t *oid_size
); 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
); 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_signature (gnutls_x509_crt_t cert
,char *sig
,size_t *sizeof_sig
); 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 *id
,size_t *id_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_SUPERSEEDED 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_points2 (gnutls_x509_crt_t crt
,gnutls_x509_subject_alt_name_t type
,const void *data
,unsigned int data_size
,unsigned int reason_flags
); 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 *san
,size_t *san_size
,unsigned int *critical
); 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
); int gnutls_x509_crt_get_subject_alt_othername_oid (gnutls_x509_crt_t cert
,unsigned int seq
,void *oid
,size_t *oid_size
); 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
); 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
); int gnutls_x509_crt_get_issuer_alt_othername_oid (gnutls_x509_crt_t cert
,unsigned int seq
,void *ret
,size_t *ret_size
); int gnutls_x509_crt_get_ca_status (gnutls_x509_crt_t cert
,unsigned int *critical
); int gnutls_x509_crt_get_basic_constraints (gnutls_x509_crt_t cert
,unsigned int *critical
,unsigned int *ca
,int *pathlen
); 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_crt_get_proxy (gnutls_x509_crt_t cert
,unsigned int *critical
,int *pathlen
,char **policyLanguage
,char **policy
,size_t *sizeof_policy
); 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 *oid_size
); 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
); int gnutls_x509_crt_get_extension_info (gnutls_x509_crt_t cert
,int indx
,void *oid
,size_t *oid_size
,unsigned int *critical
); int gnutls_x509_crt_get_extension_data (gnutls_x509_crt_t cert
,int indx
,void *data
,size_t *sizeof_data
); 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
); 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_basic_constraints (gnutls_x509_crt_t crt
,unsigned int ca
,int pathLenConstraint
); 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_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
); 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_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
); 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_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
); int gnutls_x509_crt_set_proxy (gnutls_x509_crt_t crt
,int pathLenConstraint
,const char *policyLanguage
,const char *policy
,size_t sizeof_policy
); int gnutls_x509_crt_print (gnutls_x509_crt_t cert
,gnutls_certificate_print_formats_t format
,gnutls_datum_t *out
); int gnutls_x509_crl_print (gnutls_x509_crl_t crl
,gnutls_certificate_print_formats_t format
,gnutls_datum_t *out
); int gnutls_x509_crt_get_raw_issuer_dn (gnutls_x509_crt_t cert
,gnutls_datum_t *start
); int gnutls_x509_crt_get_raw_dn (gnutls_x509_crt_t cert
,gnutls_datum_t *start
); 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
); typedef gnutls_x509_dn_t; int gnutls_x509_crt_get_subject (gnutls_x509_crt_t cert
,gnutls_x509_dn_t *dn
); int gnutls_x509_crt_get_issuer (gnutls_x509_crt_t cert
,gnutls_x509_dn_t *dn
); int gnutls_x509_dn_get_rdn_ava (gnutls_x509_dn_t dn
,int irdn
,int iava
,gnutls_x509_ava_st *ava
); int gnutls_x509_dn_init (gnutls_x509_dn_t *dn
); int gnutls_x509_dn_import (gnutls_x509_dn_t dn
,const gnutls_datum_t *data
); int gnutls_x509_dn_export (gnutls_x509_dn_t dn
,gnutls_x509_crt_fmt_t format
,void *output_data
,size_t *output_data_size
); void gnutls_x509_dn_deinit (gnutls_x509_dn_t dn
); 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_signature (gnutls_x509_crl_t crl
,char *sig
,size_t *sizeof_sig
); 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 indx
,unsigned char *serial
,size_t *serial_size
,time_t *t
); #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_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
); 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
); int gnutls_x509_crl_get_authority_key_id (gnutls_x509_crl_t crl
,void *id
,size_t *id_size
,unsigned int *critical
); int gnutls_x509_crl_get_number (gnutls_x509_crl_t crl
,void *ret
,size_t *ret_size
,unsigned int *critical
); int gnutls_x509_crl_get_extension_oid (gnutls_x509_crl_t crl
,int indx
,void *oid
,size_t *sizeof_oid
); int gnutls_x509_crl_get_extension_info (gnutls_x509_crl_t crl
,int indx
,void *oid
,size_t *sizeof_oid
,unsigned int *critical
); int gnutls_x509_crl_get_extension_data (gnutls_x509_crl_t crl
,int indx
,void *data
,size_t *sizeof_data
); int gnutls_x509_crl_set_authority_key_id (gnutls_x509_crl_t crl
,const void *id
,size_t id_size
); int gnutls_x509_crl_set_number (gnutls_x509_crl_t crl
,const void *nr
,size_t nr_size
); struct gnutls_pkcs7_int; typedef gnutls_pkcs7_t; 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 *crl
); 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 (const gnutls_x509_crt_t *cert_list
,int cert_list_length
,const gnutls_x509_crt_t *CA_list
,int CA_list_length
,const gnutls_x509_crl_t *CRL_list
,int CRL_list_length
,unsigned int flags
,unsigned int *verify
); int gnutls_x509_crt_verify (gnutls_x509_crt_t cert
,const gnutls_x509_crt_t *CA_list
,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 *buf_size
); int gnutls_x509_crt_get_key_purpose_oid (gnutls_x509_crt_t cert
,int indx
,void *oid
,size_t *oid_size
,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; 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 *password
,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_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
); int gnutls_x509_privkey_fix (gnutls_x509_privkey_t key
); 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_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
); 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
); struct gnutls_x509_crq_int; typedef gnutls_x509_crq_t; int gnutls_x509_crq_print (gnutls_x509_crq_t crq
,gnutls_certificate_print_formats_t format
,gnutls_datum_t *out
); 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_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 *data
,unsigned int sizeof_data
); int gnutls_x509_crq_set_version (gnutls_x509_crq_t crq
,unsigned int version
); int gnutls_x509_crq_get_version (gnutls_x509_crq_t crq
); int gnutls_x509_crq_set_key (gnutls_x509_crq_t crq
,gnutls_x509_privkey_t key
); int gnutls_x509_crq_sign2 (gnutls_x509_crq_t crq
,gnutls_x509_privkey_t key
,gnutls_digest_algorithm_t dig
,unsigned int flags
); 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
,char *pass
,size_t *sizeof_pass
); int gnutls_x509_crq_set_attribute_by_oid (gnutls_x509_crq_t crq
,const char *oid
,void *buf
,size_t sizeof_buf
); int gnutls_x509_crq_get_attribute_by_oid (gnutls_x509_crq_t crq
,const char *oid
,int indx
,void *buf
,size_t *sizeof_buf
); 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
); int gnutls_x509_crt_set_crq_extensions (gnutls_x509_crt_t crt
,gnutls_x509_crq_t crq
); int gnutls_x509_crq_set_key_rsa_raw (gnutls_x509_crq_t crq
,const gnutls_datum_t *m
,const gnutls_datum_t *e
); 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
); int gnutls_x509_crq_set_key_usage (gnutls_x509_crq_t crq
,unsigned int usage
); int gnutls_x509_crq_set_basic_constraints (gnutls_x509_crq_t crq
,unsigned int ca
,int pathLenConstraint
); int gnutls_x509_crq_set_key_purpose_oid (gnutls_x509_crq_t crq
,const void *oid
,unsigned int critical
); int gnutls_x509_crq_get_key_purpose_oid (gnutls_x509_crq_t crq
,int indx
,void *oid
,size_t *sizeof_oid
,unsigned int *critical
); int gnutls_x509_crq_get_extension_data (gnutls_x509_crq_t crq
,int indx
,void *data
,size_t *sizeof_data
); int gnutls_x509_crq_get_extension_info (gnutls_x509_crq_t crq
,int indx
,void *oid
,size_t *sizeof_oid
,unsigned int *critical
); int gnutls_x509_crq_get_attribute_data (gnutls_x509_crq_t crq
,int indx
,void *data
,size_t *sizeof_data
); int gnutls_x509_crq_get_attribute_info (gnutls_x509_crq_t crq
,int indx
,void *oid
,size_t *sizeof_oid
); int gnutls_x509_crq_get_pk_algorithm (gnutls_x509_crq_t crq
,unsigned int *bits
); int gnutls_x509_crq_get_key_id (gnutls_x509_crq_t crq
,unsigned int flags
,unsigned char *output_data
,size_t *output_data_size
); int gnutls_x509_crq_get_key_rsa_raw (gnutls_x509_crq_t crq
,gnutls_datum_t *m
,gnutls_datum_t *e
); int gnutls_x509_crq_get_key_usage (gnutls_x509_crq_t crq
,unsigned int *key_usage
,unsigned int *critical
); int gnutls_x509_crq_get_basic_constraints (gnutls_x509_crq_t crq
,unsigned int *critical
,unsigned int *ca
,int *pathlen
); 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
); int gnutls_x509_crq_get_subject_alt_othername_oid (gnutls_x509_crq_t crq
,unsigned int seq
,void *ret
,size_t *ret_size
); int gnutls_x509_crq_get_extension_by_oid (gnutls_x509_crq_t crq
,const char *oid
,int indx
,void *buf
,size_t *sizeof_buf
,unsigned int *critical
);
#define GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME "2.5.4.11"
#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"
typedef enum { GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED = 1, GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED = 2 } gnutls_certificate_import_flags;
Enumeration of different certificate import flags.
Fail if the
certificates in the buffer are more than the space allocated for
certificates. The error code will be GNUTLS_E_SHORT_MEMORY_BUFFER .
|
|
Fail if the certificates
in the buffer are not ordered starting from subject to issuer.
The error code will be GNUTLS_E_CERTIFICATE_LIST_UNSORTED .
|
int gnutls_x509_crt_init (gnutls_x509_crt_t *cert
);
This function will initialize an X.509 certificate structure.
|
The structure to be initialized |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
void gnutls_x509_crt_deinit (gnutls_x509_crt_t cert
);
This function will deinitialize a certificate structure.
|
The structure to be deinitialized |
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".
|
The structure to store the parsed certificate. |
|
The DER or PEM encoded certificate. |
|
One of DER or PEM |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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
);
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".
|
The structures to store the parsed certificate. Must not be initialized. |
|
Initially must hold the maximum number of certs. It will be updated with the number of certs available. |
|
The PEM encoded certificate. |
|
One of DER or PEM. |
|
must be (0) or an OR'd sequence of gnutls_certificate_import_flags. |
Returns : |
the number of certificates read or a negative error value. |
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 *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".
|
Holds the certificate |
|
the format of output params. One of PEM or DER. |
|
will contain a certificate PEM or DER encoded |
|
holds the size of output_data (and will be replaced by the actual size of parameters) |
Returns : |
In case of failure a negative error code will be returned, and 0 on success. |
int gnutls_x509_crt_get_issuer_dn (gnutls_x509_crt_t cert
,char *buf
,size_t *buf_size
);
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.
|
should contain a gnutls_x509_crt_t structure |
|
a pointer to a structure to hold the name (may be null) |
|
initially holds the size of buf
|
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. |
int gnutls_x509_crt_get_issuer_dn_oid (gnutls_x509_crt_t cert
,int indx
,void *oid
,size_t *oid_size
);
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.
|
should contain a gnutls_x509_crt_t structure |
|
This specifies which OID to return. Use (0) to get the first one. |
|
a pointer to a buffer to hold the OID (may be null) |
|
initially holds the size of oid
|
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. |
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
);
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.
|
should contain a gnutls_x509_crt_t structure |
|
holds an Object Identified in null terminated string |
|
In case multiple same OIDs exist in the RDN, this specifies which to send. Use (0) to get the first one. |
|
If non-zero returns the raw DER data of the DN part. |
|
a pointer to a structure to hold the name (may be null) |
|
initially holds the size of buf
|
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. |
int gnutls_x509_crt_get_dn (gnutls_x509_crt_t cert
,char *buf
,size_t *buf_size
);
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.
|
should contain a gnutls_x509_crt_t structure |
|
a pointer to a structure to hold the name (may be null) |
|
initially holds the size of buf
|
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. |
int gnutls_x509_crt_get_dn_oid (gnutls_x509_crt_t cert
,int indx
,void *oid
,size_t *oid_size
);
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.
|
should contain a gnutls_x509_crt_t structure |
|
This specifies which OID to return. Use (0) to get the first one. |
|
a pointer to a buffer to hold the OID (may be null) |
|
initially holds the size of oid
|
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. |
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
);
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.
|
should contain a gnutls_x509_crt_t structure |
|
holds an Object Identified in null terminated string |
|
In case multiple same OIDs exist in the RDN, this specifies which to send. Use (0) to get the first one. |
|
If non-zero returns the raw DER data of the DN part. |
|
a pointer where the DN part will be copied (may be null). |
|
initially holds the size of buf
|
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. |
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 DNSName/IPAddress subject alternative name PKIX extension.
|
should contain an gnutls_x509_crt_t structure |
|
A null terminated string that contains a DNS name |
Returns : |
non-zero for a successful match, and zero on failure. |
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 that has been used to sign this certificate.
|
should contain a gnutls_x509_crt_t structure |
Returns : |
a gnutls_sign_algorithm_t value, or a negative error code on error. |
int gnutls_x509_crt_get_signature (gnutls_x509_crt_t cert
,char *sig
,size_t *sizeof_sig
);
This function will extract the signature field of a certificate.
|
should contain a gnutls_x509_crt_t structure |
|
a pointer where the signature part will be copied (may be null). |
|
initially holds the size of sig
|
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. and a negative error code on error. |
int gnutls_x509_crt_get_version (gnutls_x509_crt_t cert
);
This function will return the version of the specified Certificate.
|
should contain a gnutls_x509_crt_t structure |
Returns : |
version of certificate, or a negative error code on error. |
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 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.
|
Holds the certificate |
|
should be 0 for now |
|
will contain the key ID |
|
holds the size of output_data (and will be replaced by the actual size of parameters) |
Returns : |
In case of failure a negative error code will be returned, and 0 on success. |
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.
|
a certificate of type gnutls_x509_crt_t |
|
The key ID |
|
Holds the size of the serial field. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_crt_get_authority_key_id (gnutls_x509_crt_t cert
,void *id
,size_t *id_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 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.
|
should contain a gnutls_x509_crt_t structure |
|
The place where the identifier will be copied |
|
Holds the size of the id field. |
|
will be non-zero if the extension is marked as critical (may be null) |
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. |
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).
|
should contain a gnutls_x509_crt_t structure |
|
The place where the identifier will be copied |
|
Holds the size of the result field. |
|
will be non-zero if the extension is marked as critical (may be null) |
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. |
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 retrieves the CRL distribution points (2.5.29.31), contained in the given certificate in the X509v3 Certificate Extensions.
|
should contain a gnutls_x509_crt_t structure |
|
specifies the sequence number of the distribution point (0 for the first one, 1 for the second etc.) |
|
is the place where the distribution point will be copied to |
|
holds the size of ret. |
|
Revocation reasons. An ORed sequence of flags from gnutls_x509_crl_reason_flags_t . |
|
will be non-zero if the extension is marked as critical (may be null) |
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. |
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
);
This function will set the CRL distribution points certificate extension.
|
a certificate of type gnutls_x509_crt_t |
|
is one of the gnutls_x509_subject_alt_name_t enumerations |
|
The data to be set |
|
The data size |
|
revocation reasons |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
Since 2.6.0
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.
|
a certificate of type gnutls_x509_crt_t |
|
is one of the gnutls_x509_subject_alt_name_t enumerations |
|
The data to be set |
|
revocation reasons |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
a certificate of type gnutls_x509_crt_t |
|
the certificate where the dist points will be copied from |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
should contain a gnutls_x509_crt_t structure |
Returns : |
activation time, or (time_t)-1 on error. |
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.
|
should contain a gnutls_x509_crt_t structure |
Returns : |
expiration time, or (time_t)-1 on error. |
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 uint8_t.
|
should contain a gnutls_x509_crt_t structure |
|
The place where the serial number will be copied |
|
Holds the size of the result field. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
should contain a gnutls_x509_crt_t structure |
|
if bits is non null it will hold the size of the parameters' in bits |
Returns : |
a member of the gnutls_pk_algorithm_t enumeration on success, or a negative error code on error. |
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 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.
|
Holds the certificate |
|
will hold the modulus |
|
will hold the public exponent |
Returns : |
GNUTLS_E_SUCCESS on success, otherwise a negative error code. |
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 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.
|
Holds the certificate |
|
will hold the p |
|
will hold the q |
|
will hold the g |
|
will hold the y |
Returns : |
GNUTLS_E_SUCCESS on success, otherwise a negative error code. |
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
);
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.
|
should contain a gnutls_x509_crt_t structure |
|
specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) |
|
is the place where the alternative name will be copied to |
|
holds the size of san. |
|
will be non-zero if the extension is marked as critical (may be null) |
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. |
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
);
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).
|
should contain a gnutls_x509_crt_t structure |
|
specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) |
|
is the place where the alternative name will be copied to |
|
holds the size of ret. |
|
holds the type of the alternative name (one of gnutls_x509_subject_alt_name_t). |
|
will be non-zero if the extension is marked as critical (may be null) |
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. |
int gnutls_x509_crt_get_subject_alt_othername_oid (gnutls_x509_crt_t cert
,unsigned int seq
,void *oid
,size_t *oid_size
);
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.
|
should contain a gnutls_x509_crt_t structure |
|
specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) |
|
is the place where the otherName OID will be copied to |
|
holds the size of ret. |
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. |
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
);
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.
|
should contain a gnutls_x509_crt_t structure |
|
specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) |
|
is the place where the alternative name will be copied to |
|
holds the size of ian. |
|
will be non-zero if the extension is marked as critical (may be null) |
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
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
);
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).
|
should contain a gnutls_x509_crt_t structure |
|
specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) |
|
is the place where the alternative name will be copied to |
|
holds the size of ret. |
|
holds the type of the alternative name (one of gnutls_x509_subject_alt_name_t). |
|
will be non-zero if the extension is marked as critical (may be null) |
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
int gnutls_x509_crt_get_issuer_alt_othername_oid (gnutls_x509_crt_t cert
,unsigned int seq
,void *ret
,size_t *ret_size
);
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
.
|
should contain a gnutls_x509_crt_t structure |
|
specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) |
|
is the place where the otherName OID will be copied to |
|
holds the size of ret. |
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
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 (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.
|
should contain a gnutls_x509_crt_t structure |
|
will be non-zero if the extension is marked as critical |
Returns : |
A negative error code 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. |
int gnutls_x509_crt_get_basic_constraints (gnutls_x509_crt_t cert
,unsigned int *critical
,unsigned int *ca
,int *pathlen
);
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).
|
should contain a gnutls_x509_crt_t structure |
|
will be non-zero if the extension is marked as critical |
|
pointer to output integer indicating CA status, may be NULL, value is 1 if the certificate CA flag is set, 0 otherwise. |
|
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. |
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. |
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
.
|
should contain a gnutls_x509_crt_t structure |
|
where the key usage bits will be stored |
|
will be non-zero if the extension is marked as critical |
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. |
int gnutls_x509_crt_set_key_usage (gnutls_x509_crt_t crt
,unsigned int usage
);
This function will set the keyUsage certificate extension.
|
a certificate of type gnutls_x509_crt_t |
|
an ORed sequence of the GNUTLS_KEY_* elements. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_crt_get_proxy (gnutls_x509_crt_t cert
,unsigned int *critical
,int *pathlen
,char **policyLanguage
,char **policy
,size_t *sizeof_policy
);
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).
|
should contain a gnutls_x509_crt_t structure |
|
will be non-zero if the extension is marked as critical |
|
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. |
|
output variable with OID of policy language |
|
output variable with policy data |
|
output variable size of policy data |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned,
otherwise a negative error code is returned. |
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.
|
holds an Object Identifier in a null terminated string |
Returns : |
1 on known OIDs and 0 otherwise. |
int gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert
,int indx
,void *oid
,size_t *oid_size
);
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.
|
should contain a gnutls_x509_crt_t structure |
|
Specifies which extension OID to send. Use (0) to get the first one. |
|
a pointer to a structure to hold the OID (may be null) |
|
initially holds the size of 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. |
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
);
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.
|
should contain a gnutls_x509_crt_t structure |
|
holds an Object Identified in null terminated string |
|
In case multiple same OIDs exist in the extensions, this specifies which to send. Use (0) to get the first one. |
|
a pointer to a structure to hold the name (may be null) |
|
initially holds the size of buf
|
|
will be non-zero if the extension is marked as critical |
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. |
int gnutls_x509_crt_get_extension_info (gnutls_x509_crt_t cert
,int indx
,void *oid
,size_t *oid_size
,unsigned int *critical
);
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_data()
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.
|
should contain a gnutls_x509_crt_t structure |
|
Specifies which extension OID to send. Use (0) to get the first one. |
|
a pointer to a structure to hold the OID |
|
initially holds the maximum size of oid , on return
holds actual size of oid . |
|
output variable with critical flag, may be 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. |
int gnutls_x509_crt_get_extension_data (gnutls_x509_crt_t cert
,int indx
,void *data
,size_t *sizeof_data
);
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_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.
|
should contain a gnutls_x509_crt_t structure |
|
Specifies which extension OID to send. Use (0) to get the first one. |
|
a pointer to a structure to hold the data (may be null) |
|
initially holds the size of 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. |
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
);
This function will set an the extension, by the specified OID, in the certificate. The extension data should be binary data DER encoded.
|
a certificate of type gnutls_x509_crt_t |
|
holds an Object Identified in null terminated string |
|
a pointer to a DER encoded data |
|
holds the size of buf
|
|
should be non-zero if the extension is to be marked as critical |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
a certificate of type gnutls_x509_crt_t |
|
holds an Object Identifier in a null terminated string |
|
must be 0, or 1 if the data are DER encoded |
|
a pointer to the name |
|
holds the size of name
|
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
a certificate of type gnutls_x509_crt_t |
|
holds an Object Identifier in a null terminated string |
|
must be 0, or 1 if the data are DER encoded |
|
a pointer to the name |
|
holds the size of name
|
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
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()
.
|
a certificate of type gnutls_x509_crt_t |
|
holds the version number. For X.509v1 certificates must be 1. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
a certificate of type gnutls_x509_crt_t |
|
holds a private key |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_crt_set_ca_status (gnutls_x509_crt_t crt
,unsigned int ca
);
This function will set the basicConstraints certificate extension.
Use gnutls_x509_crt_set_basic_constraints()
if you want to control
the pathLenConstraint field too.
|
a certificate of type gnutls_x509_crt_t |
|
true(1) or false(0). Depending on the Certificate authority status. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_crt_set_basic_constraints (gnutls_x509_crt_t crt
,unsigned int ca
,int pathLenConstraint
);
This function will set the basicConstraints certificate extension.
|
a certificate of type gnutls_x509_crt_t |
|
true(1) or false(0). Depending on the Certificate authority status. |
|
non-negative error codes indicate maximum length of path, and negative error codes indicate that the pathLenConstraints field should not be present. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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. 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()
.
|
a certificate of type gnutls_x509_crt_t |
|
is one of the gnutls_x509_subject_alt_name_t enumerations |
|
The data to be set, a (0) terminated string |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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
);
This function will set the subject alternative name certificate extension. It can set the following types:
GNUTLS_SAN_DNSNAME
: as a text string
GNUTLS_SAN_RFC822NAME
: as a text string
GNUTLS_SAN_URI
: as a text string
GNUTLS_SAN_IPADDRESS
: as a binary IP address (4 or 16 bytes)
Other values can be set as binary values with the proper DER encoding.
|
a certificate of type gnutls_x509_crt_t |
|
is one of the gnutls_x509_subject_alt_name_t enumerations |
|
The data to be set |
|
The size of data to be set |
|
GNUTLS_FSAN_SET to clear previous data or GNUTLS_FSAN_APPEND to append. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
Since 2.6.0
int gnutls_x509_crt_sign (gnutls_x509_crt_t crt
,gnutls_x509_crt_t issuer
,gnutls_x509_privkey_t issuer_key
);
This function is the same a gnutls_x509_crt_sign2()
with no flags,
and SHA1 as the hash algorithm.
|
a certificate of type gnutls_x509_crt_t |
|
is the certificate of the certificate issuer |
|
holds the issuer's private key |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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
);
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.
|
a certificate of type gnutls_x509_crt_t |
|
is the certificate of the certificate issuer |
|
holds the issuer's private key |
|
The message digest to use, GNUTLS_DIG_SHA1 is a safe choice |
|
must be 0 |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
a certificate of type gnutls_x509_crt_t |
|
The actual time |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
a certificate of type gnutls_x509_crt_t |
|
The actual time |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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 uint8_t.
|
a certificate of type gnutls_x509_crt_t |
|
The serial number |
|
Holds the size of the serial field. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
a certificate of type gnutls_x509_crt_t |
|
The key ID |
|
Holds the size of the serial field. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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
);
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.
|
a gnutls_x509_crt_t structure with the new proxy cert |
|
the end entity certificate that will be issuing the proxy |
|
must be 0, or 1 if the CN is DER encoded |
|
a pointer to the CN name, may be NULL (but MUST then be added later) |
|
holds the size of name
|
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_crt_set_proxy (gnutls_x509_crt_t crt
,int pathLenConstraint
,const char *policyLanguage
,const char *policy
,size_t sizeof_policy
);
This function will set the proxyCertInfo extension.
|
a certificate of type gnutls_x509_crt_t |
|
non-negative error codes indicate maximum length of path, and negative error codes indicate that the pathLenConstraints field should not be present. |
|
OID describing the language of policy . |
|
uint8_t byte array with policy language, can be NULL
|
|
size of policy . |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_crt_print (gnutls_x509_crt_t cert
,gnutls_certificate_print_formats_t format
,gnutls_datum_t *out
);
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()
.
|
The structure to be printed |
|
Indicate the format to use |
|
Newly allocated datum with (0) terminated string. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_crl_print (gnutls_x509_crl_t crl
,gnutls_certificate_print_formats_t format
,gnutls_datum_t *out
);
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()
.
|
The structure to be printed |
|
Indicate the format to use |
|
Newly allocated datum with (0) terminated string. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_crt_get_raw_issuer_dn (gnutls_x509_crt_t cert
,gnutls_datum_t *start
);
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()
.
|
should contain a gnutls_x509_crt_t structure |
|
will hold the starting point of the DN |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.or a negative error code on error. |
int gnutls_x509_crt_get_raw_dn (gnutls_x509_crt_t cert
,gnutls_datum_t *start
);
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()
.
|
should contain a gnutls_x509_crt_t structure |
|
will hold the starting point of the DN |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. or a negative error code on error. |
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 RFC4514.
|
should contain a DER encoded RDN sequence |
|
a pointer to a structure to hold the peer's name |
|
holds the size of buf
|
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, or
GNUTLS_E_SHORT_MEMORY_BUFFER is returned and *sizeof_buf is
updated if the provided buffer is not long enough, otherwise a
negative error value. |
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.
|
should contain a DER encoded RDN sequence |
|
Indicates which OID to return. Use 0 for the first one. |
|
a pointer to a structure to hold the peer's name OID |
|
holds the size of buf
|
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, or
GNUTLS_E_SHORT_MEMORY_BUFFER is returned and *sizeof_buf is
updated if the provided buffer is not long enough, otherwise a
negative error value. |
Since 2.4.0
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 RFC4514.
|
should contain a DER encoded RDN sequence |
|
an Object Identifier |
|
In case multiple same OIDs exist in the RDN indicates which to send. Use 0 for the first one. |
|
If non-zero then the raw DER data are returned. |
|
a pointer to a structure to hold the peer's name |
|
holds the size of buf
|
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, or
GNUTLS_E_SHORT_MEMORY_BUFFER is returned and *sizeof_buf is
updated if the provided buffer is not long enough, otherwise a
negative error value. |
int gnutls_x509_crt_get_subject (gnutls_x509_crt_t cert
,gnutls_x509_dn_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.
|
should contain a gnutls_x509_crt_t structure |
|
output variable with pointer to uint8_t DN. |
Returns : |
Returns 0 on success, or an error code. |
int gnutls_x509_crt_get_issuer (gnutls_x509_crt_t cert
,gnutls_x509_dn_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.
|
should contain a gnutls_x509_crt_t structure |
|
output variable with pointer to uint8_t DN |
Returns : |
Returns 0 on success, or an error code. |
int gnutls_x509_dn_get_rdn_ava (gnutls_x509_dn_t dn
,int irdn
,int iava
,gnutls_x509_ava_st *ava
);
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, so you
should not modify any data or deallocate it. Note also that the DN
in turn points into the original certificate structure, and thus
you may not deallocate the certificate and continue to access dn
.
|
a pointer to DN |
|
index of RDN |
|
index of AVA. |
|
Pointer to structure which will hold output information. |
Returns : |
Returns 0 on success, or an error code. |
int gnutls_x509_dn_init (gnutls_x509_dn_t *dn
);
This function initializes a gnutls_x509_dn_t structure.
The object returned must be deallocated using
gnutls_x509_dn_deinit()
.
|
the object to be initialized |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
Since 2.4.0
int gnutls_x509_dn_import (gnutls_x509_dn_t dn
,const gnutls_datum_t *data
);
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.
|
the structure that will hold the imported DN |
|
should contain a DER encoded RDN sequence |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
Since 2.4.0
int gnutls_x509_dn_export (gnutls_x509_dn_t dn
,gnutls_x509_crt_fmt_t format
,void *output_data
,size_t *output_data_size
);
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".
|
Holds the uint8_t DN object |
|
the format of output params. One of PEM or DER. |
|
will contain a DN PEM or DER encoded |
|
holds the size of output_data (and will be replaced by the actual size of parameters) |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
void gnutls_x509_dn_deinit (gnutls_x509_dn_t dn
);
This function deallocates the DN object as returned by
gnutls_x509_dn_import()
.
|
a DN uint8_t object pointer. |
Since 2.4.0
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.
|
The structure to be initialized |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
void gnutls_x509_crl_deinit (gnutls_x509_crl_t crl
);
This function will deinitialize a CRL structure.
|
The structure to be initialized |
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".
|
The structure to store the parsed CRL. |
|
The DER or PEM encoded CRL. |
|
One of DER or PEM |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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".
|
Holds the revocation list |
|
the format of output params. One of PEM or DER. |
|
will contain a private key PEM or DER encoded |
|
holds the size of output_data (and will be replaced by the actual size of parameters) |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. and a negative error code on failure. |
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 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.
|
should contain a gnutls_x509_crl_t structure |
|
a pointer to a structure to hold the peer's name (may be null) |
|
initially holds the size of buf
|
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. |
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 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.
|
should contain a gnutls_x509_crl_t structure |
|
holds an Object Identified in null terminated string |
|
In case multiple same OIDs exist in the RDN, this specifies which to send. Use (0) to get the first one. |
|
If non-zero returns the raw DER data of the DN part. |
|
a pointer to a structure to hold the peer's name (may be null) |
|
initially holds the size of buf
|
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. |
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.
|
should contain a gnutls_x509_crl_t structure |
|
Specifies which DN OID to send. Use (0) to get the first one. |
|
a pointer to a structure to hold the name (may be null) |
|
initially holds the size of 'oid' |
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. |
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.
|
should contain a gnutls_x509_crl_t structure |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_crl_get_signature (gnutls_x509_crl_t crl
,char *sig
,size_t *sizeof_sig
);
This function will extract the signature field of a CRL.
|
should contain a gnutls_x509_crl_t structure |
|
a pointer where the signature part will be copied (may be null). |
|
initially holds the size of sig
|
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. and a negative error code on error. |
int gnutls_x509_crl_get_version (gnutls_x509_crl_t crl
);
This function will return the version of the specified CRL.
|
should contain a gnutls_x509_crl_t structure |
Returns : |
The version number, or a negative error code on error. |
time_t gnutls_x509_crl_get_this_update (gnutls_x509_crl_t crl
);
This function will return the time this CRL was issued.
|
should contain a gnutls_x509_crl_t structure |
Returns : |
when the CRL was issued, or (time_t)-1 on error. |
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.
|
should contain a gnutls_x509_crl_t structure |
Returns : |
when the next CRL will be issued, or (time_t)-1 on error. |
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.
|
should contain a gnutls_x509_crl_t structure |
Returns : |
number of certificates, a negative error code on failure. |
int gnutls_x509_crl_get_crt_serial (gnutls_x509_crl_t crl
,int indx
,unsigned char *serial
,size_t *serial_size
,time_t *t
);
This function will retrieve the serial number of the specified, by the index, revoked certificate.
|
should contain a gnutls_x509_crl_t structure |
|
the index of the certificate to extract (starting from 0) |
|
where the serial number will be copied |
|
initially holds the size of serial |
|
if non null, will hold the time this certificate was revoked |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. and a negative error code on error. |
#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.
|
is the CRL to be checked |
|
is the certificate of a possible issuer |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
should contain a gnutls_x509_crl_t structure |
|
holds the version number. For CRLv1 crls must be 1. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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
);
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.
|
should contain a gnutls_x509_crl_t structure |
|
is the certificate of the certificate issuer |
|
holds the issuer's private key |
|
The message digest to use. GNUTLS_DIG_SHA1 is the safe choice unless you know what you're doing. |
|
must be 0 |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
should contain a gnutls_x509_crl_t structure |
|
The actual time |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
should contain a gnutls_x509_crl_t structure |
|
The actual time |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
should contain a gnutls_x509_crl_t structure |
|
The revoked certificate's serial number |
|
Holds the size of the serial field. |
|
The time this certificate was revoked |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
should contain a gnutls_x509_crl_t structure |
|
a certificate of type gnutls_x509_crt_t with the revoked certificate |
|
The time this certificate was revoked |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_crl_get_authority_key_id (gnutls_x509_crl_t crl
,void *id
,size_t *id_size
,unsigned int *critical
);
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.
|
should contain a gnutls_x509_crl_t structure |
|
The place where the identifier will be copied |
|
Holds the size of the result field. |
|
will be non-zero if the extension is marked as critical (may be null) |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error code in case of an error. |
Since 2.8.0
int gnutls_x509_crl_get_number (gnutls_x509_crl_t crl
,void *ret
,size_t *ret_size
,unsigned int *critical
);
This function will return the CRL number extension. This is obtained by the CRL Number extension field (2.5.29.20).
|
should contain a gnutls_x509_crl_t structure |
|
The place where the number will be copied |
|
Holds the size of the result field. |
|
will be non-zero if the extension is marked as critical (may be null) |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error code in case of an error. |
Since 2.8.0
int gnutls_x509_crl_get_extension_oid (gnutls_x509_crl_t crl
,int indx
,void *oid
,size_t *sizeof_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.
|
should contain a gnutls_x509_crl_t structure |
|
Specifies which extension OID to send, use (0) to get the first one. |
|
a pointer to a structure to hold the OID (may be null) |
|
initially holds the size of oid
|
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
int gnutls_x509_crl_get_extension_info (gnutls_x509_crl_t crl
,int indx
,void *oid
,size_t *sizeof_oid
,unsigned int *critical
);
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.
|
should contain a gnutls_x509_crl_t structure |
|
Specifies which extension OID to send, use (0) to get the first one. |
|
a pointer to a structure to hold the OID |
|
initially holds the maximum size of oid , on return
holds actual size of oid . |
|
output variable with critical flag, may be NULL. |
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
int gnutls_x509_crl_get_extension_data (gnutls_x509_crl_t crl
,int indx
,void *data
,size_t *sizeof_data
);
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.
|
should contain a gnutls_x509_crl_t structure |
|
Specifies which extension OID to send. Use (0) to get the first one. |
|
a pointer to a structure to hold the data (may be null) |
|
initially holds the size of oid
|
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
int gnutls_x509_crl_set_authority_key_id (gnutls_x509_crl_t crl
,const void *id
,size_t id_size
);
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.
|
a CRL of type gnutls_x509_crl_t |
|
The key ID |
|
Holds the size of the serial field. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
Since 2.8.0
int gnutls_x509_crl_set_number (gnutls_x509_crl_t crl
,const void *nr
,size_t nr_size
);
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.
|
a CRL of type gnutls_x509_crl_t |
|
The CRL number |
|
Holds the size of the nr field. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
Since 2.8.0
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.
|
The structure to be initialized |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
void gnutls_pkcs7_deinit (gnutls_pkcs7_t pkcs7
);
This function will deinitialize a PKCS7 structure.
|
The structure to be initialized |
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".
|
The structure to store the parsed PKCS7. |
|
The DER or PEM encoded PKCS7. |
|
One of DER or PEM |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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
*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".
|
Holds the pkcs7 structure |
|
the format of output params. One of PEM or DER. |
|
will contain a structure PEM or DER encoded |
|
holds the size of output_data (and will be replaced by the actual size of parameters) |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
should contain a gnutls_pkcs7_t structure |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
After the last certificate has been read
GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE
will be returned.
|
should contain a gnutls_pkcs7_t structure |
|
contains the index of the certificate to extract |
|
the contents of the certificate will be copied there (may be null) |
|
should hold the size of the certificate |
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. |
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.
|
should contain a gnutls_pkcs7_t structure |
|
the DER encoded certificate to be added |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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()
.
|
should contain a gnutls_pkcs7_t structure |
|
the certificate to be copied. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
should contain a gnutls_pkcs7_t structure |
|
the index of the certificate to delete |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
should contain a gnutls_pkcs7_t structure |
|
contains the index of the crl to extract |
|
the contents of the crl will be copied there (may be null) |
|
should hold the size of the crl |
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. |
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.
|
should contain a gnutls_pkcs7_t structure |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_pkcs7_set_crl_raw (gnutls_pkcs7_t pkcs7
,const gnutls_datum_t *crl
);
This function will add a crl to the PKCS7 or RFC2630 crl set.
|
should contain a gnutls_pkcs7_t structure |
|
the DER encoded crl to be added |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
should contain a gnutls_pkcs7_t structure |
|
the DER encoded crl to be added |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
should contain a gnutls_pkcs7_t structure |
|
the index of the crl to delete |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
typedef enum { GNUTLS_VERIFY_DISABLE_CA_SIGN = 1<<0, GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT = 1<<1, GNUTLS_VERIFY_DO_NOT_ALLOW_SAME = 1<<2, GNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT = 1<<3, GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2 = 1<<4, GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5 = 1<<5, GNUTLS_VERIFY_DISABLE_TIME_CHECKS = 1<<6, GNUTLS_VERIFY_DISABLE_TRUSTED_TIME_CHECKS = 1<<7, GNUTLS_VERIFY_DO_NOT_ALLOW_X509_V1_CA_CRT = 1<<8, GNUTLS_VERIFY_DISABLE_CRL_CHECKS = 1<<9, GNUTLS_VERIFY_ALLOW_UNSORTED_CHAIN = 1<<10, GNUTLS_VERIFY_DO_NOT_ALLOW_UNSORTED_CHAIN = 1<<11, } gnutls_certificate_verify_flags;
Enumeration of different certificate verify flags.
If set a signer does not have to be a certificate authority. This flag should normaly be disabled, unless you know what this means. | |
Allow trusted CA certificates
with version 1. This is safer than GNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT ,
and should be used instead. That way only signers in your trusted list
will be allowed to have certificates of version 1. This is the default.
|
|
If a certificate is not signed by anyone trusted but exists in the trusted CA list do not treat it as trusted. | |
Allow CA certificates that
have version 1 (both root and intermediate). This might be
dangerous since those haven't the basicConstraints
extension. Must be used in combination with
GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT .
|
|
Allow certificates to be signed using the broken MD2 algorithm. | |
Allow certificates to be signed using the broken MD5 algorithm. | |
Disable checking of activation and expiration validity periods of certificate chains. Don't set this unless you understand the security implications. | |
If set a signer in the trusted list is never checked for expiration or activation. | |
Do not allow trusted CA certificates that have version 1. This option is to be used to deprecate all certificates of version 1. | |
Disable checking for validity using certificate revocation lists or the available OCSP data. | |
A certificate chain is tolerated if unsorted (the case with many TLS servers out there). This is the default since GnuTLS 3.1.4. | |
Do not tolerate an unsorted certificate chain. |
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 checks the DN fields and the authority key identifier and subject key identifier fields match.
|
is the certificate to be checked |
|
is the certificate of a possible issuer |
Returns : |
It will return true (1) if the given certificate is issued by the given issuer, and false (0) if not. A negative error code is returned in case of an error. |
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
);
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.
|
is the certificate list to be verified |
|
holds the number of certificate in cert_list |
|
is the CA list which will be used in verification |
|
holds the number of CA certificate in CA_list |
|
holds a list of CRLs. |
|
the length of CRL list. |
|
Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations. |
|
will hold the certificate verification output. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
is the certificate to be verified |
|
is one certificate that is considered to be trusted one |
|
holds the number of CA certificate in CA_list |
|
Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations. |
|
will hold the certificate verification output. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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. Note that since GnuTLS 3.1.4 this function includes
the time checks.
|
is the crl to be verified |
|
is a certificate list that is considered to be trusted one |
|
holds the number of CA certificates in CA_list |
|
Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations. |
|
will hold the crl verification output. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
should contain a gnutls_x509_crt_t structure |
|
should contain a list of gnutls_x509_crl_t structures |
|
the length of the crl_list |
Returns : |
0 if the certificate is NOT revoked, and 1 if it is. A negative error code is returned on error. |
int gnutls_x509_crt_get_fingerprint (gnutls_x509_crt_t cert
,gnutls_digest_algorithm_t algo
,void *buf
,size_t *buf_size
);
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.
|
should contain a gnutls_x509_crt_t structure |
|
is a digest algorithm |
|
a pointer to a structure to hold the fingerprint (may be null) |
|
initially holds the size of buf
|
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. |
int gnutls_x509_crt_get_key_purpose_oid (gnutls_x509_crt_t cert
,int indx
,void *oid
,size_t *oid_size
,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. The oid
returned will be null terminated, although oid_size
will not
account for the trailing null.
|
should contain a gnutls_x509_crt_t structure |
|
This specifies which OID to return. Use (0) to get the first one. |
|
a pointer to a buffer to hold the OID (may be null) |
|
initially holds the size of oid
|
|
output flag to indicate criticality of extension |
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. |
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.
|
a certificate of type gnutls_x509_crt_t |
|
a pointer to a null terminated string that holds the OID |
|
Whether this extension will be critical or not |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned,
otherwise a negative error code is returned. |
typedef enum { GNUTLS_PKCS_PLAIN = 1, 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_USE_PBES2_AES_128 = 32, GNUTLS_PKCS_USE_PBES2_AES_192 = 64, GNUTLS_PKCS_USE_PBES2_AES_256 = 128, GNUTLS_PKCS_NULL_PASSWORD = 256 } gnutls_pkcs_encrypt_flags_t;
Enumeration of different PKCS encryption flags.
Unencrypted private key. | |
PKCS-12 3DES. | |
PKCS-12 ARCFOUR. | |
PKCS-12 RC2-40. | |
PBES2 3DES. | |
PBES2 AES-128. | |
PBES2 AES-192. | |
PBES2 AES-256. | |
Some schemas distinguish between an empty and a NULL password. |
int gnutls_x509_privkey_init (gnutls_x509_privkey_t *key
);
This function will initialize an private key structure.
|
The structure to be initialized |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
void gnutls_x509_privkey_deinit (gnutls_x509_privkey_t key
);
This function will deinitialize a private key structure.
|
The structure to be deinitialized |
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. Destination has to be initialized.
|
The destination key, which should be initialized. |
|
The source key |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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 that contains "PRIVATE KEY". Note that this function falls back to PKCS #8 decoding without password, if the default format fails to import.
|
The structure to store the parsed key |
|
The DER or PEM encoded certificate. |
|
One of DER or PEM |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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
);
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.
|
The structure to store the parsed key |
|
The DER or PEM encoded key. |
|
One of DER or PEM |
|
the password to decrypt the key (if it is encrypted). |
|
0 if encrypted or GNUTLS_PKCS_PLAIN if not encrypted. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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
.
|
The structure to store the parsed key |
|
holds the modulus |
|
holds the public exponent |
|
holds the private exponent |
|
holds the first prime (p) |
|
holds the second prime (q) |
|
holds the coefficient |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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
);
This function will convert the given RSA raw parameters to the
native gnutls_x509_privkey_t format. The output will be stored in
key
.
|
The structure to store the parsed key |
|
holds the modulus |
|
holds the public exponent |
|
holds the private exponent |
|
holds the first prime (p) |
|
holds the second prime (q) |
|
holds the coefficient |
|
holds e1 = d mod (p-1) |
|
holds e2 = d mod (q-1) |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_privkey_fix (gnutls_x509_privkey_t key
);
This function will recalculate the secondary parameters in a key. In RSA keys, this can be the coefficient and exponent1,2.
|
Holds the key |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
a structure that holds the DSA parameters |
|
will hold the p |
|
will hold the q |
|
will hold the g |
|
will hold the y |
|
will hold the x |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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
.
|
The structure to store the parsed key |
|
holds the p |
|
holds the q |
|
holds the g |
|
holds the y |
|
holds the x |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_privkey_get_pk_algorithm
(gnutls_x509_privkey_t key
);
This function will return the public key algorithm of a private key.
|
should contain a gnutls_x509_privkey_t structure |
Returns : |
a member of the gnutls_pk_algorithm_t enumeration on success, or a negative error code on error. |
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 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.
|
Holds the key |
|
should be 0 for now |
|
will contain the key ID |
|
holds the size of output_data (and will be replaced by the actual size of parameters) |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
Do not set the number of bits directly, use gnutls_sec_param_to_pk_bits()
.
|
should contain a gnutls_x509_privkey_t structure |
|
is one of the algorithms in gnutls_pk_algorithm_t. |
|
the size of the modulus |
|
unused for now. Must be 0. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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
*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".
|
Holds the key |
|
the format of output params. One of PEM or DER. |
|
will contain a private key PEM or DER encoded |
|
holds the size of output_data (and will be replaced by the actual size of parameters) |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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. 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.
|
Holds the key |
|
the format of output params. One of PEM or DER. |
|
the password that will be used to encrypt the key. |
|
an ORed sequence of gnutls_pkcs_encrypt_flags_t |
|
will contain a private key PEM or DER encoded |
|
holds the size of output_data (and will be replaced by the actual size of parameters) |
Returns : |
In case of failure a negative error code will be returned, and 0 on success. |
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
);
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.
|
a structure that holds the rsa parameters |
|
will hold the modulus |
|
will hold the public exponent |
|
will hold the private exponent |
|
will hold the first prime (p) |
|
will hold the second prime (q) |
|
will hold the coefficient |
|
will hold e1 = d mod (p-1) |
|
will hold e2 = d mod (q-1) |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
Since 2.12.0
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.
|
a structure that holds the rsa parameters |
|
will hold the modulus |
|
will hold the public exponent |
|
will hold the private exponent |
|
will hold the first prime (p) |
|
will hold the second prime (q) |
|
will hold the coefficient |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_crq_print (gnutls_x509_crq_t crq
,gnutls_certificate_print_formats_t format
,gnutls_datum_t *out
);
This function will pretty print a certificate request, suitable for display to a human.
The output out
needs to be deallocated using gnutls_free()
.
|
The structure to be printed |
|
Indicate the format to use |
|
Newly allocated datum with (0) terminated string. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
Since 2.8.0
int gnutls_x509_crq_init (gnutls_x509_crq_t *crq
);
This function will initialize a PKCS10 certificate request structure.
|
The structure to be initialized |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
void gnutls_x509_crq_deinit (gnutls_x509_crq_t crq
);
This function will deinitialize a PKCS10 certificate request structure.
|
The structure to be initialized |
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
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".
|
The structure to store the parsed certificate request. |
|
The DER or PEM encoded certificate. |
|
One of DER or PEM |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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
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.
|
should contain a gnutls_x509_crq_t structure |
|
a pointer to a structure to hold the name (may be NULL ) |
|
initially holds the size of buf
|
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. On success 0 is returned. |
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.
|
should contain a gnutls_x509_crq_t structure |
|
Specifies which DN OID to send. Use (0) to get the first one. |
|
a pointer to a structure to hold the name (may be NULL ) |
|
initially holds the size of oid
|
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. |
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 (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()
.
|
should contain a gnutls_x509_crq_t structure |
|
holds an Object Identified in null terminated string |
|
In case multiple same OIDs exist in the RDN, this specifies which to send. Use (0) to get the first one. |
|
If non-zero returns the raw DER data of the DN part. |
|
a pointer to a structure to hold the name (may be NULL ) |
|
initially holds the size of buf
|
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. On success 0 is returned. |
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
);
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.
|
should contain a gnutls_x509_crq_t structure |
|
holds an Object Identifier in a (0)-terminated string |
|
must be 0, or 1 if the data are DER encoded |
|
a pointer to the input data |
|
holds the size of data
|
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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.
|
should contain a gnutls_x509_crq_t structure |
|
holds the version number, for v1 Requests must be 1 |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_crq_get_version (gnutls_x509_crq_t crq
);
This function will return the version of the specified Certificate request.
|
should contain a gnutls_x509_crq_t structure |
Returns : |
version of certificate request, or a negative error code on error. |
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.
|
should contain a gnutls_x509_crq_t structure |
|
holds a private key |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_crq_sign2 (gnutls_x509_crq_t crq
,gnutls_x509_privkey_t key
,gnutls_digest_algorithm_t dig
,unsigned int flags
);
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.
|
should contain a gnutls_x509_crq_t structure |
|
holds a private key |
|
The message digest to use, i.e., GNUTLS_DIG_SHA1
|
|
must be 0 |
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() ). |
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.
|
should contain a gnutls_x509_crq_t structure |
|
holds a (0)-terminated password |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_crq_get_challenge_password (gnutls_x509_crq_t crq
,char *pass
,size_t *sizeof_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.
|
should contain a gnutls_x509_crq_t structure |
|
will hold a (0)-terminated password string |
|
Initially holds the size of pass . |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_crq_set_attribute_by_oid (gnutls_x509_crq_t crq
,const char *oid
,void *buf
,size_t sizeof_buf
);
This function will set the attribute in the certificate request specified by the given Object ID. The attribute must be be DER encoded.
|
should contain a gnutls_x509_crq_t structure |
|
holds an Object Identified in (0)-terminated string |
|
a pointer to a structure that holds the attribute data |
|
holds the size of buf
|
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_crq_get_attribute_by_oid (gnutls_x509_crq_t crq
,const char *oid
,int indx
,void *buf
,size_t *sizeof_buf
);
This function will return the attribute in the certificate request specified by the given Object ID. The attribute will be DER encoded.
|
should contain a gnutls_x509_crq_t structure |
|
holds an Object Identified in (0)-terminated string |
|
In case multiple same OIDs exist in the attribute list, this specifies which to send, use (0) to get the first one |
|
a pointer to a structure to hold the attribute data (may be NULL ) |
|
initially holds the size of buf
|
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
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 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".
|
should contain a gnutls_x509_crq_t structure |
|
the format of output params. One of PEM or DER. |
|
will contain a certificate request PEM or DER encoded |
|
holds the size of output_data (and will be replaced by the actual size of parameters) |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_crt_set_crq (gnutls_x509_crt_t crt
,gnutls_x509_crq_t crq
);
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.
|
a certificate of type gnutls_x509_crt_t |
|
holds a certificate request |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
int gnutls_x509_crt_set_crq_extensions (gnutls_x509_crt_t crt
,gnutls_x509_crq_t crq
);
This function will set extensions from the given request to the certificate.
|
a certificate of type gnutls_x509_crt_t |
|
holds a certificate request |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
Since 2.8.0
int gnutls_x509_crq_set_key_rsa_raw (gnutls_x509_crq_t crq
,const gnutls_datum_t *m
,const gnutls_datum_t *e
);
This function will set the public parameters from the given private key to the request. Only RSA keys are currently supported.
|
should contain a gnutls_x509_crq_t structure |
|
holds the modulus |
|
holds the public exponent |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
Since 2.6.0
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
);
This function will set the subject alternative name certificate extension. It can set the following types:
GNUTLS_SAN_DNSNAME
: as a text string
GNUTLS_SAN_RFC822NAME
: as a text string
GNUTLS_SAN_URI
: as a text string
GNUTLS_SAN_IPADDRESS
: as a binary IP address (4 or 16 bytes)
Other values can be set as binary values with the proper DER encoding.
|
a certificate request of type gnutls_x509_crq_t |
|
is one of the gnutls_x509_subject_alt_name_t enumerations |
|
The data to be set |
|
The size of data to be set |
|
GNUTLS_FSAN_SET to clear previous data or
GNUTLS_FSAN_APPEND to append. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
Since 2.8.0
int gnutls_x509_crq_set_key_usage (gnutls_x509_crq_t crq
,unsigned int usage
);
This function will set the keyUsage certificate extension.
|
a certificate request of type gnutls_x509_crq_t |
|
an ORed sequence of the GNUTLS_KEY_* elements. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
Since 2.8.0
int gnutls_x509_crq_set_basic_constraints (gnutls_x509_crq_t crq
,unsigned int ca
,int pathLenConstraint
);
This function will set the basicConstraints certificate extension.
|
a certificate request of type gnutls_x509_crq_t |
|
true(1) or false(0) depending on the Certificate authority status. |
|
non-negative error codes indicate maximum length of path, and negative error codes indicate that the pathLenConstraints field should not be present. |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
Since 2.8.0
int gnutls_x509_crq_set_key_purpose_oid (gnutls_x509_crq_t crq
,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.
|
a certificate of type gnutls_x509_crq_t |
|
a pointer to a (0)-terminated string that holds the OID |
|
Whether this extension will be critical or not |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
Since 2.8.0
int gnutls_x509_crq_get_key_purpose_oid (gnutls_x509_crq_t crq
,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.
|
should contain a gnutls_x509_crq_t structure |
|
This specifies which OID to return, use (0) to get the first one |
|
a pointer to a buffer to hold the OID (may be NULL ) |
|
initially holds the size of oid
|
|
output variable with critical flag, may be NULL . |
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
int gnutls_x509_crq_get_extension_data (gnutls_x509_crq_t crq
,int indx
,void *data
,size_t *sizeof_data
);
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.
|
should contain a gnutls_x509_crq_t structure |
|
Specifies which extension OID to send. Use (0) to get the first one. |
|
a pointer to a structure to hold the data (may be null) |
|
initially holds the size of oid
|
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
int gnutls_x509_crq_get_extension_info (gnutls_x509_crq_t crq
,int indx
,void *oid
,size_t *sizeof_oid
,unsigned int *critical
);
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.
|
should contain a gnutls_x509_crq_t structure |
|
Specifies which extension OID to send. Use (0) to get the first one. |
|
a pointer to a structure to hold the OID |
|
initially holds the maximum size of oid , on return
holds actual size of oid . |
|
output variable with critical flag, may be NULL. |
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
int gnutls_x509_crq_get_attribute_data (gnutls_x509_crq_t crq
,int indx
,void *data
,size_t *sizeof_data
);
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.
|
should contain a gnutls_x509_crq_t structure |
|
Specifies which attribute OID to send. Use (0) to get the first one. |
|
a pointer to a structure to hold the data (may be null) |
|
initially holds the size of oid
|
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
int gnutls_x509_crq_get_attribute_info (gnutls_x509_crq_t crq
,int indx
,void *oid
,size_t *sizeof_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.
|
should contain a gnutls_x509_crq_t structure |
|
Specifies which attribute OID to send. Use (0) to get the first one. |
|
a pointer to a structure to hold the OID |
|
initially holds the maximum size of oid , on return
holds actual size of oid . |
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
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 PKCS10 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.
|
should contain a gnutls_x509_crq_t structure |
|
if bits is non-NULL it will hold the size of the parameters' in bits |
Returns : |
a member of the gnutls_pk_algorithm_t enumeration on success, or a negative error code on error. |
int gnutls_x509_crq_get_key_id (gnutls_x509_crq_t crq
,unsigned int flags
,unsigned char *output_data
,size_t *output_data_size
);
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.
|
a certificate of type gnutls_x509_crq_t |
|
should be 0 for now |
|
will contain the key ID |
|
holds the size of output_data (and will be replaced by the actual size of parameters) |
Returns : |
In case of failure a negative error code will be returned, and 0 on success. |
Since 2.8.0
int gnutls_x509_crq_get_key_rsa_raw (gnutls_x509_crq_t crq
,gnutls_datum_t *m
,gnutls_datum_t *e
);
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.
|
Holds the certificate |
|
will hold the modulus |
|
will hold the public exponent |
Returns : |
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value. |
Since 2.8.0
int gnutls_x509_crq_get_key_usage (gnutls_x509_crq_t crq
,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
.
|
should contain a gnutls_x509_crq_t structure |
|
where the key usage bits will be stored |
|
will be non-zero if the extension is marked as critical |
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
int gnutls_x509_crq_get_basic_constraints (gnutls_x509_crq_t crq
,unsigned int *critical
,unsigned int *ca
,int *pathlen
);
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).
|
should contain a gnutls_x509_crq_t structure |
|
will be non-zero if the extension is marked as critical |
|
pointer to output integer indicating CA status, may be NULL, value is 1 if the certificate CA flag is set, 0 otherwise. |
|
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. |
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
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
);
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).
|
should contain a gnutls_x509_crq_t structure |
|
specifies the sequence number of the alt name, 0 for the first one, 1 for the second etc. |
|
is the place where the alternative name will be copied to |
|
holds the size of ret. |
|
holds the gnutls_x509_subject_alt_name_t name type |
|
will be non-zero if the extension is marked as critical (may be null) |
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
int gnutls_x509_crq_get_subject_alt_othername_oid (gnutls_x509_crq_t crq
,unsigned int seq
,void *ret
,size_t *ret_size
);
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
.
|
should contain a gnutls_x509_crq_t structure |
|
specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) |
|
is the place where the otherName OID will be copied to |
|
holds the size of ret. |
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
int gnutls_x509_crq_get_extension_by_oid (gnutls_x509_crq_t crq
,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.
|
should contain a gnutls_x509_crq_t structure |
|
holds an Object Identified in null terminated string |
|
In case multiple same OIDs exist in the extensions, this specifies which to send. Use (0) to get the first one. |
|
a pointer to a structure to hold the name (may be null) |
|
initially holds the size of buf
|
|
will be non-zero if the extension is marked as critical |
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