util: create util object for bmc and tool

Create a common util object for the BMC library and host tool.  Place in
blobs namespace favoring BMC.

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I036fd65d924c65fcfa71aba5cd76275a2941ff14
diff --git a/Makefile.am b/Makefile.am
index 8789663..872b61c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -39,6 +39,7 @@
 
 noinst_LTLIBRARIES = libfirmwareblob_common.la
 libfirmwareblob_common_la_SOURCES = \
+	util.cpp \
 	firmware_handler.cpp \
 	file_handler.cpp \
 	internal/sys.cpp
diff --git a/firmware_handler.cpp b/firmware_handler.cpp
index 87116b2..7f86d5f 100644
--- a/firmware_handler.cpp
+++ b/firmware_handler.cpp
@@ -17,6 +17,7 @@
 #include "firmware_handler.hpp"
 
 #include "image_handler.hpp"
+#include "util.hpp"
 
 #include <algorithm>
 #include <cstdint>
@@ -38,12 +39,6 @@
 static constexpr auto verifyTarget = "verify_image.service";
 static constexpr auto statusPath = "/tmp/bmc.verify";
 
-const std::string FirmwareBlobHandler::verifyBlobID = "/flash/verify";
-const std::string FirmwareBlobHandler::hashBlobID = "/flash/hash";
-const std::string FirmwareBlobHandler::activeImageBlobID =
-    "/flash/active/image";
-const std::string FirmwareBlobHandler::activeHashBlobID = "/flash/active/hash";
-
 namespace
 {
 
@@ -102,9 +97,9 @@
     {
         blobs.push_back(item.blobName);
     }
-    blobs.push_back(verifyBlobID); /* Add blob_id to always exist. */
+    blobs.push_back(verifyBlobId); /* Add blob_id to always exist. */
 
-    if (0 == std::count(blobs.begin(), blobs.end(), hashBlobID))
+    if (0 == std::count(blobs.begin(), blobs.end(), hashBlobId))
     {
         return nullptr;
     }
@@ -160,20 +155,20 @@
      * no impact.
      * TODO: Should trying to delete this cause an abort?
      */
-    if (path == verifyBlobID)
+    if (path == verifyBlobId)
     {
         return false;
     }
 
-    if (path == hashBlobID || path == activeHashBlobID)
+    if (path == hashBlobId || path == activeHashBlobId)
     {
         /* They're deleting the hash. */
-        toDelete = &activeHashBlobID;
+        toDelete = &activeHashBlobId;
     }
     else
     {
         /* They're deleting the image. */
-        toDelete = &activeImageBlobID;
+        toDelete = &activeImageBlobId;
     }
 
     auto it = std::find_if(
@@ -205,17 +200,17 @@
 bool FirmwareBlobHandler::stat(const std::string& path, struct BlobMeta* meta)
 {
     /* We know we support this path because canHandle is called ahead */
-    if (path == verifyBlobID)
+    if (path == verifyBlobId)
     {
         /* TODO: We need to return information for the verify state -- did they
          * call commit() did things start?
          */
     }
-    else if (path == activeImageBlobID)
+    else if (path == activeImageBlobId)
     {
         /* TODO: We need to return information for the image that's staged. */
     }
-    else if (path == activeHashBlobID)
+    else if (path == activeHashBlobId)
     {
         /* TODO: We need to return information for the hash that's staged. */
     }
@@ -263,7 +258,7 @@
      * Calling stat() on the verify blob without an active session should not
      * provide insight.
      */
-    if (item->second->activePath == verifyBlobID)
+    if (item->second->activePath == verifyBlobId)
     {
         auto value = checkVerificationState();
 
@@ -367,7 +362,7 @@
      * The file must be opened for writing, but no transport mechanism specified
      * since it's irrelevant.
      */
-    if (path == verifyBlobID)
+    if (path == verifyBlobId)
     {
         /* In this case, there's no image handler to use, or data handler,
          * simply set up a session.
@@ -397,14 +392,14 @@
     }
 
     /* 2) there isn't, so what are they opening? */
-    if (path == activeImageBlobID)
+    if (path == activeImageBlobId)
     {
         /* 2a) are they opening the active image? this can only happen if they
          * already started one (due to canHandleBlob's behavior).
          */
         return false;
     }
-    else if (path == activeHashBlobID)
+    else if (path == activeHashBlobId)
     {
         /* 2b) are they opening the active hash? this can only happen if they
          * already started one (due to canHandleBlob's behavior).
@@ -461,16 +456,16 @@
     Session* curr;
     const std::string* active;
 
-    if (path == hashBlobID)
+    if (path == hashBlobId)
     {
         /* 2c) are they opening the /flash/hash ? (to start the process) */
         curr = &activeHash;
-        active = &activeHashBlobID;
+        active = &activeHashBlobId;
     }
     else
     {
         curr = &activeImage;
-        active = &activeImageBlobID;
+        active = &activeImageBlobId;
     }
 
     curr->flags = flags;
@@ -523,7 +518,7 @@
     /* Prevent writing to the verification blob before they trigger
      * verification.
      */
-    if (item->second->activePath == verifyBlobID)
+    if (item->second->activePath == verifyBlobId)
     {
         return false;
     }
@@ -585,7 +580,7 @@
 }
 
 /*
- * If this command is called on the session for the verifyBlobID, it'll
+ * If this command is called on the session for the verifyBlobId, it'll
  * trigger a systemd service `verify_image.service` to attempt to verify
  * the image.
  *
@@ -602,7 +597,7 @@
     }
 
     /* You can only commit on the verifyBlodId */
-    if (item->second->activePath != verifyBlobID)
+    if (item->second->activePath != verifyBlobId)
     {
         return false;
     }
@@ -639,7 +634,7 @@
     }
 
     /* Are you closing the verify blob? */
-    if (item->second->activePath == verifyBlobID)
+    if (item->second->activePath == verifyBlobId)
     {
         if (state == UpdateState::verificationStarted)
         {
@@ -655,9 +650,9 @@
 
             /* A this point, delete the active blob IDs from the blob_list. */
             blobIDs.erase(
-                std::remove(blobIDs.begin(), blobIDs.end(), activeImageBlobID));
+                std::remove(blobIDs.begin(), blobIDs.end(), activeImageBlobId));
             blobIDs.erase(
-                std::remove(blobIDs.begin(), blobIDs.end(), activeHashBlobID));
+                std::remove(blobIDs.begin(), blobIDs.end(), activeHashBlobId));
         }
         /* Must be verificationPending... not yet started, they may re-open and
          * trigger verification.
diff --git a/firmware_handler.hpp b/firmware_handler.hpp
index 314516f..3e36897 100644
--- a/firmware_handler.hpp
+++ b/firmware_handler.hpp
@@ -4,6 +4,7 @@
 
 #include "data_handler.hpp"
 #include "image_handler.hpp"
+#include "util.hpp"
 
 #include <blobs-ipmid/blobs.hpp>
 #include <cstdint>
@@ -146,8 +147,8 @@
                         std::uint16_t bitmask) :
         bus(std::move(bus)),
         handlers(firmwares), blobIDs(blobs), transports(transports),
-        bitmask(bitmask), activeImage(activeImageBlobID),
-        activeHash(activeHashBlobID), verifyImage(verifyBlobID), lookup(),
+        bitmask(bitmask), activeImage(activeImageBlobId),
+        activeHash(activeHashBlobId), verifyImage(verifyBlobId), lookup(),
         state(UpdateState::notYetStarted)
     {
     }
@@ -176,11 +177,6 @@
 
     bool triggerVerification();
 
-    static const std::string verifyBlobID;
-    static const std::string hashBlobID;
-    static const std::string activeImageBlobID;
-    static const std::string activeHashBlobID;
-
     /** Allow grabbing the current state. */
     UpdateState getCurrentState() const
     {
diff --git a/main.cpp b/main.cpp
index e9de21c..4dc8c27 100644
--- a/main.cpp
+++ b/main.cpp
@@ -23,6 +23,7 @@
 #include "lpc_handler.hpp"
 #include "lpc_nuvoton.hpp"
 #include "pci_handler.hpp"
+#include "util.hpp"
 
 #include <cstdint>
 #include <memory>
@@ -61,12 +62,12 @@
 #endif
 
 std::vector<HandlerPack> supportedFirmware = {
-    {FirmwareBlobHandler::hashBlobID, &hashHandler},
+    {hashBlobId, &hashHandler},
 #ifdef ENABLE_STATIC_LAYOUT
-    {"/flash/image", &staticLayoutHandler},
+    {staticLayoutBlobId, &staticLayoutHandler},
 #endif
 #ifdef ENABLE_TARBALL_UBI
-    {"/flash/tarball", &ubitarballHandler},
+    {ubiTarballBlobId, &ubitarballHandler},
 #endif
 };
 
diff --git a/test/firmware_canhandle_unittest.cpp b/test/firmware_canhandle_unittest.cpp
index 21dc6a0..1ec83bd 100644
--- a/test/firmware_canhandle_unittest.cpp
+++ b/test/firmware_canhandle_unittest.cpp
@@ -1,6 +1,7 @@
 #include "data_mock.hpp"
 #include "firmware_handler.hpp"
 #include "image_mock.hpp"
+#include "util.hpp"
 
 #include <sdbusplus/test/sdbus_mock.hpp>
 #include <vector>
@@ -23,7 +24,7 @@
     ImageHandlerMock imageMock;
 
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock},
+        {hashBlobId, &imageMock},
         {"asdf", &imageMock},
         {"bcdf", &imageMock},
     };
diff --git a/test/firmware_close_unittest.cpp b/test/firmware_close_unittest.cpp
index c5b8902..5bede33 100644
--- a/test/firmware_close_unittest.cpp
+++ b/test/firmware_close_unittest.cpp
@@ -1,6 +1,7 @@
 #include "data_mock.hpp"
 #include "firmware_handler.hpp"
 #include "image_mock.hpp"
+#include "util.hpp"
 
 #include <sdbusplus/test/sdbus_mock.hpp>
 #include <vector>
@@ -23,7 +24,7 @@
     ImageHandlerMock imageMock;
 
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock},
+        {hashBlobId, &imageMock},
         {"asdf", &imageMock},
     };
     std::vector<DataHandlerPack> data = {
@@ -38,18 +39,17 @@
         std::move(bus_mock), blobs, data);
 
     EXPECT_CALL(dataMock, open()).WillOnce(Return(true));
