proxygen
fizz::Aead Class Referenceabstract

#include <Aead.h>

Inheritance diagram for fizz::Aead:
fizz::OpenSSLEVPCipher< EVPImpl > fizz::test::MockAead

Public Member Functions

virtual ~Aead ()=default
 
virtual size_t keyLength () const =0
 
virtual size_t ivLength () const =0
 
virtual void setKey (TrafficKey key)=0
 
virtual std::unique_ptr< folly::IOBufencrypt (std::unique_ptr< folly::IOBuf > &&plaintext, const folly::IOBuf *associatedData, uint64_t seqNum) const =0
 
virtual void setEncryptedBufferHeadroom (size_t headroom)=0
 
virtual std::unique_ptr< folly::IOBufdecrypt (std::unique_ptr< folly::IOBuf > &&ciphertext, const folly::IOBuf *associatedData, uint64_t seqNum) const
 
virtual folly::Optional< std::unique_ptr< folly::IOBuf > > tryDecrypt (std::unique_ptr< folly::IOBuf > &&ciphertext, const folly::IOBuf *associatedData, uint64_t seqNum) const =0
 
virtual size_t getCipherOverhead () const =0
 

Detailed Description

Interface for aead algorithms (RFC 5116).

Definition at line 24 of file Aead.h.

Constructor & Destructor Documentation

virtual fizz::Aead::~Aead ( )
virtualdefault

Member Function Documentation

virtual std::unique_ptr<folly::IOBuf> fizz::Aead::decrypt ( std::unique_ptr< folly::IOBuf > &&  ciphertext,
const folly::IOBuf associatedData,
uint64_t  seqNum 
) const
inlinevirtual

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

Reimplemented in fizz::test::MockAead.

Definition at line 63 of file Aead.h.

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

66  {
67  auto plaintext = tryDecrypt(
68  std::forward<std::unique_ptr<folly::IOBuf>>(ciphertext),
69  associatedData,
70  seqNum);
71  if (!plaintext) {
72  throw std::runtime_error("decryption failed");
73  }
74  return std::move(*plaintext);
75  }
virtual folly::Optional< std::unique_ptr< folly::IOBuf > > tryDecrypt(std::unique_ptr< folly::IOBuf > &&ciphertext, const folly::IOBuf *associatedData, uint64_t seqNum) const =0
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
virtual std::unique_ptr<folly::IOBuf> fizz::Aead::encrypt ( std::unique_ptr< folly::IOBuf > &&  plaintext,
const folly::IOBuf associatedData,
uint64_t  seqNum 
) const
pure virtual

Encrypts plaintext. Will throw on error.

Implemented in fizz::OpenSSLEVPCipher< EVPImpl >, and fizz::test::MockAead.

virtual size_t fizz::Aead::getCipherOverhead ( ) const
pure virtual

Returns the number of bytes the aead will add to the plaintext (size of ciphertext - size of plaintext).

Implemented in fizz::OpenSSLEVPCipher< EVPImpl >.

virtual size_t fizz::Aead::ivLength ( ) const
pure virtual

Returns the number of iv bytes needed by this aead.

Implemented in fizz::OpenSSLEVPCipher< EVPImpl >.

virtual size_t fizz::Aead::keyLength ( ) const
pure virtual

Returns the number of key bytes needed by this aead.

Implemented in fizz::OpenSSLEVPCipher< EVPImpl >.

virtual void fizz::Aead::setEncryptedBufferHeadroom ( size_t  headroom)
pure virtual

Set a hint to the AEAD about how much space to try to leave as headroom for ciphertexts returned from encrypt. Implementations may or may not honor this.

Implemented in fizz::OpenSSLEVPCipher< EVPImpl >.

virtual void fizz::Aead::setKey ( TrafficKey  key)
pure virtual

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

Implemented in fizz::OpenSSLEVPCipher< EVPImpl >, and fizz::test::MockAead.

Referenced by encryptGCM().

virtual folly::Optional<std::unique_ptr<folly::IOBuf> > fizz::Aead::tryDecrypt ( std::unique_ptr< folly::IOBuf > &&  ciphertext,
const folly::IOBuf associatedData,
uint64_t  seqNum 
) const
pure virtual

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

Implemented in fizz::OpenSSLEVPCipher< EVPImpl >, and fizz::test::MockAead.


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