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

Fixed missing functions from doxygen headers #965

Draft
wants to merge 4 commits into
base: development
Choose a base branch
from

Conversation

gilles-peskine-arm
Copy link
Contributor

Functions which had alternative implementations were omitted from the documentation generated by apidoc_full.sh, due to the way #define's were managed. This commit fixes this except for the ECC functions.

Internal ref: IOTSSL-1447. See also ARMmbed/mbed-os-5-docs#171

@RonEld
Copy link
Contributor

RonEld commented Jun 22, 2017

Hi @gilles-peskine-arm the CI is failing because:

5.74s$ tests/scripts/doxygen.sh
/home/travis/build/ARMmbed/mbedtls/include/mbedtls/config.h:205: warning: documentation for unknown define MBEDTLS_TIMING_ALT found.
/home/travis/build/ARMmbed/mbedtls/include/mbedtls/config.h:218: warning: documentation for unknown define MBEDTLS_AES_ALT found.
/home/travis/build/ARMmbed/mbedtls/include/mbedtls/config.h:261: warning: documentation for unknown define MBEDTLS_MD2_PROCESS_ALT found.
/home/travis/build/ARMmbed/mbedtls/include/mbedtls/config.h:369: warning: documentation for unknown define MBEDTLS_ENTROPY_HARDWARE_ALT found.
/home/travis/build/ARMmbed/mbedtls/include/mbedtls/config.h:1332: warning: documentation for unknown define MBEDTLS_THREADING_ALT found.
FAIL

perhaps this post could assisst

@gilles-peskine-arm
Copy link
Contributor Author

@RonEld Yes, I noticed that today. That SO link was the second Google hit for me, the first was #520 … I'm working on a solution, never mind if the way it's done isn't pretty as long as the output is good.

simonbutcher
simonbutcher previously approved these changes Oct 1, 2017
@simonbutcher
Copy link
Contributor

Looks good to me. @Patater - if you can review this too, we can get it merged.

@simonbutcher simonbutcher added the needs-review Every commit must be reviewed by at least two team members, label Oct 1, 2017
@@ -96,7 +98,7 @@

