gnutls_privkey_derive_secret(3)

✨ gnutls_privkey_derive_secret ✨

okay bestie, welcome to the gnutls manual, page for gnutls_privkey_derive_secret πŸ’– this is the one where you take your private key and someone's public key and they do a little cryptographic handshake moment and a shared secret falls out. it's giving ✨collaboration✨. anyway sit down, hydrate, let's go 🫢


🌸 NAME 🌸

gnutls_privkey_derive_secret β€” it's an API function, no cap πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <gnutls/abstract.h>

int gnutls_privkey_derive_secret(gnutls_privkey_t privkey,
gnutls_pubkey_t pubkey, const gnutls_datum_t * nonce, gnutls_datum_t *
secret, unsigned int flags);

literally copy that exactly, don't get creative with it πŸ™ˆ


πŸ¦‹ ARGUMENTS πŸ¦‹

  • gnutls_privkey_t privkey β€” your private key, the one of type gnutls_privkey_t. this is yours, guard it with your life fr fr πŸ‘‘
  • gnutls_pubkey_t pubkey β€” the peer's public key, of type gnutls_pubkey_t. that's the other person in this little duet 🫢
  • const gnutls_datum_t * nonce β€” an optional nonce value. optional!! so you can pass one, you don't have to. it's giving "bring a plus-one if you want" πŸ’…
  • gnutls_datum_t * secret β€” this is where the shared secret gets stored. it's an out-param, so it's coming back to you filled in ✨
  • unsigned int flags β€” must be zero. that's it. zero. nothing else. do not pass go, do not pass anything else 🚫

πŸ’œ DESCRIPTION πŸ’œ

so the whole point of this function: it calculates a shared secret from our privkey and the peer's pubkey 🌈 and the result gets stored in secret.

now listen, important part, don't skip this β€” the data member of secret should be freed after use using gnutls_free(). yes, you have to clean up after yourself. it's giving "wash your own dishes" energy 😭

also, both privkey and pubkey must be backed by the X.509 keys. not optional, that's the rule, the vibe check has been performed πŸ“‹


⭐ RETURNS ⭐

  • On success, GNUTLS_E_SUCCESS (0) is returned πŸŽ‰
  • Otherwise you get a negative error value πŸ’€

that's the whole story. zero = slay, negative = not slay.


🌟 SINCE 🌟

3.8.2 β€” been around since then, an icon, an OG 🧚


πŸ’Œ REPORTING BUGS πŸ’Œ

found a bug? don't suffer in silence bestie, tell the devs:

they want to hear from you fr fr πŸ›


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 yes, you may absolutely redistribute this, they're being generous and we love that for 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/

iykyk, the real lore lives over there πŸ“š


and that's the page!! this was gnutls version 3.8.13, and we are so done here πŸ’…βœ¨ stay encrypted, stay iconic, bye bestie πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from