Botan::PKCS7_Padding Class Reference

#include <mode_pad.h>

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

PKCS#7 Padding

Definition at line 72 of file mode_pad.h.


Member Function Documentation

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

Returns:
name of the mode

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 78 of file mode_pad.h.

Referenced by unpad().

00078 { return "PKCS7"; }

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

00025    {
00026    for(u32bit j = 0; j != size; ++j)
00027       block[j] = (size-position);
00028    }

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::PKCS7_Padding::unpad ( const   block[],
u32bit  size 
) const [virtual]

Parameters:
block the last block
size the of the block

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 33 of file mode_pad.cpp.

References name().

00034    {
00035    u32bit position = block[size-1];
00036    if(position > size)
00037       throw Decoding_Error(name());
00038    for(u32bit j = size-position; j != size-1; ++j)
00039       if(block[j] != position)
00040          throw Decoding_Error(name());
00041    return (size-position);
00042    }

bool Botan::PKCS7_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 47 of file mode_pad.cpp.

00048    {
00049    if(size > 0 && size < 256)
00050       return true;
00051    else
00052       return false;
00053    }


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