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

Subversion Repositories avs_aes

[/] [avs_aes/] [trunk/] [sw/] [avs_aes.c] - Blame information for rev 10

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 ruschi
#include <avs_aes.h>
2
#include <string.h>
3
 
4
void avs_aes_init(avs_aes_handle* context){
5
        context->key    = (unsigned int*) KEY_ADDR;
6
        context->payload= (unsigned int*) DATA_ADDR;
7
        context->result = (unsigned int*) RESULT_ADDR;
8
        context->control        = (unsigned int*) AESCTRLWD;
9
        *(context->control) = 0x00000000;
10
}
11
 
12
void avs_aes_setKey(avs_aes_handle* context, unsigned int* key){
13
        int i=0;
14
        unsigned int* target_ptr = (unsigned int* )context->key;
15
        // Invalidate old key;
16
        *(context->control) &= (~0x00000080);
17
        for(i=0; i<KEYWORDS; i++){
18
                *(target_ptr++) = *(key++);
19
        }
20
        // validate key;
21
        *(context->control) |= 0x00000080;
22
}
23
 
24
void avs_aes_setPayload(avs_aes_handle* context, unsigned int* payload){
25
        int i=0;
26
        unsigned int* target_ptr = (unsigned int* )context->payload;
27
        for(i=0; i<4; i++){
28
                *(target_ptr++) = *(payload++);
29
        }
30
}
31
 
32
 
33
void avs_aes_setKeyvalid(avs_aes_handle* context){
34
        *(context->control) |= 0x00000080;
35
}
36
 
37
void avs_aes_encrypt(avs_aes_handle* context){
38
        *(context->control) |= 0x00000001;
39
}
40
 
41
void avs_aes_decrypt(avs_aes_handle* context){
42
        *(context->control) |= 0x00000002;
43
}
44
 
45
int avs_aes_isBusy(avs_aes_handle* context){
46
        unsigned int mycontrol = *(context->control);
47
        return mycontrol & 0x03;
48
}

powered by: WebSVN 2.1.0

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