manpagez: man pages & more
info gnutls
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

E.11 Cryptographic API

The following functions are to be used for low-level cryptographic operations. Their prototypes lie in ‘gnutls/crypto.h’.

gnutls_cipher_add_auth

Function: int gnutls_cipher_add_auth (gnutls_cipher_hd_t handle, const void * text, size_t text_size)

handle: is a gnutls_cipher_hd_t structure.

text: the data to be authenticated

text_size: The length of the data

This function operates on authenticated encryption with associated data (AEAD) ciphers and authenticate the input data. This function can only be called once and before any encryption operations.

Returns: Zero or a negative error code on error.

Since: 3.0

gnutls_cipher_decrypt

Function: int gnutls_cipher_decrypt (gnutls_cipher_hd_t handle, void * ciphertext, size_t ciphertextlen)

handle: is a gnutls_cipher_hd_t structure.

ciphertext: the data to encrypt

ciphertextlen: The length of data to encrypt

This function will decrypt the given data using the algorithm specified by the context.

Note that in AEAD ciphers, this will not check the tag. You will need to compare the tag sent with the value returned from gnutls_cipher_tag() .

Returns: Zero or a negative error code on error.

Since: 2.10.0

gnutls_cipher_decrypt2

Function: int gnutls_cipher_decrypt2 (gnutls_cipher_hd_t handle, const void * ciphertext, size_t ciphertextlen, void * text, size_t textlen)

handle: is a gnutls_cipher_hd_t structure.

ciphertext: the data to encrypt

ciphertextlen: The length of data to encrypt

text: the decrypted data

textlen: The available length for decrypted data

This function will decrypt the given data using the algorithm specified by the context.

Note that in AEAD ciphers, this will not check the tag. You will need to compare the tag sent with the value returned from gnutls_cipher_tag() .

Returns: Zero or a negative error code on error.

Since: 2.12.0

gnutls_cipher_deinit

Function: void gnutls_cipher_deinit (gnutls_cipher_hd_t handle)

handle: is a gnutls_cipher_hd_t structure.

This function will deinitialize all resources occupied by the given encryption context.

Since: 2.10.0

gnutls_cipher_encrypt

Function: int gnutls_cipher_encrypt (gnutls_cipher_hd_t handle, void * text, size_t textlen)

handle: is a gnutls_cipher_hd_t structure.

text: the data to encrypt

textlen: The length of data to encrypt

This function will encrypt the given data using the algorithm specified by the context.

Returns: Zero or a negative error code on error.

Since: 2.10.0

gnutls_cipher_encrypt2

Function: int gnutls_cipher_encrypt2 (gnutls_cipher_hd_t handle, const void * text, size_t textlen, void * ciphertext, size_t ciphertextlen)

handle: is a gnutls_cipher_hd_t structure.

text: the data to encrypt

textlen: The length of data to encrypt

ciphertext: the encrypted data

ciphertextlen: The available length for encrypted data

This function will encrypt the given data using the algorithm specified by the context.

Returns: Zero or a negative error code on error.

Since: 2.12.0

gnutls_cipher_get_block_size

Function: int gnutls_cipher_get_block_size (gnutls_cipher_algorithm_t algorithm)

algorithm: is an encryption algorithm

Returns: the block size of the encryption algorithm.

Since: 2.10.0

gnutls_cipher_get_iv_size

Function: int gnutls_cipher_get_iv_size (gnutls_cipher_algorithm_t algorithm)

algorithm: is an encryption algorithm

Get block size for encryption algorithm.

Returns: block size for encryption algorithm.

Since: 3.2.0

gnutls_cipher_get_tag_size

Function: int gnutls_cipher_get_tag_size (gnutls_cipher_algorithm_t algorithm)

algorithm: is an encryption algorithm

Returns: the tag size of the authenticated encryption algorithm.

Since: 3.2.2

gnutls_cipher_init

Function: int gnutls_cipher_init (gnutls_cipher_hd_t * handle, gnutls_cipher_algorithm_t cipher, const gnutls_datum_t * key, const gnutls_datum_t * iv)

handle: is a gnutls_cipher_hd_t structure.

cipher: the encryption algorithm to use

key: The key to be used for encryption

iv: The IV to use (if not applicable set NULL)

This function will initialize an context that can be used for encryption/decryption of data. This will effectively use the current crypto backend in use by gnutls or the cryptographic accelerator in use.

Returns: Zero or a negative error code on error.

Since: 2.10.0

gnutls_cipher_set_iv

Function: void gnutls_cipher_set_iv (gnutls_cipher_hd_t handle, void * iv, size_t ivlen)

handle: is a gnutls_cipher_hd_t structure.

iv: the IV to set

ivlen: The length of the IV

This function will set the IV to be used for the next encryption block.

Since: 3.0

gnutls_cipher_tag

Function: int gnutls_cipher_tag (gnutls_cipher_hd_t handle, void * tag, size_t tag_size)

handle: is a gnutls_cipher_hd_t structure.

tag: will hold the tag

tag_size: The length of the tag to return

This function operates on authenticated encryption with associated data (AEAD) ciphers and will return the output tag.

Returns: Zero or a negative error code on error.

Since: 3.0

gnutls_hash

Function: int gnutls_hash (gnutls_hash_hd_t handle, const void * text, size_t textlen)

handle: is a gnutls_cipher_hd_t structure.

text: the data to hash

textlen: The length of data to hash

