Yubico Forum
https://forum.yubico.com/

Validating OTP in perl?
https://forum.yubico.com/viewtopic.php?f=5&t=1909
Page 1 of 1

Author:  notcached [ Wed Jun 03, 2015 11:34 am ]
Post subject:  Validating OTP in perl?

Edit: the first step, decryption, is below now.

Code:
    my $privatekey = pack( 'H32', $aes );       # convert from hex to binary   
    my $binary_otp = pack( 'H32', $hex );       # convert from hex to binary   

    my $cipher = Crypt::Rijndael->new( $privatekey, Crypt::Rijndael::MODE_CBC()\
 );
    my $cleartext = $cipher->decrypt( $binary_otp );

    die("Bad otp length.\n") unless ( length( $cleartext ) == 16 );

Author:  notcached [ Fri Jun 12, 2015 3:05 pm ]
Post subject:  CRC

For calculating the CRC, it turns out that the polynomial needed was 0x1021

Code:
    my $ctx = Digest::CRC->new(width=>16, poly=>0x1021, init=>0xffff,
                               refin=>1, refout=>1, xorout=>0x0000, cont=>1 );

    $ctx->add($cleartext);
    my $crc2 = $ctx->hexdigest;

    die("Bad CRC.\n") unless ( $crc2 eq "f0b8" );

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/