To tylko jedna z 31 stron tej notatki. Zaloguj się aby zobaczyć ten dokument.
Zobacz
całą notatkę
Zygmunt Kubiak. Notatka składa się z 31 stron.
Instytut Informatyki Laboratorium Bezprzewodowych Sieci Sensorowych Sprawozdanie z ćwiczenia Temat Szyfrowanie AES Rok akademicki 2011/2012 Data wykonania ć wiczenia 2011-10-26 Data oddania sprawozdania 2011-11-09 Termin zajęć Skład grupy laboratoryjnej 1. 2. Rok/semestr/grupa Rok 4, Sem 7, gr A2 Ocena 1. Szyfrowanie AES 1.1. Kod programu Do projektu dodano standardowe pliki nagłówkowe: • C8051F020_defs.h • compiler_defs.h • dev.h • uart.h oraz: • F326_AES_Cipher.h //----------------------------------------------------------------------------- // F326_AES_Cipher.h //----------------------------------------------------------------------------- // Copyright 2007 Silicon Laboratories, Inc. // http://www.silabs.com // // Program Description: // // // How To Test: See Readme.txt // // // Target: C8051F326 // Tool chain: Keil C51 7.50 / Keil EVAL C51 // Silicon Laboratories IDE version 2.91 // Command Line: See Readme.txt // Project Name: F326_AES // // // Release 1.0 // -Initial Revision (CG/GP) // -11 JUN 2007 // #ifndef _F326_AES_CIPHER_H_ #define _F326_AES_CIPHER_H_ //----------------------------------------------------------------------------- // Typdefs //----------------------------------------------------------------------------- #include "F326_AES_Typedef.h" #include "F326_AES_Parameters.h" #include "F326_AES_Sbox.h" #include "F326_AES_Cipher.h" //----------------------------------------------------------------------------- // Prototypes //----------------------------------------------------------------------------- void Cipher (byte *in, byte *out); //----------------------------------------------------------------------------- // Close File Definition //----------------------------------------------------------------------------- //extern pdata byte EXP_KEYS[]; static byte data State[4][4]; // State vector; stored explicitly in // RAM for speed purposes static byte data CurrentKey[4][4]; // Stores the keys for the current round // of encryption //----------------------------------------------------------------------------- // Prototypes //----------------------------------------------------------------------------- void Cipher (byte *in, byte *out); // Functions defined in the AES specification; Core functions of the encryption void SubBytes (void); void ShiftRows (void); void MixColumns (void); void AddRoundKey (void); void StateIn (byte *in); void StateOut (byte *out); void LoadKeys (char i);
(…)
… : None
// Parameters : 1) byte *in - pointer to array of input, plaintext data
//
2) byte *out - pointer to array output, encrypted data
//
// Procedure that encrypts a message using AES/Rijndael
//
//----------------------------------------------------------------------------void Cipher (byte *in, byte *out)
{
char r;
int i;
StateIn (in);
// Load string to be encrypted
LoadKeys (0);
AddRoundKey…
…
//----------------------------------------------------------------------------//
// Return Value : None
// Parameters : 1) byte *in - pointer to the input which is plaintext data
//
// Copies the plaintext data to the global State array
//
//----------------------------------------------------------------------------void StateIn(byte *in)
{
char col,row;
for(col = 0; col < 4; col++) {
for(row = 0; row < 4; row++) {
State[row][col] = *(in++); }}
}
//----------------------------------------------------------------------------// StateOut
//----------------------------------------------------------------------------//
// Return Value : None
// Parameters : 1) byte *out - pointer to the output which is encrypted data
//
// Copies the encrypted data from the global State array to the output array
//
//----------------------------------------------------------------------------void StateOut (byte *out)
{
byte col,row;
for(col = 0…
…);
//----------------------------------------------------------------------------// Support Subroutines
//----------------------------------------------------------------------------//----------------------------------------------------------------------------// InvCipher
//----------------------------------------------------------------------------//
// Return Value : None
// Parameters : 1) byte *in - pointer to array of input, encrypted data
//
2) byte *out - pointer to array output…
… temp_result;
unsigned int check;
if (y==0) {
return 0; }
// Multiplying by 0 always returns 0,
// !! Since we are checking carry flag, must be aware of what is happening
// to PSW register after the addition. If an interrupt is posted after
// the addition but before the CY bit is set, the behavior of this function
// is not necessarily correct.
// save EA bit status and clear it.
check = (unsigned int…
… Laboratories IDE version 2.91
// Command Line: See Readme.txt
// Project Name: F326_AES
//
//
// Release 1.0
// -Initial Revision (CG/GP)
// -11 JUN 2007
//
#ifndef _F326_AES_TYPEDEF_H_
#define _F326_AES_TYPEDEF_H_
//----------------------------------------------------------------------------// Type definitions
//----------------------------------------------------------------------------typedef unsigned char…
... zobacz całą notatkę
Komentarze użytkowników (0)