Skip to content

API design: wolfCrypt sign/verify functions take non-const key pointers #10586

Description

@MarkAtwood

wolfCrypt's C API takes non-const (mutable) key pointers for operations that are logically read-only, including signature verification and public-key access. Affected functions include:

  • wc_Ed25519Sign, wc_Ed25519Verify
  • wc_Ed448Sign, wc_Ed448Verify
  • wc_ecc_sign_hash, wc_ecc_verify_hash
  • wc_RsaSSL_Sign, wc_RsaSSL_Verify
  • wc_MlDsaKey_Sign, wc_MlDsaKey_Verify

Impact: For Rust FFI wrappers, the standard Verifier trait takes &self (shared/immutable reference). There is no safe way to obtain *mut from &self without interior mutability, so every key type that backs sign or verify must be wrapped in UnsafeCell, propagating !Sync throughout the key hierarchy. This is a significant ergonomic burden.

The same pattern affects other language FFI wrappers (Python, Go, C++) that distinguish const/non-const or immutable/mutable references.

Suggested approach: Extend const-correctness to the sign/verify function set as an ongoing effort. The Ed448 DER functions were already fixed in PR #10372 as a contained starting point.

Migrated from internal tracking (ZD-21739).

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions