From 483a62cb7c0cf9bf4cb54402c5d16895a98170fd Mon Sep 17 00:00:00 2001 From: therealartifex Date: Sun, 1 Aug 2021 21:31:06 -0400 Subject: [PATCH] Add test module, update name of hash mode 27100 --- src/modules/module_27100.c | 2 +- tools/test_modules/m27100.pm | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 tools/test_modules/m27100.pm diff --git a/src/modules/module_27100.c b/src/modules/module_27100.c index 22a3c5fd4..f9d77234a 100644 --- a/src/modules/module_27100.c +++ b/src/modules/module_27100.c @@ -17,7 +17,7 @@ static const u32 DGST_POS2 = 2; static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH_SALTED; -static const char *HASH_NAME = "sha1(--$salt--$pass--)"; +static const char *HASH_NAME = "Ruby on Rails Restful Auth (single round, no sitekey)"; static const u64 KERN_TYPE = 27100; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT diff --git a/tools/test_modules/m27100.pm b/tools/test_modules/m27100.pm new file mode 100644 index 000000000..a88e5c5ad --- /dev/null +++ b/tools/test_modules/m27100.pm @@ -0,0 +1,44 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha1_hex); + +sub module_constraints { [[0, 256], [0, 256], [0, 55], [0, 55], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift || random_numeric_string (40); + + my $digest = sha1_hex ('--' . $salt . '--' . $word . '--'); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1;