]> git.proxmox.com Git - pve-common.git/commitdiff
OTP: support v2 secret format
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 28 Oct 2019 11:20:42 +0000 (12:20 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 29 Oct 2019 05:27:39 +0000 (06:27 +0100)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/PVE/OTP.pm

index 019076b444c9e914ef8e62a363bb1f2e73faac29..070ab59e48bb2684e48a3a4b6d4df9a563921e95 100644 (file)
@@ -137,7 +137,13 @@ sub oath_verify_otp {
     foreach my $k (PVE::Tools::split_list($keys)) {
        # Note: we generate 3 values to allow small time drift
        my $binkey;
     foreach my $k (PVE::Tools::split_list($keys)) {
        # Note: we generate 3 values to allow small time drift
        my $binkey;
-       if ($k =~ /^[A-Z2-7=]{16}$/) {
+       if ($k =~ /^v2-0x([0-9a-fA-F]+)$/) {
+           # v2, hex
+           $binkey = pack('H*', $1);
+       } elsif ($k =~ /^v2-([A-Z2-7=]+)$/) {
+           # v2, base32
+           $binkey = MIME::Base32::decode_rfc3548($1);
+       } elsif ($k =~ /^[A-Z2-7=]{16}$/) {
            $binkey = MIME::Base32::decode_rfc3548($k);
        } elsif ($k =~ /^[A-Fa-f0-9]{40}$/) {
            $binkey = pack('H*', $k);
            $binkey = MIME::Base32::decode_rfc3548($k);
        } elsif ($k =~ /^[A-Fa-f0-9]{40}$/) {
            $binkey = pack('H*', $k);