• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is part of the openHiTLS project.
3  *
4  * openHiTLS is licensed under the Mulan PSL v2.
5  * You can use this software according to the terms and conditions of the Mulan PSL v2.
6  * You may obtain a copy of Mulan PSL v2 at:
7  *
8  *     http://license.coscl.org.cn/MulanPSL2
9  *
10  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13  * See the Mulan PSL v2 for more details.
14  */
15 
16 #ifndef CRYPT_KDF_TLS12_H
17 #define CRYPT_KDF_TLS12_H
18 
19 #include "hitls_build.h"
20 #ifdef HITLS_CRYPTO_KDFTLS12
21 
22 #include <stdint.h>
23 #include "crypt_local_types.h"
24 #include "bsl_params.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif // __cplusplus
29 
30 typedef struct CryptKdfTls12Ctx CRYPT_KDFTLS12_Ctx;
31 
32 /**
33  * @ingroup  KDFTLS12
34  * @brief Generate KDFTLS12 context.
35  *
36  * @retval Success: cipher ctx.
37  *         Fails: NULL.
38  */
39 CRYPT_KDFTLS12_Ctx* CRYPT_KDFTLS12_NewCtx(void);
40 
41 /**
42  * @ingroup KDFTLS12
43  * @brief Set parameters for the KDFTLS12 context.
44  *
45  * @param ctx   [in, out] Pointer to the KDFTLS12 context.
46  * @param param [in] Either a MAC algorithm ID, a seed, a password, or a label.
47  *
48  * @retval Success: CRYPT_SUCCESS
49  *         For other error codes, see crypt_errno.h.
50  */
51 int32_t CRYPT_KDFTLS12_SetParam(CRYPT_KDFTLS12_Ctx *ctx, const BSL_Param *param);
52 
53 /**
54  * @ingroup KDFTLS12
55  * @brief Obtain the derived key based on the passed KDFTLS12 context..
56  *
57  * @param ctx   [in, out] Pointer to the KDFTLS12 context.
58  * @param out   [out] Derived key buffer.
59  * @param len   [out] Derived key buffer size.
60  *
61  * @retval Success: CRYPT_SUCCESS
62  *         For other error codes, see crypt_errno.h.
63  */
64 int32_t CRYPT_KDFTLS12_Derive(CRYPT_KDFTLS12_Ctx *ctx, uint8_t *out, uint32_t len);
65 
66 /**
67  * @ingroup KDFTLS12
68  * @brief KDFTLS12 deinitialization API
69  *
70  * @param ctx [in, out]   Pointer to the KDFTLS12 context.
71  *
72  * @retval #CRYPT_SUCCESS       Deinitialization succeeded.
73  * @retval #CRYPT_NULL_INPUT    Pointer ctx is NULL
74  */
75 int32_t CRYPT_KDFTLS12_Deinit(CRYPT_KDFTLS12_Ctx *ctx);
76 
77 /**
78  * @ingroup KDFTLS12
79  * @brief free KDFTLS12 context.
80  *
81  * @param ctx [IN] KDFTLS12 handle
82  */
83 void CRYPT_KDFTLS12_FreeCtx(CRYPT_KDFTLS12_Ctx *ctx);
84 
85 
86 #ifdef __cplusplus
87 }
88 #endif // __cplusplus
89 
90 #endif // HITLS_CRYPTO_KDFTLS12
91 
92 #endif // CRYPT_KDF_TLS12_H
93