Botan 3.14.1
Crypto and TLS for C&
Botan::DLIES_Encryptor Class Referencefinal

#include <dlies.h>

Inheritance diagram for Botan::DLIES_Encryptor:
Botan::PK_Encryptor

Public Member Functions

 DLIES_Encryptor (const DH_PrivateKey &own_priv_key, RandomNumberGenerator &rng, std::unique_ptr< KDF > kdf, std::unique_ptr< Cipher_Mode > cipher, size_t cipher_key_len, std::unique_ptr< MessageAuthenticationCode > mac, size_t mac_key_len=20)
 DLIES_Encryptor (const DH_PrivateKey &own_priv_key, RandomNumberGenerator &rng, std::unique_ptr< KDF > kdf, std::unique_ptr< MessageAuthenticationCode > mac, size_t mac_key_len=20)
std::vector< uint8_t > encrypt (const uint8_t in[], size_t length, RandomNumberGenerator &rng) const
std::vector< uint8_t > encrypt (std::span< const uint8_t > in, RandomNumberGenerator &rng) const
void set_initialization_vector (const InitializationVector &iv)
void set_other_key (const std::vector< uint8_t > &other_pub_key)

Detailed Description

DLIES Encryption

DLIES is obsolete and deprecated. Use HPKE in new systems.

Definition at line 27 of file dlies.h.

Constructor & Destructor Documentation

◆ DLIES_Encryptor() [1/2]

Botan::DLIES_Encryptor::DLIES_Encryptor ( const DH_PrivateKey & own_priv_key,
RandomNumberGenerator & rng,
std::unique_ptr< KDF > kdf,
std::unique_ptr< MessageAuthenticationCode > mac,
size_t mac_key_len = 20 )

Stream mode: use KDF to provide a stream of bytes to xor with the message

Parameters
own_priv_keyown (ephemeral) DH private key
Random Number Generatorsthe RNG to use
Key Derivation Functionsthe KDF that should be used
Message Authentication Codesthe MAC function that should be used
mac_key_lenkey length of the MAC function. Default = 20 bytes

output = (ephemeral) public key + ciphertext + tag

Definition at line 17 of file dlies.cpp.

21 :
22 DLIES_Encryptor(own_priv_key, rng, std::move(kdf), nullptr, 0, std::move(mac), mac_key_length) {}
DLIES_Encryptor(const DH_PrivateKey &own_priv_key, RandomNumberGenerator &rng, std::unique_ptr< KDF > kdf, std::unique_ptr< MessageAuthenticationCode > mac, size_t mac_key_len=20)
Definition dlies.cpp:17

References DLIES_Encryptor().

Referenced by DLIES_Encryptor().

◆ DLIES_Encryptor() [2/2]

Botan::DLIES_Encryptor::DLIES_Encryptor ( const DH_PrivateKey & own_priv_key,
RandomNumberGenerator & rng,
std::unique_ptr< KDF > kdf,
std::unique_ptr< Cipher_Mode > cipher,
size_t cipher_key_len,
std::unique_ptr< MessageAuthenticationCode > mac,
size_t mac_key_len = 20 )

Block cipher mode

Parameters
own_priv_keyown (ephemeral) DH private key
Random Number Generatorsthe RNG to use
Key Derivation Functionsthe KDF that should be used
cipherthe block cipher that should be used
cipher_key_lenthe key length of the block cipher
Message Authentication Codesthe MAC function that should be used
mac_key_lenkey length of the MAC function. Default = 20 bytes

output = (ephemeral) public key + ciphertext + tag

Definition at line 24 of file dlies.cpp.

30 :
31
32 m_own_pub_key(own_priv_key.public_value()),
33 m_ka(own_priv_key, rng, PK_Key_Agreement_Options().with_raw_shared_key()),
34 m_kdf(std::move(kdf)),
35 m_cipher(std::move(cipher)),
36 m_cipher_key_len(cipher_key_len),
37 m_mac(std::move(mac)),
38 m_mac_keylen(mac_key_length) {
41}
#define BOTAN_ASSERT_NONNULL(ptr)
Definition assert.h:121

References BOTAN_ASSERT_NONNULL.

Member Function Documentation

◆ encrypt() [1/2]

std::vector< uint8_t > Botan::PK_Encryptor::encrypt ( const uint8_t in[],
size_t length,
RandomNumberGenerator & rng ) const
inlineinherited

Encrypt a message.

Parameters
inthe message as a byte array
lengththe length of the above byte array
Random Number Generatorsthe random number source to use
Returns
encrypted message

Definition at line 37 of file pubkey.h.

37 {
38 return enc(in, length, rng);
39 }

Referenced by Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), and Botan::KeyPair::encryption_consistency_check().

◆ encrypt() [2/2]

std::vector< uint8_t > Botan::PK_Encryptor::encrypt ( std::span< const uint8_t > in,
RandomNumberGenerator & rng ) const
inlineinherited

Encrypt a message.

Parameters
inthe message
Random Number Generatorsthe random number source to use
Returns
encrypted message

Definition at line 47 of file pubkey.h.

47 {
48 return enc(in.data(), in.size(), rng);
49 }

◆ set_initialization_vector()

void Botan::DLIES_Encryptor::set_initialization_vector ( const InitializationVector & iv)
inline

Set the initialization vector for the data encryption method

If DLIES is being used with a cipher, a fresh IV must be provided for each message; it is not included in the serialized ciphertext and must be conveyed separately.

Warning
DLIES does not authenticate the IV, so for uses based on CBC it is possible for an attacker to manipulate ciphertexts undetectably, for example by flipping bytes in the ciphertext knowing that this will cause single corrupted blocks. This weakness is intrinsic to the DLIES scheme when used with CBC mode ciphers.

Definition at line 83 of file dlies.h.

83{ m_iv = iv; }

◆ set_other_key()

void Botan::DLIES_Encryptor::set_other_key ( const std::vector< uint8_t > & other_pub_key)
inline

Definition at line 70 of file dlies.h.

70{ m_other_pub_key = other_pub_key; }

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