buffet: Move privetd sources into buffet No functional changes, only renaming, fixed include paths and include guards to avoid resubmit warnings. BUG=brillo:1161 CQ-DEPEND=CL:276521 TEST=none Change-Id: Icacff92aef47fdd46542bc96eba3ffbb4df6241a Reviewed-on: https://chromium-review.googlesource.com/276319 Reviewed-by: Vitaly Buka <vitalybuka@chromium.org> Commit-Queue: Vitaly Buka <vitalybuka@chromium.org> Tested-by: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/buffet/privet/openssl_utils.cc b/buffet/privet/openssl_utils.cc new file mode 100644 index 0000000..17cc16f --- /dev/null +++ b/buffet/privet/openssl_utils.cc
@@ -0,0 +1,26 @@ +// Copyright 2014 The Chromium OS Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "buffet/privet/openssl_utils.h" + +#include <algorithm> + +#include <openssl/evp.h> +#include <openssl/hmac.h> + +#include <base/logging.h> + +namespace privetd { + +chromeos::Blob HmacSha256(const chromeos::SecureBlob& key, + const chromeos::Blob& data) { + chromeos::Blob 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); + return mac; +} + +} // namespace privetd