Commit cb8456bd authored by Kyle Nekritz's avatar Kyle Nekritz Committed by Facebook Github Bot 3

Add replay safety method and callback to AsyncTransport.

Summary: This allows the transport to signal to a higher layer when it has become replay-safe.

Reviewed By: siyengar

Differential Revision: D2974057

fb-gh-sync-id: 436f0c66b78f72ad34cdf4fe117771ea96b4388b
shipit-source-id: 436f0c66b78f72ad34cdf4fe117771ea96b4388b
parent 38b778b1
...@@ -345,6 +345,38 @@ class AsyncTransport : public DelayedDestruction, public AsyncSocketBase { ...@@ -345,6 +345,38 @@ class AsyncTransport : public DelayedDestruction, public AsyncSocketBase {
virtual void onEgressBufferCleared() = 0; virtual void onEgressBufferCleared() = 0;
}; };
/**
* Callback class to signal when a transport that did not have replay
* protection gains replay protection. This is needed for 0-RTT security
* protocols.
*/
class ReplaySafetyCallback {
public:
virtual ~ReplaySafetyCallback() = default;
/**
* Called when the transport becomes replay safe.
*/
virtual void onReplaySafe() = 0;
};
/**
* False if the transport does not have replay protection, but will in the
* future.
*/
virtual bool isReplaySafe() const { return true; }
/**
* Set the ReplaySafeCallback on this transport.
*
* This should only be called if isReplaySafe() returns false.
*/
virtual void setReplaySafetyCallback(ReplaySafetyCallback* callback) {
if (callback) {
CHECK(false) << "setReplaySafetyCallback() not supported";
}
}
protected: protected:
virtual ~AsyncTransport() = default; virtual ~AsyncTransport() = default;
}; };
......
...@@ -65,6 +65,11 @@ class MockAsyncTransport: public AsyncTransportWrapper { ...@@ -65,6 +65,11 @@ class MockAsyncTransport: public AsyncTransportWrapper {
}; };
class MockReplaySafetyCallback : public AsyncTransport::ReplaySafetyCallback {
public:
GMOCK_METHOD0_(, noexcept, , onReplaySafe, void());
};
class MockReadCallback: public AsyncTransportWrapper::ReadCallback { class MockReadCallback: public AsyncTransportWrapper::ReadCallback {
public: public:
MOCK_METHOD2(getReadBuffer, void(void**, size_t*)); MOCK_METHOD2(getReadBuffer, void(void**, size_t*));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment