aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/ec/ecp_nistz256.c
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2015-01-21 16:02:33 +0100
committerMatt Caswell <matt@openssl.org>2015-01-22 09:27:52 +0000
commite1e7dc5085a03dfd0f0b5dd9a3b99a7e9fc238ce (patch)
treee05f3323e682e9b6c683e9f31efa88034865e22f /crypto/ec/ecp_nistz256.c
parentcc4cd8213ee3e9eb0c7925d3076647b63febca10 (diff)
downloadopenssl-e1e7dc5085a03dfd0f0b5dd9a3b99a7e9fc238ce.tar.gz
ec/ecp_nistz256.c: harmonize with latest indent script.
Conflicts: crypto/ec/ecp_nistz256.c Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'crypto/ec/ecp_nistz256.c')
-rw-r--r--crypto/ec/ecp_nistz256.c119
1 files changed, 59 insertions, 60 deletions
diff --git a/crypto/ec/ecp_nistz256.c b/crypto/ec/ecp_nistz256.c
index bf3fcc6b59..d8c0dae1ae 100644
--- a/crypto/ec/ecp_nistz256.c
+++ b/crypto/ec/ecp_nistz256.c
@@ -36,21 +36,21 @@
#include "ec_lcl.h"
#if BN_BITS2 != 64
-# define TOBN(hi,lo) lo,hi
+# define TOBN(hi,lo) lo,hi
#else
-# define TOBN(hi,lo) ((BN_ULONG)hi<<32|lo)
+# define TOBN(hi,lo) ((BN_ULONG)hi<<32|lo)
#endif
#if defined(__GNUC__)
-# define ALIGN32 __attribute((aligned(32)))
+# define ALIGN32 __attribute((aligned(32)))
#elif defined(_MSC_VER)
-# define ALIGN32 __declspec(align(32))
+# define ALIGN32 __declspec(align(32))
#else
# define ALIGN32
#endif
-#define ALIGNPTR(p,N) ((unsigned char *)p+N-(size_t)p%N)
-#define P256_LIMBS (256/BN_BITS2)
+#define ALIGNPTR(p,N) ((unsigned char *)p+N-(size_t)p%N)
+#define P256_LIMBS (256/BN_BITS2)
typedef unsigned short u16;
@@ -127,7 +127,7 @@ static const BN_ULONG ONE[P256_LIMBS] = {
static void *ecp_nistz256_pre_comp_dup(void *);
static void ecp_nistz256_pre_comp_free(void *);
static void ecp_nistz256_pre_comp_clear_free(void *);
-static EC_PRE_COMP *ecp_nistz256_pre_comp_new(const EC_GROUP * group);
+static EC_PRE_COMP *ecp_nistz256_pre_comp_new(const EC_GROUP *group);
/* Precomputed tables for the default generator */
#include "ecp_nistz256_table.c"
@@ -221,15 +221,15 @@ static BN_ULONG is_one(const BN_ULONG a[P256_LIMBS])
}
#ifndef ECP_NISTZ256_REFERENCE_IMPLEMENTATION
-void ecp_nistz256_point_double(P256_POINT * r, const P256_POINT * a);
-void ecp_nistz256_point_add(P256_POINT * r,
- const P256_POINT * a, const P256_POINT * b);
-void ecp_nistz256_point_add_affine(P256_POINT * r,
- const P256_POINT * a,
- const P256_POINT_AFFINE * b);
+void ecp_nistz256_point_double(P256_POINT *r, const P256_POINT *a);
+void ecp_nistz256_point_add(P256_POINT *r,
+ const P256_POINT *a, const P256_POINT *b);
+void ecp_nistz256_point_add_affine(P256_POINT *r,
+ const P256_POINT *a,
+ const P256_POINT_AFFINE *b);
#else
/* Point double: r = 2*a */
-static void ecp_nistz256_point_double(P256_POINT * r, const P256_POINT * a)
+static void ecp_nistz256_point_double(P256_POINT *r, const P256_POINT *a)
{
BN_ULONG S[P256_LIMBS];
BN_ULONG M[P256_LIMBS];
@@ -303,17 +303,17 @@ static void ecp_nistz256_point_add(P256_POINT * r,
/* We encode infinity as (0,0), which is not on the curve,
* so it is OK. */
- in1infty = in1_x[0] | in1_x[1] | in1_x[2] | in1_x[3] |
- in1_y[0] | in1_y[1] | in1_y[2] | in1_y[3];
+ in1infty = (in1_x[0] | in1_x[1] | in1_x[2] | in1_x[3] |
+ in1_y[0] | in1_y[1] | in1_y[2] | in1_y[3]);
if (P256_LIMBS == 8)
- in1infty |= in1_x[4] | in1_x[5] | in1_x[6] | in1_x[7] |
- in1_y[4] | in1_y[5] | in1_y[6] | in1_y[7];
+ in1infty |= (in1_x[4] | in1_x[5] | in1_x[6] | in1_x[7] |
+ in1_y[4] | in1_y[5] | in1_y[6] | in1_y[7]);
- in2infty = in2_x[0] | in2_x[1] | in2_x[2] | in2_x[3] |
- in2_y[0] | in2_y[1] | in2_y[2] | in2_y[3];
+ in2infty = (in2_x[0] | in2_x[1] | in2_x[2] | in2_x[3] |
+ in2_y[0] | in2_y[1] | in2_y[2] | in2_y[3]);
if (P256_LIMBS == 8)
- in2infty |= in2_x[4] | in2_x[5] | in2_x[6] | in2_x[7] |
- in2_y[4] | in2_y[5] | in2_y[6] | in2_y[7];
+ in2infty |= (in2_x[4] | in2_x[5] | in2_x[6] | in2_x[7] |
+ in2_y[4] | in2_y[5] | in2_y[6] | in2_y[7]);
in1infty = is_zero(in1infty);
in2infty = is_zero(in2infty);
@@ -376,9 +376,9 @@ static void ecp_nistz256_point_add(P256_POINT * r,
}
/* Point addition when b is known to be affine: r = a+b */
-static void ecp_nistz256_point_add_affine(P256_POINT * r,
- const P256_POINT * a,
- const P256_POINT_AFFINE * b)
+static void ecp_nistz256_point_add_affine(P256_POINT *r,
+ const P256_POINT *a,
+ const P256_POINT_AFFINE *b)
{
BN_ULONG U2[P256_LIMBS], S2[P256_LIMBS];
BN_ULONG Z1sqr[P256_LIMBS];
@@ -402,17 +402,17 @@ static void ecp_nistz256_point_add_affine(P256_POINT * r,
/* In affine representation we encode infty as (0,0),
* which is not on the curve, so it is OK */
- in1infty = in1_x[0] | in1_x[1] | in1_x[2] | in1_x[3] |
- in1_y[0] | in1_y[1] | in1_y[2] | in1_y[3];
+ in1infty = (in1_x[0] | in1_x[1] | in1_x[2] | in1_x[3] |
+ in1_y[0] | in1_y[1] | in1_y[2] | in1_y[3]);
if (P256_LIMBS == 8)
- in1infty |= in1_x[4] | in1_x[5] | in1_x[6] | in1_x[7] |
- in1_y[4] | in1_y[5] | in1_y[6] | in1_y[7];
+ in1infty |= (in1_x[4] | in1_x[5] | in1_x[6] | in1_x[7] |
+ in1_y[4] | in1_y[5] | in1_y[6] | in1_y[7]);
- in2infty = in2_x[0] | in2_x[1] | in2_x[2] | in2_x[3] |
- in2_y[0] | in2_y[1] | in2_y[2] | in2_y[3];
+ in2infty = (in2_x[0] | in2_x[1] | in2_x[2] | in2_x[3] |
+ in2_y[0] | in2_y[1] | in2_y[2] | in2_y[3]);
if (P256_LIMBS == 8)
- in2infty |= in2_x[4] | in2_x[5] | in2_x[6] | in2_x[7] |
- in2_y[4] | in2_y[5] | in2_y[6] | in2_y[7];
+ in2infty |= (in2_x[4] | in2_x[5] | in2_x[6] | in2_x[7] |
+ in2_y[4] | in2_y[5] | in2_y[6] | in2_y[7]);
in1infty = is_zero(in1infty);
in2infty = is_zero(in2infty);
@@ -548,11 +548,11 @@ static int ecp_nistz256_bignum_to_field_elem(BN_ULONG out[P256_LIMBS],
}
/* r = sum(scalar[i]*point[i]) */
-static void ecp_nistz256_windowed_mul(const EC_GROUP * group,
- P256_POINT * r,
- const BIGNUM ** scalar,
- const EC_POINT ** point,
- int num, BN_CTX * ctx)
+static void ecp_nistz256_windowed_mul(const EC_GROUP *group,
+ P256_POINT *r,
+ const BIGNUM **scalar,
+ const EC_POINT **point,
+ int num, BN_CTX *ctx)
{
int i, j;
unsigned int index;
@@ -688,7 +688,7 @@ static void ecp_nistz256_windowed_mul(const EC_GROUP * group,
ecp_nistz256_point_add(r, r, &h);
}
-err:
+ err:
if (table_storage)
OPENSSL_free(table_storage);
if (p_str)
@@ -710,7 +710,7 @@ const static BN_ULONG def_yG[P256_LIMBS] = {
/* ecp_nistz256_is_affine_G returns one if |generator| is the standard,
* P-256 generator. */
-static int ecp_nistz256_is_affine_G(const EC_POINT * generator)
+static int ecp_nistz256_is_affine_G(const EC_POINT *generator)
{
return (generator->X.top == P256_LIMBS) &&
(generator->Y.top == P256_LIMBS) &&
@@ -719,7 +719,7 @@ static int ecp_nistz256_is_affine_G(const EC_POINT * generator)
is_equal(generator->Y.d, def_yG) && is_one(generator->Z.d);
}
-static int ecp_nistz256_mult_precompute(EC_GROUP * group, BN_CTX * ctx)
+static int ecp_nistz256_mult_precompute(EC_GROUP *group, BN_CTX *ctx)
{
/* We precompute a table for a Booth encoded exponent (wNAF) based
* computation. Each table holds 64 values for safe access, with an
@@ -827,7 +827,7 @@ static int ecp_nistz256_mult_precompute(EC_GROUP * group, BN_CTX * ctx)
ret = 1;
-err:
+ err:
if (ctx != NULL)
BN_CTX_end(ctx);
if (pre_comp)
@@ -889,10 +889,9 @@ static void booth_recode_w7(unsigned char *sign,
/* ecp_nistz256_avx2_mul_g performs multiplication by G, using only the
* precomputed table. It does 4 affine point additions in parallel,
* significantly speeding up point multiplication for a fixed value. */
-static void ecp_nistz256_avx2_mul_g(P256_POINT * r,
+static void ecp_nistz256_avx2_mul_g(P256_POINT *r,
unsigned char p_str[33],
- const
- P256_POINT_AFFINE(*preComputedTable)[64])
+ const P256_POINT_AFFINE(*preComputedTable)[64])
{
const unsigned int window_size = 7;
const unsigned int mask = (1 << (window_size + 1)) - 1;
@@ -1042,9 +1041,9 @@ static void ecp_nistz256_avx2_mul_g(P256_POINT * r,
# endif
#endif
-static int ecp_nistz256_set_from_affine(EC_POINT * out, const EC_GROUP * group,
- const P256_POINT_AFFINE * in,
- BN_CTX * ctx)
+static int ecp_nistz256_set_from_affine(EC_POINT *out, const EC_GROUP *group,
+ const P256_POINT_AFFINE *in,
+ BN_CTX *ctx)
{
BIGNUM x, y;
BN_ULONG d_x[P256_LIMBS], d_y[P256_LIMBS];
@@ -1068,12 +1067,12 @@ static int ecp_nistz256_set_from_affine(EC_POINT * out, const EC_GROUP * group,
}
/* r = scalar*G + sum(scalars[i]*points[i]) */
-static int ecp_nistz256_points_mul(const EC_GROUP * group,
- EC_POINT * r,
- const BIGNUM * scalar,
+static int ecp_nistz256_points_mul(const EC_GROUP *group,
+ EC_POINT *r,
+ const BIGNUM *scalar,
size_t num,
- const EC_POINT * points[],
- const BIGNUM * scalars[], BN_CTX * ctx)
+ const EC_POINT *points[],
+ const BIGNUM *scalars[], BN_CTX *ctx)
{
int i = 0, ret = 0, no_precomp_for_generator = 0, p_is_infinity = 0;
size_t j;
@@ -1281,13 +1280,13 @@ static int ecp_nistz256_points_mul(const EC_GROUP * group,
ret = 1;
-err:
+ err:
return ret;
}
-static int ecp_nistz256_get_affine(const EC_GROUP * group,
- const EC_POINT * point,
- BIGNUM * x, BIGNUM * y, BN_CTX * ctx)
+static int ecp_nistz256_get_affine(const EC_GROUP *group,
+ const EC_POINT *point,
+ BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
{
BN_ULONG z_inv2[P256_LIMBS];
BN_ULONG z_inv3[P256_LIMBS];
@@ -1330,14 +1329,14 @@ static int ecp_nistz256_get_affine(const EC_GROUP * group,
return 1;
}
-static EC_PRE_COMP *ecp_nistz256_pre_comp_new(const EC_GROUP * group)
+static EC_PRE_COMP *ecp_nistz256_pre_comp_new(const EC_GROUP *group)
{
EC_PRE_COMP *ret = NULL;
if (!group)
return NULL;
- ret = (EC_PRE_COMP *) OPENSSL_malloc(sizeof(EC_PRE_COMP));
+ ret = (EC_PRE_COMP *)OPENSSL_malloc(sizeof(EC_PRE_COMP));
if (!ret) {
ECerr(EC_F_ECP_NISTZ256_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);
@@ -1401,7 +1400,7 @@ static void ecp_nistz256_pre_comp_clear_free(void *pre_)
OPENSSL_free(pre);
}
-static int ecp_nistz256_window_have_precompute_mult(const EC_GROUP * group)
+static int ecp_nistz256_window_have_precompute_mult(const EC_GROUP *group)
{
/* There is a hard-coded table for the default generator. */
const EC_POINT *generator = EC_GROUP_get0_generator(group);