mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-23 00:39:51 +00:00
cleanup aes128 code a bit
This commit is contained in:
parent
a18a5bc545
commit
a40462b155
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user