1 // Copyright (c) 2013 The Chromium 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.
5 #include "crypto/hkdf.h"
12 #include "base/logging.h"
13 #include "crypto/hmac.h"
14 #include "third_party/boringssl/src/include/openssl/digest.h"
15 #include "third_party/boringssl/src/include/openssl/hkdf.h"
19 std::string HkdfSha256(base::StringPiece secret,
20 base::StringPiece salt,
21 base::StringPiece info,
22 size_t derived_key_size) {
24 key.resize(derived_key_size);
26 reinterpret_cast<uint8_t*>(&key[0]), derived_key_size, EVP_sha256(),
27 reinterpret_cast<const uint8_t*>(secret.data()), secret.size(),
28 reinterpret_cast<const uint8_t*>(salt.data()), salt.size(),
29 reinterpret_cast<const uint8_t*>(info.data()), info.size());