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

Cannot create a signed message in detached mode #129

Open
hmueller314 opened this issue Sep 29, 2021 · 1 comment
Open

Cannot create a signed message in detached mode #129

hmueller314 opened this issue Sep 29, 2021 · 1 comment

Comments

@hmueller314
Copy link

I am trying to create a sign1 message in detached mode. According to rfc8152 this is done by using a "nil" value for the message content. Following your example code I am inserting a node of the form

node = cn_cbor_data_create(NULL, 0, CBOR_CONTEXT_PARAM_COMMA NULL);
node->type = CN_CBOR_NULL;

for the message content in your json parser (test/json.cpp) but I cannot create a signed message because the call to COSE_Sign1_SetContent fails.

@hmueller314
Copy link
Author

I think I found a solution. For detached mode follow the "normal" flow, for example BuildSign1Message in Sign_test.cpp. Before encoding the message (e.g. using COSE_Encode(hSignObj.ToCOSE(), nullptr, 0, 0)) replace the payload with a "nil" value. This can be done using the following code fragment:

COSE_Sign1Message* pMessage = (COSE_Sign1Message*)h;
cn_cbor* cb_value = cn_cbor_null_create(CBOR_CONTEXT_PARAM_COMMA nullptr);
_COSE_array_replace(&pMessage->m_message, cb_value, INDEX_BODY, CBOR_CONTEXT_PARAM_COMMA nullptr);

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