|
int | noise_dhstate_calculate (const NoiseDHState *private_key_state, const NoiseDHState *public_key_state, uint8_t *shared_key, size_t shared_key_len) |
| Performs a Diffie-Hellman calculation. More...
|
|
int | noise_dhstate_clear_key (NoiseDHState *state) |
| Clears the key in a DHState object. More...
|
|
int | noise_dhstate_copy (NoiseDHState *state, const NoiseDHState *from) |
| Copies the keys from one DHState object to another. More...
|
|
int | noise_dhstate_format_fingerprint (const NoiseDHState *state, int fingerprint_type, char *buffer, size_t len) |
| Formats the public key fingerprint for the key within a DHState. More...
|
|
int | noise_dhstate_free (NoiseDHState *state) |
| Frees a DHState object after destroying all sensitive material. More...
|
|
int | noise_dhstate_generate_dependent_keypair (NoiseDHState *state, const NoiseDHState *other) |
| Generates a new key pair within a DHState object that may depend upon the parameters from another DHState object. More...
|
|
int | noise_dhstate_generate_keypair (NoiseDHState *state) |
| Generates a new key pair within a DHState object. More...
|
|
int | noise_dhstate_get_dh_id (const NoiseDHState *state) |
| Gets the algorithm identifier for a DHState object. More...
|
|
int | noise_dhstate_get_keypair (const NoiseDHState *state, uint8_t *private_key, size_t private_key_len, uint8_t *public_key, size_t public_key_len) |
| Gets the keypair from within a DHState object. More...
|
|
size_t | noise_dhstate_get_private_key_length (const NoiseDHState *state) |
| Gets the length of the private key for a DHState object. More...
|
|
int | noise_dhstate_get_public_key (const NoiseDHState *state, uint8_t *public_key, size_t public_key_len) |
| Gets the public key value from a DHState object. More...
|
|
size_t | noise_dhstate_get_public_key_length (const NoiseDHState *state) |
| Gets the length of the public key for a DHState object. More...
|
|
int | noise_dhstate_get_role (const NoiseDHState *state) |
| Gets the role that a DHState object will play in a handshake. More...
|
|
size_t | noise_dhstate_get_shared_key_length (const NoiseDHState *state) |
| Gets the length of the shared key for a DHState object. More...
|
|
int | noise_dhstate_has_keypair (const NoiseDHState *state) |
| Determine if a DHState object contains a keypair. More...
|
|
int | noise_dhstate_has_public_key (const NoiseDHState *state) |
| Determine if a DHState object contains a public key. More...
|
|
int | noise_dhstate_is_ephemeral_only (const NoiseDHState *state) |
| Determine if a DHState object only supports ephemeral keys. More...
|
|
int | noise_dhstate_is_null_public_key (const NoiseDHState *state) |
| Determine if the public key in a DHState object has the special null value. More...
|
|
int | noise_dhstate_new_by_id (NoiseDHState **state, int id) |
| Creates a new DHState object by its algorithm identifier. More...
|
|
int | noise_dhstate_new_by_name (NoiseDHState **state, const char *name) |
| Creates a new DHState object by its algorithm name. More...
|
|
int | noise_dhstate_set_keypair (NoiseDHState *state, const uint8_t *private_key, size_t private_key_len, const uint8_t *public_key, size_t public_key_len) |
| Sets the keypair within a DHState object. More...
|
|
int | noise_dhstate_set_keypair_private (NoiseDHState *state, const uint8_t *private_key, size_t private_key_len) |
| Sets the keypair within a DHState object based on a private key only. More...
|
|
int | noise_dhstate_set_null_public_key (NoiseDHState *state) |
| Sets the public key in a DHState object to the special null value. More...
|
|
int | noise_dhstate_set_public_key (NoiseDHState *state, const uint8_t *public_key, size_t public_key_len) |
| Sets the public key in a DHState object. More...
|
|
int | noise_dhstate_set_role (NoiseDHState *state, int role) |
| Sets the role that a DHState object will play in a handshake. More...
|
|
DHState objects are used to store the keypairs for the local party or the public keys for remote parties. Once the keys have been set, noise_dhstate_calculate() can be used to perform a Diffie-Hellman operation with two DHState objects.
int noise_dhstate_format_fingerprint |
( |
const NoiseDHState * |
state, |
|
|
int |
fingerprint_type, |
|
|
char * |
buffer, |
|
|
size_t |
len |
|
) |
| |
Formats the public key fingerprint for the key within a DHState.
- Parameters
-
state | The DHState object. |
fingerprint_type | The type of fingerprint to format, NOISE_FINGERPRINT_BASIC or NOISE_FINGERPRINT_FULL. |
buffer | The buffer to write the fingerprint string to, including a terminating NUL. |
len | The length of buffer in bytes. |
- Returns
- NOISE_ERROR_NONE on success.
-
NOISE_ERROR_INVALID_PARAM if state or buffer is NULL.
-
NOISE_ERROR_INVALID_PARAM if fingerprint_type is not a supported fingerprint type.
-
NOISE_ERROR_INVALID_LENGTH if len is not large enough to hold the entire fingerprint string.
-
NOISE_ERROR_INVALID_STATE if a public key has not been set on state yet.
Fingerprints are created by hashing the public key with SHA256 and then formatting the value in hexadecimal with bytes separated by colons. If the fingerprint_type is NOISE_FINGERPRINT_BASIC, then the SHA256 hash value is truncated to the first 16 bytes. If the type is NOISE_FINGERPRINT_FULL, then the entire 32 byte hash value is formatted.
Definition at line 776 of file dhstate.c.
int noise_dhstate_set_public_key |
( |
NoiseDHState * |
state, |
|
|
const uint8_t * |
public_key, |
|
|
size_t |
public_key_len |
|
) |
| |
Sets the public key in a DHState object.
- Parameters
-
state | The DHState object. |
public_key | Points to the public key. |
public_key_len | The public key length in bytes. |
- Returns
- NOISE_ERROR_NONE on success.
-
NOISE_ERROR_INVALID_PARAM if state or public_key is NULL.
-
NOISE_ERROR_INVALID_LENGTH if public_key_len is incorrect for the algorithm.
-
NOISE_ERROR_INVALID_PUBLIC_KEY if public_key is not valid and it is not the special null value.
After this function succeeds, the DHState will only contain a public key. Any existing private key will be cleared. Thus, this function is useful to set the public key of a remote party. Use noise_dhstate_set_keypair() to set both the public and private key for the local party.
The algorithm may decide to defer NOISE_ERROR_INVALID_PUBLIC_KEY to later when the public key is actually used during noise_dhstate_calculate().
- See Also
- noise_dhstate_get_public_key(), noise_dhstate_set_keypair()
Definition at line 511 of file dhstate.c.
int noise_dhstate_set_role |
( |
NoiseDHState * |
state, |
|
|
int |
role |
|
) |
| |
Sets the role that a DHState object will play in a handshake.
- Parameters
-
state | The DHState object. |
role | The role, NOISE_ROLE_INITIATOR or NOISE_ROLE_RESPONDER, or zero if the role is unspecified. |
- Returns
- NOISE_ERROR_NONE on success.
-
NOISE_ERROR_INVALID_PARAM if state is NULL.
-
NOISE_ERROR_INVALID_PARAM if role is not one of NOISE_ROLE_INITIATOR, NOISE_ROLE_RESPONDER, or zero.
This function is intended for use with algorithms that have a different method for calculating public keys and shared secrets for the two parties in a communication. An example is the post-quantum SIDH algorithm where "Alice" and "Bob" differ in the calculations they perform.
To assist with supporting such algorithms, the HandshakeState labels DHState objects as either initiator or responder depending upon who owns that specific key. The algorithm-specific back end can then use the role information to determine which object it wants to treat as "Alice" and which object should be treated as "Bob".
- See Also
- noise_dhstate_get_role()
Definition at line 835 of file dhstate.c.