Code cleanup

This commit is contained in:
Matthias Schiffer 2012-03-14 06:37:19 +01:00
parent 50019f858f
commit a3345c7d5b

View file

@ -72,11 +72,14 @@ static void squeeze(unsigned int a[32]) {
u += a[31]; a[31] = u; u += a[31]; a[31] = u;
} }
static void freeze(unsigned int a[32]) {
static const unsigned int minusp[32] = { static const unsigned int minusp[32] = {
19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128 19, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 128
}; };
static void freeze(unsigned int a[32]) {
unsigned int aorig[32]; unsigned int aorig[32];
unsigned int j; unsigned int j;
unsigned int negative; unsigned int negative;
@ -186,15 +189,6 @@ static void select(unsigned int out[32], const unsigned int r[32], const unsigne
} }
} }
static const unsigned int rho_s[32] = {
0xb0, 0xa0, 0x0e, 0x4a, 0x27, 0x1b, 0xee, 0xc4,
0x78, 0xe4, 0x2f, 0xad, 0x06, 0x18, 0x43, 0x2f,
0xa7, 0xd7, 0xfb, 0x3d, 0x99, 0x00, 0x4d, 0x2b,
0x0b, 0xdf, 0xc1, 0x4f, 0x80, 0x24, 0x83, 0x2b
};
static const unsigned int zero[32] = {0};
static void square_root(unsigned int out[32], const unsigned int z[32]) { static void square_root(unsigned int out[32], const unsigned int z[32]) {
static const unsigned int minus1[32] = { static const unsigned int minus1[32] = {
0xec, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xec, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@ -203,6 +197,13 @@ static void square_root(unsigned int out[32], const unsigned int z[32]) {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f
}; };
static const unsigned int rho_s[32] = {
0xb0, 0xa0, 0x0e, 0x4a, 0x27, 0x1b, 0xee, 0xc4,
0x78, 0xe4, 0x2f, 0xad, 0x06, 0x18, 0x43, 0x2f,
0xa7, 0xd7, 0xfb, 0x3d, 0x99, 0x00, 0x4d, 0x2b,
0x0b, 0xdf, 0xc1, 0x4f, 0x80, 0x24, 0x83, 0x2b
};
/* raise z to power (2^252-2), check if power (2^253-5) equals -1 */ /* raise z to power (2^252-2), check if power (2^253-5) equals -1 */
unsigned int z2[32]; unsigned int z2[32];
@ -344,6 +345,8 @@ static void recip(unsigned int out[32], const unsigned int z[32]) {
} }
void ecc_25519_load(ecc_25519_work *out, const ecc_public_key_256 *in) { void ecc_25519_load(ecc_25519_work *out, const ecc_public_key_256 *in) {
static const unsigned int zero[32] = {0};
int i; int i;
unsigned int X2[32], _1_a_X2[32], d_X2_a_X2[32], Y[32], Yt[32]; unsigned int X2[32], _1_a_X2[32], d_X2_a_X2[32], Y[32], Yt[32];
unsigned int d_X2[32] = {0x04, 0x6d, 0x07} /* 486660 */, a_X2[32] = {0x08, 0x6d, 0x07} /* 486664 */; unsigned int d_X2[32] = {0x04, 0x6d, 0x07} /* 486660 */, a_X2[32] = {0x08, 0x6d, 0x07} /* 486664 */;