-    EXPECT_CALL(imageMock, open(Eq(FirmwareBlobHandler::hashBlobID)))
-        .WillOnce(Return(true));
+    EXPECT_CALL(imageMock, open(StrEq(hashBlobId))).WillOnce(Return(true));
 
     EXPECT_TRUE(handler->open(
         0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::lpc,
-        FirmwareBlobHandler::hashBlobID));
+        hashBlobId));
 
     /* The active hash blob_id was added. */
     auto currentBlobs = handler->getBlobIds();
     EXPECT_EQ(4, currentBlobs.size());
     EXPECT_EQ(1, std::count(currentBlobs.begin(), currentBlobs.end(),
-                            FirmwareBlobHandler::activeHashBlobID));
+                            activeHashBlobId));
 
     /* Set up close() expectations. */
     EXPECT_CALL(dataMock, close());
@@ -70,7 +70,7 @@
     ImageHandlerMock imageMock;
 
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock},
+        {hashBlobId, &imageMock},
         {"asdf", &imageMock},
     };
     std::vector<DataHandlerPack> data = {
@@ -84,18 +84,17 @@
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
         std::move(bus_mock), blobs, data);
 
-    EXPECT_CALL(imageMock, open(Eq(FirmwareBlobHandler::hashBlobID)))
-        .WillOnce(Return(true));
+    EXPECT_CALL(imageMock, open(StrEq(hashBlobId))).WillOnce(Return(true));
 
     EXPECT_TRUE(handler->open(
         0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi,
-        FirmwareBlobHandler::hashBlobID));
+        hashBlobId));
 
     /* The active hash blob_id was added. */
     auto currentBlobs = handler->getBlobIds();
     EXPECT_EQ(4, currentBlobs.size());
     EXPECT_EQ(1, std::count(currentBlobs.begin(), currentBlobs.end(),
-                            FirmwareBlobHandler::activeHashBlobID));
+                            activeHashBlobId));
 
     /* Set up close() expectations. */
     EXPECT_CALL(imageMock, close());
