gnutls_crypto_register_aead_cipher - Linux
Overview
gnutls_crypto_register_aead_cipher registers an Authenticated Encryption with Associated Data (AEAD) cipher with GNUTLS. This allows custom or external AEAD ciphers to be used within GNUTLS for secure communication.
Syntax
gnutls_crypto_register_aead_cipher(const char *name,
gnutls_aead_cipher_function key_schedule,
gnutls_aead_cipher_function encrypt,
gnutls_aead_cipher_function decrypt,
gnutls_aead_cipher_function free_func,
size_t key_length,
size_t block_length,
size_t tag_length);
Options/Flags
| Flag | Description | Default Value |
|—|—|—|
| name
| Name of the AEAD cipher | N/A |
| key_schedule
| Function to generate a key schedule from a key | N/A |
| encrypt
| Function to encrypt data | N/A |
| decrypt
| Function to decrypt data | N/A |
| free_func
| Function to free memory allocated by the key schedule | N/A |
| key_length
| Length of the AEAD cipher key in bits | N/A |
| block_length
| Length of the AEAD cipher block in bytes | N/A |
| tag_length
| Length of the AEAD cipher tag in bytes | N/A |
Examples
To register a custom AEAD cipher named "MyCipher" with GNUTLS:
gnutls_crypto_register_aead_cipher("MyCipher",
my_key_schedule,
my_encrypt,
my_decrypt,
my_free_func,
256,
16,
16);
Common Issues
- Incompatible key lengths: Ensure that the registered cipher’s key length matches the expected key length for the desired encryption algorithm.
- Invalid functions: All registered functions must be valid and conform to the expected API specifications.
- Memory management: The
free_func
callback should properly free any allocated memory to prevent memory leaks.
Integration
gnutls_crypto_register_aead_cipher can be integrated into applications that use GNUTLS for encryption and decryption tasks. This allows custom or external AEAD ciphers to be seamlessly used within GNUTLS-based systems.