-
大小: 17KB文件类型: .zip金币: 1下载: 0 次发布日期: 2021-06-06
- 语言: C/C++
- 标签: AES128 AES encryption
资源简介
aes.c
aes.h
test.c
本人实测可以使用,基于C的AES算法代码,希望能帮到有需要的。以下是相关模式调用的函数。
void AES_init_ctx(struct AES_ctx* ctx, const uint8_t* key);
void AES_init_ctx_iv(struct AES_ctx* ctx, const uint8_t* key, const uint8_t* iv);
void AES_ctx_set_iv(struct AES_ctx* ctx, const uint8_t* iv);
void AES_ECB_encrypt(const struct AES_ctx* ctx, uint8_t* buf);
void AES_ECB_decrypt(const struct AES_ctx* ctx, uint8_t* buf);
void AES_CBC_encrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, uint32_t length);
void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, uint32_t length);
void AES_CTR_xcrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, uint32_t length);
代码片段和文件信息
/*
This is an implementation of the AES algorithm specifically ECB CTR and CBC mode.
Block size can be chosen in aes.h - available choices are AES128 AES192 AES256.
The implementation is verified against the test vectors in:
National Institute of Standards and Technology Special Publication 800-38A 2001 ED
ECB-AES128
----------
plain-text:
6bc1bee22e409f96e93d7e117393172a
ae2d8a571e03ac9c9eb76fac45af8e51
30c81c46a35ce411e5fbc1191a0a52ef
f69f2445df4f9b17ad2b417be66c3710
key:
2b7e151628aed2a6abf7158809cf4f3c
resulting cipher
3ad77bb40d7a3660a89ecaf32466ef97
f5d3d58503b9699de785895a96fdbaaf
43b1cd7f598ece23881b00e3ed030688
7b0c785e27e8ad3f8223207104725dd4
NOTE: String length must be evenly divisible by 16byte (str_len % 16 == 0)
You should pad the end of the string with zeros if this is not the case.
For AES192/256 the key size is proportionally larger.
*/
/*****************************************************************************/
/* Includes: */
/*****************************************************************************/
#include // CBC mode for memset
#include “aes.h“
/*****************************************************************************/
/* Defines: */
/*****************************************************************************/
// The number of columns comprising a state in AES. This is a constant in AES. Value=4
#define Nb 4
#if defined(AES256) && (AES256 == 1)
#define Nk 8
#define Nr 14
#elif defined(AES192) && (AES192 == 1)
#define Nk 6
#define Nr 12
#else
#define Nk 4 // The number of 32 bit words in a key.
#define Nr 10 // The number of rounds in AES Cipher.
#endif
// jcallan@github points out that declaring Multiply as a function
// reduces code size considerably with the Keil ARM compiler.
// See this link for more information: https://github.com/kokke/tiny-AES-C/pull/3
#ifndef MULTIPLY_AS_A_FUNCTION
#define MULTIPLY_AS_A_FUNCTION 0
#endif
/*****************************************************************************/
/* Private variables: */
/*****************************************************************************/
// state - array holding the intermediate results during decryption.
typedef uint8_t state_t[4][4];
// The lookup-tables are marked const so they can be placed in read-only storage instead of RAM
// The numbers below can be computed dynamically trading ROM for RAM -
// This can be useful in (embedded) bootloader applications where ROM is often limited.
static const uint8_t sbox[256] = {
//0 1 2 3 4 5 6 7 8 9 A B C D E F
0x63 0x7c 0x77 0x7b 0xf2 0x6b 0x6f 0xc5 0x30 0x01 0x67 0x2b 0xfe 0xd7 0xab 0x76
0xca
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-07-01 10:34 tiny-AES-c-master\
文件 44 2020-07-01 10:34 tiny-AES-c-master\.gitignore
文件 366 2020-07-01 10:34 tiny-AES-c-master\CMakeLists.txt
文件 1211 2020-07-01 10:34 tiny-AES-c-master\Makefile
文件 4319 2020-07-01 10:34 tiny-AES-c-master\README.md
文件 18963 2020-07-01 10:34 tiny-AES-c-master\aes.c
文件 2776 2020-07-01 10:34 tiny-AES-c-master\aes.h
文件 184 2020-07-01 10:34 tiny-AES-c-master\aes.hpp
文件 2050 2020-07-01 10:34 tiny-AES-c-master\conanfile.py
文件 279 2020-07-01 10:34 tiny-AES-c-master\library.json
文件 557 2020-07-01 10:34 tiny-AES-c-master\library.properties
文件 15539 2020-07-01 10:34 tiny-AES-c-master\test.c
文件 37 2020-07-01 10:34 tiny-AES-c-master\test.cpp
目录 0 2020-07-01 10:34 tiny-AES-c-master\test_package\
文件 313 2020-07-01 10:34 tiny-AES-c-master\test_package\CMakeLists.txt
文件 413 2020-07-01 10:34 tiny-AES-c-master\test_package\conanfile.py
文件 1211 2020-07-01 10:34 tiny-AES-c-master\unlicense.txt
相关资源
- AES加密算法C语言实现,有测试代码,
- 常用加密算法AES、RSA、DES、MD5、TEA、
- AES 128位加解密C++源码(加盐)
- AES详细源码C语言实现带注释
- AES算法的C语言版本
- AES/ECB/PKCS5Padding C++实现
- C语言环境下的AES加密算法,支持128位
- AES快速实现,加密速度大约1.4G/s,不
- AES多种加密解密方式C语言方式实现
- aes密钥扩展C语言实现
- C语言 3DES、AES、RC6、TEA、RSA、MD5、S
- C语言实现的AES加密解密
- AES、DES加密算法C语言源码
- AES 加解密c++
- AES s盒生成代码
- AES加密解密系统 VC++6.0 实现
- AES密码算法C语言实现
- C语言 stm32 AES加密解密
- AES单片机加密解密 C语言源代码
- aes算法实现C++)
- AES任意文件长度加解密C语言实现
- aes加密算法matlab
- AES128 C语言实现源码及应用例程
- CMAC(AES128)Verilog实现
- aes加密算法的verilog和c++代码
- AES加密源码使用C++实现
- AES算法源码~~~~~~~~~~~~
- zw_AES加密算法c语言实现代码.zip
- AES加密MFC程序源码
- C语言实现AES加密、解密算法
评论
共有 条评论