77 *state = noise_ed25519_new();
302 const uint8_t *public_key,
size_t public_key_len)
307 if (!state || !private_key || !public_key)
357 if (!state || !private_key)
396 uint8_t *public_key,
size_t public_key_len)
399 if (!state || !private_key || !public_key)
408 memset(private_key, 0, private_key_len);
409 memset(public_key, 0, public_key_len);
414 memcpy(private_key, state->
private_key, private_key_len);
415 memcpy(public_key, state->
public_key, public_key_len);
448 if (!state || !public_key)
459 memcpy(state->
public_key, public_key, public_key_len);
485 if (!state || !public_key)
493 memcpy(public_key, state->
public_key, public_key_len);
546 uint8_t *signature,
size_t signature_len)
549 if (!state || !message || !signature)
557 return (*(state->
sign))(state, message, message_len, signature);
584 const uint8_t *signature,
size_t signature_len)
587 if (!state || !message || !signature)
595 return (*(state->
verify))(state, message, message_len, signature);
653 char *buffer,
size_t len)
668 (fingerprint_type, buffer, len,
int noise_signstate_get_public_key(const NoiseSignState *state, uint8_t *public_key, size_t public_key_len)
Gets the public key value from a SignState object.
#define NOISE_ERROR_UNKNOWN_ID
Algorithm identifier is unknown.
int(* validate_keypair)(const NoiseSignState *state, const uint8_t *private_key, const uint8_t *public_key)
Validates a keypair.
int noise_signstate_set_keypair_private(NoiseSignState *state, const uint8_t *private_key, size_t private_key_len)
Sets the keypair within a SignState object based on a private key only.
#define NOISE_ERROR_INVALID_STATE
Operation cannot be performed in the current state.
Internal structure of the NoiseSignState type.
#define NOISE_ERROR_INVALID_PARAM
Invalid parameter to function; e.g. a NULL value.
uint8_t * public_key
Points to the public key in the subclass state.
int noise_signstate_new_by_name(NoiseSignState **state, const char *name)
Creates a new SignState object by its algorithm name.
#define NOISE_SIGN_CATEGORY
Category for signature algorithms.
#define NOISE_ERROR_NONE
Success, no error.
#define NOISE_SIGN_ED25519
Signature algorithm identifier for "Ed25519".
#define NOISE_KEY_TYPE_NO_KEY
int(* validate_public_key)(const NoiseSignState *state, const uint8_t *public_key)
Validates a public key.
size_t noise_signstate_get_private_key_length(const NoiseSignState *state)
Gets the length of the private key for a SignState object.
int noise_signstate_get_max_key_length(void)
Gets the maximum length of signing keys for the supported algorithms.
size_t noise_signstate_get_public_key_length(const NoiseSignState *state)
Gets the length of the public key for a SignState object.
int noise_signstate_free(NoiseSignState *state)
Frees a SignState object after destroying all sensitive material.
int(* verify)(const NoiseSignState *state, const uint8_t *message, size_t message_len, const uint8_t *signature)
Verifies a digital signature on a message.
#define NOISE_SIGN_NONE
Signature algorithm identifier that indicates "no algorithm".
int noise_format_fingerprint(int fingerprint_type, char *buffer, size_t len, const uint8_t *public_key, size_t public_key_len)
Formats the fingerprint for a raw public key value.
int noise_signstate_get_sign_id(const NoiseSignState *state)
Gets the algorithm identifier for a SignState object.
#define NOISE_KEY_TYPE_KEYPAIR
#define NOISE_ERROR_INVALID_PUBLIC_KEY
Invalid public key value.
#define NOISE_ERROR_NO_MEMORY
Insufficient memory to complete the operation.
int noise_signstate_has_public_key(const NoiseSignState *state)
Determine if a SignState object contains a public key.
#define NOISE_ERROR_UNKNOWN_NAME
Algorithm name is unknown.
int(* sign)(const NoiseSignState *state, const uint8_t *message, size_t message_len, uint8_t *signature)
Creates a signature.
#define NOISE_ERROR_INVALID_LENGTH
Invalid length specified for a key, packet, etc.
int noise_signstate_get_max_signature_length(void)
Gets the maximum length of signatures for the supported algorithms.
int noise_signstate_format_fingerprint(const NoiseSignState *state, int fingerprint_type, char *buffer, size_t len)
Formats the public key fingerprint for the key within a SignState.
uint16_t key_type
The type of key stored within this SignState object.
#define NOISE_ERROR_INVALID_PRIVATE_KEY
Invalid private key value.
void(* destroy)(NoiseSignState *state)
Destroys this SignState prior to the memory being freed.
int noise_name_to_id(int category, const char *name, size_t name_len)
Maps an algorithm name to the corresponding identifier.
size_t noise_signstate_get_signature_length(const NoiseSignState *state)
Gets the length of the signature for a SignState object.
#define NOISE_ERROR_NOT_APPLICABLE
An option was supplied that was not applicable to the selected protocol.
Internal definitions for the library.
int noise_signstate_new_by_id(NoiseSignState **state, int id)
Creates a new SignState object by its algorithm identifier.
void noise_free(void *ptr, size_t size)
Destroys the contents of a block of memory and free it.
uint16_t private_key_len
Length of the private key for this algorithm in bytes.
uint8_t * private_key
Points to the private key in the subclass state.
#define NOISE_KEY_TYPE_PUBLIC
uint16_t public_key_len
Length of the public key for this algorithm in bytes.
int noise_signstate_verify(const NoiseSignState *state, const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len)
Verifies a digital signature on a message.
int noise_signstate_set_keypair(NoiseSignState *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 SignState object.
int(* derive_public_key)(const NoiseSignState *state, const uint8_t *private_key, uint8_t *public_key)
Derives a public key from a private key.
int noise_signstate_generate_keypair(NoiseSignState *state)
Generates a new key pair within a SignState object.
uint16_t signature_len
Length of the signature for this algorithm in bytes.
int noise_signstate_clear_key(NoiseSignState *state)
Clears the key in a SignState object.
int sign_id
Algorithm identifier for the digital signature operation.
size_t size
Total size of the structure including subclass state.
int noise_signstate_sign(const NoiseSignState *state, const uint8_t *message, size_t message_len, uint8_t *signature, size_t signature_len)
Signs a message to create a digital signature.
void(* generate_keypair)(NoiseSignState *state)
Generates a new key pair for this digital signature algorithm.
int noise_signstate_has_keypair(const NoiseSignState *state)
Determine if a SignState object contains a keypair.
int noise_signstate_copy(NoiseSignState *state, const NoiseSignState *from)
Copies the keys from one SignState object to another.
int noise_signstate_get_keypair(const NoiseSignState *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 SignState object.
int noise_signstate_set_public_key(NoiseSignState *state, const uint8_t *public_key, size_t public_key_len)
Sets the public key in a SignState object.