Skip to content

Comments

Fix documentation for EVP_DigestSign* and EVP_DigestVerify*#10805

Closed
levitte wants to merge 2 commits intoopenssl:masterfrom
levitte:fix-evp_digestsign-and-evp_digestverify
Closed

Fix documentation for EVP_DigestSign* and EVP_DigestVerify*#10805
levitte wants to merge 2 commits intoopenssl:masterfrom
levitte:fix-evp_digestsign-and-evp_digestverify

Conversation

@levitte
Copy link
Member

@levitte levitte commented Jan 10, 2020

The documentation doesn't match actual code.

We also fix the few cases in test/evp_test.c where the returned value
from these functions is interpreted incorrectly.

The documentation doesn't match actual code.

We also fix the few cases in test/evp_test.c where the returned value
from these functions is interpreted incorrectly.
@levitte levitte added branch: master Applies to master branch approval: review pending This pull request needs review by a committer labels Jan 10, 2020
@levitte
Copy link
Member Author

levitte commented Jan 10, 2020

Should this be back-ported to 1.1.1? Considering that both EVP_DigestSignInit() and EVP_DigestVerifyInit() use the same underlying function, they may both potentially return a negative value.

@levitte
Copy link
Member Author

levitte commented Jan 10, 2020

@beldmit
Copy link
Member

beldmit commented Jan 10, 2020

Approved if no problems with Travis.

@levitte levitte force-pushed the fix-evp_digestsign-and-evp_digestverify branch from b6005d0 to 9d4d60b Compare January 10, 2020 19:49
@kaduk
Copy link
Contributor

kaduk commented Jan 11, 2020

If our tests were using a "broken check for errors", how much existing code in applications using openssl also has such a "broken check for errors".

@romen
Copy link
Member

romen commented Jan 11, 2020

I share the concern about fixing the documentation over fixing the behavior: when we promise that we won't break API compatibility (or as little as possible) with 3.0, do we refer to the API as documented or to the API as it should have been documented to match the behavior of a specific revision of the code? (I don't know if this is the case, but what if 1.0.2 and 1.1.0 adhered to the boolean return value documentation and 1.1.1 introduced the return of negative integers for special errors? Should that be seen as a bug to be fixed in 1.1.1 rather than a documentation out of sync with 1.1.1 behavior?)

Apart from the hypothetical case above, I'd like for this kind of issues to include in the PR discussion a survey of how things worked in previous (relevant) releases to understand when documentation and implementation diverged and have clearly in mind if it is more appropriate to fix documentation or behavior!

@levitte
Copy link
Member Author

levitte commented Jan 11, 2020

This is also about patterns. Most of the API surrounding EVP_PKEY has the same kind of return values (including the magic -2), so the documentation on these sets of functions broke away from that pattern in the documentation, but not in actual code as far as I can tell (it's not immediately visible in pre-3.0 code, you have to dig around a bit). I found it even more exasperating that, although related, the documentation for DigestSign and DigestVerify was quite different regarding return values.

To exasperated things further, we do use negative values much more visibly in 3.0, including -2 to indicate unsupported operations, as return values.

Regarding the stark difference in documentation of return values between DigestSign and DigestVerify, I can't help but wonder if someone just documented a snapshot of what the code looked like at that time.

It should be obvious by now that I'm looking for some sort of consistency across the board, rather than having each small set of functions do each their own thing.

@romen
Copy link
Member

romen commented Jan 11, 2020

@levitte I am not against fixing the documentation, at all, and I am with you on the efforts to uniform behavior whenever possible across the board.

My point is just that we should include in the PR this kind of survey!

I would say that I am fine with fixing the documentation in this case, for all the reasons you stated, but to be fair to our external users we should include a CHANGES entry to be fair to those diligent users that conformed to our misleading documentation!

@levitte
Copy link
Member Author

levitte commented Jan 11, 2020

we should include a CHANGES...

Ah, yes! Thanks for the reminder

@levitte
Copy link
Member Author

levitte commented Jan 12, 2020

I took a moment to look more thoroughly at the 1.1.1 crypto/evp/m_sigver.c, and it turns out that it looks like I'm wrong regarding the history of these functions.

Except for EVP_DigestVerifyFinal, it does appear that all these functions did return only 0 or 1 (including the EVP_DigestSign functions, in spite of what the manual says).

So I'm changing my mind. You were right about the compatibility remarks, and even though I don't quite like the way our return values vary so much between sets of functions, you're right that we have promised to leave the API unchanged as far as we can help, and for this set of functions, I'm not at all sure that the returned -2 is justifiable in this case.

Closing this and starting over.

@levitte levitte closed this Jan 12, 2020
@levitte levitte deleted the fix-evp_digestsign-and-evp_digestverify branch January 12, 2020 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: review pending This pull request needs review by a committer branch: master Applies to master branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants