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_HMAC_H 17 #define CRYPT_HMAC_H 18 19 #include "hitls_build.h" 20 #ifdef HITLS_CRYPTO_HMAC 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 #define HMAC_MAXBLOCKSIZE 144 31 #define HMAC_MAXOUTSIZE 64 32 33 typedef struct HMAC_Ctx CRYPT_HMAC_Ctx; 34 35 CRYPT_HMAC_Ctx *CRYPT_HMAC_NewCtx(CRYPT_MAC_AlgId id); 36 int32_t CRYPT_HMAC_Init(CRYPT_HMAC_Ctx *ctx, const uint8_t *key, uint32_t len, BSL_Param *param); 37 int32_t CRYPT_HMAC_Update(CRYPT_HMAC_Ctx *ctx, const uint8_t *in, uint32_t len); 38 int32_t CRYPT_HMAC_Final(CRYPT_HMAC_Ctx *ctx, uint8_t *out, uint32_t *len); 39 void CRYPT_HMAC_Reinit(CRYPT_HMAC_Ctx *ctx); 40 void CRYPT_HMAC_Deinit(CRYPT_HMAC_Ctx *ctx); 41 int32_t CRYPT_HMAC_Ctrl(CRYPT_HMAC_Ctx *ctx, CRYPT_MacCtrl opt, void *val, uint32_t len); 42 void CRYPT_HMAC_FreeCtx(CRYPT_HMAC_Ctx *ctx); 43 44 #ifdef __cplusplus 45 } 46 #endif /* __cplusplus */ 47 48 #endif // HITLS_CRYPTO_HMAC 49 50 #endif // CRYPT_HMAC_H 51