proxygen
fizz::test::MockAead Class Reference

#include <Mocks.h>

Inheritance diagram for fizz::test::MockAead:
fizz::Aead

Public Member Functions

 MOCK_CONST_METHOD0 (keyLength, size_t())
 
 MOCK_CONST_METHOD0 (ivLength, size_t())
 
 MOCK_CONST_METHOD0 (getCipherOverhead, size_t())
 
 MOCK_METHOD1 (setEncryptedBufferHeadroom, void(size_t))
 
 MOCK_METHOD1 (_setKey, void(TrafficKey &key))
 
void setKey (TrafficKey key) override
 
 MOCK_CONST_METHOD3 (_encrypt, std::unique_ptr< folly::IOBuf >(std::unique_ptr< folly::IOBuf > &plaintext, const folly::IOBuf *associatedData, uint64_t seqNum))
 
std::unique_ptr< folly::IOBufencrypt (std::unique_ptr< folly::IOBuf > &&plaintext, const folly::IOBuf *associatedData, uint64_t seqNum) const override
 
 MOCK_CONST_METHOD3 (_decrypt, std::unique_ptr< folly::IOBuf >(std::unique_ptr< folly::IOBuf > &ciphertext, const folly::IOBuf *associatedData, uint64_t seqNum))
 
std::unique_ptr< folly::IOBufdecrypt (std::unique_ptr< folly::IOBuf > &&ciphertext, const folly::IOBuf *associatedData, uint64_t seqNum) const override
 
 MOCK_CONST_METHOD3 (_tryDecrypt, folly::Optional< std::unique_ptr< folly::IOBuf >>(std::unique_ptr< folly::IOBuf > &ciphertext, const folly::IOBuf *associatedData, uint64_t seqNum))
 
folly::Optional< std::unique_ptr< folly::IOBuf > > tryDecrypt (std::unique_ptr< folly::IOBuf > &&ciphertext, const folly::IOBuf *associatedData, uint64_t seqNum) const override
 
void setDefaults ()
 
- Public Member Functions inherited from fizz::Aead
virtual ~Aead ()=default
 
virtual size_t keyLength () const =0
 
virtual size_t ivLength () const =0
 
virtual void setEncryptedBufferHeadroom (size_t headroom)=0
 
virtual size_t getCipherOverhead () const =0
 

Detailed Description

Definition at line 20 of file Mocks.h.

Member Function Documentation

std::unique_ptr<folly::IOBuf> fizz::test::MockAead::decrypt ( std::unique_ptr< folly::IOBuf > &&  ciphertext,
const folly::IOBuf associatedData,
uint64_t  seqNum 
) const
inlineoverridevirtual

Decrypt ciphertext. Will throw if the ciphertext does not decrypt successfully.

Reimplemented from fizz::Aead.

Definition at line 51 of file Mocks.h.

References MOCK_CONST_METHOD3, and uint64_t.

54  {
55  return _decrypt(ciphertext, associatedData, seqNum);
56  }
std::unique_ptr<folly::IOBuf> fizz::test::MockAead::encrypt ( std::unique_ptr< folly::IOBuf > &&  plaintext,
const folly::IOBuf associatedData,
uint64_t  seqNum 
) const
inlineoverridevirtual

Encrypts plaintext. Will throw on error.

Implements fizz::Aead.

Definition at line 38 of file Mocks.h.

References MOCK_CONST_METHOD3, and uint64_t.

41  {
42  return _encrypt(plaintext, associatedData, seqNum);
43  }
fizz::test::MockAead::MOCK_CONST_METHOD0 ( keyLength  ,
size_t()   
)
fizz::test::MockAead::MOCK_CONST_METHOD0 ( ivLength  ,
size_t()   
)
fizz::test::MockAead::MOCK_CONST_METHOD0 ( getCipherOverhead  ,
size_t()   
)
fizz::test::MockAead::MOCK_CONST_METHOD3 ( _encrypt  ,
std::unique_ptr< folly::IOBuf std::unique_ptr< folly::IOBuf > &plaintext, const folly::IOBuf *associatedData, uint64_t seqNum 
)
fizz::test::MockAead::MOCK_CONST_METHOD3 ( _decrypt  ,
std::unique_ptr< folly::IOBuf std::unique_ptr< folly::IOBuf > &ciphertext, const folly::IOBuf *associatedData, uint64_t seqNum 
)
fizz::test::MockAead::MOCK_CONST_METHOD3 ( _tryDecrypt  ,
folly::Optional< std::unique_ptr< folly::IOBuf >>  std::unique_ptr< folly::IOBuf > &ciphertext, const folly::IOBuf *associatedData, uint64_t seqNum 
)
fizz::test::MockAead::MOCK_METHOD1 ( setEncryptedBufferHeadroom  ,
void(size_t)   
)
fizz::test::MockAead::MOCK_METHOD1 ( _setKey  ,
void(TrafficKey &key)   
)
void fizz::test::MockAead::setDefaults ( )
inline

Definition at line 71 of file Mocks.h.

References testing::_, folly::IOBuf::copyBuffer(), testing::InvokeWithoutArgs(), and ON_CALL.

71  {
72  ON_CALL(*this, _encrypt(_, _, _)).WillByDefault(InvokeWithoutArgs([]() {
73  return folly::IOBuf::copyBuffer("ciphertext");
74  }));
75  ON_CALL(*this, _decrypt(_, _, _)).WillByDefault(InvokeWithoutArgs([]() {
76  return folly::IOBuf::copyBuffer("plaintext");
77  }));
78  ON_CALL(*this, _tryDecrypt(_, _, _)).WillByDefault(InvokeWithoutArgs([]() {
79  return folly::IOBuf::copyBuffer("plaintext");
80  }));
81  }
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
#define ON_CALL(obj, call)
const internal::AnythingMatcher _
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
void fizz::test::MockAead::setKey ( TrafficKey  key)
inlineoverridevirtual

Sets the key and iv for this aead. The length of the key and iv must match keyLength() and ivLength().

Implements fizz::Aead.

Definition at line 28 of file Mocks.h.

References MOCK_CONST_METHOD3, and uint64_t.

28  {
29  return _setKey(key);
30  }
folly::Optional<std::unique_ptr<folly::IOBuf> > fizz::test::MockAead::tryDecrypt ( std::unique_ptr< folly::IOBuf > &&  ciphertext,
const folly::IOBuf associatedData,
uint64_t  seqNum 
) const
inlineoverridevirtual

Decrypt ciphertext. Will return none if the ciphertext does not decrypt successfully. May still throw from errors unrelated to ciphertext.

Implements fizz::Aead.

Definition at line 64 of file Mocks.h.

67  {
68  return _tryDecrypt(ciphertext, associatedData, seqNum);
69  }

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