diff --git a/test/firmware_commit_unittest.cpp b/test/firmware_commit_unittest.cpp
index 425e7b9..2137383 100644
--- a/test/firmware_commit_unittest.cpp
+++ b/test/firmware_commit_unittest.cpp
@@ -1,6 +1,7 @@
 #include "data_mock.hpp"
 #include "firmware_handler.hpp"
 #include "image_mock.hpp"
+#include "util.hpp"
 
 #include <sdbusplus/test/sdbus_mock.hpp>
 #include <vector>
@@ -23,7 +24,7 @@
      */
     ImageHandlerMock imageMock1, imageMock2;
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock1},
+        {hashBlobId, &imageMock1},
         {"asdf", &imageMock2},
     };
 
@@ -52,7 +53,7 @@
      */
     ImageHandlerMock imageMock1, imageMock2;
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock1},
+        {hashBlobId, &imageMock1},
         {"asdf", &imageMock2},
     };
 
@@ -66,12 +67,11 @@
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
         std::move(bus_mock), blobs, data);
 
-    EXPECT_CALL(imageMock1, open(FirmwareBlobHandler::hashBlobID))
-        .WillOnce(Return(true));
+    EXPECT_CALL(imageMock1, open(StrEq(hashBlobId))).WillOnce(Return(true));
 
     EXPECT_TRUE(handler->open(
         0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi,
-        FirmwareBlobHandler::hashBlobID));
+        hashBlobId));
 
     EXPECT_FALSE(handler->commit(0, {}));
 }
@@ -83,7 +83,7 @@
      */
     ImageHandlerMock imageMock1, imageMock2;
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock1},
+        {hashBlobId, &imageMock1},
         {"asdf", &imageMock2},
     };
 
@@ -97,8 +97,7 @@
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
         std::move(bus_mock), blobs, data);
 
-    EXPECT_TRUE(
-        handler->open(0, OpenFlags::write, FirmwareBlobHandler::verifyBlobID));
+    EXPECT_TRUE(handler->open(0, OpenFlags::write, verifyBlobId));
 
     EXPECT_TRUE(handler->commit(0, {}));
 }
@@ -110,7 +109,7 @@
      */
     ImageHandlerMock imageMock1, imageMock2;
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock1},
+        {hashBlobId, &imageMock1},
         {"asdf", &imageMock2},
     };
 
@@ -124,8 +123,7 @@
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
         std::move(bus_mock), blobs, data);
 
