Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying location in get_attr() #95

Open
letmaik opened this issue Nov 6, 2022 · 1 comment
Open

Allow specifying location in get_attr() #95

letmaik opened this issue Nov 6, 2022 · 1 comment
Labels
cose attributes Issue related to COSE attributes enhancement New feature or request

Comments

@letmaik
Copy link
Collaborator

letmaik commented Nov 6, 2022

Once #94 is implemented, get_attr(name) will validate any location requirements for standard header parameters. However, some clients may use unknown header parameters or want to enforce some standard header parameters to be in the protected header when not required by the spec.

To support this, get_attr should get another argument to enforce location.

@letmaik letmaik added enhancement New feature or request cose attributes Issue related to COSE attributes labels Nov 6, 2022
@letmaik
Copy link
Collaborator Author

letmaik commented Nov 6, 2022

Alternatively, phdr and uhdr could be included in the API docs. However, accessing those directly would mean that the check in get_attr for disallowing parameters appearing in both buckets would not be done. It might be worth though to move this check to decoding time and reject such messages early on. Then, accessing phdr/uhdr directly would be ok.

if p_attr is not None and u_attr is not None:
raise CoseException("MALFORMED: different values for the same header parameters in the header buckets")

EDIT: pycose transforms parameter labels into class types for known parameters, and leaves unknown ones as-is. One reason that might speak against exposing phdr/uhdr more widely is that there would be no code in between that could allow access of parameters using both their native types as well as class types. This becomes important when new parameters are added to pycose since existing code might have used get_attr(1234) and shouldn't break suddenly. Accessing phdr[1234] would break if suddenly the key for that parameter is a class type. A way to get around this issue would be if the keys were always the labels themselves instead of class types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cose attributes Issue related to COSE attributes enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant