Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

beecrypt/aes.c File Reference

AES cipher, code. More...

#include "system.h"
#include "beecrypt.h"
#include "aesopt.h"
#include "aes.h"
#include "endianness.h"
#include "mp32.h"
#include "debug.h"

Go to the source code of this file.

Defines

#define etfs(i)
#define esft(i)
#define elr()
#define dtfs(i)
#define dsft(i)
#define dlr()

Functions

int aesSetup (aesParam *ap, const uint32 *key, int keybits, cipherOperation op)
int aesSetIV (aesParam *ap, const uint32 *iv)
int aesEncrypt (aesParam *ap, uint32 *dst, const uint32 *src)
int aesDecrypt (aesParam *ap, uint32 *dst, const uint32 *src)
int aesECBEncrypt (aesParam *ap, int count, uint32 *dst, const uint32 *src)
int aesECBDecrypt (aesParam *ap, int count, uint32 *dst, const uint32 *src)
int aesCBCEncrypt (aesParam *ap, int count, uint32 *dst, const uint32 *src)
int aesCBCDecrypt (aesParam *ap, int count, uint32 *dst, const uint32 *src)

Variables

const uint32 _ae0 [256]
const uint32 _ae1 [256]
const uint32 _ae2 [256]
const uint32 _ae3 [256]
const uint32 _ae4 [256]
const uint32 _ad0 [256]
const uint32 _ad1 [256]
const uint32 _ad2 [256]
const uint32 _ad3 [256]
const uint32 _ad4 [256]
const uint32 _arc []
const blockMode aesModes [2]
const blockCipher aes = { "AES", sizeof(aesParam), 16, 128, 256, 64, (blockCipherSetup) aesSetup, (blockCipherSetIV) aesSetIV, (blockCipherEncrypt) aesEncrypt, (blockCipherDecrypt) aesDecrypt, aesModes }


Detailed Description

AES cipher, code.

Definition in file aes.c.


Define Documentation

 
#define dlr  
 

Value:

