Skip to content

Comments

Update FFI's rules of engagement (regarding boolean predicates)#5249

Draft
reneme wants to merge 1 commit intorandombit:masterfrom
Rohde-Schwarz:chore/ffi_boolean_predicates
Draft

Update FFI's rules of engagement (regarding boolean predicates)#5249
reneme wants to merge 1 commit intorandombit:masterfrom
Rohde-Schwarz:chore/ffi_boolean_predicates

Conversation

@reneme
Copy link
Collaborator

@reneme reneme commented Jan 19, 2026

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 mean false and negative values may be used as BOTAN_FFI_ERROR return 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.

Not 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_version
  • botan_constant_time_compare_mem
  • botan_xof_accepts_input
  • botan_cipher_valid_nonce_length
  • botan_cipher_is_authenticated
  • botan_cipher_requires_entire_message
  • botan_mp_is_positive
  • botan_mp_is_negative
  • botan_mp_is_zero
  • botan_mp_is_odd (deprecated)
  • botan_mp_is_even (deprecated)
  • botan_mp_equal
  • botan_mp_is_prime
  • botan_mp_get_bit (1 if requested bit is set, 0 if not)
  • botan_oid_equal
  • botan_ec_group_equal
  • botan_pubkey_ecc_key_used_explicit_encoding
  • botan_x509_cert_is_ca
  • botan_tpm2_supports_crypto_backend

@reneme reneme self-assigned this Jan 19, 2026
@coveralls
Copy link

Coverage Status

coverage: 90.401% (-1.5%) from 91.944%
when pulling 3033783 on Rohde-Schwarz:chore/ffi_boolean_predicates
into 18cd21e on randombit:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants