Botan  1.11.15
Public Member Functions
Botan::ANSI_X923_Padding Class Reference

#include <mode_pad.h>

Inheritance diagram for Botan::ANSI_X923_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

ANSI X9.23 Padding

Definition at line 76 of file mode_pad.h.


Member Function Documentation

void Botan::ANSI_X923_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 66 of file mode_pad.cpp.

   {
   const byte pad_value = block_size - last_byte_pos;

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

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 87 of file mode_pad.h.

Referenced by unpad().

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

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 80 of file mode_pad.cpp.

References name().

   {
   size_t position = block[size-1];
   if(position > size)
      throw Decoding_Error(name());
   for(size_t j = size-position; j != size-1; ++j)
      if(block[j] != 0)
         throw Decoding_Error(name());
   return (size-position);
   }
bool Botan::ANSI_X923_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 85 of file mode_pad.h.

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

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