Add macaroone implementation into libweave build

BUG:25934771

Change-Id: I86f9806302135f7b7c14582196918ed85a75256e
Reviewed-on: https://weave-review.googlesource.com/1731
Reviewed-by: Alex Vakulenko <avakulenko@google.com>
diff --git a/src/privet/openssl_utils.cc b/src/privet/openssl_utils.cc
index 2a98fa8..f7bee9b 100644
--- a/src/privet/openssl_utils.cc
+++ b/src/privet/openssl_utils.cc
@@ -6,21 +6,25 @@
 
 #include <algorithm>
 
-#include <openssl/evp.h>
-#include <openssl/hmac.h>
-
 #include <base/logging.h>
 
+extern "C" {
+#include "third_party/libuweave/src/crypto_hmac.h"
+}
+
 namespace weave {
 namespace privet {
 
 std::vector<uint8_t> HmacSha256(const std::vector<uint8_t>& key,
                                 const std::vector<uint8_t>& data) {
   std::vector<uint8_t> mac(kSha256OutputSize);
-  uint32_t len = 0;
-  CHECK(HMAC(EVP_sha256(), key.data(), key.size(), data.data(), data.size(),
-             mac.data(), &len));
-  CHECK_EQ(len, kSha256OutputSize);
+  uint8_t hmac_state[uw_crypto_hmac_required_buffer_size_()];
+  CHECK_EQ(0u, uw_crypto_hmac_init_(hmac_state, sizeof(hmac_state), key.data(),
+                                    key.size()));
+  CHECK(uw_crypto_hmac_update_(hmac_state, sizeof(hmac_state), data.data(),
+                               data.size()));
+  CHECK(uw_crypto_hmac_final_(hmac_state, sizeof(hmac_state), mac.data(),
+                              mac.size()));
   return mac;
 }