gnutls_pkcs11_privkey_generate2(3)
π gnutls_pkcs11_privkey_generate2 β the manual page, bestie edition π
okay so this is a page from the gnutls manual, and honestly? it's giving "quietly powerful little function that makes keys inside your HSM and refuses to let them leave." main character energy fr. let's get into it π«Ά
β¨ NAME β¨
gnutls_pkcs11_privkey_generate2 β it's an API function, bestie. that's the whole vibe.
πΈ SYNOPSIS πΈ
#include <gnutls/pkcs11.h>
int gnutls_pkcs11_privkey_generate2(const char * url,
gnutls_pk_algorithm_t pk, unsigned int bits, const char * label,
gnutls_x509_crt_fmt_t fmt, gnutls_datum_t * pubkey, unsigned int flags);
like yes, that's a lot of parameters. it's fine. we'll go one by one π
π ARGUMENTS π
const char * urlβ a token URL. the place where the magic happens, literally.gnutls_pk_algorithm_t pkβ the public key algorithm. what flavor of key are we cooking today.unsigned int bitsβ the security bits. size matters, and we're not pretending otherwise.const char * labelβ a label. a little name tag for your key π·οΈgnutls_x509_crt_fmt_t fmtβ the format of output params. it's either PEM or DER, pick one.gnutls_datum_t * pubkeyβ will hold the public key. heads up: this one may beNULLπunsigned int flagsβ zero, or an OR'ed sequence ofGNUTLS_PKCS11_OBJ_FLAGs. you know the ones.
π¦ DESCRIPTION π¦
so what does it DO. it generates a private key in the token specified by the url. and here's the iconic part: the private key is generated within the token and will not be exportable. it lives there. it stays there. it is not coming out. that's the whole point, bestie, that's the security model, periodt π₯
this function will store the DER-encoded public key in the SubjectPublicKeyInfo format in pubkey. and when you're done with that pubkey, you need to deinitialize it using gnutls_free(). don't ghost it, clean it up properly π§
π‘ little note, and this one's important: when you're generating an elliptic curve key, you can substitute the curve in the place of thebitsparameter using theGNUTLS_CURVE_TO_BITS()macro. cute little trick, no cap.
β RETURNS β
on success, you get GNUTLS_E_SUCCESS (which is 0, the number we all love to see π₯³). otherwise you get a negative error value, which is the universe telling you something went wrong.
π SINCE π
3.1.5 β an OG, honestly. been here since forever.
π REPORTING BUGS π
found a bug? don't suffer in silence, bestie. report bugs to <bugs@gnutls.org>.
home page: https://www.gnutls.org β go say hi π
π COPYRIGHT π
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. so share it, remix it, just keep the receipts π«Ά
π SEE ALSO π
the full documentation for gnutls is maintained as a Texinfo manual. and if the /usr/share/doc/gnutls/ directory does not contain the HTML form, then bestie, just go here:
https://www.gnutls.org/manual/
and that's the page!! this was gnutls 3.8.13, and the page is gnutls_pkcs11_privkey_generate2(3). go forth and generate keys that never leave home πβ¨ππ¦πΈπ
π¦ where this page comes from
- alpine 3.22: gnutls-doc 3.8.13-r0 Β· LGPL-2.1-or-later
- alpine 3.23: gnutls-doc 3.8.13-r0 Β· LGPL-2.1-or-later
- alpine 3.24: gnutls-doc 3.8.13-r0 Β· LGPL-2.1-or-later
- arch rolling: gnutls 3.8.13-3 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 43: gnutls-devel 3.8.13-1.fc43 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 43: gnutls-devel 3.8.13-1.fc43 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 44: gnutls-devel 3.8.13-1.fc44 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- fedora 44: gnutls-devel 3.8.13-1.fc44 Β· GPL-3.0-or-later AND LGPL-2.1-or-later
- ubuntu stonking: gnutls-doc 3.8.13-1ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms