update some of the static functions

This commit is contained in:
Steffen Jaeckel 2017-06-20 19:58:13 +02:00
parent 8f433f1a36
commit 1bf42ea99a
13 changed files with 72 additions and 72 deletions

View File

@ -58,7 +58,7 @@ const unsigned char gcm_shift_table[256*2] = {
#ifndef LTC_FAST #ifndef LTC_FAST
/* right shift */ /* right shift */
static void gcm_rightshift(unsigned char *a) static void _gcm_rightshift(unsigned char *a)
{ {
int x; int x;
for (x = 15; x > 0; x--) { for (x = 15; x > 0; x--) {
@ -92,7 +92,7 @@ void gcm_gf_mult(const unsigned char *a, const unsigned char *b, unsigned char *
} }
} }
z = V[15] & 0x01; z = V[15] & 0x01;
gcm_rightshift(V); _gcm_rightshift(V);
V[0] ^= poly[z]; V[0] ^= poly[z];
} }
XMEMCPY(c, Z, 16); XMEMCPY(c, Z, 16);

View File

@ -51,7 +51,7 @@ int pelican_init(pelican_state *pelmac, const unsigned char *key, unsigned long
return CRYPT_OK; return CRYPT_OK;
} }
static void four_rounds(pelican_state *pelmac) static void _four_rounds(pelican_state *pelmac)
{ {
ulong32 s0, s1, s2, s3, t0, t1, t2, t3; ulong32 s0, s1, s2, s3, t0, t1, t2, t3;
int r; int r;
@ -114,7 +114,7 @@ int pelican_process(pelican_state *pelmac, const unsigned char *in, unsigned lon
for (x = 0; x < 16; x += sizeof(LTC_FAST_TYPE)) { for (x = 0; x < 16; x += sizeof(LTC_FAST_TYPE)) {
*(LTC_FAST_TYPE_PTR_CAST((unsigned char *)pelmac->state + x)) ^= *(LTC_FAST_TYPE_PTR_CAST((unsigned char *)in + x)); *(LTC_FAST_TYPE_PTR_CAST((unsigned char *)pelmac->state + x)) ^= *(LTC_FAST_TYPE_PTR_CAST((unsigned char *)in + x));
} }
four_rounds(pelmac); _four_rounds(pelmac);
in += 16; in += 16;
inlen -= 16; inlen -= 16;
} }
@ -124,7 +124,7 @@ int pelican_process(pelican_state *pelmac, const unsigned char *in, unsigned lon
while (inlen--) { while (inlen--) {
pelmac->state[pelmac->buflen++] ^= *in++; pelmac->state[pelmac->buflen++] ^= *in++;
if (pelmac->buflen == 16) { if (pelmac->buflen == 16) {
four_rounds(pelmac); _four_rounds(pelmac);
pelmac->buflen = 0; pelmac->buflen = 0;
} }
} }
@ -148,7 +148,7 @@ int pelican_done(pelican_state *pelmac, unsigned char *out)
} }
if (pelmac->buflen == 16) { if (pelmac->buflen == 16) {
four_rounds(pelmac); _four_rounds(pelmac);
pelmac->buflen = 0; pelmac->buflen = 0;
} }
pelmac->state[pelmac->buflen++] ^= 0x80; pelmac->state[pelmac->buflen++] ^= 0x80;

View File

