Skip to content

Commit cb63d3c

Browse files
karel-msjaeckel
authored andcommitted
Fix macro names - related to #448
1 parent 89d991e commit cb63d3c

27 files changed

Lines changed: 321 additions & 333 deletions

src/ciphers/aes/aes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const struct ltc_cipher_descriptor aes_enc_desc =
8080

8181
#endif
8282

83-
#define __LTC_AES_TAB_C__
83+
#define LTC_AES_TAB_C
8484
#include "aes_tab.c"
8585

8686
static ulong32 setup_mix(ulong32 temp)

src/ciphers/aes/aes_tab.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Td3[x] = Si[x].[09, 0d, 0b, 0e];
1515
Td4[x] = Si[x].[01, 01, 01, 01];
1616
*/
1717

18-
#ifdef __LTC_AES_TAB_C__
18+
#ifdef LTC_AES_TAB_C
1919

2020
/**
2121
@file aes_tab.c
@@ -1019,4 +1019,4 @@ static const ulong32 rcon[] = {
10191019
};
10201020
#endif
10211021

1022-
#endif /* __LTC_AES_TAB_C__ */
1022+
#endif /* LTC_AES_TAB_C */

src/ciphers/cast5.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -491,29 +491,23 @@ int cast5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_
491491
}
492492
#endif
493493

494-
#ifdef _MSC_VER
495-
#define INLINE __inline
496-
#else
497-
#define INLINE
498-
#endif
499-
500-
INLINE static ulong32 FI(ulong32 R, ulong32 Km, ulong32 Kr)
494+
LTC_INLINE static ulong32 FI(ulong32 R, ulong32 Km, ulong32 Kr)
501495
{
502496
ulong32 I;
503497
I = (Km + R);
504498
I = ROL(I, Kr);
505499
return ((S1[LTC_BYTE(I, 3)] ^ S2[LTC_BYTE(I,2)]) - S3[LTC_BYTE(I,1)]) + S4[LTC_BYTE(I,0)];
506500
}
507501

508-
INLINE static ulong32 FII(ulong32 R, ulong32 Km, ulong32 Kr)
502+
LTC_INLINE static ulong32 FII(ulong32 R, ulong32 Km, ulong32 Kr)
509503
{
510504
ulong32 I;
511505
I = (Km ^ R);
512506
I = ROL(I, Kr);
513507
return ((S1[LTC_BYTE(I, 3)] - S2[LTC_BYTE(I,2)]) + S3[LTC_BYTE(I,1)]) ^ S4[LTC_BYTE(I,0)];
514508
}
515509

