8 #include <botan/pbes2.h>     9 #include <botan/pbkdf2.h>    10 #include <botan/hmac.h>    11 #include <botan/cbc.h>    12 #include <botan/algo_factory.h>    13 #include <botan/libstate.h>    14 #include <botan/der_enc.h>    15 #include <botan/ber_dec.h>    16 #include <botan/parsing.h>    17 #include <botan/asn1_obj.h>    18 #include <botan/oids.h>    29    pipe.
write(input, length);
    65 void PBE_PKCS5v20::flush_pipe(
bool safe_to_skip)
    73       size_t got = pipe.
read(&buffer[0], buffer.
size());
    81 void PBE_PKCS5v20::set_key(
const std::string& passphrase)
    86                           &salt[0], salt.
size(),
    87                           iterations).bits_of();
   134 void PBE_PKCS5v20::decode_params(
DataSource& source)
   162    std::vector<std::string> cipher_spec = 
split_on(cipher, 
'/');
   163    if(cipher_spec.size() != 2)
   164       throw Decoding_Error(
"PBE-PKCS5 v2.0: Invalid cipher spec " + cipher);
   166    if(!
known_cipher(cipher_spec[0]) || cipher_spec[1] != 
"CBC")
   167       throw Decoding_Error(
"PBE-PKCS5 v2.0: Don't know param format for " +
   172    block_cipher = af.make_block_cipher(cipher_spec[0]);
   173    hash_function = af.make_hash_function(
"SHA-160");
   179       throw Decoding_Error(
"PBE-PKCS5 v2.0: Encoded salt is too small");
   185 OID PBE_PKCS5v20::get_oid()
 const   195    if(algo == 
"AES-128" || algo == 
"AES-192" || algo == 
"AES-256")
   197    if(algo == 
"DES" || algo == 
"TripleDES")
   204    return "PBE-PKCS5v20(" + block_cipher->
name() + 
"," +
   205                             hash_function->
name() + 
")";
   214    block_cipher(cipher),
   215    hash_function(digest),
   221    if(hash_function->
name() != 
"SHA-160")
   232    decode_params(params);
   237    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)
Algorithm_Factory & algorithm_factory() const
void write(const byte in[], size_t length)
BER_Decoder & decode(bool &)
std::string as_string() const
virtual BlockCipher * clone() const =0
std::vector< std::string > split_on(const std::string &str, char delim)
std::invalid_argument Invalid_Argument
SecureVector< byte > parameters
BER_Decoder start_cons(ASN1_Tag, ASN1_Tag=UNIVERSAL)
virtual HashFunction * clone() const =0
size_t maximum_keylength() const
DER_Encoder & encode(bool b)
void send(const byte in[], size_t length)
BER_Decoder & decode_optional(T &out, ASN1_Tag type_tag, ASN1_Tag class_tag, const T &default_value=T())
Library_State & global_state()
std::string lookup(const OID &oid)
virtual std::string name() const =0
message_id message_count() const
std::string encode(const byte der[], size_t length, const std::string &label, size_t width)
static bool known_cipher(const std::string &cipher)
BER_Decoder & verify_end()
DER_Encoder & start_cons(ASN1_Tag type_tag, ASN1_Tag class_tag=UNIVERSAL)
void set_default_msg(message_id msg)
OctetString derive_key(size_t output_len, const std::string &passphrase, const byte salt[], size_t salt_len, size_t iterations) const
PBE_PKCS5v20(DataSource &input)
virtual size_t block_size() const =0
void write(const byte[], size_t)