Implemenation of the RAKP Authentication Algorithms
This patch contains the implementation of the RAKP-HMAC_SHA1 algorithm
for Authentication.OpenSSL is used for the HMAC operation.
Change-Id: I7e926aca9010443939e32f476c37ac1481cd2476
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/auth_algo.cpp b/auth_algo.cpp
new file mode 100644
index 0000000..d2acebf
--- /dev/null
+++ b/auth_algo.cpp
@@ -0,0 +1,46 @@
+#include "auth_algo.hpp"
+
+#include <openssl/hmac.h>
+#include <openssl/sha.h>
+
+#include <iostream>
+
+namespace cipher
+{
+
+namespace rakp_auth
+{
+
+std::vector<uint8_t> AlgoSHA1::generateHMAC(std::vector<uint8_t>& input) const
+{
+ std::vector<uint8_t> output(SHA_DIGEST_LENGTH);
+ unsigned int mdLen = 0;
+
+ if (HMAC(EVP_sha1(), userKey.data(), userKey.size(), input.data(),
+ input.size(), output.data(), &mdLen) == NULL)
+ {
+ std::cerr << "Generate HMAC failed\n";
+ output.resize(0);
+ }
+
+ return output;
+}
+
+std::vector<uint8_t> AlgoSHA1::generateICV(std::vector<uint8_t>& input) const
+{
+ std::vector<uint8_t> output(SHA_DIGEST_LENGTH);
+ unsigned int mdLen = 0;
+
+ if (HMAC(EVP_sha1(), sessionIntegrityKey.data(), SHA_DIGEST_LENGTH,
+ input.data(), input.size(), output.data(), &mdLen) == NULL)
+ {
+ std::cerr << "Generate Session Integrity Key failed\n";
+ output.resize(0);
+ }
+
+ return output;
+}
+
+} // namespace auth
+
+} // namespace cipher