aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/ec/eck_prn.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2016-01-31 16:34:07 +0000
committerDr. Stephen Henson <steve@openssl.org>2016-01-31 22:18:30 +0000
commitbe2e334fce734e726a4085701bc3cbbaabf9d893 (patch)
tree1abe68a660b992e194fdb26dd42aed6860d3e87a /crypto/ec/eck_prn.c
parent81e03785f718f98861a2a84b7b5d798b00df1670 (diff)
downloadopenssl-be2e334fce734e726a4085701bc3cbbaabf9d893.tar.gz
Add EC_GROUP_order_bits, EC_GROUP_get0_order and EC_GROUP_get0_cofactor
New functions to return internal pointer for order and cofactor. This avoids the need to allocate a new BIGNUM which to copy the value to. Simplify code to use new functions. Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/ec/eck_prn.c')
-rw-r--r--crypto/ec/eck_prn.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/crypto/ec/eck_prn.c b/crypto/ec/eck_prn.c
index 6449bc441c..fa4cf6aefc 100644
--- a/crypto/ec/eck_prn.c
+++ b/crypto/ec/eck_prn.c
@@ -147,8 +147,8 @@ int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off)
int ret = 0, reason = ERR_R_BIO_LIB;
BN_CTX *ctx = NULL;
const EC_POINT *point = NULL;
- BIGNUM *p = NULL, *a = NULL, *b = NULL, *gen = NULL,
- *order = NULL, *cofactor = NULL;
+ BIGNUM *p = NULL, *a = NULL, *b = NULL, *gen = NULL;
+ const BIGNUM *order = NULL, *cofactor = NULL;
const unsigned char *seed;
size_t seed_len = 0;
@@ -199,8 +199,7 @@ int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off)
is_char_two = 1;
if ((p = BN_new()) == NULL || (a = BN_new()) == NULL ||
- (b = BN_new()) == NULL || (order = BN_new()) == NULL ||
- (cofactor = BN_new()) == NULL) {
+ (b = BN_new()) == NULL) {
reason = ERR_R_MALLOC_FAILURE;
goto err;
}
@@ -223,8 +222,9 @@ int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off)
reason = ERR_R_EC_LIB;
goto err;
}
- if (!EC_GROUP_get_order(x, order, NULL) ||
- !EC_GROUP_get_cofactor(x, cofactor, NULL)) {
+ order = EC_GROUP_get0_order(x);
+ cofactor = EC_GROUP_get0_cofactor(x);
+ if (order == NULL) {
reason = ERR_R_EC_LIB;
goto err;
}
@@ -321,8 +321,6 @@ int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off)
BN_free(a);
BN_free(b);
BN_free(gen);
- BN_free(order);
- BN_free(cofactor);
BN_CTX_free(ctx);
OPENSSL_free(buffer);
return (ret);