Skip to content

Incorrect check in adafruit_atecc_asn1.py:issuer_or_subject_length #30

Open
@brass75

Description

@brass75

In the issuer_or_subject_length function there is a check for the presence of one of the parameters where the check should really be that at least one parameter was passed with a value:

def issuer_or_subject_length(country, state_prov, city, org, org_unit, common):
    """Returns total length of provided certificate information."""
    tot_len = 0
    if country:
        tot_len += 11 + len(country)
    if state_prov:
        tot_len += 11 + len(state_prov)
    if city:
        tot_len += 11 + len(city)
    if org:
        tot_len += 11 + len(org)
    if org_unit:
        tot_len += 11 + len(org_unit)
    if common:
        tot_len += 11 + len(common)
    else:
        raise TypeError("Provided length must be > 0")
    return tot_len

The else on the bottom should be changed to if not tot_len or the equivalent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    HacktoberfestDigitalOcean's HacktoberfestbugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions