资源简介
这是一个用于计算AES CBC算法的程序,key长度128bit
满足fips-197规格,这个是最近在做一个OMS(Open Metering Sytem)项目用到的,自己在网上找了半天都找不到C语言的源代码。找到的不是工具就是别的没用的东西,要不就是找到的代码只是AES算法,不是CBC的,和spec上的数据对不上,结果经过多番实验(try啊try啊),终于成功了,哇哈哈,要不然项目要被赔款的。。。
代码片段和文件信息
/*
******************************************************************
** Advanced Encryption Standard implementation in C. **
** By Niyaz PK **
** E-mail: niyazlife@gmail.com **
** Downloaded from Website: www.hoozi.com **
******************************************************************
This is the source code for encryption using the latest AES algorithm.
AES algorithm is also called Rijndael algorithm. AES algorithm is
recommended for non-classified by the National Institute of Standards
and Technology(NIST) USA. Now-a-days AES is being used for almost
all encryption applications all around the world.
THE MAIN FEATURE OF THIS AES ENCRYPTION PROGRAM IS NOT EFFICIENCY; IT
IS SIMPLICITY AND READABILITY. THIS SOURCE CODE IS PROVIDED FOR ALL
TO UNDERSTAND THE AES ALGORITHM.
Comments are provided as needed to understand the program. But the
user must read some AES documentation to understand the underlying
theory correctly.
It is not possible to describe the complete AES algorithm in detail
here. For the complete description of the algorithm point your
browser to:
http://www.csrc.nist.gov/publications/fips/fips197/fips-197.pdf
Find the Wikipedia page of AES at:
http://en.wikipedia.org/wiki/Advanced_Encryption_Standard
******************************************************************
*/
/* Include stdio.h for standard input/output.
// Used for giving output to the screen.
*/
#include
/* The number of columns comprising a state in AES. This is a constant in AES. Value=4
*/
/*#define Nb 4
*/
/* The number of rounds in AES Cipher. It is simply initiated to zero. The actual value is recieved in the program.
int Nr=0;
*/
/* The number of 32 bit words in the key. It is simply initiated to zero. The actual value is recieved in the program.
int Nk=0;
*/
/* in - it is the array that holds the plain text to be encrypted.
// out - it is the array that holds the key for encryption.
// state - the array that holds the intermediate results during encryption.
*/
/*unsigned char in[16] out[16] state[4][4];
unsigned char in[16]state[4][4];*/
unsigned state[4][4];
/* The array that stores the round keys.
*/
unsigned char RoundKey[240];
/* The Key input to the AES Program
unsigned char Key[16];
*/
int getSBoxValue(int num)
{
int 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 /*0*/
0xca 0x82 0xc9 0x7d 0xfa 0x59 0x47 0xf0 0xad 0xd4 0xa2 0xaf 0x9c 0xa4 0x72 0xc0 /*1*/
0xb7 0xfd 0x93 0x26 0x36 0x3f 0xf7 0xcc 0x34 0xa5 0xe5 0xf1 0x71 0xd8 0x31 0x15 /*2*/
0x04 0xc7 0x23 0xc3 0x18 0x96 0x05 0x9a 0x07 0x12 0x80 0xe2 0xeb 0x27 0xb2
- 上一篇:c语言课程设计-职工信息管理系统-单链表
- 下一篇:摄影测量相对定向VC++程序
相关资源
- C++实现AES、DES加密算法含MFC界面
-
C++_AES_ECB_ba
se64 - SM4(ECB、CBC、CTR、CFB、OFB)加密算法
- YCbCr、混合高斯以及YCbCg肤色检测模型
- AES算法采用verilog硬件实现
- AES GCM算法源码
- AES 加密 C++源码
- stm32L系列F系列 加密库Cryptographic lib
- VC++ AES加密算法实现与范例的源代码
- MFC实现AES非对称加密解密算法
- AES加解密算法实现MFC
- 基于C++用用CBC与ECB模式的DES加解密
- 高级加密标准 AES (含AES的数学基础,
- AES加密/解密C++源代码
- AES算法加密解密C++源码及程序完整的
- AES GCM和ECB加密软件,和工程文件
- AES加密解密算法实现C、C++
- AES加密解密程序(C++)+实验报告
- aes加密算法源码
- AES MFC
- AES加密的HLS实现与优化
- DES_CBC加密,解密多种格式文件,基于
- 混合加密程序 VC++包括DES加密和AES加密
- AES CBC加解密源代码
- AES 算法实现(linux) 可移植
- CMAES算法C++
- AesForC.rar
- AES加密算法C++语言实现
- AES对称加密解密文件
- AES加密可加密文件
评论
共有 条评论