資源描述:
《AES加密算法的C++實(shí)現(xiàn)過(guò)程》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、//AES.H#ifndef_AES_H_#define_AES_H_#include"stdafx.h"#defineAES_KEY_ROW_NUMBER4#defineAES_KEY_COLUMN_NUMBER4#defineAES_ROUND_COUNT10classAES:publicEncryption{public:AES(void);AES(BYTE*key);virtual~AES(void);voidEncrypt(BYTE*,BYTE*,size_t);voidDecrypt(BYTE*,BYTE*,size_t);private:BYTEswa
2、pbox[11][4][4];BYTE*Cipher(BYTE*input);BYTE*InvCipher(BYTE*input);BYTE*Cipher(void*input,size_tlength);BYTE*InvCipher(void*input,size_tlength);voidKeyExpansion(BYTE*key,BYTEw[][4][AES_KEY_COLUMN_NUMBER]);BYTEFFmul(BYTEa,BYTEb);voidSubBytes(BYTEstate[][AES_KEY_COLUMN_NUMBER]);voidShiftR
3、ows(BYTEstate[][AES_KEY_COLUMN_NUMBER]);voidMixColumns(BYTEstate[][AES_KEY_COLUMN_NUMBER]);voidAddRoundKey(BYTEstate[][AES_KEY_COLUMN_NUMBER],BYTEk[][AES_KEY_COLUMN_NUMBER]);voidInvSubBytes(BYTEstate[][AES_KEY_COLUMN_NUMBER]);voidInvShiftRows(BYTEstate[][AES_KEY_COLUMN_NUMBER]);voidInv
4、MixColumns(BYTEstate[][AES_KEY_COLUMN_NUMBER]);};#endif//_AES_H_//Encryption.h#ifndef_ENCRYPTION_H_#define_ENCRYPTION_H_#include"stdafx.h"classEncryption{public:virtualvoidEncrypt(BYTE*,BYTE*,size_t)=0;virtualvoidDecrypt(BYTE*,BYTE*,size_t)=0;};#endif//EncryptionFactory.h#ifndef_ENCRYP
5、TION_FACTORY_H_#define_ENCRYPTION_FACTORY_H_#include"Encryption.h"#include"stdafx.h"classEncryptionFactory{public:EncryptionFactory(void);virtual~EncryptionFactory(void);staticEncryption*getEncryption(intencryptionType,BYTE*key);private:staticEncryption*encry;};#endif//AES.cpp#include"
6、stdafx.h"#include"AES.h"#include#include//permuteboxstaticunsignedcharpermutebox[]={/*0123456789abcdef*/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,0x
7、c0,/*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,0x75,/*3*/0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0,0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84,/*4*/0x53,0xd1,0x00,0xed,0