QSC Post Quantum Cryptographic Library 1.3.0.0 (C1)
A post quantum secure library written in Ansi C
Loading...
Searching...
No Matches
ecdhp384base.h File Reference

Elliptic Curve Diffie-Hellman over the NIST P-384 domain. More...

#include "qsccommon.h"

Go to the source code of this file.

Macros

#define QSC_ECDHP384_PUBLICKEY_SIZE   96U
#define QSC_ECDHP384_PRIVATEKEY_SIZE   48U
 The byte size of a P-384 private key.
#define QSC_ECDHP384_SHAREDSECRET_SIZE   48U
 The byte size of the derived P-384 shared secret.
#define QSC_ECDHP384_SEED_SIZE   48U
 The byte size of the deterministic seed used to derive a P-384 key-pair.

Functions

QSC_EXPORT_API void qsc_p384_public_from_private (uint8_t *publickey, const uint8_t *privatekey)
 Derive a serialized P-384 public key from a private key.
QSC_EXPORT_API void qsc_p384_generate_keypair (uint8_t *publickey, uint8_t *privatekey, bool(*rng_generate)(uint8_t *, size_t))
 Generate a random P-384 public and private key-pair.
QSC_EXPORT_API void qsc_p384_generate_seeded_keypair (uint8_t *publickey, uint8_t *privatekey, const uint8_t *seed)
 Generate a deterministic P-384 public and private key-pair from a seed.
QSC_EXPORT_API bool qsc_p384_key_exchange (uint8_t *secret, const uint8_t *publickey, const uint8_t *privatekey)
 Derive a P-384 shared secret using a peer public key and a local private key.

Detailed Description

Elliptic Curve Diffie-Hellman over the NIST P-384 domain.

This header exposes the low-level public interface for the QSC P-384 Elliptic Curve Diffie-Hellman implementation. The functions in this module provide private to public key derivation, random or seed-based key-pair generation, and shared secret derivation using a peer public key and a local private key.

The public key is encoded as a fixed-size byte array of QSC_ECDHP384_PUBLICKEY_SIZE bytes. The private key, shared secret, and deterministic seed are each encoded as fixed-size byte arrays of their respective constant sizes.

This interface is intended for base ECDH key establishment operations. Callers are responsible for providing correctly sized buffers and, where applicable, a cryptographically secure random generator callback.

Example:

uint8_t puba[QSC_ECDHP384_PUBLICKEY_SIZE];
uint8_t pubb[QSC_ECDHP384_PUBLICKEY_SIZE];
qsc_p384_generate_keypair(puba, pria, rng_generate);
qsc_p384_generate_keypair(pubb, prib, rng_generate);
if (qsc_p384_key_exchange(seca, pubb, pria) == true &&
qsc_p384_key_exchange(secb, puba, prib) == true)
{
// seca and secb should contain the same shared secret
}
QSC_EXPORT_API bool qsc_p384_key_exchange(uint8_t *secret, const uint8_t *publickey, const uint8_t *privatekey)
Derive a P-384 shared secret using a peer public key and a local private key.
Definition ecdhp384base.c:948
QSC_EXPORT_API void qsc_p384_generate_keypair(uint8_t *publickey, uint8_t *privatekey, bool(*rng_generate)(uint8_t *, size_t))
Generate a random P-384 public and private key-pair.
Definition ecdhp384base.c:926
#define QSC_ECDHP384_PRIVATEKEY_SIZE
The byte size of a P-384 private key.
Definition ecdhp384base.h:58
#define QSC_ECDHP384_SHAREDSECRET_SIZE
The byte size of the derived P-384 shared secret.
Definition ecdhp384base.h:64

Function Documentation

◆ qsc_p384_generate_keypair()

QSC_EXPORT_API void qsc_p384_generate_keypair ( uint8_t * publickey,
uint8_t * privatekey,
bool(* rng_generate )(uint8_t *, size_t) )

Generate a random P-384 public and private key-pair.

Parameters
publickey[uint8_t*] The output buffer that receives the serialized public key; must be at least QSC_ECDHP384_PUBLICKEY_SIZE bytes.
privatekey[uint8_t*] The output buffer that receives the private key; must be at least QSC_ECDHP384_PRIVATEKEY_SIZE bytes.
rng_generate[bool (*)(uint8_t*, size_t)] A pointer to a cryptographically secure random generator function that fills a buffer with random bytes and returns true on success.
Returns
[void] This function does not return a value.

◆ qsc_p384_generate_seeded_keypair()

QSC_EXPORT_API void qsc_p384_generate_seeded_keypair ( uint8_t * publickey,
uint8_t * privatekey,
const uint8_t * seed )

Generate a deterministic P-384 public and private key-pair from a seed.

Parameters
publickey[uint8_t*] The output buffer that receives the serialized public key; must be at least QSC_ECDHP384_PUBLICKEY_SIZE bytes.
privatekey[uint8_t*] The output buffer that receives the private key; must be at least QSC_ECDHP384_PRIVATEKEY_SIZE bytes.
seed[const uint8_t*] The input seed buffer; must contain QSC_ECDHP384_SEED_SIZE bytes.
Returns
[void] This function does not return a value.

◆ qsc_p384_key_exchange()

QSC_EXPORT_API bool qsc_p384_key_exchange ( uint8_t * secret,
const uint8_t * publickey,
const uint8_t * privatekey )

Derive a P-384 shared secret using a peer public key and a local private key.

Parameters
secret[uint8_t*] The output buffer that receives the shared secret; must be at least QSC_ECDHP384_SHAREDSECRET_SIZE bytes.
publickey[const uint8_t*] The peer serialized public key; must contain QSC_ECDHP384_PUBLICKEY_SIZE bytes.
privatekey[const uint8_t*] The local private key; must contain QSC_ECDHP384_PRIVATEKEY_SIZE bytes.
Returns
[bool] Returns true if the shared secret was generated successfully; returns false on failure.

◆ qsc_p384_public_from_private()

QSC_EXPORT_API void qsc_p384_public_from_private ( uint8_t * publickey,
const uint8_t * privatekey )

Derive a serialized P-384 public key from a private key.

Parameters
publickey[uint8_t*] The output buffer that receives the serialized public key; must be at least QSC_ECDHP384_PUBLICKEY_SIZE bytes.
privatekey[const uint8_t*] The input private key buffer; must contain QSC_ECDHP384_PRIVATEKEY_SIZE bytes.
Returns
[void] This function does not return a value.