Interface for the Integrity Algorithm

This patch defines the interfaces for the integrity algorithm.
It provides the API to verify integrity data of the incoming packet
and to generate integrity data for the outgoing packet.

Change-Id: Ibd645c0ab0d9f4ec26f085353d141f7a3262ab2e
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/integrity_algo.cpp b/integrity_algo.cpp
new file mode 100644
index 0000000..b765e06
--- /dev/null
+++ b/integrity_algo.cpp
@@ -0,0 +1,30 @@
+#include <openssl/hmac.h>
+#include <openssl/sha.h>
+#include "integrity_algo.hpp"
+#include "message_parsers.hpp"
+
+namespace cipher
+{
+
+namespace integrity
+{
+
+Interface::Interface(const Buffer& sik, const Key& addKey, size_t authLength)
+{
+    unsigned int mdLen = 0;
+
+    // Generated K1 for the integrity algorithm with the additional key keyed
+    // with SIK.
+    if (HMAC(EVP_sha1(), sik.data(), sik.size(), addKey.data(),
+             addKey.size(), K1.data(), &mdLen) == NULL)
+    {
+        throw std::runtime_error("Generating Key1 for integrity "
+                                 "algorithm failed");
+    }
+
+    authCodeLength = authLength;
+}
+
+}// namespace integrity
+
+}// namespace cipher