Noise-C
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
hashstate.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_HASHSTATE_H
24 #define NOISE_HASHSTATE_H
25 
26 #include <stddef.h>
27 #include <stdint.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
34 
35 int noise_hashstate_new_by_id(NoiseHashState **state, int id);
36 int noise_hashstate_new_by_name(NoiseHashState **state, const char *name);
43  (NoiseHashState *state, const uint8_t *data, size_t data_len);
45  (NoiseHashState *state, uint8_t *hash, size_t hash_len);
47  (NoiseHashState *state, const uint8_t *data, size_t data_len,
48  uint8_t *hash, size_t hash_len);
50  (NoiseHashState *state, const uint8_t *data1, size_t data1_len,
51  const uint8_t *data2, size_t data2_len, uint8_t *hash, size_t hash_len);
53  (NoiseHashState *state, const uint8_t *key, size_t key_len,
54  const uint8_t *data, size_t data_len,
55  uint8_t *output1, size_t output1_len,
56  uint8_t *output2, size_t output2_len);
58  (NoiseHashState *state, const uint8_t *passphrase, size_t passphrase_len,
59  const uint8_t *salt, size_t salt_len, size_t iterations,
60  uint8_t *output, size_t output_len);
63 
64 #ifdef __cplusplus
65 };
66 #endif
67 
68 #endif
uint16_t hash_len
Length of the output from this hash algorithm.
Definition: internal.h:160
int noise_hashstate_pbkdf2(NoiseHashState *state, const uint8_t *passphrase, size_t passphrase_len, const uint8_t *salt, size_t salt_len, size_t iterations, uint8_t *output, size_t output_len)
Hashes a passphrase and salt using the PBKDF2 key derivation function.
Definition: hashstate.c:542
Internal structure of the NoiseHashState type.
Definition: internal.h:151
int noise_hashstate_get_max_hash_length(void)
Gets the maximum hash length for the supported algorithms.
Definition: hashstate.c:603
int noise_hashstate_reset(NoiseHashState *state)
Resets the hash state.
Definition: hashstate.c:221
int noise_hashstate_new_by_id(NoiseHashState **state, int id)
Creates a new HashState object by its algorithm identifier.
Definition: hashstate.c:73
int noise_hashstate_new_by_name(NoiseHashState **state, const char *name)
Creates a new HashState object by its algorithm name.
Definition: hashstate.c:126
int noise_hashstate_hash_one(NoiseHashState *state, const uint8_t *data, size_t data_len, uint8_t *hash, size_t hash_len)
Hashes a single data buffer and returns the hash value.
Definition: hashstate.c:309
size_t noise_hashstate_get_block_length(const NoiseHashState *state)
Gets the length of the block for a HashState object.
Definition: hashstate.c:206
int noise_hashstate_get_max_block_length(void)
Gets the maximum block length for the supported algorithms.
Definition: hashstate.c:613
int noise_hashstate_hkdf(NoiseHashState *state, const uint8_t *key, size_t key_len, const uint8_t *data, size_t data_len, uint8_t *output1, size_t output1_len, uint8_t *output2, size_t output2_len)
Hashes input data with a key to generate two output values.
Definition: hashstate.c:477
int noise_hashstate_finalize(NoiseHashState *state, uint8_t *hash, size_t hash_len)
Finalizes the hash state and returns the hash value.
Definition: hashstate.c:272
int noise_hashstate_get_hash_id(const NoiseHashState *state)
Gets the algorithm identifier for a HashState object.
Definition: hashstate.c:178
int noise_hashstate_free(NoiseHashState *state)
Frees a HashState object after destroying all sensitive material.
Definition: hashstate.c:156
int noise_hashstate_update(NoiseHashState *state, const uint8_t *data, size_t data_len)
Updates the hash state with more data.
Definition: hashstate.c:245
size_t noise_hashstate_get_hash_length(const NoiseHashState *state)
Gets the length of the hash output for a HashState object.
Definition: hashstate.c:192
int noise_hashstate_hash_two(NoiseHashState *state, const uint8_t *data1, size_t data1_len, const uint8_t *data2, size_t data2_len, uint8_t *hash, size_t hash_len)
Hashes the concatenation of two data buffers and returns the combined hash value. ...
Definition: hashstate.c:352