Tom Joseph | 77531db | 2017-01-10 15:44:44 +0530 | [diff] [blame^] | 1 | #include <openssl/hmac.h> |
| 2 | #include <openssl/sha.h> |
| 3 | #include "integrity_algo.hpp" |
| 4 | #include "message_parsers.hpp" |
| 5 | |
| 6 | namespace cipher |
| 7 | { |
| 8 | |
| 9 | namespace integrity |
| 10 | { |
| 11 | |
| 12 | Interface::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 |