phpsecYubikey::getYubikeyId

  1. phpsec
    1. dev
    2. a-0.0.3
    3. a-0.0.4
    4. b-0.1
    5. b-0.2
    6. b-0.3
Versions
b-0.3 public static phpsecYubikey::getYubikeyId($otp)

Get the identity of a Yubikey OTP. The identity part is the same for every OTP, and it is the initial 2-16 modhex characters of the OTP. Since the rest of the OTP is always 32 characters, the method to extract the identity is to remove 32 characters from the end and then use the remaining string, which should be 2-16 characters, as the YubiKey identity.

Parameters

string $otp The one time password to get the identity from.

Return value

string Returns the Yubikey identity, or false on failure.

Code

phpsec/phpsec.yubikey.php, line 253

<?php
public static function getYubikeyId($otp) {
  if (!self::validOtp($otp)) {
    return false;
  }

  $idLen = strlen($otp) - 32;
  return substr($otp, 0, $idLen);
}
?>

Copyright (c) 2011, 2012 Audun Larsen.

Drupal theme by Kiwi Themes.