-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Change early data flag to input file #8596
Change early data flag to input file #8596
Conversation
0c8d22f
to
4c909e6
Compare
4c909e6
to
0183914
Compare
@xkqian Should this PR be part of the Early Data epic? |
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
0183914
to
70fbdcf
Compare
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 looks almost good to me, just some minor suggestions.
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
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.
Some comments. I think the implementation looks too complex and miss some features for tests.
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
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.
Some new comments. And previous early_data
option feedback is not addressed
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
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.
Some minor comments
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
I am fine with the two options solution. I put a comment in one of Jerry's suggestion. |
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
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.
LGTM
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.
While thinking about what option to add to ssl_client2 for early data testing I think we have lost (at least that's my case) sight of its scope. It is mainly about testing the various TLS options and the compatibility with GnuTLS and OpenSSL. Negative and edge cases testing is not really in scope.
Thus I'd say let's keep things simple, for the time being at least:
one option early_data_file whose default value is "". If a valid file path is set to early_data_file, we enable early data on the client and in the reconnection case, before to call mbedtls_ssl_handshake()
to reconnect we call mbedtls_ssl_write_early_data()
that tries to write the early_data_file
file data.
When we add more testing for early data we will see if they best fit in ssl-opt.sh or test_suite_ssl and we need to add other options in ssl_client2.
My target is to simple this PR. Let's make final decision in next PRs . For the two options from your previous comments, I do not think empty file and invalid file are same. If they are same, we have to check the file length before call
Agree.
|
Seems this is the first way which only provide one option, am I right? if yes, then the code before this commit: 57db590 can satisfy the requirements, of course, need addressing some comments.
This comment prefer to reserve the early_data option and introduce another option named "early_data_file" as the source file read early data from. The latest code is trying to satisfy this requirement. Seems we should agree with each other that which way we should take. and then I will revert code or keep the code accordingly. |
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
I just revert the code to |
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.
If with this changes you have what you need for your coming PRs implementing mbedtls_ssl_write_early_data()
this is good enough to me.
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.
It has got CI failure
One change request and one nitpick comments.
if (strlen(opt.early_data) > 0) { | ||
if ((early_data_fp = fopen(opt.early_data, "rb")) == NULL) { | ||
mbedtls_printf("failed\n ! Cannot open '%s' for reading.\n", | ||
opt.early_data); | ||
goto exit; | ||
} | ||
early_data_enabled = MBEDTLS_SSL_EARLY_DATA_ENABLED; | ||
} |
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.
To fix the CI failure
if (strlen(opt.early_data) > 0) { | |
if ((early_data_fp = fopen(opt.early_data, "rb")) == NULL) { | |
mbedtls_printf("failed\n ! Cannot open '%s' for reading.\n", | |
opt.early_data); | |
goto exit; | |
} | |
early_data_enabled = MBEDTLS_SSL_EARLY_DATA_ENABLED; | |
} | |
if (opt.early_data) { | |
if ((early_data_fp = fopen(opt.early_data, "rb")) == NULL) { | |
mbedtls_printf("failed\n ! Cannot open '%s' for reading.\n", | |
opt.early_data); | |
goto exit; | |
} | |
early_data_enabled = MBEDTLS_SSL_EARLY_DATA_ENABLED; | |
} |
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.
The CI failure is caused by the uninitialized file pointer early_data_fp.
opt.early_data will be default to "", this check maybe useless...
if (strlen(opt.early_data) > 0) { | ||
if ((early_data_fp = fopen(opt.early_data, "rb")) == NULL) { | ||
mbedtls_printf("failed\n ! Cannot open '%s' for reading.\n", | ||
opt.early_data); | ||
goto exit; | ||
} | ||
early_data_enabled = MBEDTLS_SSL_EARLY_DATA_ENABLED; | ||
} |
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.
Nitpick comment : move it to option check like previous version
if (strlen(opt.early_data) > 0) { | |
if ((early_data_fp = fopen(opt.early_data, "rb")) == NULL) { | |
mbedtls_printf("failed\n ! Cannot open '%s' for reading.\n", | |
opt.early_data); | |
goto exit; | |
} | |
early_data_enabled = MBEDTLS_SSL_EARLY_DATA_ENABLED; | |
} | |
mbedtls_ssl_conf_early_data(&conf, early_data_fp ?MBEDTLS_SSL_EARLY_DATA_ENABLE: MBEDTLS_SSL_EARLY_DATA_DISABLE); |
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.
I just see there are file processings like context_file
, will treat it like what I have done, so I prefer that way.
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
@yuhaoth are you happy with this now, too? |
} | ||
early_data_enabled = MBEDTLS_SSL_EARLY_DATA_ENABLED; | ||
} | ||
mbedtls_ssl_conf_early_data(&conf, early_data_enabled); |
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.
(nit) presumably early data defaults to disabled, so we could move this into the if()
and remove the variable?
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.
LGTM
Description
Originally we have one input option to control whether enable early data or not. Currently we need one extra parameter to input various length of early data. This pr will integrate them together.
This is part of #6542
PR checklist
Please tick as appropriate and edit the reasons (e.g.: "backport: not needed because this is a new feature")
provided, ornot requireddone, ornot required, or not required