summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2016-03-13 01:32:32 +0100
committerHaru <haru@dotalux.com>2016-07-12 20:58:32 +0200
commit3a19ceb903629a9ff7ce85f800c1b4fefc8aa2c5 (patch)
tree6d53af669e4ff00876a8e44261a6b9672ad172ee /src
parenta19ecac6d3405652f766eb7b18c7ee6a3270a78b (diff)
downloadhercules-3a19ceb903629a9ff7ce85f800c1b4fefc8aa2c5.tar.gz
hercules-3a19ceb903629a9ff7ce85f800c1b4fefc8aa2c5.tar.bz2
hercules-3a19ceb903629a9ff7ce85f800c1b4fefc8aa2c5.tar.xz
hercules-3a19ceb903629a9ff7ce85f800c1b4fefc8aa2c5.zip
Removed unnecessary typedefs from des.h
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src')
-rw-r--r--src/common/des.c28
-rw-r--r--src/common/des.h12
-rw-r--r--src/common/grfio.c16
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;