Blame doc/abstract-api.texi

Packit 549fdc
Packit 549fdc
@subheading gnutls_certificate_set_key
Packit 549fdc
@anchor{gnutls_certificate_set_key}
Packit 549fdc
@deftypefun {int} {gnutls_certificate_set_key} (gnutls_certificate_credentials_t @var{res}, const char ** @var{names}, int @var{names_size}, gnutls_pcert_st * @var{pcert_list}, int @var{pcert_list_size}, gnutls_privkey_t @var{key})
Packit 549fdc
@var{res}: is a @code{gnutls_certificate_credentials_t}  type.
Packit 549fdc
Packit 549fdc
@var{names}: is an array of DNS name of the certificate (NULL if none)
Packit 549fdc
Packit 549fdc
@var{names_size}: holds the size of the names list
Packit 549fdc
Packit 549fdc
@var{pcert_list}: contains a certificate list (path) for the specified private key
Packit 549fdc
Packit 549fdc
@var{pcert_list_size}: holds the size of the certificate list
Packit 549fdc
Packit 549fdc
@var{key}: is a @code{gnutls_privkey_t}  key
Packit 549fdc
Packit 549fdc
This function sets a certificate/private key pair in the
Packit 549fdc
gnutls_certificate_credentials_t type.  This function may be
Packit 549fdc
called more than once, in case multiple keys/certificates exist for
Packit 549fdc
the server.  For clients that want to send more than their own end-
Packit 549fdc
entity certificate (e.g., also an intermediate CA cert), the full
Packit 549fdc
certificate chain must be provided in  @code{pcert_list} .
Packit 549fdc
Packit 549fdc
Note that the  @code{key} and the elements of  @code{pcert_list} will become part of the credentials 
Packit 549fdc
structure and must not be deallocated. They will be automatically deallocated 
Packit 549fdc
when the  @code{res} structure is deinitialized.
Packit 549fdc
Packit 549fdc
If that function fails to load the  @code{res} structure is at an undefined state, it must
Packit 549fdc
not be reused to load other keys or certificates.
Packit 549fdc
Packit 549fdc
Note that, this function by default returns zero on success and a negative value on error.
Packit 549fdc
Since 3.5.6, when the flag @code{GNUTLS_CERTIFICATE_API_V2}  is set using @code{gnutls_certificate_set_flags()} 
Packit 549fdc
it returns an index (greater or equal to zero). That index can be used to other functions to refer to the added key-pair.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success this functions returns zero, and otherwise a negative value on error (see above for modifying that behavior).
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_certificate_set_retrieve_function2
Packit 549fdc
@anchor{gnutls_certificate_set_retrieve_function2}
Packit 549fdc
@deftypefun {void} {gnutls_certificate_set_retrieve_function2} (gnutls_certificate_credentials_t @var{cred}, gnutls_certificate_retrieve_function2 * @var{func})
Packit 549fdc
@var{cred}: is a @code{gnutls_certificate_credentials_t}  type.
Packit 549fdc
Packit 549fdc
@var{func}: is the callback function
Packit 549fdc
Packit 549fdc
This function sets a callback to be called in order to retrieve the
Packit 549fdc
certificate to be used in the handshake. The callback will take control
Packit 549fdc
only if a certificate is requested by the peer.
Packit 549fdc
Packit 549fdc
The callback's function prototype is:
Packit 549fdc
int (*callback)(gnutls_session_t, const gnutls_datum_t* req_ca_dn, int nreqs,
Packit 549fdc
const gnutls_pk_algorithm_t* pk_algos, int pk_algos_length, gnutls_pcert_st** pcert,
Packit 549fdc
unsigned int *pcert_length, gnutls_privkey_t * pkey);
Packit 549fdc
Packit 549fdc
 @code{req_ca_dn} is only used in X.509 certificates.
Packit 549fdc
Contains a list with the CA names that the server considers trusted.
Packit 549fdc
This is a hint and typically the client should send a certificate that is signed
Packit 549fdc
by one of these CAs. These names, when available, are DER encoded. To get a more
Packit 549fdc
meaningful value use the function @code{gnutls_x509_rdn_get()} .
Packit 549fdc
Packit 549fdc
 @code{pk_algos} contains a list with server's acceptable public key algorithms.
Packit 549fdc
The certificate returned should support the server's given algorithms.
Packit 549fdc
Packit 549fdc
 @code{pcert} should contain a single certificate and public key or a list of them.
Packit 549fdc
Packit 549fdc
 @code{pcert_length} is the size of the previous list.
Packit 549fdc
Packit 549fdc
 @code{pkey} is the private key.
