| diff -r -c -x Makefile -x opensslconf.h openssl-1.0.1m/bn/bn_asm.c openssl/bn/bn_asm.c |
| *** openssl-1.0.1m/bn/bn_asm.c 2015-03-19 06:37:10.000000000 -0700 |
| --- openssl/bn/bn_asm.c 2015-03-30 19:57:20.956149250 -0700 |
| *************** |
| *** 66,71 **** |
| --- 66,75 ---- |
| #include "cryptlib.h" |
| #include "bn_lcl.h" |
| |
| + #ifdef OPENSSL_SMALL_FOOTPRINT |
| + #undef OPENSSL_SMALL_FOOTPRINT |
| + #endif |
| + |
| #if defined(BN_LLONG) || defined(BN_UMULT_HIGH) |
| |
| BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, |
| diff -r -c -x Makefile -x opensslconf.h openssl-1.0.1m/bn/bn_rand.c openssl/bn/bn_rand.c |
| *** openssl-1.0.1m/bn/bn_rand.c 2015-03-19 06:19:00.000000000 -0700 |
| --- openssl/bn/bn_rand.c 2015-04-01 14:03:10.792764003 -0700 |
| *************** |
| *** 137,144 **** |
| --- 137,146 ---- |
| } |
| |
| /* make a random number and set the top and bottom bits */ |
| + #ifndef NO_TIME_BN_RAND |
| time(&tim); |
| RAND_add(&tim, sizeof(tim), 0.0); |
| + #endif /* NO_TIME_BN_RAND */ |
| |
| if (pseudorand) { |
| if (RAND_pseudo_bytes(buf, bytes) == -1) |
| diff -r -c -x Makefile -x opensslconf.h openssl-1.0.1m/ec/ec_cvt.c openssl/ec/ec_cvt.c |
| *** openssl-1.0.1m/ec/ec_cvt.c 2015-03-19 06:37:10.000000000 -0700 |
| --- openssl/ec/ec_cvt.c 2015-03-30 20:09:59.140126497 -0700 |
| *************** |
| *** 78,83 **** |
| --- 78,101 ---- |
| const EC_METHOD *meth; |
| EC_GROUP *ret; |
| |
| + #ifdef FORCE_SIMPLE_EC_METHOD |
| + |
| + meth = EC_GFp_simple_method(); |
| + |
| + ret = EC_GROUP_new(meth); |
| + if (ret == NULL) |
| + return NULL; |
| + |
| + if (!EC_GROUP_set_curve_GFp(ret, p, a, b, ctx)) |
| + { |
| + EC_GROUP_free(ret); |
| + return NULL; |
| + } |
| + |
| + return ret; |
| + |
| + #else /* FORCE_SIMPLE_EC_METHOD */ |
| + |
| #if defined(OPENSSL_BN_ASM_MONT) |
| /* |
| * This might appear controversial, but the fact is that generic |
| *************** |
| *** 142,147 **** |
| --- 160,167 ---- |
| } |
| } |
| |
| + #endif /* FORCE_SIMPLE_EC_METHOD */ |
| + |
| return ret; |
| } |
| |
| diff -r -c -x Makefile -x opensslconf.h openssl-1.0.1m/ec/ec_mult.c openssl/ec/ec_mult.c |
| *** openssl-1.0.1m/ec/ec_mult.c 2015-03-19 06:19:00.000000000 -0700 |
| --- openssl/ec/ec_mult.c 2015-03-30 20:07:05.080131720 -0700 |
| *************** |
| *** 385,390 **** |
| --- 385,392 ---- |
| goto err; |
| } |
| |
| + #ifndef NO_ECPOINT_MULTIPLY_PRECOMP |
| + |
| /* look if we can use precomputed multiples of generator */ |
| |
| pre_comp = |
| *************** |
| *** 415,421 **** |
| ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); |
| goto err; |
| } |
| ! } else { |
| /* can't use precomputation */ |
| pre_comp = NULL; |
| numblocks = 1; |
| --- 417,425 ---- |
| ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); |
| goto err; |
| } |
| ! } else |
| ! #endif /* NO_ECPOINT_MULTIPLY_PRECOMP */ |
| ! { |
| /* can't use precomputation */ |
| pre_comp = NULL; |
| numblocks = 1; |
| *************** |
| *** 465,476 **** |
| --- 469,483 ---- |
| if (numblocks) { |
| /* we go here iff scalar != NULL */ |
| |
| + #ifndef NO_ECPOINT_MULTIPLY_PRECOMP |
| if (pre_comp == NULL) { |
| + #endif /* NO_ECPOINT_MULTIPLY_PRECOMP */ |
| if (num_scalar != 1) { |
| ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR); |
| goto err; |
| } |
| /* we have already generated a wNAF for 'scalar' */ |
| + #ifndef NO_ECPOINT_MULTIPLY_PRECOMP |
| } else { |
| signed char *tmp_wNAF = NULL; |
| size_t tmp_len = 0; |
| *************** |
| *** 569,574 **** |
| --- 576,582 ---- |
| OPENSSL_free(tmp_wNAF); |
| } |
| } |
| + #endif /* NO_ECPOINT_MULTIPLY_PRECOMP */ |
| } |
| |
| /* |
| diff -r -c -x Makefile -x opensslconf.h openssl-1.0.1m/ec/ecp_mont.c openssl/ec/ecp_mont.c |
| *** openssl-1.0.1m/ec/ecp_mont.c 2015-03-19 06:19:00.000000000 -0700 |
| --- openssl/ec/ecp_mont.c 2015-03-30 20:01:40.968141447 -0700 |
| *************** |
| *** 79,87 **** |
| --- 79,93 ---- |
| ec_GFp_mont_group_clear_finish, |
| ec_GFp_mont_group_copy, |
| ec_GFp_mont_group_set_curve, |
| + #ifdef DISABLE_UNUSED_EC_FUNCTS |
| + 0, |
| + 0, |
| + 0, |
| + #else |
| ec_GFp_simple_group_get_curve, |
| ec_GFp_simple_group_get_degree, |
| ec_GFp_simple_group_check_discriminant, |
| + #endif |
| ec_GFp_simple_point_init, |
| ec_GFp_simple_point_finish, |
| ec_GFp_simple_point_clear_finish, |
| *************** |
| *** 97,103 **** |
| --- 103,113 ---- |
| ec_GFp_simple_invert, |
| ec_GFp_simple_is_at_infinity, |
| ec_GFp_simple_is_on_curve, |
| + #ifdef DISABLE_UNUSED_EC_FUNCTS |
| + 0, |
| + #else |
| ec_GFp_simple_cmp, |
| + #endif |
| ec_GFp_simple_make_affine, |
| ec_GFp_simple_points_make_affine, |
| 0 /* mul */ , |
| diff -r -c -x Makefile -x opensslconf.h openssl-1.0.1m/ec/ecp_smpl.c openssl/ec/ecp_smpl.c |
| *** openssl-1.0.1m/ec/ecp_smpl.c 2015-03-19 06:19:00.000000000 -0700 |
| --- openssl/ec/ecp_smpl.c 2015-03-30 20:24:36.384100170 -0700 |
| *************** |
| *** 82,90 **** |
| --- 82,96 ---- |
| ec_GFp_simple_group_clear_finish, |
| ec_GFp_simple_group_copy, |
| ec_GFp_simple_group_set_curve, |
| + #ifdef DISABLE_UNUSED_EC_FUNCTS |
| + 0, |
| + 0, |
| + 0, |
| + #else /* DISABLE_UNUSED_EC_FUNCTS */ |
| ec_GFp_simple_group_get_curve, |
| ec_GFp_simple_group_get_degree, |
| ec_GFp_simple_group_check_discriminant, |
| + #endif /* DISABLE_UNUSED_EC_FUNCTS */ |
| ec_GFp_simple_point_init, |
| ec_GFp_simple_point_finish, |
| ec_GFp_simple_point_clear_finish, |
| *************** |
| *** 100,106 **** |
| --- 106,116 ---- |
| ec_GFp_simple_invert, |
| ec_GFp_simple_is_at_infinity, |
| ec_GFp_simple_is_on_curve, |
| + #ifdef DISABLE_UNUSED_EC_FUNCTS |
| + 0, |
| + #else /* DISABLE_UNUSED_EC_FUNCTS */ |
| ec_GFp_simple_cmp, |
| + #endif /* DISABLE_UNUSED_EC_FUNCTS */ |
| ec_GFp_simple_make_affine, |
| ec_GFp_simple_points_make_affine, |
| 0 /* mul */ , |
| *************** |
| *** 206,223 **** |
| /* group->a */ |
| if (!BN_nnmod(tmp_a, a, p, ctx)) |
| goto err; |
| if (group->meth->field_encode) { |
| if (!group->meth->field_encode(group, &group->a, tmp_a, ctx)) |
| goto err; |
| ! } else if (!BN_copy(&group->a, tmp_a)) |
| ! goto err; |
| |
| /* group->b */ |
| if (!BN_nnmod(&group->b, b, p, ctx)) |
| goto err; |
| if (group->meth->field_encode) |
| if (!group->meth->field_encode(group, &group->b, &group->b, ctx)) |
| goto err; |
| |
| /* group->a_is_minus3 */ |
| if (!BN_add_word(tmp_a, 3)) |
| --- 216,238 ---- |
| /* group->a */ |
| if (!BN_nnmod(tmp_a, a, p, ctx)) |
| goto err; |
| + #ifndef SIMPLE_EC_NO_FIELD_ENCODE_DECODE |
| if (group->meth->field_encode) { |
| if (!group->meth->field_encode(group, &group->a, tmp_a, ctx)) |
| goto err; |
| ! } else |
| ! #endif /* SIMPLE_EC_NO_FIELD_ENCODE_DECODE */ |
| ! if (!BN_copy(&group->a, tmp_a)) |
| ! goto err; |
| |
| /* group->b */ |
| if (!BN_nnmod(&group->b, b, p, ctx)) |
| goto err; |
| + #ifndef SIMPLE_EC_NO_FIELD_ENCODE_DECODE |
| if (group->meth->field_encode) |
| if (!group->meth->field_encode(group, &group->b, &group->b, ctx)) |
| goto err; |
| + #endif /* SIMPLE_EC_NO_FIELD_ENCODE_DECODE */ |
| |
| /* group->a_is_minus3 */ |
| if (!BN_add_word(tmp_a, 3)) |
| *************** |
| *** 245,250 **** |
| --- 260,266 ---- |
| } |
| |
| if (a != NULL || b != NULL) { |
| + #ifndef SIMPLE_EC_NO_FIELD_ENCODE_DECODE |
| if (group->meth->field_decode) { |
| if (ctx == NULL) { |
| ctx = new_ctx = BN_CTX_new(); |
| *************** |
| *** 259,265 **** |
| if (!group->meth->field_decode(group, b, &group->b, ctx)) |
| goto err; |
| } |
| ! } else { |
| if (a != NULL) { |
| if (!BN_copy(a, &group->a)) |
| goto err; |
| --- 275,283 ---- |
| if (!group->meth->field_decode(group, b, &group->b, ctx)) |
| goto err; |
| } |
| ! } else |
| ! #endif /* SIMPLE_EC_NO_FIELD_ENCODE_DECODE */ |
| ! { |
| if (a != NULL) { |
| if (!BN_copy(a, &group->a)) |
| goto err; |
| *************** |
| *** 308,319 **** |
| if (order == NULL) |
| goto err; |
| |
| if (group->meth->field_decode) { |
| if (!group->meth->field_decode(group, a, &group->a, ctx)) |
| goto err; |
| if (!group->meth->field_decode(group, b, &group->b, ctx)) |
| goto err; |
| ! } else { |
| if (!BN_copy(a, &group->a)) |
| goto err; |
| if (!BN_copy(b, &group->b)) |
| --- 326,340 ---- |
| if (order == NULL) |
| goto err; |
| |
| + #ifndef SIMPLE_EC_NO_FIELD_ENCODE_DECODE |
| if (group->meth->field_decode) { |
| if (!group->meth->field_decode(group, a, &group->a, ctx)) |
| goto err; |
| if (!group->meth->field_decode(group, b, &group->b, ctx)) |
| goto err; |
| ! } else |
| ! #endif /* SIMPLE_EC_NO_FIELD_ENCODE_DECODE */ |
| ! { |
| if (!BN_copy(a, &group->a)) |
| goto err; |
| if (!BN_copy(b, &group->b)) |
| *************** |
| *** 423,441 **** |
| --- 444,466 ---- |
| if (x != NULL) { |
| if (!BN_nnmod(&point->X, x, &group->field, ctx)) |
| goto err; |
| + #ifndef SIMPLE_EC_NO_FIELD_ENCODE_DECODE |
| if (group->meth->field_encode) { |
| if (!group->meth->field_encode(group, &point->X, &point->X, ctx)) |
| goto err; |
| } |
| + #endif /* SIMPLE_EC_NO_FIELD_ENCODE_DECODE */ |
| } |
| |
| if (y != NULL) { |
| if (!BN_nnmod(&point->Y, y, &group->field, ctx)) |
| goto err; |
| + #ifndef SIMPLE_EC_NO_FIELD_ENCODE_DECODE |
| if (group->meth->field_encode) { |
| if (!group->meth->field_encode(group, &point->Y, &point->Y, ctx)) |
| goto err; |
| } |
| + #endif /* SIMPLE_EC_NO_FIELD_ENCODE_DECODE */ |
| } |
| |
| if (z != NULL) { |
| *************** |
| *** 444,449 **** |
| --- 469,475 ---- |
| if (!BN_nnmod(&point->Z, z, &group->field, ctx)) |
| goto err; |
| Z_is_one = BN_is_one(&point->Z); |
| + #ifndef SIMPLE_EC_NO_FIELD_ENCODE_DECODE |
| if (group->meth->field_encode) { |
| if (Z_is_one && (group->meth->field_set_to_one != 0)) { |
| if (!group->meth->field_set_to_one(group, &point->Z, ctx)) |
| *************** |
| *** 454,459 **** |
| --- 480,486 ---- |
| goto err; |
| } |
| } |
| + #endif /* SIMPLE_EC_NO_FIELD_ENCODE_DECODE */ |
| point->Z_is_one = Z_is_one; |
| } |
| |
| *************** |
| *** 473,478 **** |
| --- 500,506 ---- |
| BN_CTX *new_ctx = NULL; |
| int ret = 0; |
| |
| + #ifndef SIMPLE_EC_NO_FIELD_ENCODE_DECODE |
| if (group->meth->field_decode != 0) { |
| if (ctx == NULL) { |
| ctx = new_ctx = BN_CTX_new(); |
| *************** |
| *** 492,498 **** |
| if (!group->meth->field_decode(group, z, &point->Z, ctx)) |
| goto err; |
| } |
| ! } else { |
| if (x != NULL) { |
| if (!BN_copy(x, &point->X)) |
| goto err; |
| --- 520,528 ---- |
| if (!group->meth->field_decode(group, z, &point->Z, ctx)) |
| goto err; |
| } |
| ! } else |
| ! #endif /* SIMPLE_EC_NO_FIELD_ENCODE_DECODE */ |
| ! { |
| if (x != NULL) { |
| if (!BN_copy(x, &point->X)) |
| goto err; |
| *************** |
| *** 565,579 **** |
| |
| /* transform (X, Y, Z) into (x, y) := (X/Z^2, Y/Z^3) */ |
| |
| if (group->meth->field_decode) { |
| if (!group->meth->field_decode(group, Z, &point->Z, ctx)) |
| goto err; |
| Z_ = Z; |
| ! } else { |
| Z_ = &point->Z; |
| } |
| |
| if (BN_is_one(Z_)) { |
| if (group->meth->field_decode) { |
| if (x != NULL) { |
| if (!group->meth->field_decode(group, x, &point->X, ctx)) |
| --- 595,613 ---- |
| |
| /* transform (X, Y, Z) into (x, y) := (X/Z^2, Y/Z^3) */ |
| |
| + #ifndef SIMPLE_EC_NO_FIELD_ENCODE_DECODE |
| if (group->meth->field_decode) { |
| if (!group->meth->field_decode(group, Z, &point->Z, ctx)) |
| goto err; |
| Z_ = Z; |
| ! } else |
| ! #endif /* SIMPLE_EC_NO_FIELD_ENCODE_DECODE */ |
| ! { |
| Z_ = &point->Z; |
| } |
| |
| if (BN_is_one(Z_)) { |
| + #ifndef SIMPLE_EC_NO_FIELD_ENCODE_DECODE |
| if (group->meth->field_decode) { |
| if (x != NULL) { |
| if (!group->meth->field_decode(group, x, &point->X, ctx)) |
| *************** |
| *** 583,589 **** |
| if (!group->meth->field_decode(group, y, &point->Y, ctx)) |
| goto err; |
| } |
| ! } else { |
| if (x != NULL) { |
| if (!BN_copy(x, &point->X)) |
| goto err; |
| --- 617,625 ---- |
| if (!group->meth->field_decode(group, y, &point->Y, ctx)) |
| goto err; |
| } |
| ! } else |
| ! #endif /* SIMPLE_EC_NO_FIELD_ENCODE_DECODE */ |
| ! { |
| if (x != NULL) { |
| if (!BN_copy(x, &point->X)) |
| goto err; |
| *************** |
| *** 600,610 **** |
| goto err; |
| } |
| |
| if (group->meth->field_encode == 0) { |
| /* field_sqr works on standard representation */ |
| if (!group->meth->field_sqr(group, Z_2, Z_1, ctx)) |
| goto err; |
| ! } else { |
| if (!BN_mod_sqr(Z_2, Z_1, &group->field, ctx)) |
| goto err; |
| } |
| --- 636,649 ---- |
| goto err; |
| } |
| |
| + #ifndef SIMPLE_EC_NO_FIELD_ENCODE_DECODE |
| if (group->meth->field_encode == 0) { |
| /* field_sqr works on standard representation */ |
| if (!group->meth->field_sqr(group, Z_2, Z_1, ctx)) |
| goto err; |
| ! } else |
| ! #endif /* SIMPLE_EC_NO_FIELD_ENCODE_DECODE */ |
| ! { |
| if (!BN_mod_sqr(Z_2, Z_1, &group->field, ctx)) |
| goto err; |
| } |
| *************** |
| *** 619,631 **** |
| } |
| |
| if (y != NULL) { |
| if (group->meth->field_encode == 0) { |
| /* |
| * field_mul works on standard representation |
| */ |
| if (!group->meth->field_mul(group, Z_3, Z_2, Z_1, ctx)) |
| goto err; |
| ! } else { |
| if (!BN_mod_mul(Z_3, Z_2, Z_1, &group->field, ctx)) |
| goto err; |
| } |
| --- 658,673 ---- |
| } |
| |
| if (y != NULL) { |
| + #ifndef SIMPLE_EC_NO_FIELD_ENCODE_DECODE |
| if (group->meth->field_encode == 0) { |
| /* |
| * field_mul works on standard representation |
| */ |
| if (!group->meth->field_mul(group, Z_3, Z_2, Z_1, ctx)) |
| goto err; |
| ! } else |
| ! #endif /* SIMPLE_EC_NO_FIELD_ENCODE_DECODE */ |
| ! { |
| if (!BN_mod_mul(Z_3, Z_2, Z_1, &group->field, ctx)) |
| goto err; |
| } |
| *************** |
| *** 1249,1254 **** |
| --- 1291,1309 ---- |
| int ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, |
| EC_POINT *points[], BN_CTX *ctx) |
| { |
| + #ifdef SIMPLIFIED_MAKE_AFFINE |
| + int ret = 1; |
| + size_t i; |
| + |
| + for (i = 0; i < num; i++) |
| + { |
| + ret = ec_GFp_simple_make_affine(group, points[i], ctx); |
| + if (!ret) |
| + break; |
| + } |
| + |
| + return ret; |
| + #else /* SIMPLIFIED_MAKE_AFFINE */ |
| BN_CTX *new_ctx = NULL; |
| BIGNUM *tmp, *tmp_Z; |
| BIGNUM **prod_Z = NULL; |
| *************** |
| *** 1317,1322 **** |
| --- 1372,1378 ---- |
| ECerr(EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE, ERR_R_BN_LIB); |
| goto err; |
| } |
| + #ifndef SIMPLE_EC_NO_FIELD_ENCODE_DECODE |
| if (group->meth->field_encode != 0) { |
| /* |
| * In the Montgomery case, we just turned R*H (representing H) into |
| *************** |
| *** 1328,1333 **** |
| --- 1384,1390 ---- |
| if (!group->meth->field_encode(group, tmp, tmp, ctx)) |
| goto err; |
| } |
| + #endif /* SIMPLE_EC_NO_FIELD_ENCODE_DECODE */ |
| |
| for (i = num - 1; i > 0; --i) { |
| /* |
| *************** |
| *** 1403,1408 **** |
| --- 1460,1466 ---- |
| OPENSSL_free(prod_Z); |
| } |
| return ret; |
| + #endif /* !SIMPLIFIED_MAKE_AFFINE */ |
| } |
| |
| int ec_GFp_simple_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, |
| diff -r -c -x Makefile -x opensslconf.h openssl-1.0.1m/jpake/jpake.c openssl/jpake/jpake.c |
| *** openssl-1.0.1m/jpake/jpake.c 2015-03-19 06:37:10.000000000 -0700 |
| --- openssl/jpake/jpake.c 2015-03-31 16:16:20.828385916 -0700 |
| *************** |
| *** 3,9 **** |
| #include <openssl/crypto.h> |
| #include <openssl/sha.h> |
| #include <openssl/err.h> |
| ! #include <memory.h> |
| |
| /* |
| * In the definition, (xa, xb, xc, xd) are Alice's (x1, x2, x3, x4) or |
| --- 3,9 ---- |
| #include <openssl/crypto.h> |
| #include <openssl/sha.h> |
| #include <openssl/err.h> |
| ! #include <string.h> |
| |
| /* |
| * In the definition, (xa, xb, xc, xd) are Alice's (x1, x2, x3, x4) or |
| diff -r -c -x Makefile -x opensslconf.h openssl-1.0.1m/rand/rand.h openssl/rand/rand.h |
| *** openssl-1.0.1m/rand/rand.h 2015-03-19 06:19:00.000000000 -0700 |
| --- openssl/rand/rand.h 2015-03-30 19:48:30.056165183 -0700 |
| *************** |
| *** 143,148 **** |
| --- 143,149 ---- |
| # define RAND_R_ERROR_INSTANTIATING_DRBG 103 |
| # define RAND_R_NO_FIPS_RANDOM_METHOD_SET 101 |
| # define RAND_R_PRNG_NOT_SEEDED 100 |
| + # define RAND_R_PRNG_ERROR 108 |
| |
| #ifdef __cplusplus |
| } |