proxygen
fizz::server::DualTicketCipher Class Reference

#include <DualTicketCipher.h>

Inheritance diagram for fizz::server::DualTicketCipher:
fizz::server::TicketCipher

Public Member Functions

 DualTicketCipher (std::unique_ptr< TicketCipher > cipher, std::unique_ptr< TicketCipher > fallbackCipher)
 
folly::Future< folly::Optional< std::pair< std::unique_ptr< folly::IOBuf >, std::chrono::seconds > > > encrypt (ResumptionState resState) const override
 
folly::Future< std::pair< PskType, folly::Optional< ResumptionState > > > decrypt (std::unique_ptr< folly::IOBuf > encryptedTicket) const override
 
- Public Member Functions inherited from fizz::server::TicketCipher
virtual ~TicketCipher ()=default
 

Private Attributes

std::unique_ptr< TicketCiphercipher_
 
std::unique_ptr< TicketCipherfallbackCipher_
 

Detailed Description

Base class for using two ciphers for decryption. The idea behind this is that as we transition between psk contexts it might be useful to try multiple ciphers so that we don't break resumption on rollout.

Definition at line 21 of file DualTicketCipher.h.

Constructor & Destructor Documentation

fizz::server::DualTicketCipher::DualTicketCipher ( std::unique_ptr< TicketCipher cipher,
std::unique_ptr< TicketCipher fallbackCipher 
)
inline

Definition at line 23 of file DualTicketCipher.h.

26  : cipher_(std::move(cipher)),
27  fallbackCipher_(std::move(fallbackCipher)) {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< TicketCipher > fallbackCipher_
std::unique_ptr< TicketCipher > cipher_

Member Function Documentation

folly::Future<std::pair<PskType, folly::Optional<ResumptionState> > > fizz::server::DualTicketCipher::decrypt ( std::unique_ptr< folly::IOBuf encryptedTicket) const
inlineoverridevirtual

Returns the ResumptionState for an opaque PSK, and the type of PSK (resumption or external).

Returns Rejected if the PSK is not recognized.

Implements fizz::server::TicketCipher.

Definition at line 35 of file DualTicketCipher.h.

References cipher_, folly::IOBuf::clone(), fallbackCipher_, folly::makeFuture(), folly::gen::move, fizz::Rejected, and ticket.

36  {
37  auto bufClone = encryptedTicket->clone();
38  return cipher_->decrypt(std::move(encryptedTicket))
39  .thenValue([this, ticket = std::move(bufClone)](
41  res) mutable {
42  if (std::get<0>(res) == PskType::Rejected) {
43  return fallbackCipher_->decrypt(std::move(ticket));
44  }
45  return folly::makeFuture(std::move(res));
46  });
47  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< IOBuf > clone() const
Definition: IOBuf.cpp:527
static constexpr StringPiece ticket
std::unique_ptr< TicketCipher > fallbackCipher_
PskType
Definition: Types.h:18
std::unique_ptr< TicketCipher > cipher_
Future< typename std::decay< T >::type > makeFuture(T &&t)
Definition: Future-inl.h:1310
folly::Future<folly::Optional< std::pair<std::unique_ptr<folly::IOBuf>, std::chrono::seconds> > > fizz::server::DualTicketCipher::encrypt ( ResumptionState  resState) const
inlineoverridevirtual

Returns an opaque PSK for ResumptionState, and its validity time.

Implements fizz::server::TicketCipher.

Definition at line 31 of file DualTicketCipher.h.

References cipher_, and folly::gen::move.

31  {
32  return cipher_->encrypt(std::move(resState));
33  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< TicketCipher > cipher_

Member Data Documentation

std::unique_ptr<TicketCipher> fizz::server::DualTicketCipher::cipher_
private

Definition at line 50 of file DualTicketCipher.h.

Referenced by decrypt(), and encrypt().

std::unique_ptr<TicketCipher> fizz::server::DualTicketCipher::fallbackCipher_
private

Definition at line 51 of file DualTicketCipher.h.

Referenced by decrypt().


The documentation for this class was generated from the following file: