Clean up: Function abstraction in password file

Abstracted verifyPassword function in password source file
to make it more readable by creating a new function named
verifyIntegrityCheck.

Tested:
No oob-bios functionality impact.

Change-Id: I2a37eb12cbf33bcb560a819be37471adfde410b6
Signed-off-by: Smriti-Ayushi <smriti.ayushi@linux.intel.com>
diff --git a/include/password.hpp b/include/password.hpp
index ede47b7..52e5ab9 100644
--- a/include/password.hpp
+++ b/include/password.hpp
@@ -84,6 +84,10 @@
     bool isMatch(const std::array<uint8_t, maxHashSize>& expected,
                  const std::array<uint8_t, maxSeedSize>& seed,
                  const std::string& rawData, const std::string& algo);
+    bool getParam(std::array<uint8_t, maxHashSize>& orgUsrPwdHash,
+                  std::array<uint8_t, maxHashSize>& orgAdminPwdHash,
+                  std::array<uint8_t, maxSeedSize>& seed,
+                  std::string& hashAlgo);
     bool verifyIntegrityCheck(std::string& newPassword,
                               std::array<uint8_t, maxSeedSize>& seed,
                               unsigned int mdLen, const EVP_MD* digestFunc);
diff --git a/src/password.cpp b/src/password.cpp
index d942d85..0e348ce 100644
--- a/src/password.cpp
+++ b/src/password.cpp
@@ -81,6 +81,45 @@
     return false;
 }
 
+bool Password::getParam(std::array<uint8_t, maxHashSize>& orgUsrPwdHash,
+                        std::array<uint8_t, maxHashSize>& orgAdminPwdHash,
+                        std::array<uint8_t, maxSeedSize>& seed,
+                        std::string& hashAlgo)
+{
+    try
+    {
+        nlohmann::json json = nullptr;
+        std::ifstream ifs(seedFile.c_str());
+        if (ifs.is_open())
+        {
+            try
+            {
+                json = nlohmann::json::parse(ifs, nullptr, false);
+            }
+            catch (const nlohmann::json::parse_error& e)
+            {
+                lg2::error("Failed to parse JSON file: {ERROR}", "ERROR", e);
+                return false;
+            }
+
+            if (!json.is_discarded())
+            {
+                orgUsrPwdHash = json["UserPwdHash"];
+                orgAdminPwdHash = json["AdminPwdHash"];
+                seed = json["Seed"];
+                hashAlgo = json["HashAlgo"];
+            }
+        }
+    }
+    catch (nlohmann::detail::exception& e)
+    {
+        lg2::error("Failed to parse JSON file: {ERROR}", "ERROR", e);
+        return false;
+    }
+
+    return true;
+}
+
 bool Password::verifyIntegrityCheck(std::string& newPassword,
                                     std::array<uint8_t, maxSeedSize>& seed,
                                     unsigned int mdLen,
@@ -110,42 +149,20 @@
         std::array<uint8_t, maxHashSize> orgAdminPwdHash;
         std::array<uint8_t, maxSeedSize> seed;
         std::string hashAlgo = "";
-        try
-        {
-            nlohmann::json json = nullptr;
-            std::ifstream ifs(seedFile.c_str());
-            if (ifs.is_open())
-            {
-                try
-                {
-                    json = nlohmann::json::parse(ifs, nullptr, false);
-                }
-                catch (const nlohmann::json::parse_error& e)
-                {
-                    lg2::error("Failed to parse JSON file: {ERROR}", "ERROR",
-                               e);
-                    throw InternalFailure();
-                }
 
-                if (json.is_discarded())
-                {
-                    return;
-                }
-                orgUsrPwdHash = json["UserPwdHash"];
-                orgAdminPwdHash = json["AdminPwdHash"];
-                seed = json["Seed"];
-                hashAlgo = json["HashAlgo"];
-            }
-            else
+        if (getParam(orgUsrPwdHash, orgAdminPwdHash, seed, hashAlgo))
+        {
+            if (orgUsrPwdHash.empty() || orgAdminPwdHash.empty() ||
+                seed.empty() || hashAlgo.empty())
             {
                 return;
             }
         }
-        catch (nlohmann::detail::exception& e)
+        else
         {
-            lg2::error("Failed to parse JSON file: {ERROR}", "ERROR", e);
             throw InternalFailure();
         }
+
         if (userName == "AdminPassword")
         {
             if (!isMatch(orgAdminPwdHash, seed, currentPassword, hashAlgo))