Authen-Passphrase

 view release on metacpan or  search on metacpan

lib/Authen/Passphrase/AcceptAll.pm  view on Meta::CPAN

=item Authen::Passphrase::AcceptAll->from_crypt("")

Returns an accept-all passphrase recogniser object.  The same object is
returned from each call.  The argument must be the empty string.

=cut

sub from_crypt {
	my($class, $passwd) = @_;
	return $class->new if $passwd eq "";
	return $class->SUPER::from_crypt($passwd);
}

=item Authen::Passphrase::AcceptAll->from_rfc2307(USERPASSWORD)

Generates a new accept-all passphrase recogniser object from an RFC
2307 string.  The string must consist of "B<{CRYPT}>" (case insensitive)
followed by an acceptable crypt string.

=back

lib/Authen/Passphrase/BlowfishCrypt.pm  view on Meta::CPAN

sub from_crypt {
	my($class, $passwd) = @_;
	if($passwd =~ /\A(\$2a?\$)/) {
		$passwd =~ m#\A\$2(a?)\$([0-9]{2})\$
				([./A-Za-z0-9]{22})([./A-Za-z0-9]{31})\z#x
			or croak "malformed $1 data";
		my($kn, $cost, $salt, $hash) = ($1, $2, $3, $4);
		return $class->new(key_nul => $kn, cost => $cost,
				   salt_base64 => $salt, hash_base64 => $hash);
	}
	return $class->SUPER::from_crypt($passwd);
}

=item Authen::Passphrase::BlowfishCrypt->from_rfc2307(USERPASSWORD)

Generates a new passphrase recogniser object using the Blowfish-based
crypt() algorithm, from an RFC 2307 string.  The string must consist of
"B<{CRYPT}>" (case insensitive) followed by an acceptable crypt string.

=back

lib/Authen/Passphrase/Clear.pm  view on Meta::CPAN

=cut

sub from_rfc2307 {
	my($class, $userpassword) = @_;
	if($userpassword =~ /\A\{(?i:cleartext)\}/) {
		$userpassword =~ /\A\{.*?\}([!-~]*)\z/
			or croak "malformed {CLEARTEXT} data";
		my $text = $1;
		return $class->new($text);
	}
	return $class->SUPER::from_rfc2307($userpassword);
}

=back

=head1 METHODS

=over

=item $ppr->match(PASSPHRASE)

lib/Authen/Passphrase/DESCrypt.pm  view on Meta::CPAN

		my($salt, $hash) = ($1, $2);
		return $class->new(salt_base64 => $salt, hash_base64 => $hash);
	} elsif($passwd =~ /\A_.{19}\z/s) {
		$passwd =~ m#\A_([./0-9A-Za-z]{4})([./0-9A-Za-z]{4})
				([./0-9A-Za-z]{11})\z#x
			or croak "malformed _ data";
		my($nr, $salt, $hash) = ($1, $2, $3);
		return $class->new(fold => 1, nrounds_base64 => $nr,
				   salt_base64 => $salt, hash_base64 => $hash);
	}
	return $class->SUPER::from_crypt($passwd);
}

=item Authen::Passphrase::DESCrypt->from_rfc2307(USERPASSWORD)

Generates a new passphrase recogniser object using the DES-based
crypt() algorithm, from an RFC 2307 string.  The string must consist of
"B<{CRYPT}>" (case insensitive) followed by an acceptable crypt string.

=back

lib/Authen/Passphrase/LANManager.pm  view on Meta::CPAN

=cut

sub from_rfc2307 {
	my($class, $userpassword) = @_;
	if($userpassword =~ /\A\{(?i:lanm(?:an)?)\}/) {
		$userpassword =~ /\A\{.*?\}([0-9a-fA-F]{32})\z/
			or croak "malformed {LANMAN} data";
		my $hash = $1;
		return $class->new(hash_hex => $hash);
	}
	return $class->SUPER::from_rfc2307($userpassword);
}

=back

=head1 METHODS

