Skip to content

Commit 6d1d34d

Browse files
committed
prefix static functions with s_
1 parent c82e841 commit 6d1d34d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+199
-199
lines changed

helper.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ sub check_source {
6565
$file !~ m|src/math/.+_desc.c$| &&
6666
$file !~ m|src/pk/ec25519/tweetnacl.c$| &&
6767
$file !~ m|src/stream/sober128/sober128_stream.c$| &&
68-
$l =~ /^static(\s+[a-zA-Z0-9_]+)+\s+([^_][a-zA-Z0-9_]+)\s*\(/) {
69-
push @{$troubles->{staticfunc_name}}, "$lineno($2)";
68+
$l =~ /^static(\s+[a-zA-Z0-9_]+)+\s+([^s][a-zA-Z0-9_]+)\s*\(/) {
69+
push @{$troubles->{staticfunc_name}}, "$2";
7070
}
7171
if ($file =~ m|src/.*\.[ch]$| && $l =~ /^\s*#\s*define\s+(_[A-Z_][a-zA-Z0-9_]*)\b/) {
7272
my $n = $1;

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 s_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+
s_gcm_rightshift(V);
9696
V[0] ^= poly[z];
9797
}
9898
XMEMCPY(c, Z, 16);

src/encauth/ocb3/ocb3_add_aad.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
@param aad_block [in] AAD data (block_len size)
2222
@return CRYPT_OK if successful
2323
*/
24-
static int _ocb3_int_aad_add_block(ocb3_state *ocb, const unsigned char *aad_block)
24+
static int s_ocb3_int_aad_add_block(ocb3_state *ocb, const unsigned char *aad_block)
2525
{
2626
unsigned char tmp[MAXBLOCKSIZE];
2727
int err;
@@ -65,7 +65,7 @@ int ocb3_add_aad(ocb3_state *ocb, const unsigned char *aad, unsigned long aadlen
6565
ocb->adata_buffer_bytes += l;
6666

6767
if (ocb->adata_buffer_bytes == ocb->block_len) {
68-
if ((err = _ocb3_int_aad_add_block(ocb, ocb->adata_buffer)) != CRYPT_OK) {
68+
if ((err = s_ocb3_int_aad_add_block(ocb, ocb->adata_buffer)) != CRYPT_OK) {
6969
return err;
7070
}
7171
ocb->adata_buffer_bytes = 0;
@@ -86,7 +86,7 @@ int ocb3_add_aad(ocb3_state *ocb, const unsigned char *aad, unsigned long aadlen
8686
last_block_len = datalen - full_blocks_len;
8787

8888
for (x=0; x<full_blocks; x++) {
89-
if ((err = _ocb3_int_aad_add_block(ocb, data+x*ocb->block_len)) != CRYPT_OK) {
89+
if ((err = s_ocb3_int_aad_add_block(ocb, data+x*ocb->block_len)) != CRYPT_OK) {
9090
return err;
9191
}
9292
}

src/encauth/ocb3/ocb3_init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#ifdef LTC_OCB3_MODE
1717

18-
static void _ocb3_int_calc_offset_zero(ocb3_state *ocb, const unsigned char *nonce, unsigned long noncelen, unsigned long taglen)
18+
static void s_ocb3_int_calc_offset_zero(ocb3_state *ocb, const unsigned char *nonce, unsigned long noncelen, unsigned long taglen)
1919
{
2020
int x, y, bottom;
2121
int idx, shift;
@@ -172,7 +172,7 @@ int ocb3_init(ocb3_state *ocb, int cipher,
172172
}
173173

174174
/* initialize ocb->Offset_current = Offset_0 */
175-
_ocb3_int_calc_offset_zero(ocb, nonce, noncelen, taglen);
175+
s_ocb3_int_calc_offset_zero(ocb, nonce, noncelen, taglen);
176176

177177
/* initialize checksum to all zeros */
178178
zeromem(ocb->checksum, ocb->block_len);

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 s_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+
s_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+
s_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+
s_four_rounds(pelmac);
152152
pelmac->buflen = 0;
153153
}
154154
pelmac->state[pelmac->buflen++] ^= 0x80;

src/mac/poly1305/poly1305.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifdef LTC_POLY1305
1818

1919
/* internal only */
20-
static void _poly1305_block(poly1305_state *st, const unsigned char *in, unsigned long inlen)
20+
static void s_poly1305_block(poly1305_state *st, const unsigned char *in, unsigned long inlen)
2121
{
2222
const unsigned long hibit = (st->final) ? 0 : (1UL << 24); /* 1 << 128 */
2323
ulong32 r0,r1,r2,r3,r4;
@@ -141,14 +141,14 @@ int poly1305_process(poly1305_state *st, const unsigned char *in, unsigned long
141141
in += want;
142142
st->leftover += want;
143143
if (st->leftover < 16) return CRYPT_OK;
144-
_poly1305_block(st, st->buffer, 16);
144+
s_poly1305_block(st, st->buffer, 16);
145145
st->leftover = 0;
146146
}
147147

148148
/* process full blocks */
149149
if (inlen >= 16) {
150150
unsigned long want = (inlen & ~(16 - 1));
151-
_poly1305_block(st, in, want);
151+
s_poly1305_block(st, in, want);
152152
in += want;
153153
inlen -= want;
154154
}
@@ -186,7 +186,7 @@ int poly1305_done(poly1305_state *st, unsigned char *mac, unsigned long *maclen)
186186
st->buffer[i++] = 1;
187187
for (; i < 16; i++) st->buffer[i] = 0;
188188
st->final = 1;
189-
_poly1305_block(st, st->buffer, 16);
189+
s_poly1305_block(st, st->buffer, 16);
190190
}
191191

192192
/* fully carry h */

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 s_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 s_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 s_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 *a, void *modulus, void *mp, void *mu)
671+
static int s_build_lut(int idx, void *a, 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 *a, 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 *a, void *modulus, void *mp, int map)
778+
static int s_accel_fp_mul(int idx, void *k, ecc_point *R, void *a, 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 *a, void *modulus,
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 ss_accel_fp_mul2add(int idx1, int idx2,
902902
void *kA, void *kB,
903903
ecc_point *R, void *a, void *modulus, void *mp)
904904
{
@@ -1121,13 +1121,13 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11211121
mu = NULL;
11221122
LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
11231123
/* find point */
1124-
idx1 = _find_base(A);
1124+
idx1 = s_find_base(A);
11251125

11261126
/* no entry? */
11271127
if (idx1 == -1) {
11281128
/* find hole and add it */
1129-
if ((idx1 = _find_hole()) >= 0) {
1130-
if ((err = _add_entry(idx1, A)) != CRYPT_OK) {
1129+
if ((idx1 = s_find_hole()) >= 0) {
1130+
if ((err = s_add_entry(idx1, A)) != CRYPT_OK) {
11311131
goto LBL_ERR;
11321132
}
11331133
}
@@ -1138,13 +1138,13 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11381138
}
11391139

11401140
/* find point */
1141-
idx2 = _find_base(B);
1141+
idx2 = s_find_base(B);
11421142

11431143
/* no entry? */
11441144
if (idx2 == -1) {
11451145
/* find hole and add it */
1146-
if ((idx2 = _find_hole()) >= 0) {
1147-
if ((err = _add_entry(idx2, B)) != CRYPT_OK) {
1146+
if ((idx2 = s_find_hole()) >= 0) {
1147+
if ((err = s_add_entry(idx2, B)) != CRYPT_OK) {
11481148
goto LBL_ERR;
11491149
}
11501150
}
@@ -1168,7 +1168,7 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11681168
}
11691169

11701170
/* build the LUT */
1171-
if ((err = _build_lut(idx1, a, modulus, mp, mu)) != CRYPT_OK) {
1171+
if ((err = s_build_lut(idx1, a, modulus, mp, mu)) != CRYPT_OK) {
11721172
goto LBL_ERR;;
11731173
}
11741174
}
@@ -1189,7 +1189,7 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11891189
}
11901190

11911191
/* build the LUT */
1192-
if ((err = _build_lut(idx2, a, modulus, mp, mu)) != CRYPT_OK) {
1192+
if ((err = s_build_lut(idx2, a, modulus, mp, mu)) != CRYPT_OK) {
11931193
goto LBL_ERR;;
11941194
}
11951195
}
@@ -1200,7 +1200,7 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
12001200
/* compute mp */
12011201
if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { goto LBL_ERR; }
12021202
}
1203-
err = _accel_fp_mul2add(idx1, idx2, kA, kB, C, a, modulus, mp);
1203+
err = ss_accel_fp_mul2add(idx1, idx2, kA, kB, C, a, modulus, mp);
12041204
} else {
12051205
err = ltc_ecc_mul2add(A, kA, B, kB, C, a, modulus);
12061206
}
@@ -1234,15 +1234,15 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *a, void *modulu
12341234
mu = NULL;
12351235
LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
12361236
/* find point */
1237-
idx = _find_base(G);
1237+
idx = s_find_base(G);
12381238

12391239
/* no entry? */
12401240
if (idx == -1) {
12411241
/* find hole and add it */
1242-
idx = _find_hole();
1242+
idx = s_find_hole();
12431243

12441244
if (idx >= 0) {
1245-
if ((err = _add_entry(idx, G)) != CRYPT_OK) {
1245+
if ((err = s_add_entry(idx, G)) != CRYPT_OK) {
12461246
goto LBL_ERR;
12471247
}
12481248
}
@@ -1267,7 +1267,7 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *a, void *modulu
12671267
}
12681268

12691269
/* build the LUT */
1270-
if ((err = _build_lut(idx, a, modulus, mp, mu)) != CRYPT_OK) {
1270+
if ((err = s_build_lut(idx, a, modulus, mp, mu)) != CRYPT_OK) {
12711271
goto LBL_ERR;;
12721272
}
12731273
}
@@ -1277,7 +1277,7 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *a, void *modulu
12771277
/* compute mp */
12781278
if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { goto LBL_ERR; }
12791279
}
1280-
err = _accel_fp_mul(idx, k, R, a, modulus, mp, map);
1280+
err = s_accel_fp_mul(idx, k, R, a, modulus, mp, map);
12811281
} else {
12821282
err = ltc_ecc_mulmod(k, G, R, a, modulus, map);
12831283
}
@@ -1293,7 +1293,7 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *a, void *modulu
12931293
}
12941294

12951295
/* helper function for freeing the cache ... must be called with the cache mutex locked */
1296-
static void _ltc_ecc_fp_free_cache(void)
1296+
static void s_ltc_ecc_fp_free_cache(void)
12971297
{
12981298
unsigned x, y;
12991299
for (x = 0; x < FP_ENTRIES; x++) {
@@ -1318,7 +1318,7 @@ static void _ltc_ecc_fp_free_cache(void)
13181318
void ltc_ecc_fp_free(void)
13191319
{
13201320
LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
1321-
_ltc_ecc_fp_free_cache();
1321+
s_ltc_ecc_fp_free_cache();
13221322
LTC_MUTEX_UNLOCK(&ltc_ecc_fp_lock);
13231323
}
13241324

@@ -1337,19 +1337,19 @@ ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock)
13371337
void *mu = NULL;
13381338

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

1348-
if(idx == -1 && (idx = _find_hole()) == -1) {
1348+
if(idx == -1 && (idx = s_find_hole()) == -1) {
13491349
err = CRYPT_BUFFER_OVERFLOW;
13501350
goto LBL_ERR;
13511351
}
1352-
if ((err = _add_entry(idx, g)) != CRYPT_OK) {
1352+
if ((err = s_add_entry(idx, g)) != CRYPT_OK) {
13531353
goto LBL_ERR;
13541354
}
13551355
/* compute mp */
@@ -1366,7 +1366,7 @@ ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock)
13661366
}
13671367

13681368
/* build the LUT */
1369-
if ((err = _build_lut(idx, a, modulus, mp, mu)) != CRYPT_OK) {
1369+
if ((err = s_build_lut(idx, a, modulus, mp, mu)) != CRYPT_OK) {
13701370
goto LBL_ERR;
13711371
}
13721372
fp_cache[idx].lru_count = 2;
@@ -1504,7 +1504,7 @@ int ltc_ecc_fp_restore_state(unsigned char *in, unsigned long inlen)
15041504
/*
15051505
* start with an empty cache
15061506
*/
1507-
_ltc_ecc_fp_free_cache();
1507+
s_ltc_ecc_fp_free_cache();
15081508

15091509
/*
15101510
* decode the input packet: It consists of a sequence with a few
@@ -1574,7 +1574,7 @@ int ltc_ecc_fp_restore_state(unsigned char *in, unsigned long inlen)
15741574
ERR_OUT:
15751575
if(asn1_list)
15761576
XFREE(asn1_list);
1577-
_ltc_ecc_fp_free_cache();
1577+
s_ltc_ecc_fp_free_cache();
15781578
LTC_MUTEX_UNLOCK(&ltc_ecc_fp_lock);
15791579
return err;
15801580
}

0 commit comments

Comments
 (0)