proxygen
Exporter.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
10 
11 namespace fizz {
12 
15  folly::ByteRange exporterMaster,
17  Buf context,
18  uint16_t length) {
19  if (!context) {
20  context = folly::IOBuf::create(0);
21  }
22  auto deriver = Factory().makeKeyDeriver(cipher);
23  std::vector<uint8_t> base(deriver->hashLength());
24  folly::MutableByteRange hashedContext(base.data(), base.size());
25  deriver->hash(*context, hashedContext);
26  auto secret =
27  deriver->deriveSecret(exporterMaster, label, deriver->blankHash());
28  return deriver->expandLabel(
30  "exporter",
31  folly::IOBuf::wrapBuffer(hashedContext),
32  length);
33 }
34 } // namespace fizz
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
static std::unique_ptr< IOBuf > wrapBuffer(const void *buf, std::size_t capacity)
Definition: IOBuf.cpp:353
context
Definition: CMakeCache.txt:563
CipherSuite
Definition: Types.h:153
CipherSuite cipher
constexpr Range< Iter > range(Iter first, Iter last)
Definition: Range.h:1114
Definition: Actions.h:16
uint32_t hash() const
Definition: Range.h:662
static Buf getEkm(CipherSuite cipher, folly::ByteRange exporterMaster, folly::StringPiece label, Buf context, uint16_t length)
Definition: Exporter.cpp:13
std::unique_ptr< folly::IOBuf > Buf
Definition: Types.h:22
static constexpr StringPiece secret
virtual std::unique_ptr< KeyDerivation > makeKeyDeriver(CipherSuite cipher) const
Definition: Factory.h:62
StringPiece label