516-
INLINE static ulong32 FIII(ulong32 R, ulong32 Km, ulong32 Kr)
510+
LTC_INLINE static ulong32 FIII(ulong32 R, ulong32 Km, ulong32 Kr)
517511
{
518512
ulong32 I;
519513
I = (Km - R);

src/ciphers/idea.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,35 +35,35 @@ const struct ltc_cipher_descriptor idea_desc = {
3535

3636
typedef unsigned short int ushort16;
3737

38-
#define _LOW16(x) ((x)&0xffff) /* compiler should be able to optimize this away if x is 16 bits */
39-
#define _HIGH16(x) ((x)>>16)
40-
#define _MUL(a,b) { \
41-
ulong32 p = (ulong32)_LOW16(a) * b; \
38+
#define LOW16(x) ((x)&0xffff) /* compiler should be able to optimize this away if x is 16 bits */
39+
#define HIGH16(x) ((x)>>16)
40+
#define MUL(a,b) { \
41+
ulong32 p = (ulong32)LOW16(a) * b; \
4242
if (p) { \
43-
p = _LOW16(p) - _HIGH16(p); \
44-
a = (ushort16)p - (ushort16)_HIGH16(p); \
43+
p = LOW16(p) - HIGH16(p); \
44+
a = (ushort16)p - (ushort16)HIGH16(p); \
4545
} \
4646
else \
4747
a = 1 - a - b; \
4848
}
49-
#define _STORE16(x,y) { (y)[0] = (unsigned char)(((x)>>8)&255); (y)[1] = (unsigned char)((x)&255); }
50-
#define _LOAD16(x,y) { x = ((ushort16)((y)[0] & 255)<<8) | ((ushort16)((y)[1] & 255)); }
49+
#define STORE16(x,y) { (y)[0] = (unsigned char)(((x)>>8)&255); (y)[1] = (unsigned char)((x)&255); }
50+
#define LOAD16(x,y) { x = ((ushort16)((y)[0] & 255)<<8) | ((ushort16)((y)[1] & 255)); }
5151

5252
static ushort16 _mul_inv(ushort16 x)
5353
{
5454
ushort16 y = x;
5555
unsigned i;
5656

5757
for (i = 0; i < 15; i++) {
58-
_MUL(y, _LOW16(y));
59-
_MUL(y, x);
58+
MUL(y, LOW16(y));
59+
MUL(y, x);
6060
}
61-
return _LOW16(y);
61+
return LOW16(y);
6262
}
6363

6464
static ushort16 _add_inv(ushort16 x)
6565
{
66-
return _LOW16(0 - x);
66+
return LOW16(0 - x);
6767
}
6868

6969
static int _setup_key(const unsigned char *key, symmetric_key *skey)
@@ -74,11 +74,11 @@ static int _setup_key(const unsigned char *key, symmetric_key *skey)
7474

7575
/* prepare enc key */
7676
for (i = 0; i < 8; i++) {
77-
_LOAD16(e_key[i], key + 2 * i);
77+
LOAD16(e_key[i], key + 2 * i);
7878
}
7979
for (; i < LTC_IDEA_KEYLEN; i++) {
8080
j = (i - i % 8) - 8;
81-
e_key[i] = _LOW16((e_key[j+(i+1)%8] << 9) | (e_key[j+(i+2)%8] >> 7));
81+
e_key[i] = LOW16((e_key[j+(i+1)%8] << 9) | (e_key[j+(i+2)%8] >> 7));
8282
}
8383

8484
/* prepare dec key */
@@ -103,20 +103,20 @@ static int _process_block(const unsigned char *in, unsigned char *out, const ush
103103
int i;
104104
ushort16 x0, x1, x2, x3, t0, t1;
105105

106-
_LOAD16(x0, in + 0);
107-
_LOAD16(x1, in + 2);
108-
_LOAD16(x2, in + 4);
109-
_LOAD16(x3, in + 6);
106+
LOAD16(x0, in + 0);
107+
LOAD16(x1, in + 2);
108+
LOAD16(x2, in + 4);
109+
LOAD16(x3, in + 6);
110110

111111
for (i = 0; i < LTC_IDEA_ROUNDS; i++) {
112-
_MUL(x0, m_key[i*6+0]);
112+
MUL(x0, m_key[i*6+0]);
113113
x1 += m_key[i*6+1];
114114
x2 += m_key[i*6+2];
115-
_MUL(x3, m_key[i*6+3]);
115+
MUL(x3, m_key[i*6+3]);
116116
t0 = x0^x2;
117-
_MUL(t0, m_key[i*6+4]);
117+
MUL(t0, m_key[i*6+4]);
118118
t1 = t0 + (x1^x3);
119-
_MUL(t1, m_key[i*6+5]);
119+
MUL(t1, m_key[i*6+5]);
120120
t0 += t1;
121121
x0 ^= t1;
122122
x3 ^= t0;
@@ -125,15 +125,15 @@ static int _process_block(const unsigned char *in, unsigned char *out, const ush
125125
x2 = t0;
126126
}
127127

128-
_MUL(x0, m_key[LTC_IDEA_ROUNDS*6+0]);
128+
MUL(x0, m_key[LTC_IDEA_ROUNDS*6+0]);
129129
x2 += m_key[LTC_IDEA_ROUNDS*6+1];
130130
x1 += m_key[LTC_IDEA_ROUNDS*6+2];
131-
_MUL(x3, m_key[LTC_IDEA_ROUNDS*6+3]);
131+
MUL(x3, m_key[LTC_IDEA_ROUNDS*6+3]);
132132

133-
_STORE16(x0, out + 0);
134-
_STORE16(x2, out + 2);
135-
_STORE16(x1, out + 4);
136-
_STORE16(x3, out + 6);
133+
STORE16(x0, out + 0);
134+
STORE16(x2, out + 2);
135+
STORE16(x1, out + 4);
136+
STORE16(x3, out + 6);
137137

138138
return CRYPT_OK;
139139
}

src/ciphers/safer/safer.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
#ifdef LTC_SAFER
2626

27-
#define __LTC_SAFER_TAB_C__
27+
#define LTC_SAFER_TAB_C
2828
#include "safer_tab.c"
2929

3030
const struct ltc_cipher_descriptor safer_k64_desc = {
@@ -91,13 +91,13 @@ const struct ltc_cipher_descriptor safer_k64_desc = {
9191
/******************* Types ****************************************************/
9292

9393
#ifdef LTC_CLEAN_STACK
94-
static void _Safer_Expand_Userkey(const unsigned char *userkey_1,
94+
static void _safer_expand_userkey(const unsigned char *userkey_1,
9595
const unsigned char *userkey_2,
9696
unsigned int nof_rounds,
9797
int strengthened,
9898
safer_key_t key)
9999
#else
100-
static void Safer_Expand_Userkey(const unsigned char *userkey_1,
100+
static void safer_expand_userkey(const unsigned char *userkey_1,
101101
const unsigned char *userkey_2,
102102
unsigned int nof_rounds,
103103
int strengthened,
@@ -160,13 +160,13 @@ static void Safer_Expand_Userkey(const unsigned char *userkey_1,
160160
}
161161

162162
#ifdef LTC_CLEAN_STACK
163-
static void Safer_Expand_Userkey(const unsigned char *userkey_1,
163+
static void safer_expand_userkey(const unsigned char *userkey_1,
164164
const unsigned char *userkey_2,
165165
unsigned int nof_rounds,
166166
int strengthened,
167167
safer_key_t key)
168168
{
169-
_Safer_Expand_Userkey(userkey_1, userkey_2, nof_rounds, strengthened, key);
169+
_safer_expand_userkey(userkey_1, userkey_2, nof_rounds, strengthened, key);
170170
burn_stack(sizeof(unsigned char) * (2 * (LTC_SAFER_BLOCK_LEN + 1)) + sizeof(unsigned int)*2);
171171
}
172172
#endif
@@ -184,7 +184,7 @@ int safer_k64_setup(const unsigned char *key, int keylen, int num_rounds, symmet
184184
return CRYPT_INVALID_KEYSIZE;
185185
}
186186

187-
Safer_Expand_Userkey(key, key, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_K64_DEFAULT_NOF_ROUNDS), 0, skey->safer.key);
187+
safer_expand_userkey(key, key, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_K64_DEFAULT_NOF_ROUNDS), 0, skey->safer.key);
188188
return CRYPT_OK;
189189
}
190190

@@ -201,7 +201,7 @@ int safer_sk64_setup(const unsigned char *key, int keylen, int num_rounds, symme
201201
return CRYPT_INVALID_KEYSIZE;
202202
}
203203

204-
Safer_Expand_Userkey(key, key, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_SK64_DEFAULT_NOF_ROUNDS), 1, skey->safer.key);
204+
safer_expand_userkey(key, key, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_SK64_DEFAULT_NOF_ROUNDS), 1, skey->safer.key);
205205
return CRYPT_OK;
206206
}
207207

@@ -218,7 +218,7 @@ int safer_k128_setup(const unsigned char *key, int keylen, int num_rounds, symme
218218
return CRYPT_INVALID_KEYSIZE;
219219
}
220220

221-
Safer_Expand_Userkey(key, key+8, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_K128_DEFAULT_NOF_ROUNDS), 0, skey->safer.key);
221+
safer_expand_userkey(key, key+8, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_K128_DEFAULT_NOF_ROUNDS), 0, skey->safer.key);
222222
return CRYPT_OK;
223223
}
224224

