Modify the addIntegrityData to pass the payload length

Change-Id: Ie04dec8866fc7116b5827ad691975e7e417ec684
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/message_parsers.cpp b/message_parsers.cpp
index be70753..d43009f 100644
--- a/message_parsers.cpp
+++ b/message_parsers.cpp
@@ -199,15 +199,18 @@
     // Add session sequence number
     internal::addSequenceNumber(packet, session);
 
-    // Add Payload
-    header->payloadLength = endian::to_ipmi<uint16_t>(outMessage.payload.size());
+    size_t payloadLen = 0;
+
+    header->payloadLength = endian::to_ipmi<uint16_t>(
+             outMessage.payload.size());
+    payloadLen = outMessage.payload.size();
     // Insert the Payload into the Packet
     packet.insert(packet.end(), outMessage.payload.begin(),
                   outMessage.payload.end());
 
     if (outMessage.isPacketAuthenticated)
     {
-        internal::addIntegrityData(packet, outMessage);
+        internal::addIntegrityData(packet, outMessage, payloadLen);
     }
 
     return packet;
@@ -281,10 +284,9 @@
 }
 
 void addIntegrityData(std::vector<uint8_t>& packet,
-                      const Message& message)
+                      const Message& message,
+                      size_t payloadLen)
 {
-    auto payloadLen = message.payload.size();
-
     // The following logic calculates the number of padding bytes to be added to
     // IPMI packet. If needed each integrity Pad byte is set to FFh.
     auto paddingLen = 4 - ((payloadLen + 2) & 3);