# Things that should be enabled in "full" even if they match @excluded
my @non_excluded = qw(
PLATFORM_[A-Z0-9]+_ALT
PLATFORM_[_A-Z0-9]+_ALT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now matches double (or more) _ like PLATFORM_____WHATEVER_STUFF_____ALT. Consider removing all _ from outside the [].

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally don't think this matters. Whether the underscore is inside or outside the brackets, they'll still match to multiple underscores, but I don't think that's an issue.

@@ -170,6 +172,9 @@
if ($action eq "realfull") {
$exclude_re = qr/^$/;
$no_exclude_re = qr/./;
} elsif ($action eq "docfull") {
$exclude_re = qr/_ALT\s*$/;
$no_exclude_re = qr/(?:PLATFORM|ECP)_[_A-Z0-9]+_ALT\s*$/;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also matches double (or more) _. Consider removing all _ from outside the [].

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit says it doesn't include ECC functions in doxygen output yet, but it perhaps is partially making the attempt by having ECP in this no exclude regex. Should the |ECP addition be in the ECC function no exclude commit instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the structure of the commits makes logical sense as they are. I don't see a need to restructure them.

md_internal.h \
pk_internal.h \
ssl_internal.h \
*_wrap.h
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which _internal.h files are we additionally allowing now? Is it clear to folks adding new _internal.h files that they won't get excluded automatically anymore?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there has been a shift in what _internal.h is used for: it used to mean "don't include this in your application, it's only for internal library use", but in recently added occurrences it means "don't include this in your application, it's only for implementers of alternative crypto implementations". I wish we had distinct names for those two meanings but it's two late for that. Anyway, it looks like new _internal.h files will most likely fall in that second category, so should indeed be included by default. (Ideally we could have different doxyfiles for end-users and alt-implementers.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a comment to explain this.

@@ -98,7 +104,7 @@ int mbedtls_internal_ecp_init( const mbedtls_ecp_group *grp );
*/
void mbedtls_internal_ecp_free( const mbedtls_ecp_group *grp );

#if defined(ECP_SHORTWEIERSTRASS)
/* Short Weierstrass form */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure why removing these ECP_SHORTWEIERSTRASS and ECP_MONTGOMERY ifdefs causes ECP functions with ALT implementations to be included in the Doxygen output. If why isn't obvious to an informed developer, could you please explain why in the commit message?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this will also fix #1147

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a clarifying description to the commit. Please let me know if it's sufficient.

ChangeLog Outdated
@@ -36,6 +36,8 @@ Changes
* Clarify ECDSA documentation and improve the sample code to avoid
misunderstandings and potentially dangerous use of the API. Pointed out
by Jean-Philippe Aumasson.
* Tweaked apidoc_full.sh to include functions with alternative
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What tense are we supposed to use in the ChangeLog?

We should use a consistent tense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Judging from the surrounding ChangeLog entries, this should be Tweak for uniformity.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the tense and tried to improve the comment.

@gilles-peskine-arm gilles-peskine-arm mentioned this pull request Oct 31, 2017
4 tasks
@gilles-peskine-arm gilles-peskine-arm requested review from Patater and removed request for andresag01 and yanesca November 27, 2017 19:23
@gilles-peskine-arm
Copy link
Contributor Author

@Patater I'm treating your comments here as “changes requested”, I'll take a look. @mpg I'd appreciate your opinion as to whether this upholds the philosophy of what should be included in the Doxygen output.

@Patater
Copy link
Contributor

Patater commented Nov 28, 2017

@gilles-peskine-arm The _ stuff is just "comment", not strictly requiring a change. With or without the _ outside it'll still match multiple ______.

The comment about tense should be addressed. The ECP regex falling into the wrong commit should be addressed as well.

@mpg
Copy link
Contributor

mpg commented Nov 30, 2017

@gilles-peskine-arm I think the philosophy of what goes to doxigen output is yet to be defined, so concerns about upholding it should not block a PR. Anyway, I believe this PR keeps the spirit of what we'd been doing previously.

Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, both the intent and how it's implemented.

However, there are non-trivial merge conflicts in config.pl which need to be addressed before merging.

@gilles-peskine-arm gilles-peskine-arm added needs-work needs-backports Backports are missing or are pending review and approval. and removed needs-review Every commit must be reviewed by at least two team members, labels Apr 17, 2018
Copy link
Contributor

@Patater Patater left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've merged platform_zeroize, so MBEDTLS_PLATFORM_ZEROIZE_ALT Doxygen isn't being generated properly. I'm happy to review after a rebase on latest development.

@simonbutcher simonbutcher added the component-platform Portability layer and build scripts label May 22, 2018
@hanno-becker
Copy link

@gilles-peskine-arm If you find time, could you rebase this?

@gilles-peskine-arm
Copy link
Contributor Author

@hanno-arm Looking at the comments here there's more work to do than just rebasing. I won't have time until the week after next.

@RonEld
Copy link
Contributor

RonEld commented Oct 25, 2018

fixes #520 , but the script for generating the documentation in the website should probably change as well

@simonbutcher
Copy link
Contributor

@gilles-peskine-arm - Do you think you'll be able to rework this PR? Or can I adopt it (or find a volunteer)?

@gilles-peskine-arm
Copy link
Contributor Author

This PR has bitrotted and I don't intend to work on it in the short or medium term.

gilles-peskine-arm and others added 4 commits January 11, 2019 21:54
Functions which had alternative implementations were omitted from the
documentation generated by apidoc_full.sh, due to the way #define's
were managed. This commit fixes this except for the ECC functions.
Some internal ECP functions which can be provided as alternative
implementations to accelerate ECC operations were not being included in the
doxygen generated documentation. This is because they were only being included
in the header if the preprocessor symbols ECP_SHORTWEIERSTRASS and
ECP_MONTGOMERY were included. Yet neither symbol is a config.h option, and were
actually symbols that were defined internally in ecp.c, only after
ecp_internal.h had been included.

The missing functions also have no implementation in the library and are only
defined as a means to provide acceleration through 3rd party implementation.

Surrounding the functions by the symbols ECP_SHORTWEIERSTRASS and ECP_MONTGOMERY
therefore is unnecessary, and stops the documentation from including them.

This commit therefore removes those guards.

Fixes Mbed-TLS#1147.
Fix the tense in the ChangeLog and refine the language.
Added a comment to doxygen/mbedtls.doxyfile to explain what is and isn't
excluded from doxygen documentation and why.
@simonbutcher
Copy link
Contributor

I've rebased the PR, and attempted to address review feedback.

@RonEld / @Patater / @mpg - Could you please review? Once it's been reviewed I'll do the backports.

@mpg mpg self-requested a review January 25, 2019 10:53
@mpg mpg removed their request for review February 20, 2020 11:11
@@ -19,7 +19,7 @@ fi
CONFIG_BAK=${CONFIG_H}.bak
cp -p $CONFIG_H $CONFIG_BAK

scripts/config.pl realfull
scripts/config.pl docfull
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we only use realfull to generate the documentation (which was its original purpose in 1989caf), we don't document it, and the library doesn't even build (check_config.h would signal conflicts), I think we should change what realfull does to be useful for its intended purpose and not introduce a new name.

@@ -218,7 +223,7 @@

my $done;
for my $line (@config_lines) {
if ($action eq "full" || $action eq "realfull" || $action eq "baremetal" ) {
if (grep {$action eq $_} qw(docfull full realfull baremetal)) {
if ($line =~ /name SECTION: Module configuration options/) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that including “Module configuration options” when generating the documentation fixes the bug that some configuration options are missing (#520), but introduces a minor bug: many options have lines like //#define MBEDTLS_FOO 42 /**< Description */ that were copied from another header with // prepended, and this results in a duplicated sentence in the rendered documentation since Doxygen concatenates the documentation blocks from config.h and the other header.

@tom-cosgrove-arm tom-cosgrove-arm added the historical-reviewing Currently reviewing (for legacy PR/issues) label Jul 1, 2022
@mpg
Copy link
Contributor

mpg commented Nov 21, 2022

A couple of years later, it was not entirely clear to me what exactly this was doing, so I ran make apidoc both before and after this PR, and the main difference is that after this PR, ecp_internal.h and rsa_internal.h are included in the generated documentation. This seems desirable as those files can be used by ALT implementors.

However since 3.0 those files have moved and are now library/ecp_internal_alt.h and library/rsa_alt_helpers.h so this PR would probably need some rework in order to find them in their new location - in addition to the conflicts that have grown in the meantime.

It should also be noted that the ALT framework is going to be deprecated in favour of PSA crypto drivers in the near future.

@tom-daubney-arm tom-daubney-arm marked this pull request as draft May 18, 2023 17:52
@tom-daubney-arm tom-daubney-arm added historical-reviewed Reviewed & agreed to keep legacy PR/issue and removed historical-reviewing Currently reviewing (for legacy PR/issues) labels May 18, 2023
@tom-daubney-arm
Copy link
Contributor

As part of our review of historical PRs we have made the decision to convert older PRs that have not been updated in 3 months into drafts until they are worked on again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component-platform Portability layer and build scripts historical-reviewed Reviewed & agreed to keep legacy PR/issue needs-backports Backports are missing or are pending review and approval. needs-work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants