Skip to content

Commit 9e608fe

Browse files
committed
fix: raise ValueError instead of TypeError in issuer_or_subject_length (#30)
Corrected the check when all issuer/subject fields are empty. Previously raised TypeError (misleading), now raises ValueError. Fixes #30.
1 parent 7f69057 commit 9e608fe

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

adafruit_atecc/adafruit_atecc_asn1.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ def issuer_or_subject_length(
268268
tot_len += 11 + len(org_unit)
269269
if common:
270270
tot_len += 11 + len(common)
271-
else:
272-
raise TypeError("Provided length must be > 0")
273-
return tot_len
271+
272+
if tot_len == 0:
273+
raise TypeError("issuer_or_subject_length cannot be zero")
274+
275+
return tot_len

0 commit comments

Comments
 (0)