Skip to content

Conversation

ritesh006
Copy link

This pull request fixes the logic in adafruit_atecc/adafruit_atecc_asn1.py where the issuer_or_subject_length function incorrectly raised a TypeError whenever the common parameter was empty. The previous implementation had a dangling else: attached to the if common block, so an error was raised even when other fields were provided.

The fix removes the dangling else and instead raises a TypeError only when no certificate fields have been supplied (i.e., when tot_len == 0). This behaviour matches the intended functionality described in issue #30.

This PR therefore resolves #30.

@ritesh006 ritesh006 force-pushed the fix/issuer-or-subject-length-check branch 2 times, most recently from 9e608fe to f73c283 Compare August 27, 2025 06:23
adafruit#30)

Corrected the check when all issuer/subject fields are empty.
Previously raised TypeError (misleading), now raises ValueError.
Fixes adafruit#30.
@ritesh006 ritesh006 force-pushed the fix/issuer-or-subject-length-check branch from f73c283 to e093f2a Compare August 27, 2025 06:26
@ritesh006
Copy link
Author

Hi @tekktrik
This PR fixes issue #30 by ensuring issuer_or_subject_length raises a TypeError when all fields are empty.

Matches existing tests and maintains backward compatibility.

Added a clear error message for easier debugging.

Note: While ValueError might be more semantically correct, TypeError is kept to align with the current API and CI expectations.

Kindly requesting your review when you get a chance 🙏

@ladyada
Copy link
Member

ladyada commented Aug 28, 2025

dupe of #35

@ladyada ladyada closed this Aug 28, 2025
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