Replaced byte_buffer by array in PDCP base

master
Pedro Alvarez 6 years ago committed by Andre Puschmann
parent 8c10eabf23
commit dd56d08269

@ -40,6 +40,8 @@ namespace srslte {
#define PDCP_PDU_TYPE_PDCP_STATUS_REPORT 0x0 #define PDCP_PDU_TYPE_PDCP_STATUS_REPORT 0x0
#define PDCP_PDU_TYPE_INTERSPERSED_ROHC_FEEDBACK_PACKET 0x1 #define PDCP_PDU_TYPE_INTERSPERSED_ROHC_FEEDBACK_PACKET 0x1
#define PDCP_MAX_SDU_SIZE 9000
typedef enum { typedef enum {
PDCP_D_C_CONTROL_PDU = 0, PDCP_D_C_CONTROL_PDU = 0,
PDCP_D_C_DATA_PDU, 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); 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_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); 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) inline uint32_t pdcp_entity_base::HFN(uint32_t count)

@ -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) 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 control plane use RRC encrytion key. If data use user plane key
if (is_srb()) { 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: case CIPHERING_ALGORITHM_ID_EEA0:
break; break;
case CIPHERING_ALGORITHM_ID_128_EEA1: 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); security_128_eea1(&(k_enc[16]), count, cfg.bearer_id - 1, cfg.tx_direction, msg, msg_len, ct_tmp);
memcpy(ct, ct_tmp.msg, msg_len); memcpy(ct, ct_tmp, msg_len);
break; break;
case CIPHERING_ALGORITHM_ID_128_EEA2: 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); security_128_eea2(&(k_enc[16]), count, cfg.bearer_id - 1, cfg.tx_direction, msg, msg_len, ct_tmp);
memcpy(ct, ct_tmp.msg, msg_len); memcpy(ct, ct_tmp, msg_len);
break; break;
default: default:
break; 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) 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 control plane use RRC encrytion key. If data use user plane key
if (is_srb()) { 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: case CIPHERING_ALGORITHM_ID_EEA0:
break; break;
case CIPHERING_ALGORITHM_ID_128_EEA1: 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); security_128_eea1(&k_enc[16], count, cfg.bearer_id - 1, cfg.rx_direction, ct, ct_len, msg_tmp);
memcpy(msg, msg_tmp.msg, ct_len); memcpy(msg, msg_tmp, ct_len);
break; break;
case CIPHERING_ALGORITHM_ID_128_EEA2: 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); security_128_eea2(&k_enc[16], count, cfg.bearer_id - 1, cfg.rx_direction, ct, ct_len, msg_tmp);
memcpy(msg, msg_tmp.msg, ct_len); memcpy(msg, msg_tmp, ct_len);
break; break;
default: default:
break; break;

Loading…
Cancel
Save