blob: b765e0664619c592e3cc46f4ebae40bb3a204491 [file] [log] [blame]
Tom Joseph77531db2017-01-10 15:44:44 +05301#include <openssl/hmac.h>
2#include <openssl/sha.h>
3#include "integrity_algo.hpp"
4#include "message_parsers.hpp"
5
6namespace cipher
7{
8
9namespace integrity
10{
11
12Interface::Interface(const Buffer& sik, const Key& addKey, size_t authLength)
13{
14 unsigned int mdLen = 0;
15
16 // Generated K1 for the integrity algorithm with the additional key keyed
17 // with SIK.
18 if (HMAC(EVP_sha1(), sik.data(), sik.size(), addKey.data(),
19 addKey.size(), K1.data(), &mdLen) == NULL)
20 {
21 throw std::runtime_error("Generating Key1 for integrity "
22 "algorithm failed");
23 }
24
25 authCodeLength = authLength;
26}
27
28}// namespace integrity
29
30}// namespace cipher