gnutls_x509_privkey_export_pkcs8(3)

✨ gnutls_x509_privkey_export_pkcs8 ✨

okay bestie so this is a page from the gnutls manual, and it's about gnutls_x509_privkey_export_pkcs8 β€” literally an API function, and yes it's giving "let me yeet your private key into a PKCS8 structure" energy πŸŽ€


πŸ’– NAME πŸ’–

gnutls_x509_privkey_export_pkcs8 β€” API function, no cap πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnutls/x509.h>

int gnutls_x509_privkey_export_pkcs8(gnutls_x509_privkey_t key,
gnutls_x509_crt_fmt_t format, const char * password, unsigned int flags,
void * output_data, size_t * output_data_size);

🌸 ARGUMENTS 🌸

  • gnutls_x509_privkey_t key β€” this is the key, babe. it holds it. the whole main character πŸ”‘
  • gnutls_x509_crt_fmt_t format β€” the format of the output params. it's gonna be one of PEM or DER, pick your fighter ✨
  • const char * password β€” the password that gets used to encrypt the key. protect it like it's your notes app πŸ”’
  • unsigned int flags β€” an ORed sequence of gnutls_pkcs_encrypt_flags_t (so like, mash them together with ORs, iykyk) 🧚
  • void * output_data β€” this is where the private key lands, PEM or DER encoded πŸ’–
  • size_t * output_data_size β€” holds the size of output_data, and then gets replaced by the actual size of the parameters. glow up, honestly ✨

πŸ‘‘ DESCRIPTION πŸ‘‘

so what this function does is export the private key to a PKCS8 structure. both RSA and DSA keys can be exported, no gatekeeping. for DSA keys we use PKCS 11 definitions, that's just the vibe. and if the flags do NOT specify the encryption cipher, then the default 3DES (PBES2) gets used. default behavior, periodt.

the password can be either ASCII or UTF-8 in the default PBES2 encryption schemas, or ASCII for the PKCS12 schemas. so like, know which one you're in bestie πŸ™ˆ

if the buffer you provided isn't long enough to hold the output, then *output_data_size gets updated and GNUTLS_E_SHORT_MEMORY_BUFFER will be returned. classic "not me underestimating the buffer size" moment πŸ’€

if the structure is PEM encoded, it's gonna have a header of "BEGIN ENCRYPTED PRIVATE KEY" or "BEGIN PRIVATE KEY" if encryption isn't used. iconic headers, honestly 🌈


⭐ RETURNS ⭐

in case of failure a negative error code gets returned, and 0 on success. that's it. that's the whole thing 🫢


πŸŽ€ REPORTING BUGS πŸŽ€

report bugs 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, very generous of them fr fr πŸ’–)


🌟 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_x509_privkey_export_pkcs8(3) from the gnutls manual, version 3.8.13 β€” go forth and export those keys responsibly, mwah πŸ’…βœ¨

πŸ“¦ where this page comes from