@@ -235,7 +235,7 @@ int safer_sk128_setup(const unsigned char *key, int keylen, int num_rounds, symm
235235
return CRYPT_INVALID_KEYSIZE;
236236
}
237237

238-
Safer_Expand_Userkey(key, key+8, (unsigned int)(num_rounds != 0?num_rounds:LTC_SAFER_SK128_DEFAULT_NOF_ROUNDS), 1, skey->safer.key);
238+
safer_expand_userkey(key, key+8, (unsigned int)(num_rounds != 0?num_rounds:LTC_SAFER_SK128_DEFAULT_NOF_ROUNDS), 1, skey->safer.key);
239239
return CRYPT_OK;
240240
}
241241

src/ciphers/safer/safer_tab.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Tables for LTC_SAFER block ciphers
77
*/
88

9-
#ifdef __LTC_SAFER_TAB_C__
9+
#ifdef LTC_SAFER_TAB_C
1010

1111
/* This is the box defined by ebox[x] = 45^x mod 257.
1212
* Its assumed that the value "256" corresponds to zero. */
@@ -49,6 +49,6 @@ static const unsigned char safer_lbox[256] = {
4949
184, 64, 120, 45, 58, 233, 100, 31, 146, 144, 125, 57, 111, 224, 137, 48
5050
};
5151

52-
#endif /* __LTC_SAFER_TAB_C__ */
52+
#endif /* LTC_SAFER_TAB_C */
5353

5454

src/ciphers/safer/saferp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#ifdef LTC_SAFERP
1111

12-
#define __LTC_SAFER_TAB_C__
12+
#define LTC_SAFER_TAB_C
1313
#include "safer_tab.c"
1414

1515
const struct ltc_cipher_descriptor saferp_desc =

0 commit comments

Comments
 (0)