• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 The Weave Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "src/privet/openssl_utils.h"
6 
7 #include <algorithm>
8 
9 #include <base/logging.h>
10 
11 extern "C" {
12 #include "third_party/libuweave/src/crypto_hmac.h"
13 }
14 
15 namespace weave {
16 namespace privet {
17 
HmacSha256(const std::vector<uint8_t> & key,const std::vector<uint8_t> & data)18 std::vector<uint8_t> HmacSha256(const std::vector<uint8_t>& key,
19                                 const std::vector<uint8_t>& data) {
20   std::vector<uint8_t> mac(kSha256OutputSize);
21   const UwCryptoHmacMsg messages[] = {{data.data(), data.size()}};
22   CHECK(uw_crypto_hmac_(key.data(), key.size(), messages, arraysize(messages),
23                         mac.data(), mac.size()));
24   return mac;
25 }
26 
27 }  // namespace privet
28 }  // namespace weave
29