feat: enable oscore credentials lookup and storage#1911
Conversation
|
It is worth installing and running pre-commit to tidy up the source formatting. |
fdc8821 to
42c2033
Compare
|
I suggest that you go through all the failed tasks and fix the associated issue before doing the next push. There is some overlap, but a lot of discrete issues that need to get fixed. |
3b6f3cd to
bd0d278
Compare
Apologies for the spam, I am used to that all runs are canceled automatically if a new push has triggered it. |
bd0d278 to
23a3852
Compare
57a1bb3 to
d2cd11c
Compare
|
@mrdeep1 please have another look. I will finalize it next week, but please check if this follows the appropriate format. For now maybe focus on the API expansions in coap_oscore and the general flow. I will cleanup some internals next week, so it should then be ready for final scrutiny should this approach be fine. |
c70a91d to
e094227
Compare
Agreed. One of the reasons for doing #1952 as
If you wrap any callback invocations with
I think I would persevere with 2 at this point. |
39daed9 to
4c7c7cb
Compare
|
@mrdeep1 update accordingly, dropped the API extensions besides register handlers. |
4c7c7cb to
a5daf79
Compare
mrdeep1
left a comment
There was a problem hiding this comment.
Thanks for doing this work.
I'm currently running regression tests to see if any issues raised.
|
Looks great! I have a question regarding the order of execution of finding OSC ctx using external callback and libcoap's RAM. Why this order? For me it seems that we should first search libcoap's RAM and then use external callback if no OSC ctx was found. If you imagine that you have external storage (like FLASH memory) thta you are using to persist OSC ctx through devices reboots, then it would be better to reach to RAM first and if OSC ctx is not available in RAM then reach to FLASH memory. For embedded devices reading FLASH would be suboptimal. |
|
@magdalenaszumny thanks for the feedback. If you consider the API extension to only focus on storage in flash, then I agree. But the main feature of the integration is to allow to expand or even potentially replace the libcoap internal storage. With this inital goal, it seemed more appropriate to call the lookup function first and keeping the control by the application. If we call the lookup function first, it allows the integrator of the function to control the behavior, if we call the internal lookup first, the control moves back to libcoap. However, the PR has been through a few iterations. By example, reusing the libcoap provided external coap_oscore_conf_t type and requiring the textual format (for now). So how it is currently, its seems follow more of a fallback structure. But the inital idea was to prioritize external storage as the "source of truth.". I am open to change if the current order seems to not provide a clear benefit, given the full context. @mrdeep1 feel free to add your PoV here aswell. |
Thank you for explanation! I think that our use cases are similar but different. In the future we would like to contribute to libcoap possibility to restore OSCORE context from the flash (or some other place). I think the flow would be very similar, but it would have to be done only if OSCORE context is not found in libcoap and then it would serve as fallback. I wonder if it would be possible to have one solution for both problems. |
Is it possible for the application layer to decide whether to get the appropriate information out of RAM / Flash? |
I think it should be possible, but probably it would require to first search through libcoap's RAM to check if there is a context. If context is not found in libcoap's RAM then we would search in FLASH. |
|
I have started on testing using the new functionality - apologies for taking so long to get around to it. |
|
I'm in the process of providing a reasonable number of changes to get this working properly and will generate a diff file against this PR.
are some of the areas updated. As there is a large overhead of creating the oscore context every packet, I have moved the find_cb to after checking if the oscore context already exists. |
|
Apologies for taking so long. The example coap-server's This should satisfy the FLASH requirements. patch1.txt contains the suggested changes to 98b7a84 - there are a fair number of them.
I'm not sure why With the 2 new set functions, I am not sure that we need to be able configure |
|
I will look into the patch tomorrow and cherry-pick it, while provide some background information and feature preferences, which are important to me. Wont get to it today |
Add reference counting to recipient contexts so they can be safely removed while still in use by active sessions. Expose callback hooks for credential lookup, echo, and sequence storage to allow custom backends. Expand example server to demonstrate the external storage via a simple file based database. Expand coap_oscore_rcp_conf_t to enable settings preconfigured echo value, sequence counter and window value as uint64 Enable temporary credentials returned by the find function and are destroyed after use.
98b7a84 to
6948dba
Compare
|
I rebased and changes attached as fixup. Nice approach with reusing the existing session About storing the echo. I was a bit conservative, was not sure if it is enought just using the session. With the added change, we might get away of not needing to store the echo challenge in the external storage. Setting the echo challange was always related to, ensuring that the echo information is kept. Since, as you identified, for each request the security credentials are retrieved from the external storage. Lastly, seems we only check the |
|
To keep the scan-build happy, the following needs to be applied Otherwise, you have all my changes integrated.
Good question. I did not check out Appendix B.2 usage. It is where ID Context is actually used and changed that may need to be checked. |
6948dba to
63cf038
Compare
|
Generally it seems Appendix 2.B will be depricated in the future with https://datatracker.ietf.org/doc/draft-ietf-core-oscore-key-update/. I am not at all familiar with KUDOS. It seems however, it also uses the randomized context id. |
|
This seems to be working for OSCORE B.2. At some point the commits need to be squashed into a single commit. The storage of the |
Work related to #1892
Enabling:
-OOPEN: