diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2023-06-15 13:44:39 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2023-06-15 13:44:39 +0000 |
commit | 8ff508bb79926c0e7cda4bf6a683a16d86bacc8c (patch) | |
tree | 76266be9acb7a3ae49cb4bb70e31f8fa8e9edebd | |
parent | 56c698ef92950f0b080589a610854fadaac6ddf5 (diff) |
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
-rw-r--r-- | lib/libcrypto/asn1/asn1_item.c | 44 |
1 files changed, 21 insertions, 23 deletions
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) { |