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

#include <pbes1.h>

Inheritance diagram for Botan::PBE_PKCS5v15:
Botan::PBE Botan::Filter

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

Botan::PBE_PKCS5v15::PBE_PKCS5v15 ( BlockCipher cipher,
HashFunction hash,
Cipher_Dir  direction 
)
Parameters
cipherthe block cipher to use (DES or RC2)
hashthe hash function to use
directionare 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  }
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
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

virtual bool Botan::Filter::attachable ( )
inlinevirtualinherited

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; }
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  }
void reset()
Definition: pipe.cpp:76
void end_msg()
Definition: pipe.cpp:166
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  }
virtual std::string name() const =0
void Botan::Filter::send ( const byte  in[],
size_t  length 
)
protectedinherited
Parameters
insome input for the filter
lengththe 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  }
virtual void write(const byte input[], size_t length)=0
size_t size() const
Definition: secmem.h:29
void Botan::Filter::send ( byte  in)
inlineprotectedinherited
Parameters
insome 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); }
void send(const byte in[], size_t length)
Definition: filter.cpp:28
void Botan::Filter::send ( const MemoryRegion< byte > &  in)
inlineprotectedinherited
Parameters
insome 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()); }
void send(const byte in[], size_t length)
Definition: filter.cpp:28
size_t size() const
Definition: secmem.h:29
void Botan::Filter::send ( const MemoryRegion< byte > &  in,
size_t  length 
)
inlineprotectedinherited
Parameters
insome input for the filter
lengththe number of bytes of in to send

Definition at line 74 of file filter.h.

75  {
76  send(&in[0], length);
77  }
void send(const byte in[], size_t length)
Definition: filter.cpp:28
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  }
void start_msg()
Definition: pipe.cpp:152
void append(Filter *filt)
Definition: pipe.cpp:215
virtual BlockCipher * clone() const =0
size_t default_msg() const
Definition: pipe.h:206
void set_default_msg(message_id msg)
Definition: pipe.cpp:106
message_id message_count() const
Definition: pipe.cpp:282
void Botan::PBE_PKCS5v15::write ( const byte  input[],
size_t  length 
)
virtual

Write a portion of a message to this filter.

Parameters
inputthe input as a byte array
lengththe 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  }
void write(const byte in[], size_t length)
Definition: pipe_rw.cpp:34

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