netipmid: apply clang-format rules
Lots of whitespace change. Let clang-format do its job and keep the code
looking nice.
Change-Id: Idfcad1a99cab8170d55a06163de8ad3f420b68b7
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/integrity_algo.cpp b/integrity_algo.cpp
index 0c3efe8..bac87d7 100644
--- a/integrity_algo.cpp
+++ b/integrity_algo.cpp
@@ -1,8 +1,10 @@
+#include "integrity_algo.hpp"
+
+#include "message_parsers.hpp"
+
#include <openssl/evp.h>
#include <openssl/hmac.h>
#include <openssl/sha.h>
-#include "integrity_algo.hpp"
-#include "message_parsers.hpp"
namespace cipher
{
@@ -10,20 +12,20 @@
namespace integrity
{
-AlgoSHA1::AlgoSHA1(const std::vector<uint8_t>& sik)
- : Interface(SHA1_96_AUTHCODE_LENGTH)
+AlgoSHA1::AlgoSHA1(const std::vector<uint8_t>& sik) :
+ Interface(SHA1_96_AUTHCODE_LENGTH)
{
k1 = generateKn(sik, rmcp::const_1);
}
std::vector<uint8_t> AlgoSHA1::generateHMAC(const uint8_t* input,
- const size_t len) const
+ const size_t len) const
{
std::vector<uint8_t> output(SHA_DIGEST_LENGTH);
unsigned int mdLen = 0;
- if (HMAC(EVP_sha1(), k1.data(), k1.size(), input, len,
- output.data(), &mdLen) == NULL)
+ if (HMAC(EVP_sha1(), k1.data(), k1.size(), input, len, output.data(),
+ &mdLen) == NULL)
{
throw std::runtime_error("Generating integrity data failed");
}
@@ -38,38 +40,36 @@
}
bool AlgoSHA1::verifyIntegrityData(
- const std::vector<uint8_t>& packet,
- const size_t length,
- std::vector<uint8_t>::const_iterator integrityData) const
+ const std::vector<uint8_t>& packet, const size_t length,
+ std::vector<uint8_t>::const_iterator integrityData) const
{
auto output = generateHMAC(
- packet.data() + message::parser::RMCP_SESSION_HEADER_SIZE,
- length);
+ packet.data() + message::parser::RMCP_SESSION_HEADER_SIZE, length);
// Verify if the generated integrity data for the packet and the received
// integrity data matches.
return (std::equal(output.begin(), output.end(), integrityData));
}
-std::vector<uint8_t> AlgoSHA1::generateIntegrityData(
- const std::vector<uint8_t>& packet) const
+std::vector<uint8_t>
+ AlgoSHA1::generateIntegrityData(const std::vector<uint8_t>& packet) const
{
return generateHMAC(
- packet.data() + message::parser::RMCP_SESSION_HEADER_SIZE,
- packet.size() - message::parser::RMCP_SESSION_HEADER_SIZE);
+ packet.data() + message::parser::RMCP_SESSION_HEADER_SIZE,
+ packet.size() - message::parser::RMCP_SESSION_HEADER_SIZE);
}
std::vector<uint8_t> AlgoSHA1::generateKn(const std::vector<uint8_t>& sik,
- const rmcp::Const_n& const_n) const
+ const rmcp::Const_n& const_n) const
{
unsigned int mdLen = 0;
std::vector<uint8_t> Kn(sik.size());
// Generated Kn for the integrity algorithm with the additional key keyed
// with SIK.
- if (HMAC(EVP_sha1(), sik.data(), sik.size(), const_n.data(),
- const_n.size(), Kn.data(), &mdLen) == NULL)
+ if (HMAC(EVP_sha1(), sik.data(), sik.size(), const_n.data(), const_n.size(),
+ Kn.data(), &mdLen) == NULL)
{
throw std::runtime_error("Generating KeyN for integrity "
"algorithm failed");
@@ -77,20 +77,20 @@
return Kn;
}
-AlgoSHA256::AlgoSHA256(const std::vector<uint8_t>& sik)
- : Interface(SHA256_128_AUTHCODE_LENGTH)
+AlgoSHA256::AlgoSHA256(const std::vector<uint8_t>& sik) :
+ Interface(SHA256_128_AUTHCODE_LENGTH)
{
k1 = generateKn(sik, rmcp::const_1);
}
std::vector<uint8_t> AlgoSHA256::generateHMAC(const uint8_t* input,
- const size_t len) const
+ const size_t len) const
{
std::vector<uint8_t> output(SHA256_DIGEST_LENGTH);
unsigned int mdLen = 0;
- if (HMAC(EVP_sha256(), k1.data(), k1.size(), input, len,
- output.data(), &mdLen) == NULL)
+ if (HMAC(EVP_sha256(), k1.data(), k1.size(), input, len, output.data(),
+ &mdLen) == NULL)
{
throw std::runtime_error("Generating HMAC_SHA256_128 failed");
}
@@ -105,30 +105,28 @@
}
bool AlgoSHA256::verifyIntegrityData(
- const std::vector<uint8_t>& packet,
- const size_t length,
- std::vector<uint8_t>::const_iterator integrityData) const
+ const std::vector<uint8_t>& packet, const size_t length,
+ std::vector<uint8_t>::const_iterator integrityData) const
{
auto output = generateHMAC(
- packet.data() + message::parser::RMCP_SESSION_HEADER_SIZE,
- length);
+ packet.data() + message::parser::RMCP_SESSION_HEADER_SIZE, length);
// Verify if the generated integrity data for the packet and the received
// integrity data matches.
return (std::equal(output.begin(), output.end(), integrityData));
}
-std::vector<uint8_t> AlgoSHA256::generateIntegrityData(
- const std::vector<uint8_t>& packet) const
+std::vector<uint8_t>
+ AlgoSHA256::generateIntegrityData(const std::vector<uint8_t>& packet) const
{
return generateHMAC(
- packet.data() + message::parser::RMCP_SESSION_HEADER_SIZE,
- packet.size() - message::parser::RMCP_SESSION_HEADER_SIZE);
+ packet.data() + message::parser::RMCP_SESSION_HEADER_SIZE,
+ packet.size() - message::parser::RMCP_SESSION_HEADER_SIZE);
}
std::vector<uint8_t> AlgoSHA256::generateKn(const std::vector<uint8_t>& sik,
- const rmcp::Const_n& const_n) const
+ const rmcp::Const_n& const_n) const
{
unsigned int mdLen = 0;
std::vector<uint8_t> Kn(sik.size());
@@ -144,6 +142,6 @@
return Kn;
}
-}// namespace integrity
+} // namespace integrity
-}// namespace cipher
+} // namespace cipher