From dd56d0826937850e1ddc4838512271ce33d73000 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 24 Jul 2019 17:20:03 +0100 Subject: [PATCH] Replaced byte_buffer by array in PDCP base --- lib/include/srslte/upper/pdcp_entity_base.h | 3 +++ lib/src/upper/pdcp_entity_base.cc | 24 ++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/include/srslte/upper/pdcp_entity_base.h b/lib/include/srslte/upper/pdcp_entity_base.h index f5b2dc07d..8236e89bf 100644 --- a/lib/include/srslte/upper/pdcp_entity_base.h +++ b/lib/include/srslte/upper/pdcp_entity_base.h @@ -40,6 +40,8 @@ namespace srslte { #define PDCP_PDU_TYPE_PDCP_STATUS_REPORT 0x0 #define PDCP_PDU_TYPE_INTERSPERSED_ROHC_FEEDBACK_PACKET 0x1 +#define PDCP_MAX_SDU_SIZE 9000 + typedef enum { PDCP_D_C_CONTROL_PDU = 0, PDCP_D_C_DATA_PDU, @@ -110,6 +112,7 @@ protected: bool integrity_verify(uint8_t* msg, uint32_t msg_len, uint32_t count, uint8_t* mac); void cipher_encrypt(uint8_t* msg, uint32_t msg_len, uint32_t count, uint8_t* ct); void cipher_decrypt(uint8_t* ct, uint32_t ct_len, uint32_t count, uint8_t* msg); + }; inline uint32_t pdcp_entity_base::HFN(uint32_t count) diff --git a/lib/src/upper/pdcp_entity_base.cc b/lib/src/upper/pdcp_entity_base.cc index 10af6b9a7..da023feb5 100644 --- a/lib/src/upper/pdcp_entity_base.cc +++ b/lib/src/upper/pdcp_entity_base.cc @@ -142,8 +142,8 @@ bool pdcp_entity_base::integrity_verify(uint8_t* msg, uint32_t msg_len, uint32_t void pdcp_entity_base::cipher_encrypt(uint8_t* msg, uint32_t msg_len, uint32_t count, uint8_t* ct) { - byte_buffer_t ct_tmp; - uint8_t* k_enc; + uint8_t* k_enc; + uint8_t ct_tmp[PDCP_MAX_SDU_SIZE]; // If control plane use RRC encrytion key. If data use user plane key if (is_srb()) { @@ -162,12 +162,12 @@ void pdcp_entity_base::cipher_encrypt(uint8_t* msg, uint32_t msg_len, uint32_t c case CIPHERING_ALGORITHM_ID_EEA0: break; case CIPHERING_ALGORITHM_ID_128_EEA1: - security_128_eea1(&(k_enc[16]), count, cfg.bearer_id - 1, cfg.tx_direction, msg, msg_len, ct_tmp.msg); - memcpy(ct, ct_tmp.msg, msg_len); + security_128_eea1(&(k_enc[16]), count, cfg.bearer_id - 1, cfg.tx_direction, msg, msg_len, ct_tmp); + memcpy(ct, ct_tmp, msg_len); break; case CIPHERING_ALGORITHM_ID_128_EEA2: - security_128_eea2(&(k_enc[16]), count, cfg.bearer_id - 1, cfg.tx_direction, msg, msg_len, ct_tmp.msg); - memcpy(ct, ct_tmp.msg, msg_len); + security_128_eea2(&(k_enc[16]), count, cfg.bearer_id - 1, cfg.tx_direction, msg, msg_len, ct_tmp); + memcpy(ct, ct_tmp, msg_len); break; default: break; @@ -177,8 +177,8 @@ void pdcp_entity_base::cipher_encrypt(uint8_t* msg, uint32_t msg_len, uint32_t c void pdcp_entity_base::cipher_decrypt(uint8_t* ct, uint32_t ct_len, uint32_t count, uint8_t* msg) { - byte_buffer_t msg_tmp; - uint8_t* k_enc; + uint8_t* k_enc; + uint8_t msg_tmp[PDCP_MAX_SDU_SIZE]; // If control plane use RRC encrytion key. If data use user plane key if (is_srb()) { @@ -197,12 +197,12 @@ void pdcp_entity_base::cipher_decrypt(uint8_t* ct, uint32_t ct_len, uint32_t cou case CIPHERING_ALGORITHM_ID_EEA0: break; case CIPHERING_ALGORITHM_ID_128_EEA1: - security_128_eea1(&k_enc[16], count, cfg.bearer_id - 1, cfg.rx_direction, ct, ct_len, msg_tmp.msg); - memcpy(msg, msg_tmp.msg, ct_len); + security_128_eea1(&k_enc[16], count, cfg.bearer_id - 1, cfg.rx_direction, ct, ct_len, msg_tmp); + memcpy(msg, msg_tmp, ct_len); break; case CIPHERING_ALGORITHM_ID_128_EEA2: - security_128_eea2(&k_enc[16], count, cfg.bearer_id - 1, cfg.rx_direction, ct, ct_len, msg_tmp.msg); - memcpy(msg, msg_tmp.msg, ct_len); + security_128_eea2(&k_enc[16], count, cfg.bearer_id - 1, cfg.rx_direction, ct, ct_len, msg_tmp); + memcpy(msg, msg_tmp, ct_len); break; default: break;