Commit a59228c6 authored by Mike Hamburg's avatar Mike Hamburg

const** related fixes for gcc

parent 1b4072de
......@@ -462,7 +462,7 @@ goldilocks_verify (
linear_combo_var_fixed_vt( pk_text,
challenge, GOLDI_SCALAR_BITS,
s, GOLDI_SCALAR_BITS,
goldilocks_global.wnafs, WNAF_PRECMP_BITS );
(const tw_niels_a_t*)goldilocks_global.wnafs, WNAF_PRECMP_BITS );
untwist_and_double_and_serialize( pk, pk_text );
......
......@@ -70,52 +70,6 @@ constant_time_lookup_tw_niels (
constant_time_lookup(out,in,sizeof(*out),nin,idx);
}
/*
static __inline__ void
constant_time_lookup_tw_pniels (
tw_pniels_a_t out,
const tw_pniels_a_t in,
int nin,
int idx
) {
big_register_t big_one = br_set_to_mask(1), big_i = br_set_to_mask(idx);
big_register_t *o = (big_register_t *)out;
const big_register_t *i = (const big_register_t *)in;
int j;
unsigned int k;
really_memset(out, 0, sizeof(*out));
for (j=0; j<nin; j++, big_i-=big_one) {
big_register_t mask = br_is_zero(big_i);
for (k=0; k<sizeof(*out)/sizeof(*o); k++) {
o[k] |= mask & i[k+j*sizeof(*out)/sizeof(*o)];
}
}
}
static __inline__ void
constant_time_lookup_tw_niels (
tw_niels_a_t out,
const tw_niels_a_t in,
int nin,
int idx
) {
big_register_t big_one = br_set_to_mask(1), big_i = br_set_to_mask(idx);
big_register_t *o = (big_register_t *)out;
const big_register_t *i = (const big_register_t *)in;
int j;
unsigned int k;
really_memset(out, 0, sizeof(*out));
for (j=0; j<nin; j++, big_i-=big_one) {
big_register_t mask = br_is_zero(big_i);
for (k=0; k<sizeof(*out)/sizeof(*o); k++) {
o[k] |= mask & i[k+j*sizeof(*out)/sizeof(*o)];
}
}
}
*/
static void
convert_to_signed_window_form (
word_t *out,
......@@ -180,7 +134,7 @@ scalarmul (
inv = (bits>>(WINDOW-1))-1;
bits ^= inv;
constant_time_lookup_tw_pniels(pn, multiples, NTABLE, bits & WINDOW_T_MASK);
constant_time_lookup_tw_pniels(pn, (const tw_pniels_a_t*)multiples, NTABLE, bits & WINDOW_T_MASK);
cond_negate_tw_pniels(pn, inv);
convert_tw_pniels_to_tw_extensible(working, pn);
......@@ -200,7 +154,7 @@ scalarmul (
inv = (bits>>(WINDOW-1))-1;
bits ^= inv;
constant_time_lookup_tw_pniels(pn, multiples, NTABLE, bits & WINDOW_T_MASK);
constant_time_lookup_tw_pniels(pn, (const tw_pniels_a_t*)multiples, NTABLE, bits & WINDOW_T_MASK);
cond_negate_tw_pniels(pn, inv);
add_tw_pniels_to_tw_extensible(working, pn);
}
......@@ -355,7 +309,7 @@ scalarmul_fixed_base (
tab ^= invert;
tab &= (1<<(t-1)) - 1;
constant_time_lookup_tw_niels(ni, table->table + (j<<(t-1)), 1<<(t-1), tab);
constant_time_lookup_tw_niels(ni, (const tw_niels_a_t*)table->table + (j<<(t-1)), 1<<(t-1), tab);
cond_negate_tw_niels(ni, invert);
if (i||j) {
add_tw_niels_to_tw_extensible(out, ni);
......@@ -582,7 +536,7 @@ precompute_fixed_base (
}
}
field_simultaneous_invert(zis, zs, n<<(t-1));
field_simultaneous_invert(zis, (const field_a_t*)zs, n<<(t-1));
field_a_t product;
for (i=0; i<n<<(t-1); i++) {
......@@ -670,7 +624,7 @@ precompute_fixed_base_wnaf (
}
}
field_simultaneous_invert(zis, zs, 1<<tbits);
field_simultaneous_invert(zis, (const field_a_t *)zs, 1<<tbits);
field_a_t product;
for (i=0; i<1<<tbits; i++) {
......
......@@ -367,7 +367,7 @@ int main(int argc, char **argv) {
when = now();
for (i=0; i<nbase/10; i++) {
q448_randomize(&crand, sk);
scalarmul_fixed_base_wnaf_vt(&ext,sk,SCALAR_BITS,wnaft,6);
scalarmul_fixed_base_wnaf_vt(&ext,sk,SCALAR_BITS,(const tw_niels_a_t*)wnaft,6);
}
when = now() - when;
printf("edwards vt6: %5.1fµs\n", when * 1e6 / i);
......@@ -382,7 +382,7 @@ int main(int argc, char **argv) {
when = now();
for (i=0; i<nbase/10; i++) {
q448_randomize(&crand, sk);
scalarmul_fixed_base_wnaf_vt(&ext,sk,SCALAR_BITS,wnaft,4);
scalarmul_fixed_base_wnaf_vt(&ext,sk,SCALAR_BITS,(const tw_niels_a_t*)wnaft,4);
}
when = now() - when;
printf("edwards vt4: %5.1fµs\n", when * 1e6 / i);
......@@ -397,7 +397,7 @@ int main(int argc, char **argv) {
when = now();
for (i=0; i<nbase/10; i++) {
q448_randomize(&crand, sk);
scalarmul_fixed_base_wnaf_vt(&ext,sk,SCALAR_BITS,wnaft,5);
scalarmul_fixed_base_wnaf_vt(&ext,sk,SCALAR_BITS,(const tw_niels_a_t*)wnaft,5);
}
when = now() - when;
printf("edwards vt5: %5.1fµs\n", when * 1e6 / i);
......@@ -406,7 +406,7 @@ int main(int argc, char **argv) {
for (i=0; i<nbase/10; i++) {
q448_randomize(&crand, sk);
q448_randomize(&crand, tk);
linear_combo_var_fixed_vt(&ext,sk,FIELD_BITS,tk,FIELD_BITS,wnaft,5);
linear_combo_var_fixed_vt(&ext,sk,FIELD_BITS,tk,FIELD_BITS,(const tw_niels_a_t*)wnaft,5);
}
when = now() - when;
printf("vt vf combo: %5.1fµs\n", when * 1e6 / i);
......@@ -716,7 +716,7 @@ int main(int argc, char **argv) {
serialize_extensible(b, &exta);
ignore_result(precompute_fixed_base_wnaf(wnaft,&exu,5));
linear_combo_var_fixed_vt(&ext,sk,FIELD_BITS,tk,FIELD_BITS,wnaft,5);
linear_combo_var_fixed_vt(&ext,sk,FIELD_BITS,tk,FIELD_BITS,(const tw_niels_a_t*)wnaft,5);
untwist_and_double(&exta,&exv);
serialize_extensible(c, &exta);
......
......@@ -89,7 +89,7 @@ single_scalarmul_compatibility_test (
continue;
}
scalarmul_fixed_base_wnaf_vt(&work, scalar, nbits, pre, i);
scalarmul_fixed_base_wnaf_vt(&work, scalar, nbits, (const tw_niels_a_t*)pre, i);
untwist_and_double_and_serialize(wout[i], &work);
}
......@@ -193,7 +193,7 @@ single_linear_combo_test (
/* use the dedicated wNAF linear combo algorithm */
copy_tw_extensible(&working, &text1);
linear_combo_var_fixed_vt(&working, scalar1, nbits1, scalar2, nbits2, wnaf, 5);
linear_combo_var_fixed_vt(&working, scalar1, nbits1, scalar2, nbits2, (const tw_niels_a_t*)wnaf, 5);
untwist_and_double_and_serialize(result_wnaf, &working);
/* use the dedicated combs algorithm */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment