aboutsummaryrefslogtreecommitdiffstats
path: root/src/block/blowfish
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-06-13 17:57:42 +0000
committerlloyd <[email protected]>2012-06-13 17:57:42 +0000
commit9644a3ecebb15d8241e65dcae63bd6d0382a95a6 (patch)
treecc633b1d14b103a879bf25d6662dc4dab4574d32 /src/block/blowfish
parent140a52d5857811f274363ee8c1a983374802db14 (diff)
Truncate passwords to 55 characters instead of throwing an exception.
This matches the behavior of other bcrypt implementations.
Diffstat (limited to 'src/block/blowfish')
-rw-r--r--src/block/blowfish/blowfish.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/block/blowfish/blowfish.cpp b/src/block/blowfish/blowfish.cpp
index c224f479b..5e882b16a 100644
--- a/src/block/blowfish/blowfish.cpp
+++ b/src/block/blowfish/blowfish.cpp
@@ -115,8 +115,8 @@ void Blowfish::key_expansion(const byte key[],
void Blowfish::eks_key_schedule(const byte key[], size_t length,
const byte salt[16], size_t workfactor)
{
- if(length == 0 || length >= 56)
- throw Invalid_Key_Length("EKSBlowfish", length);
+ // Truncate longer passwords to the 56 byte limit Blowfish enforces
+ length = std::min<size_t>(length, 55);
if(workfactor == 0)
throw std::invalid_argument("Bcrypt work factor must be at least 1");