-    EXPECT_TRUE(
-        handler->open(0, OpenFlags::write, FirmwareBlobHandler::verifyBlobID));
+    EXPECT_TRUE(handler->open(0, OpenFlags::write, verifyBlobId));
 
     /* Note: I used StrictMock<> here to just catch all the calls.  However, the
      * unit-tests pass if we don't use StrictMock and ignore the calls.
diff --git a/test/firmware_createhandler_unittest.cpp b/test/firmware_createhandler_unittest.cpp
index 84769cb..65aa6ef 100644
--- a/test/firmware_createhandler_unittest.cpp
+++ b/test/firmware_createhandler_unittest.cpp
@@ -1,6 +1,7 @@
 #include "data_mock.hpp"
 #include "firmware_handler.hpp"
 #include "image_mock.hpp"
+#include "util.hpp"
 
 #include <phosphor-logging/test/sdjournal_mock.hpp>
 #include <sdbusplus/test/sdbus_mock.hpp>
@@ -25,7 +26,7 @@
     //    SwapJouralHandler(&journalMock);
 
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock},
+        {hashBlobId, &imageMock},
     };
 
     std::vector<DataHandlerPack> data = {
diff --git a/test/firmware_delete_unittest.cpp b/test/firmware_delete_unittest.cpp
index 10c4227..49809f8 100644
--- a/test/firmware_delete_unittest.cpp
+++ b/test/firmware_delete_unittest.cpp
@@ -1,6 +1,7 @@
 #include "data_mock.hpp"
 #include "firmware_handler.hpp"
 #include "image_mock.hpp"
+#include "util.hpp"
 
 #include <sdbusplus/test/sdbus_mock.hpp>
 #include <vector>
@@ -21,7 +22,7 @@
     ImageHandlerMock imageMock;
 
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock},
+        {hashBlobId, &imageMock},
         {"asdf", &imageMock},
     };
     std::vector<DataHandlerPack> data = {
@@ -35,18 +36,17 @@
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
         std::move(bus_mock), blobs, data);
 
-    EXPECT_CALL(imageMock, open(Eq(FirmwareBlobHandler::hashBlobID)))
-        .WillOnce(Return(true));
+    EXPECT_CALL(imageMock, open(StrEq(hashBlobId))).WillOnce(Return(true));
 
     EXPECT_TRUE(handler->open(
         0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi,
-        FirmwareBlobHandler::hashBlobID));
+        hashBlobId));
 
     /* The active hash blob_id was added. */
     auto currentBlobs = handler->getBlobIds();
     EXPECT_EQ(4, currentBlobs.size());
     EXPECT_EQ(1, std::count(currentBlobs.begin(), currentBlobs.end(),
-                            FirmwareBlobHandler::activeHashBlobID));
+                            activeHashBlobId));
 
     /* Set up close() expectations. */
     EXPECT_CALL(imageMock, close());
@@ -55,15 +55,15 @@
     currentBlobs = handler->getBlobIds();
     EXPECT_EQ(4, currentBlobs.size());
     EXPECT_EQ(1, std::count(currentBlobs.begin(), currentBlobs.end(),
-                            FirmwareBlobHandler::activeHashBlobID));
+                            activeHashBlobId));
 
     /* Delete the blob. */
-    EXPECT_TRUE(handler->deleteBlob(FirmwareBlobHandler::activeHashBlobID));
+    EXPECT_TRUE(handler->deleteBlob(activeHashBlobId));
 
     currentBlobs = handler->getBlobIds();
     EXPECT_EQ(3, currentBlobs.size());
     EXPECT_EQ(0, std::count(currentBlobs.begin(), currentBlobs.end(),
-                            FirmwareBlobHandler::activeHashBlobID));
+                            activeHashBlobId));
 }
 
 } // namespace blobs
diff --git a/test/firmware_handler_unittest.cpp b/test/firmware_handler_unittest.cpp
index 1457a3b..020d7ff 100644
--- a/test/firmware_handler_unittest.cpp
+++ b/test/firmware_handler_unittest.cpp
@@ -1,5 +1,6 @@
 #include "firmware_handler.hpp"
 #include "image_mock.hpp"
+#include "util.hpp"
 
 #include <algorithm>
 #include <sdbusplus/test/sdbus_mock.hpp>
@@ -28,7 +29,7 @@
     ImageHandlerMock imageMock;
 
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock},
+        {hashBlobId, &imageMock},
         {"asdf", &imageMock},
     };
 
@@ -58,16 +59,14 @@
         std::move(bus_mock), blobs, data);
     EXPECT_EQ(handler, nullptr);
 
-    blobs.push_back({FirmwareBlobHandler::hashBlobID, &imageMock});
+    blobs.push_back({hashBlobId, &imageMock});
 
     handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
         std::move(bus_mock), blobs, data);
     auto result = handler->getBlobIds();
     EXPECT_EQ(3, result.size());
     EXPECT_EQ(3, std::count(result.begin(), result.end(), "asdf") +
-                     std::count(result.begin(), result.end(),
-                                FirmwareBlobHandler::hashBlobID) +
-                     std::count(result.begin(), result.end(),
-                                FirmwareBlobHandler::verifyBlobID));
+                     std::count(result.begin(), result.end(), hashBlobId) +
+                     std::count(result.begin(), result.end(), verifyBlobId));
 }
 } // namespace blobs
diff --git a/test/firmware_open_unittest.cpp b/test/firmware_open_unittest.cpp
index c56d5d5..1820bb1 100644
--- a/test/firmware_open_unittest.cpp
+++ b/test/firmware_open_unittest.cpp
@@ -1,6 +1,7 @@
 #include "data_mock.hpp"
 #include "firmware_handler.hpp"
 #include "image_mock.hpp"
