Skip to content

Conversation

@akgamerz790
Copy link
Contributor

This PR fixes the logic error in the issuer_or_subject_length function described in issue #30.

Problem:
The else clause was incorrectly attached to the if common: statement, meaning the TypeError would only be raised if the common parameter was falsy, rather than checking if any certificate information was provided.

Solution:
Changed the logic to check if not tot_len: after all parameters have been processed, ensuring the TypeError is raised when no certificate information is provided, regardless of which parameter is missing.

Changes:

  • Fixed incorrect else clause placement in issuer_or_subject_length function
  • The function now properly validates that at least one certificate parameter has a value

Fixes #30

akgamerz790 and others added 3 commits November 2, 2025 11:20
The else clause was attached to the 'if common:' statement instead of
checking the total length. This change ensures the TypeError is raised
when no certificate information is provided, regardless of which
parameter is missing.

Fixes adafruit#30
@dhalbert dhalbert merged commit 9eb8714 into adafruit:main Nov 2, 2025
1 check passed
Copy link
Contributor

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

Thanks for the fix. I made it more general so it also checks for accidental negative lengths. I also changed it to a ValueError, because the problem is with the value, not the type.

adafruit-adabot pushed a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Nov 5, 2025
Updating https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15 to 3.0.2 from 3.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_ADS1x15#107 from pantheraleo-7/type-hint-forward-reference

Updating https://github.com/adafruit/Adafruit_CircuitPython_ATECC to 1.3.0 from 1.2.25:
  > Merge pull request adafruit/Adafruit_CircuitPython_ATECC#38 from CaptainHaddock2016/patch-1
  > Merge pull request adafruit/Adafruit_CircuitPython_ATECC#40 from akgamerz790/fix-issuer-subject-length-bug
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.

Incorrect check in adafruit_atecc_asn1.py:issuer_or_subject_length

2 participants