use ipmiblob library from ipmi-blob-tool

Drop all code that is now handled by the ipmiblob library provided by
the new ipmi-blob-tool.  This is a library that can be included on the
BMC if necessary, but relies on nothing that is strictly meant for the
BMC.

Change-Id: I2b02ae0d432e84c08e598d27eef85b57c06a70fc
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/process.cpp b/process.cpp
index a73f70e..661f59d 100644
--- a/process.cpp
+++ b/process.cpp
@@ -19,6 +19,7 @@
 #include "ipmi.hpp"
 
 #include <cstring>
+#include <ipmiblob/crc.hpp>
 #include <unordered_map>
 #include <vector>
 
@@ -47,9 +48,8 @@
     {BlobOEMCommands::bmcBlobWriteMeta, writeMeta},
 };
 
-IpmiBlobHandler validateBlobCommand(CrcInterface* crc, const uint8_t* reqBuf,
-                                    uint8_t* replyCmdBuf, size_t* dataLen,
-                                    ipmi_ret_t* code)
+IpmiBlobHandler validateBlobCommand(const uint8_t* reqBuf, uint8_t* replyCmdBuf,
+                                    size_t* dataLen, ipmi_ret_t* code)
 {
     size_t requestLength = (*dataLen);
     /* We know dataLen is at least 1 already */
@@ -88,11 +88,8 @@
         /* Set the in-place CRC to zero. */
         std::memcpy(bytes.data(), &reqBuf[3], requestBodyLen);
 
-        crc->clear();
-        crc->compute(bytes.data(), bytes.size());
-
         /* Crc expected but didn't match. */
-        if (crcValue != crc->get())
+        if (crcValue != ipmiblob::generateCrc(bytes))
         {
             *code = IPMI_CC_UNSPECIFIED_ERROR;
             return nullptr;
@@ -111,8 +108,8 @@
 }
 
 ipmi_ret_t processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr,
-                              CrcInterface* crc, const uint8_t* reqBuf,
-                              uint8_t* replyCmdBuf, size_t* dataLen)
+                              const uint8_t* reqBuf, uint8_t* replyCmdBuf,
+                              size_t* dataLen)
 {
     ipmi_ret_t result = cmd(mgr, reqBuf, replyCmdBuf, dataLen);
     if (result != IPMI_CC_OK)
@@ -137,12 +134,10 @@
     }
 
     /* The command, whatever it was, replied, so let's set the CRC. */
-    crc->clear();
-    crc->compute(replyCmdBuf + sizeof(uint16_t),
-                 replyLength - sizeof(uint16_t));
-
+    std::vector<std::uint8_t> crcBuffer(replyCmdBuf + sizeof(uint16_t),
+                                        replyCmdBuf + replyLength);
     /* Copy the CRC into place. */
-    uint16_t crcValue = crc->get();
+    uint16_t crcValue = ipmiblob::generateCrc(crcBuffer);
     std::memcpy(replyCmdBuf, &crcValue, sizeof(crcValue));
 
     return result;