proxygen
|
#include <AeadTokenCipher.h>
Public Member Functions | |
AeadTokenCipher (std::vector< std::string > contextStrings) | |
~AeadTokenCipher () | |
bool | setSecrets (const std::vector< folly::ByteRange > &tokenSecrets) |
folly::Optional< Buf > | encrypt (Buf plaintext) const |
folly::Optional< Buf > | decrypt (Buf) const |
Static Public Attributes | |
static constexpr size_t | kMinTokenSecretLength = 32 |
Private Types | |
using | Secret = std::vector< uint8_t > |
using | Salt = std::array< uint8_t, kSaltLength > |
using | SeqNum = uint32_t |
Private Member Functions | |
AeadType | createAead (folly::ByteRange secret, folly::ByteRange salt) const |
void | clearSecrets () |
Private Attributes | |
std::vector< Secret > | secrets_ |
std::vector< std::string > | contextStrings_ |
Static Private Attributes | |
static constexpr size_t | kSaltLength = HkdfType::HashLen |
static constexpr size_t | kTokenHeaderLength = kSaltLength + sizeof(SeqNum) |
Used to encrypt and decrypt various tokens (for example PSKs).
Definition at line 22 of file AeadTokenCipher.h.
|
private |
Definition at line 53 of file AeadTokenCipher.h.
|
private |
Definition at line 51 of file AeadTokenCipher.h.
|
private |
Definition at line 54 of file AeadTokenCipher.h.
|
inlineexplicit |
Set additional context strings for use with these tokens. The strings will be used, in order, as part of the key derivation so that different contexts will result in different keys, preventing keys from one context from being used for another.
Definition at line 32 of file AeadTokenCipher.h.
|
inline |
Definition at line 35 of file AeadTokenCipher.h.
References fizz::server::AeadTokenCipher< AeadType, HkdfType >::clearSecrets(), fizz::server::AeadTokenCipher< AeadType, HkdfType >::decrypt(), fizz::server::AeadTokenCipher< AeadType, HkdfType >::encrypt(), and fizz::server::AeadTokenCipher< AeadType, HkdfType >::setSecrets().
|
private |
Definition at line 125 of file AeadTokenCipher-inl.h.
References fizz::CryptoUtils::clean(), folly::range(), and secret.
Referenced by fizz::server::AeadTokenCipher< AeadType, HkdfType >::~AeadTokenCipher().
|
private |
Definition at line 109 of file AeadTokenCipher-inl.h.
References deadlock::info(), folly::gen::move, and folly::IOBuf::wrapBuffer().
folly::Optional< Buf > fizz::server::AeadTokenCipher< AeadType, HkdfType >::decrypt | ( | Buf | token | ) | const |
Definition at line 83 of file AeadTokenCipher-inl.h.
References folly::gen::move, folly::none, folly::range(), and secret.
Referenced by fizz::server::AeadTokenCipher< AeadType, HkdfType >::~AeadTokenCipher().
folly::Optional< Buf > fizz::server::AeadTokenCipher< AeadType, HkdfType >::encrypt | ( | Buf | plaintext | ) | const |
Definition at line 62 of file AeadTokenCipher-inl.h.
References folly::IOBuf::create(), folly::gen::move, folly::none, folly::io::detail::Writable< Derived >::push(), and folly::range().
Referenced by fizz::server::AeadTokenCipher< AeadType, HkdfType >::~AeadTokenCipher().
bool fizz::server::AeadTokenCipher< AeadType, HkdfType >::setSecrets | ( | const std::vector< folly::ByteRange > & | tokenSecrets | ) |
Set secrets to use for token encryption/decryption. The first one will be used for encryption. All secrets must be at least kMinTokenSecretLength long.
Definition at line 37 of file AeadTokenCipher-inl.h.
References folly::gen::move, and folly::range().
Referenced by fizz::server::AeadTokenCipher< AeadType, HkdfType >::~AeadTokenCipher().
|
private |
Definition at line 64 of file AeadTokenCipher.h.
|
static |
Definition at line 24 of file AeadTokenCipher.h.
|
staticprivate |
Definition at line 52 of file AeadTokenCipher.h.
|
staticprivate |
Definition at line 55 of file AeadTokenCipher.h.
|
private |
Definition at line 62 of file AeadTokenCipher.h.