File perl-Crypt-SmbHash.spec of Package perl-Crypt-SmbHash
#
# spec file for package perl-Crypt-SmbHash
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
Name: perl-Crypt-SmbHash
Version: 0.12
Release: 0
%define cpan_name Crypt-SmbHash
Summary: Perl-only implementation of lanman and nt md4 hash functions, for use in[cut]
License: CHECK(GPL-1.0+ or Artistic-1.0)
Group: Development/Libraries/Perl
Url: http://search.cpan.org/dist/Crypt-SmbHash/
Source0: https://cpan.metacpan.org/authors/id/B/BJ/BJKUIT/%{cpan_name}-%{version}.tar.gz
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: perl
BuildRequires: perl-macros
%{perl_requires}
%description
This module generates Lanman and NT MD4 style password hashes, using
perl-only code for portability. The module aids in the administration of
Samba style systems.
In the Samba distribution, authentication is referred to a private
smbpasswd file. Entries have similar forms to the following:
username:unixuid:LM:NT
Where LM and NT are one-way password hashes of the same password.
ntlmgen generates the hashes given in the first argument, and places the
result in the second and third arguments.
Example: To generate a smbpasswd entry:
#!/usr/local/bin/perl
use Crypt::SmbHash;
$username = $ARGV[0];
$password = $ARGV[1];
if ( !$password ) {
print "Not enough arguments\n";
print "Usage: $0 username password\n";
exit 1;
}
$uid = (getpwnam($username))[2];
my ($login,undef,$uid) = getpwnam($ARGV[0]);
ntlmgen $password, $lm, $nt;
printf "%s:%d:%s:%s:[%-11s]:LCT-%08X\n", $login, $uid, $lm, $nt, "U", time;
ntlmgen returns returns the hash values in a list context, so the
alternative method of using it is:
( $lm, $nt ) = ntlmgen $password;
The functions lmhash and nthash are used by ntlmgen to generate the hashes,
and are available when requested:
use Crypt::SmbHash qw(lmhash nthash)
$lm = lmhash($pass);
$nt = nthash($pass);
If Encoding is available (part of perl-5.8) the $pass argument to ntlmgen,
lmhash and nthash must be a perl string. In double use this:
use Crypt::SmbHash qw(ntlmgen lmhash nthash);
use Encode;
( $lm, $nt ) = ntlmgen decode('iso-8859-1', $pass);
$lm = lmhash(decode_utf8($pass), $pwenc);
$nt = nthash(decode_utf8($pass));
The $pwenc parameter to lmhash() is optional and defaults to 'iso-8859-1'.
It specifies the encoding to which the password is encoded before hashing.
%prep
%setup -q -n %{cpan_name}-%{version}
%build
%{__perl} Makefile.PL INSTALLDIRS=vendor
%{__make} %{?_smp_mflags}
%check
%{__make} test
%install
%perl_make_install
%perl_process_packlist
%perl_gen_filelist
%files -f %{name}.files
%defattr(-,root,root,755)
%doc Changes README
%changelog