aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2011-02-17 19:41:49 +0000
committerlloyd <[email protected]>2011-02-17 19:41:49 +0000
commit20b9d66dc60595e685d99f59a7ef306074d8e0b1 (patch)
treed3f743ce470368cf6764c126021c5aa726267504
parent88a892707f05625cbcf0c8cc4b3e0ed7852967b5 (diff)
Move password hashing schemes to src/passhash
Set the upper limit on bcrypt hashing to workfactor 18, which takes about 25 seconds to run on my desktop machine.
-rw-r--r--src/block/blowfish/blowfish.cpp7
-rw-r--r--src/passhash/bcrypt/bcrypt.cpp (renamed from src/constructs/bcrypt/bcrypt.cpp)2
-rw-r--r--src/passhash/bcrypt/bcrypt.h (renamed from src/constructs/bcrypt/bcrypt.h)0
-rw-r--r--src/passhash/bcrypt/info.txt (renamed from src/constructs/bcrypt/info.txt)0
-rw-r--r--src/passhash/passhash9/info.txt (renamed from src/constructs/passhash/info.txt)0
-rw-r--r--src/passhash/passhash9/passhash9.cpp (renamed from src/constructs/passhash/passhash9.cpp)0
-rw-r--r--src/passhash/passhash9/passhash9.h (renamed from src/constructs/passhash/passhash9.h)0
7 files changed, 7 insertions, 2 deletions
diff --git a/src/block/blowfish/blowfish.cpp b/src/block/blowfish/blowfish.cpp
index 6610decd8..b6319eec0 100644
--- a/src/block/blowfish/blowfish.cpp
+++ b/src/block/blowfish/blowfish.cpp
@@ -117,7 +117,12 @@ void Blowfish::eks_key_schedule(const byte key[], size_t length,
if(workfactor == 0)
throw std::invalid_argument("Bcrypt work factor must be at least 1");
- if(workfactor > 24) // ok?
+ /*
+ * On a 2.8 GHz Core-i7, workfactor == 18 takes about 25 seconds to
+ * hash a password. This seems like a reasonable upper bound for the
+ * time being.
+ */
+ if(workfactor > 18)
throw std::invalid_argument("Requested Bcrypt work factor too large");
clear();
diff --git a/src/constructs/bcrypt/bcrypt.cpp b/src/passhash/bcrypt/bcrypt.cpp
index b2152a0a7..e533c6081 100644
--- a/src/constructs/bcrypt/bcrypt.cpp
+++ b/src/passhash/bcrypt/bcrypt.cpp
@@ -142,7 +142,7 @@ bool check_bcrypt(const std::string& pass, const std::string& hash)
return false;
}
- const size_t workfactor = to_u32bit(hash.substr(4, 2));
+ const u16bit workfactor = to_u32bit(hash.substr(4, 2));
MemoryVector<byte> salt = bcrypt_base64_decode(hash.substr(7, 22));
diff --git a/src/constructs/bcrypt/bcrypt.h b/src/passhash/bcrypt/bcrypt.h
index 8a6ab58ea..8a6ab58ea 100644
--- a/src/constructs/bcrypt/bcrypt.h
+++ b/src/passhash/bcrypt/bcrypt.h
diff --git a/src/constructs/bcrypt/info.txt b/src/passhash/bcrypt/info.txt
index 91ab92e88..91ab92e88 100644
--- a/src/constructs/bcrypt/info.txt
+++ b/src/passhash/bcrypt/info.txt
diff --git a/src/constructs/passhash/info.txt b/src/passhash/passhash9/info.txt
index f96809f29..f96809f29 100644
--- a/src/constructs/passhash/info.txt
+++ b/src/passhash/passhash9/info.txt
diff --git a/src/constructs/passhash/passhash9.cpp b/src/passhash/passhash9/passhash9.cpp
index e5f379052..e5f379052 100644
--- a/src/constructs/passhash/passhash9.cpp
+++ b/src/passhash/passhash9/passhash9.cpp
diff --git a/src/constructs/passhash/passhash9.h b/src/passhash/passhash9/passhash9.h
index 92cc391dc..92cc391dc 100644
--- a/src/constructs/passhash/passhash9.h
+++ b/src/passhash/passhash9/passhash9.h