Merge pull request #1844 from s3inlc/test-plugin-101_111_112

Added test modules for mode 101, 111 and 112
pull/1849/head
Jens Steube 5 years ago committed by GitHub
commit fb938970d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,45 @@
#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
use Digest::SHA qw (sha1);
use MIME::Base64 qw (encode_base64);
sub module_constraints { [[0, 255], [-1, -1], [0, 55], [-1, -1], [-1, -1]] }
sub module_generate_hash
{
my $word = shift;
my $digest = sha1 ($word);
my $base64_buf = encode_base64 ($digest, "");
my $hash = sprintf ("{SHA}%s", $base64_buf);
return $hash;
}
sub module_verify_hash
{
my $line = shift;
my ($hash, $word) = split (':', $line);
return unless defined $hash;
return unless defined $word;
my $word_packed = pack_if_HEX_notation ($word);
my $new_hash = module_generate_hash ($word_packed);
return ($new_hash, $word);
}
1;

@ -0,0 +1,46 @@
#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
use Digest::SHA qw (sha1);
use MIME::Base64 qw (encode_base64);
sub module_constraints { [[0, 255], [0, 255], [0, 55], [0, 55], [0, 55]] }
sub module_generate_hash
{
my $word = shift;
my $salt = shift;
my $digest = sha1 ($word . $salt);
my $base64_buf = encode_base64 ($digest . $salt, "");
my $hash = sprintf ("{SSHA}%s", $base64_buf);
return $hash;
}
sub module_verify_hash
{
my $line = shift;
my ($hash, $word) = split (':', $line);
return unless defined $hash;
return unless defined $word;
my $word_packed = pack_if_HEX_notation ($word);
my $new_hash = module_generate_hash ($word_packed);
return ($new_hash, $word);
}
1;

@ -0,0 +1,46 @@
#!/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, 30], [20, 20], [0, 30], [20, 20], [20, 55]] }
sub module_generate_hash
{
my $word = shift;
my $salt = shift;
my $salt_bin = pack("H*", $salt);
my $digest = sha1_hex ($word . $salt_bin);
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);
return ($new_hash, $word);
}
1;
Loading…
Cancel
Save