Botan  1.11.15
src/lib/pbkdf/pbkdf1/pbkdf1.h
Go to the documentation of this file.
00001 /*
00002 * PBKDF1
00003 * (C) 1999-2007 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #ifndef BOTAN_PBKDF1_H__
00009 #define BOTAN_PBKDF1_H__
00010 
00011 #include <botan/pbkdf.h>
00012 #include <botan/hash.h>
00013 
00014 namespace Botan {
00015 
00016 /**
00017 * PKCS #5 v1 PBKDF, aka PBKDF1
00018 * Can only generate a key up to the size of the hash output.
00019 * Unless needed for backwards compatability, use PKCS5_PBKDF2
00020 */
00021 class BOTAN_DLL PKCS5_PBKDF1 : public PBKDF
00022    {
00023    public:
00024       /**
00025       * Create a PKCS #5 instance using the specified hash function.
00026       * @param hash pointer to a hash function object to use
00027       */
00028       PKCS5_PBKDF1(HashFunction* hash) : m_hash(hash) {}
00029 
00030       std::string name() const
00031          {
00032          return "PBKDF1(" + m_hash->name() + ")";
00033          }
00034 
00035       PBKDF* clone() const
00036          {
00037          return new PKCS5_PBKDF1(m_hash->clone());
00038          }
00039 
00040       size_t pbkdf(byte output_buf[], size_t output_len,
00041                            const std::string& passphrase,
00042                            const byte salt[], size_t salt_len,
00043                            size_t iterations,
00044                            std::chrono::milliseconds msec) const override;
00045    private:
00046       std::unique_ptr<HashFunction> m_hash;
00047    };
00048 
00049 }
00050 
00051 #endif