Debian Codegraph @

t/03-totp-test-vectors.t

raw symbols SCIP
1 use Test::Morescip-perl cpan Pass-OTP 1.901 Test/More/;
2
3 use utf8scip-perl cpan Pass-OTP 1.901 utf8/;
4 use strictscip-perl cpan Pass-OTP 1.901 strict/;
5 use warningsscip-perl cpan Pass-OTP 1.901 warnings/;
6
7 require_okscip-perl cpan Pass-OTP 1.901 main/require_ok(). 'Pass::OTP';
8
9 # Based on the test vectors from RFC6238
10
11 my %seeds = (
12 sha1 => '3132333435363738393031323334353637383930',
13 sha256 => '3132333435363738393031323334353637383930' .
14 '313233343536373839303132',
15 sha512 => '3132333435363738393031323334353637383930' .
16 '3132333435363738393031323334353637383930' .
17 '3132333435363738393031323334353637383930' .
18 '31323334',
19 );
20
21 sub is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp(). {
22 my %opts = (@_scip-perl cpan Pass-OTP 1.901 main/`@_`.);
23
24 isscip-perl cpan Pass-OTP 1.901 main/is().(
25 Pass::OTP::otpscip-perl cpan Pass-OTP 1.901 Pass/OTP/otp().(
26 secret => $seeds{lcscip-perl cpan Pass-OTP 1.901 main/lc(). $opts{algorithm}},
27 algorithm => $opts{algorithm},
28 now => $opts{now},
29 digits => 8,
30 type => 'totp'),
31 $opts{totp},
32 "Test vector with time (sec) $opts{now} on mode $opts{algorithm}"
33 );
34 }
35
36 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 59, algorithm => 'sha1', totp => '94287082');
37 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 59, algorithm => 'sha256', totp => '46119246');
38 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 59, algorithm => 'sha512', totp => '90693936');
39
40
41 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 1111111109, algorithm => 'sha1', totp => '07081804');
42 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 1111111109, algorithm => 'sha256', totp => '68084774');
43 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 1111111109, algorithm => 'sha512', totp => '25091201');
44
45
46 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 1111111111, algorithm => 'sha1', totp => '14050471');
47 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 1111111111, algorithm => 'sha256', totp => '67062674');
48 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 1111111111, algorithm => 'sha512', totp => '99943326');
49
50
51 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 1234567890, algorithm => 'sha1', totp => '89005924');
52 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 1234567890, algorithm => 'sha256', totp => '91819424');
53 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 1234567890, algorithm => 'sha512', totp => '93441116');
54
55
56 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 2000000000, algorithm => 'sha1', totp => '69279037');
57 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 2000000000, algorithm => 'sha256', totp => '90698825');
58 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 2000000000, algorithm => 'sha512', totp => '38618901');
59
60
61 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 20000000000, algorithm => 'sha1', totp => '65353130');
62 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 20000000000, algorithm => 'sha256', totp => '77737706');
63 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 20000000000, algorithm => 'sha512', totp => '47863826');
64
65
66 is_totpscip-perl cpan Pass-OTP 1.901 main/is_totp().(now => 59, algorithm => 'SHA512', totp => '90693936');
67
68 done_testingscip-perl cpan Pass-OTP 1.901 main/done_testing().(20);