summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2023-07-02 14:53:19 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2023-07-02 14:53:19 +0000
commitdf911457b741813f456055677b8c727a8c97ccba (patch)
tree66fbfdac62e6901bbb5eee28a9d0889d84265afa /lib
parent51beb3bbed1714e9ce4edd80589c1694a6774e83 (diff)
Use asprintf() to avoid repetition in string constants
... since ASN1_bn_print() is stupid. ok jsing
Diffstat (limited to 'lib')
-rw-r--r--lib/libcrypto/ec/eck_prn.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/libcrypto/ec/eck_prn.c b/lib/libcrypto/ec/eck_prn.c
index 9bf05bb38c1..598b83835f1 100644
--- a/lib/libcrypto/ec/eck_prn.c
+++ b/lib/libcrypto/ec/eck_prn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eck_prn.c,v 1.23 2023/07/02 13:48:47 tb Exp $ */
+/* $OpenBSD: eck_prn.c,v 1.24 2023/07/02 14:53:18 tb Exp $ */
/*
* Written by Nils Larsch for the OpenSSL project.
*/
@@ -203,7 +203,9 @@ ecpk_print_explicit_parameters(BIO *bp, const EC_GROUP *group, int off)
BIGNUM *p, *a, *b, *order, *cofactor;
BIGNUM *gen = NULL;
const EC_POINT *generator;
- const unsigned char *conversion, *seed;
+ const char *conversion_form;
+ char *conversion = NULL;
+ const unsigned char *seed;
size_t seed_len;
unsigned char *buffer = NULL;
size_t buf_len, i;
@@ -286,13 +288,17 @@ ecpk_print_explicit_parameters(BIO *bp, const EC_GROUP *group, int off)
goto err;
if (form == POINT_CONVERSION_COMPRESSED)
- conversion = "Generator (compressed):";
+ conversion_form = "compressed";
else if (form == POINT_CONVERSION_UNCOMPRESSED)
- conversion = "Generator (uncompressed):";
+ conversion_form = "compressed";
else if (form == POINT_CONVERSION_HYBRID)
- conversion = "Generator (hybrid):";
+ conversion_form = "hybrid";
else
- conversion = "Generator (unknown):";
+ conversion_form = "unknown";
+ if (asprintf(&conversion, "Generator (%s):", conversion_form) == -1) {
+ conversion = NULL;
+ goto err;
+ }
if (!ASN1_bn_print(bp, conversion, gen, buffer, off))
goto err;
@@ -311,6 +317,7 @@ err:
BN_CTX_end(ctx);
BN_CTX_free(ctx);
free(buffer);
+ free(conversion);
return ret;
}