1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-15 00:02:49 +03:00

adjusted version checking mechanism

git-svn-id: svn://svn.code.sf.net/p/axtls/code/trunk@46 9a5d90b5-6617-0410-8a86-bb477d3ed2e3
This commit is contained in:
cameronrich
2006-12-01 03:57:08 +00:00
parent df2886ed07
commit 3d2f9ac3fd
10 changed files with 151 additions and 173 deletions

View File

@ -17,8 +17,6 @@
*/
/**
* @file aes.c
*
* AES implementation - this is a small code version. There are much faster
* versions around but they are much larger in size (i.e. they use large
* submix tables).
@ -34,12 +32,13 @@
#define rot2(x) (((x) << 16) | ((x) >> 16))
#define rot3(x) (((x) << 8) | ((x) >> 24))
/* This cute trick does 4 'mul by two' at once. Stolen from
/*
* This cute trick does 4 'mul by two' at once. Stolen from
* Dr B. R. Gladman <brg@gladman.uk.net> but I'm sure the u-(u>>7) is
* a standard graphics trick
* The key to this is that we need to xor with 0x1b if the top bit is set.
* a 1xxx xxxx 0xxx 0xxx First we mask the 7bit,
* b 1000 0000 0000 0000 then we shift right by 7 puting the 7bit in 0bit,
* b 1000 0000 0000 0000 then we shift right by 7 putting the 7bit in 0bit,
* c 0000 0001 0000 0000 we then subtract (c) from (b)
* d 0111 1111 0000 0000 and now we and with our mask
* e 0001 1011 0000 0000
@ -194,7 +193,7 @@ void AES_set_key(AES_CTX *ctx, const uint8_t *key,
ctx->rounds = i;
ctx->key_size = words;
W = ctx->ks;
for (i=0; i<words; i+=2)
for (i = 0; i < words; i+=2)
{
W[i+0]= ((uint32_t)key[ 0]<<24)|
((uint32_t)key[ 1]<<16)|
@ -212,6 +211,7 @@ void AES_set_key(AES_CTX *ctx, const uint8_t *key,
for (i = words; i<ii; i++)
{
tmp = W[i-1];
if ((i % words) == 0)
{
tmp2 =(uint32_t)aes_sbox[(tmp )&0xff]<< 8;
@ -221,6 +221,7 @@ void AES_set_key(AES_CTX *ctx, const uint8_t *key,
tmp=tmp2^(((unsigned int)*ip)<<24);
ip++;
}
if ((words == 8) && ((i % words) == 4))
{
tmp2 =(uint32_t)aes_sbox[(tmp )&0xff] ;
@ -247,6 +248,7 @@ void AES_convert_key(AES_CTX *ctx)
k = ctx->ks;
k += 4;
for (i=ctx->rounds*4; i>4; i--)
{
w= *k;
@ -474,4 +476,3 @@ static void AES_decrypt(const AES_CTX *ctx, uint32_t *data)
}
#endif