1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-10-30 06:36:21 +00:00

[TAS-240][FEAT] Implement TESLA Chain Renewal and Revocation II

* revocation sucessfully tested.
* Diagram of step 1 is wrong in that KROOT with CID=0 also received after entering step 1.
* Duration of CREV=2.75h
* All tags verified succesffully.
This commit is contained in:
cesaaargm 2024-08-15 21:48:29 +02:00
parent 092a78f580
commit ea0684d640
3 changed files with 64 additions and 0 deletions

View File

@ -330,6 +330,28 @@ void osnma_msg_receiver::process_osnma_message(const std::shared_ptr<OSNMA_msg>&
d_tesla_key_verified = false; // force the verification up to the Kroot due to chain change d_tesla_key_verified = false; // force the verification up to the Kroot due to chain change
} }
if (d_osnma_data.d_nma_header.nmas == 3 /* DU */ && d_osnma_data.d_nma_header.cpks == 3 /* CREV */ && d_GST_chain_revocation_start == 0)
{
d_flag_chain_revocation = true;
d_number_of_blocks[d_osnma_data.d_dsm_header.dsm_id] = 0; // delete blocks received up to now, new chain must be received.
// d_public_key_verified = false;
d_kroot_verified = false;
d_tesla_key_verified = false;
d_GST_chain_revocation_start = d_helper->compute_gst(osnma_msg->WN_sf0, osnma_msg->TOW_sf0);
LOG(INFO) << "Galileo OSNMA: Chain revocation :: Start at GST=[" << osnma_msg->WN_sf0 << " " << osnma_msg->TOW_sf0 << "]";
std::cout << "Galileo OSNMA: Chain revocation :: Start at GST=[" << osnma_msg->WN_sf0 << " " << osnma_msg->TOW_sf0 << "]" << std::endl;
}
if (d_flag_chain_revocation && d_osnma_data.d_nma_header.nmas == 2 /* OP */ && d_osnma_data.d_nma_header.cpks == 1 /* Nominal */)
{
d_flag_chain_revocation = false;
uint32_t final_GST = d_helper->compute_gst(osnma_msg->WN_sf0, osnma_msg->TOW_sf0);
double duration_hours = (final_GST - d_GST_chain_revocation_start) / 3600.0;
LOG(INFO) << "Galileo OSNMA: Chain revocation :: Finished at GST=[" << osnma_msg->WN_sf0 << " " << osnma_msg->TOW_sf0 << "]"
<< ", Duration=" << duration_hours << "h";
std::cout << "Galileo OSNMA: Chain revocation :: Finished at GST=[" << osnma_msg->WN_sf0 << " " << osnma_msg->TOW_sf0 << "]"
<< ", Duration=" << duration_hours << "h" << std::endl;
}
read_dsm_header(osnma_msg->hkroot[1]); read_dsm_header(osnma_msg->hkroot[1]);
read_dsm_block(osnma_msg); read_dsm_block(osnma_msg);
process_dsm_block(osnma_msg); // will process dsm block if received a complete one, then will call mack processing upon re-setting the dsm block to 0 process_dsm_block(osnma_msg); // will process dsm block if received a complete one, then will call mack processing upon re-setting the dsm block to 0

View File

@ -130,6 +130,7 @@ private:
uint32_t d_GST_PKR_PKREV_start{}; uint32_t d_GST_PKR_PKREV_start{};
uint32_t d_GST_PKR_AM_start{}; uint32_t d_GST_PKR_AM_start{};
uint32_t d_GST_chain_renewal_start{}; uint32_t d_GST_chain_renewal_start{};
uint32_t d_GST_chain_revocation_start{};
uint32_t d_count_successful_tags{0}; uint32_t d_count_successful_tags{0};
uint32_t d_count_failed_tags{0}; uint32_t d_count_failed_tags{0};
@ -151,6 +152,7 @@ private:
bool d_flag_NPK_set{false}; bool d_flag_NPK_set{false};
bool d_flag_alert_message{false}; bool d_flag_alert_message{false};
bool d_flag_chain_renewal{false}; bool d_flag_chain_renewal{false};
bool d_flag_chain_revocation{false};
// Provide access to inner functions to Gtest // Provide access to inner functions to Gtest
FRIEND_TEST(OsnmaMsgReceiverTest, TeslaKeyVerification); FRIEND_TEST(OsnmaMsgReceiverTest, TeslaKeyVerification);
@ -164,6 +166,7 @@ private:
FRIEND_TEST(OsnmaTestVectors, PublicKeyRenewal); FRIEND_TEST(OsnmaTestVectors, PublicKeyRenewal);
FRIEND_TEST(OsnmaTestVectors, PublicKeyRevocation); FRIEND_TEST(OsnmaTestVectors, PublicKeyRevocation);
FRIEND_TEST(OsnmaTestVectors, ChainRenewal); FRIEND_TEST(OsnmaTestVectors, ChainRenewal);
FRIEND_TEST(OsnmaTestVectors, ChainRevocation);
FRIEND_TEST(OsnmaTestVectors, AlertMessage); FRIEND_TEST(OsnmaTestVectors, AlertMessage);
}; };

