* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IOTC_KDF_H
#define IOTC_KDF_H
#include "iotc_md.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
IotcMdType md;
const uint8_t *password;
uint32_t passwordLen;
const uint8_t *salt;
uint32_t saltLen;
uint32_t iterCount;
} IotcPbkdf2HmacParam;
typedef struct {
IotcMdType md;
const uint8_t *salt;
uint32_t saltLen;
const uint8_t *info;
uint32_t infoLen;
const uint8_t *material;
uint32_t materialLen;
} IotcHkdfParam;
* @brief 基于HMAC的PKCS#5 PBKDF2密钥派生
*
* @param param [IN] 密钥派生参数
* @param key [OUT] 生成密钥缓冲区,可写长度至少为keyLen
* @param keyLen [IN] 生成密钥的长度,取决于param->md摘要算法
* @return 0成功,其他失败
*/
int32_t IotcPkcs5Pbkdf2Hmac(const IotcPbkdf2HmacParam *param, uint8_t *key, uint32_t keyLen);
* @brief HKDF密钥派生
*
* @param param [IN] 密钥派生参数
* @param key [OUT] 生成密钥缓冲区,可写长度至少为keyLen
* @param keyLen [IN] 生成密钥的长度,不超过摘要算法类型字节数的255倍
* @return 0成功,其他失败
*/
int32_t IotcHkdf(const IotcHkdfParam *param, uint8_t *key, uint32_t keyLen);
#ifdef __cplusplus
}
#endif
#endif