Contains the primary public API for Elliptic Curve Diffie-Hellman (ECDH) using NIST prime curves. More...
#include "qsccommon.h"Go to the source code of this file.
Functions | |
| QSC_EXPORT_API void | qsc_ecdh_public_from_private (uint8_t *publickey, const uint8_t *privatekey) |
| Derives a public key from an existing private key. | |
| QSC_EXPORT_API bool | qsc_ecdh_generate_keypair (uint8_t *publickey, uint8_t *privatekey, bool(*rng_generate)(uint8_t *, size_t)) |
| Generates public and private keys for the ECDH key encapsulation mechanism. | |
| QSC_EXPORT_API bool | qsc_ecdh_generate_seeded_keypair (uint8_t *publickey, uint8_t *privatekey, const uint8_t *seed) |
| Generates public and private keys for the ECDH key encapsulation mechanism using a seed. | |
| QSC_EXPORT_API bool | qsc_ecdh_key_exchange (uint8_t *secret, const uint8_t *privatekey, const uint8_t *publickey) |
| Decapsulates the shared secret for a given cipher-text using a private-key. | |
Contains the primary public API for Elliptic Curve Diffie-Hellman (ECDH) using NIST prime curves.
This header defines the API for the Elliptic Curve Diffie-Hellman (ECDH) key agreement mechanism over the NIST prime field curves P-256, P-384, and P-521. The implementation supports generation of elliptic curve key pairs (random or seeded) and computation of a shared secret using a peer's public key.
The construction follows the ECDH primitive defined in NIST SP 800-56A and is compatible with the domain parameters specified in FIPS 186-4 / FIPS 186-5. The implementation reuses the underlying field arithmetic and point operations provided by the corresponding NIST ECDSA implementations (P-256, P-384, P-521).
Scalar multiplication is performed in constant time to mitigate timing and side-channel attacks. Public key validation and coordinate checks are expected to conform to the requirements defined in NIST SP 800-56A.
| QSC_EXPORT_API bool qsc_ecdh_generate_keypair | ( | uint8_t * | publickey, |
| uint8_t * | privatekey, | ||
| bool(* | rng_generate )(uint8_t *, size_t) ) |
Generates public and private keys for the ECDH key encapsulation mechanism.
| publickey | [uint8_t*] Pointer to the output public-key array. |
| privatekey | [uint8_t*] Pointer to the output private-key array. |
| rng_generate | [bool (*)(uint8_t*, size_t)] Pointer to the random generator function. |
| QSC_EXPORT_API bool qsc_ecdh_generate_seeded_keypair | ( | uint8_t * | publickey, |
| uint8_t * | privatekey, | ||
| const uint8_t * | seed ) |
Generates public and private keys for the ECDH key encapsulation mechanism using a seed.
| publickey | [uint8_t*] Pointer to the output public-key array. |
| privatekey | [uint8_t*] Pointer to the output private-key array. |
| seed | [const uint8_t*] Pointer to the random seed. |
| QSC_EXPORT_API bool qsc_ecdh_key_exchange | ( | uint8_t * | secret, |
| const uint8_t * | privatekey, | ||
| const uint8_t * | publickey ) |
Decapsulates the shared secret for a given cipher-text using a private-key.
| secret | [uint8_t*] Pointer to the shared secret key array. |
| privatekey | [const uint8_t*] Pointer to the private-key array. |
| publickey | [const uint8_t*] Pointer to the public-key array. |
| QSC_EXPORT_API void qsc_ecdh_public_from_private | ( | uint8_t * | publickey, |
| const uint8_t * | privatekey ) |
Derives a public key from an existing private key.
The private key is interpreted as 32 raw bytes. Scalar clamping is applied internally during public key derivation, as specified by RFC 7748.
This function is intended for use when importing or reconstructing keys from external representations such as PKCS#8 or application-defined storage.
| publickey | [uint8_t*] Pointer to the output public-key array. |
| privatekey | [const uint8_t*] Pointer to the input private-key array. |