Blame doc/pkcs12-api.texi

Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_bag_decrypt
Packit Service 4684c1
@anchor{gnutls_pkcs12_bag_decrypt}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_bag_decrypt} (gnutls_pkcs12_bag_t @var{bag}, const char * @var{pass})
Packit Service 4684c1
@var{bag}: The bag
Packit Service 4684c1
Packit Service 4684c1
@var{pass}: The password used for encryption, must be ASCII.
Packit Service 4684c1
Packit Service 4684c1
This function will decrypt the given encrypted bag and return 0 on
Packit Service 4684c1
success.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned,
Packit Service 4684c1
otherwise a negative error code is returned.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_bag_deinit
Packit Service 4684c1
@anchor{gnutls_pkcs12_bag_deinit}
Packit Service 4684c1
@deftypefun {void} {gnutls_pkcs12_bag_deinit} (gnutls_pkcs12_bag_t @var{bag})
Packit Service 4684c1
@var{bag}: A pointer to the type to be initialized
Packit Service 4684c1
Packit Service 4684c1
This function will deinitialize a PKCS12 Bag structure.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_bag_enc_info
Packit Service 4684c1
@anchor{gnutls_pkcs12_bag_enc_info}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_bag_enc_info} (gnutls_pkcs12_bag_t @var{bag}, unsigned int * @var{schema}, unsigned int * @var{cipher}, void * @var{salt}, unsigned int * @var{salt_size}, unsigned int * @var{iter_count}, char ** @var{oid})
Packit Service 4684c1
@var{bag}: The bag
Packit Service 4684c1
Packit Service 4684c1
@var{schema}: indicate the schema as one of @code{gnutls_pkcs_encrypt_flags_t} 
Packit Service 4684c1
Packit Service 4684c1
@var{cipher}: the cipher used as @code{gnutls_cipher_algorithm_t} 
Packit Service 4684c1
Packit Service 4684c1
@var{salt}: PBKDF2 salt (if non-NULL then  @code{salt_size} initially holds its size)
Packit Service 4684c1
Packit Service 4684c1
@var{salt_size}: PBKDF2 salt size
Packit Service 4684c1
Packit Service 4684c1
@var{iter_count}: PBKDF2 iteration count
Packit Service 4684c1
Packit Service 4684c1
@var{oid}: if non-NULL it will contain an allocated null-terminated variable with the OID
Packit Service 4684c1
Packit Service 4684c1
This function will provide information on the encryption algorithms used
Packit Service 4684c1
in an encrypted bag. If the structure algorithms
Packit Service 4684c1
are unknown the code @code{GNUTLS_E_UNKNOWN_CIPHER_TYPE}  will be returned,
Packit Service 4684c1
and only  @code{oid} , will be set. That is,  @code{oid} will be set on encrypted bags
Packit Service 4684c1
whether supported or not. It must be deinitialized using @code{gnutls_free()} .
Packit Service 4684c1
The other variables are only set on supported structures.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} @code{GNUTLS_E_INVALID_REQUEST}  if the provided bag isn't encrypted,
Packit Service 4684c1
@code{GNUTLS_E_UNKNOWN_CIPHER_TYPE}  if the structure's encryption isn't supported, or
Packit Service 4684c1
another negative error code in case of a failure. Zero on success.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_bag_encrypt
Packit Service 4684c1
@anchor{gnutls_pkcs12_bag_encrypt}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_bag_encrypt} (gnutls_pkcs12_bag_t @var{bag}, const char * @var{pass}, unsigned int @var{flags})
Packit Service 4684c1
@var{bag}: The bag
Packit Service 4684c1
Packit Service 4684c1
@var{pass}: The password used for encryption, must be ASCII
Packit Service 4684c1
Packit Service 4684c1
@var{flags}: should be one of @code{gnutls_pkcs_encrypt_flags_t}  elements bitwise or'd
Packit Service 4684c1
Packit Service 4684c1
This function will encrypt the given bag.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned,
Packit Service 4684c1
otherwise a negative error code is returned.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_bag_get_count
Packit Service 4684c1
@anchor{gnutls_pkcs12_bag_get_count}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_bag_get_count} (gnutls_pkcs12_bag_t @var{bag})
Packit Service 4684c1
@var{bag}: The bag
Packit Service 4684c1
Packit Service 4684c1
This function will return the number of the elements within the bag.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} Number of elements in bag, or an negative error code on
Packit Service 4684c1
error.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_bag_get_data
Packit Service 4684c1
@anchor{gnutls_pkcs12_bag_get_data}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_bag_get_data} (gnutls_pkcs12_bag_t @var{bag}, unsigned @var{indx}, gnutls_datum_t * @var{data})
Packit Service 4684c1
@var{bag}: The bag
Packit Service 4684c1
Packit Service 4684c1
@var{indx}: The element of the bag to get the data from
Packit Service 4684c1
Packit Service 4684c1
@var{data}: where the bag's data will be. Should be treated as constant.
Packit Service 4684c1
Packit Service 4684c1
This function will return the bag's data. The data is a constant
Packit Service 4684c1
that is stored into the bag.  Should not be accessed after the bag
Packit Service 4684c1
is deleted.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit Service 4684c1
negative error value.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_bag_get_friendly_name
Packit Service 4684c1
@anchor{gnutls_pkcs12_bag_get_friendly_name}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_bag_get_friendly_name} (gnutls_pkcs12_bag_t @var{bag}, unsigned @var{indx}, char ** @var{name})
Packit Service 4684c1
@var{bag}: The bag
Packit Service 4684c1
Packit Service 4684c1
@var{indx}: The bag's element to add the id
Packit Service 4684c1
Packit Service 4684c1
@var{name}: will hold a pointer to the name (to be treated as const)
Packit Service 4684c1
Packit Service 4684c1
This function will return the friendly name, of the specified bag
Packit Service 4684c1
element.  The key ID is usually used to distinguish the local
Packit Service 4684c1
private key and the certificate pair.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit Service 4684c1
negative error value. or a negative error code on error.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_bag_get_key_id
Packit Service 4684c1
@anchor{gnutls_pkcs12_bag_get_key_id}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_bag_get_key_id} (gnutls_pkcs12_bag_t @var{bag}, unsigned @var{indx}, gnutls_datum_t * @var{id})
Packit Service 4684c1
@var{bag}: The bag
Packit Service 4684c1
Packit Service 4684c1
@var{indx}: The bag's element to add the id
Packit Service 4684c1
Packit Service 4684c1
@var{id}: where the ID will be copied (to be treated as const)
Packit Service 4684c1
Packit Service 4684c1
This function will return the key ID, of the specified bag element.
Packit Service 4684c1
The key ID is usually used to distinguish the local private key and
Packit Service 4684c1
the certificate pair.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit Service 4684c1
negative error value. or a negative error code on error.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_bag_get_type
Packit Service 4684c1
@anchor{gnutls_pkcs12_bag_get_type}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_bag_get_type} (gnutls_pkcs12_bag_t @var{bag}, unsigned @var{indx})
Packit Service 4684c1
@var{bag}: The bag
Packit Service 4684c1
Packit Service 4684c1
@var{indx}: The element of the bag to get the type
Packit Service 4684c1
Packit Service 4684c1
This function will return the bag's type.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} On error a negative error value or one of the @code{gnutls_pkcs12_bag_type_t}  enumerations.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_bag_init
Packit Service 4684c1
@anchor{gnutls_pkcs12_bag_init}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_bag_init} (gnutls_pkcs12_bag_t * @var{bag})
Packit Service 4684c1
@var{bag}: A pointer to the type to be initialized
Packit Service 4684c1
Packit Service 4684c1
This function will initialize a PKCS12 bag structure. PKCS12 Bags
Packit Service 4684c1
usually contain private keys, lists of X.509 Certificates and X.509
Packit Service 4684c1
Certificate revocation lists.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit Service 4684c1
negative error value.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_bag_set_crl
Packit Service 4684c1
@anchor{gnutls_pkcs12_bag_set_crl}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_bag_set_crl} (gnutls_pkcs12_bag_t @var{bag}, gnutls_x509_crl_t @var{crl})
Packit Service 4684c1
@var{bag}: The bag
Packit Service 4684c1
Packit Service 4684c1
@var{crl}: the CRL to be copied.
Packit Service 4684c1
Packit Service 4684c1
This function will insert the given CRL into the
Packit Service 4684c1
bag. This is just a wrapper over @code{gnutls_pkcs12_bag_set_data()} .
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} the index of the added bag on success, or a negative error code
Packit Service 4684c1
on failure.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_bag_set_crt
Packit Service 4684c1
@anchor{gnutls_pkcs12_bag_set_crt}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_bag_set_crt} (gnutls_pkcs12_bag_t @var{bag}, gnutls_x509_crt_t @var{crt})
Packit Service 4684c1
@var{bag}: The bag
Packit Service 4684c1
Packit Service 4684c1
@var{crt}: the certificate to be copied.
Packit Service 4684c1
Packit Service 4684c1
This function will insert the given certificate into the
Packit Service 4684c1
bag. This is just a wrapper over @code{gnutls_pkcs12_bag_set_data()} .
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} the index of the added bag on success, or a negative
Packit Service 4684c1
value on failure.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_bag_set_data
Packit Service 4684c1
@anchor{gnutls_pkcs12_bag_set_data}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_bag_set_data} (gnutls_pkcs12_bag_t @var{bag}, gnutls_pkcs12_bag_type_t @var{type}, const gnutls_datum_t * @var{data})
Packit Service 4684c1
@var{bag}: The bag
Packit Service 4684c1
Packit Service 4684c1
@var{type}: The data's type
Packit Service 4684c1
Packit Service 4684c1
@var{data}: the data to be copied.
Packit Service 4684c1
Packit Service 4684c1
This function will insert the given data of the given type into
Packit Service 4684c1
the bag.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} the index of the added bag on success, or a negative
Packit Service 4684c1
value on error.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_bag_set_friendly_name
Packit Service 4684c1
@anchor{gnutls_pkcs12_bag_set_friendly_name}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_bag_set_friendly_name} (gnutls_pkcs12_bag_t @var{bag}, unsigned @var{indx}, const char * @var{name})
Packit Service 4684c1
@var{bag}: The bag
Packit Service 4684c1
Packit Service 4684c1
@var{indx}: The bag's element to add the id
Packit Service 4684c1
Packit Service 4684c1
@var{name}: the name
Packit Service 4684c1
Packit Service 4684c1
This function will add the given key friendly name, to the
Packit Service 4684c1
specified, by the index, bag element. The name will be encoded as
Packit Service 4684c1
a 'Friendly name' bag attribute, which is usually used to set a
Packit Service 4684c1
user name to the local private key and the certificate pair.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit Service 4684c1
negative error value. or a negative error code on error.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_bag_set_key_id
Packit Service 4684c1
@anchor{gnutls_pkcs12_bag_set_key_id}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_bag_set_key_id} (gnutls_pkcs12_bag_t @var{bag}, unsigned @var{indx}, const gnutls_datum_t * @var{id})
Packit Service 4684c1
@var{bag}: The bag
Packit Service 4684c1
Packit Service 4684c1
@var{indx}: The bag's element to add the id
Packit Service 4684c1
Packit Service 4684c1
@var{id}: the ID
Packit Service 4684c1
Packit Service 4684c1
This function will add the given key ID, to the specified, by the
Packit Service 4684c1
index, bag element. The key ID will be encoded as a 'Local key
Packit Service 4684c1
identifier' bag attribute, which is usually used to distinguish
Packit Service 4684c1
the local private key and the certificate pair.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit Service 4684c1
negative error value. or a negative error code on error.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_bag_set_privkey
Packit Service 4684c1
@anchor{gnutls_pkcs12_bag_set_privkey}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_bag_set_privkey} (gnutls_pkcs12_bag_t @var{bag}, gnutls_x509_privkey_t @var{privkey}, const char * @var{password}, unsigned @var{flags})
Packit Service 4684c1
@var{bag}: The bag
Packit Service 4684c1
Packit Service 4684c1
@var{privkey}: the private key to be copied.
Packit Service 4684c1
Packit Service 4684c1
@var{password}: the password to protect the key with (may be @code{NULL} )
Packit Service 4684c1
Packit Service 4684c1
@var{flags}: should be one of @code{gnutls_pkcs_encrypt_flags_t}  elements bitwise or'd
Packit Service 4684c1
Packit Service 4684c1
This function will insert the given private key into the
Packit Service 4684c1
bag. This is just a wrapper over @code{gnutls_pkcs12_bag_set_data()} .
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} the index of the added bag on success, or a negative
Packit Service 4684c1
value on failure.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_deinit
Packit Service 4684c1
@anchor{gnutls_pkcs12_deinit}
Packit Service 4684c1
@deftypefun {void} {gnutls_pkcs12_deinit} (gnutls_pkcs12_t @var{pkcs12})
Packit Service 4684c1
@var{pkcs12}: The type to be initialized
Packit Service 4684c1
Packit Service 4684c1
This function will deinitialize a PKCS12 type.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_export
Packit Service 4684c1
@anchor{gnutls_pkcs12_export}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_export} (gnutls_pkcs12_t @var{pkcs12}, gnutls_x509_crt_fmt_t @var{format}, void * @var{output_data}, size_t * @var{output_data_size})
Packit Service 4684c1
@var{pkcs12}: A pkcs12 type
Packit Service 4684c1
Packit Service 4684c1
@var{format}: the format of output params. One of PEM or DER.
Packit Service 4684c1
Packit Service 4684c1
@var{output_data}: will contain a structure PEM or DER encoded
Packit Service 4684c1
Packit Service 4684c1
@var{output_data_size}: holds the size of output_data (and will be
Packit Service 4684c1
replaced by the actual size of parameters)
Packit Service 4684c1
Packit Service 4684c1
This function will export the pkcs12 structure to DER or PEM format.
Packit Service 4684c1
Packit Service 4684c1
If the buffer provided is not long enough to hold the output, then
Packit Service 4684c1
*output_data_size will be updated and GNUTLS_E_SHORT_MEMORY_BUFFER
Packit Service 4684c1
will be returned.
Packit Service 4684c1
Packit Service 4684c1
If the structure is PEM encoded, it will have a header
Packit Service 4684c1
of "BEGIN PKCS12".
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} In case of failure a negative error code will be
Packit Service 4684c1
returned, and 0 on success.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_export2
Packit Service 4684c1
@anchor{gnutls_pkcs12_export2}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_export2} (gnutls_pkcs12_t @var{pkcs12}, gnutls_x509_crt_fmt_t @var{format}, gnutls_datum_t * @var{out})
Packit Service 4684c1
@var{pkcs12}: A pkcs12 type
Packit Service 4684c1
Packit Service 4684c1
@var{format}: the format of output params. One of PEM or DER.
Packit Service 4684c1
Packit Service 4684c1
@var{out}: will contain a structure PEM or DER encoded
Packit Service 4684c1
Packit Service 4684c1
This function will export the pkcs12 structure to DER or PEM format.
Packit Service 4684c1
Packit Service 4684c1
The output buffer is allocated using @code{gnutls_malloc()} .
Packit Service 4684c1
Packit Service 4684c1
If the structure is PEM encoded, it will have a header
Packit Service 4684c1
of "BEGIN PKCS12".
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} In case of failure a negative error code will be
Packit Service 4684c1
returned, and 0 on success.
Packit Service 4684c1
Packit Service 4684c1
@strong{Since:} 3.1.3
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_generate_mac
Packit Service 4684c1
@anchor{gnutls_pkcs12_generate_mac}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_generate_mac} (gnutls_pkcs12_t @var{pkcs12}, const char * @var{pass})
Packit Service 4684c1
@var{pkcs12}: A pkcs12 type
Packit Service 4684c1
Packit Service 4684c1
@var{pass}: The password for the MAC
Packit Service 4684c1
Packit Service 4684c1
This function will generate a MAC for the PKCS12 structure.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit Service 4684c1
negative error value.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_generate_mac2
Packit Service 4684c1
@anchor{gnutls_pkcs12_generate_mac2}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_generate_mac2} (gnutls_pkcs12_t @var{pkcs12}, gnutls_mac_algorithm_t @var{mac}, const char * @var{pass})
Packit Service 4684c1
@var{pkcs12}: A pkcs12 type
Packit Service 4684c1
Packit Service 4684c1
@var{mac}: the MAC algorithm to use
Packit Service 4684c1
Packit Service 4684c1
@var{pass}: The password for the MAC
Packit Service 4684c1
Packit Service 4684c1
This function will generate a MAC for the PKCS12 structure.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit Service 4684c1
negative error value.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_get_bag
Packit Service 4684c1
@anchor{gnutls_pkcs12_get_bag}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_get_bag} (gnutls_pkcs12_t @var{pkcs12}, int @var{indx}, gnutls_pkcs12_bag_t @var{bag})
Packit Service 4684c1
@var{pkcs12}: A pkcs12 type
Packit Service 4684c1
Packit Service 4684c1
@var{indx}: contains the index of the bag to extract
Packit Service 4684c1
Packit Service 4684c1
@var{bag}: An initialized bag, where the contents of the bag will be copied
Packit Service 4684c1
Packit Service 4684c1
This function will return a Bag from the PKCS12 structure.
Packit Service 4684c1
Packit Service 4684c1
After the last Bag has been read
Packit Service 4684c1
@code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE}  will be returned.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit Service 4684c1
negative error value.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_import
Packit Service 4684c1
@anchor{gnutls_pkcs12_import}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_import} (gnutls_pkcs12_t @var{pkcs12}, const gnutls_datum_t * @var{data}, gnutls_x509_crt_fmt_t @var{format}, unsigned int @var{flags})
Packit Service 4684c1
@var{pkcs12}: The data to store the parsed PKCS12.
Packit Service 4684c1
Packit Service 4684c1
@var{data}: The DER or PEM encoded PKCS12.
Packit Service 4684c1
Packit Service 4684c1
@var{format}: One of DER or PEM
Packit Service 4684c1
Packit Service 4684c1
@var{flags}: an ORed sequence of gnutls_privkey_pkcs8_flags
Packit Service 4684c1
Packit Service 4684c1
This function will convert the given DER or PEM encoded PKCS12
Packit Service 4684c1
to the native gnutls_pkcs12_t format. The output will be stored in 'pkcs12'.
Packit Service 4684c1
Packit Service 4684c1
If the PKCS12 is PEM encoded it should have a header of "PKCS12".
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit Service 4684c1
negative error value.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_init
Packit Service 4684c1
@anchor{gnutls_pkcs12_init}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_init} (gnutls_pkcs12_t * @var{pkcs12})
Packit Service 4684c1
@var{pkcs12}: A pointer to the type to be initialized
Packit Service 4684c1
Packit Service 4684c1
This function will initialize a PKCS12 type. PKCS12 structures
Packit Service 4684c1
usually contain lists of X.509 Certificates and X.509 Certificate
Packit Service 4684c1
revocation lists.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit Service 4684c1
negative error value.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_mac_info
Packit Service 4684c1
@anchor{gnutls_pkcs12_mac_info}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_mac_info} (gnutls_pkcs12_t @var{pkcs12}, unsigned int * @var{mac}, void * @var{salt}, unsigned int * @var{salt_size}, unsigned int * @var{iter_count}, char ** @var{oid})
Packit Service 4684c1
@var{pkcs12}: A pkcs12 type
Packit Service 4684c1
Packit Service 4684c1
@var{mac}: the MAC algorithm used as @code{gnutls_mac_algorithm_t} 
Packit Service 4684c1
Packit Service 4684c1
@var{salt}: the salt used for string to key (if non-NULL then  @code{salt_size} initially holds its size)
Packit Service 4684c1
Packit Service 4684c1
@var{salt_size}: string to key salt size
Packit Service 4684c1
Packit Service 4684c1
@var{iter_count}: string to key iteration count
Packit Service 4684c1
Packit Service 4684c1
@var{oid}: if non-NULL it will contain an allocated null-terminated variable with the OID
Packit Service 4684c1
Packit Service 4684c1
This function will provide information on the MAC algorithm used
Packit Service 4684c1
in a PKCS @code{12}  structure. If the structure algorithms
Packit Service 4684c1
are unknown the code @code{GNUTLS_E_UNKNOWN_HASH_ALGORITHM}  will be returned,
Packit Service 4684c1
and only  @code{oid} , will be set. That is,  @code{oid} will be set on structures
Packit Service 4684c1
with a MAC whether supported or not. It must be deinitialized using @code{gnutls_free()} .
Packit Service 4684c1
The other variables are only set on supported structures.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} @code{GNUTLS_E_INVALID_REQUEST}  if the provided structure doesn't contain a MAC,
Packit Service 4684c1
@code{GNUTLS_E_UNKNOWN_HASH_ALGORITHM}  if the structure's MAC isn't supported, or
Packit Service 4684c1
another negative error code in case of a failure. Zero on success.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_set_bag
Packit Service 4684c1
@anchor{gnutls_pkcs12_set_bag}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_set_bag} (gnutls_pkcs12_t @var{pkcs12}, gnutls_pkcs12_bag_t @var{bag})
Packit Service 4684c1
@var{pkcs12}: should contain a gnutls_pkcs12_t type
Packit Service 4684c1
Packit Service 4684c1
@var{bag}: An initialized bag
Packit Service 4684c1
Packit Service 4684c1
This function will insert a Bag into the PKCS12 structure.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit Service 4684c1
negative error value.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_simple_parse
Packit Service 4684c1
@anchor{gnutls_pkcs12_simple_parse}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_simple_parse} (gnutls_pkcs12_t @var{p12}, const char * @var{password}, gnutls_x509_privkey_t * @var{key}, gnutls_x509_crt_t ** @var{chain}, unsigned int * @var{chain_len}, gnutls_x509_crt_t ** @var{extra_certs}, unsigned int * @var{extra_certs_len}, gnutls_x509_crl_t * @var{crl}, unsigned int @var{flags})
Packit Service 4684c1
@var{p12}: A pkcs12 type
Packit Service 4684c1
Packit Service 4684c1
@var{password}: optional password used to decrypt the structure, bags and keys.
Packit Service 4684c1
Packit Service 4684c1
@var{key}: a structure to store the parsed private key.
Packit Service 4684c1
Packit Service 4684c1
@var{chain}: the corresponding to key certificate chain (may be @code{NULL} )
Packit Service 4684c1
Packit Service 4684c1
@var{chain_len}: will be updated with the number of additional (may be @code{NULL} )
Packit Service 4684c1
Packit Service 4684c1
@var{extra_certs}: optional pointer to receive an array of additional
Packit Service 4684c1
certificates found in the PKCS12 structure (may be @code{NULL} ).
Packit Service 4684c1
Packit Service 4684c1
@var{extra_certs_len}: will be updated with the number of additional
Packit Service 4684c1
certs (may be @code{NULL} ).
Packit Service 4684c1
Packit Service 4684c1
@var{crl}: an optional structure to store the parsed CRL (may be @code{NULL} ).
Packit Service 4684c1
Packit Service 4684c1
@var{flags}: should be zero or one of GNUTLS_PKCS12_SP_*
Packit Service 4684c1
Packit Service 4684c1
This function parses a PKCS12 structure in  @code{pkcs12} and extracts the
Packit Service 4684c1
private key, the corresponding certificate chain, any additional
Packit Service 4684c1
certificates and a CRL. The structures in  @code{key} ,  @code{chain}  @code{crl} , and  @code{extra_certs} must not be initialized.
Packit Service 4684c1
Packit Service 4684c1
The  @code{extra_certs} and  @code{extra_certs_len} parameters are optional
Packit Service 4684c1
and both may be set to @code{NULL} . If either is non-@code{NULL} , then both must
Packit Service 4684c1
be set. The value for  @code{extra_certs} is allocated
Packit Service 4684c1
using @code{gnutls_malloc()} .
Packit Service 4684c1
Packit Service 4684c1
Encrypted PKCS12 bags and PKCS8 private keys are supported, but
Packit Service 4684c1
only with password based security and the same password for all
Packit Service 4684c1
operations.
Packit Service 4684c1
Packit Service 4684c1
Note that a PKCS12 structure may contain many keys and/or certificates,
Packit Service 4684c1
and there is no way to identify which key/certificate pair you want.
Packit Service 4684c1
For this reason this function is useful for PKCS12 files that contain 
Packit Service 4684c1
only one key/certificate pair and/or one CRL.
Packit Service 4684c1
Packit Service 4684c1
If the provided structure has encrypted fields but no password
Packit Service 4684c1
is provided then this function returns @code{GNUTLS_E_DECRYPTION_FAILED} .
Packit Service 4684c1
Packit Service 4684c1
Note that normally the chain constructed does not include self signed
Packit Service 4684c1
certificates, to comply with TLS' requirements. If, however, the flag 
Packit Service 4684c1
@code{GNUTLS_PKCS12_SP_INCLUDE_SELF_SIGNED}  is specified then
Packit Service 4684c1
self signed certificates will be included in the chain.
Packit Service 4684c1
Packit Service 4684c1
Prior to using this function the PKCS @code{12}  structure integrity must
Packit Service 4684c1
be verified using @code{gnutls_pkcs12_verify_mac()} .
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit Service 4684c1
negative error value.
Packit Service 4684c1
Packit Service 4684c1
@strong{Since:} 3.1.0
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1
Packit Service 4684c1
@subheading gnutls_pkcs12_verify_mac
Packit Service 4684c1
@anchor{gnutls_pkcs12_verify_mac}
Packit Service 4684c1
@deftypefun {int} {gnutls_pkcs12_verify_mac} (gnutls_pkcs12_t @var{pkcs12}, const char * @var{pass})
Packit Service 4684c1
@var{pkcs12}: should contain a gnutls_pkcs12_t type
Packit Service 4684c1
Packit Service 4684c1
@var{pass}: The password for the MAC
Packit Service 4684c1
Packit Service 4684c1
This function will verify the MAC for the PKCS12 structure.
Packit Service 4684c1
Packit Service 4684c1
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
Packit Service 4684c1
negative error value.
Packit Service 4684c1
@end deftypefun
Packit Service 4684c1