Botan 1.10.17
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 (byte in)
void send (const byte in[], size_t length)
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
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.

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

References Botan::Algorithm::name().

Referenced by Botan::get_pbe(), and Botan::get_pbe().

◆ ~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 ( )
inlinevirtualinherited

Check whether this filter is an attachable filter.

Returns
true if this filter is attachable, false otherwise

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

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.

49 {
50 pipe.end_msg();
51 flush_pipe(false);
52 pipe.reset();
53 }

◆ 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.

153 {
154 return "PBE-PKCS5v15(" + block_cipher->name() + "," +
155 hash_function->name() + ")";
156 }

◆ send() [1/4]

void Botan::Filter::send ( byte in)
inlineprotectedinherited
Parameters
insome input for the filter

Definition at line 63 of file filter.h.

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

References send().

Referenced by send().

◆ send() [2/4]

void Botan::Filter::send ( const byte in[],
size_t length )
protectedinherited

◆ send() [3/4]

void Botan::Filter::send ( const MemoryRegion< byte > & in)
inlineprotectedinherited
Parameters
insome input for the filter

Definition at line 68 of file filter.h.

68{ send(&in[0], in.size()); }

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

Referenced by send().

◆ send() [4/4]

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 }

References send().

◆ 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.

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 }
CBC_Decryption(BlockCipher *cipher, BlockCipherModePaddingMethod *padding)
Definition cbc.cpp:115
CBC_Encryption(BlockCipher *cipher, BlockCipherModePaddingMethod *padding)
Definition cbc.cpp:17
@ ENCRYPTION
Definition sym_algo.h:87

References Botan::CBC_Decryption::CBC_Decryption(), Botan::CBC_Encryption::CBC_Encryption(), and Botan::ENCRYPTION.

◆ write()

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.

21 {
22 pipe.write(input, length);
23 flush_pipe(true);
24 }

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