Packit 549fdc
Packit 549fdc
If the callback function is provided then gnutls will call it, in the
Packit 549fdc
handshake, after the certificate request message has been received.
Packit 549fdc
All the provided by the callback values will not be released or
Packit 549fdc
modified by gnutls.
Packit 549fdc
Packit 549fdc
In server side pk_algos and req_ca_dn are NULL.
Packit 549fdc
Packit 549fdc
The callback function should set the certificate list to be sent,
Packit 549fdc
and return 0 on success. If no certificate was selected then the
Packit 549fdc
number of certificates should be set to zero. The value (-1)
Packit 549fdc
indicates error and the handshake will be terminated. If both certificates
Packit 549fdc
are set in the credentials and a callback is available, the callback
Packit 549fdc
takes predence.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pcert_deinit
Packit 549fdc
@anchor{gnutls_pcert_deinit}
Packit 549fdc
@deftypefun {void} {gnutls_pcert_deinit} (gnutls_pcert_st * @var{pcert})
Packit 549fdc
@var{pcert}: The structure to be deinitialized
Packit 549fdc
Packit 549fdc
This function will deinitialize a pcert structure.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pcert_export_openpgp
Packit 549fdc
@anchor{gnutls_pcert_export_openpgp}
Packit 549fdc
@deftypefun {int} {gnutls_pcert_export_openpgp} (gnutls_pcert_st * @var{pcert}, gnutls_openpgp_crt_t * @var{crt})
Packit 549fdc
@var{pcert}: The pcert structure.
Packit 549fdc
Packit 549fdc
@var{crt}: An initialized @code{gnutls_openpgp_crt_t} .
Packit 549fdc
Packit 549fdc
This function is no-op.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_UNIMPLEMENTED_FEATURE} .
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pcert_export_x509
Packit 549fdc
@anchor{gnutls_pcert_export_x509}
Packit 549fdc
@deftypefun {int} {gnutls_pcert_export_x509} (gnutls_pcert_st * @var{pcert}, gnutls_x509_crt_t * @var{crt})
Packit 549fdc
@var{pcert}: The pcert structure.
Packit 549fdc
Packit 549fdc
@var{crt}: An initialized @code{gnutls_x509_crt_t} .
Packit 549fdc
Packit 549fdc
Converts the given @code{gnutls_pcert_t}  type into a @code{gnutls_x509_crt_t} .
Packit 549fdc
This function only works if the type of  @code{pcert} is @code{GNUTLS_CRT_X509} .
Packit 549fdc
When successful, the value written to  @code{crt} must be freed with
Packit 549fdc
@code{gnutls_x509_crt_deinit()}  when no longer needed.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pcert_import_openpgp
Packit 549fdc
@anchor{gnutls_pcert_import_openpgp}
Packit 549fdc
@deftypefun {int} {gnutls_pcert_import_openpgp} (gnutls_pcert_st * @var{pcert}, gnutls_openpgp_crt_t @var{crt}, unsigned int @var{flags})
Packit 549fdc
@var{pcert}: The pcert structure
Packit 549fdc
Packit 549fdc
@var{crt}: The raw certificate to be imported
Packit 549fdc
Packit 549fdc
@var{flags}: zero for now
Packit 549fdc
Packit 549fdc
This function is no-op.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_UNIMPLEMENTED_FEATURE} .
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pcert_import_openpgp_raw
Packit 549fdc
@anchor{gnutls_pcert_import_openpgp_raw}
Packit 549fdc
@deftypefun {int} {gnutls_pcert_import_openpgp_raw} (gnutls_pcert_st * @var{pcert}, const gnutls_datum_t * @var{cert}, gnutls_openpgp_crt_fmt_t         @var{format}, gnutls_openpgp_keyid_t @var{keyid}, unsigned int @var{flags})
Packit 549fdc
@var{pcert}: The pcert structure
Packit 549fdc
Packit 549fdc
@var{cert}: The raw certificate to be imported
Packit 549fdc
Packit 549fdc
@var{format}: The format of the certificate
Packit 549fdc
Packit 549fdc
@var{keyid}: The key ID to use (NULL for the master key)
Packit 549fdc
Packit 549fdc
@var{flags}: zero for now
Packit 549fdc
Packit 549fdc
This function is no-op.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_UNIMPLEMENTED_FEATURE} .
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pcert_import_x509
Packit 549fdc
@anchor{gnutls_pcert_import_x509}
Packit 549fdc
@deftypefun {int} {gnutls_pcert_import_x509} (gnutls_pcert_st * @var{pcert}, gnutls_x509_crt_t @var{crt}, unsigned int @var{flags})
Packit 549fdc
@var{pcert}: The pcert structure
Packit 549fdc
Packit 549fdc
@var{crt}: The certificate to be imported
Packit 549fdc
Packit 549fdc
@var{flags}: zero for now
Packit 549fdc
Packit 549fdc
This convenience function will import the given certificate to a
Packit 549fdc
@code{gnutls_pcert_st}  structure. The structure must be deinitialized
Packit 549fdc
afterwards using @code{gnutls_pcert_deinit()} ;
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pcert_import_x509_list
Packit 549fdc
@anchor{gnutls_pcert_import_x509_list}
Packit 549fdc
@deftypefun {int} {gnutls_pcert_import_x509_list} (gnutls_pcert_st * @var{pcert}, gnutls_x509_crt_t * @var{crt}, unsigned * @var{ncrt}, unsigned int @var{flags})
Packit 549fdc
@var{pcert}: The pcert structure
Packit 549fdc
Packit 549fdc
@var{crt}: The certificates to be imported
Packit 549fdc
Packit 549fdc
@var{ncrt}: The number of certificates
Packit 549fdc
Packit 549fdc
@var{flags}: zero or @code{GNUTLS_X509_CRT_LIST_SORT} 
Packit 549fdc
Packit 549fdc
This convenience function will import the given certificate to a
Packit 549fdc
@code{gnutls_pcert_st}  structure. The structure must be deinitialized
Packit 549fdc
afterwards using @code{gnutls_pcert_deinit()} ;
Packit 549fdc
Packit 549fdc
In the case @code{GNUTLS_X509_CRT_LIST_SORT}  is specified and that
Packit 549fdc
function cannot sort the list, @code{GNUTLS_E_CERTIFICATE_LIST_UNSORTED} 
Packit 549fdc
will be returned. Currently sorting can fail if the list size
Packit 549fdc
exceeds an internal constraint (16).
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pcert_import_x509_raw
Packit 549fdc
@anchor{gnutls_pcert_import_x509_raw}
Packit 549fdc
@deftypefun {int} {gnutls_pcert_import_x509_raw} (gnutls_pcert_st * @var{pcert}, const gnutls_datum_t * @var{cert}, gnutls_x509_crt_fmt_t @var{format}, unsigned int @var{flags})
Packit 549fdc
@var{pcert}: The pcert structure
Packit 549fdc
Packit 549fdc
@var{cert}: The raw certificate to be imported
Packit 549fdc
Packit 549fdc
@var{format}: The format of the certificate
Packit 549fdc
Packit 549fdc
@var{flags}: zero for now
Packit 549fdc
Packit 549fdc
This convenience function will import the given certificate to a
Packit 549fdc
@code{gnutls_pcert_st}  structure. The structure must be deinitialized
Packit 549fdc
afterwards using @code{gnutls_pcert_deinit()} ;
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pcert_list_import_x509_raw
Packit 549fdc
@anchor{gnutls_pcert_list_import_x509_raw}
Packit 549fdc
@deftypefun {int} {gnutls_pcert_list_import_x509_raw} (gnutls_pcert_st * @var{pcerts}, unsigned int * @var{pcert_max}, const gnutls_datum_t * @var{data}, gnutls_x509_crt_fmt_t @var{format}, unsigned int @var{flags})
Packit 549fdc
@var{pcerts}: The structures to store the parsed certificate. Must not be initialized.
Packit 549fdc
Packit 549fdc
@var{pcert_max}: Initially must hold the maximum number of certs. It will be updated with the number of certs available.
Packit 549fdc
Packit 549fdc
@var{data}: The certificates.
Packit 549fdc
Packit 549fdc
@var{format}: One of DER or PEM.
Packit 549fdc
Packit 549fdc
@var{flags}: must be (0) or an OR'd sequence of gnutls_certificate_import_flags.
Packit 549fdc
Packit 549fdc
This function will convert the given PEM encoded certificate list
Packit 549fdc
to the native gnutls_x509_crt_t format. The output will be stored
Packit 549fdc
in  @code{certs} .  They will be automatically initialized.
Packit 549fdc
Packit 549fdc
If the Certificate is PEM encoded it should have a header of "X509
Packit 549fdc
CERTIFICATE", or "CERTIFICATE".
Packit 549fdc
Packit 549fdc
@strong{Returns:} the number of certificates read or a negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_decrypt_data
Packit 549fdc
@anchor{gnutls_privkey_decrypt_data}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_decrypt_data} (gnutls_privkey_t @var{key}, unsigned int @var{flags}, const gnutls_datum_t * @var{ciphertext}, gnutls_datum_t * @var{plaintext})
Packit 549fdc
@var{key}: Holds the key
Packit 549fdc
Packit 549fdc
@var{flags}: zero for now
Packit 549fdc
Packit 549fdc
@var{ciphertext}: holds the data to be decrypted
Packit 549fdc
Packit 549fdc
@var{plaintext}: will contain the decrypted data, allocated with @code{gnutls_malloc()} 
Packit 549fdc
Packit 549fdc
This function will decrypt the given data using the algorithm
Packit 549fdc
supported by the private key.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_deinit
Packit 549fdc
@anchor{gnutls_privkey_deinit}
Packit 549fdc
@deftypefun {void} {gnutls_privkey_deinit} (gnutls_privkey_t @var{key})
Packit 549fdc
@var{key}: The key to be deinitialized
Packit 549fdc
Packit 549fdc
This function will deinitialize a private key structure.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_export_dsa_raw
Packit 549fdc
@anchor{gnutls_privkey_export_dsa_raw}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_export_dsa_raw} (gnutls_privkey_t @var{key}, gnutls_datum_t * @var{p}, gnutls_datum_t * @var{q}, gnutls_datum_t * @var{g}, gnutls_datum_t * @var{y}, gnutls_datum_t * @var{x})
Packit 549fdc
@var{key}: Holds the public key
Packit 549fdc
Packit 549fdc
@var{p}: will hold the p
Packit 549fdc
Packit 549fdc
@var{q}: will hold the q
Packit 549fdc
Packit 549fdc
@var{g}: will hold the g
Packit 549fdc
Packit 549fdc
@var{y}: will hold the y
Packit 549fdc
Packit 549fdc
@var{x}: will hold the x
Packit 549fdc
Packit 549fdc
This function will export the DSA private key's parameters found
Packit 549fdc
in the given structure. The new parameters will be allocated using
Packit 549fdc
@code{gnutls_malloc()}  and will be stored in the appropriate datum.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_export_dsa_raw2
Packit 549fdc
@anchor{gnutls_privkey_export_dsa_raw2}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_export_dsa_raw2} (gnutls_privkey_t @var{key}, gnutls_datum_t * @var{p}, gnutls_datum_t * @var{q}, gnutls_datum_t * @var{g}, gnutls_datum_t * @var{y}, gnutls_datum_t * @var{x}, unsigned int @var{flags})
Packit 549fdc
@var{key}: Holds the public key
Packit 549fdc
Packit 549fdc
@var{p}: will hold the p
Packit 549fdc
Packit 549fdc
@var{q}: will hold the q
Packit 549fdc
Packit 549fdc
@var{g}: will hold the g
Packit 549fdc
Packit 549fdc
@var{y}: will hold the y
Packit 549fdc
Packit 549fdc
@var{x}: will hold the x
Packit 549fdc
Packit 549fdc
@var{flags}: flags from @code{gnutls_abstract_export_flags_t} 
Packit 549fdc
Packit 549fdc
This function will export the DSA private key's parameters found
Packit 549fdc
in the given structure. The new parameters will be allocated using
Packit 549fdc
@code{gnutls_malloc()}  and will be stored in the appropriate datum.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.6.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_export_ecc_raw
Packit 549fdc
@anchor{gnutls_privkey_export_ecc_raw}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_export_ecc_raw} (gnutls_privkey_t @var{key}, gnutls_ecc_curve_t * @var{curve}, gnutls_datum_t * @var{x}, gnutls_datum_t * @var{y}, gnutls_datum_t * @var{k})
Packit 549fdc
@var{key}: Holds the public key
Packit 549fdc
Packit 549fdc
@var{curve}: will hold the curve
Packit 549fdc
Packit 549fdc
@var{x}: will hold the x coordinate
Packit 549fdc
Packit 549fdc
@var{y}: will hold the y coordinate
Packit 549fdc
Packit 549fdc
@var{k}: will hold the private key
Packit 549fdc
Packit 549fdc
This function will export the ECC private key's parameters found
Packit 549fdc
in the given structure. The new parameters will be allocated using
Packit 549fdc
@code{gnutls_malloc()}  and will be stored in the appropriate datum.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_export_ecc_raw2
Packit 549fdc
@anchor{gnutls_privkey_export_ecc_raw2}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_export_ecc_raw2} (gnutls_privkey_t @var{key}, gnutls_ecc_curve_t * @var{curve}, gnutls_datum_t * @var{x}, gnutls_datum_t * @var{y}, gnutls_datum_t * @var{k}, unsigned int @var{flags})
Packit 549fdc
@var{key}: Holds the public key
Packit 549fdc
Packit 549fdc
@var{curve}: will hold the curve
Packit 549fdc
Packit 549fdc
@var{x}: will hold the x coordinate
Packit 549fdc
Packit 549fdc
@var{y}: will hold the y coordinate
Packit 549fdc
Packit 549fdc
@var{k}: will hold the private key
Packit 549fdc
Packit 549fdc
@var{flags}: flags from @code{gnutls_abstract_export_flags_t} 
Packit 549fdc
Packit 549fdc
This function will export the ECC private key's parameters found
Packit 549fdc
in the given structure. The new parameters will be allocated using
Packit 549fdc
@code{gnutls_malloc()}  and will be stored in the appropriate datum.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.6.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_export_openpgp
Packit 549fdc
@anchor{gnutls_privkey_export_openpgp}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_export_openpgp} (gnutls_privkey_t @var{pkey}, gnutls_openpgp_privkey_t * @var{key})
Packit 549fdc
@var{pkey}: The private key
Packit 549fdc
Packit 549fdc
@var{key}: Location for the key to be exported.
Packit 549fdc
Packit 549fdc
This function is no-op.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_UNIMPLEMENTED_FEATURE} .
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_export_pkcs11
Packit 549fdc
@anchor{gnutls_privkey_export_pkcs11}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_export_pkcs11} (gnutls_privkey_t @var{pkey}, gnutls_pkcs11_privkey_t * @var{key})
Packit 549fdc
@var{pkey}: The private key
Packit 549fdc
Packit 549fdc
@var{key}: Location for the key to be exported.
Packit 549fdc
Packit 549fdc
Converts the given abstract private key to a @code{gnutls_pkcs11_privkey_t} 
Packit 549fdc
type. The key must be of type @code{GNUTLS_PRIVKEY_PKCS11} . The key
Packit 549fdc
returned in  @code{key} must be deinitialized with
Packit 549fdc
@code{gnutls_pkcs11_privkey_deinit()} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_export_rsa_raw
Packit 549fdc
@anchor{gnutls_privkey_export_rsa_raw}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_export_rsa_raw} (gnutls_privkey_t @var{key}, gnutls_datum_t * @var{m}, gnutls_datum_t * @var{e}, gnutls_datum_t * @var{d}, gnutls_datum_t * @var{p}, gnutls_datum_t * @var{q}, gnutls_datum_t * @var{u}, gnutls_datum_t * @var{e1}, gnutls_datum_t * @var{e2})
Packit 549fdc
@var{key}: Holds the certificate
Packit 549fdc
Packit 549fdc
@var{m}: will hold the modulus
Packit 549fdc
Packit 549fdc
@var{e}: will hold the public exponent
Packit 549fdc
Packit 549fdc
@var{d}: will hold the private exponent
Packit 549fdc
Packit 549fdc
@var{p}: will hold the first prime (p)
Packit 549fdc
Packit 549fdc
@var{q}: will hold the second prime (q)
Packit 549fdc
Packit 549fdc
@var{u}: will hold the coefficient
Packit 549fdc
Packit 549fdc
@var{e1}: will hold e1 = d mod (p-1)
Packit 549fdc
Packit 549fdc
@var{e2}: will hold e2 = d mod (q-1)
Packit 549fdc
Packit 549fdc
This function will export the RSA private key's parameters found
Packit 549fdc
in the given structure. The new parameters will be allocated using
Packit 549fdc
@code{gnutls_malloc()}  and will be stored in the appropriate datum. For
Packit 549fdc
EdDSA keys, the  @code{y} value should be @code{NULL} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_export_rsa_raw2
Packit 549fdc
@anchor{gnutls_privkey_export_rsa_raw2}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_export_rsa_raw2} (gnutls_privkey_t @var{key}, gnutls_datum_t * @var{m}, gnutls_datum_t * @var{e}, gnutls_datum_t * @var{d}, gnutls_datum_t * @var{p}, gnutls_datum_t * @var{q}, gnutls_datum_t * @var{u}, gnutls_datum_t * @var{e1}, gnutls_datum_t * @var{e2}, unsigned int @var{flags})
Packit 549fdc
@var{key}: Holds the certificate
Packit 549fdc
Packit 549fdc
@var{m}: will hold the modulus
Packit 549fdc
Packit 549fdc
@var{e}: will hold the public exponent
Packit 549fdc
Packit 549fdc
@var{d}: will hold the private exponent
Packit 549fdc
Packit 549fdc
@var{p}: will hold the first prime (p)
Packit 549fdc
Packit 549fdc
@var{q}: will hold the second prime (q)
Packit 549fdc
Packit 549fdc
@var{u}: will hold the coefficient
Packit 549fdc
Packit 549fdc
@var{e1}: will hold e1 = d mod (p-1)
Packit 549fdc
Packit 549fdc
@var{e2}: will hold e2 = d mod (q-1)
Packit 549fdc
Packit 549fdc
@var{flags}: flags from @code{gnutls_abstract_export_flags_t} 
Packit 549fdc
Packit 549fdc
This function will export the RSA private key's parameters found
Packit 549fdc
in the given structure. The new parameters will be allocated using
Packit 549fdc
@code{gnutls_malloc()}  and will be stored in the appropriate datum.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.6.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_export_x509
Packit 549fdc
@anchor{gnutls_privkey_export_x509}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_export_x509} (gnutls_privkey_t @var{pkey}, gnutls_x509_privkey_t * @var{key})
Packit 549fdc
@var{pkey}: The private key
Packit 549fdc
Packit 549fdc
@var{key}: Location for the key to be exported.
Packit 549fdc
Packit 549fdc
Converts the given abstract private key to a @code{gnutls_x509_privkey_t} 
Packit 549fdc
type. The abstract key must be of type @code{GNUTLS_PRIVKEY_X509} . The input
Packit 549fdc
 @code{key} must not be initialized. The key returned in  @code{key} should be deinitialized
