gnutls_x509_ext_export_key_usage(3)

πŸ’… gnutls_x509_ext_export_key_usage(3) β€” the gnutls manual, but make it make sense

okay bestie, sit down, hydrate, and let me tell you about a little function from the gnutls manual (that's the manual name, she's famous) that turns your key usage vibes into actual DER-encoded PKIX extension bytes. it's giving glow-up for bit strings ✨


🌸 NAME 🌸

gnutls_x509_ext_export_key_usage β€” an API function, and yes she's iconic for it πŸŽ€


✨ SYNOPSIS ✨

#include <gnutls/x509-ext.h>

int gnutls_x509_ext_export_key_usage(unsigned int usage, gnutls_datum_t
* ext);

like. look at her. two args. no drama. periodt πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • unsigned int usage β€” an ORed sequence of the GNUTLS_KEY_* elements. so you literally just mash your flags together with | and she understands, no cap 🫢
  • gnutls_datum_t * ext β€” the DER-encoded extension data. and listen, bestie, you must free this with gnutls_free(). not free(). not vibes. gnutls_free(). the way that leaks are NOT the aesthetic 😭

πŸ‘‘ DESCRIPTION πŸ‘‘

so what does she actually do? this function converts the keyUsage bit string into a DER encoded PKIX extension. that's the whole plot. the ext data gets allocated using gnutls_malloc(), which is exactly why you're freeing it with gnutls_free() later β€” they're a matched set, they're soulmates, don't separate them πŸ’–


🌈 RETURNS 🌈

on success you get GNUTLS_E_SUCCESS (that's 0, the good number, the slay number) ✨ otherwise you get a negative error value. negative. as in, not it. as in, check your flags boo πŸ™ˆ


⭐ SINCE ⭐

3.3.0 β€” she's been around, she's got history, she's a legacy queen πŸ‘‘


πŸ’œ REPORTING BUGS πŸ’œ

found something cursed? don't just tweet about it, report bugs to <bugs@gnutls.org>. πŸ›

home page: https://www.gnutls.org β€” go, be nosy, it's fine 🌸


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. fr fr, that's the deal, and it's a generous one 🫢


🧚 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/

iykyk, that's the mothership πŸ’«


lowkey reminder: usage is ORed GNUTLS_KEY_* elements, ext is DER-encoded extension data, and it must be freed using gnutls_free(). no skipping, bestie πŸ’€

and that's the page!! this one shipped as part of gnutls 3.8.13 (that's the source and version, right there in the footer, she said it herself) β€” mwah, go export some key usage, you're doing amazing sweetie πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from