View File

@ -244,6 +244,45 @@ TEST_F(OsnmaTestVectors, ChainRenewal)
ASSERT_EQ(osnma->d_count_failed_macseq, 0); ASSERT_EQ(osnma->d_count_failed_macseq, 0);
} }
TEST_F(OsnmaTestVectors, ChainRevocation)
{
// Arrange
std::string crtFilePath = std::string(BASE_OSNMA_TEST_VECTORS) + "cryptographic_material/Merkle_tree_2/PublicKey/OSNMA_PublicKey_20231007041500_PKID_7.crt";
std::string merkleFilePath = std::string(BASE_OSNMA_TEST_VECTORS) + "cryptographic_material/Merkle_tree_2/MerkleTree/OSNMA_MerkleTree_20231007041500_PKID_7.xml";
osnma_msg_receiver_sptr osnma = osnma_msg_receiver_make(crtFilePath, merkleFilePath);
std::tm input_time_step1 = {0, 45, 21, 6, 10 - 1, 2023 - 1900, 0, 0, 0, 0, 0};
std::tm input_time_step2 = {0, 30, 23, 6, 10 - 1, 2023 - 1900, 0, 0, 0, 0, 0};
std::tm input_time_step3 = {0, 30, 00, 7, 10 - 1, 2023 - 1900, 0, 0, 0, 0, 0};
std::vector<std::tm> input_times = {input_time_step1, input_time_step2, input_time_step3};
std::vector<TestVector> testVectors_step1 = readTestVectorsFromFile(std::string(BASE_OSNMA_TEST_VECTORS) + "osnma_test_vectors/crev_step1/06_OCT_2023_GST_21_45_01.csv");
std::vector<TestVector> testVectors_step2 = readTestVectorsFromFile(std::string(BASE_OSNMA_TEST_VECTORS) + "osnma_test_vectors/crev_step2/06_OCT_2023_GST_23_30_01.csv");
std::vector<TestVector> testVectors_step3 = readTestVectorsFromFile(std::string(BASE_OSNMA_TEST_VECTORS) + "osnma_test_vectors/crev_step3/07_OCT_2023_GST_00_30_01.csv");
if (testVectors_step1.empty() || testVectors_step2.empty() || testVectors_step3.empty())
{
ASSERT_TRUE(false);
}
std::vector<std::vector<TestVector>> testVectors = {testVectors_step1, testVectors_step2, testVectors_step3};
// Act
bool result = feedOsnmaWithTestVectors(osnma, testVectors, input_times);
ASSERT_TRUE(result);
// Assert
LOG(INFO) << "Successful tags count= " << osnma->d_count_successful_tags;
LOG(INFO) << "Failed tags count= " << osnma->d_count_failed_tags;
LOG(INFO) << "Unverified tags count= " << osnma->d_tags_awaiting_verify.size();
LOG(INFO) << "Failed Kroot count= " << osnma->d_count_failed_Kroot;
LOG(INFO) << "Failed PK count= " << osnma->d_count_failed_pubKey;
LOG(INFO) << "Failed MACSEQ count= " << osnma->d_count_failed_macseq;
ASSERT_EQ(osnma->d_count_failed_tags, 0);
ASSERT_EQ(osnma->d_count_failed_Kroot, 0);
ASSERT_EQ(osnma->d_count_failed_pubKey, 0);
ASSERT_EQ(osnma->d_count_failed_macseq, 0);
}
TEST_F(OsnmaTestVectors, AlertMessage) TEST_F(OsnmaTestVectors, AlertMessage)
{ {
// Arrange // Arrange