From 3a19ceb903629a9ff7ce85f800c1b4fefc8aa2c5 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 13 Mar 2016 01:32:32 +0100 Subject: Removed unnecessary typedefs from des.h Signed-off-by: Haru --- src/common/des.c | 28 ++++++++++++++-------------- src/common/des.h | 12 +++++++++--- src/common/grfio.c | 16 ++++++++-------- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/common/des.c b/src/common/des.c index c811dd96c..706aafbdd 100644 --- a/src/common/des.c +++ b/src/common/des.c @@ -40,9 +40,9 @@ static const uint8_t mask[8] = { /// Initial permutation (IP). -static void IP(BIT64* src) +static void IP(struct BIT64 *src) { - BIT64 tmp = {{0}}; + struct BIT64 tmp = {{0}}; static const uint8_t ip_table[64] = { 58, 50, 42, 34, 26, 18, 10, 2, @@ -68,9 +68,9 @@ static void IP(BIT64* src) /// Final permutation (IP^-1). -static void FP(BIT64* src) +static void FP(struct BIT64 *src) { - BIT64 tmp = {{0}}; + struct BIT64 tmp = {{0}}; static const uint8_t fp_table[64] = { 40, 8, 48, 16, 56, 24, 64, 32, @@ -97,9 +97,9 @@ static void FP(BIT64* src) /// Expansion (E). /// Expands upper four 8-bits (32b) into eight 6-bits (48b). -static void E(BIT64* src) +static void E(struct BIT64 *src) { - BIT64 tmp = {{0}}; + struct BIT64 tmp = {{0}}; #if 0 // original @@ -137,9 +137,9 @@ static void E(BIT64* src) /// Transposition (P-BOX). -static void TP(BIT64* src) +static void TP(struct BIT64 *src) { - BIT64 tmp = {{0}}; + struct BIT64 tmp = {{0}}; static const uint8_t tp_table[32] = { 16, 7, 20, 21, @@ -166,9 +166,9 @@ static void TP(BIT64* src) /// Substitution boxes (S-boxes). /// NOTE: This implementation was optimized to process two nibbles in one step (twice as fast). -static void SBOX(BIT64* src) +static void SBOX(struct BIT64 *src) { - BIT64 tmp = {{0}}; + struct BIT64 tmp = {{0}}; static const uint8_t s_table[4][64] = { { @@ -207,9 +207,9 @@ static void SBOX(BIT64* src) /// DES round function. /// XORs src[0..3] with TP(SBOX(E(src[4..7]))). -static void RoundFunction(BIT64* src) +static void RoundFunction(struct BIT64 *src) { - BIT64 tmp = *src; + struct BIT64 tmp = *src; E(&tmp); SBOX(&tmp); TP(&tmp); @@ -221,7 +221,7 @@ static void RoundFunction(BIT64* src) } -void des_decrypt_block(BIT64* block) +void des_decrypt_block(struct BIT64 *block) { IP(block); RoundFunction(block); @@ -231,7 +231,7 @@ void des_decrypt_block(BIT64* block) void des_decrypt(unsigned char* data, size_t size) { - BIT64* p = (BIT64*)data; + struct BIT64 *p = (struct BIT64 *)data; size_t i; for( i = 0; i*8 < size; i += 8 ) diff --git a/src/common/des.h b/src/common/des.h index e7460e9fd..61cf2c04a 100644 --- a/src/common/des.h +++ b/src/common/des.h @@ -23,12 +23,18 @@ #include "common/hercules.h" +/* Struct definitions */ + /// One 64-bit block. -typedef struct BIT64 { uint8_t b[8]; } BIT64; +struct BIT64 { + uint8_t b[8]; +}; + +/* Interface */ struct des_interface { - void (*decrypt_block) (BIT64* block); - void (*decrypt) (unsigned char* data, size_t size); + void (*decrypt_block) (struct BIT64 *block); + void (*decrypt) (unsigned char *data, size_t size); }; #ifdef HERCULES_CORE diff --git a/src/common/grfio.c b/src/common/grfio.c index c24f2aee5..c5c38455d 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -121,9 +121,9 @@ static uint8_t grf_substitution(uint8_t in) } #if 0 /* this is not used anywhere, is it ok to delete? */ -static void grf_shuffle_enc(BIT64* src) +static void grf_shuffle_enc(struct BIT64 *src) { - BIT64 out; + struct BIT64 out; out.b[0] = src->b[3]; out.b[1] = src->b[4]; @@ -138,9 +138,9 @@ static void grf_shuffle_enc(BIT64* src) } #endif // 0 -static void grf_shuffle_dec(BIT64* src) +static void grf_shuffle_dec(struct BIT64 *src) { - BIT64 out; + struct BIT64 out; out.b[0] = src->b[3]; out.b[1] = src->b[4]; @@ -156,8 +156,8 @@ static void grf_shuffle_dec(BIT64* src) static void grf_decode_header(unsigned char* buf, size_t len) { - BIT64* p = (BIT64*)buf; - size_t nblocks = len / sizeof(BIT64); + struct BIT64 *p = (struct BIT64 *)buf; + size_t nblocks = len / sizeof(struct BIT64); size_t i; // first 20 blocks are all des-encrypted @@ -169,8 +169,8 @@ static void grf_decode_header(unsigned char* buf, size_t len) static void grf_decode_full(unsigned char* buf, size_t len, int cycle) { - BIT64* p = (BIT64*)buf; - size_t nblocks = len / sizeof(BIT64); + struct BIT64 *p = (struct BIT64 *)buf; + size_t nblocks = len / sizeof(struct BIT64); int dcycle, scycle; size_t i, j; -- cgit v1.2.3-60-g2f50