+#include "util.hpp"
 
 #include <sdbusplus/test/sdbus_mock.hpp>
 #include <vector>
@@ -22,7 +23,7 @@
     ImageHandlerMock imageMock;
 
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock},
+        {hashBlobId, &imageMock},
         {"asdf", &imageMock},
     };
     std::vector<DataHandlerPack> data = {
@@ -44,7 +45,7 @@
     auto currentBlobs = handler->getBlobIds();
     EXPECT_EQ(4, currentBlobs.size());
     EXPECT_EQ(1, std::count(currentBlobs.begin(), currentBlobs.end(),
-                            FirmwareBlobHandler::activeImageBlobID));
+                            activeImageBlobId));
 }
 
 TEST(FirmwareHandlerOpenTest, OpenWithEverythingValidHashFile)
@@ -53,7 +54,7 @@
     ImageHandlerMock imageMock;
 
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock},
+        {hashBlobId, &imageMock},
         {"asdf", &imageMock},
     };
     std::vector<DataHandlerPack> data = {
@@ -66,18 +67,17 @@
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
         std::move(bus_mock), blobs, data);
 
-    EXPECT_CALL(imageMock, open(Eq(FirmwareBlobHandler::hashBlobID)))
-        .WillOnce(Return(true));
+    EXPECT_CALL(imageMock, open(StrEq(hashBlobId))).WillOnce(Return(true));
 
     EXPECT_TRUE(handler->open(
         0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi,
-        FirmwareBlobHandler::hashBlobID));
+        hashBlobId));
 
     /* The active hash blob_id was added. */
     auto currentBlobs = handler->getBlobIds();
     EXPECT_EQ(4, currentBlobs.size());
     EXPECT_EQ(1, std::count(currentBlobs.begin(), currentBlobs.end(),
-                            FirmwareBlobHandler::activeHashBlobID));
+                            activeHashBlobId));
 }
 
 TEST(FirmwareHandlerOpenTest, OpenWithDataHandlerAllSucceeds)
@@ -89,7 +89,7 @@
     ImageHandlerMock imageMock;
 
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock},
+        {hashBlobId, &imageMock},
         {"asdf", &imageMock},
     };
     std::vector<DataHandlerPack> data = {
@@ -104,18 +104,17 @@
         std::move(bus_mock), blobs, data);
 
     EXPECT_CALL(dataMock, open()).WillOnce(Return(true));
-    EXPECT_CALL(imageMock, open(Eq(FirmwareBlobHandler::hashBlobID)))
-        .WillOnce(Return(true));
+    EXPECT_CALL(imageMock, open(StrEq(hashBlobId))).WillOnce(Return(true));
 
     EXPECT_TRUE(handler->open(
         0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::lpc,
-        FirmwareBlobHandler::hashBlobID));
+        hashBlobId));
 
     /* The active hash blob_id was added. */
     auto currentBlobs = handler->getBlobIds();
     EXPECT_EQ(4, currentBlobs.size());
     EXPECT_EQ(1, std::count(currentBlobs.begin(), currentBlobs.end(),
-                            FirmwareBlobHandler::activeHashBlobID));
+                            activeHashBlobId));
 }
 
 TEST(FirmwareHandlerOpenTest, OpenWithDataHandlerReturnsFailure)
@@ -125,7 +124,7 @@
     ImageHandlerMock imageMock;
 
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock},
+        {hashBlobId, &imageMock},
         {"asdf", &imageMock},
     };
     std::vector<DataHandlerPack> data = {
@@ -143,7 +142,7 @@
 
     EXPECT_FALSE(handler->open(
         0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::lpc,
-        FirmwareBlobHandler::hashBlobID));
+        hashBlobId));
 
     /* The active hash blob_id was added. */
     auto currentBlobs = handler->getBlobIds();
@@ -158,7 +157,7 @@
     ImageHandlerMock imageMock1, imageMock2;
 
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock1},
+        {hashBlobId, &imageMock1},
         {"asdf", &imageMock2},
     };
     std::vector<DataHandlerPack> data = {
@@ -180,21 +179,20 @@
     auto currentBlobs = handler->getBlobIds();
     EXPECT_EQ(4, currentBlobs.size());
     EXPECT_EQ(1, std::count(currentBlobs.begin(), currentBlobs.end(),
-                            FirmwareBlobHandler::activeImageBlobID));
+                            activeImageBlobId));
 
     /* Open the hash file (since we opened an image file). */
     EXPECT_FALSE(handler->open(
         1, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi,
-        FirmwareBlobHandler::hashBlobID));
+        hashBlobId));
 
     EXPECT_TRUE(handler->close(0));
 
-    EXPECT_CALL(imageMock1, open(StrEq(FirmwareBlobHandler::hashBlobID)))
-        .WillOnce(Return(true));
+    EXPECT_CALL(imageMock1, open(StrEq(hashBlobId))).WillOnce(Return(true));
 
     EXPECT_TRUE(handler->open(
         1, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi,
-        FirmwareBlobHandler::hashBlobID));
+        hashBlobId));
 }
 
 TEST(FirmwareHandlerOpenTest, OpenEverythingSucceedsOpenActiveFails)
