gnutls_privkey_sign_hash(3)

✨ gnutls_privkey_sign_hash ✨

okay bestie, so this is a page from the gnutls manual β€” specifically gnutls_privkey_sign_hash(3) β€” and it's literally an API function πŸ’…. ngl it's a lil niche but it's lowkey iconic once you get it. let's get into it 🫢


πŸŽ€ NAME πŸŽ€

gnutls_privkey_sign_hash β€” API function. that's it, that's the name, she's serving exactly what she says on the tin πŸ’–


🌸 SYNOPSIS 🌸

#include <gnutls/abstract.h>

int gnutls_privkey_sign_hash(gnutls_privkey_t signer,
gnutls_digest_algorithm_t hash_algo, unsigned int flags, const
gnutls_datum_t * hash_data, gnutls_datum_t * signature);

like, the whole vibe in one function signature, no cap ✨


πŸ¦‹ ARGUMENTS πŸ¦‹

here's who's who at this function's little party:

  • gnutls_privkey_t signer β€” holds the signer's key. the main character, honestly πŸ‘‘
  • gnutls_digest_algorithm_t hash_algo β€” the hash algorithm used. which flavor of hash we're going with, fr fr
  • unsigned int flags β€” zero or one of gnutls_privkey_flags_t. zero!! or one!! not a whole lil collection, bestie, just pick one (or none) πŸ™ˆ
  • const gnutls_datum_t * hash_data β€” holds the data to be signed. this is the thing getting the signature glow-up πŸ’–
  • gnutls_datum_t * signature β€” will contain newly allocated signature. fresh out the oven, allocated and everything ✨

πŸ’œ DESCRIPTION πŸ’œ

so this function will sign the given hashed data using a signature algorithm supported by the private key. that's the whole assignment 🫑 Signature algorithms are always used together with a hash functions. and here's the tea: different hash functions may be used for the RSA algorithm, but only SHA-XXX for the DSA keys. so like, RSA is flexible, DSA is picky, we respect her boundaries πŸ’…

you may use gnutls_pubkey_get_preferred_hash_algorithm() to determine the hash algorithm. it's giving helpful bestie energy, use her πŸ₯°

now the flags, okay, listen: the flags may be GNUTLS_PRIVKEY_SIGN_FLAG_TLS1_RSA or GNUTLS_PRIVKEY_SIGN_FLAG_RSA_PSS. and here's how they differ:

  • with GNUTLS_PRIVKEY_SIGN_FLAG_TLS1_RSA, this function will ignore hash_algo and perform a raw PKCS1 signature. like, it literally just doesn't care about that argument, bye πŸ‘‹
  • with GNUTLS_PRIVKEY_SIGN_FLAG_RSA_PSS, an RSA-PSS signature will be generated. different flavor, same slay πŸ”₯
⚠️ note that, not all algorithm support signing already hashed data. when signing with Ed25519, gnutls_privkey_sign_data() should be used. so if you're on Ed25519, this is NOT the function for you, bestie, go use the other one instead 😭

🌈 RETURNS 🌈

on success, GNUTLS_E_SUCCESS (0) is returned, otherwise a negative error value. so like, 0 = we ate, negative = not me today πŸ’€


⭐ SINCE ⭐

2.12.0 β€” she's been around since 2.12.0, an OG fr fr 🧚


πŸ“ REPORTING BUGS πŸ“

found a bug? don't be shy, tell the girlies:


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, copy away, just keep the receipt πŸŽ€


🌸 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_privkey_sign_hash(3) from the gnutls manual, version 3.8.13, dated 3.8.13 β€” okay so the footer literally just says gnutls 3.8.13 on both sides with the page name in the middle, and honestly? consistent queen behavior πŸ‘‘βœ¨ periodt.

πŸ“¦ where this page comes from