1 /*
2  * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef IOT_HMAC_H
17 #define IOT_HMAC_H
18 
19 /**
20  * This file make use the hmac to make mqtt pwd.The method is use the date string to hash the device passwd .
21  * Take care that this implement depends on the hmac of the mbedtls
22 */
23 
24 /**
25  * This function used to generate the passwd for the mqtt to connect the HuaweiIoT platform
26  * @param content: This is the content for the hmac,and usually it is the device passwd set or get from the Iot Platform
27  * @param content_len: The length of the content
28  * @param key: This is the key for the hmac, and usually it is the time,
29  * used in the client_id:the format is:yearmonthdatehour:like 1970010100
30  * @param key_len: The length of the key
31  * @param buf: used to storage the hmac code
32  * @param buf_len:the buf length
33  * @return:0 success while others failed
34  */
35 int HmacGeneratePwd(unsigned char *content, int contentLen, unsigned char *key, int keyLen,
36                     unsigned char *buf)
37 #endif