Noise-C
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
cipherstate.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_CIPHERSTATE_H
24 #define NOISE_CIPHERSTATE_H
25 
26 #include <noise/protocol/buffer.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
33 
35 int noise_cipherstate_new_by_name(NoiseCipherState **state, const char *name);
41  (NoiseCipherState *state, const uint8_t *key, size_t key_len);
44  (NoiseCipherState *state, const uint8_t *ad, size_t ad_len,
45  NoiseBuffer *buffer);
47  (NoiseCipherState *state, const uint8_t *ad, size_t ad_len,
48  NoiseBuffer *buffer);
51 int noise_cipherstate_set_nonce(NoiseCipherState *state, uint64_t nonce);
54 
55 #ifdef __cplusplus
56 };
57 #endif
58 
59 #endif
int noise_cipherstate_decrypt(NoiseCipherState *state, NoiseBuffer *buffer)
Decrypts a block of data with this CipherState object.
Definition: cipherstate.c:493
int noise_cipherstate_init_key(NoiseCipherState *state, const uint8_t *key, size_t key_len)
Initializes the key on a CipherState object.
Definition: cipherstate.c:222
int noise_cipherstate_get_cipher_id(const NoiseCipherState *state)
Gets the algorithm identifier for a CipherState object.
Definition: cipherstate.c:174
int noise_cipherstate_set_nonce(NoiseCipherState *state, uint64_t nonce)
Sets the nonce value for this cipherstate object.
Definition: cipherstate.c:517
int noise_cipherstate_decrypt_with_ad(NoiseCipherState *state, const uint8_t *ad, size_t ad_len, NoiseBuffer *buffer)
Decrypts a block of data with this CipherState object.
Definition: cipherstate.c:374
int noise_cipherstate_free(NoiseCipherState *state)
Frees a CipherState object after destroying all sensitive material.
Definition: cipherstate.c:152
int noise_cipherstate_get_max_mac_length(void)
Gets the maximum MAC length for the supported algorithms.
Definition: cipherstate.c:551
int noise_cipherstate_encrypt_with_ad(NoiseCipherState *state, const uint8_t *ad, size_t ad_len, NoiseBuffer *buffer)
Encrypts a block of data with this CipherState object.
Definition: cipherstate.c:294
size_t noise_cipherstate_get_mac_length(const NoiseCipherState *state)
Gets the length of packet MAC values for a CipherState object.
Definition: cipherstate.c:202
uint8_t key_len
Length of the key for this cipher in bytes.
Definition: internal.h:70
Internal structure of the NoiseCipherState type.
Definition: internal.h:58
int noise_cipherstate_get_max_key_length(void)
Gets the maximum key length for the supported algorithms.
Definition: cipherstate.c:541
Buffer management.
int noise_cipherstate_new_by_name(NoiseCipherState **state, const char *name)
Creates a new CipherState object by its algorithm name.
Definition: cipherstate.c:122
int noise_cipherstate_new_by_id(NoiseCipherState **state, int id)
Creates a new CipherState object by its algorithm identifier.
Definition: cipherstate.c:77
int noise_cipherstate_encrypt(NoiseCipherState *state, NoiseBuffer *buffer)
Encrypts a block of data with this CipherState object.
Definition: cipherstate.c:451
int noise_cipherstate_has_key(const NoiseCipherState *state)
Determine if the key has been set on a CipherState object.
Definition: cipherstate.c:247
size_t noise_cipherstate_get_key_length(const NoiseCipherState *state)
Gets the length of the encryption key for a CipherState object.
Definition: cipherstate.c:188
Type that defines a region of memory for a data buffer.
Definition: buffer.h:33