8 #include <botan/pbes1.h>     9 #include <botan/pbkdf1.h>    10 #include <botan/der_enc.h>    11 #include <botan/ber_dec.h>    12 #include <botan/cbc.h>    22    pipe.
write(input, length);
    58 void PBE_PKCS5v15::flush_pipe(
bool safe_to_skip)
    66       size_t got = pipe.
read(&buffer[0], buffer.
size());
    74 void PBE_PKCS5v15::set_key(
const std::string& passphrase)
    79                                                     &salt[0], salt.
size(),
    80                                                     iterations).bits_of();
    84    copy_mem(&key[0], &key_and_iv[0], 8);
   113 void PBE_PKCS5v15::decode_params(
DataSource& source)
   129 OID PBE_PKCS5v15::get_oid()
 const   131    const OID base_pbes1_oid(
"1.2.840.113549.1.5");
   133    const std::string cipher = block_cipher->
name();
   134    const std::string digest = hash_function->
name();
   136    if(cipher == 
"DES" && digest == 
"MD2")
   137       return (base_pbes1_oid + 1);
   138    else if(cipher == 
"DES" && digest == 
"MD5")
   139       return (base_pbes1_oid + 3);
   140    else if(cipher == 
"DES" && digest == 
"SHA-160")
   141       return (base_pbes1_oid + 10);
   142    else if(cipher == 
"RC2" && digest == 
"MD2")
   143       return (base_pbes1_oid + 4);
   144    else if(cipher == 
"RC2" && digest == 
"MD5")
   145       return (base_pbes1_oid + 6);
   146    else if(cipher == 
"RC2" && digest == 
"SHA-160")
   147       return (base_pbes1_oid + 11);
   149       throw Internal_Error(
"PBE-PKCS5 v1.5: get_oid() has run out of options");
   154    return "PBE-PKCS5v15(" + block_cipher->
name() + 
"," +
   155                             hash_function->
name() + 
")";
   164    direction(dir), block_cipher(cipher), hash_function(hash), iterations(0)
   166    if(cipher->
name() != 
"DES" && cipher->
name() != 
"RC2")
   172    if(hash->
name() != 
"MD2" && hash->
name() != 
"MD5" &&
   173       hash->
name() != 
"SHA-160")
   183    delete hash_function;
 
size_t remaining(message_id msg=DEFAULT_MESSAGE) const
SecureVector< byte > get_contents()
void append(Filter *filt)
size_t default_msg() const
size_t read(byte output[], size_t length)
SecureVector< byte > random_vec(size_t bytes)
void write(const byte in[], size_t length)
BER_Decoder & decode(bool &)
virtual BlockCipher * clone() const =0
std::invalid_argument Invalid_Argument
BER_Decoder start_cons(ASN1_Tag, ASN1_Tag=UNIVERSAL)
virtual HashFunction * clone() const =0
DER_Encoder & encode(bool b)
void send(const byte in[], size_t length)
void copy_mem(T *out, const T *in, size_t n)
void write(const byte[], size_t)
virtual std::string name() const =0
message_id message_count() const
PBE_PKCS5v15(BlockCipher *cipher, HashFunction *hash, Cipher_Dir direction)
BER_Decoder & verify_end()
DER_Encoder & start_cons(ASN1_Tag type_tag, ASN1_Tag class_tag=UNIVERSAL)
void set_default_msg(message_id msg)