1 /* 2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 #ifndef __HMAC_WAPI_SMS4_H__ 20 #define __HMAC_WAPI_SMS4_H__ 21 22 /* **************************************************************************** 23 1 头文件包含 24 **************************************************************************** */ 25 #ifdef __cplusplus 26 #if __cplusplus 27 extern "C" { 28 #endif 29 #endif 30 31 /* **************************************************************************** 32 2 宏定义 33 **************************************************************************** */ 34 #define byte_sub(_s, _a) ((_s)[((hi_u32)(_a)) >> 24 & 0xFF] << 24 ^ \ 35 (_s)[((hi_u32)(_a)) >> 16 & 0xFF] << 16 ^ \ 36 (_s)[((hi_u32)(_a)) >> 8 & 0xFF] << 8 ^ \ 37 (_s)[((hi_u32)(_a)) & 0xFF]) 38 39 #define l1(_b) ((_b) ^ rotl32(_b, 2) ^ rotl32(_b, 10) ^ rotl32(_b, 18) ^ rotl32(_b, 24)) 40 #define l2(_b) ((_b) ^ rotl32(_b, 13) ^ rotl32(_b, 23)) 41 42 /* **************************************************************************** 43 2 函数声明 44 *****************************************************************************/ 45 hi_void hmac_sms4_crypt(const hi_u8 *puc_input, hi_u8 input_len, hi_u8 *puc_output, 46 const hi_u32 *puc_rk, hi_u8 rk_len); 47 hi_void hmac_sms4_keyext(const hi_u8 *puc_key, hi_u8 key_len, hi_u32 *puc_rk, hi_u8 rk_len); 48 49 #ifdef __cplusplus 50 #if __cplusplus 51 } 52 #endif 53 #endif 54 55 #endif /* __HMAC_WAPI_SMS4_H__ */ 56