OpenCores
URL https://opencores.org/ocsvn/avs_aes/avs_aes/trunk

Subversion Repositories avs_aes

[/] [avs_aes/] [trunk/] [sw/] [AEStester.c] - Diff between revs 5 and 11

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 5 Rev 11
Line 1... Line 1...
 
/**
 
*  \file AEStester.c
 
*  \brief test program and example of how to use the software
 
*
 
*  This file is part of the project      avs_aes
 
*  see: http://opencores.org/project,avs_aes
 
*
 
* \section AUTHORS
 
*          Thomas Ruschival -- ruschi@opencores.org (www.ruschival.de)
 
*
 
* \section LICENSE
 
*  Copyright (c) 2009, Authors and opencores.org
 
*  All rights reserved.
 
*
 
*  Redistribution and use in source and binary forms, with or without modification,
 
*  are permitted provided that the following conditions are met:
 
*         * Redistributions of source code must retain the above copyright notice,
 
*         this list of conditions and the following disclaimer.
 
*         * Redistributions in binary form must reproduce the above copyright notice,
 
*         this list of conditions and the following disclaimer in the documentation
 
*         and/or other materials provided with the distribution.
 
*         * Neither the name of the organization nor the names of its contributors
 
*         may be used to endorse or promote products derived from this software without
 
*         specific prior written permission.
 
*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
*  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
*  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
*  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 
*  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 
*  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
*  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
*  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
*  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
*  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 
*  THE POSSIBILITY OF SUCH DAMAGE
 
*/
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <avs_aes.h>
#include <avs_aes.h>
#include <avs_aes_driver.h>
 
#define SDRAM_ADDR     0x08000000
 
 
 
 
 
int main(){
int main(){
        volatile unsigned int* aesctrl       = (unsigned int *)AESCTRLWD;
 
        volatile unsigned int* resultport    = (unsigned int *)RESULT_ADDR;
 
        volatile unsigned int* dataport      = (unsigned int *)DATA_ADDR;
 
        volatile unsigned int* keyport           = (unsigned int *)KEY_ADDR;
 
        avs_aes_handle context;
        avs_aes_handle context;
 
 
 
 
    //init pointers
 
    volatile int* wptr = (int*)SDRAM_ADDR;
 
    volatile int* rptr = (int*)SDRAM_ADDR;
 
        int i=0;
        int i=0;
 
 
    unsigned int result[4];
    unsigned int result[4];
        unsigned int Userkey[8] = {
        unsigned int Userkey[8] = {
                0x11111111,0x22222222,0x33333333,0x44444444,
                0x11111111,0x22222222,0x33333333,0x44444444,
                0x55555555,0x66666666,0x77777777,0x88888888};
                0x55555555,0x66666666,0x77777777,0x88888888};
        unsigned int Payload[4] = {
        unsigned int Payload[4] = {
                0xAA555555,0xBB666666,0xCC777777,0xDD888888};
                0xAA555555,0xBB666666,0xCC777777,0xDD888888};
 
 
 
 
 
 
 
 
// Start MEMTEST   
 
    printf("Hello from Nios II!\n");
 
    // Fill the memory 
 
    printf("Filling Memory at %p \n",wptr);
 
    i=42;
 
    while(i< 4){
 
        printf("| %d -> %X |\n",i, wptr);
 
        *(wptr++)=Userkey[i++];
 
    }
 
    i=0;
 
    printf("\n I: %d Reading Memory from %X \n",i,rptr);
 
 
 
    while(i< 4){
 
        printf("MEM: %X > %X \n",rptr,*rptr);
 
        rptr++;
 
        i++;
 
    }
 
 
 
// START AES-Operations
// START AES-Operations
        printf("AES-Test\n");
        printf("AES-Test\n");
        avs_aes_init(&context);
        avs_aes_init(&context);
        avs_aes_setKey(&context,&Userkey);
        avs_aes_setKey(&context,&Userkey);
        avs_aes_setPayload(&context,&Payload);
        avs_aes_setPayload(&context,&Payload);
        avs_aes_encrypt(&context);
        avs_aes_encrypt(&context);
 
 
    while(avs_aes_isBusy(&context)){
    while(avs_aes_isBusy(&context)){
        printf("not ready\n");
        printf("not ready\n");
    }
    }
    printf("receiving 729cd44f 32a48d85 b8188185 c579ae49\n");
    printf("receiving 729cd44f 32a48d85 b8188185 c579ae49\n");
    memcpy(result,context.result,4*sizeof(unsigned int));
    memcpy(result,context.result,4*sizeof(unsigned int));

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.