@@ -207,7 +205,7 @@
     ImageHandlerMock imageMock;
 
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock},
+        {hashBlobId, &imageMock},
         {"asdf", &imageMock},
     };
     std::vector<DataHandlerPack> data = {
@@ -229,7 +227,7 @@
     auto currentBlobs = handler->getBlobIds();
     EXPECT_EQ(4, currentBlobs.size());
     EXPECT_EQ(1, std::count(currentBlobs.begin(), currentBlobs.end(),
-                            FirmwareBlobHandler::activeImageBlobID));
+                            activeImageBlobId));
 
     /* Close only active session, to verify it's failing on attempt to open a
      * specific blob_id.
@@ -238,7 +236,7 @@
 
     EXPECT_FALSE(handler->open(
         1, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi,
-        FirmwareBlobHandler::activeImageBlobID));
+        activeImageBlobId));
 }
 
 TEST(FirmwareHandlerOpenTest, OpenWithEverythingValidImageHandlerFails)
@@ -249,7 +247,7 @@
     ImageHandlerMock imageMock;
 
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock},
+        {hashBlobId, &imageMock},
         {"asdf", &imageMock},
     };
     std::vector<DataHandlerPack> data = {
@@ -279,7 +277,7 @@
     ImageHandlerMock imageMock;
 
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock},
+        {hashBlobId, &imageMock},
         {"asdf", &imageMock},
     };
     std::vector<DataHandlerPack> data = {
@@ -303,7 +301,7 @@
     ImageHandlerMock imageMock;
 
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock},
+        {hashBlobId, &imageMock},
         {"asdf", &imageMock},
     };
     std::vector<DataHandlerPack> data = {
@@ -327,7 +325,7 @@
     ImageHandlerMock imageMock;
 
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock},
+        {hashBlobId, &imageMock},
         {"asdf", &imageMock},
     };
     std::vector<DataHandlerPack> data = {
diff --git a/test/firmware_sessionstat_unittest.cpp b/test/firmware_sessionstat_unittest.cpp
index 4f6584f..e395358 100644
--- a/test/firmware_sessionstat_unittest.cpp
+++ b/test/firmware_sessionstat_unittest.cpp
@@ -1,6 +1,7 @@
 #include "data_mock.hpp"
 #include "firmware_handler.hpp"
 #include "image_mock.hpp"
+#include "util.hpp"
 
 #include <sdbusplus/test/sdbus_mock.hpp>
 #include <vector>
@@ -19,7 +20,7 @@
      */
     ImageHandlerMock imageMock1, imageMock2;
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock1},
+        {hashBlobId, &imageMock1},
         {"asdf", &imageMock2},
     };
 
@@ -57,7 +58,7 @@
      */
     ImageHandlerMock imageMock1, imageMock2;
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock1},
+        {hashBlobId, &imageMock1},
         {"asdf", &imageMock2},
     };
 
diff --git a/test/firmware_stat_unittest.cpp b/test/firmware_stat_unittest.cpp
index d6cc99d..4c90735 100644
--- a/test/firmware_stat_unittest.cpp
+++ b/test/firmware_stat_unittest.cpp
@@ -1,5 +1,6 @@
 #include "firmware_handler.hpp"
 #include "image_mock.hpp"
+#include "util.hpp"
 
 #include <sdbusplus/test/sdbus_mock.hpp>
 #include <vector>
@@ -20,7 +21,7 @@
     ImageHandlerMock imageMock;
 
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock},
+        {hashBlobId, &imageMock},
         {"asdf", &imageMock},
     };
     std::vector<DataHandlerPack> data = {
diff --git a/test/firmware_write_unittest.cpp b/test/firmware_write_unittest.cpp
index d9fcae4..6ba2081 100644
--- a/test/firmware_write_unittest.cpp
+++ b/test/firmware_write_unittest.cpp
@@ -1,6 +1,7 @@
 #include "data_mock.hpp"
 #include "firmware_handler.hpp"
 #include "image_mock.hpp"
+#include "util.hpp"
 
 #include <cstdint>
 #include <cstring>
@@ -20,7 +21,7 @@
 
     ImageHandlerMock imageMock1, imageMock2;
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock1},
+        {hashBlobId, &imageMock1},
         {"asdf", &imageMock2},
     };
 
@@ -51,7 +52,7 @@
 
     ImageHandlerMock imageMock1, imageMock2;
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock1},
+        {hashBlobId, &imageMock1},
         {"asdf", &imageMock2},
     };
 
@@ -94,7 +95,7 @@
 
     ImageHandlerMock imageMock1, imageMock2;
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock1},
+        {hashBlobId, &imageMock1},
         {"asdf", &imageMock2},
     };
 
diff --git a/test/firmware_writemeta_unittest.cpp b/test/firmware_writemeta_unittest.cpp
index 4e8cd45..ad7f25b 100644
--- a/test/firmware_writemeta_unittest.cpp
+++ b/test/firmware_writemeta_unittest.cpp
@@ -1,6 +1,7 @@
 #include "data_mock.hpp"
 #include "firmware_handler.hpp"
 #include "image_mock.hpp"
