Skip to content

OKPKey.__delitem__() allows creation of invalid COSE OKP Key #135

@steffen-kiess

Description

@steffen-kiess

The OKPKey.__delitem__() function has a bug in the if condition. Currently the code

import pycose.keys.curves
key = pycose.keys.OKPKey.generate_key(pycose.keys.curves.Ed25519)
del key[pycose.keys.keyparam.OKPKpX]
del key[pycose.keys.keyparam.OKPKpD]
print(key)

will run and print

<COSE_Key(OKPKey): {'OKPKpCurve': 'Ed25519', 'KpKty': 'KtyOKP'}>

The if in line 249

if self._key_transform(key) == OKPKpX and OKPKpD not in self.store:
should be an elif, otherwise the first if is ignored.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions