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

Decrypting an Encrypt0 message #125

Open
nevelis opened this issue Mar 17, 2021 · 2 comments
Open

Decrypting an Encrypt0 message #125

nevelis opened this issue Mar 17, 2021 · 2 comments

Comments

@nevelis
Copy link

nevelis commented Mar 17, 2021

Hey all - I'm just getting started with cose-c & I'm trying to figure out how to decrypt an Encrypt0 message. I'm trying to do something similar to this Python code: https://pycose.readthedocs.io/en/latest/examples.html#cose-encrypt0

I'm digging around the tests to see if I can figure this out but any starting point for loading a shared key & decrypting this type of message would be helpful. Are there any examples or code snippets to do this in C? Thanks in advance!

Aaron

@nevelis
Copy link
Author

nevelis commented Mar 20, 2021

I was able to figure out how to decrypt a token generated in Python using the following code in C: https://github.com/Network-Tokens/example-tokens/blob/master/src/cose-test/main.cc

I've noticed that COSE_Encrypt_GetContent() returns a zero-length, even though it returns a valid pointer to the data. It looks like it is null-terminated so I'm able to use strlen() but I suspect this might be problematic... Any suggestions? This seems like a bug. The unit tests stop right before they extract & validate the data.

@nevelis
Copy link
Author

nevelis commented May 3, 2021

I've created #126 to fix the zero-length issue (it finally became a problem when using binary data & strlen() was stopping early).

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

No branches or pull requests

1 participant