@ -572,7 +572,7 @@ static const struct {
}; };
/* find a hole and free as required, return -1 if no hole found */ /* find a hole and free as required, return -1 if no hole found */
static int find_hole(void) static int _find_hole(void)
{ {
unsigned x; unsigned x;
int y, z; int y, z;
@ -608,7 +608,7 @@ static int find_hole(void)
} }
/* determine if a base is already in the cache and if so, where */ /* determine if a base is already in the cache and if so, where */
static int find_base(ecc_point *g) static int _find_base(ecc_point *g)
{ {
int x; int x;
for (x = 0; x < FP_ENTRIES; x++) { for (x = 0; x < FP_ENTRIES; x++) {
@ -626,7 +626,7 @@ static int find_base(ecc_point *g)
} }
/* add a new base to the cache */ /* add a new base to the cache */
static int add_entry(int idx, ecc_point *g) static int _add_entry(int idx, ecc_point *g)
{ {
unsigned x, y; unsigned x, y;
@ -668,7 +668,7 @@ static int add_entry(int idx, ecc_point *g)
* The algorithm builds patterns in increasing bit order by first making all * The algorithm builds patterns in increasing bit order by first making all
* single bit input patterns, then all two bit input patterns and so on * single bit input patterns, then all two bit input patterns and so on
*/ */
static int build_lut(int idx, void *modulus, void *mp, void *mu) static int _build_lut(int idx, void *modulus, void *mp, void *mu)
{ {
unsigned x, y, err, bitlen, lut_gap; unsigned x, y, err, bitlen, lut_gap;
void *tmp; void *tmp;
@ -775,7 +775,7 @@ DONE:
} }
/* perform a fixed point ECC mulmod */ /* perform a fixed point ECC mulmod */
static int accel_fp_mul(int idx, void *k, ecc_point *R, void *modulus, void *mp, int map) static int _accel_fp_mul(int idx, void *k, ecc_point *R, void *modulus, void *mp, int map)
{ {
unsigned char kb[128]; unsigned char kb[128];
int x; int x;
@ -898,7 +898,7 @@ static int accel_fp_mul(int idx, void *k, ecc_point *R, void *modulus, void *mp,
#ifdef LTC_ECC_SHAMIR #ifdef LTC_ECC_SHAMIR
/* perform a fixed point ECC mulmod */ /* perform a fixed point ECC mulmod */
static int accel_fp_mul2add(int idx1, int idx2, static int _accel_fp_mul2add(int idx1, int idx2,
void *kA, void *kB, void *kA, void *kB,
ecc_point *R, void *modulus, void *mp) ecc_point *R, void *modulus, void *mp)
{ {
@ -1119,13 +1119,13 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
mu = NULL; mu = NULL;
LTC_MUTEX_LOCK(&ltc_ecc_fp_lock); LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
/* find point */ /* find point */
idx1 = find_base(A); idx1 = _find_base(A);
/* no entry? */ /* no entry? */
if (idx1 == -1) { if (idx1 == -1) {
/* find hole and add it */ /* find hole and add it */
if ((idx1 = find_hole()) >= 0) { if ((idx1 = _find_hole()) >= 0) {
if ((err = add_entry(idx1, A)) != CRYPT_OK) { if ((err = _add_entry(idx1, A)) != CRYPT_OK) {
goto LBL_ERR; goto LBL_ERR;
} }
} }
@ -1136,13 +1136,13 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
} }
/* find point */ /* find point */
idx2 = find_base(B); idx2 = _find_base(B);
/* no entry? */ /* no entry? */
if (idx2 == -1) { if (idx2 == -1) {
/* find hole and add it */ /* find hole and add it */
if ((idx2 = find_hole()) >= 0) { if ((idx2 = _find_hole()) >= 0) {
if ((err = add_entry(idx2, B)) != CRYPT_OK) { if ((err = _add_entry(idx2, B)) != CRYPT_OK) {
goto LBL_ERR; goto LBL_ERR;
} }
} }
@ -1166,7 +1166,7 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
} }
/* build the LUT */ /* build the LUT */
if ((err = build_lut(idx1, modulus, mp, mu)) != CRYPT_OK) { if ((err = _build_lut(idx1, modulus, mp, mu)) != CRYPT_OK) {
goto LBL_ERR;; goto LBL_ERR;;
} }
} }
@ -1187,7 +1187,7 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
} }
/* build the LUT */ /* build the LUT */
if ((err = build_lut(idx2, modulus, mp, mu)) != CRYPT_OK) { if ((err = _build_lut(idx2, modulus, mp, mu)) != CRYPT_OK) {
goto LBL_ERR;; goto LBL_ERR;;
} }
} }
@ -1198,7 +1198,7 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
/* compute mp */ /* compute mp */
if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { goto LBL_ERR; } if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { goto LBL_ERR; }
} }
err = accel_fp_mul2add(idx1, idx2, kA, kB, C, modulus, mp); err = _accel_fp_mul2add(idx1, idx2, kA, kB, C, modulus, mp);
} else { } else {
err = ltc_ecc_mul2add(A, kA, B, kB, C, modulus); err = ltc_ecc_mul2add(A, kA, B, kB, C, modulus);
} }
@ -1231,15 +1231,15 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int ma
mu = NULL; mu = NULL;
LTC_MUTEX_LOCK(&ltc_ecc_fp_lock); LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
/* find point */ /* find point */
idx = find_base(G); idx = _find_base(G);
/* no entry? */ /* no entry? */
if (idx == -1) { if (idx == -1) {
/* find hole and add it */ /* find hole and add it */
idx = find_hole(); idx = _find_hole();
if (idx >= 0) { if (idx >= 0) {
if ((err = add_entry(idx, G)) != CRYPT_OK) { if ((err = _add_entry(idx, G)) != CRYPT_OK) {
goto LBL_ERR; goto LBL_ERR;
} }
} }
@ -1264,7 +1264,7 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int ma
} }
/* build the LUT */ /* build the LUT */
if ((err = build_lut(idx, modulus, mp, mu)) != CRYPT_OK) { if ((err = _build_lut(idx, modulus, mp, mu)) != CRYPT_OK) {
goto LBL_ERR;; goto LBL_ERR;;
} }
} }
@ -1274,7 +1274,7 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int ma
/* compute mp */ /* compute mp */
if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { goto LBL_ERR; } if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { goto LBL_ERR; }
} }
err = accel_fp_mul(idx, k, R, modulus, mp, map); err = _accel_fp_mul(idx, k, R, modulus, mp, map);
} else { } else {
err = ltc_ecc_mulmod(k, G, R, modulus, map); err = ltc_ecc_mulmod(k, G, R, modulus, map);
} }
@ -1290,7 +1290,7 @@ LBL_ERR:
} }
/* helper function for freeing the cache ... must be called with the cache mutex locked */ /* helper function for freeing the cache ... must be called with the cache mutex locked */
static void ltc_ecc_fp_free_cache(void) static void _ltc_ecc_fp_free_cache(void)
{ {
unsigned x, y; unsigned x, y;
for (x = 0; x < FP_ENTRIES; x++) { for (x = 0; x < FP_ENTRIES; x++) {
@ -1315,7 +1315,7 @@ static void ltc_ecc_fp_free_cache(void)
void ltc_ecc_fp_free(void) void ltc_ecc_fp_free(void)
{ {
LTC_MUTEX_LOCK(&ltc_ecc_fp_lock); LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
ltc_ecc_fp_free_cache(); _ltc_ecc_fp_free_cache();
LTC_MUTEX_UNLOCK(&ltc_ecc_fp_lock); LTC_MUTEX_UNLOCK(&ltc_ecc_fp_lock);
} }
@ -1334,7 +1334,7 @@ ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock)
void *mu = NULL; void *mu = NULL;
LTC_MUTEX_LOCK(&ltc_ecc_fp_lock); LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
if ((idx = find_base(g)) >= 0) { if ((idx = _find_base(g)) >= 0) {
/* it is already in the cache ... just check that the LUT is initialized */ /* it is already in the cache ... just check that the LUT is initialized */
if(fp_cache[idx].lru_count >= 2) { if(fp_cache[idx].lru_count >= 2) {
LTC_MUTEX_UNLOCK(&ltc_ecc_fp_lock); LTC_MUTEX_UNLOCK(&ltc_ecc_fp_lock);
@ -1342,11 +1342,11 @@ ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock)
} }
} }
if(idx == -1 && (idx = find_hole()) == -1) { if(idx == -1 && (idx = _find_hole()) == -1) {
err = CRYPT_BUFFER_OVERFLOW; err = CRYPT_BUFFER_OVERFLOW;
goto LBL_ERR; goto LBL_ERR;
} }
if ((err = add_entry(idx, g)) != CRYPT_OK) { if ((err = _add_entry(idx, g)) != CRYPT_OK) {
goto LBL_ERR; goto LBL_ERR;
} }
/* compute mp */ /* compute mp */
@ -1363,7 +1363,7 @@ ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock)
} }
/* build the LUT */ /* build the LUT */
if ((err = build_lut(idx, modulus, mp, mu)) != CRYPT_OK) { if ((err = _build_lut(idx, modulus, mp, mu)) != CRYPT_OK) {
goto LBL_ERR; goto LBL_ERR;
} }
fp_cache[idx].lru_count = 2; fp_cache[idx].lru_count = 2;
@ -1501,7 +1501,7 @@ int ltc_ecc_fp_restore_state(unsigned char *in, unsigned long inlen)
/* /*
* start with an empty cache * start with an empty cache
*/ */
ltc_ecc_fp_free_cache(); _ltc_ecc_fp_free_cache();
/* /*
* decode the input packet: It consists of a sequence with a few * 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)
ERR_OUT: ERR_OUT:
if(asn1_list) if(asn1_list)
XFREE(asn1_list); XFREE(asn1_list);
ltc_ecc_fp_free_cache(); _ltc_ecc_fp_free_cache();
LTC_MUTEX_UNLOCK(&ltc_ecc_fp_lock); LTC_MUTEX_UNLOCK(&ltc_ecc_fp_lock);
return err; return err;
} }

View File

@ -14,7 +14,7 @@
#ifdef LTC_XTS_MODE #ifdef LTC_XTS_MODE
static int tweak_uncrypt(const unsigned char *C, unsigned char *P, unsigned char *T, symmetric_xts *xts) static int _tweak_uncrypt(const unsigned char *C, unsigned char *P, unsigned char *T, symmetric_xts *xts)
{ {
unsigned long x; unsigned long x;
int err; int err;
@ -108,7 +108,7 @@ int xts_decrypt(const unsigned char *ct, unsigned long ptlen, unsigned char *pt,
} }
for (i = 0; i < lim; i++) { for (i = 0; i < lim; i++) {
if ((err = tweak_uncrypt(ct, pt, T, xts)) != CRYPT_OK) { if ((err = _tweak_uncrypt(ct, pt, T, xts)) != CRYPT_OK) {
return err; return err;
} }
ct += 16; ct += 16;
@ -122,7 +122,7 @@ int xts_decrypt(const unsigned char *ct, unsigned long ptlen, unsigned char *pt,
xts_mult_x(CC); xts_mult_x(CC);
/* PP = tweak decrypt block m-1 */ /* PP = tweak decrypt block m-1 */
if ((err = tweak_uncrypt(ct, PP, CC, xts)) != CRYPT_OK) { if ((err = _tweak_uncrypt(ct, PP, CC, xts)) != CRYPT_OK) {
return err; return err;
} }
@ -136,7 +136,7 @@ int xts_decrypt(const unsigned char *ct, unsigned long ptlen, unsigned char *pt,
} }
/* Pm-1 = Tweak uncrypt CC */ /* Pm-1 = Tweak uncrypt CC */
if ((err = tweak_uncrypt(CC, pt, T, xts)) != CRYPT_OK) { if ((err = _tweak_uncrypt(CC, pt, T, xts)) != CRYPT_OK) {
return err; return err;
} }
} }