Packit 549fdc
using @code{gnutls_x509_privkey_deinit()} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_generate
Packit 549fdc
@anchor{gnutls_privkey_generate}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_generate} (gnutls_privkey_t @var{pkey}, gnutls_pk_algorithm_t @var{algo}, unsigned int @var{bits}, unsigned int @var{flags})
Packit 549fdc
@var{pkey}: An initialized private key
Packit 549fdc
Packit 549fdc
@var{algo}: is one of the algorithms in @code{gnutls_pk_algorithm_t} .
Packit 549fdc
Packit 549fdc
@var{bits}: the size of the parameters to generate
Packit 549fdc
Packit 549fdc
@var{flags}: Must be zero or flags from @code{gnutls_privkey_flags_t} .
Packit 549fdc
Packit 549fdc
This function will generate a random private key. Note that this
Packit 549fdc
function must be called on an initialized private key.
Packit 549fdc
Packit 549fdc
The flag @code{GNUTLS_PRIVKEY_FLAG_PROVABLE} 
Packit 549fdc
instructs the key generation process to use algorithms like Shawe-Taylor
Packit 549fdc
(from FIPS PUB186-4) which generate provable parameters out of a seed
Packit 549fdc
for RSA and DSA keys. See @code{gnutls_privkey_generate2()}  for more
Packit 549fdc
information.
Packit 549fdc
Packit 549fdc
Note that when generating an elliptic curve key, the curve
Packit 549fdc
can be substituted in the place of the bits parameter using the
Packit 549fdc
@code{GNUTLS_CURVE_TO_BITS()}  macro. The input to the macro is any curve from
Packit 549fdc
@code{gnutls_ecc_curve_t} .
Packit 549fdc
Packit 549fdc
For DSA keys, if the subgroup size needs to be specified check
Packit 549fdc
the @code{GNUTLS_SUBGROUP_TO_BITS()}  macro.
Packit 549fdc
Packit 549fdc
It is recommended to do not set the number of  @code{bits} directly, use @code{gnutls_sec_param_to_pk_bits()}  instead .
Packit 549fdc
Packit 549fdc
See also @code{gnutls_privkey_generate2()} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_generate2
Packit 549fdc
@anchor{gnutls_privkey_generate2}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_generate2} (gnutls_privkey_t @var{pkey}, gnutls_pk_algorithm_t @var{algo}, unsigned int @var{bits}, unsigned int @var{flags}, const gnutls_keygen_data_st * @var{data}, unsigned @var{data_size})
Packit 549fdc
@var{pkey}: The private key
Packit 549fdc
Packit 549fdc
@var{algo}: is one of the algorithms in @code{gnutls_pk_algorithm_t} .
Packit 549fdc
Packit 549fdc
@var{bits}: the size of the modulus
Packit 549fdc
Packit 549fdc
@var{flags}: Must be zero or flags from @code{gnutls_privkey_flags_t} .
Packit 549fdc
Packit 549fdc
@var{data}: Allow specifying @code{gnutls_keygen_data_st}  types such as the seed to be used.
Packit 549fdc
Packit 549fdc
@var{data_size}: The number of  @code{data} available.
Packit 549fdc
Packit 549fdc
This function will generate a random private key. Note that this
Packit 549fdc
function must be called on an initialized private key.
Packit 549fdc
Packit 549fdc
The flag @code{GNUTLS_PRIVKEY_FLAG_PROVABLE} 
Packit 549fdc
instructs the key generation process to use algorithms like Shawe-Taylor
Packit 549fdc
(from FIPS PUB186-4) which generate provable parameters out of a seed
Packit 549fdc
for RSA and DSA keys. On DSA keys the PQG parameters are generated using the
Packit 549fdc
seed, while on RSA the two primes. To specify an explicit seed
Packit 549fdc
(by default a random seed is used), use the  @code{data} with a @code{GNUTLS_KEYGEN_SEED} 
Packit 549fdc
type.
Packit 549fdc
Packit 549fdc
Note that when generating an elliptic curve key, the curve
Packit 549fdc
can be substituted in the place of the bits parameter using the
Packit 549fdc
@code{GNUTLS_CURVE_TO_BITS()}  macro.
Packit 549fdc
Packit 549fdc
To export the generated keys in memory or in files it is recommended to use the
Packit 549fdc
PKCS@code{8}  form as it can handle all key types, and can store additional parameters
Packit 549fdc
such as the seed, in case of provable RSA or DSA keys.
Packit 549fdc
Generated keys can be exported in memory using @code{gnutls_privkey_export_x509()} ,
Packit 549fdc
and then with @code{gnutls_x509_privkey_export2_pkcs8()} .
Packit 549fdc
Packit 549fdc
If key generation is part of your application, avoid setting the number
Packit 549fdc
of bits directly, and instead use @code{gnutls_sec_param_to_pk_bits()} .
Packit 549fdc
That way the generated keys will adapt to the security levels
Packit 549fdc
of the underlying GnuTLS library.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.5.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_get_pk_algorithm
Packit 549fdc
@anchor{gnutls_privkey_get_pk_algorithm}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_get_pk_algorithm} (gnutls_privkey_t @var{key}, unsigned int * @var{bits})
Packit 549fdc
@var{key}: should contain a @code{gnutls_privkey_t}  type
Packit 549fdc
Packit 549fdc
@var{bits}: If set will return the number of bits of the parameters (may be NULL)
Packit 549fdc
Packit 549fdc
This function will return the public key algorithm of a private
Packit 549fdc
key and if possible will return a number of bits that indicates
Packit 549fdc
the security parameter of the key.
Packit 549fdc
Packit 549fdc
@strong{Returns:} a member of the @code{gnutls_pk_algorithm_t}  enumeration on
Packit 549fdc
success, or a negative error code on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_get_seed
Packit 549fdc
@anchor{gnutls_privkey_get_seed}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_get_seed} (gnutls_privkey_t @var{key}, gnutls_digest_algorithm_t * @var{digest}, void * @var{seed}, size_t * @var{seed_size})
Packit 549fdc
@var{key}: should contain a @code{gnutls_privkey_t}  type
Packit 549fdc
Packit 549fdc
@var{digest}: if non-NULL it will contain the digest algorithm used for key generation (if applicable)
Packit 549fdc
Packit 549fdc
@var{seed}: where seed will be copied to
Packit 549fdc
Packit 549fdc
@var{seed_size}: originally holds the size of  @code{seed} , will be updated with actual size
Packit 549fdc
Packit 549fdc
This function will return the seed that was used to generate the
Packit 549fdc
given private key. That function will succeed only if the key was generated
Packit 549fdc
as a provable key.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.5.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_get_spki
Packit 549fdc
@anchor{gnutls_privkey_get_spki}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_get_spki} (gnutls_privkey_t @var{privkey}, gnutls_x509_spki_t @var{spki}, unsigned int @var{flags})
Packit 549fdc
@var{privkey}: a public key of type @code{gnutls_privkey_t} 
Packit 549fdc
Packit 549fdc
@var{spki}: a SubjectPublicKeyInfo structure of type @code{gnutls_privkey_spki_t} 
Packit 549fdc
Packit 549fdc
@var{flags}: must be zero
Packit 549fdc
Packit 549fdc
This function will return the public key information if available.
Packit 549fdc
The provided  @code{spki} must be initialized.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.6.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_get_type
Packit 549fdc
@anchor{gnutls_privkey_get_type}
Packit 549fdc
@deftypefun {gnutls_privkey_type_t} {gnutls_privkey_get_type} (gnutls_privkey_t @var{key})
Packit 549fdc
@var{key}: should contain a @code{gnutls_privkey_t}  type
Packit 549fdc
Packit 549fdc
This function will return the type of the private key. This is
Packit 549fdc
actually the type of the subsystem used to set this private key.
Packit 549fdc
Packit 549fdc
@strong{Returns:} a member of the @code{gnutls_privkey_type_t}  enumeration on
Packit 549fdc
success, or a negative error code on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_import_dsa_raw
Packit 549fdc
@anchor{gnutls_privkey_import_dsa_raw}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_import_dsa_raw} (gnutls_privkey_t @var{key}, const gnutls_datum_t * @var{p}, const gnutls_datum_t * @var{q}, const gnutls_datum_t * @var{g}, const gnutls_datum_t * @var{y}, const gnutls_datum_t * @var{x})
Packit 549fdc
@var{key}: The structure to store the parsed key
Packit 549fdc
Packit 549fdc
@var{p}: holds the p
Packit 549fdc
Packit 549fdc
@var{q}: holds the q
Packit 549fdc
Packit 549fdc
@var{g}: holds the g
Packit 549fdc
Packit 549fdc
@var{y}: holds the y
Packit 549fdc
Packit 549fdc
@var{x}: holds the x
Packit 549fdc
Packit 549fdc
This function will convert the given DSA raw parameters to the
Packit 549fdc
native @code{gnutls_privkey_t}  format.  The output will be stored
Packit 549fdc
in  @code{key} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_import_ecc_raw
Packit 549fdc
@anchor{gnutls_privkey_import_ecc_raw}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_import_ecc_raw} (gnutls_privkey_t @var{key}, gnutls_ecc_curve_t @var{curve}, const gnutls_datum_t * @var{x}, const gnutls_datum_t * @var{y}, const gnutls_datum_t * @var{k})
Packit 549fdc
@var{key}: The key
Packit 549fdc
Packit 549fdc
@var{curve}: holds the curve
Packit 549fdc
Packit 549fdc
@var{x}: holds the x
Packit 549fdc
Packit 549fdc
@var{y}: holds the y
Packit 549fdc
Packit 549fdc
@var{k}: holds the k
Packit 549fdc
Packit 549fdc
This function will convert the given elliptic curve parameters to the
Packit 549fdc
native @code{gnutls_privkey_t}  format.  The output will be stored
Packit 549fdc
in  @code{key} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_import_ext
Packit 549fdc
@anchor{gnutls_privkey_import_ext}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_import_ext} (gnutls_privkey_t @var{pkey}, gnutls_pk_algorithm_t @var{pk}, void * @var{userdata}, gnutls_privkey_sign_func @var{sign_func}, gnutls_privkey_decrypt_func @var{decrypt_func}, unsigned int @var{flags})
Packit 549fdc
@var{pkey}: The private key
Packit 549fdc
Packit 549fdc
@var{pk}: The public key algorithm
Packit 549fdc
Packit 549fdc
@var{userdata}: private data to be provided to the callbacks
Packit 549fdc
Packit 549fdc
@var{sign_func}: callback for signature operations
Packit 549fdc
Packit 549fdc
@var{decrypt_func}: callback for decryption operations
Packit 549fdc
Packit 549fdc
@var{flags}: Flags for the import
Packit 549fdc
Packit 549fdc
This function will associate the given callbacks with the
Packit 549fdc
@code{gnutls_privkey_t}  type. At least one of the two callbacks
Packit 549fdc
must be non-null.
Packit 549fdc
Packit 549fdc
Note that the signing function is supposed to "raw" sign data, i.e.,
Packit 549fdc
without any hashing or preprocessing. In case of RSA the DigestInfo
Packit 549fdc
will be provided, and the signing function is expected to do the PKCS @code{1} 
Packit 549fdc
1.5 padding and the exponentiation.
Packit 549fdc
Packit 549fdc
See also @code{gnutls_privkey_import_ext3()} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_import_ext2
Packit 549fdc
@anchor{gnutls_privkey_import_ext2}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_import_ext2} (gnutls_privkey_t @var{pkey}, gnutls_pk_algorithm_t @var{pk}, void * @var{userdata}, gnutls_privkey_sign_func @var{sign_fn}, gnutls_privkey_decrypt_func @var{decrypt_fn}, gnutls_privkey_deinit_func @var{deinit_fn}, unsigned int @var{flags})
Packit 549fdc
@var{pkey}: The private key
Packit 549fdc
Packit 549fdc
@var{pk}: The public key algorithm
Packit 549fdc
Packit 549fdc
@var{userdata}: private data to be provided to the callbacks
Packit 549fdc
Packit 549fdc
@var{sign_fn}: callback for signature operations
Packit 549fdc
Packit 549fdc
@var{decrypt_fn}: callback for decryption operations
Packit 549fdc
Packit 549fdc
@var{deinit_fn}: a deinitialization function
Packit 549fdc
Packit 549fdc
@var{flags}: Flags for the import
Packit 549fdc
Packit 549fdc
This function will associate the given callbacks with the
Packit 549fdc
@code{gnutls_privkey_t}  type. At least one of the two callbacks
Packit 549fdc
must be non-null. If a deinitialization function is provided
Packit 549fdc
then flags is assumed to contain @code{GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE} .
Packit 549fdc
Packit 549fdc
Note that the signing function is supposed to "raw" sign data, i.e.,
Packit 549fdc
without any hashing or preprocessing. In case of RSA the DigestInfo
Packit 549fdc
will be provided, and the signing function is expected to do the PKCS @code{1} 
Packit 549fdc
1.5 padding and the exponentiation.
Packit 549fdc
Packit 549fdc
See also @code{gnutls_privkey_import_ext3()} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_import_ext3
Packit 549fdc
@anchor{gnutls_privkey_import_ext3}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_import_ext3} (gnutls_privkey_t @var{pkey}, void * @var{userdata}, gnutls_privkey_sign_func @var{sign_fn}, gnutls_privkey_decrypt_func @var{decrypt_fn}, gnutls_privkey_deinit_func @var{deinit_fn}, gnutls_privkey_info_func @var{info_fn}, unsigned int @var{flags})
Packit 549fdc
@var{pkey}: The private key
Packit 549fdc
Packit 549fdc
@var{userdata}: private data to be provided to the callbacks
Packit 549fdc
Packit 549fdc
@var{sign_fn}: callback for signature operations
Packit 549fdc
Packit 549fdc
@var{decrypt_fn}: callback for decryption operations
Packit 549fdc
Packit 549fdc
@var{deinit_fn}: a deinitialization function
Packit 549fdc
Packit 549fdc
@var{info_fn}: returns info about the public key algorithm (should not be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{flags}: Flags for the import
Packit 549fdc
Packit 549fdc
This function will associate the given callbacks with the
Packit 549fdc
@code{gnutls_privkey_t}  type. At least one of the two callbacks
Packit 549fdc
must be non-null. If a deinitialization function is provided
Packit 549fdc
then flags is assumed to contain @code{GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE} .
Packit 549fdc
Packit 549fdc
Note that the signing function is supposed to "raw" sign data, i.e.,
Packit 549fdc
without any hashing or preprocessing. In case of RSA the DigestInfo
Packit 549fdc
will be provided, and the signing function is expected to do the PKCS @code{1} 
Packit 549fdc
1.5 padding and the exponentiation.
Packit 549fdc
Packit 549fdc
The  @code{info_fn} must provide information on the algorithms supported by
Packit 549fdc
this private key, and should support the flags @code{GNUTLS_PRIVKEY_INFO_PK_ALGO}  and
Packit 549fdc
@code{GNUTLS_PRIVKEY_INFO_SIGN_ALGO} . It must return -1 on unknown flags.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_import_ext4
Packit 549fdc
@anchor{gnutls_privkey_import_ext4}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_import_ext4} (gnutls_privkey_t @var{pkey}, void * @var{userdata}, gnutls_privkey_sign_data_func @var{sign_data_fn}, gnutls_privkey_sign_hash_func @var{sign_hash_fn}, gnutls_privkey_decrypt_func @var{decrypt_fn}, gnutls_privkey_deinit_func @var{deinit_fn}, gnutls_privkey_info_func @var{info_fn}, unsigned int @var{flags})
Packit 549fdc
@var{pkey}: The private key
Packit 549fdc
Packit 549fdc
@var{userdata}: private data to be provided to the callbacks
Packit 549fdc
Packit 549fdc
@var{sign_data_fn}: callback for signature operations (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{sign_hash_fn}: callback for signature operations (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{decrypt_fn}: callback for decryption operations (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{deinit_fn}: a deinitialization function
Packit 549fdc
Packit 549fdc
@var{info_fn}: returns info about the public key algorithm (should not be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{flags}: Flags for the import
Packit 549fdc
Packit 549fdc
This function will associate the given callbacks with the
Packit 549fdc
@code{gnutls_privkey_t}  type. At least one of the callbacks
Packit 549fdc
must be non-null. If a deinitialization function is provided
Packit 549fdc
then flags is assumed to contain @code{GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE} .
Packit 549fdc
Packit 549fdc
Note that in contrast with the signing function of
Packit 549fdc
@code{gnutls_privkey_import_ext3()} , the signing functions provided to this
Packit 549fdc
function take explicitly the signature algorithm as parameter and
Packit 549fdc
different functions are provided to sign the data and hashes.
Packit 549fdc
Packit 549fdc
The  @code{sign_hash_fn} is to be called to sign pre-hashed data. The input
Packit 549fdc
to the callback is the output of the hash (such as SHA256) corresponding
Packit 549fdc
to the signature algorithm. For RSA PKCS@code{1}  signatures, the signature
Packit 549fdc
algorithm can be set to @code{GNUTLS_SIGN_RSA_RAW} , and in that case the data
Packit 549fdc
should be handled as if they were an RSA PKCS@code{1}  DigestInfo structure.
Packit 549fdc
Packit 549fdc
The  @code{sign_data_fn} is to be called to sign data. The input data will be
Packit 549fdc
he data to be signed (and hashed), with the provided signature
Packit 549fdc
algorithm. This function is to be used for signature algorithms like
Packit 549fdc
Ed25519 which cannot take pre-hashed data as input.
Packit 549fdc
Packit 549fdc
When both  @code{sign_data_fn} and  @code{sign_hash_fn} functions are provided they
Packit 549fdc
must be able to operate on all the supported signature algorithms,
Packit 549fdc
unless prohibited by the type of the algorithm (e.g., as with Ed25519).
Packit 549fdc
Packit 549fdc
The  @code{info_fn} must provide information on the signature algorithms supported by
Packit 549fdc
this private key, and should support the flags @code{GNUTLS_PRIVKEY_INFO_PK_ALGO}  and
Packit 549fdc
@code{GNUTLS_PRIVKEY_INFO_HAVE_SIGN_ALGO} . It must return -1 on unknown flags.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.6.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_import_openpgp
Packit 549fdc
@anchor{gnutls_privkey_import_openpgp}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_import_openpgp} (gnutls_privkey_t @var{pkey}, gnutls_openpgp_privkey_t @var{key}, unsigned int @var{flags})
Packit 549fdc
@var{pkey}: The private key
Packit 549fdc
Packit 549fdc
@var{key}: The private key to be imported
Packit 549fdc
Packit 549fdc
@var{flags}: Flags for the import
Packit 549fdc
Packit 549fdc
This function is no-op.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_UNIMPLEMENTED_FEATURE} .
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_import_openpgp_raw
Packit 549fdc
@anchor{gnutls_privkey_import_openpgp_raw}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_import_openpgp_raw} (gnutls_privkey_t @var{pkey}, const gnutls_datum_t * @var{data}, gnutls_openpgp_crt_fmt_t           @var{format}, const gnutls_openpgp_keyid_t           @var{keyid}, const char * @var{password})
Packit 549fdc
@var{pkey}: The private key
Packit 549fdc
Packit 549fdc
@var{data}: The private key data to be imported
Packit 549fdc
Packit 549fdc
@var{format}: The format of the private key
Packit 549fdc
Packit 549fdc
@var{keyid}: The key id to use (optional)
Packit 549fdc
Packit 549fdc
@var{password}: A password (optional)
Packit 549fdc
Packit 549fdc
This function is no-op.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_UNIMPLEMENTED_FEATURE} .
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_import_pkcs11
Packit 549fdc
@anchor{gnutls_privkey_import_pkcs11}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_import_pkcs11} (gnutls_privkey_t @var{pkey}, gnutls_pkcs11_privkey_t @var{key}, unsigned int @var{flags})
Packit 549fdc
@var{pkey}: The private key
Packit 549fdc
Packit 549fdc
@var{key}: The private key to be imported
Packit 549fdc
Packit 549fdc
@var{flags}: Flags for the import
Packit 549fdc
Packit 549fdc
This function will import the given private key to the abstract
Packit 549fdc
@code{gnutls_privkey_t}  type.
Packit 549fdc
Packit 549fdc
The @code{gnutls_pkcs11_privkey_t}  object must not be deallocated
Packit 549fdc
during the lifetime of this structure.
Packit 549fdc
Packit 549fdc
 @code{flags} might be zero or one of @code{GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE} 
