]> Dogcows Code - chaz/p5-File-KDBX/blobdiff - lib/File/KDBX/Key/Composite.pm
Add key file saving and refactor some stuff
[chaz/p5-File-KDBX] / lib / File / KDBX / Key / Composite.pm
index cd97314de325c8886ad040bd9810f00aecc58706..86b803aaeb85f920025492ee396a9921bad30d40 100644 (file)
@@ -29,6 +29,15 @@ sub init {
     return $self->hide;
 }
 
+=method raw_key
+
+    $raw_key = $key->raw_key;
+    $raw_key = $key->raw_key($challenge);
+
+Get the raw key from each component key and return a generated composite raw key.
+
+=cut
+
 sub raw_key {
     my $self = shift;
     my $challenge = shift;
@@ -46,6 +55,42 @@ sub raw_key {
     );
 }
 
+=attr keys
+
+    \@keys = $key->keys;
+
+Get one or more component L<File::KDBX::Key>.
+
+=cut
+
+sub keys {
+    my $self = shift;
+    $self->{keys} = shift if @_;
+    return $self->{keys} ||= [];
+}
+
+=method challenge
+
+    $response = $key->challenge(...);
+
+Issues a challenge to any L<File::KDBX::Key::ChallengeResponse> components keys. Arguments are passed through
+to each component key. The responses are hashed together and the composite response is returned.
+
+Returns empty string if there are no challenge-response components keys.
+
+=cut
+
+sub challenge {
+    my $self = shift;
+
+    my @chalresp_keys = grep { $_->can('challenge') } @{$self->keys} or return '';
+
+    my @responses = map { $_->challenge(@_) } @chalresp_keys;
+    my $cleanup = erase_scoped \@responses;
+
+    return digest_data('SHA256', @responses);
+}
+
 sub hide {
     my $self = shift;
     $_->hide for @{$self->keys};
@@ -58,30 +103,20 @@ sub show {
     return $self;
 }
 
-sub challenge {
-    my $self = shift;
-    my @args = @_;
+1;
+__END__
 
-    my @chalresp_keys = grep { $_->can('challenge') } @{$self->keys} or return '';
+=head1 SYNOPSIS
 
-    my @responses = map { $_->challenge(@args) } @chalresp_keys;
-    my $cleanup = erase_scoped \@responses;
+    use File::KDBX::Key::Composite;
 
-    return digest_data('SHA256', @responses);
-}
+    my $key = File::KDBX::Key::Composite->(\@component_keys);
 
-=attr keys
+=head1 DESCRIPTION
 
-    \@keys = $key->keys;
+A composite key is a collection of other keys. A master key capable of unlocking a KDBX database is always
+a composite key, even if it only has a single component.
 
-Get one or more component L<File::KDBX::Key>.
+Inherets methods and attributes from L<File::KDBX::Key>.
 
 =cut
-
-sub keys {
-    my $self = shift;
-    $self->{keys} = shift if @_;
-    return $self->{keys} ||= [];
-}
-
-1;
This page took 0.021057 seconds and 4 git commands to generate.