gnutls_cipher_encrypt3(3)

πŸ’– gnutls_cipher_encrypt3(3) πŸ’–

okay bestie, so this is a page from the gnutls manual, and we're talking about gnutls_cipher_encrypt3 β€” she's an API function, she encrypts stuff, and she's lowkey iconic. let's get into it 🫢


✨ NAME ✨

gnutls_cipher_encrypt3 β€” API function. yes that's it. that's the whole name. slay.


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnutls/crypto.h>

int gnutls_cipher_encrypt3(gnutls_cipher_hd_t handle, const void *
ptext, size_t ptext_len, void * ctext, size_t * ctext_len, unsigned
flags);

there she is. six arguments. main character energy fr fr πŸ’…


🌸 ARGUMENTS 🌸

  • gnutls_cipher_hd_t handle β€” bestie this is a gnutls_cipher_hd_t type. that's the vibe. that's the handle.
  • const void * ptext β€” the data you wanna encrypt. the tea. the lore. πŸ“
  • size_t ptext_len β€” how long that data is, in case you were wondering.
  • void * ctext β€” where the encrypted data goes. the glow-up destination ✨
  • size_t * ctext_len β€” the length of the encrypted data. and listen, this one's a little diva: initially it must hold the maximum available size. she needs to know how much room she's got before she starts. πŸ’€
  • unsigned flags β€” flags for padding. padding is the stuffing, the filler, the extra bits when things don't line up perfectly. iconic honestly.

πŸ’œ DESCRIPTION πŸ’œ

so this function will encrypt the given data using the algorithm specified by the context. periodt.

for block ciphers, ptext_len is typically a multiple of the block size. and if it's not? no worries, the caller can instruct the function to pad that last block according to flags. currently, the only available padding scheme is GNUTLS_CIPHER_PADDING_PKCS7. that's the only one on the menu, bestie. no substitutions. πŸŽ€

now here's the important part, the way that this works:

if ctext is not NULL, it must hold enough space to store the resulting cipher text. and if you wanna check what size you actually need? you can call this function with ctext set to NULL. when you do that, ctext_len will be updated without performing actual encryption. it's like a vibe check before the real thing, iykyk. πŸ”₯

no cap: set ctext to NULL first if you don't know your sizes. do not skip this step, she will not be nice about it. 😭

πŸ‘‘ RETURNS πŸ‘‘

zero, or a negative error code on error. that's it. zero = we ate. negative = we did not. 🌈


⭐ SINCE ⭐

3.7.7 β€” she's been around since 3.7.7, a true veteran of the game. πŸ’–


πŸ™ˆ REPORTING BUGS πŸ™ˆ

found a bug? spill it 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. so like, take her, share her, just don't be weird about it. πŸ’œ


πŸ”₯ 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 the gnutls manual, version 3.8.13, and the page is gnutls_cipher_encrypt3(3). go encrypt something responsibly, drink water, and remember: check your ctext_len before you commit. mwah πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from