-
Notifications
You must be signed in to change notification settings - Fork 128
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
Implement BIO_dump #2331
base: main
Are you sure you want to change the base?
Implement BIO_dump #2331
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2331 +/- ##
==========================================
+ Coverage 78.76% 78.80% +0.04%
==========================================
Files 620 620
Lines 107861 107874 +13
Branches 15319 15322 +3
==========================================
+ Hits 84953 85012 +59
+ Misses 22252 22205 -47
- Partials 656 657 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
||
// BIO_dump should return an estimate of bytes written | ||
int ret = BIO_dump(bio.get(), data, sizeof(data)); | ||
ASSERT_GT(ret, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make this assertion more specific.
ASSERT_EQ(ret, 80);
ASSERT_TRUE(BIO_mem_contents(bio.get(), &contents, &len)); | ||
std::string output(reinterpret_cast<const char *>(contents), len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also make an assertion about the value of len
. Should it return a value equal to (or greater than) the value returned above?
if (!BIO_hexdump(bio, (const uint8_t *)data, (size_t)len, 0)) { | ||
return -1; | ||
} | ||
|
||
// Return estimate of bytes written (each line is ~80 bytes) | ||
return ((len + 15) / 16) * 80; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of needing to estimate how many bytes were written, this could be exact. Why not modify hexdump_write
above to return the actual number of bytes written (just bump a counter on each of its calls to BIO_write
), call hexdump_write
directly instead of calling it via BIO_hexdump
, then return whatever value it returns?
Issues:
Addresses #CryptoAlg-3030
Description of changes:
Implemented BIO_dump() function in AWS-LC, matching OpenSSL 1.1.1's functionality. This function enables hexadecimal dumping of data through the BIO interface, providing compatibility for applications that rely on this OpenSSL API.
Call-outs:
Testing:
Added test in crypto/bio/bio_test.cc
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.