mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-18 21:23:02 +00:00
Fix defects detected by clang-tidy
This commit is contained in:
parent
8fd6e4dc40
commit
d0a1825c24
@ -305,7 +305,7 @@ bool Gnss_Crypto::verify_signature_ecdsa_p256(const std::vector<uint8_t>& messag
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned long errCode = ERR_get_error();
|
uint64_t errCode = ERR_get_error();
|
||||||
char* err = ERR_error_string(errCode, nullptr);
|
char* err = ERR_error_string(errCode, nullptr);
|
||||||
LOG(WARNING) << "OpenSSL: OSNMA message authentication failed: " << err;
|
LOG(WARNING) << "OpenSSL: OSNMA message authentication failed: " << err;
|
||||||
}
|
}
|
||||||
@ -1273,7 +1273,7 @@ bool Gnss_Crypto::pubkey_copy(EVP_PKEY* src, EVP_PKEY** dest)
|
|||||||
|
|
||||||
// Read the data from the memory buffer
|
// Read the data from the memory buffer
|
||||||
char* bio_data;
|
char* bio_data;
|
||||||
long data_len = BIO_get_mem_data(mem_bio, &bio_data);
|
int64_t data_len = BIO_get_mem_data(mem_bio, &bio_data);
|
||||||
|
|
||||||
// Create a new memory buffer and load the data into it
|
// Create a new memory buffer and load the data into it
|
||||||
BIO* mem_bio2 = BIO_new_mem_buf(bio_data, data_len);
|
BIO* mem_bio2 = BIO_new_mem_buf(bio_data, data_len);
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
/*!
|
/*!
|
||||||
* \file osnma_helper.h
|
* \file osnma_helper.h
|
||||||
* \brief Class for auxiliary osnma functions
|
* \brief Class for auxiliary osnma functions
|
||||||
* \author Carles Fernandez-Prades, 2024 cfernandez(at)cttc.es
|
* \author Carles Fernandez-Prades, 2024 cfernandez(at)cttc.es
|
||||||
*
|
*
|
||||||
* -----------------------------------------------------------------------------
|
* -----------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||||
* This file is part of GNSS-SDR.
|
* This file is part of GNSS-SDR.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors)
|
* Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors)
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*
|
*
|
||||||
* -----------------------------------------------------------------------------
|
* -----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "osnma_helper.h"
|
#include "osnma_helper.h"
|
||||||
@ -26,6 +26,7 @@ uint32_t Osnma_Helper::compute_gst(uint32_t WN, uint32_t TOW) const
|
|||||||
return GST;
|
return GST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<uint8_t> Osnma_Helper::gst_to_uint8(uint32_t GST) const
|
std::vector<uint8_t> Osnma_Helper::gst_to_uint8(uint32_t GST) const
|
||||||
{
|
{
|
||||||
std::vector<uint8_t> res;
|
std::vector<uint8_t> res;
|
||||||
@ -37,6 +38,7 @@ std::vector<uint8_t> Osnma_Helper::gst_to_uint8(uint32_t GST) const
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Convert a binary string to a vector of bytes.
|
* @brief Convert a binary string to a vector of bytes.
|
||||||
*
|
*
|
||||||
@ -47,7 +49,8 @@ std::vector<uint8_t> Osnma_Helper::gst_to_uint8(uint32_t GST) const
|
|||||||
* @param binaryString The binary string to be converted.
|
* @param binaryString The binary string to be converted.
|
||||||
* @return The vector of bytes converted from the binary string.
|
* @return The vector of bytes converted from the binary string.
|
||||||
*/
|
*/
|
||||||
std::vector<uint8_t> Osnma_Helper::bytes(const std::string& binaryString) const {
|
std::vector<uint8_t> Osnma_Helper::bytes(const std::string& binaryString) const
|
||||||
|
{
|
||||||
std::vector<uint8_t> bytes;
|
std::vector<uint8_t> bytes;
|
||||||
|
|
||||||
// Determine the size of the padding needed.
|
// Determine the size of the padding needed.
|
||||||
@ -55,12 +58,14 @@ std::vector<uint8_t> Osnma_Helper::bytes(const std::string& binaryString) const
|
|||||||
|
|
||||||
std::string padded_binary = binaryString;
|
std::string padded_binary = binaryString;
|
||||||
|
|
||||||
if (padding_size != 0) {
|
if (padding_size != 0)
|
||||||
padding_size = 8 - padding_size; // Compute padding size
|
{
|
||||||
|
padding_size = 8 - padding_size; // Compute padding size
|
||||||
padded_binary.append(padding_size, '0'); // Append zeros to the binary string
|
padded_binary.append(padding_size, '0'); // Append zeros to the binary string
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < padded_binary.size(); i += 8) {
|
for (size_t i = 0; i < padded_binary.size(); i += 8)
|
||||||
|
{
|
||||||
uint8_t byte = std::bitset<8>(padded_binary.substr(i, 8)).to_ulong();
|
uint8_t byte = std::bitset<8>(padded_binary.substr(i, 8)).to_ulong();
|
||||||
bytes.push_back(byte);
|
bytes.push_back(byte);
|
||||||
}
|
}
|
||||||
@ -68,37 +73,49 @@ std::vector<uint8_t> Osnma_Helper::bytes(const std::string& binaryString) const
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string Osnma_Helper::verification_status_str(const int& status) const
|
std::string Osnma_Helper::verification_status_str(const int& status) const
|
||||||
{
|
{
|
||||||
switch (status) {
|
switch (status)
|
||||||
case 0: return "SUCCESS";
|
{
|
||||||
case 1: return "FAIL";
|
case 0:
|
||||||
case 2: return "UNVERIFIED";
|
return "SUCCESS";
|
||||||
default: return "UNKNOWN";
|
case 1:
|
||||||
}
|
return "FAIL";
|
||||||
|
case 2:
|
||||||
|
return "UNVERIFIED";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string Osnma_Helper::convert_to_hex_string(const std::vector<uint8_t>& vector) const
|
std::string Osnma_Helper::convert_to_hex_string(const std::vector<uint8_t>& vector) const
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << std::hex << std::setfill('0');
|
ss << std::hex << std::setfill('0');
|
||||||
for (auto byte : vector) {
|
for (auto byte : vector)
|
||||||
|
{
|
||||||
ss << std::setw(2) << static_cast<int>(byte);
|
ss << std::setw(2) << static_cast<int>(byte);
|
||||||
}
|
}
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<uint8_t> Osnma_Helper::convert_from_hex_string(const std::string& hex_string) const
|
std::vector<uint8_t> Osnma_Helper::convert_from_hex_string(const std::string& hex_string) const
|
||||||
{
|
{
|
||||||
std::vector<uint8_t> result;
|
std::vector<uint8_t> result;
|
||||||
|
|
||||||
std::string adjusted_hex_string = hex_string;
|
std::string adjusted_hex_string = hex_string;
|
||||||
if (hex_string.length() % 2 != 0) {
|
if (hex_string.length() % 2 != 0)
|
||||||
|
{
|
||||||
adjusted_hex_string = "0" + hex_string;
|
adjusted_hex_string = "0" + hex_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::size_t i = 0; i < adjusted_hex_string.length(); i += 2) {
|
for (std::size_t i = 0; i < adjusted_hex_string.length(); i += 2)
|
||||||
|
{
|
||||||
std::string byte_string = adjusted_hex_string.substr(i, 2);
|
std::string byte_string = adjusted_hex_string.substr(i, 2);
|
||||||
uint8_t byte = static_cast<uint8_t>(std::stoul(byte_string, nullptr, 16));
|
auto byte = static_cast<uint8_t>(std::stoul(byte_string, nullptr, 16));
|
||||||
result.push_back(byte);
|
result.push_back(byte);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user