diff options
author | Bodo Möller <bodo@openssl.org> | 2002-11-18 14:33:39 +0000 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 2002-11-18 14:33:39 +0000 |
commit | 46633554961a5950410ef5690093b56f1f06e752 (patch) | |
tree | 23bac08f10b30941e4e28887099eb30909bb563c /crypto/ec | |
parent | 9dc610495cb70d9e9566a188853860c542221d86 (diff) |
use consistent order of function definitions
Diffstat (limited to 'crypto/ec')
-rw-r--r-- | crypto/ec/ecp_mont.c | 120 | ||||
-rw-r--r-- | crypto/ec/ecp_nist.c | 39 |
2 files changed, 79 insertions, 80 deletions
diff --git a/crypto/ec/ecp_mont.c b/crypto/ec/ecp_mont.c index 900228d8af..36f8236864 100644 --- a/crypto/ec/ecp_mont.c +++ b/crypto/ec/ecp_mont.c @@ -122,66 +122,6 @@ int ec_GFp_mont_group_init(EC_GROUP *group) } -int ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) - { - BN_CTX *new_ctx = NULL; - BN_MONT_CTX *mont = NULL; - BIGNUM *one = NULL; - int ret = 0; - - if (group->field_data1 != NULL) - { - BN_MONT_CTX_free(group->field_data1); - group->field_data1 = NULL; - } - if (group->field_data2 != NULL) - { - BN_free(group->field_data2); - group->field_data2 = NULL; - } - - if (ctx == NULL) - { - ctx = new_ctx = BN_CTX_new(); - if (ctx == NULL) - return 0; - } - - mont = BN_MONT_CTX_new(); - if (mont == NULL) goto err; - if (!BN_MONT_CTX_set(mont, p, ctx)) - { - ECerr(EC_F_GFP_MONT_GROUP_SET_CURVE, ERR_R_BN_LIB); - goto err; - } - one = BN_new(); - if (one == NULL) goto err; - if (!BN_to_montgomery(one, BN_value_one(), mont, ctx)) goto err; - - group->field_data1 = mont; - mont = NULL; - group->field_data2 = one; - one = NULL; - - ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); - - if (!ret) - { - BN_MONT_CTX_free(group->field_data1); - group->field_data1 = NULL; - BN_free(group->field_data2); - group->field_data2 = NULL; - } - - err: - if (new_ctx != NULL) - BN_CTX_free(new_ctx); - if (mont != NULL) - BN_MONT_CTX_free(mont); - return ret; - } - - void ec_GFp_mont_group_finish(EC_GROUP *group) { if (group->field_data1 != NULL) @@ -253,6 +193,66 @@ int ec_GFp_mont_group_copy(EC_GROUP *dest, const EC_GROUP *src) } +int ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) + { + BN_CTX *new_ctx = NULL; + BN_MONT_CTX *mont = NULL; + BIGNUM *one = NULL; + int ret = 0; + + if (group->field_data1 != NULL) + { + BN_MONT_CTX_free(group->field_data1); + group->field_data1 = NULL; + } + if (group->field_data2 != NULL) + { + BN_free(group->field_data2); + group->field_data2 = NULL; + } + + if (ctx == NULL) + { + ctx = new_ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + } + + mont = BN_MONT_CTX_new(); + if (mont == NULL) goto err; + if (!BN_MONT_CTX_set(mont, p, ctx)) + { + ECerr(EC_F_GFP_MONT_GROUP_SET_CURVE, ERR_R_BN_LIB); + goto err; + } + one = BN_new(); + if (one == NULL) goto err; + if (!BN_to_montgomery(one, BN_value_one(), mont, ctx)) goto err; + + group->field_data1 = mont; + mont = NULL; + group->field_data2 = one; + one = NULL; + + ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); + + if (!ret) + { + BN_MONT_CTX_free(group->field_data1); + group->field_data1 = NULL; + BN_free(group->field_data2); + group->field_data2 = NULL; + } + + err: + if (new_ctx != NULL) + BN_CTX_free(new_ctx); + if (mont != NULL) + BN_MONT_CTX_free(mont); + return ret; + } + + int ec_GFp_mont_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { if (group->field_data1 == NULL) diff --git a/crypto/ec/ecp_nist.c b/crypto/ec/ecp_nist.c index 0b39bb6166..a6634f9bff 100644 --- a/crypto/ec/ecp_nist.c +++ b/crypto/ec/ecp_nist.c @@ -128,7 +128,6 @@ void ec_GFp_nist_group_finish(EC_GROUP *group) BN_free(&group->b); } - void ec_GFp_nist_group_clear_finish(EC_GROUP *group) { BN_clear_free(&group->field); @@ -136,6 +135,25 @@ void ec_GFp_nist_group_clear_finish(EC_GROUP *group) BN_clear_free(&group->b); } +int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src) + { + if (dest == NULL || src == NULL) + return 0; + + if (!BN_copy(&dest->field, &src->field)) + return 0; + if (!BN_copy(&dest->a, &src->a)) + return 0; + if (!BN_copy(&dest->b, &src->b)) + return 0; + + dest->curve_name = src->curve_name; + + dest->a_is_minus3 = src->a_is_minus3; + + return 1; + } + int ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) @@ -211,25 +229,6 @@ int ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p, return ret; } -int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src) - { - if (dest == NULL || src == NULL) - return 0; - - if (!BN_copy(&dest->field, &src->field)) - return 0; - if (!BN_copy(&dest->a, &src->a)) - return 0; - if (!BN_copy(&dest->b, &src->b)) - return 0; - - dest->curve_name = src->curve_name; - - dest->a_is_minus3 = src->a_is_minus3; - - return 1; - } - int ec_GFp_nist_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { |