Update FFI's rules of engagement (regarding boolean predicates)#5249
Draft
reneme wants to merge 1 commit intorandombit:masterfrom
Draft
Update FFI's rules of engagement (regarding boolean predicates)#5249reneme wants to merge 1 commit intorandombit:masterfrom
reneme wants to merge 1 commit intorandombit:masterfrom
Conversation
This file contains hidden or 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
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.
As discussed the other day, we agreed to harmonize the return codes of boolean predicates in the FFI as much as reasonable. The current suggestion is that 1 should mean
true, 0 should meanfalseand negative values may be used asBOTAN_FFI_ERRORreturn codes. Any other integer return values beyond 0/1 must use an out-parameter.This provides an overview of the currently-implemented predicate functions in the FFI. Also, I committed a suggestion for the extended wording in the "rules of engagement" for the FFI. No API was adapted so far.
Currently Non-Compliant
Let's check them off one-by-one.
botan_ffi_supports_apibotan_constant_time_comparebotan_same_membotan_bcrypt_is_validbotan_ec_group_supports_application_specific_groupbotan_ec_group_supports_named_groupbotan_privkey_check_keybotan_pubkey_check_keybotan_privkey_stateful_operationbotan_pk_op_verify_finishbotan_x509_cert_allowed_usagebotan_x509_cert_allowed_extended_usage_str(FIX:botan_x509_cert_allowed_extended_usage_*should return "1" on true #5252)botan_x509_cert_allowed_extended_usage_oid(FIX:botan_x509_cert_allowed_extended_usage_*should return "1" on true #5252)botan_x509_cert_hostname_matchbotan_x509_cert_verify(maybe? returns a validation_result and SUCCESS (0))botan_x509_is_revokedbotan_hotp_checkbotan_totp_checkNot sure
These "compare" functions are strictly not compliant with the above-described rule. But perhaps we should keep them anyway, as they are consistent with
strcmp?botan_mp_cmp(special case: returns -1 for x < y, 0 for x == y, and 1 for x > y)botan_oid_cmp(special case: same as botan_mp_cmp)Compliant
botan_ffi_supports_api_versionbotan_constant_time_compare_membotan_xof_accepts_inputbotan_cipher_valid_nonce_lengthbotan_cipher_is_authenticatedbotan_cipher_requires_entire_messagebotan_mp_is_positivebotan_mp_is_negativebotan_mp_is_zerobotan_mp_is_odd(deprecated)botan_mp_is_even(deprecated)botan_mp_equalbotan_mp_is_primebotan_mp_get_bit(1 if requested bit is set, 0 if not)botan_oid_equalbotan_ec_group_equalbotan_pubkey_ecc_key_used_explicit_encodingbotan_x509_cert_is_cabotan_tpm2_supports_crypto_backend