Botan: Botan::ANSI_X923_Padding Class Reference

Botan 1.10.12

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
Botan::ANSI_X923_Padding Class Reference

`#include <mode_pad.h>`

Inheritance diagram for Botan::ANSI_X923_Padding:

## Public Member Functions
std::string | name () const
void | pad (byte[], size_t, size_t) const
virtual size_t | pad_bytes (size_t block_size, size_t position) const
size_t | unpad (const byte[], size_t) const
bool | valid_blocksize (size_t) const

## Detailed Description

ANSI X9.23 Padding

Definition at line 84 of file mode_pad.h.

## Member Function Documentation

std::string Botan::ANSI_X923_Padding::name | ( |  | ) | const
| inlinevirtual

Returns
  name of the mode

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 90 of file mode_pad.h.

90 { return "X9.23"; }

void Botan::ANSI_X923_Padding::pad | ( | byte | block[],
|  | size_t | size,
|  | size_t | current_position
| ) |  | const
| virtual

Parameters

  block | output buffer
  size | of the block
  current_position | in the last block

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 65 of file mode_pad.cpp.

66 {
67 for(size_t j = 0; j != size-position; ++j)
68 block[j] = 0;
69 block[size-position-1] = static_cast<byte>(size-position);
70 }
Botan::byte
unsigned char byte
Definition: types.h:22

size_t Botan::BlockCipherModePaddingMethod::pad_bytes | ( | size_t | block_size,
|  | size_t | position
| ) |  | const
| virtualinherited

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 17 of file mode_pad.cpp.

Referenced by Botan::ECB_Encryption::name(), and Botan::CBC_Encryption::set_iv().

18 {
19 return (bs - pos);
20 }

size_t Botan::ANSI_X923_Padding::unpad | ( | const byte | block[],
|  | size_t | size
| ) |  | const
| virtual

Parameters

  block | the last block
  size | the of the block

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 75 of file mode_pad.cpp.

References Botan::BlockCipherModePaddingMethod::name().

76 {
77 size_t position = block[size-1];
78 if(position > size)
79 throw Decoding_Error(name());
80 for(size_t j = size-position; j != size-1; ++j)
81 if(block[j] != 0)
82 throw Decoding_Error(name());
83 return (size-position);
84 }
Botan::ANSI_X923_Padding::name
std::string name() const
Definition: mode_pad.h:90

bool Botan::ANSI_X923_Padding::valid_blocksize | ( | size_t | block_size | ) | const
| virtual

Parameters

  block_size | of the cipher

Returns
  valid block size for this padding mode

Implements Botan::BlockCipherModePaddingMethod.

Definition at line 89 of file mode_pad.cpp.

90 {
91 if(size > 0 && size < 256)
92 return true;
93 else
94 return false;
95 }

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

- src/filters/modes/mode_pad/mode_pad.h
- src/filters/modes/mode_pad/mode_pad.cpp