diff options
-rw-r--r-- | command/open_session.cpp | 6 | ||||
-rw-r--r-- | integrity_algo.hpp | 20 |
2 files changed, 22 insertions, 4 deletions
diff --git a/command/open_session.cpp b/command/open_session.cpp index 5b0800f..96507f6 100644 --- a/command/open_session.cpp +++ b/command/open_session.cpp @@ -28,10 +28,8 @@ std::vector<uint8_t> openSession(std::vector<uint8_t>& inPayload, } // Check for valid Integrity Algorithms - if ((request->intAlgo != - static_cast<uint8_t>(cipher::integrity::Algorithms::NONE)) && - (request->intAlgo != - static_cast<uint8_t>(cipher::integrity::Algorithms::HMAC_SHA1_96))) + if(!cipher::integrity::Interface::isAlgorithmSupported(static_cast + <cipher::integrity::Algorithms>(request->intAlgo))) { response->status_code = static_cast<uint8_t>(RAKP_ReturnCode::INVALID_INTEGRITY_ALGO); diff --git a/integrity_algo.hpp b/integrity_algo.hpp index ac06e06..7b895c5 100644 --- a/integrity_algo.hpp +++ b/integrity_algo.hpp @@ -102,6 +102,26 @@ class Interface */ Buffer virtual generateIntegrityData(const Buffer& 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) + { + if (algo == Algorithms::NONE || algo == Algorithms::HMAC_SHA1_96) + { + return true; + } + else + { + return false; + } + } + /* * AuthCode field length varies based on the integrity algorithm, for * HMAC-SHA1-96 the authcode field is 12 bytes. For HMAC-SHA256-128 and |