亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? 08e.c

?? Program for implementing AES on 8051 based microcontrollers. SDCC is used as the C compiler. Microco
?? C
?? 第 1 頁 / 共 2 頁
字號:
// Program Description: ENCRYPT 16-bytes of data received from UART and display ENCRYPTED data on LCD
//
// Author: Anurag Chugh (anurag@ucmicrosys.com)

// NOTES:
// --01--
// 128-bit Advanced Standard Encryption is being used.
//
// --02--
// All communication (LCD or UART) is done using the characters
// '0','1','2','3','4','5','6','7','8','9','A','B','C','D','F'
// These characters represent the Hexadecimal Digits
// 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F Respectively
// 
// This is done so that the input and output can be carried out easily by using UART and LCD
// in a human readable form.
// 
// --03--
// The following code has been taken from
// http://www.hoozi.com/Articles/AESEncryption.htm
// It has been modified by Anurag Chugh (lithiumhead@msn.com) on 10th June 2008
// for use as a training exercie using the UNI-51-SDK
//
// --04-- 
// Here is one of the test vectors taken from
// http://www.csrc.nist.gov/publications/fips/fips197/fips-197.pdf
// to test if your encryption/decryption functions are working properly
// Key (128-bit):	E8E9EAEBEDEEEFF0F2F3F4F5F7F8F9FA
// Plaintext:		014BAF2278A69D331D5180103643E99A
// Ciphertext:		6743C3D1519AB4F2CD9A78AB09A511BD
//
// Actual code to be used at proper places in the following program:
//
// Key:
// const unsigned char Key[16] = {0xE8,0xE9,0xEA,0xEB,0xED,0xEE,0xEF,0xF0,0xF2,0xF3,0xF4,0xF5,0xF7,0xF8,0xF9,0xFA}; //Test Vector
//
// Plain text:
// xdata at 0x0000 unsigned char in[16] = {0x01,0x4B,0xAF,0x22,0x78,0xA6,0x9D,0x33,0x1D,0x51,0x80,0x10,0x36,0x43,0xE9,0x9A}; //Test Vector


