gnutls_privkey_generate(3)

πŸ’– gnutls_privkey_generate(3) πŸ’–

okay bestie, welcome to the gnutls corner of the man pages, this one lives in the gnutls manual and it's literally all about making brand new private keys out of ✨nothing✨


🌸 NAME 🌸

gnutls_privkey_generate β€” API function. that's it, that's the name, she's an API function and she's iconic πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <gnutls/abstract.h>

int gnutls_privkey_generate(gnutls_privkey_t pkey, gnutls_pk_algorithm_t
algo, unsigned int bits, unsigned int flags);

look at her. four little arguments. so demure, so mindful πŸ¦‹


🫢 ARGUMENTS 🫢

  • gnutls_privkey_t pkey β€” an initialized private key. yes babes, initialized first, she can't work with a blank slate, we talked about this 😭
  • gnutls_pk_algorithm_t algo β€” is one of the algorithms in gnutls_pk_algorithm_t. pick your fighter πŸ’œ
  • unsigned int bits β€” the size of the parameters to generate. how much key do you want, bestie, because you're getting exactly that many bits
  • unsigned int flags β€” Must be zero or flags from gnutls_privkey_flags_t. zero. or flags. no in-between πŸ™ˆ

🌈 DESCRIPTION 🌈

so this function will generate a random private key. random. fresh out the oven, no cap πŸ”₯ and note that this function must be called on an initialized private key β€” do not come to her with an uninitialized key, she will simply not πŸ’€

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. very demure, very FIPS, very "my parameters have receipts" ✨ see gnutls_privkey_generate2() for more information.

πŸ“Œ 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 the macro is any curve from gnutls_ecc_curve_t. so like, you don't have to count bits by hand, the macro does it for you, she's so helpful 🧚

for DSA keys, if the subgroup size needs to be specified check the GNUTLS_SUBGROUP_TO_BITS() macro. another macro, another slay πŸ’…

it is recommended to do not set the number of bits directly, use gnutls_sec_param_to_pk_bits() instead . fr fr, let the security-parameter function pick your bits, she knows what she's doing πŸ‘‘

see also gnutls_privkey_generate2(). yes she has a sequel, and yes the sequel ate πŸ“


⭐ RETURNS ⭐

on success, GNUTLS_E_SUCCESS (0) is returned, otherwise a negative error value. so 0 = we ate, negative = we did not eat 😭


πŸ’œ SINCE πŸ’œ

3.3.0 β€” she's been around since 3.3.0, a true veteran of the group chat, main character energy since day one πŸ‘‘


🌸 REPORTING BUGS 🌸

report bugs to <bugs@gnutls.org>. home page: https://www.gnutls.org

(if you found a bug, tell them, they want to know, don't be shy bestie 🫢)


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 like, copy it, share it, remix it, just keep the copyright notice and this notice, periodt πŸ’–)


πŸ¦‹ 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/

go read the full thing, iykyk, it's giving ✨comprehensive✨


and that's the whole page, bestie!! this was gnutls 3.8.13, signed, sealed, delivered by your favorite manpage girly πŸ’… mwah, go generate some keys responsibly πŸŽ€βœ¨

πŸ“¦ where this page comes from