gnutls_x509_privkey_generate(3)

πŸ’… gnutls_x509_privkey_generate(3) β€” the gnutls manual, bestie edition πŸŽ€

okay so you're in the gnutls manual, section 3, and today's main character is gnutls_x509_privkey_generate ✨


πŸ¦‹ NAME πŸ¦‹

gnutls_x509_privkey_generate β€” API function. that's it, that's the name, she's an API function and she's serving 🫢


✨ SYNOPSIS ✨

#include <gnutls/x509.h>

int gnutls_x509_privkey_generate(gnutls_x509_privkey_t key,
gnutls_pk_algorithm_t algo, unsigned int bits, unsigned int flags);

🌸 ARGUMENTS 🌸

  • gnutls_x509_privkey_t key β€” an initialized key. like, she has to be initialized first, no shortcuts bestie πŸ’–
  • gnutls_pk_algorithm_t algo β€” this is one of the algorithms in gnutls_pk_algorithm_t. pick your fighter πŸ‘‘
  • unsigned int bits β€” the size of the parameters to generate. the size, the parameters, we're generating them πŸ’…
  • unsigned int flags β€” Must be zero, or flags from gnutls_privkey_flags_t. zero is always an option, just saying ✨

πŸ’œ DESCRIPTION πŸ’œ

so this function will generate a random private key. no cap, that's literally the whole job. and note β€” this function must be called on an initialized private key. not optional, not vibes-based, initialized. periodt πŸ”₯

the flag GNUTLS_PRIVKEY_FLAG_PROVABLE instructs the key generation process to use algorithms like Shawe-Taylor (from FIPS PUB186-4) which generate provable parameters out of a seed for RSA and DSA keys. fancy fancy. if you want more info on that, go check gnutls_x509_privkey_generate2(). she knows things πŸ’…

also, 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. the input to that macro is any curve from gnutls_ecc_curve_t. curve in, bits out, iconic behavior 🌈

for DSA keys, if the subgroup size needs to be specified, check the GNUTLS_SUBGROUP_TO_BITS() macro. she's got you covered πŸŽ€

it is recommended to do not set the number of bits directly β€” use gnutls_sec_param_to_pk_bits() instead. like, don't do it manually bestie, there's a whole function for that 😭

see also gnutls_privkey_generate(), gnutls_x509_privkey_generate2(). the whole friend group 🫢


⭐ RETURNS ⭐

on success, GNUTLS_E_SUCCESS (0) is returned. otherwise a negative error value. so if you see a negative number, that's the universe telling you something πŸ™ˆ


πŸ’€ 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 πŸ’–


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

okay that's the whole page bestie, you ate, go generate some keys πŸ‘‘ this was gnutls version 3.8.13, page gnutls_x509_privkey_generate(3), and the copyright vibes run 2001-2023. mwah πŸ’…βœ¨

πŸ“¦ where this page comes from