-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop exporting OpenSSLFactory as a public dependency
Summary: This is part of the ongoing work to make fizz's use of OpenSSL an "implementation detail" and not expose it as a public dependency. This diff does a few things: - rename `Factory`->`DefaultFactory` and `IFactory`->`Factory` - Moved methods with openssl dependencies from `DefaultFactory` to `OpenSSLFactory`. - create implementation files for FizzClientContext.h and FizzServerContext.h and move openssl_factory to be a private dependency. - remove `openssl_factory` from most `exported_deps` except for some tests and any target with a class that extends OpenSSLFactory. Factory is now a pure virtual interface and so internal parts of fizz that reference Factory no longer depend on openssl. Almost no parts of fizz will exprort `OpenSSLFactory` as a public dependency. Reviewed By: mingtaoy Differential Revision: D51481217 fbshipit-source-id: 11e1785bd37ace714e9473b0d9d7c2d107e590ae
- Loading branch information
1 parent
66c56c2
commit 9dd9a38
Showing
20 changed files
with
294 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (c) 2018-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include "fizz/client/FizzClientContext.h" | ||
|
||
#include <fizz/protocol/OpenSSLFactory.h> | ||
|
||
namespace fizz { | ||
namespace client { | ||
|
||
FizzClientContext::FizzClientContext() | ||
: factory_(std::make_shared<OpenSSLFactory>()), | ||
clock_(std::make_shared<SystemClock>()) {} | ||
|
||
} // namespace client | ||
} // namespace fizz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright (c) 2018-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <fizz/protocol/Factory.h> | ||
|
||
namespace fizz { | ||
|
||
/** | ||
* This class instantiates various objects to facilitate testing. | ||
*/ | ||
class DefaultFactory : public Factory { | ||
public: | ||
[[nodiscard]] std::unique_ptr<PlaintextReadRecordLayer> | ||
makePlaintextReadRecordLayer() const override { | ||
return std::make_unique<PlaintextReadRecordLayer>(); | ||
} | ||
|
||
[[nodiscard]] std::unique_ptr<PlaintextWriteRecordLayer> | ||
makePlaintextWriteRecordLayer() const override { | ||
return std::make_unique<PlaintextWriteRecordLayer>(); | ||
} | ||
|
||
[[nodiscard]] std::unique_ptr<EncryptedReadRecordLayer> | ||
makeEncryptedReadRecordLayer(EncryptionLevel encryptionLevel) const override { | ||
return std::make_unique<EncryptedReadRecordLayer>(encryptionLevel); | ||
} | ||
|
||
[[nodiscard]] std::unique_ptr<EncryptedWriteRecordLayer> | ||
makeEncryptedWriteRecordLayer( | ||
EncryptionLevel encryptionLevel) const override { | ||
return std::make_unique<EncryptedWriteRecordLayer>(encryptionLevel); | ||
} | ||
|
||
[[nodiscard]] std::unique_ptr<KeyScheduler> makeKeyScheduler( | ||
CipherSuite cipher) const override { | ||
auto keyDer = makeKeyDeriver(cipher); | ||
return std::make_unique<KeyScheduler>(std::move(keyDer)); | ||
} | ||
|
||
[[nodiscard]] Random makeRandom() const override { | ||
return RandomGenerator<Random().size()>().generateRandom(); | ||
} | ||
|
||
[[nodiscard]] uint32_t makeTicketAgeAdd() const override { | ||
return RandomNumGenerator<uint32_t>().generateRandom(); | ||
} | ||
|
||
[[nodiscard]] std::unique_ptr<folly::IOBuf> makeRandomBytes( | ||
size_t count) const override { | ||
return RandomBufGenerator(count).generateRandom(); | ||
} | ||
|
||
[[nodiscard]] std::shared_ptr<PeerCert> makePeerCert( | ||
CertificateEntry certEntry, | ||
bool /*leaf*/) const override { | ||
return CertUtils::makePeerCert(std::move(certEntry.cert_data)); | ||
} | ||
|
||
[[nodiscard]] std::shared_ptr<Cert> makeIdentityOnlyCert( | ||
std::string ident) const override { | ||
return std::make_shared<IdentityCert>(std::move(ident)); | ||
} | ||
|
||
[[nodiscard]] std::string getHkdfPrefix() const override { | ||
return kHkdfLabelPrefix.str(); | ||
} | ||
}; | ||
} // namespace fizz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.