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.hpp b/integrity_algo.hpp
index 3d56b82..6c8460f 100644
--- a/integrity_algo.hpp
+++ b/integrity_algo.hpp
@@ -1,8 +1,9 @@
#pragma once
+#include "rmcp.hpp"
+
#include <array>
#include <vector>
-#include "rmcp.hpp"
namespace cipher
{
@@ -39,109 +40,107 @@
*/
class Interface
{
- public:
- /**
- * @brief Constructor for Interface
- *
- * @param[in] - AuthCode length
- */
- explicit Interface(size_t authLength)
- : authCodeLength(authLength) {}
+ public:
+ /**
+ * @brief Constructor for Interface
+ *
+ * @param[in] - AuthCode length
+ */
+ explicit Interface(size_t authLength) : authCodeLength(authLength)
+ {
+ }
- Interface() = delete;
- virtual ~Interface() = default;
- Interface(const Interface&) = default;
- Interface& operator=(const Interface&) = default;
- Interface(Interface&&) = default;
- Interface& operator=(Interface&&) = default;
+ Interface() = delete;
+ virtual ~Interface() = default;
+ Interface(const Interface&) = default;
+ Interface& operator=(const Interface&) = default;
+ Interface(Interface&&) = default;
+ Interface& operator=(Interface&&) = default;
- /**
- * @brief Verify the integrity data of the packet
- *
- * @param[in] packet - Incoming IPMI packet
- * @param[in] packetLen - Packet length excluding authCode
- * @param[in] integrityData - Iterator to the authCode in the packet
- *
- * @return true if authcode in the packet is equal to one generated
- * using integrity algorithm on the packet data, false otherwise
- */
- bool virtual verifyIntegrityData(
- const std::vector<uint8_t>& packet,
- const size_t packetLen,
- std::vector<uint8_t>::const_iterator integrityData) const = 0;
+ /**
+ * @brief Verify the integrity data of the packet
+ *
+ * @param[in] packet - Incoming IPMI packet
+ * @param[in] packetLen - Packet length excluding authCode
+ * @param[in] integrityData - Iterator to the authCode in the packet
+ *
+ * @return true if authcode in the packet is equal to one generated
+ * using integrity algorithm on the packet data, false otherwise
+ */
+ bool virtual verifyIntegrityData(
+ const std::vector<uint8_t>& packet, const size_t packetLen,
+ std::vector<uint8_t>::const_iterator integrityData) const = 0;
- /**
- * @brief Generate integrity data for the outgoing IPMI packet
- *
- * @param[in] input - Outgoing IPMI packet
- *
- * @return authcode for the outgoing IPMI packet
- *
- */
- std::vector<uint8_t> virtual generateIntegrityData(
- const std::vector<uint8_t>& input) const = 0;
+ /**
+ * @brief Generate integrity data for the outgoing IPMI packet
+ *
+ * @param[in] input - Outgoing IPMI packet
+ *
+ * @return authcode for the outgoing IPMI packet
+ *
+ */
+ std::vector<uint8_t> virtual generateIntegrityData(
+ const std::vector<uint8_t>& input) const = 0;
- /**
- * @brief Check if the Integrity algorithm is supported
- *
- * @param[in] algo - integrity algorithm
- *
- * @return true if algorithm is supported else false
- *
- */
- static bool isAlgorithmSupported(Algorithms algo)
+ /**
+ * @brief Check if the Integrity algorithm is supported
+ *
+ * @param[in] algo - integrity algorithm
+ *
+ * @return true if algorithm is supported else false
+ *
+ */
+ static bool isAlgorithmSupported(Algorithms algo)
+ {
+ if (algo == Algorithms::HMAC_SHA1_96 ||
+ algo == Algorithms::HMAC_SHA256_128)
{
- if (algo == Algorithms::HMAC_SHA1_96 ||
- algo == Algorithms::HMAC_SHA256_128)
- {
- return true;
- }
- else
- {
- return false;
- }
+ return true;
}
+ else
+ {
+ return false;
+ }
+ }
- /**
- * @brief Generate additional keying material based on SIK
- *
- * @note
- * The IPMI 2.0 spec only states that the additional keying material is
- * generated by running HMAC(constN) using SIK as the key. It does not
- * state whether this is the integrity algorithm or the authentication
- * algorithm. Other implementations of the RMCP+ algorithm (ipmitool
- * and ipmiutil) are not consistent on this matter. But it does not
- * really matter because based on any of the defined cipher suites, the
- * integrity and authentication algorithms are both based on the same
- * digest method (integrity::Algorithms::HMAC_SHA1_96 uses SHA1 and
- * rakp_auth::Algorithms::RAKP_HMAC_SHA1 uses SHA1). None of the
- * defined cipher suites mix and match digests for integrity and
- * authentication. Generating Kn belongs in either the integrity or
- * authentication classes, so in this implementation, integrity has
- * been chosen.
- *
- * @param[in] sik - session integrity key
- * @param[in] data - 20-byte Const_n
- *
- * @return on success returns the Kn based on this integrity class
- *
- */
- std::vector<uint8_t> virtual generateKn(
- const std::vector<uint8_t>& sik,
- const rmcp::Const_n& data) const = 0;
+ /**
+ * @brief Generate additional keying material based on SIK
+ *
+ * @note
+ * The IPMI 2.0 spec only states that the additional keying material is
+ * generated by running HMAC(constN) using SIK as the key. It does not
+ * state whether this is the integrity algorithm or the authentication
+ * algorithm. Other implementations of the RMCP+ algorithm (ipmitool
+ * and ipmiutil) are not consistent on this matter. But it does not
+ * really matter because based on any of the defined cipher suites, the
+ * integrity and authentication algorithms are both based on the same
+ * digest method (integrity::Algorithms::HMAC_SHA1_96 uses SHA1 and
+ * rakp_auth::Algorithms::RAKP_HMAC_SHA1 uses SHA1). None of the
+ * defined cipher suites mix and match digests for integrity and
+ * authentication. Generating Kn belongs in either the integrity or
+ * authentication classes, so in this implementation, integrity has
+ * been chosen.
+ *
+ * @param[in] sik - session integrity key
+ * @param[in] data - 20-byte Const_n
+ *
+ * @return on success returns the Kn based on this integrity class
+ *
+ */
+ std::vector<uint8_t> virtual generateKn(
+ const std::vector<uint8_t>& sik, const rmcp::Const_n& data) const = 0;
- /** @brief Authcode field
- *
- * AuthCode field length varies based on the integrity algorithm, for
- * HMAC-SHA1-96 the authcode field is 12 bytes. For HMAC-SHA256-128 and
- * HMAC-MD5-128 the authcode field is 16 bytes.
- */
- size_t authCodeLength;
+ /** @brief Authcode field
+ *
+ * AuthCode field length varies based on the integrity algorithm, for
+ * HMAC-SHA1-96 the authcode field is 12 bytes. For HMAC-SHA256-128 and
+ * HMAC-MD5-128 the authcode field is 16 bytes.
+ */
+ size_t authCodeLength;
- protected:
-
- /** @brief K1 key used to generated the integrity data. */
- std::vector<uint8_t> k1;
+ protected:
+ /** @brief K1 key used to generated the integrity data. */
+ std::vector<uint8_t> k1;
};
/**
@@ -157,76 +156,73 @@
*/
class AlgoSHA1 final : public Interface
{
- public:
- static constexpr size_t SHA1_96_AUTHCODE_LENGTH = 12;
+ public:
+ static constexpr size_t SHA1_96_AUTHCODE_LENGTH = 12;
- /**
- * @brief Constructor for AlgoSHA1
- *
- * @param[in] - Session Integrity Key
- */
- explicit AlgoSHA1(const std::vector<uint8_t>& sik);
+ /**
+ * @brief Constructor for AlgoSHA1
+ *
+ * @param[in] - Session Integrity Key
+ */
+ explicit AlgoSHA1(const std::vector<uint8_t>& sik);
- AlgoSHA1() = delete;
- ~AlgoSHA1() = default;
- AlgoSHA1(const AlgoSHA1&) = default;
- AlgoSHA1& operator=(const AlgoSHA1&) = default;
- AlgoSHA1(AlgoSHA1&&) = default;
- AlgoSHA1& operator=(AlgoSHA1&&) = default;
+ AlgoSHA1() = delete;
+ ~AlgoSHA1() = default;
+ AlgoSHA1(const AlgoSHA1&) = default;
+ AlgoSHA1& operator=(const AlgoSHA1&) = default;
+ AlgoSHA1(AlgoSHA1&&) = default;
+ AlgoSHA1& operator=(AlgoSHA1&&) = default;
- /**
- * @brief Verify the integrity data of the packet
- *
- * @param[in] packet - Incoming IPMI packet
- * @param[in] length - Length of the data in the packet to calculate
- * the integrity data
- * @param[in] integrityData - Iterator to the authCode in the packet
- *
- * @return true if authcode in the packet is equal to one generated
- * using integrity algorithm on the packet data, false otherwise
- */
- bool verifyIntegrityData(
- const std::vector<uint8_t>& packet,
- const size_t length,
- std::vector<uint8_t>::const_iterator integrityData)
- const override;
+ /**
+ * @brief Verify the integrity data of the packet
+ *
+ * @param[in] packet - Incoming IPMI packet
+ * @param[in] length - Length of the data in the packet to calculate
+ * the integrity data
+ * @param[in] integrityData - Iterator to the authCode in the packet
+ *
+ * @return true if authcode in the packet is equal to one generated
+ * using integrity algorithm on the packet data, false otherwise
+ */
+ bool verifyIntegrityData(
+ const std::vector<uint8_t>& packet, const size_t length,
+ std::vector<uint8_t>::const_iterator integrityData) const override;
- /**
- * @brief Generate integrity data for the outgoing IPMI packet
- *
- * @param[in] input - Outgoing IPMI packet
- *
- * @return on success return the integrity data for the outgoing IPMI
- * packet
- */
- std::vector<uint8_t> generateIntegrityData(
- const std::vector<uint8_t>& packet) const override;
+ /**
+ * @brief Generate integrity data for the outgoing IPMI packet
+ *
+ * @param[in] input - Outgoing IPMI packet
+ *
+ * @return on success return the integrity data for the outgoing IPMI
+ * packet
+ */
+ std::vector<uint8_t> generateIntegrityData(
+ const std::vector<uint8_t>& packet) const override;
- /**
- * @brief Generate additional keying material based on SIK
- *
- * @param[in] sik - session integrity key
- * @param[in] data - 20-byte Const_n
- *
- * @return on success returns the Kn based on HMAC-SHA1
- *
- */
- std::vector<uint8_t> generateKn(
- const std::vector<uint8_t>& sik,
- const rmcp::Const_n& const_n) const;
+ /**
+ * @brief Generate additional keying material based on SIK
+ *
+ * @param[in] sik - session integrity key
+ * @param[in] data - 20-byte Const_n
+ *
+ * @return on success returns the Kn based on HMAC-SHA1
+ *
+ */
+ std::vector<uint8_t> generateKn(const std::vector<uint8_t>& sik,
+ const rmcp::Const_n& const_n) const;
- private:
- /**
- * @brief Generate HMAC based on HMAC-SHA1-96 algorithm
- *
- * @param[in] input - pointer to the message
- * @param[in] length - length of the message
- *
- * @return on success returns the message authentication code
- *
- */
- std::vector<uint8_t> generateHMAC(const uint8_t* input,
- const size_t len) const;
+ private:
+ /**
+ * @brief Generate HMAC based on HMAC-SHA1-96 algorithm
+ *
+ * @param[in] input - pointer to the message
+ * @param[in] length - length of the message
+ *
+ * @return on success returns the message authentication code
+ *
+ */
+ std::vector<uint8_t> generateHMAC(const uint8_t* input,
+ const size_t len) const;
};
/**
@@ -242,79 +238,75 @@
*/
class AlgoSHA256 final : public Interface
{
- public:
- static constexpr size_t SHA256_128_AUTHCODE_LENGTH = 16;
+ public:
+ static constexpr size_t SHA256_128_AUTHCODE_LENGTH = 16;
- /**
- * @brief Constructor for AlgoSHA256
- *
- * @param[in] - Session Integrity Key
- */
- explicit AlgoSHA256(const std::vector<uint8_t>& sik);
+ /**
+ * @brief Constructor for AlgoSHA256
+ *
+ * @param[in] - Session Integrity Key
+ */
+ explicit AlgoSHA256(const std::vector<uint8_t>& sik);
- AlgoSHA256() = delete;
- ~AlgoSHA256() = default;
- AlgoSHA256(const AlgoSHA256&) = default;
- AlgoSHA256& operator=(const AlgoSHA256&) = default;
- AlgoSHA256(AlgoSHA256&&) = default;
- AlgoSHA256& operator=(AlgoSHA256&&) = default;
+ AlgoSHA256() = delete;
+ ~AlgoSHA256() = default;
+ AlgoSHA256(const AlgoSHA256&) = default;
+ AlgoSHA256& operator=(const AlgoSHA256&) = default;
+ AlgoSHA256(AlgoSHA256&&) = default;
+ AlgoSHA256& operator=(AlgoSHA256&&) = default;
- /**
- * @brief Verify the integrity data of the packet
- *
- * @param[in] packet - Incoming IPMI packet
- * @param[in] length - Length of the data in the packet to calculate
- * the integrity data
- * @param[in] integrityData - Iterator to the authCode in the packet
- *
- * @return true if authcode in the packet is equal to one generated
- * using integrity algorithm on the packet data, false otherwise
- */
- bool verifyIntegrityData(
- const std::vector<uint8_t>& packet,
- const size_t length,
- std::vector<uint8_t>::const_iterator integrityData)
- const override;
+ /**
+ * @brief Verify the integrity data of the packet
+ *
+ * @param[in] packet - Incoming IPMI packet
+ * @param[in] length - Length of the data in the packet to calculate
+ * the integrity data
+ * @param[in] integrityData - Iterator to the authCode in the packet
+ *
+ * @return true if authcode in the packet is equal to one generated
+ * using integrity algorithm on the packet data, false otherwise
+ */
+ bool verifyIntegrityData(
+ const std::vector<uint8_t>& packet, const size_t length,
+ std::vector<uint8_t>::const_iterator integrityData) const override;
- /**
- * @brief Generate integrity data for the outgoing IPMI packet
- *
- * @param[in] packet - Outgoing IPMI packet
- *
- * @return on success return the integrity data for the outgoing IPMI
- * packet
- */
- std::vector<uint8_t> generateIntegrityData(
- const std::vector<uint8_t>& packet) const override;
+ /**
+ * @brief Generate integrity data for the outgoing IPMI packet
+ *
+ * @param[in] packet - Outgoing IPMI packet
+ *
+ * @return on success return the integrity data for the outgoing IPMI
+ * packet
+ */
+ std::vector<uint8_t> generateIntegrityData(
+ const std::vector<uint8_t>& packet) const override;
- /**
- * @brief Generate additional keying material based on SIK
- *
- * @param[in] sik - session integrity key
- * @param[in] data - 20-byte Const_n
- *
- * @return on success returns the Kn based on HMAC-SHA256
- *
- */
- std::vector<uint8_t> generateKn(
- const std::vector<uint8_t>& sik,
- const rmcp::Const_n& const_n) const;
+ /**
+ * @brief Generate additional keying material based on SIK
+ *
+ * @param[in] sik - session integrity key
+ * @param[in] data - 20-byte Const_n
+ *
+ * @return on success returns the Kn based on HMAC-SHA256
+ *
+ */
+ std::vector<uint8_t> generateKn(const std::vector<uint8_t>& sik,
+ const rmcp::Const_n& const_n) const;
- private:
- /**
- * @brief Generate HMAC based on HMAC-SHA256-128 algorithm
- *
- * @param[in] input - pointer to the message
- * @param[in] len - length of the message
- *
- * @return on success returns the message authentication code
- *
- */
- std::vector<uint8_t> generateHMAC(const uint8_t* input,
- const size_t len) const;
+ private:
+ /**
+ * @brief Generate HMAC based on HMAC-SHA256-128 algorithm
+ *
+ * @param[in] input - pointer to the message
+ * @param[in] len - length of the message
+ *
+ * @return on success returns the message authentication code
+ *
+ */
+ std::vector<uint8_t> generateHMAC(const uint8_t* input,
+ const size_t len) const;
};
-}// namespace integrity
+} // namespace integrity
-}// namespace cipher
-
+} // namespace cipher