diff options
author | lloyd <[email protected]> | 2008-10-26 02:26:59 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-10-26 02:26:59 +0000 |
commit | 7c4f004b837ca96894db839c3f04f8f1238947e7 (patch) | |
tree | b112578b686eea603152dc4eb507ef4a0f38037c /src/core | |
parent | dea1aa500fd7da2968448677fd628e8a4dddb6fb (diff) |
Move s2k.{h,cpp} and S2K algos from core and kdf to new s2k/ dir
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/info.txt | 2 | ||||
-rw-r--r-- | src/core/s2k.cpp | 53 | ||||
-rw-r--r-- | src/core/s2k.h | 97 |
3 files changed, 0 insertions, 152 deletions
diff --git a/src/core/info.txt b/src/core/info.txt index 82376a8b8..6e674fce5 100644 --- a/src/core/info.txt +++ b/src/core/info.txt @@ -34,8 +34,6 @@ mem_pool.h mutex.h rng.cpp rng.h -s2k.cpp -s2k.h secmem.h symkey.cpp symkey.h diff --git a/src/core/s2k.cpp b/src/core/s2k.cpp deleted file mode 100644 index 9c67aef10..000000000 --- a/src/core/s2k.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/************************************************* -* S2K Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ - -#include <botan/s2k.h> - -namespace Botan { - -/************************************************* -* Derive a key from a passphrase * -*************************************************/ -OctetString S2K::derive_key(u32bit key_len, - const std::string& passphrase) const - { - return derive(key_len, passphrase, salt, salt.size(), iterations()); - } - -/************************************************* -* Set the number of iterations * -*************************************************/ -void S2K::set_iterations(u32bit i) - { - iter = i; - } - -/************************************************* -* Change the salt * -*************************************************/ -void S2K::change_salt(const byte new_salt[], u32bit length) - { - salt.set(new_salt, length); - } - -/************************************************* -* Change the salt * -*************************************************/ -void S2K::change_salt(const MemoryRegion<byte>& new_salt) - { - change_salt(new_salt.begin(), new_salt.size()); - } - -/************************************************* -* Create a new random salt * -*************************************************/ -void S2K::new_random_salt(RandomNumberGenerator& rng, - u32bit length) - { - salt.create(length); - rng.randomize(salt, length); - } - -} diff --git a/src/core/s2k.h b/src/core/s2k.h deleted file mode 100644 index 3efcff638..000000000 --- a/src/core/s2k.h +++ /dev/null @@ -1,97 +0,0 @@ -/************************************************* -* S2K Header File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ - -#ifndef BOTAN_S2K_H__ -#define BOTAN_S2K_H__ - -#include <botan/symkey.h> -#include <botan/rng.h> - -namespace Botan { - -/************************************************* -* S2K Interface * -*************************************************/ -class BOTAN_DLL S2K - { - public: - /** - * Create a copy of this object. - * @return an auto_ptr to a copy of this object - */ - virtual S2K* clone() const = 0; - - /** - * Get the algorithm name. - * @return the name of this S2K algorithm - */ - virtual std::string name() const = 0; - - /** - * Clear this objects internal values. - */ - virtual void clear() {} - - /** - * Derive a key from a passphrase with this S2K object. It will use - * the salt value and number of iterations configured in this object. - * @param key_len the desired length of the key to produce - * @param passphrase the password to derive the key from - */ - OctetString derive_key(u32bit key_len, - const std::string& passphrase) const; - - /** - * Set the number of iterations for the one-way function during - * key generation. - * @param n the desired number of iterations - */ - void set_iterations(u32bit n); - - /** - * Set a new salt value. - * @param new_salt a byte array defining the new salt value - * @param len the length of the above byte array - */ - void change_salt(const byte new_salt[], u32bit len); - - /** - * Set a new salt value. - * @param new_salt the new salt value - */ - void change_salt(const MemoryRegion<byte>& new_salt); - - /** - * Create a new random salt value using the rng - * @param rng the random number generator to use - * @param len the desired length of the new salt value - */ - void new_random_salt(RandomNumberGenerator& rng, u32bit len); - - /** - * Get the number of iterations for the key derivation currently - * configured in this S2K object. - * @return the current number of iterations - */ - u32bit iterations() const { return iter; } - - /** - * Get the currently configured salt value of this S2K object. - * @return the current salt value - */ - SecureVector<byte> current_salt() const { return salt; } - - S2K() { iter = 0; } - virtual ~S2K() {} - private: - virtual OctetString derive(u32bit, const std::string&, - const byte[], u32bit, u32bit) const = 0; - SecureVector<byte> salt; - u32bit iter; - }; - -} - -#endif |