View File

@ -14,7 +14,7 @@
#ifdef LTC_XTS_MODE #ifdef LTC_XTS_MODE
static int tweak_crypt(const unsigned char *P, unsigned char *C, unsigned char *T, symmetric_xts *xts) static int _tweak_crypt(const unsigned char *P, unsigned char *C, unsigned char *T, symmetric_xts *xts)
{ {
unsigned long x; unsigned long x;
int err; int err;
@ -111,7 +111,7 @@ int xts_encrypt(const unsigned char *pt, unsigned long ptlen, unsigned char *ct,
} }
for (i = 0; i < lim; i++) { for (i = 0; i < lim; i++) {
if ((err = tweak_crypt(pt, ct, T, xts)) != CRYPT_OK) { if ((err = _tweak_crypt(pt, ct, T, xts)) != CRYPT_OK) {
return err; return err;
} }
ct += 16; ct += 16;
@ -122,7 +122,7 @@ int xts_encrypt(const unsigned char *pt, unsigned long ptlen, unsigned char *ct,
/* if ptlen not divide 16 then */ /* if ptlen not divide 16 then */
if (mo > 0) { if (mo > 0) {
/* CC = tweak encrypt block m-1 */ /* CC = tweak encrypt block m-1 */
if ((err = tweak_crypt(pt, CC, T, xts)) != CRYPT_OK) { if ((err = _tweak_crypt(pt, CC, T, xts)) != CRYPT_OK) {
return err; return err;
} }
@ -137,7 +137,7 @@ int xts_encrypt(const unsigned char *pt, unsigned long ptlen, unsigned char *ct,
} }
/* Cm-1 = Tweak encrypt PP */ /* Cm-1 = Tweak encrypt PP */
if ((err = tweak_crypt(PP, ct, T, xts)) != CRYPT_OK) { if ((err = _tweak_crypt(PP, ct, T, xts)) != CRYPT_OK) {
return err; return err;
} }
} }

View File

@ -16,7 +16,7 @@
#ifdef LTC_DER #ifdef LTC_DER
static int char_to_int(unsigned char x) static int _char_to_int(unsigned char x)
{ {
switch (x) { switch (x) {
case '0': return 0; case '0': return 0;
@ -34,13 +34,13 @@ static int char_to_int(unsigned char x)
} }
#define DECODE_V(y, max) do {\ #define DECODE_V(y, max) do {\
y = char_to_int(buf[x])*10 + char_to_int(buf[x+1]); \ y = _char_to_int(buf[x])*10 + _char_to_int(buf[x+1]); \
if (y >= max) return CRYPT_INVALID_PACKET; \ if (y >= max) return CRYPT_INVALID_PACKET; \
x += 2; \ x += 2; \
} while(0) } while(0)
#define DECODE_V4(y, max) do {\ #define DECODE_V4(y, max) do {\
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]); \ 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]); \
if (y >= max) return CRYPT_INVALID_PACKET; \ if (y >= max) return CRYPT_INVALID_PACKET; \
x += 4; \ x += 4; \
} while(0) } while(0)
@ -118,7 +118,7 @@ YYYYMMDDhhmmss.fs-hh'mm'
unsigned fs = out->fs; unsigned fs = out->fs;
if (x >= sizeof(buf)) return CRYPT_INVALID_PACKET; if (x >= sizeof(buf)) return CRYPT_INVALID_PACKET;
out->fs *= 10; out->fs *= 10;
out->fs += char_to_int(buf[x]); out->fs += _char_to_int(buf[x]);
if (fs > out->fs) return CRYPT_OVERFLOW; if (fs > out->fs) return CRYPT_OVERFLOW;
x++; x++;
} }

