ASCON Suite
hkdf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 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 ASCON_HKDF_H
24 #define ASCON_HKDF_H
25 
26 #include <stddef.h>
27 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
43 #define ASCON_HKDF_OUTPUT_SIZE 32
44 
48 typedef struct
49 {
51  unsigned char prk[ASCON_HKDF_OUTPUT_SIZE];
52 
54  unsigned char out[ASCON_HKDF_OUTPUT_SIZE];
55 
57  unsigned char counter;
58 
60  unsigned char posn;
61 
63 
67 typedef struct
68 {
70  unsigned char prk[ASCON_HKDF_OUTPUT_SIZE];
71 
73  unsigned char out[ASCON_HKDF_OUTPUT_SIZE];
74 
76  unsigned char counter;
77 
79  unsigned char posn;
80 
82 
101  (unsigned char *out, size_t outlen,
102  const unsigned char *key, size_t keylen,
103  const unsigned char *salt, size_t saltlen,
104  const unsigned char *info, size_t infolen);
105 
119  const unsigned char *key, size_t keylen,
120  const unsigned char *salt, size_t saltlen);
121 
136  const unsigned char *info, size_t infolen,
137  unsigned char *out, size_t outlen);
138 
145 
164  (unsigned char *out, size_t outlen,
165  const unsigned char *key, size_t keylen,
166  const unsigned char *salt, size_t saltlen,
167  const unsigned char *info, size_t infolen);
168 
182  const unsigned char *key, size_t keylen,
183  const unsigned char *salt, size_t saltlen);
184 
199  const unsigned char *info, size_t infolen,
200  unsigned char *out, size_t outlen);
201 
208 
209 #ifdef __cplusplus
210 }
211 #endif
212 
213 #endif
void ascon_hkdfa_extract(ascon_hkdfa_state_t *state, const unsigned char *key, size_t keylen, const unsigned char *salt, size_t saltlen)
Extracts entropy from a key and salt for ASCON-HKDFA.
int ascon_hkdf(unsigned char *out, size_t outlen, const unsigned char *key, size_t keylen, const unsigned char *salt, size_t saltlen, const unsigned char *info, size_t infolen)
Derives key material using ASCON-HKDF.
void ascon_hkdf_extract(ascon_hkdf_state_t *state, const unsigned char *key, size_t keylen, const unsigned char *salt, size_t saltlen)
Extracts entropy from a key and salt for ASCON-HKDF.
int ascon_hkdfa_expand(ascon_hkdfa_state_t *state, const unsigned char *info, size_t infolen, unsigned char *out, size_t outlen)
Expands key material using a ASCON-HKDFA state.
int ascon_hkdf_expand(ascon_hkdf_state_t *state, const unsigned char *info, size_t infolen, unsigned char *out, size_t outlen)
Expands key material using a ASCON-HKDF state.
void ascon_hkdfa_free(ascon_hkdfa_state_t *state)
Frees all sensitive material in a ASCON-HKDFA state.
void ascon_hkdf_free(ascon_hkdf_state_t *state)
Frees all sensitive material in a ASCON-HKDF state.
#define ASCON_HKDF_OUTPUT_SIZE
Default output block size for ASCON-HKDF and ASCON-HKDFA. Key material is generated in blocks of this...
Definition: hkdf.h:43
int ascon_hkdfa(unsigned char *out, size_t outlen, const unsigned char *key, size_t keylen, const unsigned char *salt, size_t saltlen, const unsigned char *info, size_t infolen)
Derives key material using ASCON-HKDFA.
ascon_state_t state
[snippet_key]
Definition: snippets.c:2
State for incremental generation of key material from ASCON-HKDF.
Definition: hkdf.h:49
unsigned char posn
Definition: hkdf.h:60
unsigned char counter
Definition: hkdf.h:57
State for incremental generation of key material from ASCON-HKDFA.
Definition: hkdf.h:68
unsigned char posn
Definition: hkdf.h:79
unsigned char counter
Definition: hkdf.h:76