Botan  1.11.15
Public Member Functions
Botan::PKCS7_Padding Class Reference

#include <mode_pad.h>

Inheritance diagram for Botan::PKCS7_Padding:
Botan::BlockCipherModePaddingMethod

List of all members.

Public Member Functions

void add_padding (secure_vector< byte > &buffer, size_t final_block_bytes, size_t block_size) const override
std::string name () const
size_t unpad (const byte[], size_t) const
bool valid_blocksize (size_t bs) const

Detailed Description

PKCS#7 Padding

Definition at line 59 of file mode_pad.h.


Member Function Documentation

void Botan::PKCS7_Padding::add_padding ( secure_vector< byte > &  buffer,
size_t  final_block_bytes,
size_t  block_size 
) const [override, virtual]

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 36 of file mode_pad.cpp.

   {
   const byte pad_value = block_size - last_byte_pos;

   for(size_t i = 0; i != pad_value; ++i)
      buffer.push_back(pad_value);
   }
std::string Botan::PKCS7_Padding::name ( ) const [inline, virtual]
Returns:
name of the mode

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 70 of file mode_pad.h.

Referenced by unpad().

{ return "PKCS7"; }
size_t Botan::PKCS7_Padding::unpad ( const byte  block[],
size_t  size 
) const [virtual]
Parameters:
blockthe last block
sizethe of the block

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 49 of file mode_pad.cpp.

References name().

   {
   size_t position = block[size-1];

   if(position > size)
      throw Decoding_Error("Bad padding in " + name());

   for(size_t j = size-position; j != size-1; ++j)
      if(block[j] != position)
         throw Decoding_Error("Bad padding in " + name());

   return (size-position);
   }
bool Botan::PKCS7_Padding::valid_blocksize ( size_t  block_size) const [inline, virtual]
Parameters:
block_sizeof the cipher
Returns:
valid block size for this padding mode

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 68 of file mode_pad.h.

{ return (bs > 0 && bs < 256); }

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