Blame doc/crypto-api.texi

Packit 549fdc
Packit 549fdc
@subheading gnutls_aead_cipher_decrypt
Packit 549fdc
@anchor{gnutls_aead_cipher_decrypt}
Packit 549fdc
@deftypefun {int} {gnutls_aead_cipher_decrypt} (gnutls_aead_cipher_hd_t @var{handle}, const void * @var{nonce}, size_t @var{nonce_len}, const void * @var{auth}, size_t @var{auth_len}, size_t @var{tag_size}, const void * @var{ctext}, size_t @var{ctext_len}, void * @var{ptext}, size_t * @var{ptext_len})
Packit 549fdc
@var{handle}: is a @code{gnutls_aead_cipher_hd_t}  type.
Packit 549fdc
Packit 549fdc
@var{nonce}: the nonce to set
Packit 549fdc
Packit 549fdc
@var{nonce_len}: The length of the nonce
Packit 549fdc
Packit 549fdc
@var{auth}: the data to be authenticated
Packit 549fdc
Packit 549fdc
@var{auth_len}: The length of the data
Packit 549fdc
Packit 549fdc
@var{tag_size}: The size of the tag to use (use zero for the default)
Packit 549fdc
Packit 549fdc
@var{ctext}: the data to decrypt
Packit 549fdc
Packit 549fdc
@var{ctext_len}: the length of data to decrypt (includes tag size)
Packit 549fdc
Packit 549fdc
@var{ptext}: the decrypted data
Packit 549fdc
Packit 549fdc
@var{ptext_len}: the length of decrypted data (initially must hold the maximum available size)
Packit 549fdc
Packit 549fdc
This function will decrypt the given data using the algorithm
Packit 549fdc
specified by the context. This function must be provided the whole
Packit 549fdc
data to be decrypted, including the tag, and will fail if the tag
Packit 549fdc
verification fails.
Packit 549fdc
Packit 549fdc
@strong{Returns:} Zero or a negative error code on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_aead_cipher_deinit
Packit 549fdc
@anchor{gnutls_aead_cipher_deinit}
Packit 549fdc
@deftypefun {void} {gnutls_aead_cipher_deinit} (gnutls_aead_cipher_hd_t @var{handle})
Packit 549fdc
@var{handle}: is a @code{gnutls_aead_cipher_hd_t}  type.
Packit 549fdc
Packit 549fdc
This function will deinitialize all resources occupied by the given
Packit 549fdc
authenticated-encryption context.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_aead_cipher_encrypt
Packit 549fdc
@anchor{gnutls_aead_cipher_encrypt}
Packit 549fdc
@deftypefun {int} {gnutls_aead_cipher_encrypt} (gnutls_aead_cipher_hd_t @var{handle}, const void * @var{nonce}, size_t @var{nonce_len}, const void * @var{auth}, size_t @var{auth_len}, size_t @var{tag_size}, const void * @var{ptext}, size_t @var{ptext_len}, void * @var{ctext}, size_t * @var{ctext_len})
Packit 549fdc
@var{handle}: is a @code{gnutls_aead_cipher_hd_t}  type.
Packit 549fdc
Packit 549fdc
@var{nonce}: the nonce to set
Packit 549fdc
Packit 549fdc
@var{nonce_len}: The length of the nonce
Packit 549fdc
Packit 549fdc
@var{auth}: the data to be authenticated
Packit 549fdc
Packit 549fdc
@var{auth_len}: The length of the data
Packit 549fdc
Packit 549fdc
@var{tag_size}: The size of the tag to use (use zero for the default)
Packit 549fdc
Packit 549fdc
@var{ptext}: the data to encrypt
Packit 549fdc
Packit 549fdc
@var{ptext_len}: The length of data to encrypt
Packit 549fdc
Packit 549fdc
@var{ctext}: the encrypted data
Packit 549fdc
Packit 549fdc
@var{ctext_len}: the length of encrypted data (initially must hold the maximum available size, including space for tag)
Packit 549fdc
Packit 549fdc
This function will encrypt the given data using the algorithm
Packit 549fdc
specified by the context. The output data will contain the
Packit 549fdc
authentication tag.
Packit 549fdc
Packit 549fdc
@strong{Returns:} Zero or a negative error code on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_aead_cipher_init
Packit 549fdc
@anchor{gnutls_aead_cipher_init}
Packit 549fdc
@deftypefun {int} {gnutls_aead_cipher_init} (gnutls_aead_cipher_hd_t * @var{handle}, gnutls_cipher_algorithm_t @var{cipher}, const gnutls_datum_t * @var{key})
Packit 549fdc
@var{handle}: is a @code{gnutls_aead_cipher_hd_t}  type.
Packit 549fdc
Packit 549fdc
@var{cipher}: the authenticated-encryption algorithm to use
Packit 549fdc
Packit 549fdc
@var{key}: The key to be used for encryption
Packit 549fdc
Packit 549fdc
This function will initialize an context that can be used for
Packit 549fdc
encryption/decryption of data. This will effectively use the
Packit 549fdc
current crypto backend in use by gnutls or the cryptographic
Packit 549fdc
accelerator in use.
Packit 549fdc
Packit 549fdc
@strong{Returns:} Zero or a negative error code on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_cipher_add_auth
Packit 549fdc
@anchor{gnutls_cipher_add_auth}
Packit 549fdc
@deftypefun {int} {gnutls_cipher_add_auth} (gnutls_cipher_hd_t @var{handle}, const void * @var{ptext}, size_t @var{ptext_size})
Packit 549fdc
@var{handle}: is a @code{gnutls_cipher_hd_t}  type
Packit 549fdc
Packit 549fdc
@var{ptext}: the data to be authenticated
Packit 549fdc
Packit 549fdc
@var{ptext_size}: the length of the data
Packit 549fdc
Packit 549fdc
This function operates on authenticated encryption with
Packit 549fdc
associated data (AEAD) ciphers and authenticate the
Packit 549fdc
input data. This function can only be called once
Packit 549fdc
and before any encryption operations.
Packit 549fdc
Packit 549fdc
@strong{Returns:} Zero or a negative error code on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_cipher_decrypt
Packit 549fdc
@anchor{gnutls_cipher_decrypt}
Packit 549fdc
@deftypefun {int} {gnutls_cipher_decrypt} (gnutls_cipher_hd_t @var{handle}, void * @var{ctext}, size_t @var{ctext_len})
Packit 549fdc
@var{handle}: is a @code{gnutls_cipher_hd_t}  type
Packit 549fdc
Packit 549fdc
@var{ctext}: the data to decrypt
Packit 549fdc
Packit 549fdc
@var{ctext_len}: the length of data to decrypt
Packit 549fdc
Packit 549fdc
This function will decrypt the given data using the algorithm
Packit 549fdc
specified by the context.
Packit 549fdc
Packit 549fdc
Note that in AEAD ciphers, this will not check the tag. You will
Packit 549fdc
need to compare the tag sent with the value returned from @code{gnutls_cipher_tag()} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} Zero or a negative error code on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.10.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_cipher_decrypt2
Packit 549fdc
@anchor{gnutls_cipher_decrypt2}
Packit 549fdc
@deftypefun {int} {gnutls_cipher_decrypt2} (gnutls_cipher_hd_t @var{handle}, const void * @var{ctext}, size_t @var{ctext_len}, void * @var{ptext}, size_t @var{ptext_len})
Packit 549fdc
@var{handle}: is a @code{gnutls_cipher_hd_t}  type
Packit 549fdc
Packit 549fdc
@var{ctext}: the data to decrypt
Packit 549fdc
Packit 549fdc
@var{ctext_len}: the length of data to decrypt
Packit 549fdc
Packit 549fdc
@var{ptext}: the decrypted data
Packit 549fdc
Packit 549fdc
@var{ptext_len}: the available length for decrypted data
Packit 549fdc
Packit 549fdc
This function will decrypt the given data using the algorithm
Packit 549fdc
specified by the context. For block ciphers the  @code{ctext_len} must be
Packit 549fdc
a multiple of the block size. For the supported ciphers the plaintext
Packit 549fdc
data length will equal the ciphertext size.
Packit 549fdc
Packit 549fdc
Note that in AEAD ciphers, this will not check the tag. You will
Packit 549fdc
need to compare the tag sent with the value returned from @code{gnutls_cipher_tag()} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} Zero 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_cipher_deinit
Packit 549fdc
@anchor{gnutls_cipher_deinit}
Packit 549fdc
@deftypefun {void} {gnutls_cipher_deinit} (gnutls_cipher_hd_t @var{handle})
Packit 549fdc
@var{handle}: is a @code{gnutls_cipher_hd_t}  type
Packit 549fdc
Packit 549fdc
This function will deinitialize all resources occupied by the given
Packit 549fdc
encryption context.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.10.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_cipher_encrypt
Packit 549fdc
@anchor{gnutls_cipher_encrypt}
Packit 549fdc
@deftypefun {int} {gnutls_cipher_encrypt} (gnutls_cipher_hd_t @var{handle}, void * @var{ptext}, size_t @var{ptext_len})
Packit 549fdc
@var{handle}: is a @code{gnutls_cipher_hd_t}  type
Packit 549fdc
Packit 549fdc
@var{ptext}: the data to encrypt
Packit 549fdc
Packit 549fdc
@var{ptext_len}: the length of data to encrypt
Packit 549fdc
Packit 549fdc
This function will encrypt the given data using the algorithm
Packit 549fdc
specified by the context.
Packit 549fdc
Packit 549fdc
@strong{Returns:} Zero or a negative error code on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.10.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_cipher_encrypt2
Packit 549fdc
@anchor{gnutls_cipher_encrypt2}
Packit 549fdc
@deftypefun {int} {gnutls_cipher_encrypt2} (gnutls_cipher_hd_t @var{handle}, const void * @var{ptext}, size_t @var{ptext_len}, void * @var{ctext}, size_t @var{ctext_len})
Packit 549fdc
@var{handle}: is a @code{gnutls_cipher_hd_t}  type
Packit 549fdc
Packit 549fdc
@var{ptext}: the data to encrypt
Packit 549fdc
Packit 549fdc
@var{ptext_len}: the length of data to encrypt
Packit 549fdc
Packit 549fdc
@var{ctext}: the encrypted data
Packit 549fdc
Packit 549fdc
@var{ctext_len}: the available length for encrypted data
Packit 549fdc
Packit 549fdc
This function will encrypt the given data using the algorithm
Packit 549fdc
specified by the context. For block ciphers the  @code{ptext_len} must be
Packit 549fdc
a multiple of the block size. For the supported ciphers the encrypted
Packit 549fdc
data length will equal the plaintext size.
Packit 549fdc
Packit 549fdc
@strong{Returns:} Zero 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_cipher_get_block_size
Packit 549fdc
@anchor{gnutls_cipher_get_block_size}
Packit 549fdc
@deftypefun {unsigned} {gnutls_cipher_get_block_size} (gnutls_cipher_algorithm_t @var{algorithm})
Packit 549fdc
@var{algorithm}: is an encryption algorithm
Packit 549fdc
Packit 549fdc
Packit 549fdc
@strong{Returns:} the block size of the encryption algorithm.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.10.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_cipher_get_iv_size
Packit 549fdc
@anchor{gnutls_cipher_get_iv_size}
Packit 549fdc
@deftypefun {unsigned} {gnutls_cipher_get_iv_size} (gnutls_cipher_algorithm_t @var{algorithm})
Packit 549fdc
@var{algorithm}: is an encryption algorithm
Packit 549fdc
Packit 549fdc
Get block size for encryption algorithm.
Packit 549fdc
Packit 549fdc
@strong{Returns:} block size for encryption algorithm.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.2.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_cipher_get_tag_size
Packit 549fdc
@anchor{gnutls_cipher_get_tag_size}
Packit 549fdc
@deftypefun {unsigned} {gnutls_cipher_get_tag_size} (gnutls_cipher_algorithm_t @var{algorithm})
Packit 549fdc
@var{algorithm}: is an encryption algorithm
Packit 549fdc
Packit 549fdc
This function returns the tag size of an authenticated encryption
Packit 549fdc
algorithm. For non-AEAD algorithms, it returns zero.
Packit 549fdc
Packit 549fdc
@strong{Returns:} the tag size of the authenticated encryption algorithm.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.2.2
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_cipher_init
Packit 549fdc
@anchor{gnutls_cipher_init}
Packit 549fdc
@deftypefun {int} {gnutls_cipher_init} (gnutls_cipher_hd_t * @var{handle}, gnutls_cipher_algorithm_t @var{cipher}, const gnutls_datum_t * @var{key}, const gnutls_datum_t * @var{iv})
Packit 549fdc
@var{handle}: is a @code{gnutls_cipher_hd_t}  type
Packit 549fdc
Packit 549fdc
@var{cipher}: the encryption algorithm to use
Packit 549fdc
Packit 549fdc
@var{key}: the key to be used for encryption/decryption
Packit 549fdc
Packit 549fdc
@var{iv}: the IV to use (if not applicable set NULL)
Packit 549fdc
Packit 549fdc
This function will initialize the  @code{handle} context to be usable
Packit 549fdc
for encryption/decryption of data. This will effectively use the
Packit 549fdc
current crypto backend in use by gnutls or the cryptographic
Packit 549fdc
accelerator in use.
Packit 549fdc
Packit 549fdc
@strong{Returns:} Zero or a negative error code on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.10.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_cipher_set_iv
Packit 549fdc
@anchor{gnutls_cipher_set_iv}
Packit 549fdc
@deftypefun {void} {gnutls_cipher_set_iv} (gnutls_cipher_hd_t @var{handle}, void * @var{iv}, size_t @var{ivlen})
Packit 549fdc
@var{handle}: is a @code{gnutls_cipher_hd_t}  type
Packit 549fdc
Packit 549fdc
@var{iv}: the IV to set
Packit 549fdc
Packit 549fdc
@var{ivlen}: the length of the IV
Packit 549fdc
Packit 549fdc
This function will set the IV to be used for the next
Packit 549fdc
encryption block.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_cipher_tag
Packit 549fdc
@anchor{gnutls_cipher_tag}
Packit 549fdc
@deftypefun {int} {gnutls_cipher_tag} (gnutls_cipher_hd_t @var{handle}, void * @var{tag}, size_t @var{tag_size})
Packit 549fdc
@var{handle}: is a @code{gnutls_cipher_hd_t}  type
Packit 549fdc
Packit 549fdc
@var{tag}: will hold the tag
Packit 549fdc
Packit 549fdc
@var{tag_size}: the length of the tag to return
Packit 549fdc
Packit 549fdc
This function operates on authenticated encryption with
Packit 549fdc
associated data (AEAD) ciphers and will return the
Packit 549fdc
output tag.
Packit 549fdc
Packit 549fdc
@strong{Returns:} Zero or a negative error code on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_crypto_register_aead_cipher
Packit 549fdc
@anchor{gnutls_crypto_register_aead_cipher}
Packit 549fdc
@deftypefun {int} {gnutls_crypto_register_aead_cipher} (gnutls_cipher_algorithm_t @var{algorithm}, int @var{priority}, gnutls_cipher_init_func @var{init}, gnutls_cipher_setkey_func @var{setkey}, gnutls_cipher_aead_encrypt_func @var{aead_encrypt}, gnutls_cipher_aead_decrypt_func @var{aead_decrypt}, gnutls_cipher_deinit_func @var{deinit})
Packit 549fdc
@var{algorithm}: is the gnutls AEAD cipher identifier
Packit 549fdc
Packit 549fdc
@var{priority}: is the priority of the algorithm
Packit 549fdc
Packit 549fdc
@var{init}: A function which initializes the cipher
Packit 549fdc
Packit 549fdc
@var{setkey}: A function which sets the key of the cipher
Packit 549fdc
Packit 549fdc
@var{aead_encrypt}: Perform the AEAD encryption
Packit 549fdc
Packit 549fdc
@var{aead_decrypt}: Perform the AEAD decryption
Packit 549fdc
Packit 549fdc
@var{deinit}: A function which deinitializes the cipher
Packit 549fdc
Packit 549fdc
This function will register a cipher algorithm to be used by
Packit 549fdc
gnutls.  Any algorithm registered will override the included
Packit 549fdc
algorithms and by convention kernel implemented algorithms have
Packit 549fdc
priority of 90 and CPU-assisted of 80.  The algorithm with the lowest priority will be
Packit 549fdc
used by gnutls.
Packit 549fdc
Packit 549fdc
In the case the registered init or setkey functions return @code{GNUTLS_E_NEED_FALLBACK} ,
Packit 549fdc
GnuTLS will attempt to use the next in priority registered cipher.
Packit 549fdc
Packit 549fdc
The functions registered will be used with the new AEAD API introduced in
Packit 549fdc
GnuTLS 3.4.0. Internally GnuTLS uses the new AEAD API.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_crypto_register_cipher
Packit 549fdc
@anchor{gnutls_crypto_register_cipher}
Packit 549fdc
@deftypefun {int} {gnutls_crypto_register_cipher} (gnutls_cipher_algorithm_t @var{algorithm}, int @var{priority}, gnutls_cipher_init_func @var{init}, gnutls_cipher_setkey_func @var{setkey}, gnutls_cipher_setiv_func @var{setiv}, gnutls_cipher_encrypt_func @var{encrypt}, gnutls_cipher_decrypt_func @var{decrypt}, gnutls_cipher_deinit_func @var{deinit})
Packit 549fdc
@var{algorithm}: is the gnutls algorithm identifier
Packit 549fdc
Packit 549fdc
@var{priority}: is the priority of the algorithm
Packit 549fdc
Packit 549fdc
@var{init}: A function which initializes the cipher
Packit 549fdc
Packit 549fdc
@var{setkey}: A function which sets the key of the cipher
Packit 549fdc
Packit 549fdc
@var{setiv}: A function which sets the nonce/IV of the cipher (non-AEAD)
Packit 549fdc
Packit 549fdc
@var{encrypt}: A function which performs encryption (non-AEAD)
Packit 549fdc
Packit 549fdc
@var{decrypt}: A function which performs decryption (non-AEAD)
Packit 549fdc
Packit 549fdc
@var{deinit}: A function which deinitializes the cipher
Packit 549fdc
Packit 549fdc
This function will register a cipher algorithm to be used by
Packit 549fdc
gnutls.  Any algorithm registered will override the included
Packit 549fdc
algorithms and by convention kernel implemented algorithms have
Packit 549fdc
priority of 90 and CPU-assisted of 80.  The algorithm with the lowest priority will be
Packit 549fdc
used by gnutls.
Packit 549fdc
Packit 549fdc
In the case the registered init or setkey functions return @code{GNUTLS_E_NEED_FALLBACK} ,
Packit 549fdc
GnuTLS will attempt to use the next in priority registered cipher.
Packit 549fdc
Packit 549fdc
The functions which are marked as non-AEAD they are not required when
Packit 549fdc
registering a cipher to be used with the new AEAD API introduced in
Packit 549fdc
GnuTLS 3.4.0. Internally GnuTLS uses the new AEAD API.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_crypto_register_digest
Packit 549fdc
@anchor{gnutls_crypto_register_digest}
Packit 549fdc
@deftypefun {int} {gnutls_crypto_register_digest} (gnutls_digest_algorithm_t @var{algorithm}, int @var{priority}, gnutls_digest_init_func @var{init}, gnutls_digest_hash_func @var{hash}, gnutls_digest_output_func @var{output}, gnutls_digest_deinit_func @var{deinit}, gnutls_digest_fast_func @var{hash_fast})
Packit 549fdc
@var{algorithm}: is the gnutls digest identifier
Packit 549fdc
Packit 549fdc
@var{priority}: is the priority of the algorithm
Packit 549fdc
Packit 549fdc
@var{init}: A function which initializes the digest
Packit 549fdc
Packit 549fdc
@var{hash}: Perform the hash operation
Packit 549fdc
Packit 549fdc
@var{output}: Provide the output of the digest
Packit 549fdc
Packit 549fdc
@var{deinit}: A function which deinitializes the digest
Packit 549fdc
Packit 549fdc
@var{hash_fast}: Perform the digest operation in one go
Packit 549fdc
Packit 549fdc
This function will register a digest algorithm to be used by gnutls.
Packit 549fdc
Any algorithm registered will override the included algorithms and
Packit 549fdc
by convention kernel implemented algorithms have priority of 90
Packit 549fdc
and CPU-assisted of 80.
Packit 549fdc
The algorithm with the lowest priority will be used by gnutls.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_crypto_register_mac
Packit 549fdc
@anchor{gnutls_crypto_register_mac}
Packit 549fdc
@deftypefun {int} {gnutls_crypto_register_mac} (gnutls_mac_algorithm_t @var{algorithm}, int @var{priority}, gnutls_mac_init_func @var{init}, gnutls_mac_setkey_func @var{setkey}, gnutls_mac_setnonce_func @var{setnonce}, gnutls_mac_hash_func @var{hash}, gnutls_mac_output_func @var{output}, gnutls_mac_deinit_func @var{deinit}, gnutls_mac_fast_func @var{hash_fast})
Packit 549fdc
@var{algorithm}: is the gnutls MAC identifier
Packit 549fdc
Packit 549fdc
@var{priority}: is the priority of the algorithm
Packit 549fdc
Packit 549fdc
@var{init}: A function which initializes the MAC
Packit 549fdc
Packit 549fdc
@var{setkey}: A function which sets the key of the MAC
Packit 549fdc
Packit 549fdc
@var{setnonce}: A function which sets the nonce for the mac (may be @code{NULL}  for common MAC algorithms)
Packit 549fdc
Packit 549fdc
@var{hash}: Perform the hash operation
Packit 549fdc
Packit 549fdc
@var{output}: Provide the output of the MAC
Packit 549fdc
Packit 549fdc
@var{deinit}: A function which deinitializes the MAC
Packit 549fdc
Packit 549fdc
@var{hash_fast}: Perform the MAC operation in one go
Packit 549fdc
Packit 549fdc
This function will register a MAC algorithm to be used by gnutls.
Packit 549fdc
Any algorithm registered will override the included algorithms and
Packit 549fdc
by convention kernel implemented algorithms have priority of 90
Packit 549fdc
and CPU-assisted of 80.
Packit 549fdc
The algorithm with the lowest priority will be used by gnutls.
Packit 549fdc
Packit 549fdc
@strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.4.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_decode_ber_digest_info
Packit 549fdc
@anchor{gnutls_decode_ber_digest_info}
Packit 549fdc
@deftypefun {int} {gnutls_decode_ber_digest_info} (const gnutls_datum_t * @var{info}, gnutls_digest_algorithm_t * @var{hash}, unsigned char * @var{digest}, unsigned int * @var{digest_size})
Packit 549fdc
@var{info}: an RSA BER encoded DigestInfo structure
Packit 549fdc
Packit 549fdc
@var{hash}: will contain the hash algorithm of the structure
Packit 549fdc
Packit 549fdc
@var{digest}: will contain the hash output of the structure
Packit 549fdc
Packit 549fdc
@var{digest_size}: will contain the hash size of the structure; initially must hold the maximum size of  @code{digest} 
Packit 549fdc
Packit 549fdc
This function will parse an RSA PKCS@code{1}  1.5 DigestInfo structure
Packit 549fdc
and report the hash algorithm used as well as the digest data.
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise
Packit 549fdc
an error code is returned.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.5.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_decode_rs_value
Packit 549fdc
@anchor{gnutls_decode_rs_value}
Packit 549fdc
@deftypefun {int} {gnutls_decode_rs_value} (const gnutls_datum_t * @var{sig_value}, gnutls_datum_t * @var{r}, gnutls_datum_t * @var{s})
Packit 549fdc
@var{sig_value}: holds a Dss-Sig-Value DER or BER encoded structure
Packit 549fdc
Packit 549fdc
@var{r}: will contain the r value
Packit 549fdc
Packit 549fdc
@var{s}: will contain the s value
Packit 549fdc
Packit 549fdc
This function will decode the provided  @code{sig_value} , 
Packit 549fdc
into  @code{r} and  @code{s} elements. The Dss-Sig-Value is used for DSA and ECDSA
Packit 549fdc
signatures.
Packit 549fdc
Packit 549fdc
The output values may be padded with a zero byte to prevent them
Packit 549fdc
from being interpreted as negative values. The value
Packit 549fdc
should be deallocated using @code{gnutls_free()} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise
Packit 549fdc
an error code is returned.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.6.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_encode_ber_digest_info
Packit 549fdc
@anchor{gnutls_encode_ber_digest_info}
Packit 549fdc
@deftypefun {int} {gnutls_encode_ber_digest_info} (gnutls_digest_algorithm_t @var{hash}, const gnutls_datum_t * @var{digest}, gnutls_datum_t * @var{output})
Packit 549fdc
@var{hash}: the hash algorithm that was used to get the digest
Packit 549fdc
Packit 549fdc
@var{digest}: must contain the digest data
Packit 549fdc
Packit 549fdc
@var{output}: will contain the allocated DigestInfo BER encoded data
Packit 549fdc
Packit 549fdc
This function will encode the provided digest data, and its
Packit 549fdc
algorithm into an RSA PKCS@code{1}  1.5 DigestInfo structure. 
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise
Packit 549fdc
an error code is returned.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.5.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_encode_rs_value
Packit 549fdc
@anchor{gnutls_encode_rs_value}
Packit 549fdc
@deftypefun {int} {gnutls_encode_rs_value} (gnutls_datum_t * @var{sig_value}, const gnutls_datum_t * @var{r}, const gnutls_datum_t * @var{s})
Packit 549fdc
@var{sig_value}: will hold a Dss-Sig-Value DER encoded structure
Packit 549fdc
Packit 549fdc
@var{r}: must contain the r value
Packit 549fdc
Packit 549fdc
@var{s}: must contain the s value
Packit 549fdc
Packit 549fdc
This function will encode the provided r and s values, 
Packit 549fdc
into a Dss-Sig-Value structure, used for DSA and ECDSA
Packit 549fdc
signatures.
Packit 549fdc
Packit 549fdc
The output value should be deallocated using @code{gnutls_free()} .
Packit 549fdc
Packit 549fdc
@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise
Packit 549fdc
an error code is returned.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.6.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_hash
Packit 549fdc
@anchor{gnutls_hash}
Packit 549fdc
@deftypefun {int} {gnutls_hash} (gnutls_hash_hd_t @var{handle}, const void * @var{ptext}, size_t @var{ptext_len})
Packit 549fdc
@var{handle}: is a @code{gnutls_hash_hd_t}  type
Packit 549fdc
Packit 549fdc
@var{ptext}: the data to hash
Packit 549fdc
Packit 549fdc
@var{ptext_len}: the length of data to hash
Packit 549fdc
Packit 549fdc
This function will hash the given data using the algorithm
Packit 549fdc
specified by the context.
Packit 549fdc
Packit 549fdc
@strong{Returns:} Zero or a negative error code on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.10.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_hash_deinit
Packit 549fdc
@anchor{gnutls_hash_deinit}
Packit 549fdc
@deftypefun {void} {gnutls_hash_deinit} (gnutls_hash_hd_t @var{handle}, void * @var{digest})
Packit 549fdc
@var{handle}: is a @code{gnutls_hash_hd_t}  type
Packit 549fdc
Packit 549fdc
@var{digest}: is the output value of the hash
Packit 549fdc
Packit 549fdc
This function will deinitialize all resources occupied by
Packit 549fdc
the given hash context.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.10.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_hash_fast
Packit 549fdc
@anchor{gnutls_hash_fast}
Packit 549fdc
@deftypefun {int} {gnutls_hash_fast} (gnutls_digest_algorithm_t @var{algorithm}, const void * @var{ptext}, size_t @var{ptext_len}, void * @var{digest})
Packit 549fdc
@var{algorithm}: the hash algorithm to use
Packit 549fdc
Packit 549fdc
@var{ptext}: the data to hash
Packit 549fdc
Packit 549fdc
@var{ptext_len}: the length of data to hash
Packit 549fdc
Packit 549fdc
@var{digest}: is the output value of the hash
Packit 549fdc
Packit 549fdc
This convenience function will hash the given data and return output
Packit 549fdc
on a single call.
Packit 549fdc
Packit 549fdc
@strong{Returns:} Zero or a negative error code on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.10.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_hash_get_len
Packit 549fdc
@anchor{gnutls_hash_get_len}
Packit 549fdc
@deftypefun {unsigned} {gnutls_hash_get_len} (gnutls_digest_algorithm_t @var{algorithm})
Packit 549fdc
@var{algorithm}: the hash algorithm to use
Packit 549fdc
Packit 549fdc
This function will return the length of the output data
Packit 549fdc
of the given hash algorithm.
Packit 549fdc
Packit 549fdc
@strong{Returns:} The length or zero on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.10.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_hash_init
Packit 549fdc
@anchor{gnutls_hash_init}
Packit 549fdc
@deftypefun {int} {gnutls_hash_init} (gnutls_hash_hd_t * @var{dig}, gnutls_digest_algorithm_t @var{algorithm})
Packit 549fdc
@var{dig}: is a @code{gnutls_hash_hd_t}  type
Packit 549fdc
Packit 549fdc
@var{algorithm}: the hash algorithm to use
Packit 549fdc
Packit 549fdc
This function will initialize an context that can be used to
Packit 549fdc
produce a Message Digest of data.  This will effectively use the
Packit 549fdc
current crypto backend in use by gnutls or the cryptographic
Packit 549fdc
accelerator in use.
Packit 549fdc
Packit 549fdc
@strong{Returns:} Zero or a negative error code on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.10.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_hash_output
Packit 549fdc
@anchor{gnutls_hash_output}
Packit 549fdc
@deftypefun {void} {gnutls_hash_output} (gnutls_hash_hd_t @var{handle}, void * @var{digest})
Packit 549fdc
@var{handle}: is a @code{gnutls_hash_hd_t}  type
Packit 549fdc
Packit 549fdc
@var{digest}: is the output value of the hash
Packit 549fdc
Packit 549fdc
This function will output the current hash value
Packit 549fdc
and reset the state of the hash.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.10.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_hmac
Packit 549fdc
@anchor{gnutls_hmac}
Packit 549fdc
@deftypefun {int} {gnutls_hmac} (gnutls_hmac_hd_t @var{handle}, const void * @var{ptext}, size_t @var{ptext_len})
Packit 549fdc
@var{handle}: is a @code{gnutls_hmac_hd_t}  type
Packit 549fdc
Packit 549fdc
@var{ptext}: the data to hash
Packit 549fdc
Packit 549fdc
@var{ptext_len}: the length of data to hash
Packit 549fdc
Packit 549fdc
This function will hash the given data using the algorithm
Packit 549fdc
specified by the context.
Packit 549fdc
Packit 549fdc
@strong{Returns:} Zero or a negative error code on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.10.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_hmac_deinit
Packit 549fdc
@anchor{gnutls_hmac_deinit}
Packit 549fdc
@deftypefun {void} {gnutls_hmac_deinit} (gnutls_hmac_hd_t @var{handle}, void * @var{digest})
Packit 549fdc
@var{handle}: is a @code{gnutls_hmac_hd_t}  type
Packit 549fdc
Packit 549fdc
@var{digest}: is the output value of the MAC
Packit 549fdc
Packit 549fdc
This function will deinitialize all resources occupied by
Packit 549fdc
the given hmac context.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.10.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_hmac_fast
Packit 549fdc
@anchor{gnutls_hmac_fast}
Packit 549fdc
@deftypefun {int} {gnutls_hmac_fast} (gnutls_mac_algorithm_t @var{algorithm}, const void * @var{key}, size_t @var{keylen}, const void * @var{ptext}, size_t @var{ptext_len}, void * @var{digest})
Packit 549fdc
@var{algorithm}: the hash algorithm to use
Packit 549fdc
Packit 549fdc
@var{key}: the key to use
Packit 549fdc
Packit 549fdc
@var{keylen}: the length of the key
Packit 549fdc
Packit 549fdc
@var{ptext}: the data to hash
Packit 549fdc
Packit 549fdc
@var{ptext_len}: the length of data to hash
Packit 549fdc
Packit 549fdc
@var{digest}: is the output value of the hash
Packit 549fdc
Packit 549fdc
This convenience function will hash the given data and return output
Packit 549fdc
on a single call.
Packit 549fdc
Packit 549fdc
@strong{Returns:} Zero or a negative error code on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.10.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_hmac_get_len
Packit 549fdc
@anchor{gnutls_hmac_get_len}
Packit 549fdc
@deftypefun {unsigned} {gnutls_hmac_get_len} (gnutls_mac_algorithm_t @var{algorithm})
Packit 549fdc
@var{algorithm}: the hmac algorithm to use
Packit 549fdc
Packit 549fdc
This function will return the length of the output data
Packit 549fdc
of the given hmac algorithm.
Packit 549fdc
Packit 549fdc
@strong{Returns:} The length or zero on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.10.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_hmac_init
Packit 549fdc
@anchor{gnutls_hmac_init}
Packit 549fdc
@deftypefun {int} {gnutls_hmac_init} (gnutls_hmac_hd_t * @var{dig}, gnutls_mac_algorithm_t @var{algorithm}, const void * @var{key}, size_t @var{keylen})
Packit 549fdc
@var{dig}: is a @code{gnutls_hmac_hd_t}  type
Packit 549fdc
Packit 549fdc
@var{algorithm}: the HMAC algorithm to use
Packit 549fdc
Packit 549fdc
@var{key}: the key to be used for encryption
Packit 549fdc
Packit 549fdc
@var{keylen}: the length of the key
Packit 549fdc
Packit 549fdc
This function will initialize an context that can be used to
Packit 549fdc
produce a Message Authentication Code (MAC) of data.  This will
Packit 549fdc
effectively use the current crypto backend in use by gnutls or the
Packit 549fdc
cryptographic accelerator in use.
Packit 549fdc
Packit 549fdc
Note that despite the name of this function, it can be used
Packit 549fdc
for other MAC algorithms than HMAC.
Packit 549fdc
Packit 549fdc
@strong{Returns:} Zero or a negative error code on error.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.10.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_hmac_output
Packit 549fdc
@anchor{gnutls_hmac_output}
Packit 549fdc
@deftypefun {void} {gnutls_hmac_output} (gnutls_hmac_hd_t @var{handle}, void * @var{digest})
Packit 549fdc
@var{handle}: is a @code{gnutls_hmac_hd_t}  type
Packit 549fdc
Packit 549fdc
@var{digest}: is the output value of the MAC
Packit 549fdc
Packit 549fdc
This function will output the current MAC value
Packit 549fdc
and reset the state of the MAC.
Packit 549fdc
Packit 549fdc
@strong{Since:} 2.10.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_hmac_set_nonce
Packit 549fdc
@anchor{gnutls_hmac_set_nonce}
Packit 549fdc
@deftypefun {void} {gnutls_hmac_set_nonce} (gnutls_hmac_hd_t @var{handle}, const void * @var{nonce}, size_t @var{nonce_len})
Packit 549fdc
@var{handle}: is a @code{gnutls_hmac_hd_t}  type
Packit 549fdc
Packit 549fdc
@var{nonce}: the data to set as nonce
Packit 549fdc
Packit 549fdc
@var{nonce_len}: the length of data
Packit 549fdc
Packit 549fdc
This function will set the nonce in the MAC algorithm.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.2.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_mac_get_nonce_size
Packit 549fdc
@anchor{gnutls_mac_get_nonce_size}
Packit 549fdc
@deftypefun {size_t} {gnutls_mac_get_nonce_size} (gnutls_mac_algorithm_t @var{algorithm})
Packit 549fdc
@var{algorithm}: is an encryption algorithm
Packit 549fdc
Packit 549fdc
Returns the size of the nonce used by the MAC in TLS.
Packit 549fdc
Packit 549fdc
@strong{Returns:} length (in bytes) of the given MAC nonce size, or 0.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.2.0
Packit 549fdc
@end deftypefun
Packit 549fdc
Packit 549fdc
@subheading gnutls_rnd
Packit 549fdc
@anchor{gnutls_rnd}
Packit 549fdc
@deftypefun {int} {gnutls_rnd} (gnutls_rnd_level_t @var{level}, void * @var{data}, size_t @var{len})
Packit 549fdc
@var{level}: a security level
Packit 549fdc
Packit 549fdc
@var{data}: place to store random bytes
Packit 549fdc
Packit 549fdc
@var{len}: The requested size
Packit 549fdc
Packit 549fdc
This function will generate random data and store it to output
Packit 549fdc
buffer. The value of  @code{level} should be one of @code{GNUTLS_RND_NONCE} ,
Packit 549fdc
@code{GNUTLS_RND_RANDOM}  and @code{GNUTLS_RND_KEY} . See the manual and
Packit 549fdc
@code{gnutls_rnd_level_t}  for detailed information.
Packit 549fdc
Packit 549fdc
This function is thread-safe and also fork-safe.
Packit 549fdc
Packit 549fdc
@strong{Returns:} Zero on 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_rnd_refresh
Packit 549fdc
@anchor{gnutls_rnd_refresh}
Packit 549fdc
@deftypefun {void} {gnutls_rnd_refresh} ( @var{void})
Packit 549fdc
Packit 549fdc
This function refreshes the random generator state.
Packit 549fdc
That is the current precise time, CPU usage, and
Packit 549fdc
other values are input into its state.
Packit 549fdc
Packit 549fdc
On a slower rate input from /dev/urandom is mixed too.
Packit 549fdc
Packit 549fdc
@strong{Since:} 3.1.7
Packit 549fdc
@end deftypefun
Packit 549fdc