10a7ce71fSopenharmony_ci/* 20a7ce71fSopenharmony_ci * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED. 30a7ce71fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 40a7ce71fSopenharmony_ci * you may not use this file except in compliance with the License. 50a7ce71fSopenharmony_ci * You may obtain a copy of the License at 60a7ce71fSopenharmony_ci * 70a7ce71fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 80a7ce71fSopenharmony_ci * 90a7ce71fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 100a7ce71fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 110a7ce71fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 120a7ce71fSopenharmony_ci * See the License for the specific language governing permissions and 130a7ce71fSopenharmony_ci * limitations under the License. 140a7ce71fSopenharmony_ci */ 150a7ce71fSopenharmony_ci 160a7ce71fSopenharmony_ci#ifndef IOT_HMAC_H 170a7ce71fSopenharmony_ci#define IOT_HMAC_H 180a7ce71fSopenharmony_ci 190a7ce71fSopenharmony_ci/** 200a7ce71fSopenharmony_ci * This file make use the hmac to make mqtt pwd.The method is use the date string to hash the device passwd . 210a7ce71fSopenharmony_ci * Take care that this implement depends on the hmac of the mbedtls 220a7ce71fSopenharmony_ci*/ 230a7ce71fSopenharmony_ci 240a7ce71fSopenharmony_ci/** 250a7ce71fSopenharmony_ci * This function used to generate the passwd for the mqtt to connect the HuaweiIoT platform 260a7ce71fSopenharmony_ci * @param content: This is the content for the hmac,and usually it is the device passwd set or get from the Iot Platform 270a7ce71fSopenharmony_ci * @param content_len: The length of the content 280a7ce71fSopenharmony_ci * @param key: This is the key for the hmac, and usually it is the time, 290a7ce71fSopenharmony_ci * used in the client_id:the format is:yearmonthdatehour:like 1970010100 300a7ce71fSopenharmony_ci * @param key_len: The length of the key 310a7ce71fSopenharmony_ci * @param buf: used to storage the hmac code 320a7ce71fSopenharmony_ci * @param buf_len:the buf length 330a7ce71fSopenharmony_ci * @return:0 success while others failed 340a7ce71fSopenharmony_ci */ 350a7ce71fSopenharmony_ciint HmacGeneratePwd(unsigned char *content, int contentLen, unsigned char *key, int keyLen, 360a7ce71fSopenharmony_ci unsigned char *buf) 370a7ce71fSopenharmony_ci#endif