Merge branch 'master' of github.com:Lyndir/MasterPassword
This commit is contained in:
commit
6f741f6f2f
@ -85,8 +85,7 @@ depend() {
|
|||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Checking dependency $1..."
|
echo "Checking dependency $1..."
|
||||||
objects=( "lib/$1"/*.o )
|
[[ -e "lib/$1/.built" ]] && return
|
||||||
[[ -e $objects ]] && return
|
|
||||||
|
|
||||||
pushd "lib/$1"
|
pushd "lib/$1"
|
||||||
files=( * )
|
files=( * )
|
||||||
@ -113,6 +112,7 @@ depend() {
|
|||||||
echo "Building dependency $1..."
|
echo "Building dependency $1..."
|
||||||
if [[ -e Makefile ]]; then
|
if [[ -e Makefile ]]; then
|
||||||
make
|
make
|
||||||
|
date > .built
|
||||||
else
|
else
|
||||||
echo >&2 "error: Don't know how to build: $1"
|
echo >&2 "error: Don't know how to build: $1"
|
||||||
exit 1
|
exit 1
|
||||||
@ -125,6 +125,7 @@ depend() {
|
|||||||
mpw() {
|
mpw() {
|
||||||
depend scrypt
|
depend scrypt
|
||||||
|
|
||||||
|
echo
|
||||||
echo "Building target: $target..."
|
echo "Building target: $target..."
|
||||||
CFLAGS=(
|
CFLAGS=(
|
||||||
# include paths
|
# include paths
|
||||||
@ -155,6 +156,7 @@ mpw-bench() {
|
|||||||
depend scrypt
|
depend scrypt
|
||||||
depend bcrypt
|
depend bcrypt
|
||||||
|
|
||||||
|
echo
|
||||||
echo "Building target: $target..."
|
echo "Building target: $target..."
|
||||||
CFLAGS=(
|
CFLAGS=(
|
||||||
# include paths
|
# include paths
|
||||||
@ -198,6 +200,5 @@ cc() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for target in "${targets[@]}"; do
|
for target in "${targets[@]}"; do
|
||||||
echo
|
|
||||||
"$target" "$@"
|
"$target" "$@"
|
||||||
done
|
done
|
||||||
|
@ -110,7 +110,8 @@ int main(int argc, char *const argv[]) {
|
|||||||
}
|
}
|
||||||
memset(sitePasswordSeed, 0, sizeof(sitePasswordSeed));
|
memset(sitePasswordSeed, 0, sizeof(sitePasswordSeed));
|
||||||
|
|
||||||
fprintf( stderr, "\riteration %d / %d..", i, iterations );
|
if (i % 1 == 0)
|
||||||
|
fprintf( stderr, "\rmpw: iteration %d / %d..", i, iterations );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output timing results.
|
// Output timing results.
|
||||||
@ -122,7 +123,8 @@ int main(int argc, char *const argv[]) {
|
|||||||
long long secs = (endTime.tv_sec - startTime.tv_sec);
|
long long secs = (endTime.tv_sec - startTime.tv_sec);
|
||||||
long long usecs = (endTime.tv_usec - startTime.tv_usec);
|
long long usecs = (endTime.tv_usec - startTime.tv_usec);
|
||||||
double elapsed = secs + usecs / 1000000.0;
|
double elapsed = secs + usecs / 1000000.0;
|
||||||
fprintf( stdout, "Master Password: %d iterations in %llds %lldµs -> %.2f/s\n", iterations, secs, usecs, iterations / elapsed );
|
double mpwSpeed = iterations / elapsed;
|
||||||
|
fprintf( stdout, " done. %d iterations in %llds %lldµs -> %.2f/s\n", iterations, secs, usecs, mpwSpeed );
|
||||||
|
|
||||||
// Start SHA-256
|
// Start SHA-256
|
||||||
if (gettimeofday(&startTime, NULL) != 0) {
|
if (gettimeofday(&startTime, NULL) != 0) {
|
||||||
@ -132,9 +134,13 @@ int main(int argc, char *const argv[]) {
|
|||||||
|
|
||||||
iterations = 50000000;
|
iterations = 50000000;
|
||||||
uint8_t hash[32];
|
uint8_t hash[32];
|
||||||
for (int i = 0; i < iterations; ++i)
|
for (int i = 0; i < iterations; ++i) {
|
||||||
SHA256_Buf(masterPassword, strlen(masterPassword), hash);
|
SHA256_Buf(masterPassword, strlen(masterPassword), hash);
|
||||||
|
|
||||||
|
if (i % 1000 == 0)
|
||||||
|
fprintf( stderr, "\rsha256: iteration %d / %d..", i, iterations );
|
||||||
|
}
|
||||||
|
|
||||||
// Output timing results.
|
// Output timing results.
|
||||||
if (gettimeofday(&endTime, NULL) != 0) {
|
if (gettimeofday(&endTime, NULL) != 0) {
|
||||||
fprintf(stderr, "Could not get time: %d\n", errno);
|
fprintf(stderr, "Could not get time: %d\n", errno);
|
||||||
@ -143,7 +149,8 @@ int main(int argc, char *const argv[]) {
|
|||||||
secs = (endTime.tv_sec - startTime.tv_sec);
|
secs = (endTime.tv_sec - startTime.tv_sec);
|
||||||
usecs = (endTime.tv_usec - startTime.tv_usec);
|
usecs = (endTime.tv_usec - startTime.tv_usec);
|
||||||
elapsed = secs + usecs / 1000000.0;
|
elapsed = secs + usecs / 1000000.0;
|
||||||
fprintf( stdout, "SHA-256: %d iterations in %llds %lldµs -> %.2f/s\n", iterations, secs, usecs, iterations / elapsed );
|
double sha256Speed = iterations / elapsed;
|
||||||
|
fprintf( stdout, " done. %d iterations in %llds %lldµs -> %.2f/s\n", iterations, secs, usecs, sha256Speed );
|
||||||
|
|
||||||
// Start BCrypt
|
// Start BCrypt
|
||||||
if (gettimeofday(&startTime, NULL) != 0) {
|
if (gettimeofday(&startTime, NULL) != 0) {
|
||||||
@ -153,9 +160,13 @@ int main(int argc, char *const argv[]) {
|
|||||||
|
|
||||||
int bcrypt_cost = 9;
|
int bcrypt_cost = 9;
|
||||||
iterations = 600;
|
iterations = 600;
|
||||||
for (int i = 0; i < iterations; ++i)
|
for (int i = 0; i < iterations; ++i) {
|
||||||
crypt(masterPassword, crypt_gensalt("$2b$", bcrypt_cost, userName, strlen(userName)));
|
crypt(masterPassword, crypt_gensalt("$2b$", bcrypt_cost, userName, strlen(userName)));
|
||||||
|
|
||||||
|
if (i % 10 == 0)
|
||||||
|
fprintf( stderr, "\rbcrypt (cost %d): iteration %d / %d..", bcrypt_cost, i, iterations );
|
||||||
|
}
|
||||||
|
|
||||||
// Output timing results.
|
// Output timing results.
|
||||||
if (gettimeofday(&endTime, NULL) != 0) {
|
if (gettimeofday(&endTime, NULL) != 0) {
|
||||||
fprintf(stderr, "Could not get time: %d\n", errno);
|
fprintf(stderr, "Could not get time: %d\n", errno);
|
||||||
@ -164,7 +175,13 @@ int main(int argc, char *const argv[]) {
|
|||||||
secs = (endTime.tv_sec - startTime.tv_sec);
|
secs = (endTime.tv_sec - startTime.tv_sec);
|
||||||
usecs = (endTime.tv_usec - startTime.tv_usec);
|
usecs = (endTime.tv_usec - startTime.tv_usec);
|
||||||
elapsed = secs + usecs / 1000000.0;
|
elapsed = secs + usecs / 1000000.0;
|
||||||
fprintf( stdout, "BCrypt (cost %d): %d iterations in %llds %lldµs -> %.2f/s\n", bcrypt_cost, iterations, secs, usecs, iterations / elapsed );
|
double bcrypt9Speed = iterations / elapsed;
|
||||||
|
fprintf( stdout, " done. %d iterations in %llds %lldµs -> %.2f/s\n", iterations, secs, usecs, bcrypt9Speed );
|
||||||
|
|
||||||
|
// Summarize.
|
||||||
|
fprintf( stdout, "\n== SUMMARY ==\nOn this machine,\n" );
|
||||||
|
fprintf( stdout, "mpw is %f times slower than sha256\n", sha256Speed / mpwSpeed );
|
||||||
|
fprintf( stdout, "mpw is %f times slower than bcrypt (cost 9)\n", bcrypt9Speed / mpwSpeed );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user