gnutls_pkcs11_privkey_generate3(3)

πŸ’– gnutls_pkcs11_privkey_generate3 πŸ’–

okay bestie, so this one lives in the gnutls manual, and it's literally the glow-up machine for private keys. it's an API function, it's iconic, and we're gonna go through it together. grab a strawberry πŸ“


✨ NAME ✨

gnutls_pkcs11_privkey_generate3 β€” API function


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnutls/pkcs11.h>

int gnutls_pkcs11_privkey_generate3(const char * url,
gnutls_pk_algorithm_t pk, unsigned int bits, const char * label, const
gnutls_datum_t * cid, gnutls_x509_crt_fmt_t fmt, gnutls_datum_t *
pubkey, unsigned int key_usage, unsigned int flags);

πŸŽ€ ARGUMENTS πŸŽ€

  • const char * url β€” a token URL. this is where the magic happens, the address of the lil token that's gonna hold your new key ✨
  • gnutls_pk_algorithm_t pk β€” the public key algorithm. which flavor of key are we making, bestie
  • unsigned int bits β€” the security bits. how much security are we giving πŸ’…
  • const char * label β€” a label. a cute lil name tag for your key
  • const gnutls_datum_t * cid β€” the CKA_ID to use for the new object
  • gnutls_x509_crt_fmt_t fmt β€” the format of output params. PEM or DER
  • gnutls_datum_t * pubkey β€” will hold the public key (may be NULL)
  • unsigned int key_usage β€” one of GNUTLS_KEY_*
  • unsigned int flags β€” zero, or an OR'ed sequence of GNUTLS_PKCS11_OBJ_FLAGs

🌸 DESCRIPTION 🌸

so basically this function will generate a private key in the token specified by the url. the private key gets generated within the token and it will not be exportable β€” no cap, it's staying home, it's not leaving the house 🏠✨

this function will store the DER-encoded public key in the SubjectPublicKeyInfo format in pubkey. and heads up: that pubkey should be deinitialized using gnutls_free().

not me forgetting to free it... bestie don't be like me, call gnutls_free() πŸ™ˆ

note that when generating an elliptic curve key, the curve can be substituted in the place of the bits parameter using the GNUTLS_CURVE_TO_BITS() macro. sneaky but iconic πŸ¦‹

since 3.6.3 the objects are marked as sensitive by default unless GNUTLS_PKCS11_OBJ_FLAG_MARK_NOT_SENSITIVE is specified. so yeah, sensitive is the default vibe now πŸ’…


⭐ RETURNS ⭐

on success, GNUTLS_E_SUCCESS (0) is returned, otherwise a negative error value. simple as that, periodt.


πŸ‘‘ SINCE πŸ‘‘

3.4.0


🌈 REPORTING BUGS 🌈

found a bug? tell the girlies at <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, go off 🫢


πŸ”₯ 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_pkcs11_privkey_generate3(3) from the gnutls manual, version 3.8.13, and it's giving main character energy fr fr. go generate some keys, stay unexportable, and remember: deinitialize with gnutls_free(). mwah πŸ’‹βœ¨πŸŽ€

πŸ“¦ where this page comes from