Egg::Model::Auth::Crypt::CBC - AUTH component to treat code of attestation data with Crypt::CBC.


Egg-Release-Authorize documentation Contained in the Egg-Release-Authorize distribution.

Index


Code Index:

NAME

Top

Egg::Model::Auth::Crypt::CBC - AUTH component to treat code of attestation data with Crypt::CBC.

SYNOPSIS

Top

  package MyApp::Model::Auth::MyAuth;
  ..........

  __PACKAGE__->config(
    crypt_cbc => {
      cipher => 'Blowfish',
      key    => 'AbCd1234',
      .......
      ...
      },
    );

  __PACKAGE__->setup_api( File => qw/ Crypt::CBC / );

DESCRIPTION

Top

It is API component to treat the password in the attestation data with Crypt::CBC.

'Crypt::CBC' is included in the list following API component name that adds the setting of 'crypt_cbc' to the configuration to use it and specifies it for 'setup_api' method.

  __PACKAGE__->setup_api( File => qw/ Crypt::CBC / );

And, please set 'cipher' and 'key' used when the password in the attestation data is encrypted in 'crypt_cbc'.

Additionally, all set content extends to Crypt::CBC.

METHODS

Top

password_check ([CRYPT_PASSWORD], [INPUT_PAWWORD])

CRYPT_PASSWORD is decoded and whether it agrees is confirmed with INPUT_PAWWORD.

create_password ([PLAIN_PASSWORD])

PLAIN_PASSWORD is encrypted.

SEE ALSO

Top

Egg::Release, Egg::Model::Auth, Egg::Model::Auth::Base::API, Crypt::CBC,

AUTHOR

Top

Masatoshi Mizuno <lushe&64;cpan.org>

COPYRIGHT AND LICENSE

Top


Egg-Release-Authorize documentation Contained in the Egg-Release-Authorize distribution.

package Egg::Model::Auth::Crypt::CBC;
#
# Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
#
# $Id: CBC.pm 347 2008-06-14 18:57:53Z lushe $
#
use strict;
use warnings;
use Carp qw/ croak /;
use Crypt::CBC;

our $VERSION= '0.01';

sub _setup {
	my($class, $e)= @_;
	$class->config->{crypt_cbc_salt} ||= "";
	my $c= $class->config->{crypt_cbc} ||= {};
	$c->{cipher} || die __PACKAGE__. q{ - I want setup 'crypt_cbc->{cipher}'.};
	$c->{key}    || die __PACKAGE__. q{ - I want setup 'crypt_cbc->{key}'.};
	$c->{iv}      ||= '$KJh#(}q';
	$c->{padding} ||= 'standard';
	$c->{prepend_iv}    = 0 unless exists($c->{prepend_iv});
	$c->{regenerate_key}= 1 unless exists($c->{regenerate_key});
	$class->next::method($e);
}
sub __cbc {
	${$_[0]}->{_crypt_cbc} ||= Crypt::CBC->new($_[0]->config->{crypt_cbc});
}
sub password_check {
	my $self = shift;
	my $crypt= shift || croak 'I want crypt string.';
	   $crypt=~s{^\s+} []; $crypt=~s{\s+$} [];
	my $password= shift || croak 'I want target password.';
	   $password=~s{^\s+} []; $password=~s{\s+$} [];
	$password eq $self->__cbc->decrypt_hex($crypt) ? 1: 0;
}
sub create_password {
	my $self    = shift;
	my $password= shift || croak 'I want target password.';
	   $password=~s{^\s+} []; $password=~s{\s+$} [];
	$self->__cbc->encrypt_hex($password. $self->config->{crypt_cbc_salt});
}

1;

__END__