7 use File
::KDBX
::Constants
qw(:magic :kdf);
8 use File
::KDBX
::Util
qw(can_fork dumper);
9 use File
::Spec
::Functions
qw(catfile);
15 $Data::Dumper
::Deepcopy
= 1;
16 $Data::Dumper
::Deparse
= 1;
17 $Data::Dumper
::Indent
= 1;
18 $Data::Dumper
::Quotekeys
= 0;
19 $Data::Dumper
::Sortkeys
= 1;
20 $Data::Dumper
::Terse
= 1;
21 $Data::Dumper
::Trailingcomma
= 1;
22 $Data::Dumper
::Useqq
= 1;
31 require Test
::Warnings
;
33 push @warnings_flags, ':no_end_test' if !$ENV{AUTHOR_TESTING
} || grep { $_ eq ':no_warnings_test' } @args;
34 Test
::Warnings-
>import(@warnings_flags);
36 # Just export a random assortment of things useful for testing.
38 *{"${caller}::dumper"} = \
&File
::KDBX
::Util
::dumper
;
39 *{"${caller}::catfile"} = \
&File
::Spec
::Functions
::catfile
;
41 *{"${caller}::exception"} = \
&Test
::Fatal
::exception
;
42 *{"${caller}::warning"} = \
&Test
::Warnings
::warning
;
43 *{"${caller}::warnings"} = \
&Test
::Warnings
::warnings
;
45 *{"${caller}::dump_test_deep_template"} = \
&dump_test_deep_template
;
46 *{"${caller}::ok_magic"} = \
&ok_magic
;
47 *{"${caller}::fast_kdf"} = \
&fast_kdf
;
48 *{"${caller}::can_fork"} = \
&can_fork
;
49 *{"${caller}::testfile"} = \
&testfile
;
53 return catfile
($Bin, 'files', @_);
56 sub dump_test_deep_template
{
59 my $str = Dumper
$struct;
60 # booleans: bless( do{\(my $o = 1)}, 'boolean' )
61 $str =~ s/bless\( do\{\\\(my \$o = ([01])\)\}, 'boolean' \)/bool($1)/gs;
63 $str =~ s/bless\(.+?'([^']+)' \)/obj_isa('$1')/gs;
64 # convert two to four space indentation
65 $str =~ s/^( +)/' ' x (length($1) * 2)/gme;
67 open(my $fh, '>>', 'TEST-DEEP-TEMPLATES.pl') or die "open failed: $!";
76 my $magic = [$kdbx->sig1, $kdbx->sig2, $kdbx->version];
81 ], $note // 'KDBX magic numbers are correct';
85 my $uuid = shift // KDF_UUID_AES
;
87 KDF_PARAM_UUID
() => $uuid,
89 if ($uuid eq KDF_UUID_AES
|| $uuid eq KDF_UUID_AES_CHALLENGE_RESPONSE
) {
90 $params->{+KDF_PARAM_AES_ROUNDS
} = 17;
91 $params->{+KDF_PARAM_AES_SEED
} = "\1" x
32;
94 $params->{+KDF_PARAM_ARGON2_SALT
} = "\1" x
32;
95 $params->{+KDF_PARAM_ARGON2_PARALLELISM
} = 1;
96 $params->{+KDF_PARAM_ARGON2_MEMORY
} = 1 << 13;
97 $params->{+KDF_PARAM_ARGON2_ITERATIONS
} = 2;
98 $params->{+KDF_PARAM_ARGON2_VERSION
} = 0x13;