Next: DANE API, Previous: TPM API, Up: API reference [Contents][Index]
The following functions are to be used for abstract key handling. Their prototypes lie in gnutls/abstract.h.
res: is a gnutls_certificate_credentials_t
type.
names: is an array of DNS name of the certificate (NULL if none)
names_size: holds the size of the names list
pcert_list: contains a certificate list (path) for the specified private key
pcert_list_size: holds the size of the certificate list
key: is a gnutls_privkey_t
key
This function sets a certificate/private key pair in the
gnutls_certificate_credentials_t type. This function may be
called more than once, in case multiple keys/certificates exist for
the server. For clients that wants to send more than its own end
entity certificate (e.g., also an intermediate CA cert) then put
the certificate chain in pcert_list
.
Note that the pcert_list
and key
will become part of the credentials
structure and must not be deallocated. They will be automatically deallocated
when the res
type is deinitialized.
If that function fails to load the res
structure is at an undefined state, it must
not be reused to load other keys or certificates.
Returns: GNUTLS_E_SUCCESS
(0) on success, or a negative error code.
Since: 3.0
cred: is a gnutls_certificate_credentials_t
type.
func: is the callback function
This function sets a callback to be called in order to retrieve the certificate to be used in the handshake. The callback will take control only if a certificate is requested by the peer.
The callback’s function prototype is: int (*callback)(gnutls_session_t, const gnutls_datum_t* req_ca_dn, int nreqs, const gnutls_pk_algorithm_t* pk_algos, int pk_algos_length, gnutls_pcert_st** pcert, unsigned int *pcert_length, gnutls_privkey_t * pkey);
req_ca_dn
is only used in X.509 certificates.
Contains a list with the CA names that the server considers trusted.
This is a hint and typically the client should send a certificate that is signed
by one of these CAs. These names, when available, are DER encoded. To get a more
meaningful value use the function gnutls_x509_rdn_get()
.
pk_algos
contains a list with server’s acceptable signature algorithms.
The certificate returned should support the server’s given algorithms.
pcert
should contain a single certificate and public key or a list of them.
pcert_length
is the size of the previous list.
pkey
is the private key.
If the callback function is provided then gnutls will call it, in the handshake, after the certificate request message has been received. All the provided by the callback values will not be released or modified by gnutls.
In server side pk_algos and req_ca_dn are NULL.
The callback function should set the certificate list to be sent, and return 0 on success. If no certificate was selected then the number of certificates should be set to zero. The value (-1) indicates error and the handshake will be terminated. If both certificates are set in the credentials and a callback is available, the callback takes predence.
Since: 3.0
pcert: The structure to be deinitialized
This function will deinitialize a pcert structure.
Since: 3.0
pcert: The pcert structure.
crt: An initialized gnutls_openpgp_crt_t
.
Converts the given gnutls_pcert_t
type into a gnutls_openpgp_crt_t
.
This function only works if the type of pcert
is GNUTLS_CRT_OPENPGP
.
When successful, the value written to crt
must be freed with
gnutls_openpgp_crt_deinit()
when no longer needed.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.4.0
pcert: The pcert structure.
crt: An initialized gnutls_x509_crt_t
.
Converts the given gnutls_pcert_t
type into a gnutls_x509_crt_t
.
This function only works if the type of pcert
is GNUTLS_CRT_X509
.
When successful, the value written to crt
must be freed with
gnutls_x509_crt_deinit()
when no longer needed.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.4.0
pcert: The pcert structure
crt: The raw certificate to be imported
flags: zero for now
This convenience function will import the given certificate to a
gnutls_pcert_st
structure. The structure must be deinitialized
afterwards using gnutls_pcert_deinit()
;
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.0
pcert: The pcert structure
cert: The raw certificate to be imported
format: The format of the certificate
keyid: The key ID to use (NULL for the master key)
flags: zero for now
This convenience function will import the given certificate to a
gnutls_pcert_st
structure. The structure must be deinitialized
afterwards using gnutls_pcert_deinit()
;
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.0
pcert: The pcert structure
crt: The certificate to be imported
flags: zero for now
This convenience function will import the given certificate to a
gnutls_pcert_st
structure. The structure must be deinitialized
afterwards using gnutls_pcert_deinit()
;
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.0
pcert: The pcert structure
crt: The certificates to be imported
ncrt: The number of certificates
flags: zero or GNUTLS_X509_CRT_LIST_SORT
This convenience function will import the given certificate to a
gnutls_pcert_st
structure. The structure must be deinitialized
afterwards using gnutls_pcert_deinit()
;
In the case GNUTLS_X509_CRT_LIST_SORT
is specified and that
function cannot sort the list, GNUTLS_E_CERTIFICATE_LIST_UNSORTED
will be returned. Currently sorting can fail if the list size
exceeds an internal constraint (16).
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.4.0
pcert: The pcert structure
cert: The raw certificate to be imported
format: The format of the certificate
flags: zero for now
This convenience function will import the given certificate to a
gnutls_pcert_st
structure. The structure must be deinitialized
afterwards using gnutls_pcert_deinit()
;
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.0
pcerts: The structures to store the parsed certificate. Must not be initialized.
pcert_max: Initially must hold the maximum number of certs. It will be updated with the number of certs available.
data: The certificates.
format: One of DER or PEM.
flags: must be (0) or an OR’d sequence of gnutls_certificate_import_flags.
This function will convert the given PEM encoded certificate list
to the native gnutls_x509_crt_t format. The output will be stored
in certs
. They will be automatically initialized.
If the Certificate is PEM encoded it should have a header of "X509 CERTIFICATE", or "CERTIFICATE".
Returns: the number of certificates read or a negative error value.
Since: 3.0
key: Holds the key
flags: zero for now
ciphertext: holds the data to be decrypted
plaintext: will contain the decrypted data, allocated with gnutls_malloc()
This function will decrypt the given data using the algorithm supported by the private key.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: The key to be deinitialized
This function will deinitialize a private key structure.
Since: 2.12.0
key: Holds the public key
p: will hold the p
q: will hold the q
g: will hold the g
y: will hold the y
x: will hold the x
This function will export the DSA private key’s parameters found
in the given structure. The new parameters will be allocated using
gnutls_malloc()
and will be stored in the appropriate datum.
Returns: GNUTLS_E_SUCCESS
on success, otherwise a negative error code.
Since: 3.3.0
key: Holds the public key
curve: will hold the curve
x: will hold the x coordinate
y: will hold the y coordinate
k: will hold the private key
This function will export the ECC private key’s parameters found
in the given structure. The new parameters will be allocated using
gnutls_malloc()
and will be stored in the appropriate datum.
Returns: GNUTLS_E_SUCCESS
on success, otherwise a negative error code.
Since: 3.3.0
pkey: The private key
key: Location for the key to be exported.
Converts the given abstract private key to a gnutls_openpgp_privkey_t
type. The key must be of type GNUTLS_PRIVKEY_OPENPGP
. The key
returned in key
must be deinitialized with
gnutls_openpgp_privkey_deinit()
.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.4.0
pkey: The private key
key: Location for the key to be exported.
Converts the given abstract private key to a gnutls_pkcs11_privkey_t
type. The key must be of type GNUTLS_PRIVKEY_PKCS11
. The key
returned in key
must be deinitialized with
gnutls_pkcs11_privkey_deinit()
.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.4.0
key: Holds the certificate
m: will hold the modulus
e: will hold the public exponent
d: will hold the private exponent
p: will hold the first prime (p)
q: will hold the second prime (q)
u: will hold the coefficient
e1: will hold e1 = d mod (p-1)
e2: will hold e2 = d mod (q-1)
This function will export the RSA private key’s parameters found
in the given structure. The new parameters will be allocated using
gnutls_malloc()
and will be stored in the appropriate datum.
Returns: GNUTLS_E_SUCCESS
on success, otherwise a negative error code.
Since: 3.3.0
pkey: The private key
key: Location for the key to be exported.
Converts the given abstract private key to a gnutls_x509_privkey_t
type. The key must be of type GNUTLS_PRIVKEY_X509
. The key returned
in key
must be deinitialized with gnutls_x509_privkey_deinit()
.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.4.0
pkey: The private key
algo: is one of the algorithms in gnutls_pk_algorithm_t
.
bits: the size of the modulus
flags: unused for now. Must be 0.
This function will generate a random private key. Note that this function must be called on an empty private key.
Note that when generating an elliptic curve key, the curve
can be substituted in the place of the bits parameter using the
GNUTLS_CURVE_TO_BITS()
macro.
Do not set the number of bits directly, use gnutls_sec_param_to_pk_bits()
.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.3.0
key: should contain a gnutls_privkey_t
type
bits: If set will return the number of bits of the parameters (may be NULL)
This function will return the public key algorithm of a private key and if possible will return a number of bits that indicates the security parameter of the key.
Returns: a member of the gnutls_pk_algorithm_t
enumeration on
success, or a negative error code on error.
Since: 2.12.0
key: should contain a gnutls_privkey_t
type
This function will return the type of the private key. This is actually the type of the subsystem used to set this private key.
Returns: a member of the gnutls_privkey_type_t
enumeration on
success, or a negative error code on error.
Since: 2.12.0
key: The structure to store the parsed key
p: holds the p
q: holds the q
g: holds the g
y: holds the y
x: holds the x
This function will convert the given DSA raw parameters to the
native gnutls_privkey_t
format. The output will be stored
in key
.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
key: The key
curve: holds the curve
x: holds the x
y: holds the y
k: holds the k
This function will convert the given elliptic curve parameters to the
native gnutls_privkey_t
format. The output will be stored
in key
.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.0
pkey: The private key
pk: The public key algorithm
userdata: private data to be provided to the callbacks
sign_func: callback for signature operations
decrypt_func: callback for decryption operations
flags: Flags for the import
This function will associate the given callbacks with the
gnutls_privkey_t
type. At least one of the two callbacks
must be non-null.
See also gnutls_privkey_import_ext3()
.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.0
pkey: The private key
pk: The public key algorithm
userdata: private data to be provided to the callbacks
sign_fn: callback for signature operations
decrypt_fn: callback for decryption operations
deinit_fn: a deinitialization function
flags: Flags for the import
This function will associate the given callbacks with the
gnutls_privkey_t
type. At least one of the two callbacks
must be non-null. If a deinitialization function is provided
then flags is assumed to contain GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE
.
Note that the signing function is supposed to "raw" sign data, i.e.,
without any hashing or preprocessing. In case of RSA the DigestInfo
will be provided, and the signing function is expected to do the PKCS 1
1.5 padding and the exponentiation.
See also gnutls_privkey_import_ext3()
.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.1
pkey: The private key
userdata: private data to be provided to the callbacks
sign_fn: callback for signature operations
decrypt_fn: callback for decryption operations
deinit_fn: a deinitialization function
info_fn: returns info about the public key algorithm (should not be NULL
)
flags: Flags for the import
This function will associate the given callbacks with the
gnutls_privkey_t
type. At least one of the two callbacks
must be non-null. If a deinitialization function is provided
then flags is assumed to contain GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE
.
Note that the signing function is supposed to "raw" sign data, i.e.,
without any hashing or preprocessing. In case of RSA the DigestInfo
will be provided, and the signing function is expected to do the PKCS 1
1.5 padding and the exponentiation.
The info_fn
must provide information on the algorithms supported by
this private key, and should support the flags GNUTLS_PRIVKEY_INFO_PK_ALGO
and
GNUTLS_PRIVKEY_INFO_SIGN_ALGO
. It must return -1 on unknown flags.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.4.0
pkey: The private key
key: The private key to be imported
flags: Flags for the import
This function will import the given private key to the abstract
gnutls_privkey_t
type.
The gnutls_openpgp_privkey_t
object must not be deallocated
during the lifetime of this structure. The subkey set as
preferred will be used, or the master key otherwise.
flags
might be zero or one of GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE
and GNUTLS_PRIVKEY_IMPORT_COPY
.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 2.12.0
pkey: The private key
data: The private key data to be imported
format: The format of the private key
keyid: The key id to use (optional)
password: A password (optional)
This function will import the given private key to the abstract
gnutls_privkey_t
type.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.1.0
pkey: The private key
key: The private key to be imported
flags: Flags for the import
This function will import the given private key to the abstract
gnutls_privkey_t
type.
The gnutls_pkcs11_privkey_t
object must not be deallocated
during the lifetime of this structure.
flags
might be zero or one of GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE
and GNUTLS_PRIVKEY_IMPORT_COPY
.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: A key of type gnutls_pubkey_t
url: A PKCS 11 url
This function will import a PKCS 11 private key to a gnutls_private_key_t
type.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.1.0
key: The structure to store the parsed key
m: holds the modulus
e: holds the public exponent
d: holds the private exponent
p: holds the first prime (p)
q: holds the second prime (q)
u: holds the coefficient (optional)
e1: holds e1 = d mod (p-1) (optional)
e2: holds e2 = d mod (q-1) (optional)
This function will convert the given RSA raw parameters to the
native gnutls_privkey_t
format. The output will be stored in
key
.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
pkey: The private key
fdata: The TPM key to be imported
format: The format of the private key
srk_password: The password for the SRK key (optional)
key_password: A password for the key (optional)
flags: should be zero
This function will import the given private key to the abstract
gnutls_privkey_t
type.
With respect to passwords the same as in gnutls_privkey_import_tpm_url()
apply.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.1.0
pkey: The private key
url: The URL of the TPM key to be imported
srk_password: The password for the SRK key (optional)
key_password: A password for the key (optional)
flags: One of the GNUTLS_PRIVKEY_* flags
This function will import the given private key to the abstract
gnutls_privkey_t
type.
Note that unless GNUTLS_PRIVKEY_DISABLE_CALLBACKS
is specified, if incorrect (or NULL) passwords are given
the PKCS11 callback functions will be used to obtain the
correct passwords. Otherwise if the SRK password is wrong
GNUTLS_E_TPM_SRK_PASSWORD_ERROR
is returned and if the key password
is wrong or not provided then GNUTLS_E_TPM_KEY_PASSWORD_ERROR
is returned.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.1.0
key: A key of type gnutls_privkey_t
url: A PKCS 11 url
flags: should be zero
This function will import a PKCS11 or TPM URL as a
private key. The supported URL types can be checked
using gnutls_url_is_supported()
.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.1.0
pkey: The private key
key: The private key to be imported
flags: Flags for the import
This function will import the given private key to the abstract
gnutls_privkey_t
type.
The gnutls_x509_privkey_t
object must not be deallocated
during the lifetime of this structure.
flags
might be zero or one of GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE
and GNUTLS_PRIVKEY_IMPORT_COPY
.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 2.12.0
pkey: The private key
data: The private key data to be imported
format: The format of the private key
password: A password (optional)
flags: an ORed sequence of gnutls_pkcs_encrypt_flags_t
This function will import the given private key to the abstract
gnutls_privkey_t
type.
The supported formats are basic unencrypted key, PKCS8, PKCS12, and the openssl format.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.1.0
key: A pointer to the type to be initialized
This function will initialize a private key.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: A key of type gnutls_privkey_t
fn: the callback
userdata: data associated with the callback
This function will set a callback function to be used when required to access the object. This function overrides any other global PIN functions.
Note that this function must be called right after initialization to have effect.
Since: 3.1.0
signer: Holds the key
hash: should be a digest algorithm
flags: Zero or one of gnutls_privkey_flags_t
data: holds the data to be signed
signature: will contain the signature allocated with gnutls_malloc()
This function will sign the given data using a signature algorithm supported by the private key. Signature algorithms are always used together with a hash functions. Different hash functions may be used for the RSA algorithm, but only the SHA family for the DSA keys.
You may use gnutls_pubkey_get_preferred_hash_algorithm()
to determine
the hash algorithm.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 2.12.0
signer: Holds the signer’s key
hash_algo: The hash algorithm used
flags: Zero or one of gnutls_privkey_flags_t
hash_data: holds the data to be signed
signature: will contain newly allocated signature
This function will sign the given hashed data using a signature algorithm supported by the private key. Signature algorithms are always used together with a hash functions. Different hash functions may be used for the RSA algorithm, but only SHA-XXX for the DSA keys.
You may use gnutls_pubkey_get_preferred_hash_algorithm()
to determine
the hash algorithm.
Note that if GNUTLS_PRIVKEY_SIGN_FLAG_TLS1_RSA
flag is specified this function
will ignore hash_algo
and perform a raw PKCS1 signature.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: Holds the key
Checks the status of the private key token. This function
is an actual wrapper over gnutls_pkcs11_privkey_status()
, and
if the private key is a PKCS 11
token it will check whether
it is inserted or not.
Returns: this function will return non-zero if the token holding the private key is still available (inserted), and zero otherwise.
Since: 3.1.10
key: should contain a gnutls_privkey_t
type
This function will verify the private key parameters.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.3.0
key: The key to be deinitialized
This function will deinitialize a public key structure.
Since: 2.12.0
key: Holds the public key
flags: should be 0 for now
plaintext: The data to be encrypted
ciphertext: contains the encrypted data
This function will encrypt the given data, using the public key.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.0
key: Holds the certificate
format: the format of output params. One of PEM or DER.
output_data: will contain a certificate PEM or DER encoded
output_data_size: holds the size of output_data (and will be replaced by the actual size of parameters)
This function will export the public key to DER or PEM format. The contents of the exported data is the SubjectPublicKeyInfo X.509 structure.
If the buffer provided is not long enough to hold the output, then
*output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER
will
be returned.
If the structure is PEM encoded, it will have a header of "BEGIN CERTIFICATE".
Returns: In case of failure a negative error code will be returned, and 0 on success.
Since: 2.12.0
key: Holds the certificate
format: the format of output params. One of PEM or DER.
out: will contain a certificate PEM or DER encoded
This function will export the public key to DER or PEM format. The contents of the exported data is the SubjectPublicKeyInfo X.509 structure.
The output buffer will be allocated using gnutls_malloc()
.
If the structure is PEM encoded, it will have a header of "BEGIN CERTIFICATE".
Returns: In case of failure a negative error code will be returned, and 0 on success.
Since: 3.1.3
key: Holds the public key
p: will hold the p (may be NULL
)
q: will hold the q (may be NULL
)
g: will hold the g (may be NULL
)
y: will hold the y (may be NULL
)
This function will export the DSA public key’s parameters found in
the given certificate. The new parameters will be allocated using
gnutls_malloc()
and will be stored in the appropriate datum.
This function allows for NULL
parameters since 3.4.1.
Returns: GNUTLS_E_SUCCESS
on success, otherwise a negative error code.
Since: 3.3.0
key: Holds the public key
curve: will hold the curve (may be NULL
)
x: will hold x (may be NULL
)
y: will hold y (may be NULL
)
This function will export the ECC public key’s parameters found in
the given key. The new parameters will be allocated using
gnutls_malloc()
and will be stored in the appropriate datum.
This function allows for NULL
parameters since 3.4.1.
Returns: GNUTLS_E_SUCCESS
on success, otherwise a negative error code.
Since: 3.0
key: Holds the public key
parameters: DER encoding of an ANSI X9.62 parameters
ecpoint: DER encoding of ANSI X9.62 ECPoint
This function will export the ECC public key’s parameters found in
the given certificate. The new parameters will be allocated using
gnutls_malloc()
and will be stored in the appropriate datum.
Returns: GNUTLS_E_SUCCESS
on success, otherwise a negative error code.
Since: 3.3.0
key: Holds the certificate
m: will hold the modulus (may be NULL
)
e: will hold the public exponent (may be NULL
)
This function will export the RSA public key’s parameters found in
the given structure. The new parameters will be allocated using
gnutls_malloc()
and will be stored in the appropriate datum.
This function allows for NULL
parameters since 3.4.1.
Returns: GNUTLS_E_SUCCESS
on success, otherwise a negative error code.
Since: 3.3.0
key: Holds the public key
flags: should be one of the flags from gnutls_keyid_flags_t
output_data: will contain the key ID
output_data_size: holds the size of output_data (and will be replaced by the actual size of parameters)
This function will return a unique ID that depends on the public key parameters. This ID can be used in checking whether a certificate corresponds to the given public key.
If the buffer provided is not long enough to hold the output, then
*output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER
will
be returned. The output will normally be a SHA-1 hash output,
which is 20 bytes.
Returns: In case of failure a negative error code will be returned, and 0 on success.
Since: 2.12.0
key: should contain a gnutls_pubkey_t
type
usage: If set will return the number of bits of the parameters (may be NULL)
This function will return the key usage of the public key.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: Holds the public key
flags: should be 0 or GNUTLS_PUBKEY_GET_OPENPGP_FINGERPRINT
output_data: will contain the key ID
output_data_size: holds the size of output_data (and will be replaced by the actual size of parameters)
subkey: Will be non zero if the key ID corresponds to a subkey
This function returns the OpenPGP key ID of the corresponding key. The key is a unique ID that depends on the public key parameters.
If the flag GNUTLS_PUBKEY_GET_OPENPGP_FINGERPRINT
is specified
this function returns the fingerprint of the master key.
If the buffer provided is not long enough to hold the output, then
*output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER
will
be returned. The output is GNUTLS_OPENPGP_KEYID_SIZE
bytes long.
Returns: In case of failure a negative error code will be returned, and 0 on success.
Since: 3.0
key: should contain a gnutls_pubkey_t
type
bits: If set will return the number of bits of the parameters (may be NULL)
This function will return the public key algorithm of a public key and if possible will return a number of bits that indicates the security parameter of the key.
Returns: a member of the gnutls_pk_algorithm_t
enumeration on
success, or a negative error code on error.
Since: 2.12.0
key: Holds the certificate
hash: The result of the call with the hash algorithm used for signature
mand: If non zero it means that the algorithm MUST use this hash. May be NULL.
This function will read the certifcate and return the appropriate digest algorithm to use for signing with this certificate. Some certificates (i.e. DSA might not be able to sign without the preferred algorithm).
To get the signature algorithm instead of just the hash use gnutls_pk_to_sign()
with the algorithm of the certificate/key and the provided hash
.
Returns: the 0 if the hash algorithm is found. A negative error code is returned on error.
Since: 2.12.0
key: The public key.
data: The DER or PEM encoded certificate.
format: One of DER or PEM
This function will import the provided public key in
a SubjectPublicKeyInfo X.509 structure to a native
gnutls_pubkey_t
type. The output will be stored
in key
. If the public key is PEM encoded it should have a header
of "PUBLIC KEY".
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: The structure to store the parsed key
p: holds the p
q: holds the q
g: holds the g
y: holds the y
This function will convert the given DSA raw parameters to the
native gnutls_pubkey_t
format. The output will be stored
in key
.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: The structure to store the parsed key
curve: holds the curve
x: holds the x
y: holds the y
This function will convert the given elliptic curve parameters to a
gnutls_pubkey_t
. The output will be stored in key
.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.0
key: The structure to store the parsed key
parameters: DER encoding of an ANSI X9.62 parameters
ecpoint: DER encoding of ANSI X9.62 ECPoint
This function will convert the given elliptic curve parameters to a
gnutls_pubkey_t
. The output will be stored in key
.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.0
key: The public key
crt: The certificate to be imported
flags: should be zero
Imports a public key from an openpgp key. This function will import
the given public key to the abstract gnutls_pubkey_t
type. The subkey set as preferred will be imported or the
master key otherwise.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 2.12.0
pkey: The public key
data: The public key data to be imported
format: The format of the public key
keyid: The key id to use (optional)
flags: Should be zero
This function will import the given public key to the abstract
gnutls_pubkey_t
type.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.1.3
key: The public key
obj: The parameters to be imported
flags: should be zero
Imports a public key from a pkcs11 key. This function will import
the given public key to the abstract gnutls_pubkey_t
type.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: The public key
pkey: The private key
usage: GNUTLS_KEY_* key usage flags.
flags: should be zero
Imports the public key from a private. This function will import
the given public key to the abstract gnutls_pubkey_t
type.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: The key
m: holds the modulus
e: holds the public exponent
This function will replace the parameters in the given structure. The new parameters should be stored in the appropriate gnutls_datum.
Returns: GNUTLS_E_SUCCESS
on success, or an negative error code.
Since: 2.12.0
pkey: The public key
fdata: The TPM key to be imported
format: The format of the private key
srk_password: The password for the SRK key (optional)
flags: One of the GNUTLS_PUBKEY_* flags
This function will import the public key from the provided TPM key structure.
With respect to passwords the same as in
gnutls_pubkey_import_tpm_url()
apply.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.1.0
pkey: The public key
url: The URL of the TPM key to be imported
srk_password: The password for the SRK key (optional)
flags: should be zero
This function will import the given private key to the abstract
gnutls_privkey_t
type.
Note that unless GNUTLS_PUBKEY_DISABLE_CALLBACKS
is specified, if incorrect (or NULL) passwords are given
the PKCS11 callback functions will be used to obtain the
correct passwords. Otherwise if the SRK password is wrong
GNUTLS_E_TPM_SRK_PASSWORD_ERROR
is returned.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.1.0
key: A key of type gnutls_pubkey_t
url: A PKCS 11 url
flags: One of GNUTLS_PKCS11_OBJ_* flags
This function will import a public key from the provided URL.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.1.0
key: The public key
crt: The certificate to be imported
flags: should be zero
This function will import the given public key to the abstract
gnutls_pubkey_t
type.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: The public key
crq: The certificate to be imported
flags: should be zero
This function will import the given public key to the abstract
gnutls_pubkey_t
type.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.1.5
pkey: The public key
data: The public key data to be imported
format: The format of the public key
flags: should be zero
This function will import the given public key to the abstract
gnutls_pubkey_t
type.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.1.3
key: A pointer to the type to be initialized
This function will initialize a public key.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 2.12.0
pubkey: The data to be printed
format: Indicate the format to use
out: Newly allocated datum with null terminated string.
This function will pretty print public key information, suitable for display to a human.
Only GNUTLS_CRT_PRINT_FULL
and GNUTLS_CRT_PRINT_FULL_NUMBERS
are implemented.
The output out
needs to be deallocated using gnutls_free()
.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.1.5
key: a certificate of type gnutls_x509_crt_t
usage: an ORed sequence of the GNUTLS_KEY_* elements.
This function will set the key usage flags of the public key. This is only useful if the key is to be exported to a certificate or certificate request.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: A key of type gnutls_pubkey_t
fn: the callback
userdata: data associated with the callback
This function will set a callback function to be used when required to access the object. This function overrides any other global PIN functions.
Note that this function must be called right after initialization to have effect.
Since: 3.1.0
pubkey: Holds the public key
algo: The signature algorithm used
flags: Zero or an OR list of gnutls_certificate_verify_flags
data: holds the signed data
signature: contains the signature
This function will verify the given signed data, using the parameters from the certificate.
Returns: In case of a verification failure GNUTLS_E_PK_SIG_VERIFY_FAILED
is returned, and zero or positive code on success. For known to be insecure
signatures this function will return GNUTLS_E_INSUFFICIENT_SECURITY
unless
the flag GNUTLS_VERIFY_ALLOW_BROKEN
is specified.
Since: 3.0
key: Holds the public key
algo: The signature algorithm used
flags: Zero or an OR list of gnutls_certificate_verify_flags
hash: holds the hash digest to be verified
signature: contains the signature
This function will verify the given signed digest, using the
parameters from the public key. Note that unlike gnutls_privkey_sign_hash()
,
this function accepts a signature algorithm instead of a digest algorithm.
You can use gnutls_pk_to_sign()
to get the appropriate value.
Returns: In case of a verification failure GNUTLS_E_PK_SIG_VERIFY_FAILED
is returned, and zero or positive code on success.
Since: 3.0
key: should contain a gnutls_pubkey_t
type
This function will verify the private key parameters.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.3.0
st: A gnutls_custom_url_st
structure
Register a custom URL. This will affect the following functions:
gnutls_url_is_supported()
, gnutls_privkey_import_url()
,
gnutls_pubkey_import_url, gnutls_x509_crt_import_url()
and all functions that depend on
them, e.g., gnutls_certificate_set_x509_key_file2()
.
The provided structure and callback functions must be valid throughout
the lifetime of the process. The registration of an existing URL type
will fail with GNUTLS_E_INVALID_REQUEST
.
This function is not thread safe.
Returns: returns zero if the given structure was imported or a negative value otherwise.
Since: 3.4.0
crt: the certificate to be added
privkey: the key to be added
label: the friendly name to describe the key
cert_url: if non-NULL it will contain an allocated value with the certificate URL
key_url: if non-NULL it will contain an allocated value with the key URL
This function will added the given key and certificate pair, to the system list.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.4.0
cert_url: the URL of the certificate
key_url: the URL of the key
This function will delete the key and certificate pair.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.4.0
iter: an iterator of system keys
This function will deinitialize the iterator.
Since: 3.4.0
iter: an iterator of the system keys (must be set to NULL
initially)
cert_type: A value of gnutls_certificate_type_t which indicates the type of certificate to look for
cert_url: The certificate URL of the pair (may be NULL
)
key_url: The key URL of the pair (may be NULL
)
label: The friendly name (if any) of the pair (may be NULL
)
der: if non-NULL the DER data of the certificate
flags: should be zero
This function will return on each call a certificate
and key pair URLs, as well as a label associated with them,
and the DER-encoded certificate. When the iteration is complete it will
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE
.
Typically cert_type
should be GNUTLS_CRT_X509
.
All values set are allocated and must be cleared using gnutls_free()
,
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 3.4.0
crl: should contain a gnutls_x509_crl_t type
issuer: is the certificate of the certificate issuer
issuer_key: holds the issuer’s private key
dig: The message digest to use. GNUTLS_DIG_SHA1 is the safe choice unless you know what you’re doing.
flags: must be 0
This function will sign the CRL with the issuer’s private key, and will copy the issuer’s information into the CRL.
This must be the last step in a certificate CRL since all the previously set parameters are now signed.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since 2.12.0
crq: should contain a gnutls_x509_crq_t
type
key: holds a private key
dig: The message digest to use, i.e., GNUTLS_DIG_SHA1
flags: must be 0
This function will sign the certificate request with a private key.
This must be the same key as the one used in
gnutls_x509_crt_set_key()
since a certificate request is self
signed.
This must be the last step in a certificate request generation since all the previously set parameters are now signed.
Returns: GNUTLS_E_SUCCESS
on success, otherwise a negative error code.
GNUTLS_E_ASN1_VALUE_NOT_FOUND
is returned if you didn’t set all
information in the certificate request (e.g., the version using
gnutls_x509_crq_set_version()
).
Since: 2.12.0
crq: should contain a gnutls_x509_crq_t
type
key: holds a public key
This function will set the public parameters from the given public key to the request.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 2.12.0
crt: a certificate of type gnutls_x509_crt_t
issuer: is the certificate of the certificate issuer
issuer_key: holds the issuer’s private key
dig: The message digest to use, GNUTLS_DIG_SHA1
is a safe choice
flags: must be 0
This function will sign the certificate with the issuer’s private key, and will copy the issuer’s information into the certificate.
This must be the last step in a certificate generation since all the previously set parameters are now signed.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
crt: should contain a gnutls_x509_crt_t
type
key: holds a public key
This function will set the public parameters from the given public key to the request.
Returns: On success, GNUTLS_E_SUCCESS
(0) is returned, otherwise a
negative error value.
Since: 2.12.0
Next: DANE API, Previous: TPM API, Up: API reference [Contents][Index]