-
Notifications
You must be signed in to change notification settings - Fork 124
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
Add support for BIO_FP_TEXT in file BIOs #1153
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fa86ae6
to
9af3dbb
Compare
andrewhop
reviewed
Aug 14, 2023
e24b35e
to
6a21c52
Compare
c06b69d
to
4256ea2
Compare
2938856
to
1e31cbc
Compare
f3d548a
to
1fd9b9f
Compare
justsmth
reviewed
Aug 30, 2023
justsmth
reviewed
Aug 31, 2023
1435270
to
980db0a
Compare
11c8707
to
d244db5
Compare
justsmth
previously approved these changes
Sep 11, 2023
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.
Not part of this PR, but I noticed that BIO_get_fp
also doesn't have much test coverage.
0953e84
to
7811ffd
Compare
``` [----------] 1 test from BIOTest [ RUN ] BIOTest.TextFile ..\crypto\bio\bio_test.cc(200): error: Expected equality of these values: "test\n" std::string(contents) Which is: "test\r\r\n" [ FAILED ] BIOTest.TextFile (1 ms) [----------] 1 test from BIOTest (1 ms total) ```
This reverts commit cfe74e9.
This reverts commit b3ff5fb.
This reverts commit 5616785.
76b03cd
to
c2d1648
Compare
justsmth
approved these changes
Oct 18, 2023
Merged
WillChilds-Klein
added a commit
that referenced
this pull request
Dec 13, 2024
Upstream commit [`5ee4e95`][1]'s source changes are almost identical to our addition of `BIO_FP_TEXT` in [PR 1153][2]. The only difference in behavior is that we will call `_setmode` w/ `_O_BINARY` on windows when no flags are specified, where BoringSSL will simply no-op and leave the underlying file's mode alone. Upstream's commit has some nice tests, though, so we crib those and change a single line of expectation to account for our difference in behavior. [1]: google/boringssl@5ee4e95 [2]: #1153 [3]: https://github.com/openssl/openssl/blob/dc10ffc2834e0d2f5ebc1c3e29bd97f1f43a0ead/crypto/bio/bss_file.c#L235-L237
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issues
Addresses CryptoAlg-2036
Notes
OpenSSL defines a "close flag"
BIO_FP_TEXT
which is used by callers to indicate that file-backed BIOs should be opened in "text" mode as opposed to the default of raw "binary" mode. Of platforms currently supported by AWS-LC, this is only meaningful on windows. From linux'sfopen
man page:And from Windows:
The terminology here is a bit confusing. In text mode, "Input" here refers to reading files and "output" refers to writing files to disk. So, if an application is using conventional unixy LF line endings (
\n
) and then writes a line of text to a file, the Windows CRT will instead write a CRLF line ending (\r\n
). When reading from a file, the CRT will translate CRLF back to LF transparently to the application. In binary mode, what you see is what you get and no translation occurs.OpenSSL supports setting text mode for a variety of BIO operations (including when opening files with
fopen
), but only sets this flag internally when callingBIO_new_fp
. Note thatBIO_new_fp
operates on openFILE *
s, and does not itself open the file. Instead, it uses the Windows CRT-specific function_setmode
to set binary/text mode on the already opened file.To implement this functionality in AWS-LC, we only set translation mode in functions using the
BIO_C_SET_FILE_PTR
control directive:BIO_set_fp
andBIO_new_fp
. AWS-LC's BIO functions that callfopen
along the way do not provide the caller a parameter for specifying flags, so we're limited here by the interface.Finally, it's a little odd to refer to
BIO_FP_TEXT
as a "close flag", as the behavior it determines has nothing to do with how or if the file is closed. However, this is how OpenSSL's code refers to it, so it's the terminology we use here.Links
Documentation links for the Windows-specific functions used in this change can be found here:
_setmode
: used to set translation mode on an open file_fileno
: used to convert aFILE *
to a file descriptorTesting
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.