P-256#

Key-agreement over the P-256 NIST curve.

For key-conversion functions related to P-256 see the P-256 ECDSA section.

API Reference#

bool Hacl_P256_dh_initiator(uint8_t *public_key, uint8_t *private_key)#

Compute the public key from the private key.

The function returns true if a private key is valid and false otherwise.

The outparam public_key points to 64 bytes of valid memory, i.e., uint8_t[64]. The argument private_key points to 32 bytes of valid memory, i.e., uint8_t[32].

The private key is valid: • 0 < private_key < the order of the curve.

bool Hacl_P256_dh_responder(uint8_t *shared_secret, uint8_t *their_pubkey, uint8_t *private_key)#

Execute the diffie-hellmann key exchange.

The function returns true for successful creation of an ECDH shared secret and false otherwise.

The outparam shared_secret points to 64 bytes of valid memory, i.e., uint8_t[64]. The argument their_pubkey points to 64 bytes of valid memory, i.e., uint8_t[64]. The argument private_key points to 32 bytes of valid memory, i.e., uint8_t[32].

The function also checks whether private_key and their_pubkey are valid.