aes.h

来自「aes cbc mode source code」· C头文件 代码 · 共 74 行

H
74 行
字号
#ifndef __AES_H__
#define __AES_H__

#define BLK_SIZE	16
#define	TXT_SIZE	600
#define	NUM_RND		11


#include <exception>
#include <cstring>
//#include "aesTable.h"

#define Uint8	unsigned char
#define Uint32	unsigned int

class Block
{
public:
	unsigned int *pBlkWord;
	unsigned char blkByte[BLK_SIZE];
};

class Aes
{

public:
	
	Aes(); // Constructor
	virtual ~Aes();	// Destructor

	void aesEncrypt(unsigned char *m_input_txt, 
					unsigned char *m_key, 
					unsigned char *pCipher);

	void aesDecrypt(unsigned char *pMesg, 
					unsigned char* pKey, 
					unsigned char* pResult);

	Block aesGetIV();
	
	void aesSetIV(unsigned char *pIV);

private:

	Block	mesg;
	Block	key;
	Block	initVec;
	Block	cipher;
	Block	rndKeys[NUM_RND];
	static unsigned char SBox[256];
	static unsigned char SBoxInv[256];

	void blockEnc(Block *pMesg, Block key);
	void blockDec(Block *pMesg, Block key);

	void byteSub(Block *pBlk);
	void invByteSub(Block *pBlk);

	void shiftRow(Block *pBlk);
	void invShiftRow(Block *pBlk);

	void mixColumn(Block *pBlk);
	void invMixColumn(Block *pBlk);

	void makeKeys(Block key);
	void getRndKeys(int rndNum, Block *pKey);


};



#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?