| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #ifndef __lk_sm4_h__
- #define __lk_sm4_h__
- #ifdef __cpluscplus
- extern "C" {
- #endif
- #include "stm32f10x.h"
- //#include <strings.h>
- #include <string.h>
- #ifdef __cpluscplus
- }
- #endif
- #define u8 unsigned char
- #define u32 unsigned long
- void four_uCh2uLong(u8 *in, u32 *out); //四字节转换成u32
- void uLong2four_uCh(u32 in, u8 *out); //u32转换成四字节
- unsigned long move(u32 data, int length); //左移,保留丢弃位放置尾部
- unsigned long func_key(u32 input); //先使用Sbox进行非线性变化,再将线性变换L置换为L'
- unsigned long func_data(u32 input); //先使用Sbox进行非线性变化,再进行线性变换L
- void print_hex(u8 *data, int len); //无符号字符数组转16进制打印
- extern u16 encode_fun(u8 len,u8 *key, u8 *input, u8 *output); //加密函数
- extern void decode_fun(u8 len,u8 *key, u8 *input, u8 *output); //解密函数
- typedef struct _sm4_data_{
- u32 mkey[4]; //存储密钥的u32数据
- u32 key[36]; //用于密钥扩展算法与系统参数FK运算后的结果存储
- u32 rkey[36]; //用于存放加密数据
- }sm4daInfo;
- #ifdef __cpluscplus
- extern "C" {
- #endif
- #ifdef __cpluscplus
- }
- #endif
- #endif
|