1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-07-05 06:12:35 +00:00
hashcat/tools/test_modules/m15700.pm
Jens Steube e134564a73 Increase default iteration count per kernel invocation from 1024 to 2048
Add support for lower iteration counts per kernel invocation than the default, enabling TMTO for low scrypt configurations, such as N=1024
Use TMTO 2 if it reaches 4 times the device processor count, instead of TMTO 1 always
Improve performance for low scrypt configurations (hash-mode 9300)
Fix unit test for 15700 with correct scrypt configurations
Disable CPU over subscription for SCRYPT based algorithms
2025-06-15 21:14:40 +02:00

69 lines
1.6 KiB
Perl

#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
use Crypt::ScryptKDF qw (scrypt_raw);
use Digest::Keccak qw (keccak_256_hex);
sub module_constraints { [[0, 256], [32, 32], [-1, -1], [-1, -1], [-1, -1]] }
sub module_generate_hash
{
my $word = shift;
my $salt = shift;
my $scrypt_N = shift || 262144;
my $scrypt_r = shift || 8;
my $scrypt_p = shift || 1;
my $ciphertext = shift || random_bytes (32);
my $derived_key = scrypt_raw ($word, $salt, $scrypt_N, $scrypt_r, $scrypt_p, 32);
my $derived_key_cropped = substr ($derived_key, 16, 16);
my $digest = keccak_256_hex ($derived_key_cropped . $ciphertext);
my $hash = sprintf ("\$ethereum\$s*%i*%i*%i*%s*%s*%s", $scrypt_N, $scrypt_r, $scrypt_p, unpack ("H*", $salt), unpack ("H*", $ciphertext), $digest);
return $hash;
}
sub module_verify_hash
{
my $line = shift;
my ($hash, $word) = split (':', $line);
return unless defined $hash;
return unless defined $word;
my $signature = substr ($hash, 0, 12);
return unless ($signature eq "\$ethereum\$s\*");
my @data = split ('\*', $hash);
return unless scalar (@data) == 7;
shift @data;
my $scrypt_N = shift @data;
my $scrypt_r = shift @data;
my $scrypt_p = shift @data;
my $salt = pack ("H*", shift @data);
my $ciphertext = pack ("H*", shift @data);
my $word_packed = pack_if_HEX_notation ($word);
my $new_hash = module_generate_hash ($word_packed, $salt, $scrypt_N, $scrypt_r, $scrypt_p, $ciphertext);
return ($new_hash, $word);
}
1;