View File

@ -15,7 +15,7 @@
#ifdef LTC_DER #ifdef LTC_DER
static unsigned long fetch_length(const unsigned char *in, unsigned long inlen, unsigned long *data_offset) static unsigned long _fetch_length(const unsigned char *in, unsigned long inlen, unsigned long *data_offset)
{ {
unsigned long x, z; unsigned long x, z;
@ -51,7 +51,7 @@ static unsigned long fetch_length(const unsigned char *in, unsigned long inlen,
return z+*data_offset; return z+*data_offset;
} }
static int new_element(ltc_asn1_list **l) static int _new_element(ltc_asn1_list **l)
{ {
/* alloc new link */ /* alloc new link */
if (*l == NULL) { if (*l == NULL) {
@ -92,7 +92,7 @@ int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc
if (*inlen == 0) { if (*inlen == 0) {
/* alloc new link */ /* alloc new link */
if ((err = new_element(&l)) != CRYPT_OK) { if ((err = _new_element(&l)) != CRYPT_OK) {
goto error; goto error;
} }
} }
@ -103,14 +103,14 @@ int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc
type = *in; type = *in;
/* fetch length */ /* fetch length */
len = fetch_length(in, *inlen, &data_offset); len = _fetch_length(in, *inlen, &data_offset);
if (len > *inlen) { if (len > *inlen) {
err = CRYPT_INVALID_PACKET; err = CRYPT_INVALID_PACKET;
goto error; goto error;
} }
/* alloc new link */ /* alloc new link */
if ((err = new_element(&l)) != CRYPT_OK) { if ((err = _new_element(&l)) != CRYPT_OK) {
goto error; goto error;
} }

View File

@ -16,7 +16,7 @@
#ifdef LTC_DER #ifdef LTC_DER
/* LTC define to ASN.1 TAG */ /* LTC define to ASN.1 TAG */
static int ltc_to_asn1(ltc_asn1_type v) static int _ltc_to_asn1(ltc_asn1_type v)
{ {
switch (v) { switch (v) {
case LTC_ASN1_BOOLEAN: return 0x01; case LTC_ASN1_BOOLEAN: return 0x01;
@ -45,12 +45,12 @@ static int ltc_to_asn1(ltc_asn1_type v)
} }
static int qsort_helper(const void *a, const void *b) static int _qsort_helper(const void *a, const void *b)
{ {
ltc_asn1_list *A = (ltc_asn1_list *)a, *B = (ltc_asn1_list *)b; ltc_asn1_list *A = (ltc_asn1_list *)a, *B = (ltc_asn1_list *)b;
int r; int r;
r = ltc_to_asn1(A->type) - ltc_to_asn1(B->type); r = _ltc_to_asn1(A->type) - _ltc_to_asn1(B->type);
/* for QSORT the order is UNDEFINED if they are "equal" which means it is NOT DETERMINISTIC. So we force it to be :-) */ /* for QSORT the order is UNDEFINED if they are "equal" which means it is NOT DETERMINISTIC. So we force it to be :-) */
if (r == 0) { if (r == 0) {
@ -89,7 +89,7 @@ int der_encode_set(ltc_asn1_list *list, unsigned long inlen,
} }
/* sort it by the "type" field */ /* sort it by the "type" field */
XQSORT(copy, inlen, sizeof(*copy), &qsort_helper); XQSORT(copy, inlen, sizeof(*copy), &_qsort_helper);
/* call der_encode_sequence_ex() */ /* call der_encode_sequence_ex() */
err = der_encode_sequence_ex(copy, inlen, out, outlen, LTC_ASN1_SET); err = der_encode_sequence_ex(copy, inlen, out, outlen, LTC_ASN1_SET);

View File

@ -20,7 +20,7 @@ struct edge {
unsigned long size; unsigned long size;
}; };
static int qsort_helper(const void *a, const void *b) static int _qsort_helper(const void *a, const void *b)
{ {
struct edge *A = (struct edge *)a, *B = (struct edge *)b; struct edge *A = (struct edge *)a, *B = (struct edge *)b;
int r; int r;
@ -132,7 +132,7 @@ int der_encode_setof(ltc_asn1_list *list, unsigned long inlen,
} }
/* sort based on contents (using edges) */ /* sort based on contents (using edges) */
XQSORT(edges, inlen, sizeof(*edges), &qsort_helper); XQSORT(edges, inlen, sizeof(*edges), &_qsort_helper);
/* copy static header */ /* copy static header */
XMEMCPY(out, buf, hdrlen); XMEMCPY(out, buf, hdrlen);

View File

@ -15,7 +15,7 @@
#ifdef LTC_DER #ifdef LTC_DER
static int char_to_int(unsigned char x) static int _char_to_int(unsigned char x)
{ {
switch (x) { switch (x) {
case '0': return 0; case '0': return 0;
@ -33,7 +33,7 @@ static int char_to_int(unsigned char x)
} }
#define DECODE_V(y, max) \ #define DECODE_V(y, max) \
y = char_to_int(buf[x])*10 + char_to_int(buf[x+1]); \ y = _char_to_int(buf[x])*10 + _char_to_int(buf[x+1]); \
if (y >= max) return CRYPT_INVALID_PACKET; \ if (y >= max) return CRYPT_INVALID_PACKET; \
x += 2; x += 2;

View File

@ -26,7 +26,7 @@
@param g [out] bignum where generated 'g' is stored (must be initialized by caller) @param g [out] bignum where generated 'g' is stored (must be initialized by caller)
@return CRYPT_OK if successful, upon error this function will free all allocated memory @return CRYPT_OK if successful, upon error this function will free all allocated memory
*/ */
static int dsa_make_params(prng_state *prng, int wprng, int group_size, int modulus_size, void *p, void *q, void *g) static int _dsa_make_params(prng_state *prng, int wprng, int group_size, int modulus_size, void *p, void *q, void *g)
{ {
unsigned long L, N, n, outbytes, seedbytes, counter, j, i; unsigned long L, N, n, outbytes, seedbytes, counter, j, i;
int err, res, mr_tests_q, mr_tests_p, found_p, found_q, hash; int err, res, mr_tests_q, mr_tests_p, found_p, found_q, hash;
@ -227,7 +227,7 @@ int dsa_make_key_ex(prng_state *prng, int wprng, int group_size, int modulus_siz
if (p_hex == NULL || q_hex == NULL || g_hex == NULL) { if (p_hex == NULL || q_hex == NULL || g_hex == NULL) {
/* generate params */ /* generate params */
err = dsa_make_params(prng, wprng, group_size, modulus_size, key->p, key->q, key->g); err = _dsa_make_params(prng, wprng, group_size, modulus_size, key->p, key->q, key->g);
if (err != CRYPT_OK) { goto cleanup; } if (err != CRYPT_OK) { goto cleanup; }
} }
else { else {

View File

@ -21,7 +21,7 @@
#ifdef LTC_MECC #ifdef LTC_MECC
static int is_point(ecc_key *key) static int _is_point(ecc_key *key)
{ {
void *prime, *b, *t1, *t2; void *prime, *b, *t1, *t2;
int err; int err;
@ -153,7 +153,7 @@ int ecc_import_ex(const unsigned char *in, unsigned long inlen, ecc_key *key, co
if ((err = mp_set(key->pubkey.z, 1)) != CRYPT_OK) { goto done; } if ((err = mp_set(key->pubkey.z, 1)) != CRYPT_OK) { goto done; }
/* is it a point on the curve? */ /* is it a point on the curve? */
if ((err = is_point(key)) != CRYPT_OK) { if ((err = _is_point(key)) != CRYPT_OK) {
goto done; goto done;
} }

View File

@ -49,7 +49,7 @@ const struct ltc_prng_descriptor fortuna_desc = {
}; };
/* update the IV */ /* update the IV */
static void fortuna_update_iv(prng_state *prng) static void _fortuna_update_iv(prng_state *prng)
{ {
int x; int x;
unsigned char *IV; unsigned char *IV;
@ -62,7 +62,7 @@ static void fortuna_update_iv(prng_state *prng)
} }
/* reseed the PRNG */ /* reseed the PRNG */
static int fortuna_reseed(prng_state *prng) static int _fortuna_reseed(prng_state *prng)
{ {
unsigned char tmp[MAXBLOCKSIZE]; unsigned char tmp[MAXBLOCKSIZE];
hash_state md; hash_state md;
@ -106,7 +106,7 @@ static int fortuna_reseed(prng_state *prng)
if ((err = rijndael_setup(prng->fortuna.K, 32, 0, &prng->fortuna.skey)) != CRYPT_OK) { if ((err = rijndael_setup(prng->fortuna.K, 32, 0, &prng->fortuna.skey)) != CRYPT_OK) {
return err; return err;
} }
fortuna_update_iv(prng); _fortuna_update_iv(prng);
/* reset pool len */ /* reset pool len */
prng->fortuna.pool0_len = 0; prng->fortuna.pool0_len = 0;
@ -217,7 +217,7 @@ int fortuna_ready(prng_state *prng)
LTC_ARGCHK(prng != NULL); LTC_ARGCHK(prng != NULL);
LTC_MUTEX_LOCK(&prng->lock); LTC_MUTEX_LOCK(&prng->lock);
err = fortuna_reseed(prng); err = _fortuna_reseed(prng);
prng->ready = (err == CRYPT_OK) ? 1 : 0; prng->ready = (err == CRYPT_OK) ? 1 : 0;
LTC_MUTEX_UNLOCK(&prng->lock); LTC_MUTEX_UNLOCK(&prng->lock);
@ -246,7 +246,7 @@ unsigned long fortuna_read(unsigned char *out, unsigned long outlen, prng_state
/* do we have to reseed? */ /* do we have to reseed? */
if (++prng->fortuna.wd == LTC_FORTUNA_WD || prng->fortuna.pool0_len >= 64) { if (++prng->fortuna.wd == LTC_FORTUNA_WD || prng->fortuna.pool0_len >= 64) {
if (fortuna_reseed(prng) != CRYPT_OK) { if (_fortuna_reseed(prng) != CRYPT_OK) {
goto LBL_UNLOCK; goto LBL_UNLOCK;
} }
} }
@ -260,22 +260,22 @@ unsigned long fortuna_read(unsigned char *out, unsigned long outlen, prng_state
rijndael_ecb_encrypt(prng->fortuna.IV, out, &prng->fortuna.skey); rijndael_ecb_encrypt(prng->fortuna.IV, out, &prng->fortuna.skey);
out += 16; out += 16;
outlen -= 16; outlen -= 16;
fortuna_update_iv(prng); _fortuna_update_iv(prng);
} }
/* left over bytes? */ /* left over bytes? */
if (outlen > 0) { if (outlen > 0) {
rijndael_ecb_encrypt(prng->fortuna.IV, tmp, &prng->fortuna.skey); rijndael_ecb_encrypt(prng->fortuna.IV, tmp, &prng->fortuna.skey);
XMEMCPY(out, tmp, outlen); XMEMCPY(out, tmp, outlen);
fortuna_update_iv(prng); _fortuna_update_iv(prng);
} }
/* generate new key */ /* generate new key */
rijndael_ecb_encrypt(prng->fortuna.IV, prng->fortuna.K , &prng->fortuna.skey); rijndael_ecb_encrypt(prng->fortuna.IV, prng->fortuna.K , &prng->fortuna.skey);
fortuna_update_iv(prng); _fortuna_update_iv(prng);
rijndael_ecb_encrypt(prng->fortuna.IV, prng->fortuna.K+16, &prng->fortuna.skey); rijndael_ecb_encrypt(prng->fortuna.IV, prng->fortuna.K+16, &prng->fortuna.skey);
fortuna_update_iv(prng); _fortuna_update_iv(prng);
if (rijndael_setup(prng->fortuna.K, 32, 0, &prng->fortuna.skey) != CRYPT_OK) { if (rijndael_setup(prng->fortuna.K, 32, 0, &prng->fortuna.skey) != CRYPT_OK) {
tlen = 0; tlen = 0;