hcrypto_dh(3)
π hcrypto_dh β Diffie-Hellman functions π
okay bestie, sit down, hydrate, because we're doing Diffie-Hellman from the Heimdal crypto library and it's honestly giving cryptography main character energy πβ¨
β¨ SYNOPSIS β¨
π«Ά Functions π«Ά
no cap, here's the whole squad, exactly as they come:
const DH_METHOD * DH_ltm_method (void)
DH * DH_new (void)
DH * DH_new_method (ENGINE *engine)
void DH_free (DH *dh)
int DH_up_ref (DH *dh)
int DH_size (const DH *dh)
int DH_set_ex_data (DH *dh, int idx, void *data)
void * DH_get_ex_data (DH *dh, int idx)
int DH_generate_parameters_ex (DH *dh, int prime_len, int generator,
BN_GENCB *cb)
int DH_check_pubkey (const DH *dh, const BIGNUM *pub_key, int *codes)
int DH_generate_key (DH *dh)
int DH_compute_key (unsigned char *shared_key, const BIGNUM
*peer_pub_key, DH *dh)
int DH_set_method (DH *dh, const DH_METHOD *method)
const DH_METHOD * DH_null_method (void)
void DH_set_default_method (const DH_METHOD *meth)
const DH_METHOD * DH_get_default_method (void)
π Detailed Description π
See the DH - Diffie-Hellman key exchange for description and examples. that's it, that's the whole vibe β go read that one for the lore and the examples π
π Function Documentation π
π¦ int DH_check_pubkey (const DH * dh, const BIGNUM * pub_key, int * codes) π¦
girl, we're doing a vibe check on the public key. is it sane? is it normal? let's find out π΅οΈβοΈ
Parameters
dhβ the local peer DH parameters.pub_keyβ the remote peer public key parameters.codesβ return that the failures of thepub_keyare.
Returns
1 on success, 0 on failure and *codes is set the the combined fail check for the public key. (yes, "the the", that's how it's written, i don't make the rules π)
Checks that the function performs are:
pub_keyis not negativepub_key> 1 andpub_key<p- 1, to avoid small subgroups attack.- if
g== 2,pub_keyhave more then one bit set, if bits set is 1,log_2(pub_key)is trival
not me protecting you from small subgroups attacks like the icon you are π«Ά
π¦ int DH_compute_key (unsigned char * shared_key, const BIGNUM * peer_pub_key, DH * dh) π¦
Complute the shared secret key. (spelling as-is, bestie, we don't touch the source π) this is the moment where you and your peer agree on a secret and it's lowkey iconic β¨
Parameters
shared_keyβ the resulting shared key, need to be at leastDH_size()large.peer_pub_keyβ the peer's public key.dhβ the dh key pair.
Returns
1 on success.
Checks that the pubkey passed in is valid using DH_check_pubkey().
π¦ void DH_free (DH * dh) π¦
Free a DH object and release related resources, like ENGINE, that the object was using. it's giving responsible adult, we love a clean exit π
Parameters
dhβ object to be freed.
π¦ int DH_generate_key (DH * dh) π¦
Generate a new DH private-public key pair. The dh parameter must be allocted first with DH_new(). dh->p and dp->g must be set.
π¨ heads up bestie: you have toDH_new()that thing first, anddh->panddp->gmust be set. no shortcuts, no cap.
Parameters
dhβ dh parameter.
Returns
1 on success.
π¦ int DH_generate_parameters_ex (DH * dh, int prime_len, int generator, BN_GENCB * cb) π¦
Generate DH parameters for the DH object give parameters. (again, their words, not mine π)
Parameters
dhβ The DH object to generate parameters for.prime_lenβ length of the primegeneratorβ generator,gcbβ Callback parameters to show progress, can beNULL.
Returns
the maximum size in bytes of the out data.
π¦ const DH_METHOD* DH_get_default_method (void) π¦
Return the default DH implementation. the one that shows up when nobody picked a fave πΈ
Returns
pointer to a DH_METHOD.
π¦ void* DH_get_ex_data (DH * dh, int idx) π¦
Get the data for index idx in the DH object. peek inside the little storage locker, slay π
Parameters
dhβ DH object.idxβ index to get the data for.
Returns
the object store in index idx
π¦ const DH_METHOD* DH_ltm_method (void) π¦
DH implementation using libtommath. math girlies rise π
Returns
the DH_METHOD for the DH implementation using libtommath.
π¦ DH* DH_new (void) π¦
Create a new DH object using DH_new_method(NULL), see DH_new_method(). brand new, fresh out the box β¨
Returns
a newly allocated DH object.
π¦ DH* DH_new_method (ENGINE * engine) π¦
Create a new DH object from the given engine, if the NULL is used, the default engine is used. Free the DH object with DH_free(). don't forget the cleanup, bestie π§Ή
Parameters
engineβ The engine to use to allocate the DH object.
Returns
a newly allocated DH object.
π¦ const DH_METHOD* DH_null_method (void) π¦
Return the dummy DH implementation. it's the nothing-burger of methods, and honestly? iconic for it π
Returns
pointer to a DH_METHOD.
π¦ void DH_set_default_method (const DH_METHOD * meth) π¦
Set the default DH implementation. choosing your fave fr fr π
Parameters
methβ pointer to aDH_METHOD.
π¦ int DH_set_ex_data (DH * dh, int idx, void * data) π¦
Set the data index idx in the DH object to data. tuck it in, keep it safe π
Parameters
dhβ DH object.idxβ index to set the data for.dataβ data to store for the indexidx.
Returns
1 on success.
π¦ int DH_set_method (DH * dh, const DH_METHOD * method) π¦
Set a new method for the DH keypair. glow-up time π₯
Parameters
dhβ dh parameter.methodβ the new method for the DH parameter.
Returns
1 on success.
π¦ int DH_size (const DH * dh) π¦
The maximum output size of the DH_compute_key() function. how much room you need to give that shared key, periodt π
Parameters
dhβ The DH object to get the size from.
Returns
the maximum size in bytes of the out data.
π¦ int DH_up_ref (DH * dh) π¦
Add a reference to the DH object. The object should be free with DH_free() to drop the reference. keeping the party alive a little longer π«Ά
Parameters
dhβ the object to increase the reference count too.
Returns
the updated reference count, can't safely be used except for debug printing.
β οΈ fr fr: that return value is for debug printing only. do not build logic on it, it will not love you back π
π Author π
Generated automatically by Doxygen for Heimdal crypto library from the source code. so technically the author is a robot and we respect the robot π€π
and that's the whole page, bestie!! you now know every single function, every parameter, every return value, and every check. no skips, no summaries, we ate and left no crumbs π
this was hcrypto_dh(3) from Version 7.8.0, dated Tue Nov 15 2022 β Heimdal crypto library, out. mwah π
π¦ where this page comes from
- alpine 3.22: heimdal-doc 7.8.0-r4 Β· BSD-3-Clause
- alpine 3.23: heimdal-doc 7.8.0-r5 Β· BSD-3-Clause
- alpine 3.24: heimdal-doc 7.8.0-r5 Β· BSD-3-Clause
- epel 10: heimdal-devel 7.8.0-26.el10_2 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- epel 9: heimdal-devel 7.8.0-5.el9 Β· BSD and MIT
- fedora 43: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 43: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-28.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-28.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms