Botan
1.11.15
|
00001 /* 00002 * KDF1 00003 * (C) 1999-2007 Jack Lloyd 00004 * 00005 * Botan is released under the Simplified BSD License (see license.txt) 00006 */ 00007 00008 #include <botan/internal/kdf_utils.h> 00009 #include <botan/kdf1.h> 00010 00011 namespace Botan { 00012 00013 BOTAN_REGISTER_KDF_1HASH(KDF1, "KDF1"); 00014 00015 size_t KDF1::kdf(byte key[], size_t key_len, 00016 const byte secret[], size_t secret_len, 00017 const byte salt[], size_t salt_len) const 00018 { 00019 m_hash->update(secret, secret_len); 00020 m_hash->update(salt, salt_len); 00021 00022 if(key_len < m_hash->output_length()) 00023 { 00024 secure_vector<byte> v = m_hash->final(); 00025 copy_mem(key, &v[0], key_len); 00026 return key_len; 00027 } 00028 00029 m_hash->final(key); 00030 return m_hash->output_length(); 00031 } 00032 00033 }