初始化:添加本地配置文件

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
This commit is contained in:
qzh
2025-08-31 15:42:43 +08:00
commit b1d0ef0d0d
12 changed files with 554 additions and 0 deletions

39
src/main.c Normal file
View File

@@ -0,0 +1,39 @@
#include "zuc256.h"
#include <stdio.h>
int main(void) {
// 256位密钥32字节
uint8_t key[32] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
};
// 128位初始向量16字节
uint8_t iv[16] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
};
// 待加密数据
uint8_t plaintext[] = "Hello, ZUC256 algorithm!";
uint8_t ciphertext[sizeof(plaintext)];
uint8_t decrypted[sizeof(plaintext)];
zuc256_context ctx;
// 加密过程
zuc256_init(&ctx, key, iv);
zuc256_crypt(&ctx, plaintext, ciphertext, sizeof(plaintext));
// 解密过程使用相同的密钥和IV重新初始化
zuc256_init(&ctx, key, iv);
zuc256_crypt(&ctx, ciphertext, decrypted, sizeof(plaintext));
// 输出结果
printf("Original: %s\n", plaintext);
printf("Decrypted: %s\n", decrypted);
return 0;
}