Botan
1.11.15
|
#include <eax.h>
Public Types | |
typedef SCAN_Name | Spec |
Public Member Functions | |
bool | authenticated () const override |
void | clear () override |
size_t | default_nonce_length () const override |
virtual void | finish (secure_vector< byte > &final_block, size_t offset=0)=0 |
Key_Length_Specification | key_spec () const override |
virtual size_t | minimum_final_size () const =0 |
std::string | name () const override |
virtual size_t | output_length (size_t input_length) const =0 |
virtual std::string | provider () const |
template<typename Alloc > | |
void | set_ad (const std::vector< byte, Alloc > &ad) |
void | set_associated_data (const byte ad[], size_t ad_len) override |
template<typename Alloc > | |
void | set_associated_data_vec (const std::vector< byte, Alloc > &ad) |
template<typename Alloc > | |
void | set_key (const std::vector< byte, Alloc > &key) |
void | set_key (const SymmetricKey &key) |
void | set_key (const byte key[], size_t length) |
template<typename Alloc > | |
secure_vector< byte > | start (const std::vector< byte, Alloc > &nonce) |
secure_vector< byte > | start (const byte nonce[], size_t nonce_len) |
secure_vector< byte > | start () |
template<typename Alloc > | |
secure_vector< byte > | start_vec (const std::vector< byte, Alloc > &nonce) |
size_t | tag_size () const override |
virtual void | update (secure_vector< byte > &blocks, size_t offset=0)=0 |
size_t | update_granularity () const override |
bool | valid_keylength (size_t length) const |
bool | valid_nonce_length (size_t) const override |
Protected Member Functions | |
size_t | block_size () const |
EAX_Mode (BlockCipher *cipher, size_t tag_size) | |
Protected Attributes | |
secure_vector< byte > | m_ad_mac |
std::unique_ptr< BlockCipher > | m_cipher |
std::unique_ptr < MessageAuthenticationCode > | m_cmac |
std::unique_ptr< StreamCipher > | m_ctr |
secure_vector< byte > | m_nonce_mac |
size_t | m_tag_size |
typedef SCAN_Name Botan::Transform::Spec [inherited] |
Definition at line 27 of file transform.h.
Botan::EAX_Mode::EAX_Mode | ( | BlockCipher * | cipher, |
size_t | tag_size | ||
) | [protected] |
cipher | the cipher to use |
tag_size | is how big the auth tag will be |
Definition at line 39 of file eax.cpp.
References m_cmac, name(), and Botan::ASN1::to_string().
: m_tag_size(tag_size ? tag_size : cipher->block_size()), m_cipher(cipher), m_ctr(new CTR_BE(m_cipher->clone())), m_cmac(new CMAC(m_cipher->clone())) { if(m_tag_size < 8 || m_tag_size > m_cmac->output_length()) throw Invalid_Argument(name() + ": Bad tag size " + std::to_string(tag_size)); }
bool Botan::AEAD_Mode::authenticated | ( | ) | const [inline, override, virtual, inherited] |
Returns true iff this mode provides authentication as well as confidentiality.
Reimplemented from Botan::Cipher_Mode.
Definition at line 25 of file aead.h.
{ return true; }
size_t Botan::EAX_Mode::block_size | ( | ) | const [inline, protected] |
Definition at line 45 of file eax.h.
Referenced by set_associated_data().
{ return m_cipher->block_size(); }
void Botan::EAX_Mode::clear | ( | ) | [override, virtual] |
Implements Botan::Transform.
Definition at line 49 of file eax.cpp.
References m_ad_mac, m_cipher, m_cmac, m_ctr, m_nonce_mac, and Botan::zeroise().
size_t Botan::AEAD_Mode::default_nonce_length | ( | ) | const [inline, override, virtual, inherited] |
Default AEAD nonce size (a commonly supported value among AEAD modes, and large enough that random collisions are unlikely).
Implements Botan::Transform.
Reimplemented in Botan::CCM_Mode.
Definition at line 57 of file aead.h.
{ return 12; }
virtual void Botan::Transform::finish | ( | secure_vector< byte > & | final_block, |
size_t | offset = 0 |
||
) | [pure virtual, inherited] |
Complete processing of a message.
final_block | in/out parameter which must be at least minimum_final_size() bytes, and will be set to any final output |
offset | an offset into final_block to begin processing |
Implemented in Botan::CTS_Decryption, Botan::OCB_Decryption, Botan::CCM_Decryption, Botan::EAX_Decryption, Botan::CBC_Decryption, Botan::GCM_Decryption, Botan::SIV_Decryption, Botan::OCB_Encryption, Botan::CCM_Encryption, Botan::ChaCha20Poly1305_Decryption, Botan::CTS_Encryption, Botan::Stream_Decompression, Botan::CFB_Decryption, Botan::EAX_Encryption, Botan::SIV_Encryption, Botan::ECB_Decryption, Botan::XTS_Decryption, Botan::GCM_Encryption, Botan::CBC_Encryption, Botan::CFB_Encryption, Botan::ChaCha20Poly1305_Encryption, Botan::Stream_Compression, Botan::XTS_Encryption, Botan::ECB_Encryption, and Botan::Stream_Cipher_Mode.
Referenced by botan_cipher_update().
Key_Length_Specification Botan::EAX_Mode::key_spec | ( | ) | const [override, virtual] |
Implements Botan::Keyed_Transform.
Definition at line 68 of file eax.cpp.
References m_cipher.
{ return m_cipher->key_spec(); }
virtual size_t Botan::Transform::minimum_final_size | ( | ) | const [pure virtual, inherited] |
Implemented in Botan::CTS_Decryption, Botan::CCM_Decryption, Botan::OCB_Decryption, Botan::CBC_Decryption, Botan::SIV_Decryption, Botan::EAX_Decryption, Botan::GCM_Decryption, Botan::CCM_Encryption, Botan::OCB_Encryption, Botan::CTS_Encryption, Botan::ChaCha20Poly1305_Decryption, Botan::SIV_Encryption, Botan::ECB_Decryption, Botan::EAX_Encryption, Botan::CBC_Encryption, Botan::GCM_Encryption, Botan::ChaCha20Poly1305_Encryption, Botan::ECB_Encryption, Botan::Stream_Cipher_Mode, Botan::CFB_Mode, Botan::XTS_Mode, and Botan::Compressor_Transform.
Referenced by botan_cipher_update().
std::string Botan::EAX_Mode::name | ( | ) | const [override, virtual] |
Implements Botan::Transform.
Definition at line 58 of file eax.cpp.
References m_cipher.
Referenced by EAX_Mode().
{ return (m_cipher->name() + "/EAX"); }
virtual size_t Botan::Transform::output_length | ( | size_t | input_length | ) | const [pure virtual, inherited] |
Returns the size of the output if this transform is used to process a message with input_length bytes. Will throw if unable to give a precise answer.
Implemented in Botan::CCM_Decryption, Botan::OCB_Decryption, Botan::CBC_Decryption, Botan::SIV_Decryption, Botan::EAX_Decryption, Botan::CCM_Encryption, Botan::GCM_Decryption, Botan::OCB_Encryption, Botan::CTS_Encryption, Botan::SIV_Encryption, Botan::ECB_Decryption, Botan::ChaCha20Poly1305_Decryption, Botan::XTS_Decryption, Botan::EAX_Encryption, Botan::CBC_Encryption, Botan::GCM_Encryption, Botan::XTS_Encryption, Botan::ChaCha20Poly1305_Encryption, Botan::ECB_Encryption, Botan::CFB_Mode, Botan::Compressor_Transform, and Botan::Stream_Cipher_Mode.
virtual std::string Botan::Transform::provider | ( | ) | const [inline, virtual, inherited] |
Return some short name describing the provider of this tranformation. Useful in cases where multiple implementations are available (eg, different implementations of AES). Default "core" is used for the 'standard' implementation included in the library.
Definition at line 120 of file transform.h.
{ return "core"; }
void Botan::AEAD_Mode::set_ad | ( | const std::vector< byte, Alloc > & | ad | ) | [inline, inherited] |
Definition at line 48 of file aead.h.
{ set_associated_data(&ad[0], ad.size()); }
void Botan::EAX_Mode::set_associated_data | ( | const byte | ad[], |
size_t | ad_len | ||
) | [override, virtual] |
Set associated data that is not included in the ciphertext but that should be authenticated. Must be called after set_key and before start.
Unless reset by another call, the associated data is kept between messages. Thus, if the AD does not change, calling once (after set_key) is the optimum.
ad | the associated data |
ad_len | length of add in bytes |
Implements Botan::AEAD_Mode.
Definition at line 91 of file eax.cpp.
References block_size(), m_ad_mac, and m_cmac.
{ m_ad_mac = eax_prf(1, block_size(), *m_cmac, ad, length); }
void Botan::AEAD_Mode::set_associated_data_vec | ( | const std::vector< byte, Alloc > & | ad | ) | [inline, inherited] |
Definition at line 42 of file aead.h.
{ set_associated_data(&ad[0], ad.size()); }
void Botan::Keyed_Transform::set_key | ( | const std::vector< byte, Alloc > & | key | ) | [inline, inherited] |
Definition at line 148 of file transform.h.
Referenced by botan_cipher_set_key().
{ set_key(&key[0], key.size()); }
void Botan::Keyed_Transform::set_key | ( | const SymmetricKey & | key | ) | [inline, inherited] |
Definition at line 153 of file transform.h.
References Botan::OctetString::begin(), and Botan::OctetString::length().
{ set_key(key.begin(), key.length()); }
void Botan::Keyed_Transform::set_key | ( | const byte | key[], |
size_t | length | ||
) | [inline, inherited] |
Set the symmetric key of this transform
key | contains the key material |
length | in bytes of key param |
Definition at line 163 of file transform.h.
{ if(!valid_keylength(length)) throw Invalid_Key_Length(name(), length); key_schedule(key, length); }
secure_vector<byte> Botan::Transform::start | ( | const std::vector< byte, Alloc > & | nonce | ) | [inline, inherited] |
Begin processing a message.
nonce | the per message nonce |
Definition at line 34 of file transform.h.
Referenced by botan_cipher_start().
{ return start(&nonce[0], nonce.size()); }
secure_vector<byte> Botan::Transform::start | ( | const byte | nonce[], |
size_t | nonce_len | ||
) | [inline, inherited] |
Begin processing a message.
nonce | the per message nonce |
nonce_len | length of nonce |
Definition at line 55 of file transform.h.
{ return start_raw(nonce, nonce_len); }
secure_vector<byte> Botan::Transform::start | ( | ) | [inline, inherited] |
Begin processing a message.
Definition at line 63 of file transform.h.
{ return start_raw(nullptr, 0); }
secure_vector<byte> Botan::Transform::start_vec | ( | const std::vector< byte, Alloc > & | nonce | ) | [inline, inherited] |
Begin processing a message.
nonce | the per message nonce |
Definition at line 45 of file transform.h.
{ return start(&nonce[0], nonce.size()); }
size_t Botan::EAX_Mode::tag_size | ( | ) | const [inline, override, virtual] |
Return the size of the authentication tag used (in bytes)
Reimplemented from Botan::Cipher_Mode.
Definition at line 35 of file eax.h.
Referenced by Botan::EAX_Encryption::finish(), and Botan::EAX_Decryption::finish().
{ return m_tag_size; }
virtual void Botan::Transform::update | ( | secure_vector< byte > & | blocks, |
size_t | offset = 0 |
||
) | [pure virtual, inherited] |
Process some data. Input must be in size update_granularity() byte blocks.
blocks | in/out paramter which will possibly be resized |
offset | an offset into blocks to begin processing |
Implemented in Botan::OCB_Decryption, Botan::EAX_Decryption, Botan::CBC_Decryption, Botan::GCM_Decryption, Botan::OCB_Encryption, Botan::ChaCha20Poly1305_Decryption, Botan::Stream_Decompression, Botan::CFB_Decryption, Botan::EAX_Encryption, Botan::ECB_Decryption, Botan::XTS_Decryption, Botan::GCM_Encryption, Botan::CBC_Encryption, Botan::CFB_Encryption, Botan::ChaCha20Poly1305_Encryption, Botan::Stream_Compression, Botan::XTS_Encryption, Botan::ECB_Encryption, Botan::CCM_Mode, Botan::SIV_Mode, and Botan::Stream_Cipher_Mode.
Referenced by botan_cipher_update().
size_t Botan::EAX_Mode::update_granularity | ( | ) | const [override, virtual] |
Implements Botan::Transform.
Definition at line 63 of file eax.cpp.
References m_cipher.
{ return 8 * m_cipher->parallel_bytes(); }
bool Botan::Keyed_Transform::valid_keylength | ( | size_t | length | ) | const [inline, inherited] |
Check whether a given key length is valid for this algorithm.
length | the key length to be checked. |
Definition at line 142 of file transform.h.
References Botan::Key_Length_Specification::valid_keylength().
{ return key_spec().valid_keylength(length); }
bool Botan::EAX_Mode::valid_nonce_length | ( | size_t | nonce_len | ) | const [inline, override, virtual] |
Return true iff nonce_len is a valid length for the nonce
Implements Botan::Transform.
Definition at line 33 of file eax.h.
{ return true; }
secure_vector<byte> Botan::EAX_Mode::m_ad_mac [protected] |
Definition at line 53 of file eax.h.
Referenced by clear(), Botan::EAX_Encryption::finish(), Botan::EAX_Decryption::finish(), and set_associated_data().
std::unique_ptr<BlockCipher> Botan::EAX_Mode::m_cipher [protected] |
Definition at line 49 of file eax.h.
Referenced by clear(), key_spec(), name(), and update_granularity().
std::unique_ptr<MessageAuthenticationCode> Botan::EAX_Mode::m_cmac [protected] |
Definition at line 51 of file eax.h.
Referenced by clear(), EAX_Mode(), Botan::EAX_Encryption::finish(), Botan::EAX_Decryption::finish(), set_associated_data(), Botan::EAX_Encryption::update(), and Botan::EAX_Decryption::update().
std::unique_ptr<StreamCipher> Botan::EAX_Mode::m_ctr [protected] |
Definition at line 50 of file eax.h.
Referenced by clear(), Botan::EAX_Decryption::finish(), Botan::EAX_Encryption::update(), and Botan::EAX_Decryption::update().
secure_vector<byte> Botan::EAX_Mode::m_nonce_mac [protected] |
Definition at line 55 of file eax.h.
Referenced by clear(), Botan::EAX_Encryption::finish(), and Botan::EAX_Decryption::finish().
size_t Botan::EAX_Mode::m_tag_size [protected] |