+#include "util.hpp"
 
 #include <sdbusplus/test/sdbus_mock.hpp>
 
@@ -15,7 +16,7 @@
 {
     ImageHandlerMock imageMock1, imageMock2;
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock1},
+        {hashBlobId, &imageMock1},
         {"asdf", &imageMock2},
     };
 
@@ -46,7 +47,7 @@
 {
     ImageHandlerMock imageMock1, imageMock2;
     std::vector<HandlerPack> blobs = {
-        {FirmwareBlobHandler::hashBlobID, &imageMock1},
+        {hashBlobId, &imageMock1},
         {"asdf", &imageMock2},
     };
 
diff --git a/test/tools_updater_unittest.cpp b/test/tools_updater_unittest.cpp
index 31c8d55..080671f 100644
--- a/test/tools_updater_unittest.cpp
+++ b/test/tools_updater_unittest.cpp
@@ -1,6 +1,7 @@
 #include "data_interface_mock.hpp"
 #include "updater.hpp"
 #include "updater_mock.hpp"
+#include "util.hpp"
 
 #include <blobs-ipmid/blobs.hpp>
 #include <ipmiblob/test/blob_interface_mock.hpp>
@@ -23,23 +24,23 @@
     DataInterfaceMock handlerMock;
     ipmiblob::BlobInterfaceMock blobMock;
 
-    std::string expectedBlob = "/flash/image";
-
     ipmiblob::StatResponse statObj;
     statObj.blob_state = blobs::FirmwareBlobHandler::UpdateFlags::ipmi |
                          blobs::FirmwareBlobHandler::UpdateFlags::lpc;
     statObj.size = 0;
 
     EXPECT_CALL(blobMock, getBlobList())
-        .WillOnce(Return(std::vector<std::string>({expectedBlob})));
-    EXPECT_CALL(blobMock, getStat(TypedEq<const std::string&>(expectedBlob)))
+        .WillOnce(
+            Return(std::vector<std::string>({blobs::staticLayoutBlobId})));
+    EXPECT_CALL(blobMock,
+                getStat(TypedEq<const std::string&>(blobs::staticLayoutBlobId)))
         .WillOnce(Return(statObj));
 
     EXPECT_CALL(handlerMock, supportedType())
         .WillOnce(Return(blobs::FirmwareBlobHandler::UpdateFlags::lpc));
 
     UpdateHandler updater(&blobMock, &handlerMock);
-    EXPECT_TRUE(updater.checkAvailable(expectedBlob));
+    EXPECT_TRUE(updater.checkAvailable(blobs::staticLayoutBlobId));
 }
 
 TEST(UpdaterTest, SendFileSuccess)
@@ -48,7 +49,6 @@
     DataInterfaceMock handlerMock;
     ipmiblob::BlobInterfaceMock blobMock;
 
-    std::string expectedBlob = "/flash/image";
     std::string firmwareImage = "image.bin";
 
     std::uint16_t supported =
@@ -60,7 +60,8 @@
     EXPECT_CALL(handlerMock, supportedType())
         .WillOnce(Return(blobs::FirmwareBlobHandler::UpdateFlags::lpc));
 
-    EXPECT_CALL(blobMock, openBlob(StrEq(expectedBlob.c_str()), supported))
+    EXPECT_CALL(blobMock,
+                openBlob(StrEq(blobs::staticLayoutBlobId.c_str()), supported))
         .WillOnce(Return(session));
 
     EXPECT_CALL(handlerMock,
@@ -70,7 +71,7 @@
     EXPECT_CALL(blobMock, closeBlob(session)).Times(1);
 
     UpdateHandler updater(&blobMock, &handlerMock);
-    updater.sendFile(expectedBlob, firmwareImage);
+    updater.sendFile(blobs::staticLayoutBlobId, firmwareImage);
 }
 
 #if 0 /* TODO: fix this up. */
@@ -84,11 +85,8 @@
 
     std::string firmwareImage = "image.bin";
     std::string signatureFile = "image.sig";
-    std::string expectedBlob = "/flash/image";
-    std::string expectedHash = "/flash/hash";
-    std::string expectedVerify = "/flash/verify";
 
-    std::vector<std::string> blobList = {expectedBlob};
+    std::vector<std::string> blobList = {blobs::staticLayoutBlobId};
     ipmiblob::StatResponse statObj;
     statObj.blob_state = blobs::FirmwareBlobHandler::UpdateFlags::ipmi |
                          blobs::FirmwareBlobHandler::UpdateFlags::lpc;
@@ -101,20 +99,20 @@
 
     EXPECT_CALL(blobMock, getBlobList()).WillOnce(Return(blobList));
 
-    EXPECT_CALL(blobMock, getStat(TypedEq<const std::string&>(expectedBlob)))
+    EXPECT_CALL(blobMock, getStat(TypedEq<const std::string&>(blobs::staticLayoutBlobId)))
         .WillOnce(Return(statObj));
 
     EXPECT_CALL(handlerMock, supportedType())
         .WillOnce(Return(blobs::FirmwareBlobHandler::UpdateFlags::lpc));
 
