summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-12-22 22:12:03 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-12-22 22:12:03 +0100
commit9c832519c6b4b3a001b82e832c345791221db399 (patch)
treecfc41d1e116a150a8653daa991356e8a0d1c5a58 /src
parentc6f33a891f64167a3905a71477fd65cb90237298 (diff)
downloadlibuecc-9c832519c6b4b3a001b82e832c345791221db399.tar
libuecc-9c832519c6b4b3a001b82e832c345791221db399.zip
Change type names to follow the _t convention, add `deprecated' attribute
Diffstat (limited to 'src')
-rw-r--r--src/ec25519.c30
-rw-r--r--src/ec25519_gf.c18
2 files changed, 24 insertions, 24 deletions
diff --git a/src/ec25519.c b/src/ec25519.c
index 64de22e..bc6cc13 100644
--- a/src/ec25519.c
+++ b/src/ec25519.c
@@ -159,7 +159,7 @@ static int check_zero(const unsigned int x[32]) {
return (check_equal(x, zero) | check_equal(x, p));
}
-static void selectw(ecc_25519_work *out, const ecc_25519_work *r, const ecc_25519_work *s, unsigned int b) {
+static void selectw(ecc_25519_work_t *out, const ecc_25519_work_t *r, const ecc_25519_work_t *s, unsigned int b) {
unsigned int j;
unsigned int t;
unsigned int bminus1;
@@ -347,7 +347,7 @@ static void recip(unsigned int out[32], const unsigned int z[32]) {
/* 2^255 - 21 */ mult(out, t1, z11);
}
-void ecc_25519_load_xy(ecc_25519_work *out, const ecc_int_256 *x, const ecc_int_256 *y) {
+void ecc_25519_load_xy(ecc_25519_work_t *out, const ecc_int256_t *x, const ecc_int256_t *y) {
int i;
for (i = 0; i < 32; i++) {
@@ -359,7 +359,7 @@ void ecc_25519_load_xy(ecc_25519_work *out, const ecc_int_256 *x, const ecc_int_
mult(out->T, out->X, out->Y);
}
-void ecc_25519_store_xy(ecc_int_256 *x, ecc_int_256 *y, const ecc_25519_work *in) {
+void ecc_25519_store_xy(ecc_int256_t *x, ecc_int256_t *y, const ecc_25519_work_t *in) {
unsigned int X[32], Y[32], Z[32];
int i;
@@ -380,7 +380,7 @@ void ecc_25519_store_xy(ecc_int_256 *x, ecc_int_256 *y, const ecc_25519_work *in
}
}
-void ecc_25519_load_packed(ecc_25519_work *out, const ecc_int_256 *in) {
+void ecc_25519_load_packed(ecc_25519_work_t *out, const ecc_int256_t *in) {
static const unsigned int zero[32] = {0};
static const unsigned int one[32] = {1};
@@ -410,16 +410,16 @@ void ecc_25519_load_packed(ecc_25519_work *out, const ecc_int_256 *in) {
mult(out->T, out->X, out->Y);
}
-void ecc_25519_store_packed(ecc_int_256 *out, const ecc_25519_work *in) {
- ecc_int_256 y;
+void ecc_25519_store_packed(ecc_int256_t *out, const ecc_25519_work_t *in) {
+ ecc_int256_t y;
ecc_25519_store_xy(out, &y, in);
out->p[31] |= (y.p[0] << 7);
}
-static const ecc_25519_work id = {{0}, {1}, {1}, {0}};
+static const ecc_25519_work_t id = {{0}, {1}, {1}, {0}};
-int ecc_25519_is_identity(const ecc_25519_work *in) {
+int ecc_25519_is_identity(const ecc_25519_work_t *in) {
unsigned int Y_Z[32];
sub(Y_Z, in->Y, in->Z);
@@ -428,7 +428,7 @@ int ecc_25519_is_identity(const ecc_25519_work *in) {
return (check_zero(in->X)&check_zero(Y_Z));
}
-void ecc_25519_double(ecc_25519_work *out, const ecc_25519_work *in) {
+void ecc_25519_double(ecc_25519_work_t *out, const ecc_25519_work_t *in) {
unsigned int A[32], B[32], C[32], D[32], E[32], F[32], G[32], H[32], t0[32], t1[32], t2[32], t3[32];
square(A, in->X);
@@ -449,7 +449,7 @@ void ecc_25519_double(ecc_25519_work *out, const ecc_25519_work *in) {
mult(out->Z, F, G);
}
-void ecc_25519_add(ecc_25519_work *out, const ecc_25519_work *in1, const ecc_25519_work *in2) {
+void ecc_25519_add(ecc_25519_work_t *out, const ecc_25519_work_t *in1, const ecc_25519_work_t *in2) {
unsigned int A[32], B[32], C[32], D[32], E[32], F[32], G[32], H[32], t0[32], t1[32], t2[32], t3[32], t4[32], t5[32];
mult(A, in1->X, in2->X);
@@ -472,9 +472,9 @@ void ecc_25519_add(ecc_25519_work *out, const ecc_25519_work *in1, const ecc_255
mult(out->Z, F, G);
}
-void ecc_25519_scalarmult(ecc_25519_work *out, const ecc_int_256 *n, const ecc_25519_work *base) {
- ecc_25519_work Q2, Q2p;
- ecc_25519_work cur = id;
+void ecc_25519_scalarmult(ecc_25519_work_t *out, const ecc_int256_t *n, const ecc_25519_work_t *base) {
+ ecc_25519_work_t Q2, Q2p;
+ ecc_25519_work_t cur = id;
int b, pos;
for (pos = 255; pos >= 0; --pos) {
@@ -489,7 +489,7 @@ void ecc_25519_scalarmult(ecc_25519_work *out, const ecc_int_256 *n, const ecc_2
*out = cur;
}
-static const ecc_25519_work default_base = {
+static const ecc_25519_work_t default_base = {
{0xd4, 0x6b, 0xfe, 0x7f, 0x39, 0xfa, 0x8c, 0x22,
0xe1, 0x96, 0x23, 0xeb, 0x26, 0xb7, 0x8e, 0x6a,
0x34, 0x74, 0x8b, 0x66, 0xd6, 0xa3, 0x26, 0xdd,
@@ -505,6 +505,6 @@ static const ecc_25519_work default_base = {
0x47, 0x4b, 0x4c, 0x81, 0xa6, 0x02, 0xfd, 0x29}
};
-void ecc_25519_scalarmult_base(ecc_25519_work *out, const ecc_int_256 *n) {
+void ecc_25519_scalarmult_base(ecc_25519_work_t *out, const ecc_int256_t *n) {
ecc_25519_scalarmult(out, n, &default_base);
}
diff --git a/src/ec25519_gf.c b/src/ec25519_gf.c
index bb5715f..ec3b543 100644
--- a/src/ec25519_gf.c
+++ b/src/ec25519_gf.c
@@ -37,7 +37,7 @@
#define ASR(n,s) (((n) >> s)|(IS_NEGATIVE(n)*((unsigned)-1) << (8*sizeof(n)-s)))
-const ecc_int_256 ecc_25519_gf_order = {{
+const ecc_int256_t ecc_25519_gf_order = {{
0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58,
0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -58,9 +58,9 @@ static void select(unsigned char out[32], const unsigned char r[32], const unsig
}
}
-int ecc_25519_gf_is_zero(const ecc_int_256 *in) {
+int ecc_25519_gf_is_zero(const ecc_int256_t *in) {
int i;
- ecc_int_256 r;
+ ecc_int256_t r;
unsigned int bits = 0;
ecc_25519_gf_reduce(&r, in);
@@ -71,7 +71,7 @@ int ecc_25519_gf_is_zero(const ecc_int_256 *in) {
return (((bits-1)>>8) & 1);
}
-void ecc_25519_gf_add(ecc_int_256 *out, const ecc_int_256 *in1, const ecc_int_256 *in2) {
+void ecc_25519_gf_add(ecc_int256_t *out, const ecc_int256_t *in1, const ecc_int256_t *in2) {
unsigned int j;
unsigned int u;
int nq = 1 - (in1->p[31]>>4) - (in2->p[31]>>4);
@@ -85,7 +85,7 @@ void ecc_25519_gf_add(ecc_int_256 *out, const ecc_int_256 *in1, const ecc_int_25
}
}
-void ecc_25519_gf_sub(ecc_int_256 *out, const ecc_int_256 *in1, const ecc_int_256 *in2) {
+void ecc_25519_gf_sub(ecc_int256_t *out, const ecc_int256_t *in1, const ecc_int256_t *in2) {
unsigned int j;
unsigned int u;
int nq = 8 - (in1->p[31]>>4) + (in2->p[31]>>4);
@@ -121,7 +121,7 @@ static void reduce(unsigned char a[32]) {
select(a, out1, out2, IS_NEGATIVE(u1));
}
-void ecc_25519_gf_reduce(ecc_int_256 *out, const ecc_int_256 *in) {
+void ecc_25519_gf_reduce(ecc_int256_t *out, const ecc_int256_t *in) {
int i;
for (i = 0; i < 32; i++)
@@ -155,7 +155,7 @@ static void montgomery(unsigned char out[32], const unsigned char a[32], const u
}
-void ecc_25519_gf_mult(ecc_int_256 *out, const ecc_int_256 *in1, const ecc_int_256 *in2) {
+void ecc_25519_gf_mult(ecc_int256_t *out, const ecc_int256_t *in1, const ecc_int256_t *in2) {
/* 2^512 mod q */
static const unsigned char C[32] = {
0x01, 0x0f, 0x9c, 0x44, 0xe3, 0x11, 0x06, 0xa4,
@@ -177,7 +177,7 @@ void ecc_25519_gf_mult(ecc_int_256 *out, const ecc_int_256 *in1, const ecc_int_2
montgomery(out->p, R, C);
}
-void ecc_25519_gf_recip(ecc_int_256 *out, const ecc_int_256 *in) {
+void ecc_25519_gf_recip(ecc_int256_t *out, const ecc_int256_t *in) {
static const unsigned char C[32] = {
0x01
};
@@ -230,7 +230,7 @@ void ecc_25519_gf_recip(ecc_int_256 *out, const ecc_int_256 *in) {
montgomery(out->p, R2, C);
}
-void ecc_25519_gf_sanitize_secret(ecc_int_256 *out, const ecc_int_256 *in) {
+void ecc_25519_gf_sanitize_secret(ecc_int256_t *out, const ecc_int256_t *in) {
int i;
for (i = 0; i < 32; i++)