gnutls_privkey_sign_data(3)

πŸ’– gnutls_privkey_sign_data β€” bestie, we're signing DATA today πŸ’–

okay so this is a page from the gnutls manual, and it's all about one little function that goes by the name gnutls_privkey_sign_data. She signs stuff. With your private key. Iconic behaviour honestly. Let's get into it πŸŽ€


✨ NAME ✨

gnutls_privkey_sign_data β€” literally just an API function, no cap


🌸 SYNOPSIS 🌸

#include <gnutls/abstract.h>

int gnutls_privkey_sign_data(gnutls_privkey_t signer,
gnutls_digest_algorithm_t hash, unsigned int flags, const gnutls_datum_t
* data, gnutls_datum_t * signature);

πŸ¦‹ ARGUMENTS πŸ¦‹

  • gnutls_privkey_t signer β€” the key that's holding all the power here. she's the one doing the signing, main character energy fr πŸ’…
  • gnutls_digest_algorithm_t hash β€” should be a digest algorithm. that's the vibe check on your hash function πŸ“
  • unsigned int flags β€” zero, or one of gnutls_privkey_flags_t. yes bestie, one. not a whole lil collection of them 😭
  • const gnutls_datum_t * data β€” holds the data that's about to get signed. she's the payload, she's the moment ✨
  • gnutls_datum_t * signature β€” will contain the signature, and it's allocated with gnutls_malloc(). so like, it's yours now, remember to free her 🫢

πŸ’œ DESCRIPTION πŸ’œ

This function will sign the given data using a signature algorithm supported by the private key. Periodt.

Signature algorithms are always used together with a hash function β€” they're a package deal, they don't come separately, iykyk. And here's the tea: different hash functions may be used for the RSA algorithm, but for DSA keys it's only the SHA family. that's it. that's the whole list. DSA said "SHA only, and I'm not discussing it" πŸ’€

You may use gnutls_pubkey_get_preferred_hash_algorithm() to determine the hash algorithm β€” so if you're sitting there like "which hash do I even use 😭", that's your girl, go ask her 🌈


⭐ RETURNS ⭐

On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a negative error value. so if you see a negative number, that's not a slay, that's a warning sign bestie πŸ™ˆ


πŸŽ€ SINCE πŸŽ€

2.12.0 β€” she's been around a minute, she's a legacy icon πŸ‘‘


πŸ”₯ REPORTING BUGS πŸ”₯

Found a bug? Do not suffer in silence, that's not the vibe. 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. so like, go off, redistribute, just keep the receipts attached fr fr πŸ’–


πŸ’« 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/


okay one last thing bestie β€” the signature you get back is gnutls_malloc'd, so please free it when you're done. no leaking in this household πŸ’…

and that's the page!! this one's from gnutls 3.8.13, and the date slot at the bottom was just… empty. mysterious. enigmatic. she didn't feel like dating herself today πŸ’€ anyway ily, go sign something responsibly πŸ¦‹βœ¨

πŸ“¦ where this page comes from