aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/passhash/bcrypt
diff options
context:
space:
mode:
authorlloyd <[email protected]>2015-02-18 04:21:21 +0000
committerlloyd <[email protected]>2015-02-18 04:21:21 +0000
commit88285f51ba4fd5bc1a1cc06b0760b3926046f29b (patch)
tree7443b2b266b8445433b9c63704b7a09e216282f2 /src/lib/passhash/bcrypt
parentaced9e88d970546c6324e768ce11b0a483bd3bd0 (diff)
Modify interfaces of KDF and PBKDF to write output to an array, with
higher level functions on interface handling returning a vector.
Diffstat (limited to 'src/lib/passhash/bcrypt')
-rw-r--r--src/lib/passhash/bcrypt/bcrypt.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lib/passhash/bcrypt/bcrypt.cpp b/src/lib/passhash/bcrypt/bcrypt.cpp
index 6766dc0d1..218404110 100644
--- a/src/lib/passhash/bcrypt/bcrypt.cpp
+++ b/src/lib/passhash/bcrypt/bcrypt.cpp
@@ -140,11 +140,13 @@ bool check_bcrypt(const std::string& pass, const std::string& hash)
const u16bit workfactor = to_u32bit(hash.substr(4, 2));
- std::vector<byte> salt = bcrypt_base64_decode(hash.substr(7, 22));
+ const std::vector<byte> salt = bcrypt_base64_decode(hash.substr(7, 22));
+ if(salt.size() != 16)
+ return false;
const std::string compare = make_bcrypt(pass, salt, workfactor);
- return (hash == compare);
+ return same_mem(hash.data(), compare.data(), compare.size());
}
}