Botan 3.0.0
Crypto and TLS for C&
Public Member Functions | Static Public Member Functions | List of all members
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 141 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 144 of file mode_pad.h.

145 {
146 /* no padding */
147 }

◆ 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.

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

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 153 of file mode_pad.h.

153{ 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 149 of file mode_pad.h.

149{ 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 151 of file mode_pad.h.

151{ return true; }

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