Skip to content

Commit 4fd7b50

Browse files
committed
prefix static functions with s_
1 parent cb63d3c commit 4fd7b50

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

+197
-197
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
@@ -52,7 +52,7 @@ const unsigned char gcm_shift_table[256*2] = {
5252

5353
#ifndef LTC_FAST
5454
/* right shift */
55-
static void _gcm_rightshift(unsigned char *a)
55+
static void s_gcm_rightshift(unsigned char *a)
5656
{
5757
int x;
5858
for (x = 15; x > 0; x--) {
@@ -86,7 +86,7 @@ void gcm_gf_mult(const unsigned char *a, const unsigned char *b, unsigned char *
8686
}
8787
}
8888
z = V[15] & 0x01;
89-
_gcm_rightshift(V);
89+
s_gcm_rightshift(V);
9090
V[0] ^= poly[z];
9191
}
9292
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
@@ -15,7 +15,7 @@
1515
@param aad_block [in] AAD data (block_len size)
1616
@return CRYPT_OK if successful
1717
*/
18-
static int _ocb3_int_aad_add_block(ocb3_state *ocb, const unsigned char *aad_block)
18+
static int s_ocb3_int_aad_add_block(ocb3_state *ocb, const unsigned char *aad_block)
1919
{
2020
unsigned char tmp[MAXBLOCKSIZE];
2121
int err;
@@ -59,7 +59,7 @@ int ocb3_add_aad(ocb3_state *ocb, const unsigned char *aad, unsigned long aadlen
5959
ocb->adata_buffer_bytes += l;
6060

6161
if (ocb->adata_buffer_bytes == ocb->block_len) {
62-
if ((err = _ocb3_int_aad_add_block(ocb, ocb->adata_buffer)) != CRYPT_OK) {
62+
if ((err = s_ocb3_int_aad_add_block(ocb, ocb->adata_buffer)) != CRYPT_OK) {
6363
return err;
6464
}
6565
ocb->adata_buffer_bytes = 0;
@@ -80,7 +80,7 @@ int ocb3_add_aad(ocb3_state *ocb, const unsigned char *aad, unsigned long aadlen
8080
last_block_len = datalen - full_blocks_len;
8181

8282
for (x=0; x<full_blocks; x++) {
83-
if ((err = _ocb3_int_aad_add_block(ocb, data+x*ocb->block_len)) != CRYPT_OK) {
83+
if ((err = s_ocb3_int_aad_add_block(ocb, data+x*ocb->block_len)) != CRYPT_OK) {
8484
return err;
8585
}
8686
}

src/encauth/ocb3/ocb3_init.c

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

1010
#ifdef LTC_OCB3_MODE
1111

12-
static void _ocb3_int_calc_offset_zero(ocb3_state *ocb, const unsigned char *nonce, unsigned long noncelen, unsigned long taglen)
12+
static void s_ocb3_int_calc_offset_zero(ocb3_state *ocb, const unsigned char *nonce, unsigned long noncelen, unsigned long taglen)
1313
{
1414
int x, y, bottom;
1515
int idx, shift;
@@ -166,7 +166,7 @@ int ocb3_init(ocb3_state *ocb, int cipher,
166166
}
167167

168168
/* initialize ocb->Offset_current = Offset_0 */
169-
_ocb3_int_calc_offset_zero(ocb, nonce, noncelen, taglen);
169+
s_ocb3_int_calc_offset_zero(ocb, nonce, noncelen, taglen);
170170

171171
/* initialize checksum to all zeros */
172172
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
@@ -45,7 +45,7 @@ int pelican_init(pelican_state *pelmac, const unsigned char *key, unsigned long
4545
return CRYPT_OK;
4646
}
4747

48-
static void _four_rounds(pelican_state *pelmac)
48+
static void s_four_rounds(pelican_state *pelmac)
4949
{
5050
ulong32 s0, s1, s2, s3, t0, t1, t2, t3;
5151
int r;
@@ -108,7 +108,7 @@ int pelican_process(pelican_state *pelmac, const unsigned char *in, unsigned lon
108108
for (x = 0; x < 16; x += sizeof(LTC_FAST_TYPE)) {
109109
*(LTC_FAST_TYPE_PTR_CAST((unsigned char *)pelmac->state + x)) ^= *(LTC_FAST_TYPE_PTR_CAST((unsigned char *)in + x));
110110
}
111-
_four_rounds(pelmac);
111+
s_four_rounds(pelmac);
112112
in += 16;
113113
inlen -= 16;
114114
}
@@ -118,7 +118,7 @@ int pelican_process(pelican_state *pelmac, const unsigned char *in, unsigned lon
118118
while (inlen--) {
119119
pelmac->state[pelmac->buflen++] ^= *in++;
120120
if (pelmac->buflen == 16) {
121-
_four_rounds(pelmac);
121+
s_four_rounds(pelmac);
122122
pelmac->buflen = 0;
123123
}
124124
}
@@ -142,7 +142,7 @@ int pelican_done(pelican_state *pelmac, unsigned char *out)
142142
}
143143

144144
if (pelmac->buflen == 16) {
145-
_four_rounds(pelmac);
145+
s_four_rounds(pelmac);
146146
pelmac->buflen = 0;
147147
}
148148
pelmac->state[pelmac->buflen++] ^= 0x80;

src/mac/poly1305/poly1305.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#ifdef LTC_POLY1305
1212

1313
/* internal only */
14-
static void _poly1305_block(poly1305_state *st, const unsigned char *in, unsigned long inlen)
14+
static void s_poly1305_block(poly1305_state *st, const unsigned char *in, unsigned long inlen)
1515
{
1616
const unsigned long hibit = (st->final) ? 0 : (1UL << 24); /* 1 << 128 */
1717
ulong32 r0,r1,r2,r3,r4;
@@ -135,14 +135,14 @@ int poly1305_process(poly1305_state *st, const unsigned char *in, unsigned long
135135
in += want;
136136
st->leftover += want;
137137
if (st->leftover < 16) return CRYPT_OK;
138-
_poly1305_block(st, st->buffer, 16);
138+
s_poly1305_block(st, st->buffer, 16);
139139
st->leftover = 0;
140140
}
141141

142142
/* process full blocks */
143143
if (inlen >= 16) {
144144
unsigned long want = (inlen & ~(16 - 1));
145-
_poly1305_block(st, in, want);
145+
s_poly1305_block(st, in, want);
146146
in += want;
147147
inlen -= want;
148148
}
@@ -180,7 +180,7 @@ int poly1305_done(poly1305_state *st, unsigned char *mac, unsigned long *maclen)
180180
st->buffer[i++] = 1;
181181
for (; i < 16; i++) st->buffer[i] = 0;
182182
st->final = 1;
183-
_poly1305_block(st, st->buffer, 16);
183+
s_poly1305_block(st, st->buffer, 16);
184184
}
185185

186186
/* 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
@@ -566,7 +566,7 @@ static const struct {
566566
};
567567

568568
/* find a hole and free as required, return -1 if no hole found */
569-
static int _find_hole(void)
569+
static int s_find_hole(void)
570570
{
571571
unsigned x;
572572
int y, z;
@@ -602,7 +602,7 @@ static int _find_hole(void)
602602
}
603603

604604
/* determine if a base is already in the cache and if so, where */
605-
static int _find_base(ecc_point *g)
605+
static int s_find_base(ecc_point *g)
606606
{
607607
int x;
608608
for (x = 0; x < FP_ENTRIES; x++) {
@@ -620,7 +620,7 @@ static int _find_base(ecc_point *g)
620620
}
621621

622622
/* add a new base to the cache */
623-
static int _add_entry(int idx, ecc_point *g)
623+
static int s_add_entry(int idx, ecc_point *g)
624624
{
625625
unsigned x, y;
626626

@@ -662,7 +662,7 @@ static int _add_entry(int idx, ecc_point *g)
662662
* The algorithm builds patterns in increasing bit order by first making all
663663
* single bit input patterns, then all two bit input patterns and so on
664664
*/
665-
static int _build_lut(int idx, void *a, void *modulus, void *mp, void *mu)
665+
static int s_build_lut(int idx, void *a, void *modulus, void *mp, void *mu)
666666
{
667667
unsigned x, y, err, bitlen, lut_gap;
668668
void *tmp;
@@ -769,7 +769,7 @@ static int _build_lut(int idx, void *a, void *modulus, void *mp, void *mu)
769769
}
770770

771771
/* perform a fixed point ECC mulmod */
772-
static int _accel_fp_mul(int idx, void *k, ecc_point *R, void *a, void *modulus, void *mp, int map)
772+
static int s_accel_fp_mul(int idx, void *k, ecc_point *R, void *a, void *modulus, void *mp, int map)
773773
{
774774
unsigned char kb[128];
775775
int x;
@@ -892,7 +892,7 @@ static int _accel_fp_mul(int idx, void *k, ecc_point *R, void *a, void *modulus,
892892

893893
#ifdef LTC_ECC_SHAMIR
894894
/* perform a fixed point ECC mulmod */
895-
static int _accel_fp_mul2add(int idx1, int idx2,
895+
static int ss_accel_fp_mul2add(int idx1, int idx2,
896896
void *kA, void *kB,
897897
ecc_point *R, void *a, void *modulus, void *mp)
898898
{
@@ -1115,13 +1115,13 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11151115
mu = NULL;
11161116
LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
11171117
/* find point */
1118-
idx1 = _find_base(A);
1118+
idx1 = s_find_base(A);
11191119

11201120
/* no entry? */
11211121
if (idx1 == -1) {
11221122
/* find hole and add it */
1123-
if ((idx1 = _find_hole()) >= 0) {
1124-
if ((err = _add_entry(idx1, A)) != CRYPT_OK) {
1123+
if ((idx1 = s_find_hole()) >= 0) {
1124+
if ((err = s_add_entry(idx1, A)) != CRYPT_OK) {
11251125
goto LBL_ERR;
11261126
}
11271127
}
@@ -1132,13 +1132,13 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11321132
}
11331133

11341134
/* find point */
1135-
idx2 = _find_base(B);
1135+
idx2 = s_find_base(B);
11361136

11371137
/* no entry? */
11381138
if (idx2 == -1) {
11391139
/* find hole and add it */
1140-
if ((idx2 = _find_hole()) >= 0) {
1141-
if ((err = _add_entry(idx2, B)) != CRYPT_OK) {
1140+
if ((idx2 = s_find_hole()) >= 0) {
1141+
if ((err = s_add_entry(idx2, B)) != CRYPT_OK) {
11421142
goto LBL_ERR;
11431143
}
11441144
}
@@ -1162,7 +1162,7 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11621162
}
11631163

11641164
/* build the LUT */
1165-
if ((err = _build_lut(idx1, a, modulus, mp, mu)) != CRYPT_OK) {
1165+
if ((err = s_build_lut(idx1, a, modulus, mp, mu)) != CRYPT_OK) {
11661166
goto LBL_ERR;;
11671167
}
11681168
}
@@ -1183,7 +1183,7 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11831183
}
11841184

11851185
/* build the LUT */
1186-
if ((err = _build_lut(idx2, a, modulus, mp, mu)) != CRYPT_OK) {
1186+
if ((err = s_build_lut(idx2, a, modulus, mp, mu)) != CRYPT_OK) {
11871187
goto LBL_ERR;;
11881188
}
11891189
}
@@ -1194,7 +1194,7 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11941194
/* compute mp */
11951195
if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { goto LBL_ERR; }
11961196
}
1197-
err = _accel_fp_mul2add(idx1, idx2, kA, kB, C, a, modulus, mp);
1197+
err = ss_accel_fp_mul2add(idx1, idx2, kA, kB, C, a, modulus, mp);
11981198
} else {
11991199
err = ltc_ecc_mul2add(A, kA, B, kB, C, a, modulus);
12001200
}
@@ -1228,15 +1228,15 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *a, void *modulu
12281228
mu = NULL;
12291229
LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
12301230
/* find point */
1231-
idx = _find_base(G);
1231+
idx = s_find_base(G);
12321232

12331233
/* no entry? */
12341234
if (idx == -1) {
12351235
/* find hole and add it */
1236-
idx = _find_hole();
1236+
idx = s_find_hole();
12371237

12381238
if (idx >= 0) {
1239-
if ((err = _add_entry(idx, G)) != CRYPT_OK) {
1239+
if ((err = s_add_entry(idx, G)) != CRYPT_OK) {
12401240
goto LBL_ERR;
12411241
}
12421242
}
@@ -1261,7 +1261,7 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *a, void *modulu
12611261
}
12621262

12631263
/* build the LUT */
1264-
if ((err = _build_lut(idx, a, modulus, mp, mu)) != CRYPT_OK) {
1264+
if ((err = s_build_lut(idx, a, modulus, mp, mu)) != CRYPT_OK) {
12651265
goto LBL_ERR;;
12661266
}
12671267
}
@@ -1271,7 +1271,7 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *a, void *modulu
12711271
/* compute mp */
12721272
if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { goto LBL_ERR; }
12731273
}
1274-
err = _accel_fp_mul(idx, k, R, a, modulus, mp, map);
1274+
err = s_accel_fp_mul(idx, k, R, a, modulus, mp, map);
12751275
} else {
12761276
err = ltc_ecc_mulmod(k, G, R, a, modulus, map);
12771277
}
@@ -1287,7 +1287,7 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *a, void *modulu
12871287
}
12881288

12891289
/* helper function for freeing the cache ... must be called with the cache mutex locked */
1290-
static void _ltc_ecc_fp_free_cache(void)
1290+
static void s_ltc_ecc_fp_free_cache(void)
12911291
{
12921292
unsigned x, y;
12931293
for (x = 0; x < FP_ENTRIES; x++) {
@@ -1312,7 +1312,7 @@ static void _ltc_ecc_fp_free_cache(void)
13121312
void ltc_ecc_fp_free(void)
13131313
{
13141314
LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
1315-
_ltc_ecc_fp_free_cache();
1315+
s_ltc_ecc_fp_free_cache();
13161316
LTC_MUTEX_UNLOCK(&ltc_ecc_fp_lock);
13171317
}
13181318

@@ -1331,19 +1331,19 @@ ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock)
13311331
void *mu = NULL;
13321332

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

1342-
if(idx == -1 && (idx = _find_hole()) == -1) {
1342+
if(idx == -1 && (idx = s_find_hole()) == -1) {
13431343
err = CRYPT_BUFFER_OVERFLOW;
13441344
goto LBL_ERR;
13451345
}
1346-
if ((err = _add_entry(idx, g)) != CRYPT_OK) {
1346+
if ((err = s_add_entry(idx, g)) != CRYPT_OK) {
13471347
goto LBL_ERR;
13481348
}
13491349
/* compute mp */
@@ -1360,7 +1360,7 @@ ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock)
13601360
}
13611361

13621362
/* build the LUT */
1363-
if ((err = _build_lut(idx, a, modulus, mp, mu)) != CRYPT_OK) {
1363+
if ((err = s_build_lut(idx, a, modulus, mp, mu)) != CRYPT_OK) {
13641364
goto LBL_ERR;
13651365
}
13661366
fp_cache[idx].lru_count = 2;
@@ -1498,7 +1498,7 @@ int ltc_ecc_fp_restore_state(unsigned char *in, unsigned long inlen)
14981498
/*
14991499
* start with an empty cache
15001500
*/
1501-
_ltc_ecc_fp_free_cache();
1501+
s_ltc_ecc_fp_free_cache();
15021502

15031503
/*
15041504
* decode the input packet: It consists of a sequence with a few
@@ -1568,7 +1568,7 @@ int ltc_ecc_fp_restore_state(unsigned char *in, unsigned long inlen)
15681568
ERR_OUT:
15691569
if(asn1_list)
15701570
XFREE(asn1_list);
1571-
_ltc_ecc_fp_free_cache();
1571+
s_ltc_ecc_fp_free_cache();
15721572
LTC_MUTEX_UNLOCK(&ltc_ecc_fp_lock);
15731573
return err;
15741574
}

0 commit comments

Comments
 (0)