Botan::OneAndZeros_Padding Class Reference

#include <mode_pad.h>

Inheritance diagram for Botan::OneAndZeros_Padding:

Botan::BlockCipherModePaddingMethod

List of all members.

Public Member Functions

std::string name () const
void pad (byte[], u32bit, u32bit) const
virtual u32bit pad_bytes (u32bit block_size, u32bit position) const
u32bit unpad (const byte[], u32bit) const
bool valid_blocksize (u32bit) const


Detailed Description

One And Zeros Padding

Definition at line 96 of file mode_pad.h.


Member Function Documentation

std::string Botan::OneAndZeros_Padding::name (  )  const [inline, virtual]

Returns:
name of the mode

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 102 of file mode_pad.h.

Referenced by unpad().

00102 { return "OneAndZeros"; }

void Botan::OneAndZeros_Padding::pad ( byte  block[],
u32bit  size,
u32bit  current_position 
) const [virtual]

Parameters:
block output buffer
size of the block
current_position in the last block

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 93 of file mode_pad.cpp.

00094    {
00095    block[0] = 0x80;
00096    for(u32bit j = 1; j != size; ++j)
00097       block[j] = 0x00;
00098    }

u32bit Botan::BlockCipherModePaddingMethod::pad_bytes ( u32bit  block_size,
u32bit  position 
) const [virtual, inherited]

Parameters:
block_size of the cipher
position in the current block
Returns:
number of padding bytes that will be appended

Reimplemented in Botan::Null_Padding.

Definition at line 16 of file mode_pad.cpp.

00017    {
00018    return (bs - pos);
00019    }

u32bit Botan::OneAndZeros_Padding::unpad ( const   block[],
u32bit  size 
) const [virtual]

Parameters:
block the last block
size the of the block

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 103 of file mode_pad.cpp.

References name().

00104    {
00105    while(size)
00106       {
00107       if(block[size-1] == 0x80)
00108          break;
00109       if(block[size-1] != 0x00)
00110          throw Decoding_Error(name());
00111       size--;
00112       }
00113    if(!size)
00114       throw Decoding_Error(name());
00115    return (size-1);
00116    }

bool Botan::OneAndZeros_Padding::valid_blocksize ( u32bit  block_size  )  const [virtual]

Parameters:
block_size of the cipher
Returns:
valid block size for this padding mode

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 121 of file mode_pad.cpp.

00122    {
00123    return (size > 0);
00124    }


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

Generated on Fri Aug 13 16:20:59 2010 for Botan by  doxygen 1.5.8