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 frunsigned int flagsβ zero or one ofgnutls_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 ignorehash_algoand 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:
- report bugs to <bugs@gnutls.org>.
- home page: https://www.gnutls.org
π COPYRIGHT π
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
- alpine 3.22: gnutls-doc 3.8.13-r0 Β· LGPL-2.1-or-later
- alpine 3.23: gnutls-doc 3.8.13-r0 Β· LGPL-2.1-or-later
- alpine 3.24: gnutls-doc 3.8.13-r0 Β· LGPL-2.1-or-later
- arch rolling: gnutls 3.8.13-3 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 43: gnutls-devel 3.8.13-1.fc43 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 43: gnutls-devel 3.8.13-1.fc43 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 44: gnutls-devel 3.8.13-1.fc44 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 44: gnutls-devel 3.8.13-1.fc44 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- ubuntu stonking: gnutls-doc 3.8.13-1ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms