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

Stop generating labels with NUL bytes at the end #31

Closed
dmjones opened this issue Feb 25, 2019 · 2 comments · Fixed by #33
Closed

Stop generating labels with NUL bytes at the end #31

dmjones opened this issue Feb 25, 2019 · 2 comments · Fixed by #33

Comments

@dmjones
Copy link
Contributor

dmjones commented Feb 25, 2019

If users don't pass a label or ID to the key generation functions, one is generated for them. This value will typically have ~20 NUL bytes at the end, which causes problems if users convert to/from strings using string(<some bytes>) and []byte(<the string>). This kind of simple string conversions will discard NUL bytes, resulting in a different label or ID.

We should adjust this behaviour and return non-NUL data. I would suggest generating random bytes, converting to hexadecimal characters, then returning the bytes of that hexadecimal string.

@dmjones
Copy link
Contributor Author

dmjones commented Feb 25, 2019

Of course, I argue strongly in #15 for us to drop key generation and I still intend to do that. But fixing this prior to deprecating those functions seems friendly.

@mrangana
Copy link

mrangana commented Mar 1, 2019

From the pkcs11 spec, the label is of type string.

Section: "4.4 Storage Objects" CKA_LABEL RFC2279 | string | Description of the object (default empty)."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants