Files
se-algo/inc/zuc256.h
qzh b1d0ef0d0d 初始化:添加本地配置文件
new file:   .gitignore
	new file:   .vscode/settings.json
	new file:   LICENSE
	new file:   README.md
	new file:   SConscript
	new file:   SConstruct
	new file:   algo.py
	new file:   inc/type.h
	new file:   inc/zuc256.h
	new file:   run.sh
	new file:   src/main.c
	new file:   src/zuc256.c
2025-08-31 15:44:27 +08:00

37 lines
1002 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef ZUC256_H
#define ZUC256_H
#include <stdint.h>
#include <stddef.h>
// ZUC256算法上下文结构
typedef struct {
uint32_t LFSR[16]; // 线性反馈移位寄存器
uint32_t NFSR[16]; // 非线性反馈移位寄存器
uint32_t R1, R2; // 寄存器
uint32_t key[8]; // 256位密钥 (8*32)
uint32_t iv[4]; // 128位初始向量 (4*32)
} zuc256_context;
/**
* @brief 初始化ZUC256算法上下文
*
* @param ctx 算法上下文指针
* @param key 256位密钥32字节
* @param iv 128位初始向量16字节
*/
void zuc256_init(zuc256_context *ctx, const uint8_t *key, const uint8_t *iv);
/**
* @brief 使用ZUC256算法进行加密或解密
*
* @param ctx 算法上下文指针
* @param input 输入数据
* @param output 输出数据(与输入数据长度相同)
* @param length 数据长度(字节数)
*/
void zuc256_crypt(zuc256_context *ctx, const uint8_t *input, uint8_t *output, size_t length);
#endif // ZUC256_H