File: register.pl

package info (click to toggle)
libauthen-u2f-perl 0.003-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 196 kB
  • sloc: javascript: 334; perl: 209; makefile: 8
file content (39 lines) | stat: -rw-r--r-- 761 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env perl

use warnings;
use strict;

use Authen::U2F;
use JSON;

use constant APPID   => 'https://example.com';
use constant VERSION => 'U2F_V2';

print "CHALLENGE:\n";

my $challenge = Authen::U2F->challenge;
print encode_json({
  challenge => $challenge,
  appId     => APPID,
  version   => VERSION,
}) . "\n";

exit;

print "\n";
print "ENTER RESPONSE:\n";
chomp (my $in = <STDIN>);

my $reg_response = decode_json($in);

my ($handle, $key) = Authen::U2F->registration_verify(
  challenge         => $challenge,
  app_id            => APPID,
  origin            => APPID,
  registration_data => $reg_response->{registrationData},
  client_data       => $reg_response->{clientData},
);

print "\n";
print "HANDLE: $handle\n";
print "KEY: $key\n";