s0 = \
                (_ad4[(t0 >> 24)       ] & 0xff000000) ^ \
                (_ad4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ \
                (_ad4[(t2 >>  8) & 0xff] & 0x0000ff00) ^ \
                (_ad4[(t1      ) & 0xff] & 0x000000ff) ^ \
                rk[0]; \
        s1 = \
                (_ad4[(t1 >> 24)       ] & 0xff000000) ^ \
                (_ad4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ \
                (_ad4[(t3 >>  8) & 0xff] & 0x0000ff00) ^ \
                (_ad4[(t2      ) & 0xff] & 0x000000ff) ^ \
                rk[1]; \
        s2 = \
                (_ad4[(t2 >> 24)       ] & 0xff000000) ^ \
                (_ad4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ \
                (_ad4[(t0 >>  8) & 0xff] & 0x0000ff00) ^ \
                (_ad4[(t3      ) & 0xff] & 0x000000ff) ^ \
                rk[2]; \
        s3 = \
                (_ad4[(t3 >> 24)       ] & 0xff000000) ^ \
                (_ad4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ \
                (_ad4[(t1 >>  8) & 0xff] & 0x0000ff00) ^ \
                (_ad4[(t0      ) & 0xff] & 0x000000ff) ^ \
                rk[3];

Definition at line 1107 of file aes.c.

Referenced by aesDecrypt.

#define dsft  
 

Value:

s0 = \
                _ad0[(t0 >> 24)       ] ^ \
                _ad1[(t3 >> 16) & 0xff] ^ \
                _ad2[(t2 >>  8) & 0xff] ^ \
                _ad3[(t1      ) & 0xff] ^ \
                rk[i+0]; \
    s1 = \
                _ad0[(t1 >> 24)       ] ^ \
                _ad1[(t0 >> 16) & 0xff] ^ \
                _ad2[(t3 >>  8) & 0xff] ^ \
                _ad3[(t2      ) & 0xff] ^ \
                rk[i+1]; \
    s2 = \
                _ad0[(t2 >> 24)       ] ^ \
                _ad1[(t1 >> 16) & 0xff] ^ \
                _ad2[(t0 >>  8) & 0xff] ^ \
                _ad3[(t3      ) & 0xff] ^ \
                rk[i+2]; \
    s3 = \
                _ad0[(t3 >> 24)       ] ^ \
                _ad1[(t2 >> 16) & 0xff] ^ \
                _ad2[(t1 >>  8) & 0xff] ^ \
                _ad3[(t0      ) & 0xff] ^ \
                rk[i+3];

Definition at line 1081 of file aes.c.

Referenced by aesDecrypt.

#define dtfs  
 

Value:

t0 = \
                _ad0[(s0 >> 24)       ] ^ \
                _ad1[(s3 >> 16) & 0xff] ^ \
                _ad2[(s2 >>  8) & 0xff] ^ \
                _ad3[(s1      ) & 0xff] ^ \
                rk[i+0]; \
    t1 = \
                _ad0[(s1 >> 24)       ] ^ \
                _ad1[(s0 >> 16) & 0xff] ^ \
                _ad2[(s3 >>  8) & 0xff] ^ \
                _ad3[(s2      ) & 0xff] ^ \
                rk[i+1]; \
    t2 = \
                _ad0[(s2 >> 24)       ] ^ \
                _ad1[(s1 >> 16) & 0xff] ^ \
                _ad2[(s0 >>  8) & 0xff] ^ \
                _ad3[(s3      ) & 0xff] ^ \
                rk[i+2]; \
    t3 = \
                _ad0[(s3 >> 24)       ] ^ \
                _ad1[(s2 >> 16) & 0xff] ^ \
                _ad2[(s1 >>  8) & 0xff] ^ \
                _ad3[(s0      ) & 0xff] ^ \
                rk[i+3];

Definition at line 1055 of file aes.c.

Referenced by aesDecrypt.

 
#define elr  
 

Value:

s0 = \
                (_ae4[(t0 >> 24)       ] & 0xff000000) ^ \
                (_ae4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ \
                (_ae4[(t2 >>  8) & 0xff] & 0x0000ff00) ^ \
                (_ae4[(t3      ) & 0xff] & 0x000000ff) ^ \
                rk[0]; \
        s1 = \
                (_ae4[(t1 >> 24)       ] & 0xff000000) ^ \
                (_ae4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ \
                (_ae4[(t3 >>  8) & 0xff] & 0x0000ff00) ^ \
                (_ae4[(t0      ) & 0xff] & 0x000000ff) ^ \
                rk[1]; \
        s2 = \
                (_ae4[(t2 >> 24)       ] & 0xff000000) ^ \
                (_ae4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ \
                (_ae4[(t0 >>  8) & 0xff] & 0x0000ff00) ^ \
                (_ae4[(t1      ) & 0xff] & 0x000000ff) ^ \
                rk[2]; \
        s3 = \
                (_ae4[(t3 >> 24)       ] & 0xff000000) ^ \
                (_ae4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ \
                (_ae4[(t1 >>  8) & 0xff] & 0x0000ff00) ^ \
                (_ae4[(t2      ) & 0xff] & 0x000000ff) ^ \
                rk[3];

Definition at line 967 of file aes.c.

Referenced by aesEncrypt.

#define esft  
 

Value:

s0 = \
                _ae0[(t0 >> 24)       ] ^ \
                _ae1[(t1 >> 16) & 0xff] ^ \
                _ae2[(t2 >>  8) & 0xff] ^ \
                _ae3[(t3      ) & 0xff] ^ \
                rk[i+0]; \
        s1 = \
                _ae0[(t1 >> 24)       ] ^ \
                _ae1[(t2 >> 16) & 0xff] ^ \
                _ae2[(t3 >>  8) & 0xff] ^ \
                _ae3[(t0      ) & 0xff] ^ \
                rk[i+1]; \
        s2 = \
                _ae0[(t2 >> 24)       ] ^ \
                _ae1[(t3 >> 16) & 0xff] ^ \
                _ae2[(t0 >>  8) & 0xff] ^ \
                _ae3[(t1      ) & 0xff] ^ \
                rk[i+2]; \
        s3 = \
                _ae0[(t3 >> 24)       ] ^ \
                _ae1[(t0 >> 16) & 0xff] ^ \
                _ae2[(t1 >>  8) & 0xff] ^ \
                _ae3[(t2      ) & 0xff] ^ \
                rk[i+3];

Definition at line 941 of file aes.c.

Referenced by aesEncrypt.

#define etfs  
 

Value:

t0 = \
                _ae0[(s0 >> 24)       ] ^ \
                _ae1[(s1 >> 16) & 0xff] ^ \
                _ae2[(s2 >>  8) & 0xff] ^ \
                _ae3[(s3      ) & 0xff] ^ \
                rk[i+0]; \
        t1 = \
                _ae0[(s1 >> 24)       ] ^ \
                _ae1[(s2 >> 16) & 0xff] ^ \
                _ae2[(s3 >>  8) & 0xff] ^ \
                _ae3[(s0      ) & 0xff] ^ \
                rk[i+1]; \
        t2 = \
                _ae0[(s2 >> 24)       ] ^ \
                _ae1[(s3 >> 16) & 0xff] ^ \
                _ae2[(s0 >>  8) & 0xff] ^ \
                _ae3[(s1      ) & 0xff] ^ \
                rk[i+2]; \
        t3 = \
                _ae0[(s3 >> 24)       ] ^ \
                _ae1[(s0 >> 16) & 0xff] ^ \
                _ae2[(s1 >>  8) & 0xff] ^ \
                _ae3[(s2      ) & 0xff] ^ \
                rk[i+3];

Definition at line 915 of file aes.c.

Referenced by aesEncrypt.


Variable Documentation

const uint32 _ad0[256]
 

Definition at line 389 of file aes.c.

Referenced by aesSetup.

const uint32 _ad1[256]
 

Definition at line 459 of file aes.c.

Referenced by aesSetup.

const uint32 _ad2[256]
 

Definition at line 529 of file aes.c.

Referenced by aesSetup.

const uint32 _ad3[256]
 

Definition at line 599 of file aes.c.

Referenced by aesSetup.

const uint32 _ad4[256]
 

Definition at line 669 of file aes.c.

const uint32 _ae0[256]
 

Definition at line 39 of file aes.c.

const uint32 _ae1[256]
 

Definition at line 109 of file aes.c.

const uint32 _ae2[256]
 

Definition at line 179 of file aes.c.

const uint32 _ae3[256]
 

Definition at line 249 of file aes.c.

const uint32 _ae4[256]
 

Definition at line 319 of file aes.c.

Referenced by aesSetup.

const uint32 _arc[] [static]
 

Initial value:

 {
        0x01000000, 0x02000000, 0x04000000, 0x08000000,
        0x10000000, 0x20000000, 0x40000000, 0x80000000,
        0x1B000000, 0x36000000
}

Definition at line 740 of file aes.c.

Referenced by aesSetup.

const blockMode aesModes[2] [static]
 

Initial value:

{
        {  (blockModeEncrypt) aesECBEncrypt, (blockModeDecrypt) aesECBDecrypt },
        {  (blockModeEncrypt) aesCBCEncrypt, (blockModeDecrypt) aesCBCDecrypt }
}

Definition at line 749 of file aes.c.


Generated on Tue Sep 17 16:00:00 2002 for rpm by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002