This commit is contained in:
2026-05-21 08:07:16 +08:00
parent 90908cf018
commit 84d8874a38
32 changed files with 271 additions and 27 deletions
+6
View File
@@ -20,6 +20,7 @@ struct AES_ctx
* @param ctx AES上下文结构
* @param key 16字节密钥
*/
// 函数作用:根据 16 字节密钥初始化 AES 上下文并生成轮密钥。
void AES_init_ctx(struct AES_ctx* ctx, const uint8_t* key);
/**
@@ -27,6 +28,7 @@ void AES_init_ctx(struct AES_ctx* ctx, const uint8_t* key);
* @param ctx AES上下文
* @param buf 要加密的数据(16字节块)
*/
// 函数作用:使用 AES-ECB 模式加密单个 16 字节数据块。
void AES_ECB_encrypt(const struct AES_ctx* ctx, uint8_t* buf);
/**
@@ -34,6 +36,7 @@ void AES_ECB_encrypt(const struct AES_ctx* ctx, uint8_t* buf);
* @param ctx AES上下文
* @param buf 要解密的数据(16字节块)
*/
// 函数作用:使用 AES-ECB 模式解密单个 16 字节数据块。
void AES_ECB_decrypt(const struct AES_ctx* ctx, uint8_t* buf);
/**
@@ -43,6 +46,7 @@ void AES_ECB_decrypt(const struct AES_ctx* ctx, uint8_t* buf);
* @param length 数据长度(必须是16的倍数)
* @param iv 初始化向量(16字节)
*/
// 函数作用:使用上下文中的 IV 按 AES-CBC 模式加密指定长度的缓冲区。
void AES_CBC_encrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
/**
@@ -52,6 +56,7 @@ void AES_CBC_encrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
* @param length 数据长度(必须是16的倍数)
* @param iv 初始化向量(16字节)
*/
// 函数作用:使用上下文中的 IV 按 AES-CBC 模式解密指定长度的缓冲区。
void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
/**
@@ -60,6 +65,7 @@ void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
* @param key 16字节密钥
* @param iv 16字节初始化向量
*/
// 函数作用:使用 16 字节密钥和 16 字节 IV 初始化 AES-CBC 上下文。
void AES_init_ctx_iv(struct AES_ctx* ctx, const uint8_t* key, const uint8_t* iv);
#endif // _AES_H_