Keep the colleague's microbu-esp32c5 tree in this repository
obu-firmware builds against vanetza-idf from microbu-esp32c5/external, but that tree was gitignored, so a clone of this repository could not build the firmware it ships. It is now committed here as ordinary files in its own folder, microbu-esp32c5/: the colleague's commit cf4b99f plus the V2X2MAP bridge's signature verification (--trust) used on the bench. Nothing is fetched from or pushed to the colleague's repository; this repository and its remotes carry everything. The folder's own .gitignore keeps build output, downloaded components and private key material out, as it did there; the committed file set is identical to that repository's tracked files. The ESP32-C5 is still flashed from obu-firmware/, which only takes vanetza-idf from microbu-esp32c5/, so the two stay separate folders. FLASHING.md says how to take a newer version of the colleague's tree (copy it over the folder, rebuild, test, commit).
This commit is contained in:
+91
@@ -0,0 +1,91 @@
|
||||
#include <vanetza/security/exception.hpp>
|
||||
#include <vanetza/security/v2/encryption_parameter.hpp>
|
||||
#include <vanetza/security/v2/public_key.hpp>
|
||||
#include <boost/variant/apply_visitor.hpp>
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
|
||||
namespace vanetza
|
||||
{
|
||||
namespace security
|
||||
{
|
||||
namespace v2
|
||||
{
|
||||
|
||||
SymmetricAlgorithm get_type(const EncryptionParameter& param)
|
||||
{
|
||||
struct Encryption_visitor : public boost::static_visitor<SymmetricAlgorithm>
|
||||
{
|
||||
SymmetricAlgorithm operator()(const Nonce&)
|
||||
{
|
||||
return SymmetricAlgorithm::AES128_CCM;
|
||||
}
|
||||
};
|
||||
|
||||
Encryption_visitor visit;
|
||||
return boost::apply_visitor(visit, param);
|
||||
}
|
||||
|
||||
void serialize(OutputArchive& ar, const EncryptionParameter& param)
|
||||
{
|
||||
struct Encryption_visitor : public boost::static_visitor<>
|
||||
{
|
||||
Encryption_visitor(OutputArchive& ar) :
|
||||
m_archive(ar)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(const Nonce& nonce)
|
||||
{
|
||||
for (auto& byte : nonce) {
|
||||
m_archive << byte;
|
||||
}
|
||||
}
|
||||
|
||||
OutputArchive& m_archive;
|
||||
};
|
||||
|
||||
SymmetricAlgorithm algo = get_type(param);
|
||||
serialize(ar, algo);
|
||||
Encryption_visitor visit(ar);
|
||||
boost::apply_visitor(visit, param);
|
||||
}
|
||||
|
||||
size_t get_size(const EncryptionParameter& param)
|
||||
{
|
||||
size_t size = sizeof(SymmetricAlgorithm);
|
||||
struct Encryption_visitor : public boost::static_visitor<size_t>
|
||||
{
|
||||
size_t operator()(const Nonce& nonce)
|
||||
{
|
||||
return nonce.size();
|
||||
}
|
||||
};
|
||||
|
||||
Encryption_visitor visit;
|
||||
size += boost::apply_visitor(visit, param);
|
||||
return size;
|
||||
}
|
||||
|
||||
size_t deserialize(InputArchive& ar, EncryptionParameter& param)
|
||||
{
|
||||
SymmetricAlgorithm algo;
|
||||
deserialize(ar, algo);
|
||||
switch (algo) {
|
||||
case SymmetricAlgorithm::AES128_CCM: {
|
||||
Nonce nonce;
|
||||
for (size_t s = 0; s < nonce.size(); s++) {
|
||||
ar >> nonce[s];
|
||||
}
|
||||
param = nonce;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw deserialization_error("Unknown Symmetric Algorithm");
|
||||
break;
|
||||
}
|
||||
return get_size(param);
|
||||
}
|
||||
|
||||
} // namespace v2
|
||||
} // namespace security
|
||||
} // namespace vanetza
|
||||
Reference in New Issue
Block a user