summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Joseph <tomjoseph@in.ibm.com>2017-02-24 17:16:49 +0530
committerPatrick Williams <patrick@stwcx.xyz>2017-02-24 17:02:46 +0000
commit1e7aa196037367c44fc7e61903890505a1104615 (patch)
tree08cb286026fe7bf5373805a57387795713a1debf
parent32db22e9a57e50c29077ef0173495c98df69073d (diff)
downloadphosphor-net-ipmid-1e7aa196037367c44fc7e61903890505a1104615.tar.gz
phosphor-net-ipmid-1e7aa196037367c44fc7e61903890505a1104615.zip
Validate Integrity Algorithm in Open Session Request command
Change-Id: I54106099fbbe50156529644eaadd65dc1db7e141 Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
-rw-r--r--command/open_session.cpp6
-rw-r--r--integrity_algo.hpp20
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
OpenPOWER on IntegriCloud