aes.c File Reference

AES (Rijndael) cipher. More...

#include "includes.h"

Include dependency graph for aes.c:

Go to the source code of this file.

Defines

#define AES_SMALL_TABLES
#define RCON(i)   (rcons[(i)] << 24)
#define TE0(i)   Te0[((i) >> 24) & 0xff]
#define TE1(i)   rotr(Te0[((i) >> 16) & 0xff], 8)
#define TE2(i)   rotr(Te0[((i) >> 8) & 0xff], 16)
#define TE3(i)   rotr(Te0[(i) & 0xff], 24)
#define TE41(i)   ((Te0[((i) >> 24) & 0xff] << 8) & 0xff000000)
#define TE42(i)   (Te0[((i) >> 16) & 0xff] & 0x00ff0000)
#define TE43(i)   (Te0[((i) >> 8) & 0xff] & 0x0000ff00)
#define TE44(i)   ((Te0[(i) & 0xff] >> 8) & 0x000000ff)
#define TE421(i)   ((Te0[((i) >> 16) & 0xff] << 8) & 0xff000000)
#define TE432(i)   (Te0[((i) >> 8) & 0xff] & 0x00ff0000)
#define TE443(i)   (Te0[(i) & 0xff] & 0x0000ff00)
#define TE414(i)   ((Te0[((i) >> 24) & 0xff] >> 8) & 0x000000ff)
#define TE4(i)   ((Te0[(i)] >> 8) & 0x000000ff)
#define TD0(i)   Td0[((i) >> 24) & 0xff]
#define TD1(i)   rotr(Td0[((i) >> 16) & 0xff], 8)
#define TD2(i)   rotr(Td0[((i) >> 8) & 0xff], 16)
#define TD3(i)   rotr(Td0[(i) & 0xff], 24)
#define TD41(i)   (Td4s[((i) >> 24) & 0xff] << 24)
#define TD42(i)   (Td4s[((i) >> 16) & 0xff] << 16)
#define TD43(i)   (Td4s[((i) >> 8) & 0xff] << 8)
#define TD44(i)   (Td4s[(i) & 0xff])
#define TD0_(i)   Td0[(i) & 0xff]
#define TD1_(i)   rotr(Td0[(i) & 0xff], 8)
#define TD2_(i)   rotr(Td0[(i) & 0xff], 16)
#define TD3_(i)   rotr(Td0[(i) & 0xff], 24)
#define SWAP(x)   (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)
#define GETU32(pt)
#define PUTU32(ct, st)
#define ROUND(i, d, s)
#define ROUND(i, d, s)

Functions

void rijndaelKeySetupEnc (u32 rk[], const u8 cipherKey[])
void rijndaelKeySetupDec (u32 rk[], const u8 cipherKey[])
void rijndaelEncrypt (const u32 rk[], const u8 pt[16], u8 ct[16])
void rijndaelDecrypt (const u32 rk[], const u8 ct[16], u8 pt[16])
void * aes_encrypt_init (const u8 *key, size_t len)
 Initialize AES for encryption.
void aes_encrypt (void *ctx, const u8 *plain, u8 *crypt)
 Encrypt one AES block.
void aes_encrypt_deinit (void *ctx)
 Deinitialize AES encryption.
void * aes_decrypt_init (const u8 *key, size_t len)
 Initialize AES for decryption.
void aes_decrypt (void *ctx, const u8 *crypt, u8 *plain)
 Decrypt one AES block.
void aes_decrypt_deinit (void *ctx)
 Deinitialize AES decryption.


Detailed Description

AES (Rijndael) cipher.

Modifications to public domain implementation:

Copyright
Copyright (c) 2003-2005, Jouni Malinen <[email protected]>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

Alternatively, this software may be distributed under the terms of BSD license.

See README and COPYING for more details.

Definition in file aes.c.


Define Documentation

#define GETU32 pt   ) 
 

Value:

(((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ \
((u32)(pt)[2] <<  8) ^ ((u32)(pt)[3]))

Definition at line 858 of file aes.c.

#define PUTU32 ct,
st   ) 
 

Value:

{ \
(ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); \
(ct)[2] = (u8)((st) >>  8); (ct)[3] = (u8)(st); }

Definition at line 860 of file aes.c.

#define ROUND i,
d,
 ) 
 

Value:

d##0 = TD0(s##0) ^ TD1(s##3) ^ TD2(s##2) ^ TD3(s##1) ^ rk[4 * i]; \
d##1 = TD0(s##1) ^ TD1(s##0) ^ TD2(s##3) ^ TD3(s##2) ^ rk[4 * i + 1]; \
d##2 = TD0(s##2) ^ TD1(s##1) ^ TD2(s##0) ^ TD3(s##3) ^ rk[4 * i + 2]; \
d##3 = TD0(s##3) ^ TD1(s##2) ^ TD2(s##1) ^ TD3(s##0) ^ rk[4 * i + 3]

#define ROUND i,
d,
 ) 
 

Value:

d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \
d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \
d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \
d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]


Function Documentation

void aes_decrypt void *  ctx,
const u8 *  crypt,
u8 *  plain
 

Decrypt one AES block.

Parameters:
ctx Context pointer from aes_encrypt_init()
crypt Encrypted data (16 bytes)
plain Buffer for the decrypted data (16 bytes)

Definition at line 1099 of file aes.c.

void aes_decrypt_deinit void *  ctx  ) 
 

Deinitialize AES decryption.

Parameters:
ctx Context pointer from aes_encrypt_init()

Definition at line 1105 of file aes.c.

void* aes_decrypt_init const u8 *  key,
size_t  len
 

Initialize AES for decryption.

Parameters:
key Decryption key
len Key length in bytes (usually 16, i.e., 128 bits)
Returns:
Pointer to context data or NULL on failure

Definition at line 1086 of file aes.c.

Here is the call graph for this function:

void aes_encrypt void *  ctx,
const u8 *  plain,
u8 *  crypt
 

Encrypt one AES block.

Parameters:
ctx Context pointer from aes_encrypt_init()
plain Plaintext data to be encrypted (16 bytes)
crypt Buffer for the encrypted data (16 bytes)

Definition at line 1074 of file aes.c.

void aes_encrypt_deinit void *  ctx  ) 
 

Deinitialize AES encryption.

Parameters:
ctx Context pointer from aes_encrypt_init()

Definition at line 1080 of file aes.c.

void* aes_encrypt_init const u8 *  key,
size_t  len
 

Initialize AES for encryption.

Parameters:
key Encryption key
len Key length in bytes (usually 16, i.e., 128 bits)
Returns:
Pointer to context data or NULL on failure

Definition at line 1061 of file aes.c.

Here is the call graph for this function:

void rijndaelKeySetupDec u32  rk[],
const u8  cipherKey[]
 

Expand the cipher key into the decryption key schedule.

Returns:
the number of rounds for the given cipher key size.

Definition at line 896 of file aes.c.

Here is the call graph for this function:

void rijndaelKeySetupEnc u32  rk[],
const u8  cipherKey[]
 

Expand the cipher key into the encryption key schedule.

Returns:
the number of rounds for the given cipher key size.

Definition at line 870 of file aes.c.


Generated on Sun Dec 31 13:48:59 2006 for wpa_supplicant by  doxygen 1.4.2