From dd84ee9c14ddb4e49569410c6442296f84c1a7ca Mon Sep 17 00:00:00 2001 From: Dmitry Belyavskiy Date: Thu, 15 Dec 2016 00:21:01 +0300 Subject: [PATCH] Some code clarity --- gost_ameth.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/gost_ameth.c b/gost_ameth.c index 66f89a5..b2333a4 100644 --- a/gost_ameth.c +++ b/gost_ameth.c @@ -665,9 +665,8 @@ static int pub_decode_gost_ec(EVP_PKEY *pk, X509_PUBKEY *pub) ASN1_OCTET_STRING_free(octet); return 0; } - for (i = 0, j = octet->length - 1; i < octet->length; i++, j--) { - databuf[j] = octet->data[i]; - } + + BUF_reverse(databuf, octet->data, octet->length); len = octet->length / 2; ASN1_OCTET_STRING_free(octet); @@ -735,12 +734,11 @@ static int pub_encode_gost_ec(X509_PUBKEY *pub, const EVP_PKEY *pk) goto err; } data_len = 2 * BN_num_bytes(order); - databuf = OPENSSL_malloc(data_len); + databuf = OPENSSL_zalloc(data_len); if (databuf == NULL) { GOSTerr(GOST_F_PUB_ENCODE_GOST_EC, ERR_R_MALLOC_FAILURE); goto err; } - memset(databuf, 0, data_len); store_bignum(X, databuf + data_len / 2, data_len / 2); store_bignum(Y, databuf, data_len / 2); -- 2.39.5