cleanup aes128 code a bit

This commit is contained in:
matthias.ringwald@gmail.com 2014-04-25 10:38:31 +00:00
parent a18a5bc545
commit a40462b155
2 changed files with 16 additions and 25 deletions

View File

@ -3,18 +3,15 @@
// License: Public Domain,
// Author: Philip J. Erdelsky
#include <stdint.h>
#define FULL_UNROLL
#include "rijndael.h"
// #include "KILL_DEBUGGER.h"
#define KILL_DEBUGGER()
typedef unsigned long u32;
typedef unsigned char u8;
int rijndaelStartOfCode(){
return 1;
}
typedef uint32_t u32;
typedef uint8_t u8;
static const u32 Te0[256] =
{
@ -854,7 +851,6 @@ int rijndaelSetupDecrypt(u32 *rk, const u8 *key, int keybits)
void rijndaelEncrypt(const u32 *rk, int nrounds, const u8 plaintext[16],
u8 ciphertext[16])
{
KILL_DEBUGGER();
u32 s0, s1, s2, s3, t0, t1, t2, t3;
#ifndef FULL_UNROLL
@ -1034,7 +1030,6 @@ void rijndaelEncrypt(const u32 *rk, int nrounds, const u8 plaintext[16],
rk[3];
PUTU32(ciphertext + 12, s3);
KILL_DEBUGGER();
}
@ -1042,7 +1037,6 @@ void rijndaelDecrypt(const u32 *rk, int nrounds, const u8 ciphertext[16],
u8 plaintext[16])
{
KILL_DEBUGGER();
u32 s0, s1, s2, s3, t0, t1, t2, t3;
@ -1225,10 +1219,5 @@ u32 s0, s1, s2, s3, t0, t1, t2, t3;
PUTU32(plaintext + 12, s3);
KILL_DEBUGGER();
}
int rijndaelEndOfCode(){
return 1;
}

View File

@ -6,16 +6,14 @@
#ifndef H__RIJNDAEL
#define H__RIJNDAEL
int rijndaelStartOfCode();
int rijndaelSetupEncrypt(unsigned long *rk, const unsigned char *key,
int keybits);
int rijndaelSetupDecrypt(unsigned long *rk, const unsigned char *key,
int keybits);
void rijndaelEncrypt(const unsigned long *rk, int nrounds,
const unsigned char plaintext[16], unsigned char ciphertext[16]);
void rijndaelDecrypt(const unsigned long *rk, int nrounds,
const unsigned char ciphertext[16], unsigned char plaintext[16]);
int rijndaelEndOfCode();
#if defined __cplusplus
extern "C" {
#endif
int rijndaelSetupEncrypt(unsigned long *rk, const unsigned char *key, int keybits);
int rijndaelSetupDecrypt(unsigned long *rk, const unsigned char *key, int keybits);
void rijndaelEncrypt(const unsigned long *rk, int nrounds, const unsigned char plaintext[16], unsigned char ciphertext[16]);
void rijndaelDecrypt(const unsigned long *rk, int nrounds, const unsigned char ciphertext[16], unsigned char plaintext[16]);
#define KEYBITS 128
@ -23,5 +21,9 @@ int rijndaelEndOfCode();
#define RKLENGTH(keybits) ((keybits)/8+28)
#define NROUNDS(keybits) ((keybits)/32+6)
#if defined __cplusplus
}
#endif
#endif