From: tb Date: Thu, 15 Jun 2023 13:44:38 +0000 (+0000) Subject: Rename a few variables and other cosmetics X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9e3b1f694630385f670857259d77283ceab3e398;p=openbsd Rename a few variables and other cosmetics Rename buf_in into in, buf_out into out, use in_len and out_len for their lengths, drop a couple of silly casts and remove some empty lines. ok jsing --- diff --git a/lib/libcrypto/asn1/asn1_item.c b/lib/libcrypto/asn1/asn1_item.c index b441ca8f33e..fcf45a0fee3 100644 --- a/lib/libcrypto/asn1/asn1_item.c +++ b/lib/libcrypto/asn1/asn1_item.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_item.c,v 1.11 2023/06/15 13:32:18 tb Exp $ */ +/* $OpenBSD: asn1_item.c,v 1.12 2023/06/15 13:44:38 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -233,8 +233,8 @@ ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, { const EVP_MD *type; EVP_PKEY *pkey; - unsigned char *buf_in = NULL, *buf_out = NULL; - size_t buf_out_len = 0; + unsigned char *in = NULL, *out = NULL; + size_t out_len = 0; int in_len = 0; int signid, paramtype; int rv = 2; @@ -254,7 +254,7 @@ ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, rv = pkey->ameth->item_sign(ctx, it, asn, algor1, algor2, signature); if (rv == 1) { - buf_out_len = signature->length; + out_len = signature->length; goto done; } /* Return value meanings: @@ -295,33 +295,31 @@ ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, } - if ((in_len = ASN1_item_i2d(asn, &buf_in, it)) <= 0) { + if ((in_len = ASN1_item_i2d(asn, &in, it)) <= 0) { in_len = 0; goto err; } - if (!EVP_DigestSign(ctx, NULL, &buf_out_len, buf_in, in_len)) { + if (!EVP_DigestSign(ctx, NULL, &out_len, in, in_len)) { ASN1error(ERR_R_EVP_LIB); goto err; } - - if ((buf_out = calloc(1, buf_out_len)) == NULL) { + if ((out = calloc(1, out_len)) == NULL) { ASN1error(ERR_R_MALLOC_FAILURE); goto err; } - - if (!EVP_DigestSign(ctx, buf_out, &buf_out_len, buf_in, in_len)) { + if (!EVP_DigestSign(ctx, out, &out_len, in, in_len)) { ASN1error(ERR_R_EVP_LIB); goto err; } - if (buf_out_len > INT_MAX) { + if (out_len > INT_MAX) { ASN1error(ASN1_R_TOO_LONG); goto err; } - ASN1_STRING_set0(signature, buf_out, (int)buf_out_len); - buf_out = NULL; + ASN1_STRING_set0(signature, out, out_len); + out = NULL; if (!asn1_abs_set_unused_bits(signature, 0)) { ASN1error(ERR_R_ASN1_LIB); @@ -329,11 +327,11 @@ ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, } done: - ret = (int)buf_out_len; + ret = out_len; err: EVP_MD_CTX_cleanup(ctx); - freezero(buf_in, in_len); - freezero(buf_out, buf_out_len); + freezero(in, in_len); + freezero(out, out_len); return ret; } @@ -343,10 +341,10 @@ ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, ASN1_BIT_STRING *signature, void *asn, EVP_PKEY *pkey) { EVP_MD_CTX ctx; - unsigned char *buf_in = NULL; - int ret = -1, inl; - + unsigned char *in = NULL; int mdnid, pknid; + int in_len = 0; + int ret = -1; if (!pkey) { ASN1error(ERR_R_PASSED_NULL_PARAMETER); @@ -402,20 +400,20 @@ ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, } - inl = ASN1_item_i2d(asn, &buf_in, it); + in_len = ASN1_item_i2d(asn, &in, it); - if (buf_in == NULL) { + if (in == NULL) { ASN1error(ERR_R_MALLOC_FAILURE); goto err; } - if (!EVP_DigestVerifyUpdate(&ctx, buf_in, inl)) { + if (!EVP_DigestVerifyUpdate(&ctx, in, in_len)) { ASN1error(ERR_R_EVP_LIB); ret = 0; goto err; } - freezero(buf_in, (unsigned int)inl); + freezero(in, (unsigned int)in_len); if (EVP_DigestVerifyFinal(&ctx, signature->data, (size_t)signature->length) <= 0) {