sync with OpenBSD -current

This commit is contained in:
purplerain 2023-11-22 20:51:44 +00:00
parent 1abf3d5d6c
commit 10cf24ada0
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
40 changed files with 462 additions and 489 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ec_print.c,v 1.13 2023/07/07 13:54:45 beck Exp $ */
/* $OpenBSD: ec_print.c,v 1.14 2023/11/21 22:17:15 tb Exp $ */
/* ====================================================================
* Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
*
@ -63,8 +63,7 @@ EC_POINT_point2bn(const EC_GROUP *group, const EC_POINT *point,
size_t buf_len = 0;
unsigned char *buf;
buf_len = EC_POINT_point2oct(group, point, form,
NULL, 0, ctx);
buf_len = EC_POINT_point2oct(group, point, form, NULL, 0, ctx);
if (buf_len == 0)
return NULL;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: eck_prn.c,v 1.28 2023/07/07 13:54:45 beck Exp $ */
/* $OpenBSD: eck_prn.c,v 1.30 2023/11/21 22:05:33 tb Exp $ */
/*
* Written by Nils Larsch for the OpenSSL project.
*/
@ -160,10 +160,6 @@ ECParameters_print(BIO *bp, const EC_KEY *x)
}
LCRYPTO_ALIAS(ECParameters_print);
static int
print_bin(BIO *fp, const char *str, const unsigned char *num,
size_t len, int off);
static int
ecpk_print_asn1_parameters(BIO *bp, const EC_GROUP *group, int off)
{
@ -289,8 +285,33 @@ ecpk_print_explicit_parameters(BIO *bp, const EC_GROUP *group, int off)
if (!bn_printf(bp, cofactor, off, "Cofactor: "))
goto err;
if ((seed = EC_GROUP_get0_seed(group)) != NULL) {
size_t i;
seed_len = EC_GROUP_get_seed_len(group);
if (!print_bin(bp, "Seed:", seed, seed_len, off))
/* XXX - ecx_buf_print() has a CBS version of this - dedup. */
if (!BIO_indent(bp, off, 128))
goto err;
if (BIO_printf(bp, "Seed:") <= 0)
goto err;
for (i = 0; i < seed_len; i++) {
const char *sep = ":";
if (i % 15 == 0) {
if (BIO_printf(bp, "\n") <= 0)
goto err;
if (!BIO_indent(bp, off + 4, 128))
goto err;
}
if (i + 1 == seed_len)
sep = "";
if (BIO_printf(bp, "%02x%s", seed[i], sep) <= 0)
goto err;
}
if (BIO_printf(bp, "\n") <= 0)
goto err;
}
@ -316,38 +337,3 @@ ECPKParameters_print(BIO *bp, const EC_GROUP *group, int off)
return ecpk_print_explicit_parameters(bp, group, off);
}
LCRYPTO_ALIAS(ECPKParameters_print);
static int
print_bin(BIO *fp, const char *name, const unsigned char *buf,
size_t len, int off)
{
size_t i;
char str[128];
if (buf == NULL)
return 1;
if (off) {
if (off > 128)
off = 128;
memset(str, ' ', off);
if (BIO_write(fp, str, off) <= 0)
return 0;
}
if (BIO_printf(fp, "%s", name) <= 0)
return 0;
for (i = 0; i < len; i++) {
if ((i % 15) == 0) {
str[0] = '\n';
memset(&(str[1]), ' ', off + 4);
if (BIO_write(fp, str, off + 1 + 4) <= 0)
return 0;
}
if (BIO_printf(fp, "%02x%s", buf[i], ((i + 1) == len) ? "" : ":") <= 0)
return 0;
}
if (BIO_write(fp, "\n", 1) <= 0)
return 0;
return 1;
}