Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple fizz::Aead and quic::Aead . This makes a large chunk of the codebase fizz agnostic. #16

Closed
wants to merge 1 commit into from

Conversation

deadalnix
Copy link
Contributor

This is based on top of #15 .

Now that the codebase have been refactored to use Aead/fizz:Aead and MockAead/fizz::test::MockAead in proper places, it is time to ensures the aren't aliases of each others anymore.

This introduces FizzAead as a wrapper for fizz::Aead that implements quic::Aead and forward all calls. Most of the codebase now uses quic::Aead, which a significant step toward being able to swap it for another implementation.

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label May 19, 2019
@deadalnix deadalnix changed the title Fizzdecouple2 Decouple fizz::Aead and quic::Aead . This makes a large chunk of the codebase fizz agnostic. May 19, 2019
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjoras has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjoras has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjoras has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

}

class FizzAead final : public Aead {
private:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's move the private section to be after public

class FizzAead final : public Aead {
private:
std::unique_ptr<fizz::Aead> fizzAead;
FizzAead(std::unique_ptr<fizz::Aead> _fizzAead)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rename this to fizzAeadIn if you want to avoid collided name. We don't use _someName anywhere else in mvfst.

std::unique_ptr<folly::IOBuf>
encrypt(std::unique_ptr<folly::IOBuf> &&plaintext,
const folly::IOBuf *associatedData, uint64_t seqNum) const override {
return fizzAead->encrypt(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since one can wrap a null fizz::aead in, fizzAead can possibly be nullptr. Should you check against that before deref it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wrap function ensures that this isn't the case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? is you pass nullptr to wrap, you get a FizzAead object with the fizzAead member being nullptr, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wrap funtion check the pointer that is passed in and return a null unique pointer when that's the case. The constructor is private, so by construct, the inner unique pointer is non null.

encrypt(std::unique_ptr<folly::IOBuf> &&plaintext,
const folly::IOBuf *associatedData, uint64_t seqNum) const override {
return fizzAead->encrypt(
std::forward<std::unique_ptr<folly::IOBuf>>(plaintext), associatedData,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this std::forward() simply be std::move() ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one isn't changed?

Copy link
Contributor

@yangchi yangchi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few inline comments. forgot to request changes when i submitted them

Provide FizzAead as an implementation of quic::Aead that forward calls.
Provide MockAead as a replacement for fizz::test::MockAead.

Most of the codebase now do not rely on fizz::Aead and use the mvfst specific interface.

The part remaining aware of fizz:Aead are the various handshake part of the code base, tests and FizzAead which provides a bridge between fizz and mvfst.
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjoras has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@mjoras merged this pull request in d83cfb6.

@deadalnix deadalnix deleted the fizzdecouple2 branch June 22, 2019 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants