Skip to content

fix: use issubclass instead of isinstance in _set_signature_type#800

Merged
texastony merged 1 commit intomasterfrom
fix/set-signature-type-issubclass
Apr 22, 2026
Merged

fix: use issubclass instead of isinstance in _set_signature_type#800
texastony merged 1 commit intomasterfrom
fix/set-signature-type-issubclass

Conversation

@texastony
Copy link
Copy Markdown
Contributor

@texastony texastony commented Apr 22, 2026

Summary

Replace isinstance(signing_algorithm_info, type(ec.EllipticCurve)) with issubclass(signing_algorithm_info, ec.EllipticCurve) wrapped in try/except TypeError in _PrehashingAuthenticator._set_signature_type.

The old check used isinstance against ABCMeta which was fragile and semantically incorrect for checking class hierarchy.

Changes

  • authentication.py: Fix _set_signature_type to use issubclass with TypeError guard
  • test_crypto_prehashing_authenticator.py: Use real EC curve classes instead of MagicMock; add test_set_signature_type_elliptic_curve_known_value
  • test_crypto_authentication_signer.py: Update mock patterns to use real ec.SECP256R1 for signing_algorithm_info
  • test_crypto_authentication_verifier.py: Same mock pattern fix

Testing

All 4228 unit tests pass.

Based on #794, extended to also fix signer/verifier tests that used the same broken mock pattern.

Closes #794 ; stages #793 for release.

@texastony texastony requested a review from a team as a code owner April 22, 2026 19:55
Replace isinstance(signing_algorithm_info, type(ec.EllipticCurve)) with
issubclass(signing_algorithm_info, ec.EllipticCurve) wrapped in try/except
TypeError. The old check used isinstance against ABCMeta which was fragile
and semantically incorrect for checking class hierarchy.

Update tests to use real EC curve classes (ec.SECP256R1, ec.SECP384R1)
instead of MagicMock with spec=ec.EllipticCurve, which masked the bug.

Based on PR #794.
@texastony texastony force-pushed the fix/set-signature-type-issubclass branch from 0dbd106 to 062e19a Compare April 22, 2026 20:36
Copy link
Copy Markdown

@sharmabikram sharmabikram left a comment

Choose a reason for hiding this comment

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

Looks good to me

@texastony texastony merged commit c00a58c into master Apr 22, 2026
214 checks 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.

2 participants