proxygen
Hkdf.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 
9 #pragma once
10 
11 #include <fizz/crypto/Sha256.h>
12 #include <fizz/crypto/Sha384.h>
13 #include <folly/io/IOBuf.h>
14 
15 namespace fizz {
24 class Hkdf {
25  public:
26  virtual ~Hkdf() = default;
27 
28  virtual std::vector<uint8_t> extract(
29  folly::ByteRange salt,
30  folly::ByteRange ikm) const = 0;
31 
32  virtual std::unique_ptr<folly::IOBuf> expand(
33  folly::ByteRange extractedKey,
34  const folly::IOBuf& info,
35  size_t outputBytes) const = 0;
36 
37  virtual std::unique_ptr<folly::IOBuf> hkdf(
38  folly::ByteRange ikm,
39  folly::ByteRange salt,
40  const folly::IOBuf& info,
41  size_t outputBytes) const = 0;
42 
43  virtual size_t hashLength() const = 0;
44 };
45 
53 template <typename Hash>
54 class HkdfImpl : public Hkdf {
55  public:
56  static constexpr size_t HashLen = Hash::HashLen;
57 
58  std::vector<uint8_t> extract(folly::ByteRange salt, folly::ByteRange ikm)
59  const override;
60 
61  std::unique_ptr<folly::IOBuf> expand(
62  folly::ByteRange extractedKey,
63  const folly::IOBuf& info,
64  size_t outputBytes) const override;
65 
66  std::unique_ptr<folly::IOBuf> hkdf(
67  folly::ByteRange ikm,
68  folly::ByteRange salt,
69  const folly::IOBuf& info,
70  size_t outputBytes) const override;
71 
72  size_t hashLength() const override {
73  return HashLen;
74  }
75 };
76 } // namespace fizz
77 
78 #include <fizz/crypto/Hkdf-inl.h>
virtual std::vector< uint8_t > extract(folly::ByteRange salt, folly::ByteRange ikm) const =0
size_t hashLength() const override
Definition: Hkdf.h:72
def info()
Definition: deadlock.py:447
virtual size_t hashLength() const =0
virtual std::unique_ptr< folly::IOBuf > hkdf(folly::ByteRange ikm, folly::ByteRange salt, const folly::IOBuf &info, size_t outputBytes) const =0
virtual std::unique_ptr< folly::IOBuf > expand(folly::ByteRange extractedKey, const folly::IOBuf &info, size_t outputBytes) const =0
Definition: Actions.h:16
virtual ~Hkdf()=default