Tom Joseph | d08b523 | 2017-01-24 18:15:39 +0530 | [diff] [blame^] | 1 | #include <openssl/evp.h> |
| 2 | #include <openssl/hmac.h> |
| 3 | #include <openssl/rand.h> |
| 4 | #include <numeric> |
| 5 | #include "crypt_algo.hpp" |
| 6 | #include "message_parsers.hpp" |
| 7 | |
| 8 | namespace cipher |
| 9 | { |
| 10 | |
| 11 | namespace crypt |
| 12 | { |
| 13 | |
| 14 | Interface::Interface(const buffer& sik, const key& addKey) |
| 15 | { |
| 16 | unsigned int mdLen = 0; |
| 17 | |
| 18 | // Generated K2 for the confidentiality algorithm with the additional key |
| 19 | // keyed with SIK. |
| 20 | if (HMAC(EVP_sha1(), sik.data(), sik.size(), addKey.data(), |
| 21 | addKey.size(), k2.data(), &mdLen) == NULL) |
| 22 | { |
| 23 | throw std::runtime_error("Generating K2 for confidentiality algorithm" |
| 24 | "failed"); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | }// namespace crypt |
| 29 | |
| 30 | }// namespace cipher |
| 31 | |
| 32 | |