資源簡介
AES/ECB/PKCS5Padding C++實現

代碼片段和文件信息
//
//??AES_.c
//??Encryption
//
//??Created?by?Jason.xu?on?13-10-22.
//??Copyright?(c)?2013年?zhoumin.?All?rights?reserved.
//
/*
?*??FIPS-197?compliant?AES?implementation
?*
?*??Copyright?(C)?2003-2006??Christophe?Devine
?*
?*??This?library?is?free?software;?you?can?redistribute?it?and/or
?*??modify?it?under?the?terms?of?the?GNU?Lesser?General?Public
?*??License?version?2.1?as?published?by?the?Free?Software?Foundation.
?*
?*??This?library?is?distributed?in?the?hope?that?it?will?be?useful
?*??but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty?of
?*??MERCHANTABILITY?or?FITNESS?FOR?A?PARTICULAR?PURPOSE.??See?the?GNU
?*??Lesser?General?Public?License?for?more?details.
?*
?*??You?should?have?received?a?copy?of?the?GNU?Lesser?General?Public
?*??License?along?with?this?library;?if?not?write?to?the?Free?Software
?*??Foundation?Inc.?51?Franklin?Street?Fifth?Floor?Boston
?*??MA??02110-1301??USA
?*/
/*
?*??The?AES?block?cipher?was?designed?by?Vincent?Rijmen?and?Joan?Daemen.
?*
?*??http://csrc.nist.gov/encryption/aes/rijndael/Rijndael.pdf
?*??http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf
?*/
#ifndef?_CRT_SECURE_NO_DEPRECATE
#define?_CRT_SECURE_NO_DEPRECATE?1
#endif
#include?
#include?
#include?
#include?“AES.h“
#ifndef?uint8
#define?uint8?unsigned?char
#endif
#ifndef?uint32
#define?uint32?unsigned?long
#endif
/*
?*?32-bit?integer?manipulation?macros?(big?endian)
?*/
#ifndef?GET_UINT32_BE
#define?GET_UINT32_BE(nbi)????????????????????????????\
{???????????????????????????????????????????????????????\
(n)?=?(?(uint32)?(b)[(i)????]?<24?)????????\
|?(?(uint32)?(b)[(i)?+?1]?<16?)????????\
|?(?(uint32)?(b)[(i)?+?2]?<?8?)????????\
|?(?(uint32)?(b)[(i)?+?3]???????);???????\
}
#endif
#ifndef?PUT_UINT32_BE
#define?PUT_UINT32_BE(nbi)????????????????????????????\
{???????????????????????????????????????????????????????\
(b)[(i)????]?=?(uint8)?(?(n)?>>?24?);???????\
(b)[(i)?+?1]?=?(uint8)?(?(n)?>>?16?);???????\
(b)[(i)?+?2]?=?(uint8)?(?(n)?>>??8?);???????\
(b)[(i)?+?3]?=?(uint8)?(?(n)???????);???????\
}
#endif
/*
?*?Uncomment?the?following?line?to?use?pre-computed?tables
?*?otherwise?the?tables?will?be?generated?at?the?first?run.
?*
?*?#define?FIXED_TABLES
?*/
#if?!defined(FIXED_TABLES)
/*
?*?Forward?S-box?&?tables
?*/
static?uint8?FSb[256];
static?uint32?FT0[256];
static?uint32?FT1[256];
static?uint32?FT2[256];
static?uint32?FT3[256];
/*
?*?Reverse?S-box?&?tables
?*/
static?uint8?RSb[256];
static?uint32?RT0[256];
static?uint32?RT1[256];
static?uint32?RT2[256];
static?uint32?RT3[256];
/*
?*?Round?constants
?*/
static?uint32?RCON[10];
/*
?*?Tables?generation?code
?*/
#define?ROTR8(x)?(?(?(?x?<24?)?&?0xFFFFFFFF?)?|?\
(?(?x?&?0xFFFFFFFF?)?>>?8?)?)
#define?XTIME(x)?(?(?x?<1?)?^?(?(?x?&?0x80?)???0x1B?:?0x00?)?)
#define?MUL(xy)?(?(?x?&&?y?)???pow[(log[x]?+?log[y])?%?255]?:?0?)
s
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????38907??2017-08-22?16:35??AES.cpp
?????文件????????3166??2017-08-22?16:35??AES.h
- 上一篇:c語言課程設計圖書信息管理系統
- 下一篇:多峰函數多個最優解問題 演化算法
評論
共有 條評論