ECDH_COMPUTE_KEY(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

okay bestie, welcome to ECDH_COMPUTE_KEY(3) from the Library Functions Manual β€” this is the elliptic-curve key-exchange glow-up you didn’t know you needed πŸ’…βœ¨


πŸ’– NAME πŸ’–

  • ECDH_compute_key, ECDH_size β€” Elliptic Curve Diffie-Hellman key exchange

✨ SYNOPSIS ✨

       library β€œlibcrypto” #include <openssl/ec.h>

       int
       ECDH_compute_key(void *out, size_t outlen, const EC_POINT *public_key,
           EC_KEY *ecdh,
           void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen));

       int
       ECDH_size(const EC_KEY *ecdh);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so ECDH_compute_key() performs Elliptic Curve Diffie-Hellman key agreement. it combines the private key contained in ecdh with the other party’s public_key, takes the x component of the affine coordinates, and optionally applies the key derivation function KDF. then it stores the resulting symmetric key in the buffer out, which is outlen bytes long. if KDF is NULL, outlen must be at least ECDH_size(ecdh). no cap, that part matters 😭

ECDH_size() returns the number of bytes needed to store an affine coordinate of a point on the elliptic curve used by ecdh, which is one eighth of the degree of the finite field underlying that elliptic curve, rounded up to the next integer number. it’s giving very specific math girlie and honestly? iconic πŸ”₯

🌸 RETURN VALUES 🌸

  • ECDH_compute_key() returns the length of the computed key in bytes or -1 if an error occurs.
  • ECDH_size() returns the number of bytes needed to store an affine coordinate.

πŸŽ€ SEE ALSO πŸŽ€

🧚 HISTORY 🧚

ECDH_compute_key() first appeared in OpenSSL 0.9.8 and has been available since OpenBSD 4.5.

ECDH_size() first appeared in OpenBSD 6.1.


byeee, this page is from Debian, dated June 8, 2025 β€” stay cryptographic, bestie πŸ«ΆπŸ’œ

πŸ“¦ where this page comes from