Packit 549fdc
and @code{GNUTLS_PRIVKEY_IMPORT_COPY} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_import_pkcs11_url
Packit 549fdc
@anchor{gnutls_privkey_import_pkcs11_url}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_import_pkcs11_url} (gnutls_privkey_t @var{key}, const char * @var{url})
Packit 549fdc
@var{key}: A key of type @code{gnutls_pubkey_t} 
Packit 549fdc
Packit 549fdc
@var{url}: A PKCS 11 url
Packit 549fdc
Packit 549fdc
This function will import a PKCS 11 private key to a @code{gnutls_private_key_t} 
Packit 549fdc
type.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_import_rsa_raw
Packit 549fdc
@anchor{gnutls_privkey_import_rsa_raw}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_import_rsa_raw} (gnutls_privkey_t @var{key}, const gnutls_datum_t * @var{m}, const gnutls_datum_t * @var{e}, const gnutls_datum_t * @var{d}, const gnutls_datum_t * @var{p}, const gnutls_datum_t * @var{q}, const gnutls_datum_t * @var{u}, const gnutls_datum_t * @var{e1}, const gnutls_datum_t * @var{e2})
Packit 549fdc
@var{key}: The structure to store the parsed key
Packit 549fdc
Packit 549fdc
@var{m}: holds the modulus
Packit 549fdc
Packit 549fdc
@var{e}: holds the public exponent
Packit 549fdc
Packit 549fdc
@var{d}: holds the private exponent
Packit 549fdc
Packit 549fdc
@var{p}: holds the first prime (p)
Packit 549fdc
Packit 549fdc
@var{q}: holds the second prime (q)
Packit 549fdc
Packit 549fdc
@var{u}: holds the coefficient (optional)
Packit 549fdc
Packit 549fdc
@var{e1}: holds e1 = d mod (p-1) (optional)
Packit 549fdc
Packit 549fdc
@var{e2}: holds e2 = d mod (q-1) (optional)
Packit 549fdc
Packit 549fdc
This function will convert the given RSA raw parameters to the
Packit 549fdc
native @code{gnutls_privkey_t}  format.  The output will be stored in
Packit 549fdc
 @code{key} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_import_tpm_raw
Packit 549fdc
@anchor{gnutls_privkey_import_tpm_raw}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_import_tpm_raw} (gnutls_privkey_t @var{pkey}, const gnutls_datum_t * @var{fdata}, gnutls_tpmkey_fmt_t @var{format}, const char * @var{srk_password}, const char * @var{key_password}, unsigned int @var{flags})
Packit 549fdc
@var{pkey}: The private key
Packit 549fdc
Packit 549fdc
@var{fdata}: The TPM key to be imported
Packit 549fdc
Packit 549fdc
@var{format}: The format of the private key
Packit 549fdc
Packit 549fdc
@var{srk_password}: The password for the SRK key (optional)
Packit 549fdc
Packit 549fdc
@var{key_password}: A password for the key (optional)
Packit 549fdc
Packit 549fdc
@var{flags}: should be zero
Packit 549fdc
Packit 549fdc
This function will import the given private key to the abstract
Packit 549fdc
@code{gnutls_privkey_t}  type. 
Packit 549fdc
Packit 549fdc
With respect to passwords the same as in @code{gnutls_privkey_import_tpm_url()}  apply.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_import_tpm_url
Packit 549fdc
@anchor{gnutls_privkey_import_tpm_url}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_import_tpm_url} (gnutls_privkey_t @var{pkey}, const char * @var{url}, const char * @var{srk_password}, const char * @var{key_password}, unsigned int @var{flags})
Packit 549fdc
@var{pkey}: The private key
Packit 549fdc
Packit 549fdc
@var{url}: The URL of the TPM key to be imported
Packit 549fdc
Packit 549fdc
@var{srk_password}: The password for the SRK key (optional)
Packit 549fdc
Packit 549fdc
@var{key_password}: A password for the key (optional)
Packit 549fdc
Packit 549fdc
@var{flags}: One of the GNUTLS_PRIVKEY_* flags
Packit 549fdc
Packit 549fdc
This function will import the given private key to the abstract
Packit 549fdc
@code{gnutls_privkey_t}  type.
Packit 549fdc
Packit 549fdc
Note that unless @code{GNUTLS_PRIVKEY_DISABLE_CALLBACKS} 
Packit 549fdc
is specified, if incorrect (or NULL) passwords are given
Packit 549fdc
the PKCS11 callback functions will be used to obtain the
Packit 549fdc
correct passwords. Otherwise if the SRK password is wrong
Packit 549fdc
@code{GNUTLS_E_TPM_SRK_PASSWORD_ERROR}  is returned and if the key password
Packit 549fdc
is wrong or not provided then @code{GNUTLS_E_TPM_KEY_PASSWORD_ERROR} 
Packit 549fdc
is returned. 
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_import_url
Packit 549fdc
@anchor{gnutls_privkey_import_url}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_import_url} (gnutls_privkey_t @var{key}, const char * @var{url}, unsigned int @var{flags})
Packit 549fdc
@var{key}: A key of type @code{gnutls_privkey_t} 
Packit 549fdc
Packit 549fdc
@var{url}: A PKCS 11 url
Packit 549fdc
Packit 549fdc
@var{flags}: should be zero
Packit 549fdc
Packit 549fdc
This function will import a PKCS11 or TPM URL as a
Packit 549fdc
private key. The supported URL types can be checked
Packit 549fdc
using @code{gnutls_url_is_supported()} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_import_x509
Packit 549fdc
@anchor{gnutls_privkey_import_x509}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_import_x509} (gnutls_privkey_t @var{pkey}, gnutls_x509_privkey_t @var{key}, unsigned int @var{flags})
Packit 549fdc
@var{pkey}: The private key
Packit 549fdc
Packit 549fdc
@var{key}: The private key to be imported
Packit 549fdc
Packit 549fdc
@var{flags}: Flags for the import
Packit 549fdc
Packit 549fdc
This function will import the given private key to the abstract
Packit 549fdc
@code{gnutls_privkey_t}  type.
Packit 549fdc
Packit 549fdc
The @code{gnutls_x509_privkey_t}  object must not be deallocated
Packit 549fdc
during the lifetime of this structure.
Packit 549fdc
Packit 549fdc
 @code{flags} might be zero or one of @code{GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE} 
