gnutls_x509_privkey_export(3)

πŸ’– gnutls_x509_privkey_export β€” bestie, let's get that key OUT of the vault πŸ’–

okay so this is a page from the gnutls manual (yes, that gnutls, the TLS library that's been holding it down since forever) and today we're talking about gnutls_x509_privkey_export. it's an API function. it does exactly what it sounds like. we're exporting a private key. slay. πŸ”‘


✨ SYNOPSIS ✨

#include <gnutls/x509.h>

int gnutls_x509_privkey_export(gnutls_x509_privkey_t key,
gnutls_x509_crt_fmt_t format, void * output_data, size_t *
output_data_size);

πŸŽ€ ARGUMENTS πŸŽ€

  • gnutls_x509_privkey_t key β€” this is the key itself, the main character, the whole point of the operation πŸ’… it's holding your key.
  • gnutls_x509_crt_fmt_t format β€” the format of the output params. it's one of PEM or DER. pick one, no both.
  • void * output_data β€” this is where the private key lands, PEM or DER encoded, all cozy in there.
  • size_t * output_data_size β€” holds the size of output_data when you hand it over (and will be replaced by the actual size of parameters once it's done, so it's giving before-and-after energy).

🌸 DESCRIPTION 🌸

so here's the tea. this function will export the private key to a PKCS1 structure for RSA or RSA-PSS keys, and to an integer sequence for DSA keys. other key types? they get exported in PKCS8 form. no cap, that's just how it goes.

if the structure is PEM encoded, it will have a header of "BEGIN RSA PRIVATE KEY". periodt. πŸ’…

⚠️ okay bestie listen β€” it is recommended to use gnutls_x509_privkey_export_pkcs8() instead of this function, when a consistent output format is required. like if you need everything to match, that's the move. this one? it's giving variety. know what you're getting into. πŸ™ˆ

πŸ’« RETURNS πŸ’«

on success, GNUTLS_E_SUCCESS (0) is returned. otherwise you get a negative error value and we're sad. 😭


πŸ¦‹ REPORTING BUGS πŸ¦‹

found a bug? don't suffer in silence, tell the people:


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.


🌈 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 🫢 go forth, export responsibly, and remember: gnutls_x509_privkey_export_pkcs8() if you want consistency. this page came to you from gnutls version 3.8.13, so if your version says something different, that's between you and your distro. mwah. πŸ’–βœ¨

πŸ“¦ where this page comes from