Skip to content

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

Closed
deadalnix wants to merge 1 commit into
meta:masterfrom
deadalnix:fizzdecouple2
Closed

deadalnix wants to merge 1 commit into
meta:masterfrom
deadalnix:fizzdecouple2

Conversation

@deadalnix

Copy link
Copy Markdown
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

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

Copy link
Copy Markdown
Contributor

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 facebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

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 facebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread quic/handshake/FizzBridge.h Outdated
}

class FizzAead final : public Aead {
private:

Copy link
Copy Markdown
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

Comment thread quic/handshake/FizzBridge.h Outdated
class FizzAead final : public Aead {
private:
std::unique_ptr<fizz::Aead> fizzAead;
FizzAead(std::unique_ptr<fizz::Aead> _fizzAead)

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?

@yangchi yangchi left a comment

Copy link
Copy Markdown
Contributor

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.

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

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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