From 9a40fb11ca424b0b40901c25e134f4c285b7c348 Mon Sep 17 00:00:00 2001 From: Patryk Jarosz Date: Wed, 6 Mar 2024 09:08:35 +0000 Subject: [PATCH] Revert "Added user-defined callback for finding oscore context" This reverts commit 8e9d700f1df941a518d4aab996b12884ca355452. --- include/coap3/coap_net_internal.h | 31 ------------------------------- src/coap_net.c | 13 +------------ src/coap_oscore.c | 5 +---- src/oscore/oscore_context.c | 7 ------- 4 files changed, 2 insertions(+), 54 deletions(-) diff --git a/include/coap3/coap_net_internal.h b/include/coap3/coap_net_internal.h index 0db4e153e8..6a2e8bff32 100644 --- a/include/coap3/coap_net_internal.h +++ b/include/coap3/coap_net_internal.h @@ -28,24 +28,6 @@ * @{ */ -/** - * Optional user callback to be used, when oscore_find_context can't find any context. - * Could be used to check external storage (e.g. FLASH). - * - * @param c_context The CoAP COntext to search. - * @param rcpkey_id The Recipient kid. - * @param ctxkey_id The ID Context to match (or NULL if no check). - * @param oscore_r2 Partial id_context to match against or NULL. - * @param recipient_ctx The recipient context to update. - * - * return The OSCORE context and @p recipient_ctx updated, or NULL is error. - */ -typedef oscore_ctx_t * (*external_oscore_find_context_handler_t)(const coap_context_t *c_context, - const coap_bin_const_t rcpkey_id, - const coap_bin_const_t *ctxkey_id, - uint8_t *oscore_r2, - oscore_recipient_ctx_t **recipient_ctx); - /** * Queue entry */ @@ -111,8 +93,6 @@ struct coap_context_t { #endif /* WITH_LWIP */ #if COAP_OSCORE_SUPPORT struct oscore_ctx_t *p_osc_ctx; /**< primary oscore context */ - external_oscore_find_context_handler_t external_oscore_find_context_handler; - /**< Called when oscore_find_context didn't find any context*/ #endif /* COAP_OSCORE_SUPPORT */ #if COAP_CLIENT_SUPPORT @@ -450,17 +430,6 @@ coap_mid_t coap_send_internal(coap_session_t *session, coap_pdu_t *pdu); */ int coap_client_delay_first(coap_session_t *session); -#if COAP_OSCORE_SUPPORT -/** - * Register optional user callback to be used, when oscore_find_context can't find any context. - * Callback could be used to check external storage (e.g. FLASH). - * - * @param ctx The current coap context to use. - * @param handler User callback. - */ -void coap_register_find_context_handler(coap_context_t *ctx, external_oscore_find_context_handler_t handler); -#endif - /** @} */ extern int coap_started; diff --git a/src/coap_net.c b/src/coap_net.c index 7234340a4e..625fd4e5d0 100644 --- a/src/coap_net.c +++ b/src/coap_net.c @@ -576,15 +576,6 @@ coap_new_context(const coap_address_t *listen_addr) { #endif /* COAP_EPOLL_SUPPORT || COAP_SERVER_SUPPORT */ } -#if COAP_OSCORE_SUPPORT -void -coap_register_find_context_handler(coap_context_t *ctx, external_oscore_find_context_handler_t handler) -{ - assert(ctx); - ctx->external_oscore_find_context_handler = handler; -} -#endif - void coap_set_app_data(coap_context_t *ctx, void *app_data) { assert(ctx); @@ -726,9 +717,7 @@ coap_option_check_critical(coap_session_t *session, case COAP_OPTION_OSCORE: /* Valid critical if doing OSCORE */ #if COAP_OSCORE_SUPPORT - /* Only accept OSCORE option if any OSCORE context is available, - or the user provided an external handler for finding the context. */ - if ((ctx->p_osc_ctx) || (ctx->external_oscore_find_context_handler)) + if (ctx->p_osc_ctx) break; #endif /* COAP_OSCORE_SUPPORT */ /* Fall Through */ diff --git a/src/coap_oscore.c b/src/coap_oscore.c index 6f0c57a5b6..e0fb229474 100644 --- a/src/coap_oscore.c +++ b/src/coap_oscore.c @@ -808,10 +808,7 @@ coap_oscore_decrypt_pdu(coap_session_t *session, if (opt == NULL) return NULL; - /* OSCORE is enabled if any OSCORE context is available, - or the user provided an external handler for finding the context. */ - if ((session->context->p_osc_ctx == NULL) && - (session->context->external_oscore_find_context_handler == NULL)) { + if (session->context->p_osc_ctx == NULL) { coap_log_warn("OSCORE: Not enabled\n"); if (!coap_request) coap_handle_event(session->context, diff --git a/src/oscore/oscore_context.c b/src/oscore/oscore_context.c index 14d58adf94..f9cd856235 100644 --- a/src/oscore/oscore_context.c +++ b/src/oscore/oscore_context.c @@ -227,13 +227,6 @@ oscore_find_context(const coap_context_t *c_context, } /* while rpt */ pt = pt->next; } /* end while */ - - /* no context was found in libcoap RAM - call user function to also check external storage (e.g. FLASH) */ - if (c_context->external_oscore_find_context_handler) - { - return c_context->external_oscore_find_context_handler(c_context, rcpkey_id, ctxkey_id, oscore_r2, recipient_ctx); - } - return NULL; }