=over

=item $ppr->hash

lib/Authen/Passphrase/LANManagerHalf.pm  view on Meta::CPAN

=cut

sub from_crypt {
	my($class, $passwd) = @_;
	if($passwd =~ /\A\$LM\$/) {
		$passwd =~ m#\A\$LM\$([0-9a-f]{16})\z#
			or croak "malformed \$LM\$ data";
		my $hash = $1;
		return $class->new(hash_hex => $hash);
	}
	return $class->SUPER::from_crypt($passwd);
}

=item Authen::Passphrase::LANManagerHalf->from_rfc2307(USERPASSWORD)

Generates a new LAN Manager half passphrase recogniser object from an RFC
2307 string.  The string must consist of "B<{CRYPT}>" (case insensitive)
followed by an acceptable crypt string.

=back

lib/Authen/Passphrase/MD5Crypt.pm  view on Meta::CPAN

=cut

sub from_crypt {
	my($class, $passwd) = @_;
	if($passwd =~ /\A\$1\$/) {
		$passwd =~ m:\A\$1\$([!-#%-9;-~]{0,8})\$([./0-9A-Za-z]{22})\z:
			or croak "malformed \$1\$ data";
		my($salt, $hash) = ($1, $2);
		return $class->new(salt => $salt, hash_base64 => $hash);
	}
	return $class->SUPER::from_crypt($passwd);
}

=item Authen::Passphrase::MD5Crypt->from_rfc2307(USERPASSWORD)

Generates a new passphrase recogniser object using the MD5-based
crypt() algorithm, from an RFC 2307 string.  The string must consist of
"B<{CRYPT}>" (case insensitive) followed by an acceptable crypt string.

=back

lib/Authen/Passphrase/NTHash.pm  view on Meta::CPAN

		$passwd =~ m#\A\$3\$\$([0-9a-f]{32})\z#
			or croak "malformed \$3\$ data";
		my $hash = $1;
		return $class->new(hash_hex => $hash);
	} elsif($passwd =~ /\A\$NT\$/) {
		$passwd =~ m#\A\$NT\$([0-9a-f]{32})\z#
			or croak "malformed \$NT\$ data";
		my $hash = $1;
		return $class->new(hash_hex => $hash);
	}
	return $class->SUPER::from_crypt($passwd);
}

=item Authen::Passphrase::NTHash->from_rfc2307(USERPASSWORD)

Generates a new NT-Hash passphrase recogniser object from an RFC
2307 string.  Two forms are accepted.  In the first form, the string
must consist of "B<{MSNT}>" followed by the hash in hexadecimal; case
is ignored.  In the second form, the string must consist of "B<{CRYPT}>"
(case insensitive) followed by an acceptable crypt string.

=cut

sub from_rfc2307 {
	my($class, $userpassword) = @_;
	if($userpassword =~ /\A\{(?i:msnt)\}/) {
		$userpassword =~ /\A\{.*?\}([0-9a-fA-F]{32})\z/
			or croak "malformed {MSNT} data";
		my $hash = $1;
		return $class->new(hash_hex => $hash);
	}
	return $class->SUPER::from_rfc2307($userpassword);
}

=back

=head1 METHODS

=over

=item $ppr->hash

lib/Authen/Passphrase/NetscapeMail.pm  view on Meta::CPAN

=cut

sub from_rfc2307 {
	my($class, $userpassword) = @_;
	if($userpassword =~ /\A\{(?i:ns-mta-md5)\}/) {
		$userpassword =~ /\A\{.*?\}([0-9a-fA-F]{32})([!-~]{32})\z/
			or croak "malformed {NS-MTA-MD5} data";
		my($hash, $salt) = ($1, $2);
		return $class->new(salt => $salt, hash_hex => $hash);
	}
	return $class->SUPER::from_rfc2307($userpassword);
}

=back

=head1 METHODS

=over

=item $ppr->salt

lib/Authen/Passphrase/PHPass.pm  view on Meta::CPAN

