diff --git a/OpenCL/m25850-pure.cl b/OpenCL/m30600-pure.cl similarity index 99% rename from OpenCL/m25850-pure.cl rename to OpenCL/m30600-pure.cl index 3dd845cda..5aebee3d9 100644 --- a/OpenCL/m25850-pure.cl +++ b/OpenCL/m30600-pure.cl @@ -444,7 +444,7 @@ DECLSPEC u32 u16_bin_to_u32_hex (const u32 v) | ((v1 < 10) ? '0' + v1 : 'a' - 10 + v1) << 0; } -KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m25850_init (KERN_ATTR_TMPS (bcrypt_tmp_t)) +KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m30600_init (KERN_ATTR_TMPS (bcrypt_tmp_t)) { /** * base @@ -695,7 +695,7 @@ KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m25850_init (KERN_ATTR_TMPS } } -KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m25850_loop (KERN_ATTR_TMPS (bcrypt_tmp_t)) +KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m30600_loop (KERN_ATTR_TMPS (bcrypt_tmp_t)) { /** * base @@ -898,7 +898,7 @@ KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m25850_loop (KERN_ATTR_TMPS } } -KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m25850_comp (KERN_ATTR_TMPS (bcrypt_tmp_t)) +KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m30600_comp (KERN_ATTR_TMPS (bcrypt_tmp_t)) { /** * base diff --git a/docs/changes.txt b/docs/changes.txt index 15cb31945..ce0e6b551 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -15,8 +15,8 @@ - Added hash-mode: GPG (AES-128/AES-256 (SHA-512($pass))) - Added hash-mode: HMAC-RIPEMD160 (key = $pass) - Added hash-mode: HMAC-RIPEMD160 (key = $salt) -- Added hash-mode: md5(md5($salt).md5(md5($pass))) - Added hash-mode: bcrypt(sha256($pass)) +- Added hash-mode: md5(md5($salt).md5(md5($pass))) ## ## Bugs diff --git a/src/modules/module_25850.c b/src/modules/module_30600.c similarity index 99% rename from src/modules/module_25850.c rename to src/modules/module_30600.c index 4b7a65e1b..5172ffecf 100644 --- a/src/modules/module_25850.c +++ b/src/modules/module_30600.c @@ -18,7 +18,7 @@ static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_4_6; static const u32 HASH_CATEGORY = HASH_CATEGORY_FORUM_SOFTWARE; static const char *HASH_NAME = "bcrypt(sha256($pass)) / bcryptsha256"; -static const u64 KERN_TYPE = 25850; +static const u64 KERN_TYPE = 30600; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE | OPTS_TYPE_PT_GENERATE_LE diff --git a/tools/test_modules/m30600.pm b/tools/test_modules/m30600.pm new file mode 100644 index 000000000..e01d7dc50 --- /dev/null +++ b/tools/test_modules/m30600.pm @@ -0,0 +1,84 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Crypt::Eksblowfish::Bcrypt qw (bcrypt bcrypt_hash en_base64); +use MIME::Base64 qw (decode_base64); +use Digest::SHA qw (sha256_hex); + +sub module_constraints { [[0, 256], [16, 16], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + my $iter = shift; + + my $cost = "10"; + + if (length ($iter)) + { + $cost = $iter; + } + + my $sha256_word = sha256_hex ($word); + + my $attrs = + { + key_nul => 1, + cost => $cost, + salt => $salt, + }; + + my $hash = bcrypt_hash ($attrs, $sha256_word); + + return sprintf ('$2b$%s$%s%s', $cost, en_base64 ($salt), en_base64 ($hash)); +} + +sub module_verify_hash +{ + my $line = shift; + + my $index1 = index ($line, ":", 33); + + return if $index1 < 1; + + my $hash = substr ($line, 0, $index1); + my $word = substr ($line, $index1 + 1); + + my $index2 = index ($hash, "\$", 4); + + my $iter = substr ($hash, 4, $index2 - 4); + + my $plain_base64 = substr ($hash, $index2 + 1, 22); + + # base64 mapping + + my $base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + my $itoa64_2 = "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + + my $encoded = ""; + + for (my $i = 0; $i < length ($plain_base64); $i++) + { + my $char = substr ($plain_base64, $i, 1); + + $encoded .= substr ($base64, index ($itoa64_2, $char), 1); + } + + my $salt = decode_base64 ($encoded); + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt, $iter); + + return ($new_hash, $word); +} + +1;