Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align BN_bn2hex behavior with OpenSSL #2122

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crypto/bn_extra/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int BN_bn2cbb_padded(CBB *out, size_t len, const BIGNUM *in) {
return CBB_add_space(out, &ptr, len) && BN_bn2bin_padded(ptr, len, in);
}

static const char hextable[] = "0123456789abcdef";
static const char hextable[] = "0123456789ABCDEF";

char *BN_bn2hex(const BIGNUM *bn) {
int width = bn_minimal_width(bn);
Expand Down
4 changes: 2 additions & 2 deletions crypto/fipsmodule/bn/bn_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2682,7 +2682,7 @@ TEST_F(BNTest, NonMinimal) {
EXPECT_FALSE(BN_is_pow2(ten.get()));

bssl::UniquePtr<char> hex(BN_bn2hex(ten.get()));
EXPECT_STREQ("0a", hex.get());
EXPECT_STREQ("0A", hex.get());
hex.reset(BN_bn2hex(zero.get()));
EXPECT_STREQ("0", hex.get());

Expand All @@ -2695,7 +2695,7 @@ TEST_F(BNTest, NonMinimal) {
// TODO(davidben): |BN_print| removes leading zeros within a byte, while
// |BN_bn2hex| rounds up to a byte, except for zero which it prints as
// "0". Fix this discrepancy?
EXPECT_EQ(Bytes("a"), Bytes(ptr, len));
EXPECT_EQ(Bytes("A"), Bytes(ptr, len));

bio.reset(BIO_new(BIO_s_mem()));
ASSERT_TRUE(bio);
Expand Down
4 changes: 2 additions & 2 deletions crypto/fipsmodule/ec/ec_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ TEST(ECTest, Encoding) {
ASSERT_TRUE(y_hex);

EXPECT_STREQ(
"c81561ecf2e54edefe6617db1c7a34a70744ddb261f269b83dacfcd2ade5a681",
"C81561ECF2E54EDEFE6617DB1C7A34A70744DDB261F269B83DACFCD2ADE5A681",
x_hex.get());
EXPECT_STREQ(
"e0e2afa3f9b6abe4c698ef6495f1be49a3196c5056acb3763fe4507eec596e88",
"E0E2AFA3F9B6ABE4C698EF6495F1BE49A3196C5056ACB3763FE4507EEC596E88",
y_hex.get());
}

Expand Down
Loading