This function will hash the given data using the algorithm specified by the context.

Returns: Zero or a negative error code on error.

Since: 2.10.0

gnutls_hash_deinit

Function: void gnutls_hash_deinit (gnutls_hash_hd_t handle, void * digest)

handle: is a gnutls_hash_hd_t structure.

digest: is the output value of the hash

This function will deinitialize all resources occupied by the given hash context.

Since: 2.10.0

gnutls_hash_fast

Function: int gnutls_hash_fast (gnutls_digest_algorithm_t algorithm, const void * text, size_t textlen, void * digest)

algorithm: the hash algorithm to use

text: the data to hash

textlen: The length of data to hash

digest: is the output value of the hash

This convenience function will hash the given data and return output on a single call.

Returns: Zero or a negative error code on error.

Since: 2.10.0

gnutls_hash_get_len

Function: int gnutls_hash_get_len (gnutls_digest_algorithm_t algorithm)

algorithm: the hash algorithm to use

This function will return the length of the output data of the given hash algorithm.

Returns: The length or zero on error.

Since: 2.10.0

gnutls_hash_init

Function: int gnutls_hash_init (gnutls_hash_hd_t * dig, gnutls_digest_algorithm_t algorithm)

dig: is a gnutls_hash_hd_t structure.

algorithm: the hash algorithm to use

This function will initialize an context that can be used to produce a Message Digest of data. This will effectively use the current crypto backend in use by gnutls or the cryptographic accelerator in use.

Returns: Zero or a negative error code on error.

Since: 2.10.0

gnutls_hash_output

Function: void gnutls_hash_output (gnutls_hash_hd_t handle, void * digest)

handle: is a gnutls_hash_hd_t structure.

digest: is the output value of the hash

This function will output the current hash value and reset the state of the hash.

Since: 2.10.0

gnutls_hmac

Function: int gnutls_hmac (gnutls_hmac_hd_t handle, const void * text, size_t textlen)

handle: is a gnutls_cipher_hd_t structure.

text: the data to hash

textlen: The length of data to hash

This function will hash the given data using the algorithm specified by the context.

Returns: Zero or a negative error code on error.

Since: 2.10.0

gnutls_hmac_deinit

Function: void gnutls_hmac_deinit (gnutls_hmac_hd_t handle, void * digest)

handle: is a gnutls_hmac_hd_t structure.

digest: is the output value of the MAC

This function will deinitialize all resources occupied by the given hmac context.

Since: 2.10.0

gnutls_hmac_fast

Function: int gnutls_hmac_fast (gnutls_mac_algorithm_t algorithm, const void * key, size_t keylen, const void * text, size_t textlen, void * digest)

algorithm: the hash algorithm to use

key: the key to use

keylen: The length of the key

text: the data to hash

textlen: The length of data to hash

digest: is the output value of the hash

This convenience function will hash the given data and return output on a single call.

Returns: Zero or a negative error code on error.

Since: 2.10.0

gnutls_hmac_get_len

Function: int gnutls_hmac_get_len (gnutls_mac_algorithm_t algorithm)

algorithm: the hmac algorithm to use

This function will return the length of the output data of the given hmac algorithm.

Returns: The length or zero on error.

Since: 2.10.0

gnutls_hmac_init

Function: int gnutls_hmac_init (gnutls_hmac_hd_t * dig, gnutls_mac_algorithm_t algorithm, const void * key, size_t keylen)

dig: is a gnutls_hmac_hd_t structure.

algorithm: the HMAC algorithm to use

key: The key to be used for encryption

keylen: The length of the key

This function will initialize an context that can be used to produce a Message Authentication Code (MAC) of data. This will effectively use the current crypto backend in use by gnutls or the cryptographic accelerator in use.

Note that despite the name of this function, it can be used for other MAC algorithms than HMAC.

Returns: Zero or a negative error code on error.

Since: 2.10.0

gnutls_hmac_output

Function: void gnutls_hmac_output (gnutls_hmac_hd_t handle, void * digest)

handle: is a gnutls_hmac_hd_t structure.

digest: is the output value of the MAC

This function will output the current MAC value and reset the state of the MAC.

Since: 2.10.0

gnutls_hmac_set_nonce

Function: void gnutls_hmac_set_nonce (gnutls_hmac_hd_t handle, const void * nonce, size_t nonce_len)

handle: is a gnutls_cipher_hd_t structure.

nonce: the data to set as nonce

nonce_len: The length of data

This function will set the nonce in the MAC algorithm.

Since: 3.2.0

gnutls_mac_get_nonce_size

Function: size_t gnutls_mac_get_nonce_size (gnutls_mac_algorithm_t algorithm)

algorithm: is an encryption algorithm

Returns the size of the nonce used by the MAC in TLS.

Returns: length (in bytes) of the given MAC nonce size, or 0.

Since: 3.2.0

gnutls_rnd

Function: int gnutls_rnd (gnutls_rnd_level_t level, void * data, size_t len)

level: a security level

data: place to store random bytes

len: The requested size

This function will generate random data and store it to output buffer.

Returns: Zero or a negative error code on error.

Since: 2.12.0

gnutls_rnd_refresh

Function: void gnutls_rnd_refresh ()

This function refreshes the random generator state. That is the current precise time, CPU usage, and other values are input into its state.

On a slower rate input from /dev/urandom is mixed too.

Since: 3.1.7


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on May 31, 2014 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.