aboutsummaryrefslogtreecommitdiffstats
path: root/src/passhash
diff options
context:
space:
mode:
authorlloyd <[email protected]>2011-06-13 17:06:08 +0000
committerlloyd <[email protected]>2011-06-13 17:06:08 +0000
commit5fcdf6953ed820a446862702311221c10ae0b91d (patch)
tree10354a54bb8ef5c8f9c6cdd9fa0142ab0037c635 /src/passhash
parentb145e593616e83a4c124bba70d451ef0f03c5f3f (diff)
parent1a28f7ef6064041955e7a662c5e087bbea03b6ad (diff)
propagate from branch 'net.randombit.botan' (head 150bd11dd8090559ee1e83394b8283bf93a018de)
to branch 'net.randombit.botan.c++0x' (head 7480693bb3f1e8a4e039a3e7ba3d9a7007f9730e)
Diffstat (limited to 'src/passhash')
-rw-r--r--src/passhash/bcrypt/bcrypt.cpp9
-rw-r--r--src/passhash/passhash9/passhash9.cpp3
2 files changed, 9 insertions, 3 deletions
diff --git a/src/passhash/bcrypt/bcrypt.cpp b/src/passhash/bcrypt/bcrypt.cpp
index bb2e9095a..b0d654717 100644
--- a/src/passhash/bcrypt/bcrypt.cpp
+++ b/src/passhash/bcrypt/bcrypt.cpp
@@ -112,8 +112,13 @@ std::string make_bcrypt(const std::string& pass,
std::string salt_b64 = bcrypt_base64_encode(&salt[0], salt.size());
- return "$2a$" + to_string(work_factor, 2) + "$" + salt_b64.substr(0, 22) +
- bcrypt_base64_encode(&ctext[0], ctext.size() - 1);
+ std::string work_factor_str = std::to_string(work_factor);
+ if(work_factor_str.length() == 1)
+ work_factor_str = "0" + work_factor_str;
+
+ return "$2a$" + work_factor_str +
+ "$" + salt_b64.substr(0, 22) +
+ bcrypt_base64_encode(&ctext[0], ctext.size() - 1);
}
}
diff --git a/src/passhash/passhash9/passhash9.cpp b/src/passhash/passhash9/passhash9.cpp
index e1e37da1e..43bfdd36e 100644
--- a/src/passhash/passhash9/passhash9.cpp
+++ b/src/passhash/passhash9/passhash9.cpp
@@ -53,7 +53,8 @@ std::string generate_passhash9(const std::string& pass,
MessageAuthenticationCode* prf = get_pbkdf_prf(alg_id);
if(!prf)
- throw Invalid_Argument("Passhash9: Algorithm id " + to_string(alg_id) +
+ throw Invalid_Argument("Passhash9: Algorithm id " +
+ std::to_string(alg_id) +
" is not defined");
PKCS5_PBKDF2 kdf(prf); // takes ownership of pointer