one_step_kdf.h
Go to the documentation of this file.
1 /**
2  * @file one_step_kdf.h
3  * @brief One-Step KDF
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2026 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CyclSINGLE_CRYPTO Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.6.6
29  **/
30 
31 #ifndef _ONE_STEP_KDF_H
32 #define _ONE_STEP_KDF_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 
37 //Default salt length for KMAC128
38 #define ONE_STEP_KDF_KMAC128_DEFAULT_SALT_LEN 164
39 //Default salt length for KMAC256
40 #define ONE_STEP_KDF_KMAC256_DEFAULT_SALT_LEN 132
41 
42 //C++ guard
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 
48 /**
49  * @brief One-Step KDF auxiliary functions
50  **/
51 
52 typedef enum
53 {
59 
60 
61 //One-Step KDF related functions
63  const uint8_t *z, size_t zLen, const uint8_t *salt, size_t saltLen,
64  const uint8_t *otherInfo, size_t otherInfoLen, uint8_t *dk, size_t dkLen);
65 
66 error_t oneStepKdfHash(const HashAlgo *hashAlgo, const uint8_t *z,
67  size_t zLen, const uint8_t *otherInfo, size_t otherInfoLen, uint8_t *dk,
68  size_t dkLen);
69 
70 error_t oneStepKdfHmac(const HashAlgo *hashAlgo, const uint8_t *z,
71  size_t zLen, const uint8_t *salt, size_t saltLen, const uint8_t *otherInfo,
72  size_t otherInfoLen, uint8_t *dk, size_t dkLen);
73 
74 error_t oneStepKdfKmac(uint_t strength, size_t hLen, const uint8_t *z,
75  size_t zLen, const uint8_t *salt, size_t saltLen, const uint8_t *otherInfo,
76  size_t otherInfoLen, uint8_t *dk, size_t dkLen);
77 
78 //C++ guard
79 #ifdef __cplusplus
80 }
81 #endif
82 
83 #endif
error_t oneStepKdfHash(const HashAlgo *hashAlgo, const uint8_t *z, size_t zLen, const uint8_t *otherInfo, size_t otherInfoLen, uint8_t *dk, size_t dkLen)
One-Step KDF function (with hash-based auxiliary function)
Definition: one_step_kdf.c:131
uint8_t type
Definition: coap_common.h:176
@ ONE_STEP_KDF_TYPE_HASH
Definition: one_step_kdf.h:54
error_t oneStepKdfHmac(const HashAlgo *hashAlgo, const uint8_t *z, size_t zLen, const uint8_t *salt, size_t saltLen, const uint8_t *otherInfo, size_t otherInfoLen, uint8_t *dk, size_t dkLen)
One-Step KDF function (with HMAC-based auxiliary function)
Definition: one_step_kdf.c:212
@ ONE_STEP_KDF_TYPE_HMAC
Definition: one_step_kdf.h:55
error_t oneStepKdf(OneStepKdfType type, const HashAlgo *hashAlgo, const uint8_t *z, size_t zLen, const uint8_t *salt, size_t saltLen, const uint8_t *otherInfo, size_t otherInfoLen, uint8_t *dk, size_t dkLen)
One-Step KDF function.
Definition: one_step_kdf.c:80
error_t
Error codes.
Definition: error.h:43
@ ONE_STEP_KDF_TYPE_KMAC256
Definition: one_step_kdf.h:57
General definitions for cryptographic algorithms.
uint8_t z
Definition: dns_common.h:196
Common interface for hash algorithms.
Definition: crypto.h:1243
error_t oneStepKdfKmac(uint_t strength, size_t hLen, const uint8_t *z, size_t zLen, const uint8_t *salt, size_t saltLen, const uint8_t *otherInfo, size_t otherInfoLen, uint8_t *dk, size_t dkLen)
One-Step KDF function (with KMAC-based auxiliary function)
Definition: one_step_kdf.c:314
unsigned int uint_t
Definition: compiler_port.h:57
@ ONE_STEP_KDF_TYPE_KMAC128
Definition: one_step_kdf.h:56
OneStepKdfType
One-Step KDF auxiliary functions.
Definition: one_step_kdf.h:53