mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 12:10:34 +00:00
DSM-PKR getter setter structure
This commit is contained in:
parent
7f3202be8e
commit
656684e396
@ -341,7 +341,7 @@ void osnma_msg_receiver::process_dsm_message(const std::vector<uint8_t>& dsm_msg
|
|||||||
{
|
{
|
||||||
p_dk_truncated.push_back(hash[i]);
|
p_dk_truncated.push_back(hash[i]);
|
||||||
}
|
}
|
||||||
// check DS signature
|
// Check that the padding bits received match the computed values
|
||||||
if (d_osnma_data.d_dsm_kroot_message.p_dk == p_dk_truncated)
|
if (d_osnma_data.d_dsm_kroot_message.p_dk == p_dk_truncated)
|
||||||
{
|
{
|
||||||
bool authenticated = d_crypto->verify_signature(message, d_osnma_data.d_dsm_kroot_message.ds);
|
bool authenticated = d_crypto->verify_signature(message, d_osnma_data.d_dsm_kroot_message.ds);
|
||||||
@ -371,7 +371,7 @@ void osnma_msg_receiver::process_dsm_message(const std::vector<uint8_t>& dsm_msg
|
|||||||
else if (d_osnma_data.d_dsm_header.dsm_id >= 12 && d_osnma_data.d_dsm_header.dsm_id < 16)
|
else if (d_osnma_data.d_dsm_header.dsm_id >= 12 && d_osnma_data.d_dsm_header.dsm_id < 16)
|
||||||
{
|
{
|
||||||
LOG(WARNING) << "OSNMA: DSM-PKR message received.";
|
LOG(WARNING) << "OSNMA: DSM-PKR message received.";
|
||||||
// DSM-PKR message
|
// Save DSM-PKR message
|
||||||
d_osnma_data.d_dsm_pkr_message.nb_dp = d_dsm_reader->get_number_blocks_index(dsm_msg[0]);
|
d_osnma_data.d_dsm_pkr_message.nb_dp = d_dsm_reader->get_number_blocks_index(dsm_msg[0]);
|
||||||
d_osnma_data.d_dsm_pkr_message.mid = d_dsm_reader->get_mid(dsm_msg);
|
d_osnma_data.d_dsm_pkr_message.mid = d_dsm_reader->get_mid(dsm_msg);
|
||||||
for (int k = 0; k > 128; k++)
|
for (int k = 0; k > 128; k++)
|
||||||
@ -424,7 +424,17 @@ void osnma_msg_receiver::process_dsm_message(const std::vector<uint8_t>& dsm_msg
|
|||||||
<< ", TOW=" << static_cast<uint32_t>(d_osnma_data.d_dsm_kroot_message.towh_k) * 3600
|
<< ", TOW=" << static_cast<uint32_t>(d_osnma_data.d_dsm_kroot_message.towh_k) * 3600
|
||||||
<< " received" << std::endl;
|
<< " received" << std::endl;
|
||||||
// C: NPK verification against Merkle tree root.
|
// C: NPK verification against Merkle tree root.
|
||||||
d_public_key_verified = verify_dsm_pkr(d_osnma_data.d_dsm_pkr_message);
|
if (!d_public_key_verified)
|
||||||
|
{
|
||||||
|
bool verification = verify_dsm_pkr(d_osnma_data.d_dsm_pkr_message);
|
||||||
|
if (verification)
|
||||||
|
{
|
||||||
|
d_public_key_verified = true;
|
||||||
|
d_crypto->set_public_key(d_osnma_data.d_dsm_pkr_message.npk);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -872,7 +882,6 @@ void osnma_msg_receiver::process_mack_message(const std::shared_ptr<OSNMA_msg>&
|
|||||||
|
|
||||||
bool osnma_msg_receiver::verify_dsm_pkr(DSM_PKR_message message)
|
bool osnma_msg_receiver::verify_dsm_pkr(DSM_PKR_message message)
|
||||||
{
|
{
|
||||||
// TODO create leafe base message m_i
|
|
||||||
// TODO create function for recursively apply hash
|
// TODO create function for recursively apply hash
|
||||||
|
|
||||||
// build base leaf m_i
|
// build base leaf m_i
|
||||||
|
@ -598,3 +598,26 @@ std::vector<uint8_t> Gnss_Crypto::getMerkleRoot(const std::vector<std::vector<ui
|
|||||||
}
|
}
|
||||||
return new_merkle[0];
|
return new_merkle[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Gnss_Crypto::set_public_key(const std::vector<uint8_t>& publicKey)
|
||||||
|
{
|
||||||
|
#if USE_OPENSSL_FALLBACK
|
||||||
|
// TODO - convert to OSSL PubKey format
|
||||||
|
#else
|
||||||
|
// GNU-TLS
|
||||||
|
// TODO - convert to gnutls_pubkey_st
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> Gnss_Crypto::get_public_key()
|
||||||
|
{
|
||||||
|
#if USE_OPENSSL_FALLBACK
|
||||||
|
// TODO
|
||||||
|
#else
|
||||||
|
// GNU-TLS
|
||||||
|
// TODO
|
||||||
|
#endif
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
@ -55,7 +55,8 @@ public:
|
|||||||
return d_x_4_0;
|
return d_x_4_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// void set_public_key(const std::vector<uint8_t>& publickey);
|
void set_public_key(const std::vector<uint8_t>& publickey);
|
||||||
|
static std::vector<uint8_t> get_public_key();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if USE_OPENSSL_FALLBACK
|
#if USE_OPENSSL_FALLBACK
|
||||||
|
Loading…
Reference in New Issue
Block a user