-    EXPECT_CALL(blobMock, openBlob(StrEq(expectedBlob.c_str()), Eq(supported)))
+    EXPECT_CALL(blobMock, openBlob(StrEq(blobs::staticLayoutBlobId.c_str()), Eq(supported)))
         .WillOnce(Return(session));
 
     EXPECT_CALL(handlerMock,
                 sendContents(StrEq(firmwareImage.c_str()), Eq(session)))
         .WillOnce(Return(true));
 
-    EXPECT_CALL(blobMock, openBlob(StrEq(expectedHash.c_str()), Eq(supported)))
+    EXPECT_CALL(blobMock, openBlob(StrEq(blobs::hashBlobId.c_str()), Eq(supported)))
         .WillOnce(Return(session));
 
     EXPECT_CALL(handlerMock,
@@ -122,7 +120,7 @@
         .WillOnce(Return(true));
 
     EXPECT_CALL(blobMock,
-                openBlob(StrEq(expectedVerify.c_str()), Eq(supported)))
+                openBlob(StrEq(blobs::verifyBlobId.c_str()), Eq(supported)))
         .WillOnce(Return(session));
 
     EXPECT_CALL(blobMock, commit(session, _)).WillOnce(Return());
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 7d07434..f8879b0 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -8,10 +8,11 @@
 libupdater_la_LDFLAGS = -static $(CODE_COVERAGE_LIBS) $(IPMIBLOB_LIBS) $(PCILIB_LIBS)
 libupdater_la_CXXFLAGS = -I$(top_srcdir) $(CODE_COVERAGE_CXXFLAGS) $(IPMIBLOB_CFLAGS) $(PCILIB_CFLAGS)
 libupdater_la_SOURCES = \
+	$(top_srcdir)/util.cpp \
 	updater.cpp \
 	bt.cpp \
 	lpc.cpp \
 	io.cpp \
 	pci.cpp \
 	p2a.cpp \
-	../internal/sys.cpp
+	$(top_srcdir)/internal/sys.cpp
diff --git a/tools/updater.cpp b/tools/updater.cpp
index 92afe5d..f2a0264 100644
--- a/tools/updater.cpp
+++ b/tools/updater.cpp
@@ -18,6 +18,7 @@
 
 #include "firmware_handler.hpp"
 #include "tool_errors.hpp"
+#include "util.hpp"
 
 #include <algorithm>
 #include <blobs-ipmid/blobs.hpp>
@@ -238,16 +239,8 @@
 {
     /* TODO(venture): Add optional parameter to specify the flash type, default
      * to legacy for now.
-     *
-     * TODO(venture): Move the strings from the FirmwareHandler object to a
-     * boring utils object so it will be more happly linked cleanly to both the
-     * BMC and host-side.
      */
-    std::string goalFirmware = "/flash/image";
-    std::string hashFilename = "/flash/hash";
-    std::string verifyFilename = "/flash/verify";
-
-    bool goalSupported = updater->checkAvailable(goalFirmware);
+    bool goalSupported = updater->checkAvailable(blobs::staticLayoutBlobId);
     if (!goalSupported)
     {
         throw ToolException("Goal firmware or interface not supported");
@@ -257,15 +250,15 @@
 
     /* Send over the firmware image. */
     std::fprintf(stderr, "Sending over the firmware image.\n");
-    updater->sendFile(goalFirmware, imagePath);
+    updater->sendFile(blobs::staticLayoutBlobId, imagePath);
 
     /* Send over the hash contents. */
     std::fprintf(stderr, "Sending over the hash file.\n");
-    updater->sendFile(hashFilename, signaturePath);
+    updater->sendFile(blobs::hashBlobId, signaturePath);
 
     /* Trigger the verification by opening the verify file. */
     std::fprintf(stderr, "Opening the verification file\n");
-    if (updater->verifyFile(verifyFilename))
+    if (updater->verifyFile(blobs::verifyBlobId))
     {
         std::fprintf(stderr, "succeeded\n");
     }
diff --git a/util.cpp b/util.cpp
new file mode 100644
index 0000000..99c47d5
--- /dev/null
+++ b/util.cpp
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2019 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "util.hpp"
+
+namespace blobs
+{
+
+const std::string verifyBlobId = "/flash/verify";
+const std::string hashBlobId = "/flash/hash";
+const std::string activeImageBlobId = "/flash/active/image";
+const std::string activeHashBlobId = "/flash/active/hash";
+const std::string staticLayoutBlobId = "/flash/image";
+const std::string ubiTarballBlobId = "/flash/tarball";
+
+} // namespace blobs
diff --git a/util.hpp b/util.hpp
new file mode 100644
index 0000000..8634bcd
--- /dev/null
+++ b/util.hpp
@@ -0,0 +1,15 @@
+#pragma once
+
+#include <string>
+
+namespace blobs
+{
+
+extern const std::string verifyBlobId;
+extern const std::string hashBlobId;
+extern const std::string activeImageBlobId;
+extern const std::string activeHashBlobId;
+extern const std::string staticLayoutBlobId;
+extern const std::string ubiTarballBlobId;
+
+} // namespace blobs