From: Dmitry Belyavskiy Date: Wed, 14 Dec 2016 21:21:01 +0000 (+0300) Subject: Some code clarity X-Git-Tag: v1.1.0.2~13 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=dd84ee9c14ddb4e49569410c6442296f84c1a7ca;p=openssl-gost%2Fengine.git Some code clarity --- 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);