Packit 549fdc
and @code{GNUTLS_PRIVKEY_IMPORT_COPY} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_import_x509_raw
Packit 549fdc
@anchor{gnutls_privkey_import_x509_raw}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_import_x509_raw} (gnutls_privkey_t @var{pkey}, const gnutls_datum_t * @var{data}, gnutls_x509_crt_fmt_t @var{format}, const char * @var{password}, unsigned int @var{flags})
Packit 549fdc
@var{pkey}: The private key
Packit 549fdc
Packit 549fdc
@var{data}: The private key data to be imported
Packit 549fdc
Packit 549fdc
@var{format}: The format of the private key
Packit 549fdc
Packit 549fdc
@var{password}: A password (optional)
Packit 549fdc
Packit 549fdc
@var{flags}: an ORed sequence of gnutls_pkcs_encrypt_flags_t
Packit 549fdc
Packit 549fdc
This function will import the given private key to the abstract
Packit 549fdc
@code{gnutls_privkey_t}  type. 
Packit 549fdc
Packit 549fdc
The supported formats are basic unencrypted key, PKCS8, PKCS12, 
Packit 549fdc
and the openssl format.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_init
Packit 549fdc
@anchor{gnutls_privkey_init}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_init} (gnutls_privkey_t * @var{key})
Packit 549fdc
@var{key}: A pointer to the type to be initialized
Packit 549fdc
Packit 549fdc
This function will initialize a private key object. The object can
Packit 549fdc
be used to generate, import, and perform cryptographic operations
Packit 549fdc
on the associated private key.
Packit 549fdc
Packit 549fdc
Note that when the underlying private key is a PKCS@code{11}  key (i.e.,
Packit 549fdc
when imported with a PKCS@code{11}  URI), the limitations of @code{gnutls_pkcs11_privkey_init()} 
Packit 549fdc
apply to this object as well. In versions of GnuTLS later than 3.5.11 the object
Packit 549fdc
is protected using locks and a single @code{gnutls_privkey_t}  can be re-used
Packit 549fdc
by many threads. However, for performance it is recommended to utilize
Packit 549fdc
one object per key per thread.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_set_flags
Packit 549fdc
@anchor{gnutls_privkey_set_flags}
Packit 549fdc
@deftypefun {void} {gnutls_privkey_set_flags} (gnutls_privkey_t @var{key}, unsigned int @var{flags})
Packit 549fdc
@var{key}: A key of type @code{gnutls_privkey_t} 
Packit 549fdc
Packit 549fdc
@var{flags}: flags from the @code{gnutls_privkey_flags} 
Packit 549fdc
Packit 549fdc
This function will set flags for the specified private key, after
Packit 549fdc
it is generated. Currently this is useful for the @code{GNUTLS_PRIVKEY_FLAG_EXPORT_COMPAT} 
Packit 549fdc
to allow exporting a "provable" private key in backwards compatible way.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.5.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_set_pin_function
Packit 549fdc
@anchor{gnutls_privkey_set_pin_function}
Packit 549fdc
@deftypefun {void} {gnutls_privkey_set_pin_function} (gnutls_privkey_t @var{key}, gnutls_pin_callback_t @var{fn}, void * @var{userdata})
Packit 549fdc
@var{key}: A key of type @code{gnutls_privkey_t} 
Packit 549fdc
Packit 549fdc
@var{fn}: the callback
Packit 549fdc
Packit 549fdc
@var{userdata}: data associated with the callback
Packit 549fdc
Packit 549fdc
This function will set a callback function to be used when
Packit 549fdc
required to access the object. This function overrides any other
Packit 549fdc
global PIN functions.
Packit 549fdc
Packit 549fdc
Note that this function must be called right after initialization
Packit 549fdc
to have effect.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_set_spki
Packit 549fdc
@anchor{gnutls_privkey_set_spki}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_set_spki} (gnutls_privkey_t @var{privkey}, const gnutls_x509_spki_t @var{spki}, unsigned int @var{flags})
Packit 549fdc
@var{privkey}: a public key of type @code{gnutls_privkey_t} 
Packit 549fdc
Packit 549fdc
@var{spki}: a SubjectPublicKeyInfo structure of type @code{gnutls_privkey_spki_t} 
Packit 549fdc
Packit 549fdc
@var{flags}: must be zero
Packit 549fdc
Packit 549fdc
This function will set the public key information.
Packit 549fdc
The provided  @code{spki} must be initialized.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.6.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_sign_data
Packit 549fdc
@anchor{gnutls_privkey_sign_data}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_sign_data} (gnutls_privkey_t @var{signer}, gnutls_digest_algorithm_t @var{hash}, unsigned int @var{flags}, const gnutls_datum_t * @var{data}, gnutls_datum_t * @var{signature})
Packit 549fdc
@var{signer}: Holds the key
Packit 549fdc
Packit 549fdc
@var{hash}: should be a digest algorithm
Packit 549fdc
Packit 549fdc
@var{flags}: Zero or one of @code{gnutls_privkey_flags_t} 
Packit 549fdc
Packit 549fdc
@var{data}: holds the data to be signed
Packit 549fdc
Packit 549fdc
@var{signature}: will contain the signature allocated with @code{gnutls_malloc()} 
Packit 549fdc
Packit 549fdc
This function will sign the given data using a signature algorithm
Packit 549fdc
supported by the private key. Signature algorithms are always used
Packit 549fdc
together with a hash functions.  Different hash functions may be
Packit 549fdc
used for the RSA algorithm, but only the SHA family for the DSA keys.
Packit 549fdc
Packit 549fdc
You may use @code{gnutls_pubkey_get_preferred_hash_algorithm()}  to determine
Packit 549fdc
the hash algorithm.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_sign_data2
Packit 549fdc
@anchor{gnutls_privkey_sign_data2}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_sign_data2} (gnutls_privkey_t @var{signer}, gnutls_sign_algorithm_t @var{algo}, unsigned int @var{flags}, const gnutls_datum_t * @var{data}, gnutls_datum_t * @var{signature})
Packit 549fdc
@var{signer}: Holds the key
Packit 549fdc
Packit 549fdc
@var{algo}: The signature algorithm used
Packit 549fdc
Packit 549fdc
@var{flags}: Zero or one of @code{gnutls_privkey_flags_t} 
Packit 549fdc
Packit 549fdc
@var{data}: holds the data to be signed
Packit 549fdc
Packit 549fdc
@var{signature}: will contain the signature allocated with @code{gnutls_malloc()} 
Packit 549fdc
Packit 549fdc
This function will sign the given data using the specified signature
Packit 549fdc
algorithm. This function is an enhancement of @code{gnutls_privkey_sign_data()} ,
Packit 549fdc
as it allows utilizing a alternative signature algorithm where possible
Packit 549fdc
(e.g, use an RSA key with RSA-PSS).
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.6.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_sign_hash
Packit 549fdc
@anchor{gnutls_privkey_sign_hash}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_sign_hash} (gnutls_privkey_t @var{signer}, gnutls_digest_algorithm_t @var{hash_algo}, unsigned int @var{flags}, const gnutls_datum_t * @var{hash_data}, gnutls_datum_t * @var{signature})
Packit 549fdc
@var{signer}: Holds the signer's key
Packit 549fdc
Packit 549fdc
@var{hash_algo}: The hash algorithm used
Packit 549fdc
Packit 549fdc
@var{flags}: Zero or one of @code{gnutls_privkey_flags_t} 
Packit 549fdc
Packit 549fdc
@var{hash_data}: holds the data to be signed
Packit 549fdc
Packit 549fdc
@var{signature}: will contain newly allocated signature
Packit 549fdc
Packit 549fdc
This function will sign the given hashed data using a signature algorithm
Packit 549fdc
supported by the private key. Signature algorithms are always used
Packit 549fdc
together with a hash functions.  Different hash functions may be
Packit 549fdc
used for the RSA algorithm, but only SHA-XXX for the DSA keys.
Packit 549fdc
Packit 549fdc
You may use @code{gnutls_pubkey_get_preferred_hash_algorithm()}  to determine
Packit 549fdc
the hash algorithm.
Packit 549fdc
Packit 549fdc
The flags may be @code{GNUTLS_PRIVKEY_SIGN_FLAG_TLS1_RSA}  or @code{GNUTLS_PRIVKEY_SIGN_FLAG_RSA_PSS} .
Packit 549fdc
In the former case this function will ignore  @code{hash_algo} and perform a raw PKCS1 signature,
Packit 549fdc
and in the latter an RSA-PSS signature will be generated.
Packit 549fdc
Packit 549fdc
Note that, not all algorithm support signing already hashed data. When
Packit 549fdc
signing with Ed25519, @code{gnutls_privkey_sign_data()}  should be used.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_sign_hash2
Packit 549fdc
@anchor{gnutls_privkey_sign_hash2}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_sign_hash2} (gnutls_privkey_t @var{signer}, gnutls_sign_algorithm_t @var{algo}, unsigned int @var{flags}, const gnutls_datum_t * @var{hash_data}, gnutls_datum_t * @var{signature})
Packit 549fdc
@var{signer}: Holds the signer's key
Packit 549fdc
Packit 549fdc
@var{algo}: The signature algorithm used
Packit 549fdc
Packit 549fdc
@var{flags}: Zero or one of @code{gnutls_privkey_flags_t} 
Packit 549fdc
Packit 549fdc
@var{hash_data}: holds the data to be signed
Packit 549fdc
Packit 549fdc
@var{signature}: will contain newly allocated signature
Packit 549fdc
Packit 549fdc
This function will sign the given hashed data using a signature algorithm
Packit 549fdc
supported by the private key. Signature algorithms are always used
Packit 549fdc
together with a hash functions.  Different hash functions may be
Packit 549fdc
used for the RSA algorithm, but only SHA-XXX for the DSA keys.
Packit 549fdc
Packit 549fdc
You may use @code{gnutls_pubkey_get_preferred_hash_algorithm()}  to determine
Packit 549fdc
the hash algorithm.
Packit 549fdc
Packit 549fdc
The flags may be @code{GNUTLS_PRIVKEY_SIGN_FLAG_TLS1_RSA}  or @code{GNUTLS_PRIVKEY_SIGN_FLAG_RSA_PSS} .
Packit 549fdc
In the former case this function will ignore  @code{hash_algo} and perform a raw PKCS1 signature,
Packit 549fdc
and in the latter an RSA-PSS signature will be generated.
Packit 549fdc
Packit 549fdc
Note that, not all algorithm support signing already hashed data. When
Packit 549fdc
signing with Ed25519, @code{gnutls_privkey_sign_data()}  should be used.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.6.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_status
Packit 549fdc
@anchor{gnutls_privkey_status}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_status} (gnutls_privkey_t @var{key})
Packit 549fdc
@var{key}: Holds the key
Packit 549fdc
Packit 549fdc
Checks the status of the private key token. This function
Packit 549fdc
is an actual wrapper over @code{gnutls_pkcs11_privkey_status()} , and
Packit 549fdc
if the private key is a PKCS @code{11}  token it will check whether
Packit 549fdc
it is inserted or not.
Packit 549fdc
Packit 549fdc
@strong{Returns:} this function will return non-zero if the token 
Packit 549fdc
holding the private key is still available (inserted), and zero otherwise.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1.10
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_verify_params
Packit 549fdc
@anchor{gnutls_privkey_verify_params}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_verify_params} (gnutls_privkey_t @var{key})
Packit 549fdc
@var{key}: should contain a @code{gnutls_privkey_t}  type
Packit 549fdc
Packit 549fdc
This function will verify the private key parameters.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_privkey_verify_seed
Packit 549fdc
@anchor{gnutls_privkey_verify_seed}
Packit 549fdc
@deftypefun {int} {gnutls_privkey_verify_seed} (gnutls_privkey_t @var{key}, gnutls_digest_algorithm_t @var{digest}, const void * @var{seed}, size_t @var{seed_size})
Packit 549fdc
@var{key}: should contain a @code{gnutls_privkey_t}  type
Packit 549fdc
Packit 549fdc
@var{digest}: it contains the digest algorithm used for key generation (if applicable)
Packit 549fdc
Packit 549fdc
@var{seed}: the seed of the key to be checked with
Packit 549fdc
Packit 549fdc
@var{seed_size}: holds the size of  @code{seed} 
Packit 549fdc
Packit 549fdc
This function will verify that the given private key was generated from
Packit 549fdc
the provided seed.
Packit 549fdc
Packit 549fdc
@strong{Returns:} In case of a verification failure @code{GNUTLS_E_PRIVKEY_VERIFICATION_ERROR} 
Packit 549fdc
is returned, and zero or positive code on success.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.5.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_deinit
Packit 549fdc
@anchor{gnutls_pubkey_deinit}
Packit 549fdc
@deftypefun {void} {gnutls_pubkey_deinit} (gnutls_pubkey_t @var{key})
Packit 549fdc
@var{key}: The key to be deinitialized
Packit 549fdc
Packit 549fdc
This function will deinitialize a public key structure.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_encrypt_data
Packit 549fdc
@anchor{gnutls_pubkey_encrypt_data}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_encrypt_data} (gnutls_pubkey_t @var{key}, unsigned int @var{flags}, const gnutls_datum_t * @var{plaintext}, gnutls_datum_t * @var{ciphertext})
Packit 549fdc
@var{key}: Holds the public key
Packit 549fdc
Packit 549fdc
@var{flags}: should be 0 for now
Packit 549fdc
Packit 549fdc
@var{plaintext}: The data to be encrypted
Packit 549fdc
Packit 549fdc
@var{ciphertext}: contains the encrypted data
Packit 549fdc
Packit 549fdc
This function will encrypt the given data, using the public
Packit 549fdc
key. On success the  @code{ciphertext} will be allocated using @code{gnutls_malloc()} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_export
Packit 549fdc
@anchor{gnutls_pubkey_export}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_export} (gnutls_pubkey_t @var{key}, gnutls_x509_crt_fmt_t @var{format}, void * @var{output_data}, size_t * @var{output_data_size})
Packit 549fdc
@var{key}: Holds the certificate
Packit 549fdc
Packit 549fdc
@var{format}: the format of output params. One of PEM or DER.
Packit 549fdc
Packit 549fdc
@var{output_data}: will contain a certificate PEM or DER encoded
Packit 549fdc
Packit 549fdc
@var{output_data_size}: holds the size of output_data (and will be
Packit 549fdc
replaced by the actual size of parameters)
Packit 549fdc
Packit 549fdc
This function will export the public key to DER or PEM format.
Packit 549fdc
The contents of the exported data is the SubjectPublicKeyInfo
Packit 549fdc
X.509 structure.
Packit 549fdc
Packit 549fdc
If the buffer provided is not long enough to hold the output, then
Packit 549fdc
*output_data_size is updated and @code{GNUTLS_E_SHORT_MEMORY_BUFFER}  will
Packit 549fdc
be returned.
Packit 549fdc
Packit 549fdc
If the structure is PEM encoded, it will have a header
Packit 549fdc
of "BEGIN CERTIFICATE".
Packit 549fdc
Packit 549fdc
@strong{Returns:} In case of failure a negative error code will be
Packit 549fdc
returned, and 0 on success.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_export2
Packit 549fdc
@anchor{gnutls_pubkey_export2}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_export2} (gnutls_pubkey_t @var{key}, gnutls_x509_crt_fmt_t @var{format}, gnutls_datum_t * @var{out})
Packit 549fdc
@var{key}: Holds the certificate
Packit 549fdc
Packit 549fdc
@var{format}: the format of output params. One of PEM or DER.
Packit 549fdc
Packit 549fdc
@var{out}: will contain a certificate PEM or DER encoded
Packit 549fdc
Packit 549fdc
This function will export the public key to DER or PEM format.
Packit 549fdc
The contents of the exported data is the SubjectPublicKeyInfo
Packit 549fdc
X.509 structure.
Packit 549fdc
Packit 549fdc
The output buffer will be allocated using @code{gnutls_malloc()} .
Packit 549fdc
Packit 549fdc
If the structure is PEM encoded, it will have a header
Packit 549fdc
of "BEGIN CERTIFICATE".
Packit 549fdc
Packit 549fdc
@strong{Returns:} In case of failure a negative error code will be
Packit 549fdc
returned, and 0 on success.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1.3
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_export_dsa_raw
Packit 549fdc
@anchor{gnutls_pubkey_export_dsa_raw}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_export_dsa_raw} (gnutls_pubkey_t @var{key}, gnutls_datum_t * @var{p}, gnutls_datum_t * @var{q}, gnutls_datum_t * @var{g}, gnutls_datum_t * @var{y})
Packit 549fdc
@var{key}: Holds the public key
Packit 549fdc
Packit 549fdc
@var{p}: will hold the p (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{q}: will hold the q (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{g}: will hold the g (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{y}: will hold the y (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
This function will export the DSA public key's parameters found in
Packit 549fdc
the given certificate.  The new parameters will be allocated using
Packit 549fdc
@code{gnutls_malloc()}  and will be stored in the appropriate datum.
Packit 549fdc
Packit 549fdc
This function allows for @code{NULL}  parameters since 3.4.1.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_export_dsa_raw2
Packit 549fdc
@anchor{gnutls_pubkey_export_dsa_raw2}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_export_dsa_raw2} (gnutls_pubkey_t @var{key}, gnutls_datum_t * @var{p}, gnutls_datum_t * @var{q}, gnutls_datum_t * @var{g}, gnutls_datum_t * @var{y}, unsigned @var{flags})
Packit 549fdc
@var{key}: Holds the public key
Packit 549fdc
Packit 549fdc
@var{p}: will hold the p (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{q}: will hold the q (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{g}: will hold the g (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{y}: will hold the y (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{flags}: flags from @code{gnutls_abstract_export_flags_t} 
Packit 549fdc
Packit 549fdc
This function will export the DSA public key's parameters found in
Packit 549fdc
the given certificate.  The new parameters will be allocated using
Packit 549fdc
@code{gnutls_malloc()}  and will be stored in the appropriate datum.
Packit 549fdc
Packit 549fdc
This function allows for @code{NULL}  parameters since 3.4.1.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.6.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_export_ecc_raw
Packit 549fdc
@anchor{gnutls_pubkey_export_ecc_raw}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_export_ecc_raw} (gnutls_pubkey_t @var{key}, gnutls_ecc_curve_t * @var{curve}, gnutls_datum_t * @var{x}, gnutls_datum_t * @var{y})
Packit 549fdc
@var{key}: Holds the public key
Packit 549fdc
Packit 549fdc
@var{curve}: will hold the curve (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{x}: will hold x (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{y}: will hold y (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
This function will export the ECC public key's parameters found in
Packit 549fdc
the given key.  The new parameters will be allocated using
Packit 549fdc
@code{gnutls_malloc()}  and will be stored in the appropriate datum.
Packit 549fdc
For EdDSA public keys,  @code{y} will be set to @code{NULL} .
Packit 549fdc
Packit 549fdc
This function allows for @code{NULL}  parameters since 3.4.1.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_export_ecc_raw2
Packit 549fdc
@anchor{gnutls_pubkey_export_ecc_raw2}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_export_ecc_raw2} (gnutls_pubkey_t @var{key}, gnutls_ecc_curve_t * @var{curve}, gnutls_datum_t * @var{x}, gnutls_datum_t * @var{y}, unsigned int @var{flags})
Packit 549fdc
@var{key}: Holds the public key
Packit 549fdc
Packit 549fdc
@var{curve}: will hold the curve (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{x}: will hold x (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{y}: will hold y (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{flags}: flags from @code{gnutls_abstract_export_flags_t} 
Packit 549fdc
Packit 549fdc
This function will export the ECC public key's parameters found in
Packit 549fdc
the given key.  The new parameters will be allocated using
Packit 549fdc
@code{gnutls_malloc()}  and will be stored in the appropriate datum.
Packit 549fdc
Packit 549fdc
This function allows for @code{NULL}  parameters since 3.4.1.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.6.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_export_ecc_x962
Packit 549fdc
@anchor{gnutls_pubkey_export_ecc_x962}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_export_ecc_x962} (gnutls_pubkey_t @var{key}, gnutls_datum_t * @var{parameters}, gnutls_datum_t * @var{ecpoint})
Packit 549fdc
@var{key}: Holds the public key
Packit 549fdc
Packit 549fdc
@var{parameters}: DER encoding of an ANSI X9.62 parameters
Packit 549fdc
Packit 549fdc
@var{ecpoint}: DER encoding of ANSI X9.62 ECPoint
Packit 549fdc
Packit 549fdc
This function will export the ECC public key's parameters found in
Packit 549fdc
the given certificate.  The new parameters will be allocated using
Packit 549fdc
@code{gnutls_malloc()}  and will be stored in the appropriate datum.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_export_rsa_raw
Packit 549fdc
@anchor{gnutls_pubkey_export_rsa_raw}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_export_rsa_raw} (gnutls_pubkey_t @var{key}, gnutls_datum_t * @var{m}, gnutls_datum_t * @var{e})
Packit 549fdc
@var{key}: Holds the certificate
Packit 549fdc
Packit 549fdc
@var{m}: will hold the modulus (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{e}: will hold the public exponent (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
This function will export the RSA public key's parameters found in
Packit 549fdc
the given structure.  The new parameters will be allocated using
Packit 549fdc
@code{gnutls_malloc()}  and will be stored in the appropriate datum.
Packit 549fdc
Packit 549fdc
This function allows for @code{NULL}  parameters since 3.4.1.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_export_rsa_raw2
Packit 549fdc
@anchor{gnutls_pubkey_export_rsa_raw2}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_export_rsa_raw2} (gnutls_pubkey_t @var{key}, gnutls_datum_t * @var{m}, gnutls_datum_t * @var{e}, unsigned @var{flags})
Packit 549fdc
@var{key}: Holds the certificate
Packit 549fdc
Packit 549fdc
@var{m}: will hold the modulus (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{e}: will hold the public exponent (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{flags}: flags from @code{gnutls_abstract_export_flags_t} 
Packit 549fdc
Packit 549fdc
This function will export the RSA public key's parameters found in
Packit 549fdc
the given structure.  The new parameters will be allocated using
Packit 549fdc
@code{gnutls_malloc()}  and will be stored in the appropriate datum.
Packit 549fdc
Packit 549fdc
This function allows for @code{NULL}  parameters since 3.4.1.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.6.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_get_key_id
Packit 549fdc
@anchor{gnutls_pubkey_get_key_id}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_get_key_id} (gnutls_pubkey_t @var{key}, unsigned int @var{flags}, unsigned char * @var{output_data}, size_t * @var{output_data_size})
Packit 549fdc
@var{key}: Holds the public key
Packit 549fdc
Packit 549fdc
@var{flags}: should be one of the flags from @code{gnutls_keyid_flags_t} 
Packit 549fdc
Packit 549fdc
@var{output_data}: will contain the key ID
Packit 549fdc
Packit 549fdc
@var{output_data_size}: holds the size of output_data (and will be
Packit 549fdc
replaced by the actual size of parameters)
Packit 549fdc
Packit 549fdc
This function will return a unique ID that depends on the public
Packit 549fdc
key parameters. This ID can be used in checking whether a
Packit 549fdc
certificate corresponds to the given public key.
Packit 549fdc
Packit 549fdc
If the buffer provided is not long enough to hold the output, then
Packit 549fdc
*output_data_size is updated and @code{GNUTLS_E_SHORT_MEMORY_BUFFER}  will
Packit 549fdc
be returned.  The output will normally be a SHA-1 hash output,
Packit 549fdc
which is 20 bytes.
Packit 549fdc
Packit 549fdc
@strong{Returns:} In case of failure a negative error code will be
Packit 549fdc
returned, and 0 on success.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_get_key_usage
Packit 549fdc
@anchor{gnutls_pubkey_get_key_usage}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_get_key_usage} (gnutls_pubkey_t @var{key}, unsigned int * @var{usage})
Packit 549fdc
@var{key}: should contain a @code{gnutls_pubkey_t}  type
Packit 549fdc
Packit 549fdc
@var{usage}: If set will return the number of bits of the parameters (may be NULL)
Packit 549fdc
Packit 549fdc
This function will return the key usage of the public key.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_get_openpgp_key_id
Packit 549fdc
@anchor{gnutls_pubkey_get_openpgp_key_id}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_get_openpgp_key_id} (gnutls_pubkey_t @var{key}, unsigned int @var{flags}, unsigned char * @var{output_data}, size_t * @var{output_data_size}, unsigned int * @var{subkey})
Packit 549fdc
@var{key}: Holds the public key
Packit 549fdc
Packit 549fdc
@var{flags}: should be one of the flags from @code{gnutls_keyid_flags_t} 
Packit 549fdc
Packit 549fdc
@var{output_data}: will contain the key ID
Packit 549fdc
Packit 549fdc
@var{output_data_size}: holds the size of output_data (and will be
Packit 549fdc
replaced by the actual size of parameters)
Packit 549fdc
Packit 549fdc
@var{subkey}: -- undescribed --
Packit 549fdc
Packit 549fdc
This function is no-op.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_UNIMPLEMENTED_FEATURE} .
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_get_pk_algorithm
Packit 549fdc
@anchor{gnutls_pubkey_get_pk_algorithm}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_get_pk_algorithm} (gnutls_pubkey_t @var{key}, unsigned int * @var{bits})
Packit 549fdc
@var{key}: should contain a @code{gnutls_pubkey_t}  type
Packit 549fdc
Packit 549fdc
@var{bits}: If set will return the number of bits of the parameters (may be NULL)
Packit 549fdc
Packit 549fdc
This function will return the public key algorithm of a public
Packit 549fdc
key and if possible will return a number of bits that indicates
Packit 549fdc
the security parameter of the key.
Packit 549fdc
Packit 549fdc
@strong{Returns:} a member of the @code{gnutls_pk_algorithm_t}  enumeration on
Packit 549fdc
success, or a negative error code on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_get_preferred_hash_algorithm
Packit 549fdc
@anchor{gnutls_pubkey_get_preferred_hash_algorithm}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_get_preferred_hash_algorithm} (gnutls_pubkey_t @var{key}, gnutls_digest_algorithm_t *         @var{hash}, unsigned int * @var{mand})
Packit 549fdc
@var{key}: Holds the certificate
Packit 549fdc
Packit 549fdc
@var{hash}: The result of the call with the hash algorithm used for signature
Packit 549fdc
Packit 549fdc
@var{mand}: If non zero it means that the algorithm MUST use this hash. May be NULL.
Packit 549fdc
Packit 549fdc
This function will read the certificate and return the appropriate digest
Packit 549fdc
algorithm to use for signing with this certificate. Some certificates (i.e.
Packit 549fdc
DSA might not be able to sign without the preferred algorithm).
Packit 549fdc
Packit 549fdc
To get the signature algorithm instead of just the hash use @code{gnutls_pk_to_sign()} 
Packit 549fdc
with the algorithm of the certificate/key and the provided  @code{hash} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} the 0 if the hash algorithm is found. A negative error code is
Packit 549fdc
returned on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_get_spki
Packit 549fdc
@anchor{gnutls_pubkey_get_spki}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_get_spki} (gnutls_pubkey_t @var{pubkey}, gnutls_x509_spki_t @var{spki}, unsigned int @var{flags})
Packit 549fdc
@var{pubkey}: a public key of type @code{gnutls_pubkey_t} 
Packit 549fdc
Packit 549fdc
@var{spki}: a SubjectPublicKeyInfo structure of type @code{gnutls_pubkey_spki_t} 
Packit 549fdc
Packit 549fdc
@var{flags}: must be zero
Packit 549fdc
Packit 549fdc
This function will return the public key information if available.
Packit 549fdc
The provided  @code{spki} must be initialized.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.6.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_import
Packit 549fdc
@anchor{gnutls_pubkey_import}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_import} (gnutls_pubkey_t @var{key}, const gnutls_datum_t * @var{data}, gnutls_x509_crt_fmt_t @var{format})
Packit 549fdc
@var{key}: The public key. 
Packit 549fdc
Packit 549fdc
@var{data}: The DER or PEM encoded certificate. 
Packit 549fdc
Packit 549fdc
@var{format}: One of DER or PEM 
Packit 549fdc
Packit 549fdc
This function will import the provided public key in
Packit 549fdc
a SubjectPublicKeyInfo X.509 structure to a native
Packit 549fdc
@code{gnutls_pubkey_t}  type. The output will be stored 
Packit 549fdc
in  @code{key} . If the public key is PEM encoded it should have a header 
Packit 549fdc
of "PUBLIC KEY". 
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_import_dsa_raw
Packit 549fdc
@anchor{gnutls_pubkey_import_dsa_raw}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_import_dsa_raw} (gnutls_pubkey_t @var{key}, const gnutls_datum_t * @var{p}, const gnutls_datum_t * @var{q}, const gnutls_datum_t * @var{g}, const gnutls_datum_t * @var{y})
Packit 549fdc
@var{key}: The structure to store the parsed key
Packit 549fdc
Packit 549fdc
@var{p}: holds the p
Packit 549fdc
Packit 549fdc
@var{q}: holds the q
Packit 549fdc
Packit 549fdc
@var{g}: holds the g
Packit 549fdc
Packit 549fdc
@var{y}: holds the y
Packit 549fdc
Packit 549fdc
This function will convert the given DSA raw parameters to the
Packit 549fdc
native @code{gnutls_pubkey_t}  format.  The output will be stored
Packit 549fdc
in  @code{key} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_import_ecc_raw
Packit 549fdc
@anchor{gnutls_pubkey_import_ecc_raw}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_import_ecc_raw} (gnutls_pubkey_t @var{key}, gnutls_ecc_curve_t @var{curve}, const gnutls_datum_t * @var{x}, const gnutls_datum_t * @var{y})
Packit 549fdc
@var{key}: The structure to store the parsed key
Packit 549fdc
Packit 549fdc
@var{curve}: holds the curve
Packit 549fdc
Packit 549fdc
@var{x}: holds the x
Packit 549fdc
Packit 549fdc
@var{y}: holds the y
Packit 549fdc
Packit 549fdc
This function will convert the given elliptic curve parameters to a
Packit 549fdc
@code{gnutls_pubkey_t} .  The output will be stored in  @code{key} . For EdDSA
Packit 549fdc
keys the  @code{y} parameter should be @code{NULL} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_import_ecc_x962
Packit 549fdc
@anchor{gnutls_pubkey_import_ecc_x962}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_import_ecc_x962} (gnutls_pubkey_t @var{key}, const gnutls_datum_t * @var{parameters}, const gnutls_datum_t * @var{ecpoint})
Packit 549fdc
@var{key}: The structure to store the parsed key
Packit 549fdc
Packit 549fdc
@var{parameters}: DER encoding of an ANSI X9.62 parameters
Packit 549fdc
Packit 549fdc
@var{ecpoint}: DER encoding of ANSI X9.62 ECPoint
Packit 549fdc
Packit 549fdc
This function will convert the given elliptic curve parameters to a
Packit 549fdc
@code{gnutls_pubkey_t} .  The output will be stored in  @code{key} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_import_openpgp
Packit 549fdc
@anchor{gnutls_pubkey_import_openpgp}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_import_openpgp} (gnutls_pubkey_t @var{key}, gnutls_openpgp_crt_t @var{crt}, unsigned int @var{flags})
Packit 549fdc
@var{key}: The public key
Packit 549fdc
Packit 549fdc
@var{crt}: The certificate to be imported
Packit 549fdc
Packit 549fdc
@var{flags}: should be zero
Packit 549fdc
Packit 549fdc
This function is no-op.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_UNIMPLEMENTED_FEATURE} .
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_import_openpgp_raw
Packit 549fdc
@anchor{gnutls_pubkey_import_openpgp_raw}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_import_openpgp_raw} (gnutls_pubkey_t @var{pkey}, const gnutls_datum_t * @var{data}, gnutls_openpgp_crt_fmt_t          @var{format}, const gnutls_openpgp_keyid_t          @var{keyid}, unsigned int @var{flags})
Packit 549fdc
@var{pkey}: The public key
Packit 549fdc
Packit 549fdc
@var{data}: The public key data to be imported
Packit 549fdc
Packit 549fdc
@var{format}: The format of the public key
Packit 549fdc
Packit 549fdc
@var{keyid}: The key id to use (optional)
Packit 549fdc
Packit 549fdc
@var{flags}: Should be zero
Packit 549fdc
Packit 549fdc
This function is no-op.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_UNIMPLEMENTED_FEATURE} .
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1.3
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_import_pkcs11
Packit 549fdc
@anchor{gnutls_pubkey_import_pkcs11}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_import_pkcs11} (gnutls_pubkey_t @var{key}, gnutls_pkcs11_obj_t @var{obj}, unsigned int @var{flags})
Packit 549fdc
@var{key}: The public key
Packit 549fdc
Packit 549fdc
@var{obj}: The parameters to be imported
Packit 549fdc
Packit 549fdc
@var{flags}: should be zero
Packit 549fdc
Packit 549fdc
Imports a public key from a pkcs11 key. This function will import
Packit 549fdc
the given public key to the abstract @code{gnutls_pubkey_t}  type.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_import_privkey
Packit 549fdc
@anchor{gnutls_pubkey_import_privkey}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_import_privkey} (gnutls_pubkey_t @var{key}, gnutls_privkey_t @var{pkey}, unsigned int @var{usage}, unsigned int @var{flags})
Packit 549fdc
@var{key}: The public key
Packit 549fdc
Packit 549fdc
@var{pkey}: The private key
Packit 549fdc
Packit 549fdc
@var{usage}: GNUTLS_KEY_* key usage flags.
Packit 549fdc
Packit 549fdc
@var{flags}: should be zero
Packit 549fdc
Packit 549fdc
Imports the public key from a private.  This function will import
Packit 549fdc
the given public key to the abstract @code{gnutls_pubkey_t}  type.
Packit 549fdc
Packit 549fdc
Note that in certain keys this operation may not be possible, e.g.,
Packit 549fdc
in other than RSA PKCS@code{11}  keys.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_import_rsa_raw
Packit 549fdc
@anchor{gnutls_pubkey_import_rsa_raw}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_import_rsa_raw} (gnutls_pubkey_t @var{key}, const gnutls_datum_t * @var{m}, const gnutls_datum_t * @var{e})
Packit 549fdc
@var{key}: The key
Packit 549fdc
Packit 549fdc
@var{m}: holds the modulus
Packit 549fdc
Packit 549fdc
@var{e}: holds the public exponent
Packit 549fdc
Packit 549fdc
This function will replace the parameters in the given structure.
Packit 549fdc
The new parameters should be stored in the appropriate
Packit 549fdc
gnutls_datum.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, or an negative error code.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_import_tpm_raw
Packit 549fdc
@anchor{gnutls_pubkey_import_tpm_raw}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_import_tpm_raw} (gnutls_pubkey_t @var{pkey}, const gnutls_datum_t * @var{fdata}, gnutls_tpmkey_fmt_t @var{format}, const char * @var{srk_password}, unsigned int @var{flags})
Packit 549fdc
@var{pkey}: The public key
Packit 549fdc
Packit 549fdc
@var{fdata}: The TPM key to be imported
Packit 549fdc
Packit 549fdc
@var{format}: The format of the private key
Packit 549fdc
Packit 549fdc
@var{srk_password}: The password for the SRK key (optional)
Packit 549fdc
Packit 549fdc
@var{flags}: One of the GNUTLS_PUBKEY_* flags
Packit 549fdc
Packit 549fdc
This function will import the public key from the provided TPM key
Packit 549fdc
structure.
Packit 549fdc
Packit 549fdc
With respect to passwords the same as in
Packit 549fdc
@code{gnutls_pubkey_import_tpm_url()}  apply.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_import_tpm_url
Packit 549fdc
@anchor{gnutls_pubkey_import_tpm_url}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_import_tpm_url} (gnutls_pubkey_t @var{pkey}, const char * @var{url}, const char * @var{srk_password}, unsigned int @var{flags})
Packit 549fdc
@var{pkey}: The public key
Packit 549fdc
Packit 549fdc
@var{url}: The URL of the TPM key to be imported
Packit 549fdc
Packit 549fdc
@var{srk_password}: The password for the SRK key (optional)
Packit 549fdc
Packit 549fdc
@var{flags}: should be zero
Packit 549fdc
Packit 549fdc
This function will import the given private key to the abstract
Packit 549fdc
@code{gnutls_privkey_t}  type. 
Packit 549fdc
Packit 549fdc
Note that unless @code{GNUTLS_PUBKEY_DISABLE_CALLBACKS} 
Packit 549fdc
is specified, if incorrect (or NULL) passwords are given
Packit 549fdc
the PKCS11 callback functions will be used to obtain the
Packit 549fdc
correct passwords. Otherwise if the SRK password is wrong
Packit 549fdc
@code{GNUTLS_E_TPM_SRK_PASSWORD_ERROR}  is returned.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_import_url
Packit 549fdc
@anchor{gnutls_pubkey_import_url}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_import_url} (gnutls_pubkey_t @var{key}, const char * @var{url}, unsigned int @var{flags})
Packit 549fdc
@var{key}: A key of type @code{gnutls_pubkey_t} 
Packit 549fdc
Packit 549fdc
@var{url}: A PKCS 11 url
Packit 549fdc
Packit 549fdc
@var{flags}: One of GNUTLS_PKCS11_OBJ_* flags
Packit 549fdc
Packit 549fdc
This function will import a public key from the provided URL.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_import_x509
Packit 549fdc
@anchor{gnutls_pubkey_import_x509}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_import_x509} (gnutls_pubkey_t @var{key}, gnutls_x509_crt_t @var{crt}, unsigned int @var{flags})
Packit 549fdc
@var{key}: The public key
Packit 549fdc
Packit 549fdc
@var{crt}: The certificate to be imported
Packit 549fdc
Packit 549fdc
@var{flags}: should be zero
Packit 549fdc
Packit 549fdc
This function will import the given public key to the abstract
Packit 549fdc
@code{gnutls_pubkey_t}  type.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_import_x509_crq
Packit 549fdc
@anchor{gnutls_pubkey_import_x509_crq}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_import_x509_crq} (gnutls_pubkey_t @var{key}, gnutls_x509_crq_t @var{crq}, unsigned int @var{flags})
Packit 549fdc
@var{key}: The public key
Packit 549fdc
Packit 549fdc
@var{crq}: The certificate to be imported
Packit 549fdc
Packit 549fdc
@var{flags}: should be zero
Packit 549fdc
Packit 549fdc
This function will import the given public key to the abstract
Packit 549fdc
@code{gnutls_pubkey_t}  type.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1.5
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_import_x509_raw
Packit 549fdc
@anchor{gnutls_pubkey_import_x509_raw}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_import_x509_raw} (gnutls_pubkey_t @var{pkey}, const gnutls_datum_t * @var{data}, gnutls_x509_crt_fmt_t @var{format}, unsigned int @var{flags})
Packit 549fdc
@var{pkey}: The public key
Packit 549fdc
Packit 549fdc
@var{data}: The public key data to be imported
Packit 549fdc
Packit 549fdc
@var{format}: The format of the public key
Packit 549fdc
Packit 549fdc
@var{flags}: should be zero
Packit 549fdc
Packit 549fdc
This function will import the given public key to the abstract
Packit 549fdc
@code{gnutls_pubkey_t}  type. 
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1.3
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_init
Packit 549fdc
@anchor{gnutls_pubkey_init}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_init} (gnutls_pubkey_t * @var{key})
Packit 549fdc
@var{key}: A pointer to the type to be initialized
Packit 549fdc
Packit 549fdc
This function will initialize a public key.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_print
Packit 549fdc
@anchor{gnutls_pubkey_print}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_print} (gnutls_pubkey_t @var{pubkey}, gnutls_certificate_print_formats_t @var{format}, gnutls_datum_t * @var{out})
Packit 549fdc
@var{pubkey}: The data to be printed
Packit 549fdc
Packit 549fdc
@var{format}: Indicate the format to use
Packit 549fdc
Packit 549fdc
@var{out}: Newly allocated datum with null terminated string.
Packit 549fdc
Packit 549fdc
This function will pretty print public key information, suitable for
Packit 549fdc
display to a human.
Packit 549fdc
Packit 549fdc
Only @code{GNUTLS_CRT_PRINT_FULL}  and @code{GNUTLS_CRT_PRINT_FULL_NUMBERS} 
Packit 549fdc
are implemented.
Packit 549fdc
Packit 549fdc
The output  @code{out} needs to be deallocated using @code{gnutls_free()} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1.5
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_set_key_usage
Packit 549fdc
@anchor{gnutls_pubkey_set_key_usage}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_set_key_usage} (gnutls_pubkey_t @var{key}, unsigned int @var{usage})
Packit 549fdc
@var{key}: a certificate of type @code{gnutls_x509_crt_t} 
Packit 549fdc
Packit 549fdc
@var{usage}: an ORed sequence of the GNUTLS_KEY_* elements.
Packit 549fdc
Packit 549fdc
This function will set the key usage flags of the public key. This
Packit 549fdc
is only useful if the key is to be exported to a certificate or
Packit 549fdc
certificate request.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_set_pin_function
Packit 549fdc
@anchor{gnutls_pubkey_set_pin_function}
Packit 549fdc
@deftypefun {void} {gnutls_pubkey_set_pin_function} (gnutls_pubkey_t @var{key}, gnutls_pin_callback_t @var{fn}, void * @var{userdata})
Packit 549fdc
@var{key}: A key of type @code{gnutls_pubkey_t} 
Packit 549fdc
Packit 549fdc
@var{fn}: the callback
Packit 549fdc
Packit 549fdc
@var{userdata}: data associated with the callback
Packit 549fdc
Packit 549fdc
This function will set a callback function to be used when
Packit 549fdc
required to access the object. This function overrides any other
Packit 549fdc
global PIN functions.
Packit 549fdc
Packit 549fdc
Note that this function must be called right after initialization
Packit 549fdc
to have effect.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_set_spki
Packit 549fdc
@anchor{gnutls_pubkey_set_spki}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_set_spki} (gnutls_pubkey_t @var{pubkey}, const gnutls_x509_spki_t @var{spki}, unsigned int @var{flags})
Packit 549fdc
@var{pubkey}: a public key of type @code{gnutls_pubkey_t} 
Packit 549fdc
Packit 549fdc
@var{spki}: a SubjectPublicKeyInfo structure of type @code{gnutls_pubkey_spki_t} 
Packit 549fdc
Packit 549fdc
@var{flags}: must be zero
Packit 549fdc
Packit 549fdc
This function will set the public key information.
Packit 549fdc
The provided  @code{spki} must be initialized.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.6.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_verify_data2
Packit 549fdc
@anchor{gnutls_pubkey_verify_data2}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_verify_data2} (gnutls_pubkey_t @var{pubkey}, gnutls_sign_algorithm_t @var{algo}, unsigned int @var{flags}, const gnutls_datum_t * @var{data}, const gnutls_datum_t * @var{signature})
Packit 549fdc
@var{pubkey}: Holds the public key
Packit 549fdc
Packit 549fdc
@var{algo}: The signature algorithm used
Packit 549fdc
Packit 549fdc
@var{flags}: Zero or an OR list of @code{gnutls_certificate_verify_flags} 
Packit 549fdc
Packit 549fdc
@var{data}: holds the signed data
Packit 549fdc
Packit 549fdc
@var{signature}: contains the signature
Packit 549fdc
Packit 549fdc
This function will verify the given signed data, using the
Packit 549fdc
parameters from the certificate.
Packit 549fdc
Packit 549fdc
@strong{Returns:} In case of a verification failure @code{GNUTLS_E_PK_SIG_VERIFY_FAILED}  
Packit 549fdc
is returned, and zero or positive code on success. For known to be insecure
Packit 549fdc
signatures this function will return @code{GNUTLS_E_INSUFFICIENT_SECURITY}  unless
Packit 549fdc
the flag @code{GNUTLS_VERIFY_ALLOW_BROKEN}  is specified.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_verify_hash2
Packit 549fdc
@anchor{gnutls_pubkey_verify_hash2}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_verify_hash2} (gnutls_pubkey_t @var{key}, gnutls_sign_algorithm_t @var{algo}, unsigned int @var{flags}, const gnutls_datum_t * @var{hash}, const gnutls_datum_t * @var{signature})
Packit 549fdc
@var{key}: Holds the public key
Packit 549fdc
Packit 549fdc
@var{algo}: The signature algorithm used
Packit 549fdc
Packit 549fdc
@var{flags}: Zero or an OR list of @code{gnutls_certificate_verify_flags} 
Packit 549fdc
Packit 549fdc
@var{hash}: holds the hash digest to be verified
Packit 549fdc
Packit 549fdc
@var{signature}: contains the signature
Packit 549fdc
Packit 549fdc
This function will verify the given signed digest, using the
Packit 549fdc
parameters from the public key. Note that unlike @code{gnutls_privkey_sign_hash()} ,
Packit 549fdc
this function accepts a signature algorithm instead of a digest algorithm.
Packit 549fdc
You can use @code{gnutls_pk_to_sign()}  to get the appropriate value.
Packit 549fdc
Packit 549fdc
@strong{Returns:} In case of a verification failure @code{GNUTLS_E_PK_SIG_VERIFY_FAILED}  
Packit 549fdc
is returned, and zero or positive code on success. For known to be insecure
Packit 549fdc
signatures this function will return @code{GNUTLS_E_INSUFFICIENT_SECURITY}  unless
Packit 549fdc
the flag @code{GNUTLS_VERIFY_ALLOW_BROKEN}  is specified.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_pubkey_verify_params
Packit 549fdc
@anchor{gnutls_pubkey_verify_params}
Packit 549fdc
@deftypefun {int} {gnutls_pubkey_verify_params} (gnutls_pubkey_t @var{key})
Packit 549fdc
@var{key}: should contain a @code{gnutls_pubkey_t}  type
Packit 549fdc
Packit 549fdc
This function will verify the private key parameters.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_register_custom_url
Packit 549fdc
@anchor{gnutls_register_custom_url}
Packit 549fdc
@deftypefun {int} {gnutls_register_custom_url} (const gnutls_custom_url_st * @var{st})
Packit 549fdc
@var{st}: A @code{gnutls_custom_url_st}  structure
Packit 549fdc
Packit 549fdc
Register a custom URL. This will affect the following functions:
Packit 549fdc
@code{gnutls_url_is_supported()} , @code{gnutls_privkey_import_url()} ,
Packit 549fdc
gnutls_pubkey_import_url, @code{gnutls_x509_crt_import_url()}  
Packit 549fdc
and all functions that depend on
Packit 549fdc
them, e.g., @code{gnutls_certificate_set_x509_key_file2()} .
Packit 549fdc
Packit 549fdc
The provided structure and callback functions must be valid throughout
Packit 549fdc
the lifetime of the process. The registration of an existing URL type
Packit 549fdc
will fail with @code{GNUTLS_E_INVALID_REQUEST} . Since GnuTLS 3.5.0 this function
Packit 549fdc
can be used to override the builtin URLs.
Packit 549fdc
Packit 549fdc
This function is not thread safe.
Packit 549fdc
Packit 549fdc
@strong{Returns:} returns zero if the given structure was imported or a negative value otherwise.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_system_key_add_x509
Packit 549fdc
@anchor{gnutls_system_key_add_x509}
Packit 549fdc
@deftypefun {int} {gnutls_system_key_add_x509} (gnutls_x509_crt_t @var{crt}, gnutls_x509_privkey_t @var{privkey}, const char * @var{label}, char ** @var{cert_url}, char ** @var{key_url})
Packit 549fdc
@var{crt}: the certificate to be added
Packit 549fdc
Packit 549fdc
@var{privkey}: the key to be added
Packit 549fdc
Packit 549fdc
@var{label}: the friendly name to describe the key
Packit 549fdc
Packit 549fdc
@var{cert_url}: if non-NULL it will contain an allocated value with the certificate URL
Packit 549fdc
Packit 549fdc
@var{key_url}: if non-NULL it will contain an allocated value with the key URL
Packit 549fdc
Packit 549fdc
This function will added the given key and certificate pair,
Packit 549fdc
to the system list.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_system_key_delete
Packit 549fdc
@anchor{gnutls_system_key_delete}
Packit 549fdc
@deftypefun {int} {gnutls_system_key_delete} (const char * @var{cert_url}, const char * @var{key_url})
Packit 549fdc
@var{cert_url}: the URL of the certificate
Packit 549fdc
Packit 549fdc
@var{key_url}: the URL of the key
Packit 549fdc
Packit 549fdc
This function will delete the key and certificate pair.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_system_key_iter_deinit
Packit 549fdc
@anchor{gnutls_system_key_iter_deinit}
Packit 549fdc
@deftypefun {void} {gnutls_system_key_iter_deinit} (gnutls_system_key_iter_t @var{iter})
Packit 549fdc
@var{iter}: an iterator of system keys
Packit 549fdc
Packit 549fdc
This function will deinitialize the iterator.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_system_key_iter_get_info
Packit 549fdc
@anchor{gnutls_system_key_iter_get_info}
Packit 549fdc
@deftypefun {int} {gnutls_system_key_iter_get_info} (gnutls_system_key_iter_t * @var{iter}, unsigned @var{cert_type}, char ** @var{cert_url}, char ** @var{key_url}, char ** @var{label}, gnutls_datum_t * @var{der}, unsigned int @var{flags})
Packit 549fdc
@var{iter}: an iterator of the system keys (must be set to @code{NULL}  initially)
Packit 549fdc
Packit 549fdc
@var{cert_type}: A value of gnutls_certificate_type_t which indicates the type of certificate to look for
Packit 549fdc
Packit 549fdc
@var{cert_url}: The certificate URL of the pair (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{key_url}: The key URL of the pair (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{label}: The friendly name (if any) of the pair (may be @code{NULL} )
Packit 549fdc
Packit 549fdc
@var{der}: if non-NULL the DER data of the certificate
Packit 549fdc
Packit 549fdc
@var{flags}: should be zero
Packit 549fdc
Packit 549fdc
This function will return on each call a certificate
Packit 549fdc
and key pair URLs, as well as a label associated with them,
Packit 549fdc
and the DER-encoded certificate. When the iteration is complete it will
Packit 549fdc
return @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE} .
Packit 549fdc
Packit 549fdc
Typically  @code{cert_type} should be @code{GNUTLS_CRT_X509} .
Packit 549fdc
Packit 549fdc
All values set are allocated and must be cleared using @code{gnutls_free()} ,
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_x509_crl_privkey_sign
Packit 549fdc
@anchor{gnutls_x509_crl_privkey_sign}
Packit 549fdc
@deftypefun {int} {gnutls_x509_crl_privkey_sign} (gnutls_x509_crl_t @var{crl}, gnutls_x509_crt_t @var{issuer}, gnutls_privkey_t @var{issuer_key}, gnutls_digest_algorithm_t @var{dig}, unsigned int @var{flags})
Packit 549fdc
@var{crl}: should contain a gnutls_x509_crl_t type
Packit 549fdc
Packit 549fdc
@var{issuer}: is the certificate of the certificate issuer
Packit 549fdc
Packit 549fdc
@var{issuer_key}: holds the issuer's private key
Packit 549fdc
Packit 549fdc
@var{dig}: The message digest to use. GNUTLS_DIG_SHA256 is the safe choice unless you know what you're doing.
Packit 549fdc
Packit 549fdc
@var{flags}: must be 0
Packit 549fdc
Packit 549fdc
This function will sign the CRL with the issuer's private key, and
Packit 549fdc
will copy the issuer's information into the CRL.
Packit 549fdc
Packit 549fdc
This must be the last step in a certificate CRL since all
Packit 549fdc
the previously set parameters are now signed.
Packit 549fdc
Packit 549fdc
A known limitation of this function is, that a newly-signed CRL will not
Packit 549fdc
be fully functional (e.g., for signature verification), until it
Packit 549fdc
is exported an re-imported.
Packit 549fdc
Packit 549fdc
After GnuTLS 3.6.1 the value of  @code{dig} may be @code{GNUTLS_DIG_UNKNOWN} ,
Packit 549fdc
and in that case, a suitable but reasonable for the key algorithm will be selected.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
Since 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_x509_crq_privkey_sign
Packit 549fdc
@anchor{gnutls_x509_crq_privkey_sign}
Packit 549fdc
@deftypefun {int} {gnutls_x509_crq_privkey_sign} (gnutls_x509_crq_t @var{crq}, gnutls_privkey_t @var{key}, gnutls_digest_algorithm_t @var{dig}, unsigned int @var{flags})
Packit 549fdc
@var{crq}: should contain a @code{gnutls_x509_crq_t}  type
Packit 549fdc
Packit 549fdc
@var{key}: holds a private key
Packit 549fdc
Packit 549fdc
@var{dig}: The message digest to use, i.e., @code{GNUTLS_DIG_SHA1} 
Packit 549fdc
Packit 549fdc
@var{flags}: must be 0
Packit 549fdc
Packit 549fdc
This function will sign the certificate request with a private key.
Packit 549fdc
This must be the same key as the one used in
Packit 549fdc
@code{gnutls_x509_crt_set_key()}  since a certificate request is self
Packit 549fdc
signed.
Packit 549fdc
Packit 549fdc
This must be the last step in a certificate request generation
Packit 549fdc
since all the previously set parameters are now signed.
Packit 549fdc
Packit 549fdc
A known limitation of this function is, that a newly-signed request will not
Packit 549fdc
be fully functional (e.g., for signature verification), until it
Packit 549fdc
is exported an re-imported.
Packit 549fdc
Packit 549fdc
After GnuTLS 3.6.1 the value of  @code{dig} may be @code{GNUTLS_DIG_UNKNOWN} ,
Packit 549fdc
and in that case, a suitable but reasonable for the key algorithm will be selected.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
Packit 549fdc
@code{GNUTLS_E_ASN1_VALUE_NOT_FOUND}  is returned if you didn't set all
Packit 549fdc
information in the certificate request (e.g., the version using
Packit 549fdc
@code{gnutls_x509_crq_set_version()} ).
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_x509_crq_set_pubkey
Packit 549fdc
@anchor{gnutls_x509_crq_set_pubkey}
Packit 549fdc
@deftypefun {int} {gnutls_x509_crq_set_pubkey} (gnutls_x509_crq_t @var{crq}, gnutls_pubkey_t @var{key})
Packit 549fdc
@var{crq}: should contain a @code{gnutls_x509_crq_t}  type
Packit 549fdc
Packit 549fdc
@var{key}: holds a public key
Packit 549fdc
Packit 549fdc
This function will set the public parameters from the given public
Packit 549fdc
key to the request. The  @code{key} can be deallocated after that.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_x509_crt_privkey_sign
Packit 549fdc
@anchor{gnutls_x509_crt_privkey_sign}
Packit 549fdc
@deftypefun {int} {gnutls_x509_crt_privkey_sign} (gnutls_x509_crt_t @var{crt}, gnutls_x509_crt_t @var{issuer}, gnutls_privkey_t @var{issuer_key}, gnutls_digest_algorithm_t @var{dig}, unsigned int @var{flags})
Packit 549fdc
@var{crt}: a certificate of type @code{gnutls_x509_crt_t} 
Packit 549fdc
Packit 549fdc
@var{issuer}: is the certificate of the certificate issuer
Packit 549fdc
Packit 549fdc
@var{issuer_key}: holds the issuer's private key
Packit 549fdc
Packit 549fdc
@var{dig}: The message digest to use, @code{GNUTLS_DIG_SHA256}  is a safe choice
Packit 549fdc
Packit 549fdc
@var{flags}: must be 0
Packit 549fdc
Packit 549fdc
This function will sign the certificate with the issuer's private key, and
Packit 549fdc
will copy the issuer's information into the certificate.
Packit 549fdc
Packit 549fdc
This must be the last step in a certificate generation since all
Packit 549fdc
the previously set parameters are now signed.
Packit 549fdc
Packit 549fdc
A known limitation of this function is, that a newly-signed certificate will not
Packit 549fdc
be fully functional (e.g., for signature verification), until it
Packit 549fdc
is exported an re-imported.
Packit 549fdc
Packit 549fdc
After GnuTLS 3.6.1 the value of  @code{dig} may be @code{GNUTLS_DIG_UNKNOWN} ,
Packit 549fdc
and in that case, a suitable but reasonable for the key algorithm will be selected.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_x509_crt_set_pubkey
Packit 549fdc
@anchor{gnutls_x509_crt_set_pubkey}
Packit 549fdc
@deftypefun {int} {gnutls_x509_crt_set_pubkey} (gnutls_x509_crt_t @var{crt}, gnutls_pubkey_t @var{key})
Packit 549fdc
@var{crt}: should contain a @code{gnutls_x509_crt_t}  type
Packit 549fdc
Packit 549fdc
@var{key}: holds a public key
Packit 549fdc
Packit 549fdc
This function will set the public parameters from the given public
Packit 549fdc
key to the certificate. The  @code{key} can be deallocated after that.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit 549fdc
negative error value.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.12.0
Packit 549fdc
@end deftypefun
Packit 549fdc