From ff5118db5451bbdfeeef6b6dbce2aff698c2db6e Mon Sep 17 00:00:00 2001 From: cesaaargm Date: Wed, 10 Apr 2024 17:51:43 +0200 Subject: [PATCH] [TAS-156] debug verify_tesla_key various bugfixes plus refactor recursive hash computation --- src/core/libs/osnma_msg_receiver.cc | 284 +++++++----------- src/core/libs/osnma_msg_receiver.h | 3 +- src/core/system_parameters/gnss_crypto.cc | 78 ++--- .../osnma/gnss_crypto_test.cc | 9 +- 4 files changed, 158 insertions(+), 216 deletions(-) diff --git a/src/core/libs/osnma_msg_receiver.cc b/src/core/libs/osnma_msg_receiver.cc index f5e084ffe..d058f92a6 100644 --- a/src/core/libs/osnma_msg_receiver.cc +++ b/src/core/libs/osnma_msg_receiver.cc @@ -128,9 +128,10 @@ void osnma_msg_receiver::process_osnma_message(const std::shared_ptr& read_nma_header(osnma_msg->hkroot[0]); read_dsm_header(osnma_msg->hkroot[1]); read_dsm_block(osnma_msg); - local_time_verification(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 - read_and_process_mack_block(osnma_msg); // only process them if a least 3 available. + if(d_osnma_data.d_dsm_kroot_message.towh_k != 0) + local_time_verification(osnma_msg); + read_and_process_mack_block(osnma_msg); // only process them if at least 3 available. } @@ -260,7 +261,7 @@ void osnma_msg_receiver::local_time_verification(const std::shared_ptrWN_sf0 & 0x00000FFF) << 20 | (osnma_msg->TOW_sf0 & 0x000FFFFF); //std::cout << "Galileo OSNMA: d_GST_SIS: " << d_GST_SIS << std::endl; //d_GST_0 = d_osnma_data.d_dsm_kroot_message.towh_k + 604800 * d_osnma_data.d_dsm_kroot_message.wn_k + 30; - d_GST_0 = ((d_osnma_data.d_dsm_kroot_message.wn_k & 0x00000FFF) << 20 | (d_osnma_data.d_dsm_kroot_message.towh_k & 0x000FFFFF)) + 30; + d_GST_0 = ((d_osnma_data.d_dsm_kroot_message.wn_k & 0x00000FFF) << 20 | (d_osnma_data.d_dsm_kroot_message.towh_k & 0x000FFFFF)) + 30; // applicable time (GST_Kroot + 30) //d_GST_0 = d_osnma_data.d_dsm_kroot_message.towh_k + 604800 * d_osnma_data.d_dsm_kroot_message.wn_k + 30; // TODO store list of SVs sending OSNMA and if received ID matches one stored, then just increment time 30s for that ID. if(d_receiver_time != 0) @@ -350,6 +351,7 @@ void osnma_msg_receiver::process_dsm_message(const std::vector& dsm_msg // DSM-KROOT message if (d_osnma_data.d_dsm_header.dsm_id < 12) { + // Parse Kroot message LOG(WARNING) << "OSNMA: DSM-KROOT message received."; d_osnma_data.d_dsm_kroot_message.nb_dk = d_dsm_reader->get_number_blocks_index(dsm_msg[0]); d_osnma_data.d_dsm_kroot_message.pkid = d_dsm_reader->get_pkid(dsm_msg); @@ -364,10 +366,10 @@ void osnma_msg_receiver::process_dsm_message(const std::vector& dsm_msg d_osnma_data.d_dsm_kroot_message.wn_k = d_dsm_reader->get_wn_k(dsm_msg); d_osnma_data.d_dsm_kroot_message.towh_k = d_dsm_reader->get_towh_k(dsm_msg); d_osnma_data.d_dsm_kroot_message.alpha = d_dsm_reader->get_alpha(dsm_msg); - + // Kroot field const uint16_t l_lk_bytes = d_dsm_reader->get_lk_bits(d_osnma_data.d_dsm_kroot_message.ks) / 8; d_osnma_data.d_dsm_kroot_message.kroot = d_dsm_reader->get_kroot(dsm_msg, l_lk_bytes); - + // DS field std::string hash_function = d_dsm_reader->get_hash_function(d_osnma_data.d_dsm_kroot_message.hf); uint16_t l_ds_bits = 0; const auto it = OSNMA_TABLE_15.find(hash_function); @@ -381,6 +383,7 @@ void osnma_msg_receiver::process_dsm_message(const std::vector& dsm_msg { d_osnma_data.d_dsm_kroot_message.ds[k] = dsm_msg[13 + l_lk_bytes + k]; } + // Padding const uint16_t l_dk_bits = d_dsm_reader->get_l_dk_bits(d_osnma_data.d_dsm_kroot_message.nb_dk); const uint16_t l_dk_bytes = l_dk_bits / 8; const uint16_t l_pdk_bytes = (l_dk_bytes - 13 - l_lk_bytes - l_ds_bytes); @@ -406,7 +409,7 @@ void osnma_msg_receiver::process_dsm_message(const std::vector& dsm_msg { MSG.push_back(dsm_msg[i]); } - std::vector message = MSG; // C: MSG == M || DS from ICD. Eq. 7 + std::vector message = MSG; // MSG = (M | DS) from ICD. Eq. 7 for (uint16_t k = 0; k < l_ds_bytes; k++) { MSG.push_back(d_osnma_data.d_dsm_kroot_message.ds[k]); @@ -435,12 +438,12 @@ void osnma_msg_receiver::process_dsm_message(const std::vector& dsm_msg // Check that the padding bits received match the computed values if (d_osnma_data.d_dsm_kroot_message.p_dk == p_dk_truncated) { - LOG(WARNING) << "OSNMA: DSM-KROOT message received ok."; std::cout << "Galileo OSNMA: KROOT with CID=" << static_cast(d_osnma_data.d_nma_header.cid) << ", PKID=" << static_cast(d_osnma_data.d_dsm_kroot_message.pkid) << ", WN=" << static_cast(d_osnma_data.d_dsm_kroot_message.wn_k) - << ", TOW=" << static_cast(d_osnma_data.d_dsm_kroot_message.towh_k) * 3600; + << ", TOW=" << static_cast(d_osnma_data.d_dsm_kroot_message.towh_k) * 3600 << std::endl; + local_time_verification(osnma_msg); d_kroot_verified = d_crypto->verify_signature(message, d_osnma_data.d_dsm_kroot_message.ds); if (d_kroot_verified) { @@ -1091,179 +1094,51 @@ void osnma_msg_receiver::display_data() } bool osnma_msg_receiver::verify_tesla_key(std::vector& key, uint32_t TOW) { - if(d_tesla_key_verified) + uint32_t num_of_hashes_needed; + uint32_t GST_SFi = d_receiver_time - 30; + std::vector hash; + const uint8_t lk_bytes = d_dsm_reader->get_lk_bits(d_osnma_data.d_dsm_kroot_message.ks)/8; + std::vector validated_key; + if(d_tesla_key_verified){ // have to go up to last verified key + validated_key = d_tesla_keys.rbegin()->second; + num_of_hashes_needed = (d_receiver_time - d_last_verified_key_GST) / 30; // Eq. 19 ICD modified + std::cout << "Galileo OSNMA: TESLA verification ("<< num_of_hashes_needed << " hashes) need to be performed up to closest verified TESLA key " << std::endl; + + hash = hash_chain(num_of_hashes_needed, key, GST_SFi, lk_bytes); + } + else{// have to go until Kroot + validated_key = d_osnma_data.d_dsm_kroot_message.kroot; + num_of_hashes_needed = (d_receiver_time - d_GST_0) / 30 + 1; // Eq. 19 ICD + std::cout << "Galileo OSNMA: TESLA verification ("<< num_of_hashes_needed << " hashes) need to be performed up to Kroot " << std::endl; + + hash = hash_chain(num_of_hashes_needed, key, GST_SFi, lk_bytes); + } + + if(hash.size() != key.size()) { - // TODO - find out I bt. both tesla keys, then hash until then, then compare. - // retrieve latest tesla key from d_tesla_keys - std::vector validated_key = d_tesla_keys.rbegin()->second; - // compute hashes needed - uint32_t num_of_hashes_needed = (d_GST_SIS - d_last_verified_key_GST) / 30; // Eq. 19 ICD modified - std::cout << "Galileo OSNMA: TESLA verification ("<< num_of_hashes_needed << " hashes) need to be performed. " << std::endl; - // hash current key until num_hashes and compare - auto start = std::chrono::high_resolution_clock::now(); - uint32_t GST_SFi = d_GST_SIS; // TODO - std::vector K_II = key; - std::vector K_I; // result of the recursive hash operations - const uint8_t lk_bytes = d_dsm_reader->get_lk_bits(d_osnma_data.d_dsm_kroot_message.ks)/8; - // compute the tesla key for current SF (GST_SFi and K_II change in each iteration) - for (uint32_t i = 1; i < num_of_hashes_needed ; i++) - { - // build message digest m = (K_I+1 || GST_SFi || alpha) - std::vector msg(K_II.size() + sizeof(GST_SFi) + sizeof(d_osnma_data.d_dsm_kroot_message.alpha)); - std::copy(K_II.begin(),K_II.end(),msg.begin()); - - msg.push_back((d_GST_Sf & 0xFF000000) >> 24); - msg.push_back((d_GST_Sf & 0x00FF0000) >> 16); - msg.push_back((d_GST_Sf & 0x0000FF00) >> 8); - msg.push_back(d_GST_Sf & 0x000000FF); - // extract alpha - for (int k = 5; k >= 0;k--) - { - // TODO: static extracts the MSB in case from larger to shorter int? - msg.push_back(static_cast((d_osnma_data.d_dsm_kroot_message.alpha >> (i * 8)) & 0xFF)); // extract first 6 bytes of alpha. - } - // compute hash - std::vector hash; - if (d_osnma_data.d_dsm_kroot_message.hf == 0) // Table 8. - { - hash = d_crypto->computeSHA256(msg); - } - else if (d_osnma_data.d_dsm_kroot_message.hf == 2) - { - hash = d_crypto->computeSHA3_256(msg); - } - else - { - hash = std::vector(32); - } - // truncate hash - K_I.reserve(lk_bytes); // TODO - case hash function has 512 bits - for (uint16_t i = 0; i < lk_bytes; i++) - { - K_I.push_back(hash[i]); - } - - // set parameters for next iteration - GST_SFi -= 30; // next SF time is the actual minus 30 seconds - K_II = K_I; // next key is the actual one - K_I.clear(); // empty the actual one for a new computation - } - // compare computed current key against received key - auto end = std::chrono::high_resolution_clock::now(); - std::chrono::duration elapsed = end - start; - std::cout << "Galileo OSNMA: TESLA verification ("<< num_of_hashes_needed << " hashes) took " << elapsed.count() << " seconds.\n"; - - if(K_II.size() != key.size()) - { - std::cout << "Galileo OSNMA: Error during tesla key verification. " << std::endl; - return false; - } - if (K_II == validated_key) - { - std::cout << "Galileo OSNMA: tesla key verified successfully " << std::endl; - d_tesla_keys.insert(std::pair(TOW,key)); - d_last_verified_key_GST = d_GST_SIS; - d_tesla_key_verified = true; // TODO this boolean only shows that a tesla key is verified, re-setting it all the time is not beautiful - // case one verified and after a time another one not, what would happen in the next MAck processed is that because false - // it would try to verifiy against kroot, but it could as well try against last validated key. This needs to be adressed in the future. - } - else - - { - std::cerr << "Galileo OSNMA: Error during tesla key verification. " << std::endl; - if(d_flag_debug){ - d_last_verified_key_GST = d_GST_SIS; - d_tesla_key_verified = true; - } - - else - d_tesla_key_verified = false; - } - return d_tesla_key_verified; + std::cout << "Galileo OSNMA: Error during tesla key verification. " << std::endl; + return false; } - else - {// have to go until Kroot - uint32_t num_of_hashes_needed = (d_GST_SIS - d_GST_0) / 30 + 1; // Eq. 19 ICD - std::cout << "Galileo OSNMA: TESLA verification ("<< num_of_hashes_needed << " hashes) need to be performed. " << std::endl; - auto start = std::chrono::high_resolution_clock::now(); - uint32_t GST_SFi = d_GST_SIS; - std::vector K_II = key; - std::vector K_I; // result of the recursive hash operations - const uint8_t lk_bytes = d_dsm_reader->get_lk_bits(d_osnma_data.d_dsm_kroot_message.ks)/8; - // compute the tesla key for current SF (GST_SFi and K_II change in each iteration) - for (uint32_t i = 1; i < num_of_hashes_needed ; i++) - { - // build message digest m = (K_I+1 || GST_SFi || alpha) - std::vector msg(K_II.size() + sizeof(GST_SFi) + sizeof(d_osnma_data.d_dsm_kroot_message.alpha)); - std::copy(K_II.begin(),K_II.end(),msg.begin()); - - msg.push_back((d_GST_Sf & 0xFF000000) >> 24); - msg.push_back((d_GST_Sf & 0x00FF0000) >> 16); - msg.push_back((d_GST_Sf & 0x0000FF00) >> 8); - msg.push_back(d_GST_Sf & 0x000000FF); - // extract alpha - for (int k = 5; k >= 0;k--) - { - // TODO: static extracts the MSB in case from larger to shorter int? - msg.push_back(static_cast((d_osnma_data.d_dsm_kroot_message.alpha >> (i * 8)) & 0xFF)); // extract first 6 bytes of alpha. - } - // compute hash - std::vector hash; - if (d_osnma_data.d_dsm_kroot_message.hf == 0) // Table 8. - { - hash = d_crypto->computeSHA256(msg); - } - else if (d_osnma_data.d_dsm_kroot_message.hf == 2) - { - hash = d_crypto->computeSHA3_256(msg); - } - else - { - hash = std::vector(32); - } - // truncate hash - K_I.reserve(lk_bytes); // TODO - case hash function has 512 bits - for (uint16_t i = 0; i < lk_bytes; i++) - { - K_I.push_back(hash[i]); - } - - // set parameters for next iteration - GST_SFi -= 30; // next SF time is the actual minus 30 seconds - K_II = K_I; // next key is the actual one - K_I.clear(); // empty the actual one for a new computation - } - // compare computed current key against received key - auto end = std::chrono::high_resolution_clock::now(); - std::chrono::duration elapsed = end - start; - std::cout << "Galileo OSNMA: TESLA verification ("<< num_of_hashes_needed << " hashes) took " << elapsed.count() << " seconds.\n"; - - if(K_II.size() != key.size()) - { - std::cout << "Galileo OSNMA: Error during tesla key verification. " << std::endl; - return false; - } - if (K_II == d_osnma_data.d_dsm_kroot_message.kroot) - { - std::cout << "Galileo OSNMA: tesla key verified successfully " << std::endl; + if (hash == validated_key) + { + std::cout << "Galileo OSNMA: tesla key verified successfully " << std::endl; + d_tesla_keys.insert(std::pair(TOW,key)); + d_tesla_key_verified = true; + d_last_verified_key_GST = d_receiver_time; + // TODO - propagate result + // TODO - save current tesla key as latest one? propose a map with + // TODO - Tags Sequence Verification: check ADKD[i] follows MACLT sequence + } + else{ + std::cerr << "Galileo OSNMA: Error during tesla key verification. " << std::endl; + if(d_flag_debug){ d_tesla_keys.insert(std::pair(TOW,key)); + d_last_verified_key_GST = d_receiver_time; d_tesla_key_verified = true; - d_last_verified_key_GST = d_GST_SIS; - // TODO - propagate result - // TODO - save current tesla key as latest one? propose a map with - // TODO - Tags Sequence Verification: check ADKD[i] follows MACLT sequence + // TODO - if intermediate verification fails, can one still use the former verified tesla key or should go to Kroot or even retrieve new Kroot? } - else - - { - std::cerr << "Galileo OSNMA: Error during tesla key verification. " << std::endl; - if(d_flag_debug){ - d_last_verified_key_GST = d_GST_SIS; - d_tesla_key_verified = true; - } - } - return d_tesla_key_verified; } + return d_tesla_key_verified; } /** @@ -1449,3 +1324,62 @@ bool osnma_msg_receiver::tag_has_key_available(Tag& t){ std::cout << "Galileo OSNMA: hasKey = false " << std::endl; return false; } +std::vector osnma_msg_receiver::hash_chain(uint32_t num_of_hashes_needed, std::vector key, uint32_t GST_SFi, const uint8_t lk_bytes) +{ + auto start = std::chrono::high_resolution_clock::now(); + std::vector K_II = {0x2D,0xC3,0xA3,0xCD,0xB1,0x17,0xFA,0xAD,0xB8,0x3B,0x5F,0x0B,0x6F,0xEA,0x88,0xEB};//key; + std::vector K_I; // result of the recursive hash operations + GST_SFi = 0x4E054600; + std::vector msg; + // compute the tesla key for current SF (GST_SFi and K_II change in each iteration) + for (uint32_t i = 1; i <= num_of_hashes_needed ; i++) + { + // build message digest m = (K_I+1 || GST_SFi || alpha) + msg.reserve(K_II.size() + sizeof(GST_SFi) + sizeof(d_osnma_data.d_dsm_kroot_message.alpha)); + std::copy(K_II.begin(),K_II.end(),std::back_inserter(msg)); + + msg.push_back((GST_SFi & 0xFF000000) >> 24); + msg.push_back((GST_SFi & 0x00FF0000) >> 16); + msg.push_back((GST_SFi & 0x0000FF00) >> 8); + msg.push_back(GST_SFi & 0x000000FF); + // extract alpha + d_osnma_data.d_dsm_kroot_message.alpha = 0x610BDF26D77B; + for (int k = 5; k >= 0;k--) + { + // TODO: static extracts the MSB in case from larger to shorter int? + msg.push_back(static_cast((d_osnma_data.d_dsm_kroot_message.alpha >> (k * 8)) & 0xFF)); // extract first 6 bytes of alpha. + } + // compute hash + std::vector hash; + if (d_osnma_data.d_dsm_kroot_message.hf == 0) // Table 8. + { + hash = d_crypto->computeSHA256(msg); + } + else if (d_osnma_data.d_dsm_kroot_message.hf == 2) + { + hash = d_crypto->computeSHA3_256(msg); + } + else + { + hash = std::vector(32); + } + // truncate hash + K_I.reserve(lk_bytes); // TODO - case hash function has 512 bits + for (int k = 0; k < lk_bytes; k++) + { + K_I.push_back(hash[k]); + } + // set parameters for next iteration + GST_SFi -= 30; // next SF time is the actual minus 30 seconds + K_II = K_I; // next key is the actual one + K_I.clear(); // empty the actual one for a new computation + msg.clear(); + } + if(GST_SFi + 30 != d_GST_0 - 30 && d_tesla_key_verified == false) + std::cout << "Galileo OSNMA: TESLA verification error. Kroot time mismatch! \n"; // ICD. Eq. 18 + // compare computed current key against received key + auto end = std::chrono::high_resolution_clock::now(); + std::chrono::duration elapsed = end - start; + std::cout << "Galileo OSNMA: TESLA verification ("<< num_of_hashes_needed << " hashes) took " << elapsed.count() << " seconds.\n"; + return K_II; +} diff --git a/src/core/libs/osnma_msg_receiver.h b/src/core/libs/osnma_msg_receiver.h index c921fd62d..a443850ac 100644 --- a/src/core/libs/osnma_msg_receiver.h +++ b/src/core/libs/osnma_msg_receiver.h @@ -74,6 +74,7 @@ private: void process_mack_message(); void add_satellite_data(uint32_t SV_ID, uint32_t TOW, const NavData &data); bool verify_tesla_key(std::vector& key, uint32_t TOW); + std::vector hash_chain(uint32_t num_of_hashes_needed, std::vector key, uint32_t GST_SFi, const uint8_t lk_bytes); void display_data();bool verify_tag(MACK_tag_and_info tag_and_info, OSNMA_data applicable_OSNMA, uint8_t tag_position, const std::vector& applicable_key, NavData applicable_NavData); bool verify_tag(Tag& tag); bool is_next_subframe(); @@ -98,7 +99,7 @@ private: bool d_kroot_verified{false}; bool d_tesla_key_verified{false}; bool d_flag_debug{false}; - uint32_t d_GST_Sf {}; // C: used for MACSEQ and Tesla Key verification + uint32_t d_GST_Sf {}; // C: used for MACSEQ and Tesla Key verification TODO need really to be global var? uint32_t d_last_verified_key_GST{0}; uint8_t d_Lt_min {}; // minimum equivalent tag length uint8_t d_Lt_verified_eph {0}; // verified tag bits - ephemeris diff --git a/src/core/system_parameters/gnss_crypto.cc b/src/core/system_parameters/gnss_crypto.cc index af7df7899..f55b5f609 100644 --- a/src/core/system_parameters/gnss_crypto.cc +++ b/src/core/system_parameters/gnss_crypto.cc @@ -468,6 +468,7 @@ void Gnss_Crypto::readPublicKeyFromPEM(const std::string& pemFilePath) std::cerr << "OpenSSL: error reading the Public Key from file " << pemFilePath << ". Aborting import" << std::endl; return; } + #else // Import the PEM data gnutls_datum_t pemDatum = {const_cast(reinterpret_cast(pemContent.data())), static_cast(pemContent.size())}; @@ -489,6 +490,7 @@ void Gnss_Crypto::readPublicKeyFromPEM(const std::string& pemFilePath) gnutls_pubkey_deinit(pubkey); #endif std::cout << "Public key successfully read from file " << pemFilePath << std::endl; + print_pubkey_hex(d_PublicKey); } @@ -497,48 +499,48 @@ bool Gnss_Crypto::verify_signature(const std::vector& message, const st std::vector digest = this->computeSHA256(message); if (!have_public_key()) { - std::cerr << "GnuTLS error: public key not available"<< std::endl; + std::cerr << "Galileo OSNMA::Kroot verification error::Public key not available"<< std::endl; return false; } bool success = false; #if USE_OPENSSL_FALLBACK - - EVP_MD_CTX *mdctx = NULL; // verification context; a struct that wraps the message to be verified. - int ret = 0; // error - - /* Create the Message Digest Context */ - if(!(mdctx = EVP_MD_CTX_new())) goto err; // Allocates and returns a digest context. - - /* Initialize `key` with a public key */ - // hashes cnt bytes of data at d into the verification context ctx - if(1 != EVP_DigestVerifyInit(mdctx, NULL /*TODO null?*/, EVP_sha256(), NULL, d_PublicKey)) goto err; - - /* Initialize `key` with a public key */ - if(1 != EVP_DigestVerifyUpdate(mdctx, message.data(), message.size())) goto err; - - - if( 1== EVP_DigestVerifyFinal(mdctx, signature.data(), signature.size())) - { - return true; - } - else - { - unsigned long errCode = ERR_get_error(); - int lib_code = ERR_GET_LIB(errCode); - char* err = ERR_error_string(errCode, NULL); - const char* error_string = ERR_error_string(errCode, NULL); - std::cerr << "OpenSSL: message authentication failed: " << err /*<< - "from library with code " << lib_code << - " error string: " << error_string */<< std::endl; - } -err: - if(ret != 1) - { - /* Do some error handling */ - // notify other blocks - std::cout << "ECDSA_Verify_OSSL()::error " << ret << std::endl; - - } +// using low-level API to test function -- it works in unit tests, not in real bytes. +// EVP_MD_CTX *mdctx = NULL; // verification context; a struct that wraps the message to be verified. +// int ret = 0; // error +// +// /* Create the Message Digest Context */ +// if(!(mdctx = EVP_MD_CTX_new())) goto err; // Allocates and returns a digest context. +// +// /* Initialize `key` with a public key */ +// // hashes cnt bytes of data at d into the verification context ctx +// if(1 != EVP_DigestVerifyInit(mdctx, NULL /*TODO null?*/, EVP_sha256(), NULL, d_PublicKey)) goto err; +// +// /* Initialize `key` with a public key */ +// if(1 != EVP_DigestVerifyUpdate(mdctx, message.data(), message.size())) goto err; +// +// +// if( 1 == EVP_DigestVerifyFinal(mdctx, signature.data(), signature.size())) +// { +// return true; +// } +// else +// { +// unsigned long errCode = ERR_get_error(); +// int lib_code = ERR_GET_LIB(errCode); +// char* err = ERR_error_string(errCode, NULL); +// const char* error_string = ERR_error_string(errCode, NULL); +// std::cerr << "OpenSSL: message authentication failed: " << err /*<< +// "from library with code " << lib_code << +// " error string: " << error_string */<< std::endl; +// } +//err: +// if(ret != 1) +// { +// /* Do some error handling */ +// // notify other blocks +// std::cout << "ECDSA_Verify_OSSL()::error " << ret << std::endl; +// +// } #if USE_OPENSSL_3 diff --git a/src/tests/unit-tests/signal-processing-blocks/osnma/gnss_crypto_test.cc b/src/tests/unit-tests/signal-processing-blocks/osnma/gnss_crypto_test.cc index 4f57162fa..563cf5a46 100644 --- a/src/tests/unit-tests/signal-processing-blocks/osnma/gnss_crypto_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/osnma/gnss_crypto_test.cc @@ -22,11 +22,16 @@ TEST(GnssCryptoTest, VerifySignature) { // 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x45, 0x4E, 0x44, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49, 0x43, 0x20, 0x4B, 0x45, 0x59, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x0A } ; // own ECDSA-P256 key and message generated and signed and verified successfully with openssl - std::vector message{0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x0A }; // Hello world con 0x0A al final + std::vector message{0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x0A }; // Hello world con 0x0A al final. Raw message std::vector signature{0x30, 0x45, 0x02, 0x21, 0x00, 0xFB, 0xE6, 0x09, 0x74, 0x5C, 0x12, 0xE8, 0x2C, 0x0C, 0xC9, 0x7A, 0x8E, 0x13, 0x88, 0x87, 0xDA, 0xBF, 0x08, 0x43, 0xF8, 0xC8, 0x93, 0x16, 0x5A, 0x0F, 0x7A, 0xA4, 0xBF, 0x4A, 0xE1, 0xE1, 0xDB, 0x02, 0x20, 0x6B, 0xCB, 0x2F, 0x80, 0x69, 0xBB, 0xDE, 0xC9, 0x11, 0x1D, 0x51, 0x2B, 0x9F, 0x61, 0xA0, 0xC1, 0x29, 0xD1, 0x0B, 0x58, 0x09, 0x82, 0x58, 0xFC, 0x9E, 0x00, 0xC7, 0xEE, 0xA5, 0xB9, 0xB2, 0x56}; // Hello world hashed and then encrypted with PrK - std::vector publicKey{ // PK associated to the PrK +// std::vector publicKey{// PK associated to the PrK, in der format ---test +// 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x4A, 0xF3, +// 0xEE, 0x3A, 0x94, 0x25, 0x25, 0x3D, 0x55, 0xC2, 0x5A, 0xC2, 0x2D, 0xCF, 0x14, 0x4D, 0x39, 0x0D, 0xB1, 0xFC, 0x7F, 0x31, 0x5A, 0x2A, 0x19, 0xAE, 0x4E, 0xD6, 0xCB, 0xA6, 0x59, +// 0xD6, 0x99, 0x7C, 0xE8, 0xBD, 0x1F, 0x43, 0x34, 0x1C, 0x59, 0xD9, 0xD9, 0xCA, 0xC3, 0xEE, 0x58, 0xE5, 0xEA, 0xD3, 0x55, 0x44, 0xEA, 0x89, 0x71, 0x65, 0xD0, 0x92, 0x72, 0xA2, +// 0xC8, 0x3C, 0x87, 0x5D }; + std::vector publicKey{ // PK associated to the PrK, in pem format 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49, 0x43, 0x20, 0x4B, 0x45, 0x59, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x0A, 0x4D, 0x46,