-
Notifications
You must be signed in to change notification settings - Fork 623
FIX: botan_x509_cert_is_ca() should return "1" for true
#5236
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
base: master
Are you sure you want to change the base?
Conversation
atreiber94
left a comment
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.
Good spot, and we should definitely make this behavior consistent (also in the FFI doc).
|
I think a long long time ago I discussed with @randombit that an |
Frankly, I see the appeal to that as it avoids potential ambiguity regarding the error code. But then again, on the usage site: if (is_ca(cert_handle) > 0) { /* ... */}
// ---
int ca = 0;
is_ca(cert_handle, &ca); // will someone really check the error code on a predicate?
if (ca) { /* ... */ }... I think the most important thing is that we all agree on one option, codify it in the "rules of engagement" and then harmonize it for Botan4. My vote is for: Use the returned integer, with true as 1, false as 0, errors are negative. Explicitly tell users to check predicates for |
|
I do agree the interface should be consistent as possible, and the general approach should be codified somewhere (in I guess I"m ok with using 0/1 returns for boolean predicates, though I do prefer an output parameter overall. For anything beyond 0/1 I'd be strongly in favor of output parameters (for example I consider
That approach is absolutely necessary because of FFI's versioning. In all versions of the FFI interface (eg 2.13.0's It's already bad enough if we ever remove anything (like any of the currently deprecated interfaces) - we'd likewise have to disclaim supporting any FFI API versions that included the removed functions, which since many of the deprecated interfaces are quite old means most or all of them. Leaving us in much the same position. But at least in that case, it's possible to release a new version of Botan3 which post-facto claims compliance with the same FFI interface version that was added in Botan 4.0 |
Note that this function was just introduced #5221, hence no semver breach.
Most other predicate functions in the FFI return 1 for
truewhich makes sense frankly. For instance all predicates in thebotan_mp_*family, also things likebotan_cipher_is_authenticatedorbotan_tpm2_supports_crypto_backendand some more.On the other hand,
botan_x509_is_revoked, andbotan_bcrypt_is_validreturn 0 fortrue. 🙄I think we should rectify this inconsistency with Botan4. Probably best to deprecate all predicate functions that define 0 as
trueand introduce new ones. Just flipping the behavior, even in a major release, will most certainly cause havoc 😨.