| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The following functions are to be used for X.509 certificate handling. Their prototypes lie in ‘gnutls/x509.h’.
bag: The bag
pass: The password used for encryption, must be ASCII.
This function will decrypt the given encrypted bag and return 0 on success.
Returns: On success, (0) is returned, otherwise a negative error code is returned.
bag: The structure to be initialized
This function will deinitialize a PKCS12 Bag structure.
bag: The bag
pass: The password used for encryption, must be ASCII
flags: should be one of elements bitwise or’d
This function will encrypt the given bag.
Returns: On success, (0) is returned, otherwise a negative error code is returned.
bag: The bag
This function will return the number of the elements withing the bag.
Returns: Number of elements in bag, or an negative error code on error.
bag: The bag
indx: The element of the bag to get the data from
data: where the bag’s data will be. Should be treated as constant.
This function will return the bag’s data. The data is a constant that is stored into the bag. Should not be accessed after the bag is deleted.
Returns: On success, (0) is returned, otherwise a negative error value.
bag: The bag
indx: The bag’s element to add the id
name: will hold a pointer to the name (to be treated as const)
This function will return the friendly name, of the specified bag element. The key ID is usually used to distinguish the local private key and the certificate pair.
Returns: On success, (0) is returned, otherwise a negative error value. or a negative error code on error.
bag: The bag
indx: The bag’s element to add the id
id: where the ID will be copied (to be treated as const)
This function will return the key ID, of the specified bag element. The key ID is usually used to distinguish the local private key and the certificate pair.
Returns: On success, (0) is returned, otherwise a negative error value. or a negative error code on error.
bag: The bag
indx: The element of the bag to get the type
This function will return the bag’s type.
Returns: One of the enumerations.
bag: The structure to be initialized
This function will initialize a PKCS12 bag structure. PKCS12 Bags usually contain private keys, lists of X.509 Certificates and X.509 Certificate revocation lists.
Returns: On success, (0) is returned, otherwise a negative error value.
bag: The bag
crl: the CRL to be copied.
This function will insert the given CRL into the bag. This is just a wrapper over .
Returns: the index of the added bag on success, or a negative error code on failure.
bag: The bag
crt: the certificate to be copied.
This function will insert the given certificate into the bag. This is just a wrapper over .
Returns: the index of the added bag on success, or a negative value on failure.
bag: The bag
type: The data’s type
data: the data to be copied.
This function will insert the given data of the given type into the bag.
Returns: the index of the added bag on success, or a negative value on error.
bag: The bag
indx: The bag’s element to add the id
name: the name
This function will add the given key friendly name, to the specified, by the index, bag element. The name will be encoded as a ’Friendly name’ bag attribute, which is usually used to set a user name to the local private key and the certificate pair.
Returns: On success, (0) is returned, otherwise a negative error value. or a negative error code on error.
bag: The bag
indx: The bag’s element to add the id
id: the ID
This function will add the given key ID, to the specified, by the index, bag element. The key ID will be encoded as a ’Local key identifier’ bag attribute, which is usually used to distinguish the local private key and the certificate pair.
Returns: On success, (0) is returned, otherwise a negative error value. or a negative error code on error.
pkcs12: The structure to be initialized
This function will deinitialize a PKCS12 structure.
pkcs12: Holds the pkcs12 structure
format: the format of output params. One of PEM or DER.
output_data: will contain a structure PEM or DER encoded
output_data_size: holds the size of output_data (and will be replaced by the actual size of parameters)
This function will export the pkcs12 structure to DER or PEM format.
If the buffer provided is not long enough to hold the output, then *output_data_size will be updated and GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.
If the structure is PEM encoded, it will have a header of "BEGIN PKCS12".
Returns: In case of failure a negative error code will be returned, and 0 on success.
pkcs12: should contain a gnutls_pkcs12_t structure
pass: The password for the MAC
This function will generate a MAC for the PKCS12 structure.
Returns: On success, (0) is returned, otherwise a negative error value.
pkcs12: should contain a gnutls_pkcs12_t structure
indx: contains the index of the bag to extract
bag: An initialized bag, where the contents of the bag will be copied
This function will return a Bag from the PKCS12 structure.
After the last Bag has been read will be returned.
Returns: On success, (0) is returned, otherwise a negative error value.
pkcs12: The structure to store the parsed PKCS12.
data: The DER or PEM encoded PKCS12.
format: One of DER or PEM
flags: an ORed sequence of gnutls_privkey_pkcs8_flags
This function will convert the given DER or PEM encoded PKCS12 to the native gnutls_pkcs12_t format. The output will be stored in ’pkcs12’.
If the PKCS12 is PEM encoded it should have a header of "PKCS12".
Returns: On success, (0) is returned, otherwise a negative error value.
pkcs12: The structure to be initialized
This function will initialize a PKCS12 structure. PKCS12 structures usually contain lists of X.509 Certificates and X.509 Certificate revocation lists.
Returns: On success, (0) is returned, otherwise a negative error value.
pkcs12: should contain a gnutls_pkcs12_t structure
bag: An initialized bag
This function will insert a Bag into the PKCS12 structure.
Returns: On success, (0) is returned, otherwise a negative error value.
pkcs12: should contain a gnutls_pkcs12_t structure
pass: The password for the MAC
This function will verify the MAC for the PKCS12 structure.
Returns: On success, (0) is returned, otherwise a negative error value.
pkcs7: The structure to be initialized
This function will deinitialize a PKCS7 structure.
pkcs7: should contain a structure
indx: the index of the crl to delete
This function will delete a crl from a PKCS7 or RFC2630 crl set. Index starts from 0. Returns 0 on success.
Returns: On success, (0) is returned, otherwise a negative error value.
pkcs7: should contain a gnutls_pkcs7_t structure
indx: the index of the certificate to delete
This function will delete a certificate from a PKCS7 or RFC2630 certificate set. Index starts from 0. Returns 0 on success.
Returns: On success, (0) is returned, otherwise a negative error value.
pkcs7: Holds the pkcs7 structure
format: the format of output params. One of PEM or DER.
output_data: will contain a structure PEM or DER encoded
output_data_size: holds the size of output_data (and will be replaced by the actual size of parameters)
This function will export the pkcs7 structure to DER or PEM format.
If the buffer provided is not long enough to hold the output, then * is updated and will be returned.
If the structure is PEM encoded, it will have a header of "BEGIN PKCS7".
Returns: On success, (0) is returned, otherwise a negative error value.
pkcs7: should contain a gnutls_pkcs7_t structure
This function will return the number of certifcates in the PKCS7 or RFC2630 crl set.
Returns: On success, (0) is returned, otherwise a negative error value.
pkcs7: should contain a structure
indx: contains the index of the crl to extract
crl: the contents of the crl will be copied there (may be null)
crl_size: should hold the size of the crl
This function will return a crl of the PKCS7 or RFC2630 crl set.
Returns: On success, (0) is returned, otherwise a negative error value. If the provided buffer is not long enough, then is updated and is returned. After the last crl has been read will be returned.
pkcs7: should contain a structure
This function will return the number of certifcates in the PKCS7 or RFC2630 certificate set.
Returns: On success, (0) is returned, otherwise a negative error value.
pkcs7: should contain a gnutls_pkcs7_t structure
indx: contains the index of the certificate to extract
certificate: the contents of the certificate will be copied there (may be null)
certificate_size: should hold the size of the certificate
This function will return a certificate of the PKCS7 or RFC2630 certificate set.
After the last certificate has been read will be returned.
Returns: On success, (0) is returned, otherwise a negative error value. If the provided buffer is not long enough, then is updated and is returned.
pkcs7: The structure to store the parsed PKCS7.
data: The DER or PEM encoded PKCS7.
format: One of DER or PEM
This function will convert the given DER or PEM encoded PKCS7 to the native format. The output will be stored in .
If the PKCS7 is PEM encoded it should have a header of "PKCS7".
Returns: On success, (0) is returned, otherwise a negative error value.
pkcs7: The structure to be initialized
This function will initialize a PKCS7 structure. PKCS7 structures usually contain lists of X.509 Certificates and X.509 Certificate revocation lists.
Returns: On success, (0) is returned, otherwise a negative error value.
pkcs7: should contain a structure
crl: the DER encoded crl to be added
This function will add a crl to the PKCS7 or RFC2630 crl set.
Returns: On success, (0) is returned, otherwise a negative error value.
pkcs7: should contain a structure
crl: the DER encoded crl to be added
This function will add a parsed CRL to the PKCS7 or RFC2630 crl set.
Returns: On success, (0) is returned, otherwise a negative error value.
pkcs7: should contain a structure
crt: the DER encoded certificate to be added
This function will add a certificate to the PKCS7 or RFC2630 certificate set.
Returns: On success, (0) is returned, otherwise a negative error value.
pkcs7: should contain a structure
crt: the certificate to be copied.
This function will add a parsed certificate to the PKCS7 or RFC2630 certificate set. This is a wrapper function over .
Returns: On success, (0) is returned, otherwise a negative error value.
crl: is the CRL to be checked
issuer: is the certificate of a possible issuer
This function will check if the given CRL was issued by the given issuer certificate. It will return true (1) if the given CRL was issued by the given issuer, and false (0) if not.
Returns: On success, (0) is returned, otherwise a negative error value.
crl: The structure to be initialized
This function will deinitialize a CRL structure.
crl: Holds the revocation list
format: the format of output params. One of PEM or DER.
output_data: will contain a private key PEM or DER encoded
output_data_size: holds the size of output_data (and will be replaced by the actual size of parameters)
This function will export the revocation list to DER or PEM format.
If the buffer provided is not long enough to hold the output, then will be returned.
If the structure is PEM encoded, it will have a header of "BEGIN X509 CRL".
Returns: On success, (0) is returned, otherwise a negative error value. and a negative error code on failure.
crl: should contain a structure
ret: The place where the identifier will be copied
ret_size: Holds the size of the result field.
critical: will be non (0) if the extension is marked as critical (may be null)
This function will return the CRL authority’s key identifier. This is obtained by the X.509 Authority Key identifier extension field (2.5.29.35). Note that this function only returns the keyIdentifier field of the extension.
Returns: On success, (0) is returned, otherwise a negative error code in case of an error.
Since: 2.8.0
crl: should contain a structure
This function will return the number of revoked certificates in the given CRL.
Returns: number of certificates, a negative error code on failure.
crl: should contain a structure
indx: the index of the certificate to extract (starting from 0)
serial: where the serial number will be copied
serial_size: initially holds the size of serial
t: if non null, will hold the time this certificate was revoked
This function will retrieve the serial number of the specified, by the index, revoked certificate.
Returns: On success, (0) is returned, otherwise a negative error value. and a negative error code on error.
crl: should contain a gnutls_x509_crl_t structure
indx: Specifies which DN OID to send. Use (0) to get the first one.
oid: a pointer to a structure to hold the name (may be null)
sizeof_oid: initially holds the size of ’oid’
This function will extract the requested OID of the name of the CRL issuer, specified by the given index.
If oid is null then only the size will be filled.
Returns: 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.
crl: should contain a structure
indx: Specifies which extension OID to send. Use (0) to get the first one.
data: a pointer to a structure to hold the data (may be null)
sizeof_data: initially holds the size of
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 to extract the OID and critical flag. Use instead, if you want to get data indexed by the extension OID rather than sequence.
Returns: On success, (0) is returned, otherwise a negative error code in case of an error. If your have reached the last extension available will be returned.
Since: 2.8.0
crl: should contain a structure
indx: Specifies which extension OID to send, use (0) to get the first one.
oid: a pointer to a structure to hold the OID
sizeof_oid: initially holds the maximum size of , on return holds actual size of .
critical: output variable with critical flag, may be NULL.
This function will return the requested extension OID in the CRL, and the critical flag for it. The extension OID will be stored as a string in the provided buffer. Use to extract the data.
If the buffer provided is not long enough to hold the output, then * is updated and will be returned.
Returns: On success, (0) is returned, otherwise a negative error code in case of an error. If your have reached the last extension available will be returned.
Since: 2.8.0
crl: should contain a structure
indx: Specifies which extension OID to send, use (0) to get the first one.
oid: a pointer to a structure to hold the OID (may be null)
sizeof_oid: initially holds the size of
This function will return the requested extension OID in the CRL. The extension OID will be stored as a string in the provided buffer.
Returns: On success, (0) is returned, otherwise a negative error code in case of an error. If your have reached the last extension available will be returned.
Since: 2.8.0
crl: should contain a gnutls_x509_crl_t structure
oid: holds an Object Identified in null terminated string
indx: In case multiple same OIDs exist in the RDN, this specifies which to send. Use (0) to get the first one.
raw_flag: If non (0) returns the raw DER data of the DN part.
buf: a pointer to a structure to hold the peer’s name (may be null)
sizeof_buf: initially holds the size of
This function will extract the part of the name of the CRL issuer specified by the given OID. The output will be encoded as described in RFC2253. The output string will be ASCII or UTF-8 encoded, depending on the certificate data.
Some helper macros with popular OIDs can be found in gnutls/x509.h If raw flag is (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 .
If buf is null then only the size will be filled.
Returns: 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.
crl: should contain a gnutls_x509_crl_t structure
buf: a pointer to a structure to hold the peer’s name (may be null)
sizeof_buf: initially holds the size of
This function will copy the name of the CRL issuer in the provided buffer. The name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in RFC2253. The output string will be ASCII or UTF-8 encoded, depending on the certificate data.
If buf is then only the size will be filled.
Returns: 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.
crl: should contain a structure
This function will return the time the next CRL will be issued. This field is optional in a CRL so it might be normal to get an error instead.
Returns: when the next CRL will be issued, or (time_t)-1 on error.
crl: should contain a structure
ret: The place where the number will be copied
ret_size: Holds the size of the result field.
critical: will be non (0) if the extension is marked as critical (may be null)
This function will return the CRL number extension. This is obtained by the CRL Number extension field (2.5.29.20).
Returns: On success, (0) is returned, otherwise a negative error code in case of an error.
Since: 2.8.0
crl: should contain a gnutls_x509_crl_t structure
dn: will hold the starting point of the DN
This function will return a pointer to the DER encoded DN structure and the length.
Returns: a negative error code on error, and (0) on success.
Since: 2.12.0
crl: should contain a structure
This function will return a value of the enumeration that is the signature algorithm.
Returns: On success, (0) is returned, otherwise a negative error value.
crl: should contain a gnutls_x509_crl_t structure
sig: a pointer where the signature part will be copied (may be null).
sizeof_sig: initially holds the size of
This function will extract the signature field of a CRL.
Returns: On success, (0) is returned, otherwise a negative error value. and a negative error code on error.
crl: should contain a structure
This function will return the time this CRL was issued.
Returns: when the CRL was issued, or (time_t)-1 on error.
crl: should contain a structure
This function will return the version of the specified CRL.
Returns: The version number, or a negative error code on error.
crl: The structure to store the parsed CRL.
data: The DER or PEM encoded CRL.
format: One of DER or PEM
This function will convert the given DER or PEM encoded CRL to the native format. The output will be stored in ’crl’.
If the CRL is PEM encoded it should have a header of "X509 CRL".
Returns: On success, (0) is returned, otherwise a negative error value.
crl: The structure to be initialized
This function will initialize a CRL structure. CRL stands for Certificate Revocation List. A revocation list usually contains lists of certificate serial numbers that have been revoked by an Authority. The revocation lists are always signed with the authority’s private key.
Returns: On success, (0) is returned, otherwise a negative error value.
crls: The structures to store the parsed crl list. Must not be initialized.
size: It will contain the size of the list.
data: The PEM encoded CRL.
format: One of DER or PEM.
flags: must be (0) or an OR’d sequence of gnutls_certificate_import_flags.
This function will convert the given PEM encoded CRL list to the native gnutls_x509_crl_t format. The output will be stored in . They will be automatically initialized.
If the Certificate is PEM encoded it should have a header of "X509 CRL".
Returns: the number of certificates read or a negative error value.
Since: 3.0.0
crls: The structures to store the parsed CRLs. Must not be initialized.
crl_max: Initially must hold the maximum number of crls. It will be updated with the number of crls available.
data: The PEM encoded CRLs
format: One of DER or PEM.
flags: must be (0) or an OR’d sequence of gnutls_certificate_import_flags.
This function will convert the given PEM encoded CRL list to the native gnutls_x509_crl_t format. The output will be stored in . They will be automatically initialized.
If the Certificate is PEM encoded it should have a header of "X509 CRL".
Returns: the number of certificates read or a negative error value.
Since: 3.0.0
crl: The structure to be printed
format: Indicate the format to use
out: Newly allocated datum with (0) terminated string.
This function will pretty print a X.509 certificate revocation list, suitable for display to a human.
The output needs to be deallocate using .
Returns: On success, (0) is returned, otherwise a negative error value.
crl: should contain a gnutls_x509_crl_t structure
issuer: is the certificate of the certificate issuer
issuer_key: holds the issuer’s private key
dig: The message digest to use. GNUTLS_DIG_SHA1 is the safe choice unless you know what you’re doing.
flags: must be 0
This function will sign the CRL with the issuer’s private key, and will copy the issuer’s information into the CRL.
This must be the last step in a certificate CRL since all the previously set parameters are now signed.
Returns: On success, (0) is returned, otherwise a negative error value.
Since 2.12.0
crl: a CRL of type
id: The key ID
id_size: Holds the size of the serial field.
This function will set the CRL’s authority key ID extension. Only the keyIdentifier field can be set with this function. This may be used by an authority that holds multiple private keys, to distinguish the used key.
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 2.8.0
crl: should contain a gnutls_x509_crl_t structure
serial: The revoked certificate’s serial number
serial_size: Holds the size of the serial field.
revocation_time: The time this certificate was revoked
This function will set a revoked certificate’s serial number to the CRL.
Returns: On success, (0) is returned, otherwise a negative error value.
crl: should contain a gnutls_x509_crl_t structure
crt: a certificate of type with the revoked certificate
revocation_time: The time this certificate was revoked
This function will set a revoked certificate’s serial number to the CRL.
Returns: On success, (0) is returned, otherwise a negative error value.
crl: should contain a gnutls_x509_crl_t structure
exp_time: The actual time
This function will set the time this CRL will be updated.
Returns: On success, (0) is returned, otherwise a negative error value.
crl: a CRL of type
nr: The CRL number
nr_size: Holds the size of the nr field.
This function will set the CRL’s number extension. This is to be used as a unique and monotonic number assigned to the CRL by the authority.
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 2.8.0
crl: should contain a gnutls_x509_crl_t structure
act_time: The actual time
This function will set the time this CRL was issued.
Returns: On success, (0) is returned, otherwise a negative error value.
crl: should contain a gnutls_x509_crl_t structure
version: holds the version number. For CRLv1 crls must be 1.
This function will set the version of the CRL. This must be one for CRL version 1, and so on. The CRLs generated by gnutls should have a version number of 2.
Returns: On success, (0) is returned, otherwise a negative error value.
crl: should contain a gnutls_x509_crl_t structure
issuer: is the certificate of the certificate issuer
issuer_key: holds the issuer’s private key
dig: The message digest to use. GNUTLS_DIG_SHA1 is the safe choice unless you know what you’re doing.
flags: must be 0
This function will sign the CRL with the issuer’s private key, and will copy the issuer’s information into the CRL.
This must be the last step in a certificate CRL since all the previously set parameters are now signed.
Returns: On success, (0) is returned, otherwise a negative error value.
crl: should contain a gnutls_x509_crl_t structure
issuer: is the certificate of the certificate issuer
issuer_key: holds the issuer’s private key
This function is the same a with no flags, and SHA1 as the hash algorithm.
Returns: On success, (0) is returned, otherwise a negative error value.
Deprecated: Use .
crl: is the crl to be verified
CA_list: is a certificate list that is considered to be trusted one
CA_list_length: holds the number of CA certificates in CA_list
flags: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
verify: will hold the crl verification output.
This function will try to verify the given crl and return its status. See for a detailed description of return values.
Returns: On success, (0) is returned, otherwise a negative error value.
crq: The structure to be initialized
This function will deinitialize a PKCS certificate request structure.
crq: should contain a structure
format: the format of output params. One of PEM or DER.
output_data: will contain a certificate request PEM or DER encoded
output_data_size: holds the size of output_data (and will be replaced by the actual size of parameters)
This function will export the certificate request to a PEM or DER encoded PKCS10 structure.
If the buffer provided is not long enough to hold the output, then will be returned and * will be updated.
If the structure is PEM encoded, it will have a header of "BEGIN NEW CERTIFICATE REQUEST".
Returns: On success, (0) is returned, otherwise a negative error value.
crq: should contain a structure
oid: holds an Object Identified in (0)-terminated string
indx: In case multiple same OIDs exist in the attribute list, this specifies which to send, use (0) to get the first one
buf: a pointer to a structure to hold the attribute data (may be )
sizeof_buf: initially holds the size of
This function will return the attribute in the certificate request specified by the given Object ID. The attribute will be DER encoded.
Returns: On success, (0) is returned, otherwise a negative error value.
crq: should contain a structure
indx: Specifies which attribute OID to send. Use (0) to get the first one.
data: a pointer to a structure to hold the data (may be null)
sizeof_data: initially holds the size of
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 to extract the OID. Use instead, if you want to get data indexed by the attribute OID rather than sequence.
Returns: On success, (0) is returned, otherwise a negative error code in case of an error. If your have reached the last extension available will be returned.
Since: 2.8.0
crq: should contain a structure
indx: Specifies which attribute OID to send. Use (0) to get the first one.
oid: a pointer to a structure to hold the OID
sizeof_oid: initially holds the maximum size of , on return holds actual size of .
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 to extract the data.
If the buffer provided is not long enough to hold the output, then * is updated and will be returned.
Returns: On success, (0) is returned, otherwise a negative error code in case of an error. If your have reached the last extension available will be returned.
Since: 2.8.0
crq: should contain a structure
critical: will be non (0) if the extension is marked as critical
ca: pointer to output integer indicating CA status, may be NULL, value is 1 if the certificate CA flag is set, 0 otherwise.
pathlen: pointer to output integer indicating path length (may be NULL), non-negative error codes indicate a present pathLenConstraint field and the actual value, -1 indicate that the field is absent.
This function will read the certificate’s basic constraints, and return the certificates CA status. It reads the basicConstraints X.509 extension (2.5.29.19).
Returns: If the certificate is a CA a positive value will be returned, or (0) if the certificate does not have CA flag set. A negative error code may be returned in case of errors. If the certificate does not contain the basicConstraints extension will be returned.
Since: 2.8.0
crq: should contain a structure
pass: will hold a (0)-terminated password string
sizeof_pass: Initially holds the size of .
This function will return the challenge password in the request. The challenge password is intended to be used for requesting a revocation of the certificate.
Returns: On success, (0) is returned, otherwise a negative error value.
crq: should contain a gnutls_x509_crq_t structure
oid: holds an Object Identified in null terminated string
indx: In case multiple same OIDs exist in the RDN, this specifies which to send. Use (0) to get the first one.
raw_flag: If non (0) returns the raw DER data of the DN part.
buf: a pointer to a structure to hold the name (may be )
sizeof_buf: initially holds the size of
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 .
Returns: if the provided buffer is not long enough, and in that case the * will be updated with the required size. On success 0 is returned.
crq: should contain a gnutls_x509_crq_t structure
indx: Specifies which DN OID to send. Use (0) to get the first one.
oid: a pointer to a structure to hold the name (may be )
sizeof_oid: initially holds the size of
This function will extract the requested OID of the name of the certificate request subject, specified by the given index.
Returns: if the provided buffer is not long enough, and in that case the * will be updated with the required size. On success 0 is returned.
crq: should contain a structure
buf: a pointer to a structure to hold the name (may be )
sizeof_buf: initially holds the size of
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 will be ASCII or UTF-8 encoded, depending on the certificate data.
Returns: if the provided buffer is not long enough, and in that case the * will be updated with the required size. On success 0 is returned.
crq: should contain a structure
oid: holds an Object Identified in null terminated string
indx: In case multiple same OIDs exist in the extensions, this specifies which to send. Use (0) to get the first one.
buf: a pointer to a structure to hold the name (may be null)
sizeof_buf: initially holds the size of
critical: will be non (0) if the extension is marked as critical
This function will return the extension specified by the OID in the certificate. The extensions will be returned as binary data DER encoded, in the provided buffer.
Returns: On success, (0) is returned, otherwise a negative error code in case of an error. If the certificate does not contain the specified extension will be returned.
Since: 2.8.0
crq: should contain a structure
indx: Specifies which extension OID to send. Use (0) to get the first one.
data: a pointer to a structure to hold the data (may be null)
sizeof_data: initially holds the size of
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 to extract the OID and critical flag. Use instead, if you want to get data indexed by the extension OID rather than sequence.
Returns: On success, (0) is returned, otherwise a negative error code in case of an error. If your have reached the last extension available will be returned.
Since: 2.8.0
crq: should contain a structure
indx: Specifies which extension OID to send. Use (0) to get the first one.
oid: a pointer to a structure to hold the OID
sizeof_oid: initially holds the maximum size of , on return holds actual size of .
critical: output variable with critical flag, may be NULL.
This function will return the requested extension OID in the certificate, and the critical flag for it. The extension OID will be stored as a string in the provided buffer. Use to extract the data.
If the buffer provided is not long enough to hold the output, then * is updated and will be returned.
Returns: On success, (0) is returned, otherwise a negative error code in case of an error. If your have reached the last extension available will be returned.
Since: 2.8.0
crq: a certificate of type
flags: should be 0 for now
output_data: will contain the key ID
output_data_size: holds the size of output_data (and will be replaced by the actual size of parameters)
This function will return a unique ID the depends on the public key parameters. This ID can be used in checking whether a certificate corresponds to the given private key.
If the buffer provided is not long enough to hold the output, then * is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will be returned. The output will normally be a SHA-1 hash output, which is 20 bytes.
Returns: In case of failure a negative error code will be returned, and 0 on success.
Since: 2.8.0
crq: should contain a structure
indx: This specifies which OID to return, use (0) to get the first one
oid: a pointer to a buffer to hold the OID (may be )
sizeof_oid: initially holds the size of
critical: output variable with critical flag, may be .
This function will extract the key purpose OIDs of the Certificate specified by the given index. These are stored in the Extended Key Usage extension (2.5.29.37). See the GNUTLS_KP_* definitions for human readable names.
Returns: if the provided buffer is not long enough, and in that case the * will be updated with the required size. On success 0 is returned.
Since: 2.8.0
crq: Holds the certificate
m: will hold the modulus
e: will hold the public exponent
This function will export the RSA public key’s parameters found in the given structure. The new parameters will be allocated using and will be stored in the appropriate datum.
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 2.8.0
crq: should contain a structure
key_usage: where the key usage bits will be stored
critical: will be non (0) if the extension is marked as critical
This function will return certificate’s key usage, by reading the keyUsage X.509 extension (2.5.29.15). The key usage value will
ORed values of the: , , , , , , , , .
Returns: the certificate key usage, or a negative error code in case of parsing error. If the certificate does not contain the keyUsage extension will be returned.
Since: 2.8.0
crq: should contain a structure
bits: if bits is non- it will hold the size of the parameters’ in bits
This function will return the public key algorithm of a PKCS certificate request.
If bits is non-, it should have enough size to hold the parameters size in bits. For RSA the bits returned is the modulus. For DSA the bits returned are of the public exponent.
Returns: a member of the enumeration on success, or a negative error code on error.
crq: should contain a structure
seq: specifies the sequence number of the alt name, 0 for the first one, 1 for the second etc.
ret: is the place where the alternative name will be copied to
ret_size: holds the size of ret.
ret_type: holds the name type
critical: will be non (0) if the extension is marked as critical (may be null)
This function will return the alternative names, contained in the given certificate. It is the same as except for the fact that it will return the type of the alternative name in even if the function fails for some reason (i.e. the buffer provided is not enough).
Returns: the alternative subject name type on success, one of the enumerated . It will return if is not large enough to hold the value. In that case will be updated with the required size. If the certificate request does not have an Alternative name with the specified sequence number then is returned.
Since: 2.8.0
crq: should contain a structure
seq: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
ret: is the place where the otherName OID will be copied to
ret_size: holds the size of ret.
This function will extract the type OID of an otherName Subject Alternative Name, contained in the given certificate, and return the type as an enumerated element.
This function is only useful if returned .
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. , and for unknown OIDs. It will return if is not large enough to hold the value. In that case 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 is returned.
Since: 2.8.0
crq: should contain a structure
This function will return the version of the specified Certificate request.
Returns: version of certificate request, or a negative error code on error.
crq: The structure to store the parsed certificate request.
data: The DER or PEM encoded certificate.
format: One of DER or PEM
This function will convert the given DER or PEM encoded certificate request to a structure. The output will be stored in .
If the Certificate is PEM encoded it should have a header of "NEW CERTIFICATE REQUEST".
Returns: On success, (0) is returned, otherwise a negative error value.
crq: The structure to be initialized
This function will initialize a PKCS certificate request structure.
Returns: On success, (0) is returned, otherwise a negative error value.
crq: The structure to be printed
format: Indicate the format to use
out: Newly allocated datum with (0) terminated string.
This function will pretty print a certificate request, suitable for display to a human.
The output needs to be deallocate using .
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 2.8.0
crq: should contain a structure
key: holds a private key
dig: The message digest to use, i.e.,
flags: must be 0
This function will sign the certificate request with a private key. This must be the same key as the one used in since a certificate request is self signed.
This must be the last step in a certificate request generation since all the previously set parameters are now signed.
Returns: on success, otherwise a negative error code. is returned if you didn’t set all information in the certificate request (e.g., the version using ).
Since: 2.12.0
crq: should contain a structure
oid: holds an Object Identified in (0)-terminated string
buf: a pointer to a structure that holds the attribute data
sizeof_buf: holds the size of
This function will set the attribute in the certificate request specified by the given Object ID. The attribute must be be DER encoded.
Returns: On success, (0) is returned, otherwise a negative error value.
crq: a certificate request of type
ca: true(1) or false(0) depending on the Certificate authority status.
pathLenConstraint: non-negative error codes indicate maximum length of path, and negative error codes indicate that the pathLenConstraints field should not be present.
This function will set the basicConstraints certificate extension.
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 2.8.0
crq: should contain a structure
pass: holds a (0)-terminated password
This function will set a challenge password to be used when revoking the request.
Returns: On success, (0) is returned, otherwise a negative error value.
crq: should contain a structure
oid: holds an Object Identifier in a (0)-terminated string
raw_flag: must be 0, or 1 if the data are DER encoded
data: a pointer to the input data
sizeof_data: holds the size of
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 . For OIDs that are not known (by gnutls) you should properly DER encode your data, and call this function with raw_flag set.
Returns: On success, (0) is returned, otherwise a negative error value.
crq: a certificate of type
oid: a pointer to a (0)-terminated string that holds the OID
critical: Whether this extension will be critical or not
This function will set the key purpose OIDs of the Certificate. These are stored in the Extended Key Usage extension (2.5.29.37) See the GNUTLS_KP_* definitions for human readable names.
Subsequent calls to this function will append OIDs to the OID list.
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 2.8.0
crq: should contain a structure
m: holds the modulus
e: holds the public exponent
This function will set the public parameters from the given private key to the request. Only RSA keys are currently supported.
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 2.6.0
crq: a certificate request of type
usage: an ORed sequence of the GNUTLS_KEY_* elements.
This function will set the keyUsage certificate extension.
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 2.8.0
crq: should contain a structure
key: holds a private key
This function will set the public parameters from the given private key to the request.
Returns: On success, (0) is returned, otherwise a negative error value.
crq: a certificate request of type
nt: is one of the enumerations
data: The data to be set
data_size: The size of data to be set
flags: to clear previous data or to append.
This function will set the subject alternative name certificate extension. It can set the following types:
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 2.8.0
crq: should contain a structure
version: holds the version number, for v1 Requests must be 1
This function will set the version of the certificate request. For version 1 requests this must be one.
Returns: On success, (0) is returned, otherwise a negative error value.
crq: should contain a structure
key: holds a private key
dig: The message digest to use, i.e.,
flags: must be 0
This function will sign the certificate request with a private key. This must be the same key as the one used in since a certificate request is self signed.
This must be the last step in a certificate request generation since all the previously set parameters are now signed.
Returns: on success, otherwise a negative error code. is returned if you didn’t set all information in the certificate request (e.g., the version using ).
crq: should contain a structure
key: holds a private key
This function is the same a with no flags, and SHA1 as the hash algorithm.
Returns: On success, (0) is returned, otherwise a negative error value.
Deprecated: Use instead.
crq: is the crq to be verified
flags: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
This function will verify self signature in the certificate request and return its status.
Returns: On success, (0) is returned, if verification failed, otherwise a negative error value.
Since 2.12.0
cert: should contain an gnutls_x509_crt_t structure
hostname: A null terminated string that contains a DNS name
This function will check if the given certificate’s subject matches the given hostname. This is a basic implementation of the matching described in RFC2818 (HTTPS), which takes into account wildcards, and the DNSName/IPAddress subject alternative name PKIX extension.
Returns: non (0) for a successful match, and (0) on failure.
cert: is the certificate to be checked
issuer: is the certificate of a possible issuer
This function will check if the given certificate was issued by the given issuer.
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.
cert: should contain a structure
crl_list: should contain a list of gnutls_x509_crl_t structures
crl_list_length: the length of the crl_list
This function will return check if the given certificate is revoked. It is assumed that the CRLs have been verified before.
Returns: 0 if the certificate is NOT revoked, and 1 if it is. A negative error code is returned on error.
dst: a certificate of type
src: the certificate where the dist points will be copied from
This function will copy the CRL distribution points certificate extension, from the source to the destination certificate. This may be useful to copy from a CA certificate to issued ones.
Returns: On success, (0) is returned, otherwise a negative error value.
cert: The structure to be deinitialized
This function will deinitialize a certificate structure.
cert: Holds the certificate
format: the format of output params. One of PEM or DER.
output_data: will contain a certificate PEM or DER encoded
output_data_size: holds the size of output_data (and will be replaced by the actual size of parameters)
This function will export the certificate to DER or PEM format.
If the buffer provided is not long enough to hold the output, then *output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.
If the structure is PEM encoded, it will have a header of "BEGIN CERTIFICATE".
Returns: In case of failure a negative error code will be returned, and 0 on success.
cert: should contain a structure
This function will return the time this Certificate was or will be activated.
Returns: activation time, or (time_t)-1 on error.
crt: Holds the certificate
seq: specifies the sequence number of the access descriptor (0 for the first one, 1 for the second etc.)
what: what data to get, a type.
data: output data to be freed with .
critical: pointer to output integer that is set to non-0 if the extension is marked as critical (may be )
This function extracts the Authority Information Access (AIA) extension, see RFC 5280 section 4.2.2.1 for more information. The AIA extension holds a sequence of AccessDescription (AD) data:
<informalexample><programlisting>
AuthorityInfoAccessSyntax : := SEQUENCE SIZE (1..MAX) OF AccessDescription
AccessDescription : := SEQUENCE { accessMethod OBJECT IDENTIFIER, accessLocation GeneralName } </programlisting></informalexample>
The input parameter is used to indicate which member of the sequence the caller is interested in. The first member is 0, the second member 1 and so on. When the value is out of bounds, is returned.
The type of data returned in is specified via which should be values.
If is then will hold the accessMethod OID (e.g., "1.3.6.1.5.5.7.48.1").
If is , will hold the accessLocation GeneralName type (e.g., "uniformResourceIdentifier").
If is , will hold the accessLocation URI data. Requesting this value leads to an error if the accessLocation is not of the "uniformResourceIdentifier" type.
If is , will hold the OCSP URI. Requesting this value leads to an error if the accessMethod is not 1.3.6.1.5.5.7.48.1 aka OSCP, or if accessLocation is not of the "uniformResourceIdentifier" type.
If is , will hold the caIssuers URI. Requesting this value leads to an error if the accessMethod is not 1.3.6.1.5.5.7.48.2 aka caIssuers, or if accessLocation is not of the "uniformResourceIdentifier" type.
More values may be allocated in the future as needed.
If is NULL, the function does the same without storing the output data, that is, it will set and do error checking as usual.
The value of the critical flag is returned in *. Supply a NULL if you want the function to make sure the extension is non-critical, as required by RFC 5280.
Returns: on success, on invalid , if the extension is incorrectly marked as critical (use a non-NULL to override), if the requested OID does not match (e.g., when using ), otherwise a negative error code.
Since: 3.0.0
cert: should contain a structure
ret: The place where the identifier will be copied
ret_size: Holds the size of the result field.
critical: will be non (0) if the extension is marked as critical (may be null)
This function will return the X.509v3 certificate authority’s key identifier. This is obtained by the X.509 Authority Key identifier extension field (2.5.29.35). Note that this function only returns the keyIdentifier field of the extension.
Returns: On success, (0) is returned, otherwise a negative error value.
cert: should contain a structure
critical: will be non (0) if the extension is marked as critical
ca: pointer to output integer indicating CA status, may be NULL, value is 1 if the certificate CA flag is set, 0 otherwise.
pathlen: pointer to output integer indicating path length (may be NULL), non-negative error codes indicate a present pathLenConstraint field and the actual value, -1 indicate that the field is absent.
This function will read the certificate’s basic constraints, and return the certificates CA status. It reads the basicConstraints X.509 extension (2.5.29.19).
Returns: If the certificate is a CA a positive value will be returned, or (0) if the certificate does not have CA flag set. A negative error code may be returned in case of errors. If the certificate does not contain the basicConstraints extension GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
cert: should contain a structure
critical: will be non (0) if the extension is marked as critical
This function will return certificates CA status, by reading the basicConstraints X.509 extension (2.5.29.19). If the certificate is a CA a positive value will be returned, or (0) if the certificate does not have CA flag set.
Use if you want to read the pathLenConstraint field too.
Returns: A negative error code may be returned in case of parsing error. If the certificate does not contain the basicConstraints extension will be returned.
cert: should contain a structure
seq: specifies the sequence number of the distribution point (0 for the first one, 1 for the second etc.)
ret: is the place where the distribution point will be copied to
ret_size: holds the size of ret.
reason_flags: Revocation reasons flags.
critical: will be non (0) if the extension is marked as critical (may be null)
This function retrieves the CRL distribution points (2.5.29.31), contained in the given certificate in the X509v3 Certificate Extensions.
should be an ORed sequence of , , , , , , , , , or (0) for all possible reasons.
Returns: and updates if 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 . If the certificate does not have an Alternative name with the specified sequence number then is returned.
cert: should contain a structure
oid: holds an Object Identified in null terminated string
indx: In case multiple same OIDs exist in the RDN, this specifies which to send. Use (0) to get the first one.
raw_flag: If non (0) returns the raw DER data of the DN part.
buf: a pointer where the DN part will be copied (may be null).
buf_size: initially holds the size of
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 RFC2253. 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 RFC2253 – in hex format with a ’\#’ prefix. You can check about known OIDs using .
If is null then only the size will be filled. If the is not specified the output is always null terminated, although the will not include the null character.
Returns: 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.
cert: should contain a structure
indx: This specifies which OID to return. Use (0) to get the first one.
oid: a pointer to a buffer to hold the OID (may be null)
oid_size: initially holds the size of
This function will extract the OIDs of the name of the Certificate subject specified by the given index.
If is null then only the size will be filled. If the is not specified the output is always null terminated, although the will not include the null character.
Returns: if the provided buffer is not long enough, and in that case the will be updated with the required size. On success 0 is returned.
cert: should contain a structure
buf: a pointer to a structure to hold the name (may be null)
buf_size: initially holds the size of
This function will copy the name of the Certificate in the provided buffer. The name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in RFC2253. The output string will be ASCII or UTF-8 encoded, depending on the certificate data.
If is null then only the size will be filled. If the is not specified the output is always null terminated, although the will not include the null character.
Returns: if the provided buffer is not long enough, and in that case the will be updated with the required size. On success 0 is returned.
cert: should contain a structure
This function will return the time this Certificate was or will be expired.
Returns: expiration time, or (time_t)-1 on error.
cert: should contain a structure
oid: holds an Object Identified in null terminated string
indx: In case multiple same OIDs exist in the extensions, this specifies which to send. Use (0) to get the first one.
buf: a pointer to a structure to hold the name (may be null)
buf_size: initially holds the size of
critical: will be non (0) if the extension is marked as critical
This function will return the extension specified by the OID in the certificate. The extensions will be returned as binary data DER encoded, in the provided buffer.
Returns: On success, (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.
cert: should contain a structure
indx: Specifies which extension OID to send. Use (0) to get the first one.
data: a pointer to a structure to hold the data (may be null)
sizeof_data: initially holds the size of
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 to extract the OID and critical flag. Use instead, if you want to get data indexed by the extension OID rather than sequence.
Returns: On success, (0) is returned, otherwise a negative error code is returned. If you have reached the last extension available will be returned.
cert: should contain a structure
indx: Specifies which extension OID to send. Use (0) to get the first one.
oid: a pointer to a structure to hold the OID
oid_size: initially holds the maximum size of , on return holds actual size of .
critical: output variable with critical flag, may be NULL.
This function will return the requested extension OID in the certificate, and the critical flag for it. The extension OID will be stored as a string in the provided buffer. Use to extract the data.
If the buffer provided is not long enough to hold the output, then * is updated and will be returned.
Returns: On success, (0) is returned, otherwise a negative error code is returned. If you have reached the last extension available will be returned.
cert: should contain a structure
indx: Specifies which extension OID to send. Use (0) to get the first one.
oid: a pointer to a structure to hold the OID (may be null)
oid_size: initially holds the size of
This function will return the requested extension OID in the certificate. The extension OID will be stored as a string in the provided buffer.
Returns: On success, (0) is returned, otherwise a negative error code is returned. If you have reached the last extension available will be returned.
cert: should contain a structure
algo: is a digest algorithm
buf: a pointer to a structure to hold the fingerprint (may be null)
buf_size: initially holds the size of
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.
Returns: 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.
cert: should contain a structure
seq: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
ret: is the place where the alternative name will be copied to
ret_size: holds the size of ret.
ret_type: holds the type of the alternative name (one of gnutls_x509_subject_alt_name_t).
critical: will be non (0) if the extension is marked as critical (may be null)
This function will return the alternative names, contained in the given certificate. It is the same as except for the fact that it will return the type of the alternative name in even if the function fails for some reason (i.e. the buffer provided is not enough).
Returns: the alternative issuer name type on success, one of the enumerated . It will return if is not large enough to hold the value. In that case will be updated with the required size. If the certificate does not have an Alternative name with the specified sequence number then is returned.
Since: 2.10.0
cert: should contain a structure
seq: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
ret: is the place where the alternative name will be copied to
ret_size: holds the size of ret.
critical: will be non (0) if the extension is marked as critical (may be null)
This function retrieves the Issuer Alternative Name (2.5.29.18), contained in the given certificate in the X509v3 Certificate Extensions.
When the SAN type is otherName, it will extract the data in the otherName’s value field, and is returned. You may use to get the corresponding OID and the "virtual" SAN types (e.g., ).
If an otherName OID is known, the data will be decoded. Otherwise the returned data will be DER encoded, and you will have to decode it yourself. Currently, only the RFC 3920 id-on-xmppAddr Issuer AltName is recognized.
Returns: the alternative issuer name type on success, one of the enumerated . It will return if is not large enough to hold the value. In that case will be updated with the required size. If the certificate does not have an Alternative name with the specified sequence number then is returned.
Since: 2.10.0
cert: should contain a structure
seq: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
ret: is the place where the otherName OID will be copied to
ret_size: holds the size of ret.
This function will extract the type OID of an otherName Subject Alternative Name, contained in the given certificate, and return the type as an enumerated element.
If is null then only the size will be filled. If the is not specified the output is always null terminated, although the will not include the null character.
This function is only useful if returned .
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. , and for unknown OIDs. It will return if is not large enough to hold the value. In that case 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 is returned.
Since: 2.10.0
cert: should contain a structure
oid: holds an Object Identified in null terminated string
indx: In case multiple same OIDs exist in the RDN, this specifies which to send. Use (0) to get the first one.
raw_flag: If non (0) returns the raw DER data of the DN part.
buf: a pointer to a structure to hold the name (may be null)
buf_size: initially holds the size of
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 RFC2253. 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 RFC2253 – in hex format with a ’\#’ prefix. You can check about known OIDs using .
If is null then only the size will be filled. If the is not specified the output is always null terminated, although the will not include the null character.
Returns: GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not long enough, and in that case the will be updated with the required size. On success 0 is returned.
cert: should contain a structure
indx: This specifies which OID to return. Use (0) to get the first one.
oid: a pointer to a buffer to hold the OID (may be null)
oid_size: initially holds the size of
This function will extract the OIDs of the name of the Certificate issuer specified by the given index.
If is null then only the size will be filled. If the is not specified the output is always null terminated, although the will not include the null character.
Returns: GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not long enough, and in that case the will be updated with the required size. On success 0 is returned.
cert: should contain a structure
buf: a pointer to a structure to hold the name (may be null)
buf_size: initially holds the size of
This function will copy the name of the Certificate issuer in the provided buffer. The name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in RFC2253. The output string will be ASCII or UTF-8 encoded, depending on the certificate data.
If is null then only the size will be filled. If the is not specified the output is always null terminated, although the will not include the null character.
Returns: GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not long enough, and in that case the will be updated with the required size. On success 0 is returned.
crt: Holds the certificate
buf: user allocated memory buffer, will hold the unique id
buf_size: size of user allocated memory buffer (on input), will hold actual size of the unique ID on return.
This function will extract the issuerUniqueID value (if present) for the given certificate.
If the user allocated memory buffer is not large enough to hold the full subjectUniqueID, then a GNUTLS_E_SHORT_MEMORY_BUFFER error will be returned, and buf_size will be set to the actual length.
Returns: on success, otherwise a negative error code.
Since: 2.12.0
cert: should contain a structure
dn: output variable with pointer to opaque DN
Return the Certificate’s Issuer DN as an opaque data type. You may use to decode the DN.
Note that should be treated as constant. Because points into the object, you may not deallocate and continue to access .
Returns: Returns 0 on success, or an error code.
crt: Holds the certificate
flags: should be 0 for now
output_data: will contain the key ID
output_data_size: holds the size of output_data (and will be replaced by the actual size of parameters)
This function will return a unique ID the depends on the public key parameters. This ID can be used in checking whether a certificate corresponds to the given private key.
If the buffer provided is not long enough to hold the output, then *output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will be returned. The output will normally be a SHA-1 hash output, which is 20 bytes.
Returns: In case of failure a negative error code will be returned, and 0 on success.
cert: should contain a structure
indx: This specifies which OID to return. Use (0) to get the first one.
oid: a pointer to a buffer to hold the OID (may be null)
oid_size: initially holds the size of
critical: output flag to indicate criticality of extension
This function will extract the key purpose OIDs of the Certificate specified by the given index. These are stored in the Extended Key Usage extension (2.5.29.37) See the GNUTLS_KP_* definitions for human readable names.
If is null then only the size will be filled. If the is not specified the output is always null terminated, although the will not include the null character.
Returns: 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.
cert: should contain a structure
key_usage: where the key usage bits will be stored
critical: will be non (0) if the extension is marked as critical
This function will return certificate’s key usage, by reading the keyUsage X.509 extension (2.5.29.15). The key usage value will ORed values of the: , , , , , , , , .
Returns: the certificate key usage, or a negative error code in case of parsing error. If the certificate does not contain the keyUsage extension will be returned.
cert: should contain a structure
bits: if bits is non null it will hold the size of the parameters’ in bits
This function will return the public key algorithm of an X.509 certificate.
If bits is non null, it should have enough size to hold the parameters size in bits. For RSA the bits returned is the modulus. For DSA the bits returned are of the public exponent.
Returns: a member of the enumeration on success, or a negative error code on error.
crt: Holds the certificate
p: will hold the p
q: will hold the q
g: will hold the g
y: will hold the y
This function will export the DSA public key’s parameters found in the given certificate. The new parameters will be allocated using and will be stored in the appropriate datum.
Returns: on success, otherwise a negative error code.
crt: Holds the certificate
m: will hold the modulus
e: will hold the public exponent
This function will export the RSA public key’s parameters found in the given structure. The new parameters will be allocated using and will be stored in the appropriate datum.
Returns: on success, otherwise a negative error code.
crt: Holds the certificate
hash: The result of the call with the hash algorithm used for signature
mand: If non (0) it means that the algorithm MUST use this hash. May be NULL.
This function will read the certifcate and return the appropriate digest algorithm to use for signing with this certificate. Some certificates (i.e. DSA might not be able to sign without the preferred algorithm).
Deprecated: Please use .
Returns: the 0 if the hash algorithm is found. A negative error code is returned on error.
Since: 2.12.0
cert: should contain a structure
critical: will be non (0) if the extension is marked as critical
pathlen: pointer to output integer indicating path length (may be NULL), non-negative error codes indicate a present pCPathLenConstraint field and the actual value, -1 indicate that the field is absent.
policyLanguage: output variable with OID of policy language
policy: output variable with policy data
sizeof_policy: output variable size of policy data
This function will get information from a proxy certificate. It reads the ProxyCertInfo X.509 extension (1.3.6.1.5.5.7.1.14).
Returns: On success, (0) is returned, otherwise a negative error code is returned.
cert: should contain a structure
start: will hold the starting point of the DN
This function will return a pointer to the DER encoded DN structure and the length.
Returns: On success, (0) is returned, otherwise a negative error value. or a negative error code on error.
cert: should contain a structure
start: will hold the starting point of the DN
This function will return a pointer to the DER encoded DN structure and the length.
Returns: On success, (0) is returned, otherwise a negative error value.or a negative error code on error.
cert: should contain a structure
result: The place where the serial number will be copied
result_size: Holds the size of the result field.
This function will return the X.509 certificate’s serial number. This is obtained by the X509 Certificate serialNumber field. Serial is not always a 32 or 64bit number. Some CAs use large serial numbers, thus it may be wise to handle it as something opaque.
Returns: On success, (0) is returned, otherwise a negative error value.
cert: should contain a structure
This function will return a value of the enumeration that is the signature algorithm that has been used to sign this certificate.
Returns: a value, or a negative error code on error.
cert: should contain a structure
sig: a pointer where the signature part will be copied (may be null).
sizeof_sig: initially holds the size of
This function will extract the signature field of a certificate.
Returns: On success, (0) is returned, otherwise a negative error value. and a negative error code on error.
cert: should contain a structure
seq: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
ret: is the place where the alternative name will be copied to
ret_size: holds the size of ret.
ret_type: holds the type of the alternative name (one of gnutls_x509_subject_alt_name_t).
critical: will be non (0) if the extension is marked as critical (may be null)
This function will return the alternative names, contained in the given certificate. It is the same as except for the fact that it will return the type of the alternative name in even if the function fails for some reason (i.e. the buffer provided is not enough).
Returns: the alternative subject name type on success, one of the enumerated . It will return if is not large enough to hold the value. In that case will be updated with the required size. If the certificate does not have an Alternative name with the specified sequence number then is returned.
cert: should contain a structure
seq: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
ret: is the place where the alternative name will be copied to
ret_size: holds the size of ret.
critical: will be non (0) if the extension is marked as critical (may be null)
This function retrieves the Alternative Name (2.5.29.17), contained in the given certificate in the X509v3 Certificate Extensions.
When the SAN type is otherName, it will extract the data in the otherName’s value field, and is returned. You may use to get the corresponding OID and the "virtual" SAN types (e.g., ).
If an otherName OID is known, the data will be decoded. Otherwise the returned data will be DER encoded, and you will have to decode it yourself. Currently, only the RFC 3920 id-on-xmppAddr SAN is recognized.
Returns: the alternative subject name type on success, one of the enumerated . It will return if is not large enough to hold the value. In that case will be updated with the required size. If the certificate does not have an Alternative name with the specified sequence number then is returned.
cert: should contain a structure
seq: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
oid: is the place where the otherName OID will be copied to
oid_size: holds the size of ret.
This function will extract the type OID of an otherName Subject Alternative Name, contained in the given certificate, and return the type as an enumerated element.
This function is only useful if returned .
If is null then only the size will be filled. If the is not specified the output is always null terminated, although the will not include the null character.
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. , and for unknown OIDs. It will return if is not large enough to hold the value. In that case 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 is returned.
cert: should contain a structure
ret: The place where the identifier will be copied
ret_size: Holds the size of the result field.
critical: will be non (0) if the extension is marked as critical (may be null)
This function will return the X.509v3 certificate’s subject key identifier. This is obtained by the X.509 Subject Key identifier extension field (2.5.29.14).
Returns: On success, (0) is returned, otherwise a negative error value.
crt: Holds the certificate
buf: user allocated memory buffer, will hold the unique id
buf_size: size of user allocated memory buffer (on input), will hold actual size of the unique ID on return.
This function will extract the subjectUniqueID value (if present) for the given certificate.
If the user allocated memory buffer is not large enough to hold the full subjectUniqueID, then a GNUTLS_E_SHORT_MEMORY_BUFFER error will be returned, and buf_size will be set to the actual length.
Returns: on success, otherwise a negative error code.
cert: should contain a structure
dn: output variable with pointer to opaque DN.
Return the Certificate’s Subject DN as an opaque data type. You may use to decode the DN.
Note that should be treated as constant. Because points into the object, you may not deallocate and continue to access .
Returns: Returns 0 on success, or an error code.
crt: Holds the certificate
signature: contains the signature
hash: The result of the call with the hash algorithm used for signature
This function will read the certifcate and the signed data to determine the hash algorithm used to generate the signature.
Deprecated: Use instead.
Returns: the 0 if the hash algorithm is found. A negative error code is returned on error.
Since: 2.8.0
cert: should contain a structure
This function will return the version of the specified Certificate.
Returns: version of certificate, or a negative error code on error.
cert: The structure to store the parsed certificate.
data: The DER or PEM encoded certificate.
format: One of DER or PEM
This function will convert the given DER or PEM encoded Certificate to the native gnutls_x509_crt_t format. The output will be stored in .
If the Certificate is PEM encoded it should have a header of "X509 CERTIFICATE", or "CERTIFICATE".
Returns: On success, (0) is returned, otherwise a negative error value.
cert: The structure to be initialized
This function will initialize an X.509 certificate structure.
Returns: On success, (0) is returned, otherwise a negative error value.
certs: The structures to store the parsed certificate. Must not be initialized.
size: It will contain the size of the list.
data: The PEM encoded certificate.
format: One of DER or PEM.
flags: must be (0) or an OR’d sequence of gnutls_certificate_import_flags.
This function will convert the given PEM encoded certificate list to the native gnutls_x509_crt_t format. The output will be stored in . They will be automatically initialized.
If the Certificate is PEM encoded it should have a header of "X509 CERTIFICATE", or "CERTIFICATE".
Returns: the number of certificates read or a negative error value.
Since: 3.0.0
certs: The structures to store the parsed certificate. Must not be initialized.
cert_max: Initially must hold the maximum number of certs. It will be updated with the number of certs available.
data: The PEM encoded certificate.
format: One of DER or PEM.
flags: must be (0) or an OR’d sequence of gnutls_certificate_import_flags.
This function will convert the given PEM encoded certificate list to the native gnutls_x509_crt_t format. The output will be stored in . They will be automatically initialized.
The flag will cause import to fail if the certificates in the provided buffer are more than the available structures. The flag will cause the function to fail if the provided list is not sorted from subject to issuer.
If the Certificate is PEM encoded it should have a header of "X509 CERTIFICATE", or "CERTIFICATE".
Returns: the number of certificates read or a negative error value.
cert_list: is the certificate list to be verified
cert_list_length: holds the number of certificate in cert_list
CA_list: is the CA list which will be used in verification
CA_list_length: holds the number of CA certificate in CA_list
CRL_list: holds a list of CRLs.
CRL_list_length: the length of CRL list.
flags: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
verify: will hold the certificate verification output.
This function will try to verify the given certificate list and return its status. If no flags are specified (0), this function will use the basicConstraints (2.5.29.19) PKIX extension. This means that only a certificate authority is allowed to sign a certificate.
You must also check the peer’s name in order to check if the verified certificate belongs to the actual peer.
The certificate verification output will be put in and will be one or more of the gnutls_certificate_status_t enumerated elements bitwise or’d. For a more detailed verification status use per list element.
Returns: On success, (0) is returned, otherwise a negative error value.
cert: The structure to be printed
format: Indicate the format to use
out: Newly allocated datum with (0) terminated string.
This function will pretty print a X.509 certificate, suitable for display to a human.
If the format is then all fields of the certificate will be output, on multiple lines. The format will generate one line with some selected fields, which is useful for logging purposes.
The output needs to be deallocate using .
Returns: On success, (0) is returned, otherwise a negative error value.
crt: a certificate of type
issuer: is the certificate of the certificate issuer
issuer_key: holds the issuer’s private key
dig: The message digest to use, is a safe choice
flags: must be 0
This function will sign the certificate with the issuer’s private key, and will copy the issuer’s information into the certificate.
This must be the last step in a certificate generation since all the previously set parameters are now signed.
Returns: On success, (0) is returned, otherwise a negative error value.
cert: a certificate of type
act_time: The actual time
This function will set the time this Certificate was or will be activated.
Returns: On success, (0) is returned, otherwise a negative error value.
cert: a certificate of type
id: The key ID
id_size: Holds the size of the serial field.
This function will set the X.509 certificate’s authority key ID extension. Only the keyIdentifier field can be set with this function.
Returns: On success, (0) is returned, otherwise a negative error value.
crt: a certificate of type
ca: true(1) or false(0). Depending on the Certificate authority status.
pathLenConstraint: non-negative error codes indicate maximum length of path, and negative error codes indicate that the pathLenConstraints field should not be present.
This function will set the basicConstraints certificate extension.
Returns: On success, (0) is returned, otherwise a negative error value.
crt: a certificate of type
ca: true(1) or false(0). Depending on the Certificate authority status.
This function will set the basicConstraints certificate extension. Use if you want to control the pathLenConstraint field too.
Returns: On success, (0) is returned, otherwise a negative error value.
crt: a certificate of type
type: is one of the gnutls_x509_subject_alt_name_t enumerations
data: The data to be set
data_size: The data size
reason_flags: revocation reasons
This function will set the CRL distribution points certificate extension.
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 2.6.0
crt: a certificate of type
type: is one of the gnutls_x509_subject_alt_name_t enumerations
data_string: The data to be set
reason_flags: revocation reasons
This function will set the CRL distribution points certificate extension.
Returns: On success, (0) is returned, otherwise a negative error value.
crt: a certificate of type
crq: holds a certificate request
This function will set extensions from the given request to the certificate.
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 2.8.0
crt: a certificate of type
crq: holds a certificate request
This function will set the name and public parameters as well as the extensions from the given certificate request to the certificate. Only RSA keys are currently supported.
Returns: On success, (0) is returned, otherwise a negative error value.
crt: a certificate of type
oid: holds an Object Identifier in a null terminated string
raw_flag: must be 0, or 1 if the data are DER encoded
name: a pointer to the name
sizeof_name: holds the size of
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 . For OIDs that are not known (by gnutls) you should properly DER encode your data, and call this function with set.
Returns: On success, (0) is returned, otherwise a negative error value.
cert: a certificate of type
exp_time: The actual time
This function will set the time this Certificate will expire.
Returns: On success, (0) is returned, otherwise a negative error value.
crt: a certificate of type
oid: holds an Object Identified in null terminated string
buf: a pointer to a DER encoded data
sizeof_buf: holds the size of
critical: should be non (0) if the extension is to be marked as critical
This function will set an the extension, by the specified OID, in the certificate. The extension data should be binary data DER encoded.
Returns: On success, (0) is returned, otherwise a negative error value.
crt: a certificate of type
oid: holds an Object Identifier in a null terminated string
raw_flag: must be 0, or 1 if the data are DER encoded
name: a pointer to the name
sizeof_name: holds the size of
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 . For OIDs that are not known (by gnutls) you should properly DER encode your data, and call this function with set.
Normally you do not need to call this function, since the signing operation will copy the signer’s name as the issuer of the certificate.
Returns: On success, (0) is returned, otherwise a negative error value.
cert: a certificate of type
oid: a pointer to a null terminated string that holds the OID
critical: Whether this extension will be critical or not
This function will set the key purpose OIDs of the Certificate. These are stored in the Extended Key Usage extension (2.5.29.37) See the GNUTLS_KP_* definitions for human readable names.
Subsequent calls to this function will append OIDs to the OID list.
Returns: On success, (0) is returned, otherwise a negative error code is returned.
crt: a certificate of type
usage: an ORed sequence of the GNUTLS_KEY_* elements.
This function will set the keyUsage certificate extension.
Returns: On success, (0) is returned, otherwise a negative error value.
crt: a certificate of type
key: holds a private key
This function will set the public parameters from the given private key to the certificate. Only RSA keys are currently supported.
Returns: On success, (0) is returned, otherwise a negative error value.
crt: a gnutls_x509_crt_t structure with the new proxy cert
eecrt: the end entity certificate that will be issuing the proxy
raw_flag: must be 0, or 1 if the CN is DER encoded
name: a pointer to the CN name, may be NULL (but MUST then be added later)
sizeof_name: holds the size of
This function will set the subject in to the end entity’s subject name, and add a single Common Name component of size . This corresponds to the required proxy certificate naming style. Note that if is , you MUST set it later by using or similar.
Returns: On success, (0) is returned, otherwise a negative error value.
crt: a certificate of type
pathLenConstraint: non-negative error codes indicate maximum length of path, and negative error codes indicate that the pathLenConstraints field should not be present.
policyLanguage: OID describing the language of .
policy: opaque byte array with policy language, can be
sizeof_policy: size of .
This function will set the proxyCertInfo extension.
Returns: On success, (0) is returned, otherwise a negative error value.
cert: a certificate of type
serial: The serial number
serial_size: Holds the size of the serial field.
This function will set the X.509 certificate’s serial number. Serial is not always a 32 or 64bit number. Some CAs use large serial numbers, thus it may be wise to handle it as something opaque.
Returns: On success, (0) is returned, otherwise a negative error value.
crt: a certificate of type
type: is one of the gnutls_x509_subject_alt_name_t enumerations
data: The data to be set
data_size: The size of data to be set
flags: GNUTLS_FSAN_SET to clear previous data or GNUTLS_FSAN_APPEND to append.
This function will set the subject alternative name certificate extension. It can set the following types:
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 2.6.0
crt: a certificate of type
type: is one of the gnutls_x509_subject_alt_name_t enumerations
data_string: The data to be set, a (0) terminated string
This function will set the subject alternative name certificate extension. This function assumes that data can be expressed as a null terminated string.
The name of the function is unfortunate since it is incosistent with .
Returns: On success, (0) is returned, otherwise a negative error value.
cert: a certificate of type
id: The key ID
id_size: Holds the size of the serial field.
This function will set the X.509 certificate’s subject key ID extension.
Returns: On success, (0) is returned, otherwise a negative error value.
crt: a certificate of type
version: holds the version number. For X.509v1 certificates must be 1.
This function will set the version of the certificate. This must be one for X.509 version 1, and so on. Plain certificates without extensions must have version set to one.
To create well-formed certificates, you must specify version 3 if you use any certificate extensions. Extensions are created by functions such as or .
Returns: On success, (0) is returned, otherwise a negative error value.
crt: a certificate of type
issuer: is the certificate of the certificate issuer
issuer_key: holds the issuer’s private key
dig: The message digest to use, is a safe choice
flags: must be 0
This function will sign the certificate with the issuer’s private key, and will copy the issuer’s information into the certificate.
This must be the last step in a certificate generation since all the previously set parameters are now signed.
Returns: On success, (0) is returned, otherwise a negative error value.
crt: a certificate of type
issuer: is the certificate of the certificate issuer
issuer_key: holds the issuer’s private key
This function is the same a with no flags, and SHA1 as the hash algorithm.
Returns: On success, (0) is returned, otherwise a negative error value.
crt: Holds the certificate
flags: should be 0 for now
data: holds the data to be signed
signature: contains the signature
This function will verify the given signed data, using the parameters from the certificate.
Deprecated. Please use .
Returns: In case of a verification failure is returned, and a positive code on success.
crt: Holds the certificate
flags: should be 0 for now
hash: holds the hash digest to be verified
signature: contains the signature
This function will verify the given signed digest, using the parameters from the certificate.
Deprecated. Please use .
Returns: In case of a verification failure is returned, and a positive code on success.
cert: is the certificate to be verified
CA_list: is one certificate that is considered to be trusted one
CA_list_length: holds the number of CA certificate in CA_list
flags: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
verify: will hold the certificate verification output.
This function will try to verify the given certificate and return its status.
Returns: On success, (0) is returned, otherwise a negative error value.
dn: a DN opaque object pointer.
This function deallocates the DN object as returned by .
Since: 2.4.0
dn: Holds the opaque DN object
format: the format of output params. One of PEM or DER.
output_data: will contain a DN PEM or DER encoded
output_data_size: holds the size of output_data (and will be replaced by the actual size of parameters)
This function will export the DN to DER or PEM format.
If the buffer provided is not long enough to hold the output, then * is updated and will be returned.
If the structure is PEM encoded, it will have a header of "BEGIN NAME".
Returns: On success, (0) is returned, otherwise a negative error value.
dn: input variable with opaque DN pointer
irdn: index of RDN
iava: index of AVA.
ava: Pointer to structure which will hold output information.
Get pointers to data within the DN.
Note that will contain pointers into the 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 .
Returns: Returns 0 on success, or an error code.
dn: the structure that will hold the imported DN
data: should contain a DER encoded RDN sequence
This function parses an RDN sequence and stores the result to a structure. The structure must have been initialized with . You may use to decode the DN.
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 2.4.0
dn: the object to be initialized
This function initializes a structure.
The object returned must be deallocated using .
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 2.4.0
oid: holds an Object Identifier in a null terminated string
This function will inform about known DN OIDs. This is useful since functions like use the information on known OIDs to properly encode their input. Object Identifiers that are not known are not encoded by these functions, and their input is stored directly into the ASN.1 structure. In that case of unknown OIDs, you have the responsibility of DER encoding your data.
Returns: 1 on known OIDs and 0 otherwise.
dst: The destination key, which should be initialized.
src: The source key
This function will copy a private key from source to destination key. Destination has to be initialized.
Returns: On success, (0) is returned, otherwise a negative error value.
key: The structure to be deinitialized
This function will deinitialize a private key structure.
key: a structure that holds the DSA parameters
p: will hold the p
q: will hold the q
g: will hold the g
y: will hold the y
x: will hold the x
This function will export the DSA private key’s parameters found in the given structure. The new parameters will be allocated using and will be stored in the appropriate datum.
Returns: On success, (0) is returned, otherwise a negative error value.
key: a structure that holds the rsa parameters
curve: will hold the curve
x: will hold the x coordinate
y: will hold the y coordinate
k: will hold the private key
This function will export the ECC private key’s parameters found in the given structure. The new parameters will be allocated using and will be stored in the appropriate datum.
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 3.0.0
key: Holds the key
format: the format of output params. One of PEM or DER.
password: the password that will be used to encrypt the key.
flags: an ORed sequence of gnutls_pkcs_encrypt_flags_t
output_data: will contain a private key PEM or DER encoded
output_data_size: holds the size of output_data (and will be replaced by the actual size of parameters)
This function will export the private key to a PKCS8 structure. Both RSA and DSA keys can be exported. For DSA keys we use PKCS definitions. If the flags do not specify the encryption cipher, then the default 3DES (PBES2) will be used.
The can be either ASCII or UTF-8 in the default PBES2 encryption schemas, or ASCII for the PKCS12 schemas.
If the buffer provided is not long enough to hold the output, then *output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.
If the structure is PEM encoded, it will have a header of "BEGIN ENCRYPTED PRIVATE KEY" or "BEGIN PRIVATE KEY" if encryption is not used.
Returns: In case of failure a negative error code will be returned, and 0 on success.
key: a structure that holds the rsa parameters
m: will hold the modulus
e: will hold the public exponent
d: will hold the private exponent
p: will hold the first prime (p)
q: will hold the second prime (q)
u: will hold the coefficient
e1: will hold e1 = d mod (p-1)
e2: will hold e2 = d mod (q-1)
This function will export the RSA private key’s parameters found in the given structure. The new parameters will be allocated using and will be stored in the appropriate datum.
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 2.12.0
key: a structure that holds the rsa parameters
m: will hold the modulus
e: will hold the public exponent
d: will hold the private exponent
p: will hold the first prime (p)
q: will hold the second prime (q)
u: will hold the coefficient
This function will export the RSA private key’s parameters found in the given structure. The new parameters will be allocated using and will be stored in the appropriate datum.
Returns: On success, (0) is returned, otherwise a negative error value.
key: Holds the key
format: the format of output params. One of PEM or DER.
output_data: will contain a private key PEM or DER encoded
output_data_size: holds the size of output_data (and will be replaced by the actual size of parameters)
This function will export the private key to a PKCS1 structure for RSA keys, or an integer sequence for DSA keys. The DSA keys are in the same format with the parameters used by openssl.
If the buffer provided is not long enough to hold the output, then * is updated and will be returned.
If the structure is PEM encoded, it will have a header of "BEGIN RSA PRIVATE KEY".
Returns: On success, (0) is returned, otherwise a negative error value.
key: Holds the key
This function will recalculate the secondary parameters in a key. In RSA keys, this can be the coefficient and exponent1,2.
Returns: On success, (0) is returned, otherwise a negative error value.
key: should contain a structure
algo: is one of the algorithms in .
bits: the size of the modulus
flags: unused for now. Must be 0.
This function will generate a random private key. Note that this function must be called on an empty private key.
Do not set the number of bits directly, use .
Returns: On success, (0) is returned, otherwise a negative error value.
key: Holds the key
flags: should be 0 for now
output_data: will contain the key ID
output_data_size: holds the size of output_data (and will be replaced by the actual size of parameters)
This function will return a unique ID the depends on the public key parameters. This ID can be used in checking whether a certificate corresponds to the given key.
If the buffer provided is not long enough to hold the output, then * is updated and will be returned. The output will normally be a SHA-1 hash output, which is 20 bytes.
Returns: On success, (0) is returned, otherwise a negative error value.
key: should contain a structure
This function will return the public key algorithm of a private key.
Returns: a member of the enumeration on success, or a negative error code on error.
key: The structure to store the parsed key
p: holds the p
q: holds the q
g: holds the g
y: holds the y
x: holds the x
This function will convert the given DSA raw parameters to the native format. The output will be stored in .
Returns: On success, (0) is returned, otherwise a negative error value.
key: The structure to store the parsed key
curve: holds the curve
x: holds the x
y: holds the y
k: holds the k
This function will convert the given elliptic curve parameters to the native format. The output will be stored in .
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 3.0.0
key: The structure to store the parsed key
data: The DER or PEM encoded key.
format: One of DER or PEM
password: the password to decrypt the key (if it is encrypted).
flags: 0 if encrypted or GNUTLS_PKCS_PLAIN if not encrypted.
This function will convert the given DER or PEM encoded PKCS8 2.0 encrypted key to the native gnutls_x509_privkey_t format. The output will be stored in . Both RSA and DSA keys can be imported, and flags can only be used to indicate an unencrypted key.
The 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.
Returns: On success, (0) is returned, otherwise a negative error value.
key: The structure to store the parsed key
m: holds the modulus
e: holds the public exponent
d: holds the private exponent
p: holds the first prime (p)
q: holds the second prime (q)
u: holds the coefficient
e1: holds e1 = d mod (p-1)
e2: holds e2 = d mod (q-1)
This function will convert the given RSA raw parameters to the native format. The output will be stored in .
Returns: On success, (0) is returned, otherwise a negative error value.
key: The structure to store the parsed key
m: holds the modulus
e: holds the public exponent
d: holds the private exponent
p: holds the first prime (p)
q: holds the second prime (q)
u: holds the coefficient
This function will convert the given RSA raw parameters to the native format. The output will be stored in .
Returns: On success, (0) is returned, otherwise a negative error value.
key: The structure to store the parsed key
data: The DER or PEM encoded certificate.
format: One of DER or PEM
This function will convert the given DER or PEM encoded key to the native format. The output will be stored in .
If the key is PEM encoded it should have a header of "RSA PRIVATE KEY", or "DSA PRIVATE KEY".
Returns: On success, (0) is returned, otherwise a negative error value.
key: The structure to be initialized
This function will initialize an private key structure.
Returns: On success, (0) is returned, otherwise a negative error value.
key: a key structure
This function will return the security parameter appropriate with this private key.
Returns: On success, a valid security parameter is returned otherwise is returned.
Since: 2.12.0
key: Holds the key
digest: should be MD5 or SHA1
flags: should be 0 for now
data: holds the data to be signed
signature: will contain the signature
signature_size: holds the size of signature (and will be replaced by the new size)
This function will sign the given data using a signature algorithm supported by the private key. Signature algorithms are always used together with a hash functions. Different hash functions may be used for the RSA algorithm, but only SHA-1 for the DSA keys.
If the buffer provided is not long enough to hold the output, then * is updated and will be returned.
Use to determine the hash algorithm.
Returns: On success, (0) is returned, otherwise a negative error value.
Deprecated: Use .
key: Holds the key
hash: holds the data to be signed
signature: will contain newly allocated signature
This function will sign the given hash using the private key. Do not use this function directly unless you know what it is. Typical signing requires the data to be hashed and stored in special formats (e.g. BER Digest-Info for RSA).
Returns: On success, (0) is returned, otherwise a negative error value.
Deprecated in: 2.12.0
key: should contain a structure
This function will verify the private key parameters.
Returns: On success, (0) is returned, otherwise a negative error value.
idn: should contain a DER encoded RDN sequence
oid: an Object Identifier
indx: In case multiple same OIDs exist in the RDN indicates which to send. Use 0 for the first one.
raw_flag: If non (0) then the raw DER data are returned.
buf: a pointer to a structure to hold the peer’s name
sizeof_buf: holds the size of
This function will return the name of the given Object identifier, of the RDN sequence. The name will be encoded using the rules from RFC2253.
Returns: On success, (0) is returned, or is returned and * is updated if the provided buffer is not long enough, otherwise a negative error value.
idn: should contain a DER encoded RDN sequence
indx: Indicates which OID to return. Use 0 for the first one.
buf: a pointer to a structure to hold the peer’s name OID
sizeof_buf: holds the size of
This function will return the specified Object identifier, of the RDN sequence.
Returns: On success, (0) is returned, or is returned and * is updated if the provided buffer is not long enough, otherwise a negative error value.
Since: 2.4.0
idn: should contain a DER encoded RDN sequence
buf: a pointer to a structure to hold the peer’s name
sizeof_buf: holds the size of
This function will return the name of the given RDN sequence. The name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in RFC2253.
Returns: On success, (0) is returned, or is returned and * is updated if the provided buffer is not long enough, otherwise a negative error value.
list: The structure of the list
clist: A list of CAs
clist_size: The length of the CA list
flags: should be 0.
This function will add the given certificate authorities to the trusted list. The list of CAs must not be deinitialized during this structure’s lifetime.
Returns: The number of added elements is returned.
Since: 3.0.0
list: The structure of the list
crl_list: A list of CRLs
crl_size: The length of the CRL list
flags: if GNUTLS_TL_VERIFY_CRL is given the CRLs will be verified before being added.
verification_flags: gnutls_certificate_verify_flags if flags specifies GNUTLS_TL_VERIFY_CRL
This function will add the given certificate revocation lists to the trusted list. The list of CRLs must not be deinitialized during this structure’s lifetime.
This function must be called after to allow verifying the CRLs for validity.
Returns: The number of added elements is returned.
Since: 3.0.0
list: The structure of the list
cert: A certificate
name: An identifier for the certificate
name_size: The size of the identifier
flags: should be 0.
This function will add the given certificate to the trusted list and associate it with a name. The certificate will not be be used for verification with but only with .
In principle this function can be used to set individual "server" certificates that are trusted by the user for that specific server but for no other purposes.
The certificate must not be deinitialized during the lifetime of the trusted list.
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 3.0.0
list: The structure to be deinitialized
all: if non-(0) it will deinitialize all the certificates and CRLs contained in the structure.
This function will deinitialize a trust list.
Since: 3.0.0
list: The structure of the list
cert: is the certificate to find issuer for
issuer: Will hold the issuer if any. Should be treated as constant.
flags: Use (0).
This function will attempt to find the issuer of the given certificate.
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 3.0.0
list: The structure to be initialized
size: The size of the internal hash table. Use (0) for default size.
This function will initialize an X.509 trust list structure.
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 3.0.0
list: The structure of the list
cert_list: is the certificate list to be verified
cert_list_size: is the certificate list size
flags: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
verify: will hold the certificate verification output.
func: If non-null will be called on each chain element verification with the output.
This function will try to verify the given certificate and return its status.
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 3.0.0
list: The structure of the list
cert: is the certificate to be verified
name: is the certificate’s name
name_size: is the certificate’s name size
flags: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
verify: will hold the certificate verification output.
func: If non-null will be called on each chain element verification with the output.
This function will try to find a matching named certificate. If a match is found the certificate is considered valid. In addition to that this function will also check CRLs.
Returns: On success, (0) is returned, otherwise a negative error value.
Since: 3.0.0
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by nmav on November 22, 2011 using texi2html 1.82.