proxygen
HandshakeContext-inl.h
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 
13 template <typename Hash>
15  const std::string& hkdfLabelPrefix)
16  : hkdfLabelPrefix_(hkdfLabelPrefix) {
18  hashState_.hash_init(Hash::HashEngine());
19 }
20 
21 template <typename Hash>
23  hashState_.hash_update(*data);
24 }
25 
26 template <typename Hash>
29  auto out = folly::IOBuf::create(Hash::HashLen);
30  out->append(Hash::HashLen);
31  folly::MutableByteRange outRange(out->writableData(), out->length());
32  copied.hash_final(outRange);
33  return out;
34 }
35 
36 template <typename Hash>
38  folly::ByteRange baseKey) const {
40  auto finishedKey =
42  .expandLabel(
43  baseKey, "finished", folly::IOBuf::create(0), Hash::HashLen);
44  auto data = folly::IOBuf::create(Hash::HashLen);
45  data->append(Hash::HashLen);
46  auto outRange = folly::MutableByteRange(data->writableData(), data->length());
47  Hash::hmac(finishedKey->coalesce(), *context, outRange);
48  return data;
49 }
50 } // namespace fizz
void hash_init(const EVP_MD *md)
Definition: OpenSSLHash.h:49
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
context
Definition: CMakeCache.txt:563
void appendToTranscript(const Buf &data) override
Range< unsigned char * > MutableByteRange
Definition: Range.h:1164
void hash_final(MutableByteRange out)
Definition: OpenSSLHash.h:62
void hash_update(ByteRange data)
Definition: OpenSSLHash.h:53
Definition: Actions.h:16
HandshakeContextImpl(const std::string &hkdfLabelPrefix)
const char * string
Definition: Conv.cpp:212
std::unique_ptr< folly::IOBuf > Buf
Definition: Types.h:22
Buf getFinishedData(folly::ByteRange baseKey) const override
folly::ssl::OpenSSLHash::Digest hashState_
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
Buf getHandshakeContext() const override