gnutls_crypto_register_cipher(3)

πŸ’– gnutls_crypto_register_cipher β€” bestie edition πŸ’–

okay so you're in the gnutls manual, section 3, and today's main character is gnutls_crypto_register_cipher(3). buckle up πŸŽ€


✨ NAME ✨

gnutls_crypto_register_cipher β€” it's an API function, bestie, and it's here to let you register a cipher algorithm. iykyk.


🌸 SYNOPSIS 🌸

#include <gnutls/crypto.h>

int gnutls_crypto_register_cipher(gnutls_cipher_algorithm_t algorithm,
int priority, gnutls_cipher_init_func init, gnutls_cipher_setkey_func
setkey, gnutls_cipher_setiv_func setiv, gnutls_cipher_encrypt_func
encrypt, gnutls_cipher_decrypt_func decrypt, gnutls_cipher_deinit_func
deinit);

like, that's a LOT of arguments, and every single one of them matters. no skipping πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • gnutls_cipher_algorithm_t algorithm β€” this is the gnutls algorithm identifier. it's the "who am i" of your cipher ✨
  • int priority β€” the priority of the algorithm. yes bestie, priority matters here, keep reading πŸ‘€
  • gnutls_cipher_init_func init β€” a function which initializes the cipher 🌱
  • gnutls_cipher_setkey_func setkey β€” a function which sets the key of the cipher πŸ”‘
  • gnutls_cipher_setiv_func setiv β€” a function which sets the nonce/IV of the cipher (non-AEAD)
  • gnutls_cipher_encrypt_func encrypt β€” a function which performs encryption (non-AEAD) πŸ”’
  • gnutls_cipher_decrypt_func decrypt β€” a function which performs decryption (non-AEAD) πŸ”“
  • gnutls_cipher_deinit_func deinit β€” a function which deinitializes the cipher 🧹

πŸ‘‘ DESCRIPTION πŸ‘‘

so basically this function will register a cipher algorithm to be used by gnutls. any algorithm you register will override the included algorithms, and by convention kernel implemented algorithms have priority of 90 and CPU-assisted of 80. and here's the plot twist: the algorithm with the lowest priority will be used by gnutls. yes, lowest. not highest. that's the vibe, don't fight it πŸ’€

in the case that the registered init or setkey functions return GNUTLS_E_NEED_FALLBACK, GnuTLS will attempt to use the next in priority registered cipher. slay, it's got a backup plan 🫢

the functions which are marked as non-AEAD β€” they are not required when registering a cipher to be used with the new AEAD API introduced in GnuTLS 3.4.0. internally GnuTLS uses the new AEAD API. so those ones are giving optional, lowkey.


πŸ’€ DEPRECATED πŸ’€

since 3.7.0 it is no longer possible to override cipher implementation. yeah. it's giving deprecated, bestie. mourn it, then move on. 😭

🌈 RETURNS 🌈

GNUTLS_E_SUCCESS on success, otherwise a negative error code. standard behavior, no cap.


⭐ SINCE ⭐

3.4.0 β€” so it's been around for a minute πŸ’œ


πŸ› REPORTING BUGS πŸ›

found a bug? don't be shy, report bugs to <bugs@gnutls.org> πŸ“

home page: https://www.gnutls.org


Copyright Β© 2001-2023 Free Software Foundation, Inc., and others.

Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. iconic of them honestly 🫢


🧚 SEE ALSO 🧚

the full documentation for gnutls is maintained as a Texinfo manual. if the /usr/share/doc/gnutls/ directory does not contain the HTML form, visit

https://www.gnutls.org/manual/


and that's the whole page, bestie ✨ this was gnutls_crypto_register_cipher(3) from the gnutls manual, version 3.8.13. go forth and cipher responsibly πŸ’…πŸ’–πŸŒΈ

πŸ“¦ where this page comes from