sub from_crypt {
	my($class, $passwd) = @_;
	if($passwd =~ /\A\$P\$/) {
		$passwd =~ m#\A\$P\$([./0-9A-Za-z])([!-9;-~]{8})
				([./0-9A-Za-z]{22})\z#x
			or croak "malformed \$P\$ data";
		my($cost, $salt, $hash) = ($1, $2, $3);
		return $class->new(cost_base64 => $cost, salt => $salt,
			hash_base64 => $hash);
	}
	return $class->SUPER::from_crypt($passwd);
}

=item Authen::Passphrase::PHPass->from_rfc2307(USERPASSWORD)

Generates a new phpass passphrase recogniser object from an RFC 2307
string.  The string must consist of "B<{CRYPT}>" (case insensitive)
followed by an acceptable crypt string.

=back

lib/Authen/Passphrase/RejectAll.pm  view on Meta::CPAN


=cut

sub from_crypt {
	my($class, $passwd) = @_;
	if($passwd =~ /\A[^\$].{0,11}\z/s) {
		$passwd =~ /\A[!-#\%-9;-~][!-9;-~]{0,11}\z/
			or croak "malformed reject-all crypt data";
		return $class->new;
	}
	return $class->SUPER::from_crypt($passwd);
}

=item Authen::Passphrase::RejectAll->from_rfc2307(USERPASSWORD)

Generates a new reject-all passphrase recogniser object from an RFC
2307 string.  The string must consist of "B<{CRYPT}>" (case insensitive)
followed by an acceptable crypt string.

=back

lib/Authen/Passphrase/SaltedDigest.pm  view on Meta::CPAN

	"MD4" => ["MD4", 16, 0],
	"MD5" => ["MD5", 16, 0],
	"RMD160" => ["Crypt::RIPEMD160-", 20, 0],
	"SHA" => ["SHA-1", 20, 0],
	"SMD5" => ["MD5", 16, 1],
	"SSHA" => ["SHA-1", 20, 1],
);

sub from_rfc2307 {
	my($class, $userpassword) = @_;
	return $class->SUPER::from_rfc2307($userpassword)
		unless $userpassword =~ /\A\{([-0-9A-Za-z]+)\}/;
	my $scheme = uc($1);
	my $meaning = $rfc2307_scheme_meaning{$scheme};
	return $class->SUPER::from_rfc2307($userpassword)
		unless defined $meaning;
	croak "malformed {$scheme} data"
		unless $userpassword =~
			m#\A\{.*?\}
			  ((?>(?:[A-Za-z0-9+/]{4})*)
			   (?:|[A-Za-z0-9+/]{2}[AEIMQUYcgkosw048]=|
			       [A-Za-z0-9+/][AQgw]==))\z#x;
	my $b64 = $1;
	my $hash_and_salt = decode_base64($b64);
	my($algorithm, $hash_len, $salt_allowed) = @$meaning;

lib/Authen/Passphrase/VMSPurdy.pm  view on Meta::CPAN

	my($class, $passwd) = @_;
	if($passwd =~ /\A\$VMS([123])\$/) {
		my $alg = $1;
		$passwd =~ /\A\$VMS[123]\$([0-9A-F]{4})
			    ([0-9A-F]{16})([_\$0-9A-Z]{1,31})\z/x
			or croak "malformed \$VMS${alg}\$ data";
		my($salt, $hash, $un) = ($1, $2, $3);
		return $class->new(algorithm => $decode_crypt_alg_num{$alg},
			username => $un, salt_hex => $salt, hash_hex => $hash);
	}
	return $class->SUPER::from_crypt($passwd);
}

=item Authen::Passphrase::VMSPurdy->from_rfc2307(USERPASSWORD)

Generates a new passphrase recogniser object using the VMS Purdy
polynomial algorithm family, from an RFC 2307 string.  The string must
consist of "B<{CRYPT}>" (case insensitive) followed by an acceptable
crypt string.

=back



( run in 0.307 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )