From a0974f7c730ea1878b4f317669fd9b3017f99882 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 23 Jun 2025 10:02:21 +0200 Subject: [PATCH] nr pdcp security: add a 'decipher' API function --- openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c | 10 ++++++---- openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c index f3402bcf81..41d41cf922 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c @@ -136,10 +136,10 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, } if (entity->has_ciphering) - entity->cipher(entity->security_context, - buffer + header_size + sdap_header_size, - size - (header_size + sdap_header_size), - entity->rb_id, rcvd_count, entity->is_gnb ? 0 : 1); + entity->decipher(entity->security_context, + buffer + header_size + sdap_header_size, + size - (header_size + sdap_header_size), + entity->rb_id, rcvd_count, entity->is_gnb ? 0 : 1); if (entity->has_integrity) { unsigned char integrity[PDCP_INTEGRITY_SIZE] = {0}; @@ -380,10 +380,12 @@ static void nr_pdcp_entity_set_security(struct nr_pdcp_entity_t *entity, if (parameters->ciphering_algorithm == 2) { entity->security_context = nr_pdcp_security_nea2_init(entity->security_keys_and_algos.ciphering_key); entity->cipher = nr_pdcp_security_nea2_cipher; + entity->decipher = nr_pdcp_security_nea2_cipher; entity->free_security = nr_pdcp_security_nea2_free_security; } else if (parameters->ciphering_algorithm == 1) { entity->security_context = nr_pdcp_security_nea1_init(entity->security_keys_and_algos.ciphering_key); entity->cipher = nr_pdcp_security_nea1_cipher; + entity->decipher = nr_pdcp_security_nea1_cipher; entity->free_security = nr_pdcp_security_nea1_free_security; } else { LOG_E(PDCP, "FATAL: only nea1 and nea2 supported for the moment\n"); diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h index f05ba07b02..7f1297ac3e 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h @@ -156,6 +156,9 @@ typedef struct nr_pdcp_entity_t { void (*cipher)(stream_security_context_t *security_context, unsigned char *buffer, int length, int bearer, uint32_t count, int direction); + void (*decipher)(stream_security_context_t *security_context, + unsigned char *buffer, int length, + int bearer, uint32_t count, int direction); void (*free_security)(stream_security_context_t *security_context); stream_security_context_t *integrity_context; void (*integrity)(stream_security_context_t *integrity_context,