Botan 3.5.0
Crypto and TLS for C&
Botan::Null_Padding Class Referencefinal

#include <mode_pad.h>

Inheritance diagram for Botan::Null_Padding:
Botan::BlockCipherModePaddingMethod

Public Member Functions

void add_padding (secure_vector< uint8_t > &, size_t, size_t) const override
 
std::string name () const override
 
size_t unpad (const uint8_t[], size_t size) const override
 
bool valid_blocksize (size_t) const override
 

Static Public Member Functions

static std::unique_ptr< BlockCipherModePaddingMethodcreate (std::string_view algo_spec)
 

Detailed Description

Null Padding

Definition at line 126 of file mode_pad.h.

Member Function Documentation

◆ add_padding()

void Botan::Null_Padding::add_padding ( secure_vector< uint8_t > & buffer,
size_t final_block_bytes,
size_t block_size ) const
inlineoverridevirtual

Add padding bytes to buffer.

Parameters
bufferdata to pad
final_block_bytessize of the final block in bytes
block_sizesize of each block in bytes

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 128 of file mode_pad.h.

128 { /* no padding */
129 }

◆ create()

std::unique_ptr< BlockCipherModePaddingMethod > Botan::BlockCipherModePaddingMethod::create ( std::string_view algo_spec)
staticinherited

Get a block cipher padding mode by name (eg "NoPadding" or "PKCS7")

Parameters
algo_specblock cipher padding mode name

Get a block cipher padding method by name

Definition at line 19 of file mode_pad.cpp.

19 {
20 if(algo_spec == "NoPadding") {
21 return std::make_unique<Null_Padding>();
22 }
23
24 if(algo_spec == "PKCS7") {
25 return std::make_unique<PKCS7_Padding>();
26 }
27
28 if(algo_spec == "OneAndZeros") {
29 return std::make_unique<OneAndZeros_Padding>();
30 }
31
32 if(algo_spec == "X9.23") {
33 return std::make_unique<ANSI_X923_Padding>();
34 }
35
36 if(algo_spec == "ESP") {
37 return std::make_unique<ESP_Padding>();
38 }
39
40 return nullptr;
41}

Referenced by Botan::Cipher_Mode::create().

◆ name()

std::string Botan::Null_Padding::name ( ) const
inlineoverridevirtual
Returns
name of the mode

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 135 of file mode_pad.h.

135{ return "NoPadding"; }

◆ unpad()

size_t Botan::Null_Padding::unpad ( const uint8_t block[],
size_t len ) const
inlineoverridevirtual

Remove padding bytes from block

Parameters
blockthe last block
lenthe size of the block in bytes
Returns
number of data bytes, or if the padding is invalid returns len

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 131 of file mode_pad.h.

131{ return size; }

◆ valid_blocksize()

bool Botan::Null_Padding::valid_blocksize ( size_t block_size) const
inlineoverridevirtual
Parameters
block_sizeof the cipher
Returns
valid block size for this padding mode

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 133 of file mode_pad.h.

133{ return true; }

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