Noise-C
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
handshakestate.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_HANDSHAKESTATE_H
24 #define NOISE_HANDSHAKESTATE_H
25 
27 #include <noise/protocol/dhstate.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
34 
36  (NoiseHandshakeState **state, const NoiseProtocolId *protocol_id, int role);
38  (NoiseHandshakeState **state, const char *protocol_name, int role);
42  (const NoiseHandshakeState *state, NoiseProtocolId *id);
44  (const NoiseHandshakeState *state);
46  (const NoiseHandshakeState *state);
48  (NoiseHandshakeState *state);
50  (NoiseHandshakeState *state);
54  (NoiseHandshakeState *state, const uint8_t *key, size_t key_len);
56  (NoiseHandshakeState *state, const void *prologue, size_t prologue_len);
63 int noise_handshakestate_fallback_to(NoiseHandshakeState *state, int pattern_id);
66  (NoiseHandshakeState *state, NoiseBuffer *message, const NoiseBuffer *payload);
68  (NoiseHandshakeState *state, NoiseBuffer *message, NoiseBuffer *payload);
70  (NoiseHandshakeState *state, NoiseCipherState **send, NoiseCipherState **receive);
72  (const NoiseHandshakeState *state, uint8_t *hash, size_t max_len);
73 
74 #ifdef __cplusplus
75 };
76 #endif
77 
78 #endif
Noise protocol name broken out into separate identifier fields.
Definition: names.h:33
int noise_handshakestate_has_pre_shared_key(const NoiseHandshakeState *state)
Determine if a HandshakeState object has already been configured with a pre shared key...
DHState interface.
int noise_handshakestate_get_role(const NoiseHandshakeState *state)
Gets the role that a HandshakeState object is playing.
int noise_handshakestate_get_protocol_id(const NoiseHandshakeState *state, NoiseProtocolId *id)
Gets the protocol identifier associated with a HandshakeState object.
size_t prologue_len
Length of the prologue value in bytes.
Definition: internal.h:585
int noise_handshakestate_read_message(NoiseHandshakeState *state, NoiseBuffer *message, NoiseBuffer *payload)
Reads a message payload using a HandshakeState.
int noise_handshakestate_get_handshake_hash(const NoiseHandshakeState *state, uint8_t *hash, size_t max_len)
Gets the handshake hash value once the handshake ends.
int noise_handshakestate_fallback(NoiseHandshakeState *state)
Falls back to the "XXfallback" handshake pattern.
int noise_handshakestate_free(NoiseHandshakeState *state)
Frees a HandshakeState object after destroying all sensitive material.
int noise_handshakestate_new_by_id(NoiseHandshakeState **state, const NoiseProtocolId *protocol_id, int role)
Creates a new HandshakeState object by protocol identifier.
int noise_handshakestate_needs_pre_shared_key(const NoiseHandshakeState *state)
Determine if a HandshakeState object requires a pre shared key.
int noise_handshakestate_set_pre_shared_key(NoiseHandshakeState *state, const uint8_t *key, size_t key_len)
Sets the pre shared key for a HandshakeState.
int noise_handshakestate_write_message(NoiseHandshakeState *state, NoiseBuffer *message, const NoiseBuffer *payload)
Writes a message payload using a HandshakeState.
Internal structure of the NoiseDHState type.
Definition: internal.h:213
NoiseDHState * noise_handshakestate_get_fixed_ephemeral_dh(NoiseHandshakeState *state)
Gets the DHState object that contains the local ephemeral keypair.
NoiseDHState * noise_handshakestate_get_local_keypair_dh(const NoiseHandshakeState *state)
Gets the DHState object that contains the local static keypair.
int noise_handshakestate_needs_remote_public_key(const NoiseHandshakeState *state)
Determine if a HandshakeState still needs to be configured with a remote public key before the protoc...
int noise_handshakestate_set_prologue(NoiseHandshakeState *state, const void *prologue, size_t prologue_len)
Sets the prologue for a HandshakeState.
int noise_handshakestate_get_action(const NoiseHandshakeState *state)
Gets the next action the application should perform for the handshake phase of the protocol...
int noise_handshakestate_split(NoiseHandshakeState *state, NoiseCipherState **send, NoiseCipherState **receive)
Splits the transport encryption CipherState objects out of this HandshakeState object.
int role
The role of this object, initiator or responder.
Definition: internal.h:537
NoiseDHState * noise_handshakestate_get_remote_public_key_dh(const NoiseHandshakeState *state)
Gets the DHState object that contains the remote static public key.
uint8_t * prologue
Points to the prologue value.
Definition: internal.h:582
SymmetricState interface.
int noise_handshakestate_needs_local_keypair(const NoiseHandshakeState *state)
Determine if a HandshakeState still needs to be configured with a local keypair.
Internal structure of the NoiseCipherState type.
Definition: internal.h:58
int noise_handshakestate_fallback_to(NoiseHandshakeState *state, int pattern_id)
Falls back to another handshake pattern.
NoiseDHState * noise_handshakestate_get_fixed_hybrid_dh(NoiseHandshakeState *state)
Gets the DHState object that contains the local additional hybrid secrecy keypair.
int noise_handshakestate_has_remote_public_key(const NoiseHandshakeState *state)
Determine if a HandshakeState has a remote public key.
int noise_handshakestate_new_by_name(NoiseHandshakeState **state, const char *protocol_name, int role)
Creates a new HandshakeState object by protocol name.
int noise_handshakestate_start(NoiseHandshakeState *state)
Starts the handshake on a HandshakeState object.
Internal structure of the NoiseHandshakeState type.
Definition: internal.h:531
Type that defines a region of memory for a data buffer.
Definition: buffer.h:33
int noise_handshakestate_has_local_keypair(const NoiseHandshakeState *state)
Determine if a HandshakeState has been configured with a local keypair.