mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-10-30 22:56:22 +00:00
Reorder code
This commit is contained in:
parent
2649406538
commit
28474b824f
@ -438,47 +438,7 @@ void osnma_msg_receiver::read_mack_block(const std::shared_ptr<OSNMA_msg>& osnma
|
|||||||
{
|
{
|
||||||
read_mack_header();
|
read_mack_header();
|
||||||
read_mack_body();
|
read_mack_body();
|
||||||
d_old_mack_message.push_back(d_osnma_data.d_mack_message);
|
process_mack_message(osnma_msg);
|
||||||
|
|
||||||
// MACSEQ validation
|
|
||||||
uint32_t GST_SF = osnma_msg->TOW_sf0;
|
|
||||||
|
|
||||||
// Are there flexible tags?
|
|
||||||
std::vector<uint8_t> m(5);
|
|
||||||
m[0] = static_cast<uint8_t>(osnma_msg->PRN); // PRN_A
|
|
||||||
m[1] = ((GST_SF & 0xF000) >> 24);
|
|
||||||
m[2] = ((GST_SF & 0x0F00) >> 16);
|
|
||||||
m[3] = ((GST_SF & 0x00F0) >> 8);
|
|
||||||
m[4] = (GST_SF & 0x000F);
|
|
||||||
|
|
||||||
std::vector<uint8_t> applicable_key;
|
|
||||||
// if ADKD=12, pick d_old_mack_message.front() if d_old_mack_message[10] is full
|
|
||||||
// otherwise pick d_old_mack_message.back()
|
|
||||||
applicable_key = d_old_mack_message.back().key;
|
|
||||||
std::vector<uint8_t> mac;
|
|
||||||
if (d_osnma_data.d_dsm_kroot_message.mf == 0)
|
|
||||||
{
|
|
||||||
mac = d_crypto->computeHMAC_SHA_256(applicable_key, m);
|
|
||||||
}
|
|
||||||
else if (d_osnma_data.d_dsm_kroot_message.mf == 1)
|
|
||||||
{
|
|
||||||
mac = d_crypto->computeCMAC_AES(applicable_key, m);
|
|
||||||
}
|
|
||||||
uint16_t mac_msb = 0;
|
|
||||||
if (!mac.empty())
|
|
||||||
{
|
|
||||||
mac_msb = (mac[0] << 8) + mac[1];
|
|
||||||
}
|
|
||||||
uint16_t computed_macseq = (mac_msb & 0x0FFF);
|
|
||||||
int num_tags_added = 0;
|
|
||||||
if (computed_macseq == d_osnma_data.d_mack_message.header.macseq)
|
|
||||||
{
|
|
||||||
std::cout << "OSNMA: MACSEQ authenticated for PRN_A "
|
|
||||||
<< osnma_msg->PRN << " with WN="
|
|
||||||
<< osnma_msg->WN_sf0 << ", TOW="
|
|
||||||
<< osnma_msg->TOW_sf0 << ". Tags added: "
|
|
||||||
<< num_tags_added << std::endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -714,3 +674,49 @@ void osnma_msg_receiver::read_mack_body()
|
|||||||
d_osnma_data.d_mack_message.tag_and_info[k].tag_info.cop = cop;
|
d_osnma_data.d_mack_message.tag_and_info[k].tag_info.cop = cop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void osnma_msg_receiver::process_mack_message(const std::shared_ptr<OSNMA_msg>& osnma_msg)
|
||||||
|
{
|
||||||
|
d_old_mack_message.push_back(d_osnma_data.d_mack_message);
|
||||||
|
|
||||||
|
// MACSEQ validation
|
||||||
|
uint32_t GST_SF = osnma_msg->TOW_sf0;
|
||||||
|
|
||||||
|
// Are there flexible tags?
|
||||||
|
std::vector<uint8_t> m(5);
|
||||||
|
m[0] = static_cast<uint8_t>(osnma_msg->PRN); // PRN_A
|
||||||
|
m[1] = ((GST_SF & 0xF000) >> 24);
|
||||||
|
m[2] = ((GST_SF & 0x0F00) >> 16);
|
||||||
|
m[3] = ((GST_SF & 0x00F0) >> 8);
|
||||||
|
m[4] = (GST_SF & 0x000F);
|
||||||
|
|
||||||
|
std::vector<uint8_t> applicable_key;
|
||||||
|
// if ADKD=12, pick d_old_mack_message.front() if d_old_mack_message[10] is full
|
||||||
|
// otherwise pick d_old_mack_message.back()
|
||||||
|
applicable_key = d_old_mack_message.back().key;
|
||||||
|
std::vector<uint8_t> mac;
|
||||||
|
if (d_osnma_data.d_dsm_kroot_message.mf == 0)
|
||||||
|
{
|
||||||
|
mac = d_crypto->computeHMAC_SHA_256(applicable_key, m);
|
||||||
|
}
|
||||||
|
else if (d_osnma_data.d_dsm_kroot_message.mf == 1)
|
||||||
|
{
|
||||||
|
mac = d_crypto->computeCMAC_AES(applicable_key, m);
|
||||||
|
}
|
||||||
|
uint16_t mac_msb = 0;
|
||||||
|
if (!mac.empty())
|
||||||
|
{
|
||||||
|
mac_msb = (mac[0] << 8) + mac[1];
|
||||||
|
}
|
||||||
|
uint16_t computed_macseq = (mac_msb & 0x0FFF);
|
||||||
|
int num_tags_added = 0;
|
||||||
|
if (computed_macseq == d_osnma_data.d_mack_message.header.macseq)
|
||||||
|
{
|
||||||
|
std::cout << "OSNMA: MACSEQ authenticated for PRN_A "
|
||||||
|
<< osnma_msg->PRN << " with WN="
|
||||||
|
<< osnma_msg->WN_sf0 << ", TOW="
|
||||||
|
<< osnma_msg->TOW_sf0 << ". Tags added: "
|
||||||
|
<< num_tags_added << std::endl;
|
||||||
|
}
|
||||||
|
}
|
@ -64,10 +64,11 @@ private:
|
|||||||
void read_nma_header(uint8_t nma_header);
|
void read_nma_header(uint8_t nma_header);
|
||||||
void read_dsm_header(uint8_t dsm_header);
|
void read_dsm_header(uint8_t dsm_header);
|
||||||
void read_dsm_block(const std::shared_ptr<OSNMA_msg>& osnma_msg);
|
void read_dsm_block(const std::shared_ptr<OSNMA_msg>& osnma_msg);
|
||||||
void read_mack_block(const std::shared_ptr<OSNMA_msg>& osnma_msg);
|
|
||||||
void process_dsm_message(const std::vector<uint8_t>& dsm_msg, const std::shared_ptr<OSNMA_msg>& osnma_msg);
|
void process_dsm_message(const std::vector<uint8_t>& dsm_msg, const std::shared_ptr<OSNMA_msg>& osnma_msg);
|
||||||
|
void read_mack_block(const std::shared_ptr<OSNMA_msg>& osnma_msg);
|
||||||
void read_mack_header();
|
void read_mack_header();
|
||||||
void read_mack_body();
|
void read_mack_body();
|
||||||
|
void process_mack_message(const std::shared_ptr<OSNMA_msg>& osnma_msg);
|
||||||
|
|
||||||
boost::circular_buffer<MACK_message> d_old_mack_message;
|
boost::circular_buffer<MACK_message> d_old_mack_message;
|
||||||
std::unique_ptr<OSNMA_DSM_Reader> d_dsm_reader;
|
std::unique_ptr<OSNMA_DSM_Reader> d_dsm_reader;
|
||||||
|
Loading…
Reference in New Issue
Block a user