gnutls_pubkey_verify_hash2(3)

πŸ’– gnutls_pubkey_verify_hash2 β€” API function πŸ’–

okay bestie, welcome to the gnutls manual, and specifically to the page for gnutls_pubkey_verify_hash2(3) ✨ it's an API function, it lives in the gnutls family, and it's about checking whether a signature actually checks out. no cap. let's go 🫢


✨ SYNOPSIS ✨

#include <gnutls/abstract.h>

int gnutls_pubkey_verify_hash2(gnutls_pubkey_t key,
gnutls_sign_algorithm_t algo, unsigned int flags, const gnutls_datum_t *
hash, const gnutls_datum_t * signature);

like, five args, one int back. that's the whole vibe πŸ’…


🌸 ARGUMENTS 🌸

  • gnutls_pubkey_t key β€” this is your public key, the main character of the whole operation πŸ‘‘ it holds the key, you hold the hopes.
  • gnutls_sign_algorithm_t algo β€” the signature algorithm that was used. yes, signature algorithm, not digest algorithm, we'll get to why that's a whole thing in a sec πŸ™ˆ
  • unsigned int flags β€” zero, or an OR list of gnutls_certificate_verify_flags. zero is valid! zero is fine! zero is the "I have no extra opinions" option ✨
  • const gnutls_datum_t * hash β€” holds the hash digest that you want verified. the thing being checked.
  • const gnutls_datum_t * signature β€” contains the signature. the thing doing the checking.

πŸ¦‹ DESCRIPTION πŸ¦‹

so this function verifies the given signed digest, using the parameters from the public key. that's the tea β˜•

and here's the plot twist that lowkey trips people up: unlike gnutls_privkey_sign_hash(), this function accepts a signature algorithm instead of a digest algorithm. the way that these two are different things and nobody tells you 😭 so if you've got a digest algorithm and you need the matching signature algorithm, you can use gnutls_pk_to_sign() to get the appropriate value. problem solved, slay πŸ’–


πŸ”₯ RETURNS πŸ”₯

okay so if verification fails, you get GNUTLS_E_PK_SIG_VERIFY_FAILED back. if it succeeds, you get zero or a positive code. so like... check your return values, bestie, don't just assume πŸ™ˆ

⚠️ and for signatures that are known to be insecure, this function will return GNUTLS_E_INSUFFICIENT_SECURITY β€” unless you specified the flag GNUTLS_VERIFY_ALLOW_BROKEN. that flag is literally you going "yes I know it's broken, do it anyway" πŸ’€ so be normal about it.

⭐ SINCE ⭐

3.0 β€” been here since 3.0, an absolute icon, aging like fine wine πŸ“


πŸ’œ REPORTING BUGS πŸ’œ

found a bug? don't suffer in silence, tell the gnutls 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.

(translation: go off, just keep the receipts 🧚)


🌈 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 page!! this was gnutls 3.8.13, dropping gnutls_pubkey_verify_hash2(3) energy into your terminal, and if you read all the way down here you're literally the bestie of all time πŸ«ΆπŸ’– bye babe, go verify some signatures responsibly ✨

πŸ“¦ where this page comes from