Botan  1.11.15
Public Member Functions
Botan::OneAndZeros_Padding Class Reference

#include <mode_pad.h>

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

One And Zeros Padding

Definition at line 93 of file mode_pad.h.


Member Function Documentation

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

   {
   buffer.push_back(0x80);

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

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 104 of file mode_pad.h.

Referenced by unpad().

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

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 107 of file mode_pad.cpp.

References name().

   {
   while(size)
      {
      if(block[size-1] == 0x80)
         break;
      if(block[size-1] != 0x00)
         throw Decoding_Error(name());
      size--;
      }
   if(!size)
      throw Decoding_Error(name());
   return (size-1);
   }
bool Botan::OneAndZeros_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 102 of file mode_pad.h.

{ return (bs > 0); }

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