File-KDBX
view release on metacpan or search on metacpan
lib/File/KDBX/Key.pm view on Meta::CPAN
sub raw_key {
my $self = shift;
return $self->{raw_key} if !$self->is_hidden;
return $self->_safe->peek(\$self->{raw_key});
}
sub _set_raw_key {
my $self = shift;
$self->_clear_raw_key;
$self->{raw_key} = shift; # after clear
$self->_new_safe->add(\$self->{raw_key}); # auto-hide
}
sub _clear_raw_key {
my $self = shift;
my $safe = $self->_safe;
$safe->clear if $safe;
erase \$self->{raw_key};
}
sub hide {
my $self = shift;
$self->_new_safe->add(\$self->{raw_key}) if defined $self->{raw_key};
return $self;
}
sub show {
my $self = shift;
my $safe = $self->_safe;
$safe->unlock if $safe;
return $self;
}
sub is_hidden { !!$SAFE{$_[0]} }
sub _safe { $SAFE{$_[0]} }
sub _new_safe { $SAFE{$_[0]} = File::KDBX::Safe->new }
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
File::KDBX::Key - A credential that can protect a KDBX file
=head1 VERSION
version 0.906
=head1 DESCRIPTION
A master key is one or more credentials that can protect a KDBX database. When you encrypt a database with
a master key, you will need the master key to decrypt it. B<Keep your master key safe!> If someone gains
access to your master key, they can open your database. If you forget or lose any part of your master key, all
data in the database is lost.
There are several different types of keys, each implemented as a subclass:
=over 4
=item *
L<File::KDBX::Key::Password> - Password or passphrase, knowledge of a string of characters
=item *
L<File::KDBX::Key::File> - Possession of a file ("key file") with a secret
=item *
L<File::KDBX::Key::ChallengeResponse> - Possession of a device that responds correctly when challenged
=item *
L<File::KDBX::Key::YubiKey> - Possession of a YubiKey hardware device (a type of challenge-response)
=item *
L<File::KDBX::Key::Composite> - One or more keys combined as one
=back
A good master key is produced from a high amount of "entropy" (unpredictability). The more entropy the better.
Combining multiple keys into a B<Composite> key combines the entropy of each individual key. For example, if
you have a weak password and you combine it with other keys, the composite key is stronger than the weak
password key by itself. (Of course it's much better to not have any weak components of your master key.)
B<COMPATIBILITY NOTE:> Most KeePass implementations are limited in the types and numbers of keys they support.
B<Password> keys are pretty much universally supported. B<File> keys are pretty well-supported. Many do not
support challenge-response keys. If you are concerned about compatibility, you should stick with one of these
well-supported configurations:
=over 4
=item *
One password
=item *
One key file
=item *
Composite of one password and one key file
=back
=head1 METHODS
=head2 new
( run in 0.731 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )