blob: b71636b3b6ddbcb1e0fed10cef3e2b41dcb4a8de [file] [log] [blame]
Tom Joseph8c0446c2016-08-05 07:13:07 -05001#include "auth_algo.hpp"
2
3#include <openssl/hmac.h>
4#include <openssl/sha.h>
5
6#include <iostream>
7
8namespace cipher
9{
10
11namespace rakp_auth
12{
13
14std::vector<uint8_t> AlgoSHA1::generateHMAC(std::vector<uint8_t>& input) const
15{
16 std::vector<uint8_t> output(SHA_DIGEST_LENGTH);
17 unsigned int mdLen = 0;
18
19 if (HMAC(EVP_sha1(), userKey.data(), userKey.size(), input.data(),
20 input.size(), output.data(), &mdLen) == NULL)
21 {
22 std::cerr << "Generate HMAC failed\n";
23 output.resize(0);
24 }
25
26 return output;
27}
28
29std::vector<uint8_t> AlgoSHA1::generateICV(std::vector<uint8_t>& input) const
30{
31 std::vector<uint8_t> output(SHA_DIGEST_LENGTH);
32 unsigned int mdLen = 0;
33
34 if (HMAC(EVP_sha1(), sessionIntegrityKey.data(), SHA_DIGEST_LENGTH,
35 input.data(), input.size(), output.data(), &mdLen) == NULL)
36 {
37 std::cerr << "Generate Session Integrity Key failed\n";
38 output.resize(0);
39 }
Vernon Mauery2207f512017-11-30 10:48:08 -080040 output.resize(integrityCheckValueLength);
Tom Joseph8c0446c2016-08-05 07:13:07 -050041
42 return output;
43}
44
45} // namespace auth
46
47} // namespace cipher