aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/passhash
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-09-21 14:59:01 -0400
committerJack Lloyd <[email protected]>2015-09-21 14:59:01 -0400
commit04319af23bf8ed467b17f9b74c814343e051ab6b (patch)
tree630d1a0cc931e77e7e1f07319e5cf89d00af4458 /src/lib/passhash
parent408ea0a9b8ed0f575f8ee26891473920b42ef026 (diff)
Remove use of lookup.h in favor of new T::create API.
Diffstat (limited to 'src/lib/passhash')
-rw-r--r--src/lib/passhash/passhash9/passhash9.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/lib/passhash/passhash9/passhash9.cpp b/src/lib/passhash/passhash9/passhash9.cpp
index f30684ec6..b457fc5c7 100644
--- a/src/lib/passhash/passhash9/passhash9.cpp
+++ b/src/lib/passhash/passhash9/passhash9.cpp
@@ -7,7 +7,6 @@
#include <botan/passhash9.h>
#include <botan/loadstor.h>
-#include <botan/lookup.h>
#include <botan/pbkdf2.h>
#include <botan/base64.h>
@@ -24,18 +23,18 @@ const size_t PASSHASH9_PBKDF_OUTPUT_LEN = 24; // 192 bits output
const size_t WORK_FACTOR_SCALE = 10000;
-MessageAuthenticationCode* get_pbkdf_prf(byte alg_id)
+std::unique_ptr<MessageAuthenticationCode> get_pbkdf_prf(byte alg_id)
{
if(alg_id == 0)
- return get_mac("HMAC(SHA-1)");
+ return MessageAuthenticationCode::create("HMAC(SHA-1)");
else if(alg_id == 1)
- return get_mac("HMAC(SHA-256)");
+ return MessageAuthenticationCode::create("HMAC(SHA-256)");
else if(alg_id == 2)
- return get_mac("CMAC(Blowfish)");
+ return MessageAuthenticationCode::create("CMAC(Blowfish)");
else if(alg_id == 3)
- return get_mac("HMAC(SHA-384)");
+ return MessageAuthenticationCode::create("HMAC(SHA-384)");
else if(alg_id == 4)
- return get_mac("HMAC(SHA-512)");
+ return MessageAuthenticationCode::create("HMAC(SHA-512)");
return nullptr;
}
@@ -46,14 +45,14 @@ std::string generate_passhash9(const std::string& pass,
u16bit work_factor,
byte alg_id)
{
- MessageAuthenticationCode* prf = get_pbkdf_prf(alg_id);
+ std::unique_ptr<MessageAuthenticationCode> prf = get_pbkdf_prf(alg_id);
if(!prf)
throw Invalid_Argument("Passhash9: Algorithm id " +
std::to_string(alg_id) +
" is not defined");
- PKCS5_PBKDF2 kdf(prf); // takes ownership of pointer
+ PKCS5_PBKDF2 kdf(prf.release()); // takes ownership of pointer
secure_vector<byte> salt(SALT_BYTES);
rng.randomize(salt.data(), salt.size());
@@ -110,12 +109,12 @@ bool check_passhash9(const std::string& pass, const std::string& hash)
const size_t kdf_iterations = WORK_FACTOR_SCALE * work_factor;
- MessageAuthenticationCode* pbkdf_prf = get_pbkdf_prf(alg_id);
+ std::unique_ptr<MessageAuthenticationCode> pbkdf_prf = get_pbkdf_prf(alg_id);
if(!pbkdf_prf)
return false; // unknown algorithm, reject
- PKCS5_PBKDF2 kdf(pbkdf_prf); // takes ownership of pointer
+ PKCS5_PBKDF2 kdf(pbkdf_prf.release()); // takes ownership of pointer
secure_vector<byte> cmp = kdf.derive_key(
PASSHASH9_PBKDF_OUTPUT_LEN,