Skip to content

Commit 1bf42ea

Browse files
committed
update some of the static functions
1 parent 8f433f1 commit 1bf42ea

13 files changed

Lines changed: 72 additions & 72 deletions

File tree

src/encauth/gcm/gcm_gf_mult.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const unsigned char gcm_shift_table[256*2] = {
5858

5959
#ifndef LTC_FAST
6060
/* right shift */
61-
static void gcm_rightshift(unsigned char *a)
61+
static void _gcm_rightshift(unsigned char *a)
6262
{
6363
int x;
6464
for (x = 15; x > 0; x--) {
@@ -92,7 +92,7 @@ void gcm_gf_mult(const unsigned char *a, const unsigned char *b, unsigned char *
9292
}
9393
}
9494
z = V[15] & 0x01;
95-
gcm_rightshift(V);
95+
_gcm_rightshift(V);
9696
V[0] ^= poly[z];
9797
}
9898
XMEMCPY(c, Z, 16);

src/mac/pelican/pelican.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ int pelican_init(pelican_state *pelmac, const unsigned char *key, unsigned long
5151
return CRYPT_OK;
5252
}
5353

54-
static void four_rounds(pelican_state *pelmac)
54+
static void _four_rounds(pelican_state *pelmac)
5555
{
5656
ulong32 s0, s1, s2, s3, t0, t1, t2, t3;
5757
int r;
@@ -114,7 +114,7 @@ int pelican_process(pelican_state *pelmac, const unsigned char *in, unsigned lon
114114
for (x = 0; x < 16; x += sizeof(LTC_FAST_TYPE)) {
115115
*(LTC_FAST_TYPE_PTR_CAST((unsigned char *)pelmac->state + x)) ^= *(LTC_FAST_TYPE_PTR_CAST((unsigned char *)in + x));
116116
}
117-
four_rounds(pelmac);
117+
_four_rounds(pelmac);
118118
in += 16;
119119
inlen -= 16;
120120
}
@@ -124,7 +124,7 @@ int pelican_process(pelican_state *pelmac, const unsigned char *in, unsigned lon
124124
while (inlen--) {
125125
pelmac->state[pelmac->buflen++] ^= *in++;
126126
if (pelmac->buflen == 16) {
127-
four_rounds(pelmac);
127+
_four_rounds(pelmac);
128128
pelmac->buflen = 0;
129129
}
130130
}
@@ -148,7 +148,7 @@ int pelican_done(pelican_state *pelmac, unsigned char *out)
148148
}
149149

150150
if (pelmac->buflen == 16) {
151-
four_rounds(pelmac);
151+
_four_rounds(pelmac);
152152
pelmac->buflen = 0;
153153
}
154154
pelmac->state[pelmac->buflen++] ^= 0x80;

src/math/fp/ltc_ecc_fp_mulmod.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ static const struct {
572572
};
573573

574574
/* find a hole and free as required, return -1 if no hole found */
575-
static int find_hole(void)
575+
static int _find_hole(void)
576576
{
577577
unsigned x;
578578
int y, z;
@@ -608,7 +608,7 @@ static int find_hole(void)
608608
}
609609

610610
/* determine if a base is already in the cache and if so, where */
611-
static int find_base(ecc_point *g)
611+
static int _find_base(ecc_point *g)
612612
{
613613
int x;
614614
for (x = 0; x < FP_ENTRIES; x++) {
@@ -626,7 +626,7 @@ static int find_base(ecc_point *g)
626626
}
627627

628628
/* add a new base to the cache */
629-
static int add_entry(int idx, ecc_point *g)
629+
static int _add_entry(int idx, ecc_point *g)
630630
{
631631
unsigned x, y;
632632

@@ -668,7 +668,7 @@ static int add_entry(int idx, ecc_point *g)
668668
* The algorithm builds patterns in increasing bit order by first making all
669669
* single bit input patterns, then all two bit input patterns and so on
670670
*/
671-
static int build_lut(int idx, void *modulus, void *mp, void *mu)
671+
static int _build_lut(int idx, void *modulus, void *mp, void *mu)
672672
{
673673
unsigned x, y, err, bitlen, lut_gap;
674674
void *tmp;
@@ -775,7 +775,7 @@ static int build_lut(int idx, void *modulus, void *mp, void *mu)
775775
}
776776

777777
/* perform a fixed point ECC mulmod */
778-
static int accel_fp_mul(int idx, void *k, ecc_point *R, void *modulus, void *mp, int map)
778+
static int _accel_fp_mul(int idx, void *k, ecc_point *R, void *modulus, void *mp, int map)
779779
{
780780
unsigned char kb[128];
781781
int x;
@@ -898,7 +898,7 @@ static int accel_fp_mul(int idx, void *k, ecc_point *R, void *modulus, void *mp,
898898

899899
#ifdef LTC_ECC_SHAMIR
900900
/* perform a fixed point ECC mulmod */
901-
static int accel_fp_mul2add(int idx1, int idx2,
901+
static int _accel_fp_mul2add(int idx1, int idx2,
902902
void *kA, void *kB,
903903
ecc_point *R, void *modulus, void *mp)
904904
{
@@ -1119,13 +1119,13 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11191119
mu = NULL;
11201120
LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
11211121
/* find point */
1122-
idx1 = find_base(A);
1122+
idx1 = _find_base(A);
11231123

11241124
/* no entry? */
11251125
if (idx1 == -1) {
11261126
/* find hole and add it */
1127-
if ((idx1 = find_hole()) >= 0) {
1128-
if ((err = add_entry(idx1, A)) != CRYPT_OK) {
1127+
if ((idx1 = _find_hole()) >= 0) {
1128+
if ((err = _add_entry(idx1, A)) != CRYPT_OK) {
11291129
goto LBL_ERR;
11301130
}
11311131
}
@@ -1136,13 +1136,13 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11361136
}
11371137

11381138
/* find point */
1139-
idx2 = find_base(B);
1139+
idx2 = _find_base(B);
11401140

11411141
/* no entry? */
11421142
if (idx2 == -1) {
11431143
/* find hole and add it */
1144-
if ((idx2 = find_hole()) >= 0) {
1145-
if ((err = add_entry(idx2, B)) != CRYPT_OK) {
1144+
if ((idx2 = _find_hole()) >= 0) {
1145+
if ((err = _add_entry(idx2, B)) != CRYPT_OK) {
11461146
goto LBL_ERR;
11471147
}
11481148
}
@@ -1166,7 +1166,7 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11661166
}
11671167

11681168
/* build the LUT */
1169-
if ((err = build_lut(idx1, modulus, mp, mu)) != CRYPT_OK) {
1169+
if ((err = _build_lut(idx1, modulus, mp, mu)) != CRYPT_OK) {
11701170
goto LBL_ERR;;
11711171
}
11721172
}
@@ -1187,7 +1187,7 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11871187
}
11881188

11891189
/* build the LUT */
1190-
if ((err = build_lut(idx2, modulus, mp, mu)) != CRYPT_OK) {
1190+
if ((err = _build_lut(idx2, modulus, mp, mu)) != CRYPT_OK) {
11911191
goto LBL_ERR;;
11921192
}
11931193
}
@@ -1198,7 +1198,7 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11981198
/* compute mp */
11991199
if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { goto LBL_ERR; }
12001200
}
1201-
err = accel_fp_mul2add(idx1, idx2, kA, kB, C, modulus, mp);
1201+
err = _accel_fp_mul2add(idx1, idx2, kA, kB, C, modulus, mp);
12021202
} else {
12031203
err = ltc_ecc_mul2add(A, kA, B, kB, C, modulus);
12041204
}
@@ -1231,15 +1231,15 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int ma
12311231
mu = NULL;
12321232
LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
12331233
/* find point */
1234-
idx = find_base(G);
1234+
idx = _find_base(G);
12351235

12361236
/* no entry? */
12371237
if (idx == -1) {
12381238
/* find hole and add it */
1239-
idx = find_hole();
1239+
idx = _find_hole();
12401240

12411241
if (idx >= 0) {
1242-
if ((err = add_entry(idx, G)) != CRYPT_OK) {
1242+
if ((err = _add_entry(idx, G)) != CRYPT_OK) {
12431243
goto LBL_ERR;
12441244
}
12451245
}
@@ -1264,7 +1264,7 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int ma
12641264
}
12651265

12661266
/* build the LUT */
1267-
if ((err = build_lut(idx, modulus, mp, mu)) != CRYPT_OK) {
1267+
if ((err = _build_lut(idx, modulus, mp, mu)) != CRYPT_OK) {
12681268
goto LBL_ERR;;
12691269
}
12701270
}
@@ -1274,7 +1274,7 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int ma
12741274
/* compute mp */
12751275
if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { goto LBL_ERR; }
12761276
}
1277-
err = accel_fp_mul(idx, k, R, modulus, mp, map);
1277+
err = _accel_fp_mul(idx, k, R, modulus, mp, map);
12781278
} else {
12791279
err = ltc_ecc_mulmod(k, G, R, modulus, map);
12801280
}
@@ -1290,7 +1290,7 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int ma
12901290
}
12911291

12921292
/* helper function for freeing the cache ... must be called with the cache mutex locked */
1293-
static void ltc_ecc_fp_free_cache(void)
1293+
static void _ltc_ecc_fp_free_cache(void)
12941294
{
12951295
unsigned x, y;
12961296
for (x = 0; x < FP_ENTRIES; x++) {
@@ -1315,7 +1315,7 @@ static void ltc_ecc_fp_free_cache(void)
13151315
void ltc_ecc_fp_free(void)
13161316
{
13171317
LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
1318-
ltc_ecc_fp_free_cache();
1318+
_ltc_ecc_fp_free_cache();
13191319
LTC_MUTEX_UNLOCK(&ltc_ecc_fp_lock);
13201320
}
13211321

@@ -1334,19 +1334,19 @@ ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock)
13341334
void *mu = NULL;
13351335

13361336
LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
1337-
if ((idx = find_base(g)) >= 0) {
1337+
if ((idx = _find_base(g)) >= 0) {
13381338
/* it is already in the cache ... just check that the LUT is initialized */
13391339
if(fp_cache[idx].lru_count >= 2) {
13401340
LTC_MUTEX_UNLOCK(&ltc_ecc_fp_lock);
13411341
return CRYPT_OK;
13421342
}
13431343
}
13441344

1345-
if(idx == -1 && (idx = find_hole()) == -1) {
1345+
if(idx == -1 && (idx = _find_hole()) == -1) {
13461346
err = CRYPT_BUFFER_OVERFLOW;
13471347
goto LBL_ERR;
13481348
}
1349-
if ((err = add_entry(idx, g)) != CRYPT_OK) {
1349+
if ((err = _add_entry(idx, g)) != CRYPT_OK) {
13501350
goto LBL_ERR;
13511351
}
13521352
/* compute mp */
@@ -1363,7 +1363,7 @@ ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock)
13631363
}
13641364

13651365
/* build the LUT */
1366-
if ((err = build_lut(idx, modulus, mp, mu)) != CRYPT_OK) {
1366+
if ((err = _build_lut(idx, modulus, mp, mu)) != CRYPT_OK) {
13671367
goto LBL_ERR;
13681368
}
13691369
fp_cache[idx].lru_count = 2;
@@ -1501,7 +1501,7 @@ int ltc_ecc_fp_restore_state(unsigned char *in, unsigned long inlen)
15011501
/*
15021502
* start with an empty cache
15031503
*/
1504-
ltc_ecc_fp_free_cache();
1504+
_ltc_ecc_fp_free_cache();
15051505

15061506
/*
15071507
* decode the input packet: It consists of a sequence with a few
@@ -1571,7 +1571,7 @@ int ltc_ecc_fp_restore_state(unsigned char *in, unsigned long inlen)
15711571
ERR_OUT:
15721572
if(asn1_list)
15731573
XFREE(asn1_list);
1574-
ltc_ecc_fp_free_cache();
1574+
_ltc_ecc_fp_free_cache();
15751575
LTC_MUTEX_UNLOCK(&ltc_ecc_fp_lock);
15761576
return err;
15771577
}

src/modes/xts/xts_decrypt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#ifdef LTC_XTS_MODE
1616

17-
static int tweak_uncrypt(const unsigned char *C, unsigned char *P, unsigned char *T, symmetric_xts *xts)
17+
static int _tweak_uncrypt(const unsigned char *C, unsigned char *P, unsigned char *T, symmetric_xts *xts)
1818
{
1919
unsigned long x;
2020
int err;
@@ -108,7 +108,7 @@ int xts_decrypt(const unsigned char *ct, unsigned long ptlen, unsigned char *pt,
108108
}
109109

110110
for (i = 0; i < lim; i++) {
111-
if ((err = tweak_uncrypt(ct, pt, T, xts)) != CRYPT_OK) {
111+
if ((err = _tweak_uncrypt(ct, pt, T, xts)) != CRYPT_OK) {
112112
return err;
113113
}
114114
ct += 16;
@@ -122,7 +122,7 @@ int xts_decrypt(const unsigned char *ct, unsigned long ptlen, unsigned char *pt,
122122
xts_mult_x(CC);
123123

124124
/* PP = tweak decrypt block m-1 */
125-
if ((err = tweak_uncrypt(ct, PP, CC, xts)) != CRYPT_OK) {
125+
if ((err = _tweak_uncrypt(ct, PP, CC, xts)) != CRYPT_OK) {
126126
return err;
127127
}
128128

@@ -136,7 +136,7 @@ int xts_decrypt(const unsigned char *ct, unsigned long ptlen, unsigned char *pt,
136136
}
137137

138138
/* Pm-1 = Tweak uncrypt CC */
139-
if ((err = tweak_uncrypt(CC, pt, T, xts)) != CRYPT_OK) {
139+
if ((err = _tweak_uncrypt(CC, pt, T, xts)) != CRYPT_OK) {
140140
return err;
141141
}
142142
}

src/modes/xts/xts_encrypt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#ifdef LTC_XTS_MODE
1616

17-
static int tweak_crypt(const unsigned char *P, unsigned char *C, unsigned char *T, symmetric_xts *xts)
17+
static int _tweak_crypt(const unsigned char *P, unsigned char *C, unsigned char *T, symmetric_xts *xts)
1818
{
1919
unsigned long x;
2020
int err;
@@ -111,7 +111,7 @@ int xts_encrypt(const unsigned char *pt, unsigned long ptlen, unsigned char *ct,
111111
}
112112

113113
for (i = 0; i < lim; i++) {
114-
if ((err = tweak_crypt(pt, ct, T, xts)) != CRYPT_OK) {
114+
if ((err = _tweak_crypt(pt, ct, T, xts)) != CRYPT_OK) {
115115
return err;
116116
}
117117
ct += 16;
@@ -122,7 +122,7 @@ int xts_encrypt(const unsigned char *pt, unsigned long ptlen, unsigned char *ct,
122122
/* if ptlen not divide 16 then */
123123
if (mo > 0) {
124124
/* CC = tweak encrypt block m-1 */
125-
if ((err = tweak_crypt(pt, CC, T, xts)) != CRYPT_OK) {
125+
if ((err = _tweak_crypt(pt, CC, T, xts)) != CRYPT_OK) {
126126
return err;
127127
}
128128

@@ -137,7 +137,7 @@ int xts_encrypt(const unsigned char *pt, unsigned long ptlen, unsigned char *ct,
137137
}
138138

139139
/* Cm-1 = Tweak encrypt PP */
140-
if ((err = tweak_crypt(PP, ct, T, xts)) != CRYPT_OK) {
140+
if ((err = _tweak_crypt(PP, ct, T, xts)) != CRYPT_OK) {
141141
return err;
142142
}
143143
}

src/pk/asn1/der/generalizedtime/der_decode_generalizedtime.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#ifdef LTC_DER
1818

19-
static int char_to_int(unsigned char x)
19+
static int _char_to_int(unsigned char x)
2020
{
2121
switch (x) {
2222
case '0': return 0;
@@ -34,13 +34,13 @@ static int char_to_int(unsigned char x)
3434
}
3535

3636
#define DECODE_V(y, max) do {\
37-
y = char_to_int(buf[x])*10 + char_to_int(buf[x+1]); \
37+
y = _char_to_int(buf[x])*10 + _char_to_int(buf[x+1]); \
3838
if (y >= max) return CRYPT_INVALID_PACKET; \
3939
x += 2; \
4040
} while(0)
4141

4242
#define DECODE_V4(y, max) do {\
43-
y = char_to_int(buf[x])*1000 + char_to_int(buf[x+1])*100 + char_to_int(buf[x+2])*10 + char_to_int(buf[x+3]); \
43+
y = _char_to_int(buf[x])*1000 + _char_to_int(buf[x+1])*100 + _char_to_int(buf[x+2])*10 + _char_to_int(buf[x+3]); \
4444
if (y >= max) return CRYPT_INVALID_PACKET; \
4545
x += 4; \
4646
} while(0)
@@ -118,7 +118,7 @@ YYYYMMDDhhmmss.fs-hh'mm'
118118
unsigned fs = out->fs;
119119
if (x >= sizeof(buf)) return CRYPT_INVALID_PACKET;
120120
out->fs *= 10;
121-
out->fs += char_to_int(buf[x]);
121+
out->fs += _char_to_int(buf[x]);
122122
if (fs > out->fs) return CRYPT_OVERFLOW;
123123
x++;
124124
}

0 commit comments

Comments
 (0)