-
大小: 17KB文件类型: .zip金币: 2下载: 0 次发布日期: 2021-06-06
- 语言: C/C++
- 标签: AES128 AES encryption AES
资源简介
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加解密(vc源程序)
- AES-128-CBC算法C语言源码已经修改,可
- C++实现AES、DES加密算法含MFC界面
-
C++_AES_ECB_ba
se64 - AES算法采用verilog硬件实现
- AES GCM算法源码
- AES 加密 C++源码
- stm32L系列F系列 加密库Cryptographic lib
- VC++ AES加密算法实现与范例的源代码
- MFC实现AES非对称加密解密算法
- AES加解密算法实现MFC
- 高级加密标准 AES (含AES的数学基础,
- AES加密/解密C++源代码
- AES算法加密解密C++源码及程序完整的
- AES GCM和ECB加密软件,和工程文件
- AES加密解密算法实现C、C++
- AES加密解密程序(C++)+实验报告
- aes加密算法源码
- AES MFC
- AES加密的HLS实现与优化
- 混合加密程序 VC++包括DES加密和AES加密
- AES CBC加解密源代码
- AES 算法实现(linux) 可移植
- CMAES算法C++
- AesForC.rar
- AES加密算法C++语言实现
- AES对称加密解密文件
- AES加密可加密文件
- AES5种加密模式源码C语言
- AES密码学课程设计带报告
评论
共有 条评论