proxygen
|
#include <OpenSSLEVPCipher.h>
Public Member Functions | |
OpenSSLEVPCipher () | |
~OpenSSLEVPCipher () override=default | |
OpenSSLEVPCipher (OpenSSLEVPCipher &&other)=default | |
OpenSSLEVPCipher & | operator= (OpenSSLEVPCipher &&other)=default |
void | setKey (TrafficKey trafficKey) override |
size_t | keyLength () const override |
size_t | ivLength () const override |
std::unique_ptr< folly::IOBuf > | encrypt (std::unique_ptr< folly::IOBuf > &&plaintext, const folly::IOBuf *associatedData, uint64_t seqNum) const override |
folly::Optional< std::unique_ptr< folly::IOBuf > > | tryDecrypt (std::unique_ptr< folly::IOBuf > &&ciphertext, const folly::IOBuf *associatedData, uint64_t seqNum) const override |
size_t | getCipherOverhead () const override |
void | setEncryptedBufferHeadroom (size_t headroom) override |
Public Member Functions inherited from fizz::Aead | |
virtual | ~Aead ()=default |
virtual std::unique_ptr< folly::IOBuf > | decrypt (std::unique_ptr< folly::IOBuf > &&ciphertext, const folly::IOBuf *associatedData, uint64_t seqNum) const |
Private Member Functions | |
std::array< uint8_t, EVPImpl::kIVLength > | createIV (uint64_t seqNum) const |
Private Attributes | |
TrafficKey | trafficKey_ |
size_t | headroom_ {5} |
folly::ssl::EvpCipherCtxUniquePtr | encryptCtx_ |
folly::ssl::EvpCipherCtxUniquePtr | decryptCtx_ |
Aead implementation using an OpenSSL EvpCipher.
The template struct requires the following parameters:
Definition at line 39 of file OpenSSLEVPCipher.h.
fizz::OpenSSLEVPCipher< EVPImpl >::OpenSSLEVPCipher | ( | ) |
Definition at line 30 of file OpenSSLEVPCipher-inl.h.
|
overridedefault |
|
default |
|
private |
Definition at line 153 of file OpenSSLEVPCipher-inl.h.
References folly::Endian::big(), folly::range(), uint64_t, and fizz::XOR().
Referenced by fizz::OpenSSLEVPCipher< EVPImpl >::setEncryptedBufferHeadroom().
|
overridevirtual |
Encrypts plaintext. Will throw on error.
Implements fizz::Aead.
Definition at line 113 of file OpenSSLEVPCipher-inl.h.
References fizz::detail::evpEncrypt(), and folly::gen::move.
Referenced by fizz::OpenSSLEVPCipher< EVPImpl >::ivLength().
|
overridevirtual |
Returns the number of bytes the aead will add to the plaintext (size of ciphertext - size of plaintext).
Implements fizz::Aead.
Definition at line 148 of file OpenSSLEVPCipher-inl.h.
Referenced by fizz::OpenSSLEVPCipher< EVPImpl >::ivLength().
|
inlineoverridevirtual |
Returns the number of iv bytes needed by this aead.
Implements fizz::Aead.
Definition at line 55 of file OpenSSLEVPCipher.h.
References fizz::OpenSSLEVPCipher< EVPImpl >::encrypt(), fizz::OpenSSLEVPCipher< EVPImpl >::getCipherOverhead(), fizz::OpenSSLEVPCipher< EVPImpl >::tryDecrypt(), and uint64_t.
|
inlineoverridevirtual |
Returns the number of key bytes needed by this aead.
Implements fizz::Aead.
Definition at line 51 of file OpenSSLEVPCipher.h.
|
default |
|
inlineoverridevirtual |
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.
Implements fizz::Aead.
Definition at line 75 of file OpenSSLEVPCipher.h.
References fizz::OpenSSLEVPCipher< EVPImpl >::createIV(), fizz::OpenSSLEVPCipher< EVPImpl >::headroom_, and uint64_t.
|
overridevirtual |
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 84 of file OpenSSLEVPCipher-inl.h.
References fizz::TrafficKey::iv, fizz::TrafficKey::key, and folly::gen::move.
|
overridevirtual |
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 130 of file OpenSSLEVPCipher-inl.h.
References fizz::detail::evpDecrypt(), and folly::gen::move.
Referenced by fizz::OpenSSLEVPCipher< EVPImpl >::ivLength().
|
private |
Definition at line 86 of file OpenSSLEVPCipher.h.
|
private |
Definition at line 85 of file OpenSSLEVPCipher.h.
|
private |
Definition at line 83 of file OpenSSLEVPCipher.h.
Referenced by fizz::OpenSSLEVPCipher< EVPImpl >::setEncryptedBufferHeadroom().
|
private |
Definition at line 82 of file OpenSSLEVPCipher.h.