Skip to content

Raise specialized WolfCryptApiError for failed API calls.#110

Merged
dgarske merged 3 commits into
wolfSSL:masterfrom
roberthdevries:special-wc-api-retval-exceptions
May 8, 2026
Merged

Raise specialized WolfCryptApiError for failed API calls.#110
dgarske merged 3 commits into
wolfSSL:masterfrom
roberthdevries:special-wc-api-retval-exceptions

Conversation

@roberthdevries
Copy link
Copy Markdown
Contributor

This exception takes the return value and converts that to a human-readable string (if error string support is compiled in.)

The specialized exception is derived from WolfCryptError meaning that existing users will not notice the difference except for the nicer description.

This exception takes the return value and converts that to
a human-readable string (if error string support is compiled in.)

The specialized exception is derived from WolfCryptError meaning
that existing users will not notice the difference except for the
nicer description.
Copy link
Copy Markdown
Contributor

@JeremiahM37 JeremiahM37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skoll Code Review

Scan type: review
Overall recommendation: COMMENT
Findings: 6 total — 3 posted, 3 skipped
2 finding(s) posted as inline comments (see file-level comments below)

Posted findings

  • [Medium] Inconsistent conversion in ECC decode_key: only one of two adjacent size checks was migratedwolfcrypt/ciphers.py:1267-1272
  • [Medium] WolfCryptApiError fed non-error-code values (sizes, lengths) — produces misleading messageswolfcrypt/ciphers.py:741,904,1269; wolfcrypt/asn.py:56-62
  • [Medium] Bug exposure: RsaPrivate.make_key passes wrong variable as err_codewolfcrypt/ciphers.py:874

Skipped findings

  • [Medium] No tests for the new WolfCryptApiError class
  • [Low] Behavioral change in _Hmac._init: error condition narrowed from != 0 to < 0
  • [Low] Inconsistent conversion in asn.py: make_signature and hash_oid_from_class left as WolfCryptError

Review generated by Skoll

Comment thread wolfcrypt/ciphers.py
Comment thread wolfcrypt/ciphers.py
If the size return value is negative, an error is detected. In that case raise an exception. Even though a zero is not a valid size value, it would indicate success in other cases. But a 0 return value would not make much sense as a return value for this function.
@dgarske dgarske merged commit 4ec45a6 into wolfSSL:master May 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants