Botan 1.10.17

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

`#include <pbes1.h>`

Inheritance diagram for Botan::PBE_PKCS5v15:

## Public Member Functions
virtual bool | attachable ()
void | end_msg ()
std::string | name () const
| PBE_PKCS5v15 (BlockCipher *cipher, HashFunction *hash, Cipher_Dir direction)
void | start_msg ()
void | write (const byte[], size_t)
| ~PBE_PKCS5v15 ()

## Protected Member Functions
void | send (const byte in[], size_t length)
void | send (byte in)
void | send (const MemoryRegion< byte > &in)
void | send (const MemoryRegion< byte > &in, size_t length)

## Detailed Description

PKCS #5 v1.5 PBE

Definition at line 21 of file pbes1.h.

## Constructor & Destructor Documentation

## ◆ PBE_PKCS5v15()

Botan::PBE_PKCS5v15::PBE_PKCS5v15 | ( | BlockCipher * | cipher,
|  | HashFunction * | hash,
|  | Cipher_Dir | direction
| ) |  |

Parameters

  cipher | the block cipher to use (DES or RC2)
  hash | the hash function to use
  direction | are we encrypting or decrypting

Definition at line 161 of file pbes1.cpp.

References Botan::Algorithm::name().

163 :
164 direction(dir), block_cipher(cipher), hash_function(hash), iterations(0)
165 {
166 if(cipher->name() != "DES" && cipher->name() != "RC2")
167 {
168 throw Invalid_Argument("PBE_PKCS5v1.5: Unknown cipher " +
169 cipher->name());
170 }
171
172 if(hash->name() != "MD2" && hash->name() != "MD5" &&
173 hash->name() != "SHA-160")
174 {
175 throw Invalid_Argument("PBE_PKCS5v1.5: Unknown hash " +
176 hash->name());
177 }
178 }
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20

## ◆ ~PBE_PKCS5v15()

Botan::PBE_PKCS5v15::~PBE_PKCS5v15 | ( |  | ) |

Definition at line 180 of file pbes1.cpp.

181 {
182 delete block_cipher;
183 delete hash_function;
184 }

## Member Function Documentation

## ◆ attachable()

virtual bool Botan::Filter::attachable | ( |  | ) |
| inline virtual inherited

Check whether this filter is an attachable filter.

Returns
  true if this filter is attachable, false otherwise

Reimplemented in Botan::SecureQueue, and Botan::DataSink.

Definition at line 50 of file filter.h.

50 { return true; }

## ◆ end_msg()

void Botan::PBE_PKCS5v15::end_msg | ( |  | ) |
| virtual

Notify that the current message is finished; flush buffers and do end-of-message processing (if any).

Reimplemented from Botan::Filter.

Definition at line 48 of file pbes1.cpp.

References Botan::Pipe::end_msg(), and Botan::Pipe::reset().

49 {
50 pipe.end_msg();
51 flush_pipe(false);
52 pipe.reset();
53 }
Botan::Pipe::reset
void reset()
Definition: pipe.cpp:76
Botan::Pipe::end_msg
void end_msg()
Definition: pipe.cpp:166

## ◆ name()

std::string Botan::PBE_PKCS5v15::name | ( |  | ) | const
| virtual

Returns
  descriptive name for this filter

Implements Botan::Filter.

Definition at line 152 of file pbes1.cpp.

References Botan::Algorithm::name().

153 {
154 return "PBE-PKCS5v15(" + block_cipher->name() + "," +
155 hash_function->name() + ")";
156 }
Botan::Algorithm::name
virtual std::string name() const =0

## ◆ send() [1/4]

void Botan::Filter::send | ( | const byte | in[],
|  | size_t | length
| ) |  |
| protected inherited

Parameters

  in | some input for the filter
  length | the length of in

Definition at line 28 of file filter.cpp.

References Botan::MemoryRegion< T >::clear(), Botan::MemoryRegion< T >::size(), and Botan::Filter::write().

Referenced by Botan::PK_Encryptor_Filter::end_msg(), Botan::Zlib_Compression::end_msg(), Botan::Bzip_Compression::end_msg(), Botan::Hex_Encoder::end_msg(), Botan::Base64_Encoder::end_msg(), Botan::PK_Decryptor_Filter::end_msg(), Botan::Bzip_Decompression::end_msg(), Botan::Zlib_Decompression::end_msg(), Botan::PK_Signer_Filter::end_msg(), Botan::Hex_Decoder::end_msg(), Botan::Base64_Decoder::end_msg(), Botan::PK_Verifier_Filter::end_msg(), Botan::Hash_Filter::end_msg(), Botan::MAC_Filter::end_msg(), Botan::Bzip_Compression::flush(), Botan::Zlib_Compression::flush(), Botan::Zlib_Compression::write(), Botan::Bzip_Compression::write(), Botan::StreamCipher_Filter::write(), Botan::Bzip_Decompression::write(), Botan::Zlib_Decompression::write(), Botan::Hex_Decoder::write(), and Botan::Base64_Decoder::write().

29 {
30 bool nothing_attached = true;
31 for(size_t j = 0; j != total_ports(); ++j)
32 if(next[j])
33 {
34 if(write_queue.size())
35 next[j]->write(&write_queue[0], write_queue.size());
36 next[j]->write(input, length);
37 nothing_attached = false;
38 }
39
40 if(nothing_attached)
41 write_queue += std::make_pair(input, length);
42 else
43 write_queue.clear();
44 }
Botan::Filter::write
virtual void write(const byte input[], size_t length)=0
Botan::MemoryRegion::clear
void clear()
Definition: secmem.h:158
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29

## ◆ send() [2/4]

void Botan::Filter::send | ( | byte | in | ) |
| inline protected inherited

Parameters

  in | some input for the filter

Definition at line 63 of file filter.h.

References Botan::Filter::send().

Referenced by Botan::Filter::send().

63 { send(&in, 1); }
Botan::Filter::send
void send(const byte in[], size_t length)
Definition: filter.cpp:28

## ◆ send() [3/4]

void Botan::Filter::send | ( | const MemoryRegion< byte > & | in | ) |
| inline protected inherited

Parameters

  in | some input for the filter

Definition at line 68 of file filter.h.

References Botan::Filter::send(), and Botan::MemoryRegion< T >::size().

Referenced by Botan::Filter::send().

68 { send(&in[0], in.size()); }
Botan::Filter::send
void send(const byte in[], size_t length)
Definition: filter.cpp:28
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29

## ◆ send() [4/4]

void Botan::Filter::send | ( | const MemoryRegion< byte > & | in,
|  | size_t | length
| ) |  |
| inline protected inherited

Parameters

  in | some input for the filter
  length | the number of bytes of in to send

Definition at line 74 of file filter.h.

75 {
76 send(&in[0], length);
77 }
Botan::Filter::send
void send(const byte in[], size_t length)
Definition: filter.cpp:28

## ◆ start_msg()

void Botan::PBE_PKCS5v15::start_msg | ( |  | ) |
| virtual

Start a new message. Must be closed by end_msg() before another message can be started.

Reimplemented from Botan::Filter.

Definition at line 29 of file pbes1.cpp.

References Botan::Pipe::append(), Botan::BlockCipher::clone(), Botan::Pipe::default_msg(), Botan::ENCRYPTION, Botan::Pipe::message_count(), Botan::Pipe::set_default_msg(), and Botan::Pipe::start_msg().

30 {
31 if(direction == ENCRYPTION)
32 pipe.append(new CBC_Encryption(block_cipher->clone(),
33 new PKCS7_Padding,
34 key, iv));
35 else
36 pipe.append(new CBC_Decryption(block_cipher->clone(),
37 new PKCS7_Padding,
38 key, iv));
39
40 pipe.start_msg();
41 if(pipe.message_count() > 1)
42 pipe.set_default_msg(pipe.default_msg() + 1);
43 }
Botan::Pipe::start_msg
void start_msg()
Definition: pipe.cpp:152
Botan::Pipe::append
void append(Filter *filt)
Definition: pipe.cpp:215
Botan::Pipe::default_msg
size_t default_msg() const
Definition: pipe.h:209
Botan::ENCRYPTION
Definition: sym_algo.h:87
Botan::BlockCipher::clone
virtual BlockCipher * clone() const =0
Botan::Pipe::message_count
message_id message_count() const
Definition: pipe.cpp:282
Botan::Pipe::set_default_msg
void set_default_msg(message_id msg)
Definition: pipe.cpp:106

## ◆ write()

void Botan::PBE_PKCS5v15::write | ( | const byte | input[],
|  | size_t | length
| ) |  |
| virtual

Write a portion of a message to this filter.

Parameters

  input | the input as a byte array
  length | the length of the byte array input

Implements Botan::Filter.

Definition at line 20 of file pbes1.cpp.

References Botan::Pipe::write().

21 {
22 pipe.write(input, length);
23 flush_pipe(true);
24 }
Botan::Pipe::write
void write(const byte in[], size_t length)
Definition: pipe_rw.cpp:34

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

- src/pbe/pbes1/pbes1.h
- src/pbe/pbes1/pbes1.cpp