终版
This commit is contained in:
@@ -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);
|
||||
|
||||
/**
|
||||
@@ -28,6 +29,7 @@ void AES_init_ctx(struct AES_ctx* ctx, const uint8_t* key);
|
||||
* @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);
|
||||
|
||||
/**
|
||||
@@ -35,6 +37,7 @@ void AES_init_ctx_iv(struct AES_ctx* ctx, const uint8_t* key, const uint8_t* iv)
|
||||
* @param ctx AES上下文
|
||||
* @param buf 要加密的数据(16字节块)
|
||||
*/
|
||||
// 函数作用:使用 AES-ECB 模式加密单个 16 字节数据块。
|
||||
void AES_ECB_encrypt(const struct AES_ctx* ctx, uint8_t* buf);
|
||||
|
||||
/**
|
||||
@@ -42,6 +45,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);
|
||||
|
||||
/**
|
||||
@@ -50,6 +54,7 @@ void AES_ECB_decrypt(const struct AES_ctx* ctx, uint8_t* buf);
|
||||
* @param buf 要加密的数据
|
||||
* @param length 数据长度(必须是16的倍数)
|
||||
*/
|
||||
// 函数作用:使用上下文中的 IV 按 AES-CBC 模式加密指定长度的缓冲区。
|
||||
void AES_CBC_encrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
|
||||
|
||||
/**
|
||||
@@ -58,6 +63,7 @@ void AES_CBC_encrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
|
||||
* @param buf 要解密的数据
|
||||
* @param length 数据长度(必须是16的倍数)
|
||||
*/
|
||||
// 函数作用:使用上下文中的 IV 按 AES-CBC 模式解密指定长度的缓冲区。
|
||||
void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
|
||||
|
||||
#endif // _AES_H_
|
||||
|
||||
Reference in New Issue
Block a user