Print the curve name, not bit length in EVP_PKEY_print_*
This is a departure from OpenSSL's output (which seems to just append even more information afterwards), but is a better way to identify the algorithm. Change-Id: Iccffdf9297bde5362d902d4de1d99de7b673bed2 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/54952 Reviewed-by: Bob Beck <bbe@google.com> Commit-Queue: David Benjamin <davidben@google.com>
This commit is contained in:
committed by
Boringssl LUCI CQ
parent
fd4315d8eb
commit
054a5d36bb
@@ -762,14 +762,13 @@ TEST(EVPExtraTest, Print) {
|
||||
61
|
||||
)");
|
||||
|
||||
// TODO(davidben): This output should include the curve name.
|
||||
bssl::UniquePtr<EVP_PKEY> ec =
|
||||
ParsePrivateKey(EVP_PKEY_EC, kExampleECKeyDER, sizeof(kExampleECKeyDER));
|
||||
ASSERT_TRUE(ec);
|
||||
EXPECT_EQ(PrintToString(ec.get(), /*indent=*/2, &EVP_PKEY_print_params),
|
||||
" ECDSA-Parameters: (256 bit)\n");
|
||||
" ECDSA-Parameters: (P-256)\n");
|
||||
EXPECT_EQ(PrintToString(ec.get(), /*indent=*/2, &EVP_PKEY_print_public),
|
||||
R"( Public-Key: (256 bit)
|
||||
R"( Public-Key: (P-256)
|
||||
pub:
|
||||
04:e6:2b:69:e2:bf:65:9f:97:be:2f:1e:0d:94:8a:
|
||||
4c:d5:97:6b:b7:a9:1e:0d:46:fb:dd:a9:a9:1e:9d:
|
||||
@@ -778,7 +777,7 @@ TEST(EVPExtraTest, Print) {
|
||||
4b:cf:72:22:c1
|
||||
)");
|
||||
EXPECT_EQ(PrintToString(ec.get(), /*indent=*/2, &EVP_PKEY_print_private),
|
||||
R"( Private-Key: (256 bit)
|
||||
R"( Private-Key: (P-256)
|
||||
priv:
|
||||
07:0f:08:72:7a:d4:a0:4a:9c:dd:59:c9:4d:89:68:
|
||||
77:08:b5:6f:c9:5d:30:77:0e:e8:d1:c9:ce:0a:8b:
|
||||
|
||||
+5
-2
@@ -259,8 +259,11 @@ static int do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype) {
|
||||
if (!BIO_indent(bp, off, 128)) {
|
||||
return 0;
|
||||
}
|
||||
if (BIO_printf(bp, "%s: (%u bit)\n", ecstr,
|
||||
BN_num_bits(EC_GROUP_get0_order(group))) <= 0) {
|
||||
int curve_name = EC_GROUP_get_curve_name(group);
|
||||
if (BIO_printf(bp, "%s: (%s)\n", ecstr,
|
||||
curve_name == NID_undef
|
||||
? "unknown curve"
|
||||
: EC_curve_nid2nist(curve_name)) <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user