Thread: Execution Time - Rijandael encryption

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    230

    Execution Time - Rijandael encryption

    My professor posted this problem for us.

    The reading assignment in the last lecture covered how AES (Rjindael) works. This problem will give you an idea as to how much processing time AES requires to perform key generation, encryption and decryption.
    Download the AES implementation source code from: http://islab.oregonstate.edu/koc/ece...Sha/sprash.zip
    First, familiarize yourself with the AES key generation, encryption and decryption functions in this source code. Choose a key and block size of 128 bits. Choose any plaintext M 128*5 bit long. Then, perform the following:
    1) Execute the key generation function to get a key K
    • Compute the execution time.
    2) Execute the encryption function to encrypt M using K, and obtain the ciphertext
    • Compute the execution time.
    3) Execute the decryption function to decrypt C using K, and to obtain M back.
    • Compute the execution time.

    Repeat each of the above steps 100 times and give the average execution time for each of the three functions. List the type and speed of the processor, and the memory (RAM) of the machine you execute the code on.

    I hope you know how to measure execution time! If not, please try to figure it out yourself before asking for help. Include a description of how you measured the timing, such as what functions you measured the execution time of.



    I chose a plaintext of 5 blocks of(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
    and a key of (bbbbbbbbbbbbbbbbbbbbbb)
    I used this as my way of measuring execution time
    In the rijandael.cpp file are the functions for makekey, enrcrypt, decrypt.
    as a note i changed the the memset and buffers from 300 to 600 b/c it kept crashing

    Code:
    void CRijndael::Encrypt(char const* in, char* result, size_t n)
    {
    	time_t begin = clock();
    	memset(result,0,600);
    	if(false==m_bKeyInit)
    		throw exception(sm_szErrorMsg1);
    	//n should be > 0 and multiple of m_blockSize
    	if(0==n || n%m_blockSize!=0)
    		throw exception(sm_szErrorMsg2);
    	int i;
    	char const* pin;
    	char* presult;
    	for(i=0,pin=in,presult=result; i<n/m_blockSize; i++)
    	{
    		EncryptBlock(pin, presult);
    		pin += m_blockSize;
    		presult += m_blockSize;
    	}
    
    	result[n] = '\0';
    	time_t end = clock();
    	double dif = difftime(end,begin);
    	ofstream myfile;
    	myfile.open("Encrypt.txt", ios::app);
    	myfile << "Diffms: " << dif << endl;
    	myfile.close();
    	
    }
    I keep getting 0 or .1 ms for my times (encryption/decryption) and i know this is a fast algorithm but I just wanted to know if im doing this correctly or any1 else is getting the same values.
    Last edited by Salem; 09-21-2008 at 12:13 AM. Reason: quote tags for the prose
    C++ Rules!!!!
    ------------
    Microsoft Visual Studio .NET Enterprise

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mac OS X Users/C programmers?
    By petermichaux in forum C Programming
    Replies: 16
    Last Post: 04-18-2011, 06:36 AM
  2. How to get program execution time
    By pobri19 in forum C++ Programming
    Replies: 8
    Last Post: 01-20-2009, 07:45 AM
  3. Representing floats with color?
    By DrSnuggles in forum C++ Programming
    Replies: 113
    Last Post: 12-30-2008, 09:11 AM
  4. execution time
    By shuo in forum C++ Programming
    Replies: 3
    Last Post: 10-17-2007, 02:58 AM
  5. relating date....
    By Prakash in forum C Programming
    Replies: 3
    Last Post: 09-19-2001, 09:08 AM