Botan 3.9.0
Crypto and TLS for C&
|
#include <mode_pad.h>
Public Member Functions | |
virtual void | add_padding (std::span< uint8_t > buffer, size_t final_block_bytes, size_t block_size) const |
void | apply_padding (std::span< uint8_t > last_block, size_t final_block_bytes) const override |
std::string | name () const override |
virtual size_t | output_length (size_t input_length, size_t block_size) const |
size_t | remove_padding (std::span< const uint8_t > last_block) const override |
size_t | unpad (std::span< const uint8_t > last_block) const |
bool | valid_blocksize (size_t bs) const override |
Static Public Member Functions | |
static std::unique_ptr< BlockCipherModePaddingMethod > | create (std::string_view algo_spec) |
PKCS#7 Padding
Definition at line 106 of file mode_pad.h.
|
virtualinherited |
Add padding bytes to buffer.
buffer | data to pad, span must be large enough to hold the padding behind the final (partial) block |
final_block_bytes | size of the final block in bytes |
block_size | size of each block in bytes |
Reimplemented in Botan::Null_Padding.
Definition at line 44 of file mode_pad.cpp.
References apply_padding(), BOTAN_ASSERT_NOMSG, Botan::CT::scoped_poison(), and valid_blocksize().
|
overridevirtual |
Applies the concrete padding to the last_block
assuming the padding bytes should start at padding_start_pos
within the last block.
Concrete implementations of this function must ensure not to leak padding_start_pos
via side channels. Both the bytes of last_block
and padding_start_pos
are passed in with CT::poison applied.
Implements Botan::BlockCipherModePaddingMethod.
Definition at line 66 of file mode_pad.cpp.
References Botan::CT::Mask< T >::is_gte().
|
staticinherited |
Get a block cipher padding mode by name (eg "NoPadding" or "PKCS7")
algo_spec | block cipher padding mode name |
Get a block cipher padding method by name
Definition at line 20 of file mode_pad.cpp.
Referenced by Botan::Cipher_Mode::create().
|
inlineoverridevirtual |
Implements Botan::BlockCipherModePaddingMethod.
Definition at line 114 of file mode_pad.h.
|
inlinevirtualinherited |
input_length | number of bytes to be padded |
block_size | size of each block in bytes |
Reimplemented in Botan::Null_Padding.
Definition at line 66 of file mode_pad.h.
Referenced by Botan::CBC_Encryption::output_length().
|
overridevirtual |
Removes the padding from last_block
and returns the number of data bytes. If the padding is invalid, this returns the byte length of last_block
.
Concrete implementations of this function must ensure not to leak the size or validity of the padding via side channels. The bytes of last_block
are passed in with CT::poison applied to them.
Implements Botan::BlockCipherModePaddingMethod.
Definition at line 86 of file mode_pad.cpp.
References Botan::CT::Mask< T >::is_equal(), Botan::CT::Mask< T >::is_gt(), and Botan::CT::Mask< T >::is_gte().
|
inherited |
Remove padding bytes from block
last_block | the last block containing the padding |
last_block
(i.e. the block size) Definition at line 54 of file mode_pad.cpp.
References Botan::CT::driveby_unpoison(), remove_padding(), Botan::CT::scoped_poison(), and valid_blocksize().
|
inlineoverridevirtual |
block_size | of the cipher |
Implements Botan::BlockCipherModePaddingMethod.
Definition at line 112 of file mode_pad.h.