gnutls_x509_crt_get_key_usage(3)

πŸ’– gnutls_x509_crt_get_key_usage πŸ’–

okay bestie, so this one lives in the gnutls manual, section 3 β€” aka the "you type man 3 gnutls_x509_crt_get_key_usage and the whole vibe is C library functions" corner of the internet. it's giving ✨certificate inspection✨ and honestly? we're obsessed.


✨ NAME ✨

gnutls_x509_crt_get_key_usage β€” API function πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnutls/x509.h>

int gnutls_x509_crt_get_key_usage(gnutls_x509_crt_t cert, unsigned int *
key_usage, unsigned int * critical);

🌸 ARGUMENTS 🌸

  • gnutls_x509_crt_t cert β€” bestie this should contain a gnutls_x509_crt_t type, no cap. that's literally the whole job. πŸ‘‘
  • unsigned int * key_usage β€” this is where the key usage bits get stored. like, the function drops them off here and dips. πŸ’…
  • unsigned int * critical β€” will be non-zero if the extension is marked as critical. so if it's not zero, the cert is being very serious about this extension. main character energy fr. 🚨

πŸ’œ DESCRIPTION πŸ’œ

okay so this function will return the certificate's key usage, and it does that by reading the keyUsage X.509 extension, which is 2.5.29.15. iykyk. πŸ”₯

the key usage value you get back is gonna be the ORed values of these absolute icons:

  • GNUTLS_KEY_DIGITAL_SIGNATURE
  • GNUTLS_KEY_NON_REPUDIATION
  • GNUTLS_KEY_KEY_ENCIPHERMENT
  • GNUTLS_KEY_DATA_ENCIPHERMENT
  • GNUTLS_KEY_KEY_AGREEMENT
  • GNUTLS_KEY_KEY_CERT_SIGN
  • GNUTLS_KEY_CRL_SIGN
  • GNUTLS_KEY_ENCIPHER_ONLY
  • GNUTLS_KEY_DECIPHER_ONLY

the way it just *or*s them all together... bitwise baddie behavior. πŸ’–


⭐ RETURNS ⭐

zero on success 🫢 β€” or a negative error code in case of a parsing error 😭.

and listen: if the certificate does not contain the keyUsage extension, then GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned. so don't come for her, she's literally telling you the data isn't there. πŸ™ˆ


πŸ› REPORTING BUGS πŸ›

found a bug? report 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. slay, that's the license, periodt. πŸ’…


🌸 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 version 3.8.13 doing its thing, and yes we love her for it. go read some certs. bye!! πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from