mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-10 15:30:55 +00:00
remove unused functions
This commit is contained in:
parent
092d8e7bf1
commit
8cc6539d2d
1
Makefile
1
Makefile
@ -21,7 +21,6 @@ CFLAGS += $(OPTFLAGS) \
|
||||
-Winit-self \
|
||||
-Wuninitialized \
|
||||
-Wformat-security \
|
||||
-Wno-unused-function \
|
||||
-Werror
|
||||
|
||||
# disable sequence point warning because of AES code
|
||||
|
@ -29,6 +29,7 @@ ge25519_full_to_pniels(ge25519_pniels *p, const ge25519 *r) {
|
||||
adding & doubling
|
||||
*/
|
||||
|
||||
#if 0 // UNUSED
|
||||
static void
|
||||
ge25519_add_p1p1(ge25519_p1p1 *r, const ge25519 *p, const ge25519 *q) {
|
||||
bignum25519 a,b,c,d,t,u;
|
||||
@ -48,7 +49,7 @@ ge25519_add_p1p1(ge25519_p1p1 *r, const ge25519 *p, const ge25519 *q) {
|
||||
curve25519_add_after_basic(r->z, d, c);
|
||||
curve25519_sub_after_basic(r->t, d, c);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void
|
||||
ge25519_double_p1p1(ge25519_p1p1 *r, const ge25519 *p) {
|
||||
@ -119,12 +120,14 @@ ge25519_double(ge25519 *r, const ge25519 *p) {
|
||||
ge25519_p1p1_to_full(r, &t);
|
||||
}
|
||||
|
||||
#if 0 // UNUSED
|
||||
static void
|
||||
ge25519_add(ge25519 *r, const ge25519 *p, const ge25519 *q) {
|
||||
ge25519_p1p1 t;
|
||||
ge25519_add_p1p1(&t, p, q);
|
||||
ge25519_p1p1_to_full(r, &t);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
ge25519_nielsadd2(ge25519 *r, const ge25519_niels *q) {
|
||||
@ -294,6 +297,7 @@ STATIC void ge25519_double_scalarmult_vartime(ge25519 *r, const ge25519 *p1, con
|
||||
}
|
||||
|
||||
/* computes [s1]p1 */
|
||||
#if 0 // UNUSED
|
||||
STATIC void ge25519_scalarmult_vartime(ge25519 *r, const ge25519 *p1, const bignum256modm s1) {
|
||||
signed char slide1[256];
|
||||
ge25519_pniels pre1[S1_TABLE_SIZE];
|
||||
@ -326,6 +330,7 @@ STATIC void ge25519_scalarmult_vartime(ge25519 *r, const ge25519 *p1, const bign
|
||||
ge25519_p1p1_to_partial(r, &t);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The following conditional move stuff uses conditional moves.
|
||||
@ -376,6 +381,7 @@ DONNA_INLINE static void ge25519_cmove_stride4b(long * r, long * p, long * pos,
|
||||
}
|
||||
#define HAS_CMOVE_STRIDE4B
|
||||
|
||||
#if 0 // UNUSED
|
||||
STATIC void ge25519_move_conditional_pniels_array(ge25519_pniels * r, const ge25519_pniels * p, int pos, int n) {
|
||||
#ifdef HAS_CMOVE_STRIDE4B
|
||||
size_t i;
|
||||
@ -393,6 +399,7 @@ STATIC void ge25519_move_conditional_pniels_array(ge25519_pniels * r, const ge25
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC void ge25519_move_conditional_niels_array(ge25519_niels * r, const uint8_t p[8][96], int pos, int n) {
|
||||
size_t i;
|
||||
@ -406,6 +413,7 @@ STATIC void ge25519_move_conditional_niels_array(ge25519_niels * r, const uint8_
|
||||
}
|
||||
|
||||
/* computes [s1]p1, constant time */
|
||||
#if 0 // UNUSED
|
||||
STATIC void ge25519_scalarmult(ge25519 *r, const ge25519 *p1, const bignum256modm s1) {
|
||||
signed char slide1[64];
|
||||
ge25519_pniels pre1[9];
|
||||
@ -439,6 +447,7 @@ STATIC void ge25519_scalarmult(ge25519 *r, const ge25519 *p1, const bignum256mod
|
||||
ge25519_p1p1_to_partial(r, &t);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_GE25519_SCALARMULT_BASE_CHOOSE_NIELS)
|
||||
|
||||
@ -506,8 +515,3 @@ ge25519_scalarmult_base_niels(ge25519 *r, const uint8_t basepoint_table[256][96]
|
||||
ge25519_nielsadd2(r, &t);
|
||||
}
|
||||
}
|
||||
|
||||
STATIC void ge25519_scalarmult_base(ge25519 *r, const bignum256modm s) {
|
||||
ge25519_scalarmult_base_niels(r, ge25519_niels_base_multiples, s);
|
||||
}
|
||||
|
||||
|
@ -365,92 +365,3 @@ STATIC void contract256_slidingwindow_modm(signed char r[256], const bignum256mo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
helpers for batch verifcation, are allowed to be vartime
|
||||
*/
|
||||
|
||||
/* out = a - b, a must be larger than b */
|
||||
STATIC void sub256_modm_batch(bignum256modm out, const bignum256modm a, const bignum256modm b, size_t limbsize) {
|
||||
size_t i = 0;
|
||||
bignum256modm_element_t carry = 0;
|
||||
switch (limbsize) {
|
||||
case 8: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
|
||||
case 7: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
|
||||
case 6: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
|
||||
case 5: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
|
||||
case 4: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
|
||||
case 3: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
|
||||
case 2: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
|
||||
case 1: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
|
||||
case 0:
|
||||
default: out[i] = (a[i] - b[i]) - carry;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* is a < b */
|
||||
STATIC int lt256_modm_batch(const bignum256modm a, const bignum256modm b, size_t limbsize) {
|
||||
switch (limbsize) {
|
||||
case 8: if (a[8] > b[8]) return 0; if (a[8] < b[8]) return 1;
|
||||
case 7: if (a[7] > b[7]) return 0; if (a[7] < b[7]) return 1;
|
||||
case 6: if (a[6] > b[6]) return 0; if (a[6] < b[6]) return 1;
|
||||
case 5: if (a[5] > b[5]) return 0; if (a[5] < b[5]) return 1;
|
||||
case 4: if (a[4] > b[4]) return 0; if (a[4] < b[4]) return 1;
|
||||
case 3: if (a[3] > b[3]) return 0; if (a[3] < b[3]) return 1;
|
||||
case 2: if (a[2] > b[2]) return 0; if (a[2] < b[2]) return 1;
|
||||
case 1: if (a[1] > b[1]) return 0; if (a[1] < b[1]) return 1;
|
||||
case 0: if (a[0] > b[0]) return 0; if (a[0] < b[0]) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* is a <= b */
|
||||
STATIC int lte256_modm_batch(const bignum256modm a, const bignum256modm b, size_t limbsize) {
|
||||
switch (limbsize) {
|
||||
case 8: if (a[8] > b[8]) return 0; if (a[8] < b[8]) return 1;
|
||||
case 7: if (a[7] > b[7]) return 0; if (a[7] < b[7]) return 1;
|
||||
case 6: if (a[6] > b[6]) return 0; if (a[6] < b[6]) return 1;
|
||||
case 5: if (a[5] > b[5]) return 0; if (a[5] < b[5]) return 1;
|
||||
case 4: if (a[4] > b[4]) return 0; if (a[4] < b[4]) return 1;
|
||||
case 3: if (a[3] > b[3]) return 0; if (a[3] < b[3]) return 1;
|
||||
case 2: if (a[2] > b[2]) return 0; if (a[2] < b[2]) return 1;
|
||||
case 1: if (a[1] > b[1]) return 0; if (a[1] < b[1]) return 1;
|
||||
case 0: if (a[0] > b[0]) return 0; if (a[0] < b[0]) return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* is a == 0 */
|
||||
STATIC int iszero256_modm_batch(const bignum256modm a) {
|
||||
size_t i;
|
||||
for (i = 0; i < 9; i++)
|
||||
if (a[i])
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* is a == 1 */
|
||||
STATIC int isone256_modm_batch(const bignum256modm a) {
|
||||
size_t i;
|
||||
if (a[0] != 1)
|
||||
return 0;
|
||||
for (i = 1; i < 9; i++)
|
||||
if (a[i])
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* can a fit in to (at most) 128 bits */
|
||||
STATIC int isatmost128bits256_modm_batch(const bignum256modm a) {
|
||||
uint32_t mask =
|
||||
((a[8] ) | /* 16 */
|
||||
(a[7] ) | /* 46 */
|
||||
(a[6] ) | /* 76 */
|
||||
(a[5] ) | /* 106 */
|
||||
(a[4] & 0x3fffff00)); /* 128 */
|
||||
|
||||
return (mask == 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user