/*
******************************************************************
**	   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 use 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"UART.H"
#include"LCD.H"

// 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 specified 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 output CipherText after encryption.
// state - the array that holds the intermediate results during encryption.
//
// All these are stored in the Internal XRAM of P89V51RD2 which is addressable
// from 0x000 to 0x2FF (768 bytes ie 1024-256=768).
xdata at 0x0000 unsigned char in[16];
xdata at 0x0010 unsigned char out[16];
xdata at 0x0020 unsigned char state[4][4];

// The array that stores the round keys.
// This array is also stored in the Internal XRAM immediately after the above arrays.
xdata at 0x0030 unsigned char RoundKey[240];

// The Key input to the AES Program
// It is stored in the Flash Memory along with the program code using the const keyword.
// It doesn't change during the execution of the program and is must be known
// beforehand to the sender and receiver.
const unsigned char Key[16] = {0xE8,0xE9,0xEA,0xEB,0xED,0xEE,0xEF,0xF0,0xF2,0xF3,0xF4,0xF5,0xF7,0xF8,0xF9,0xFA};


const 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, 0x75, //3
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, //4
0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, //5
0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, //6
0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, //7
0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, //8
0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, //9
0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, //A
0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, //B
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, //C
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, //D
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, //E
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 }; //F
  

int getSBoxValue(int num)
{
	return sbox[num];
}

// The round constant word array, Rcon[i], contains the values given by 
// x to the power (i-1) being powers of x (x is denoted as {02}) in the field GF(28)
// Note that i starts at 1, not 0).
// It is stored in the Flash Memory along with the program code using the const keyword.
// It doesn't change during the execution of the program.
const int Rcon[255] = {
0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 
0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 
0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 
0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 
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 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb  };
	
// This function produces Nb(Nr+1) round keys. The round keys are used in each round to encrypt the states. 
void KeyExpansion()
{
	int i,j;
	unsigned char temp[4],k;
	
	// The first round key is the key itself.
	for(i=0;i<Nk;i++)
	{
		RoundKey[i*4]=Key[i*4];
		RoundKey[i*4+1]=Key[i*4+1];
		RoundKey[i*4+2]=Key[i*4+2];
		RoundKey[i*4+3]=Key[i*4+3];
	}

	// All other round keys are found from the previous round keys.
	while (i < (Nb * (Nr+1)))
	{
		for(j=0;j<4;j++)
		{
			temp[j]=RoundKey[(i-1) * 4 + j];
		}
		if (i % Nk == 0)
		{
			// This function rotates the 4 bytes in a word to the left once.
			// [a0,a1,a2,a3] becomes [a1,a2,a3,a0]

			// Function RotWord()
			{
				k = temp[0];
				temp[0] = temp[1];
				temp[1] = temp[2];
				temp[2] = temp[3];
				temp[3] = k;
			}

			// SubWord() is a function that takes a four-byte input word and 
			// applies the S-box to each of the four bytes to produce an output word.

			// Function Subword()
			{
				temp[0]=getSBoxValue(temp[0]);
				temp[1]=getSBoxValue(temp[1]);
				temp[2]=getSBoxValue(temp[2]);
				temp[3]=getSBoxValue(temp[3]);
			}

			temp[0] =  temp[0] ^ Rcon[i/Nk];
		}
		else if (Nk > 6 && i % Nk == 4)
		{
			// Function Subword()
			{
				temp[0]=getSBoxValue(temp[0]);
				temp[1]=getSBoxValue(temp[1]);
				temp[2]=getSBoxValue(temp[2]);
				temp[3]=getSBoxValue(temp[3]);
			}
		}
		RoundKey[i*4+0] = RoundKey[(i-Nk)*4+0] ^ temp[0];
		RoundKey[i*4+1] = RoundKey[(i-Nk)*4+1] ^ temp[1];
		RoundKey[i*4+2] = RoundKey[(i-Nk)*4+2] ^ temp[2];
		RoundKey[i*4+3] = RoundKey[(i-Nk)*4+3] ^ temp[3];
		i++;
	}
}

// This function adds the round key to state.
// The round key is added to the state by an XOR function.
void AddRoundKey(int round) 
{
	int i,j;
	for(i=0;i<4;i++)
	{
		for(j=0;j<4;j++)
		{
			state[j][i] ^= RoundKey[round * Nb * 4 + i * Nb + j];
		}
	}
}

// The SubBytes Function Substitutes the values in the

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品中文在线影院| 欧美精选在线播放| 国产欧美精品日韩区二区麻豆天美| 久久91精品国产91久久小草| 日韩欧美在线不卡| 国产又黄又大久久| 国产精品女人毛片| 色视频欧美一区二区三区| 亚洲综合激情小说| 日韩一区二区三区免费观看| 麻豆久久久久久| 国产亚洲一区二区三区| 成人免费看的视频| 亚洲一二三区在线观看| 日韩欧美一级精品久久| 国产福利精品一区二区| 亚洲嫩草精品久久| 日韩一区二区三区在线| 国产成人精品三级麻豆| 亚洲精品免费一二三区| 日韩一二三四区| 成人深夜在线观看| 亚洲高清免费在线| 国产婷婷一区二区| 日本高清不卡aⅴ免费网站| 日日骚欧美日韩| 欧美国产精品一区| 欧美男同性恋视频网站| 国产成人精品一区二区三区四区| 亚洲精品中文在线| 久久影音资源网| 欧美综合视频在线观看| 国产一区二区精品久久91| 一区二区三区影院| 久久久99久久精品欧美| 欧美色国产精品| 国产精品18久久久久久vr| 一区二区不卡在线播放 | www.欧美精品一二区| 亚洲国产日日夜夜| 欧美国产综合一区二区| 宅男噜噜噜66一区二区66| 成人激情小说网站| 久久电影网站中文字幕 | 91成人在线免费观看| 国内欧美视频一区二区| 亚洲成av人综合在线观看| 国产免费成人在线视频| 91麻豆精品国产| 色婷婷综合久久久中文字幕| 国产精品一区二区三区乱码| 日韩av网站免费在线| 一个色综合网站| 国产精品麻豆一区二区 | 精品婷婷伊人一区三区三| 高清shemale亚洲人妖| 久久99久久久久久久久久久| 亚洲靠逼com| 国产精品乱人伦中文| 精品国产一区二区三区四区四| 国产午夜精品在线观看| 欧美精品丝袜久久久中文字幕| 91亚洲永久精品| 成人av网址在线| 国产福利精品一区| 国产麻豆成人传媒免费观看| 日日骚欧美日韩| 日韩精品一级中文字幕精品视频免费观看 | 亚洲男人的天堂在线观看| 中文字幕免费不卡在线| 久久综合九色综合久久久精品综合| 欧美精品丝袜久久久中文字幕| 欧美在线视频日韩| 色哟哟日韩精品| 91丝袜高跟美女视频| jlzzjlzz欧美大全| www.成人在线| 99国产精品久久久久久久久久久| 国产成人在线网站| 风间由美中文字幕在线看视频国产欧美 | 成人av网站在线观看| 成人av高清在线| 99久久精品费精品国产一区二区| av在线这里只有精品| 91在线观看成人| 在线免费观看日本欧美| 在线视频观看一区| 欧美日韩三级在线| 欧美一级午夜免费电影| 亚洲精品一区二区三区蜜桃下载| 精品国产123| 欧美激情中文不卡| 亚洲色图视频网站| 性做久久久久久| 久久精品国产精品亚洲精品| 国产激情偷乱视频一区二区三区 | 国产欧美精品国产国产专区| 国产午夜精品久久久久久免费视| 中文字幕va一区二区三区| 中文字幕一区在线观看视频| 一区二区三区不卡在线观看| 调教+趴+乳夹+国产+精品| 美日韩一区二区三区| 国产99久久久国产精品| 91视频观看免费| 在线成人av影院| 久久视频一区二区| 亚洲老司机在线| 麻豆免费精品视频| 91丨国产丨九色丨pron| 51午夜精品国产| 国产精品少妇自拍| 亚洲成a人片在线不卡一二三区| 蜜桃av一区二区三区电影| 国产在线不卡一区| 色综合久久天天综合网| 日韩午夜在线观看| 亚洲图片另类小说| 久久国产麻豆精品| 日本韩国精品在线| 欧美精品一区二区三区在线播放 | 一区二区激情小说| 国产一区欧美日韩| 欧美日韩在线三级| 亚洲国产岛国毛片在线| 爽好久久久欧美精品| 大陆成人av片| 日韩视频免费观看高清在线视频| 国产精品久久久久久久久免费丝袜| 日韩有码一区二区三区| www.亚洲激情.com| 久久欧美中文字幕| 午夜精品福利在线| 99精品久久久久久| 久久久国产午夜精品| 日产精品久久久久久久性色| 成人ar影院免费观看视频| 精品99一区二区三区| 午夜精品久久久久久久99樱桃| 成人免费不卡视频| 欧美精品一区二区三区一线天视频| 一区二区三区国产精品| av在线这里只有精品| 国产日韩影视精品| 麻豆91在线看| 正在播放一区二区| 亚洲国产视频在线| 色天使色偷偷av一区二区| 国产精品视频观看| 国产成人av福利| 26uuuu精品一区二区| 日韩成人精品在线观看| 欧美三级日韩三级国产三级| 中文字幕在线不卡视频| 成人性生交大片免费看视频在线| 欧美zozo另类异族| 玖玖九九国产精品| 91精品国产91久久久久久一区二区 | 91玉足脚交白嫩脚丫在线播放| 久久日一线二线三线suv| 美腿丝袜在线亚洲一区| 欧美一二三区精品| 免费人成在线不卡| 欧美一区二区网站| 日本不卡视频在线观看| 3atv在线一区二区三区| 五月婷婷激情综合| 欧美日韩国产片| 三级欧美在线一区| 日韩欧美中文字幕一区| 美日韩一区二区三区| 欧美不卡在线视频| 国产一区二区三区久久久| 久久综合九色综合97婷婷女人 | 国产成人精品免费视频网站| 久久综合色8888| 国产成人精品亚洲777人妖| 国产色产综合色产在线视频 | 91社区在线播放| 一区二区三区产品免费精品久久75| 色噜噜夜夜夜综合网| 亚洲午夜视频在线观看| 欧美日韩亚州综合| 另类小说视频一区二区| 国产亚洲一二三区| a级高清视频欧美日韩| 一区二区三区不卡在线观看 | 日韩一卡二卡三卡国产欧美| 视频精品一区二区| 久久免费午夜影院| www.成人在线| 日韩专区中文字幕一区二区| 日韩欧美亚洲一区二区| 国产99久久久精品| 一区二区三区在线视频播放 | 91香蕉国产在线观看软件| 亚洲一区欧美一区| 精品粉嫩aⅴ一区二区三区四区| 丁香五精品蜜臀久久久久99网站 | 久久男人中文字幕资源站|