Noise-C
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
signstate.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Southern Storm Software, Pty Ltd.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef NOISE_SIGNSTATE_H
24 #define NOISE_SIGNSTATE_H
25 
26 #include <stddef.h>
27 #include <stdint.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
34 
35 int noise_signstate_new_by_id(NoiseSignState **state, int id);
36 int noise_signstate_new_by_name(NoiseSignState **state, const char *name);
46  (NoiseSignState *state, const uint8_t *private_key, size_t private_key_len,
47  const uint8_t *public_key, size_t public_key_len);
49  (NoiseSignState *state, const uint8_t *private_key, size_t private_key_len);
51  (const NoiseSignState *state, uint8_t *private_key, size_t private_key_len,
52  uint8_t *public_key, size_t public_key_len);
54  (NoiseSignState *state, const uint8_t *public_key, size_t public_key_len);
56  (const NoiseSignState *state, uint8_t *public_key, size_t public_key_len);
59  (const NoiseSignState *state, const uint8_t *message, size_t message_len,
60  uint8_t *signature, size_t signature_len);
62  (const NoiseSignState *state, const uint8_t *message, size_t message_len,
63  const uint8_t *signature, size_t signature_len);
64 int noise_signstate_copy(NoiseSignState *state, const NoiseSignState *from);
66  (const NoiseSignState *state, int fingerprint_type,
67  char *buffer, size_t len);
70 
71 #ifdef __cplusplus
72 };
73 #endif
74 
75 #endif
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.
Definition: signstate.c:482
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.
Definition: signstate.c:352
Internal structure of the NoiseSignState type.
Definition: internal.h:362
uint8_t * public_key
Points to the public key in the subclass state.
Definition: internal.h:386
int noise_signstate_new_by_name(NoiseSignState **state, const char *name)
Creates a new SignState object by its algorithm name.
Definition: signstate.c:108
size_t noise_signstate_get_private_key_length(const NoiseSignState *state)
Gets the length of the private key for a SignState object.
Definition: signstate.c:190
int noise_signstate_get_max_key_length(void)
Gets the maximum length of signing keys for the supported algorithms.
Definition: signstate.c:677
size_t noise_signstate_get_public_key_length(const NoiseSignState *state)
Gets the length of the public key for a SignState object.
Definition: signstate.c:175
int noise_signstate_free(NoiseSignState *state)
Frees a SignState object after destroying all sensitive material.
Definition: signstate.c:138
int noise_signstate_get_sign_id(const NoiseSignState *state)
Gets the algorithm identifier for a SignState object.
Definition: signstate.c:160
int noise_signstate_has_public_key(const NoiseSignState *state)
Determine if a SignState object contains a public key.
Definition: signstate.c:242
int noise_signstate_get_max_signature_length(void)
Gets the maximum length of signatures for the supported algorithms.
Definition: signstate.c:687
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.
Definition: signstate.c:652
size_t noise_signstate_get_signature_length(const NoiseSignState *state)
Gets the length of the signature for a SignState object.
Definition: signstate.c:205
int noise_signstate_new_by_id(NoiseSignState **state, int id)
Creates a new SignState object by its algorithm identifier.
Definition: signstate.c:67
uint16_t private_key_len
Length of the private key for this algorithm in bytes.
Definition: internal.h:374
uint8_t * private_key
Points to the private key in the subclass state.
Definition: internal.h:383
uint16_t public_key_len
Length of the public key for this algorithm in bytes.
Definition: internal.h:377
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.
Definition: signstate.c:583
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.
Definition: signstate.c:301
int noise_signstate_generate_keypair(NoiseSignState *state)
Generates a new key pair within a SignState object.
Definition: signstate.c:264
uint16_t signature_len
Length of the signature for this algorithm in bytes.
Definition: internal.h:380
int noise_signstate_clear_key(NoiseSignState *state)
Clears the key in a SignState object.
Definition: signstate.c:507
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.
Definition: signstate.c:545
int noise_signstate_has_keypair(const NoiseSignState *state)
Determine if a SignState object contains a keypair.
Definition: signstate.c:222
int noise_signstate_copy(NoiseSignState *state, const NoiseSignState *from)
Copies the keys from one SignState object to another.
Definition: signstate.c:609
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.
Definition: signstate.c:395
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.
Definition: signstate.c:443