category OSS
package OSS_Yubico
copyright Copyright (c) 2007 - 2012, Open Source Solutions Limited, Dublin, Ireland
license New BSD License

 Methods

Decrypts an AES128-ECB encrypted string.

aes128EcbDecrypt(string $cipherText, string $key) : string
Static

Parameters

$cipherText

string

the encrypted string, a string of hexadecimal values

$key

string

the AES key, a string of hexadecimal values

Returns

stringa string of hexadecimal values

Calculates the CRC16 value of a string.

crc16(string $string) : string
Static

Parameters

$string

string

Returns

stringthe CRC16 value as a hexadecimal number

Returns error text by given code

getErrorMessage(int $errorCode) : string
Static

Parameters

$errorCode

int

Eror code is negative value from one to eight

Returns

string

Converts a hexadecimal string to Base64.

hex2base64(string $hex) : string
Static

Parameters

$hex

string

Returns

string

Converts a hexadecimal number (string) to its binary number representation.

hex2bin(string $hex) : string
Static

Parameters

$hex

string

Returns

string

Converts a hexadecimal string to ModHex.

hex2modhex(string $hex) : string
Static

Parameters

$hex

string

Returns

string

Checks if the CRC16 value is correct, and returns boolean true or false, respectively.

isCrcGood(string $string) : bool
Static

Parameters

$string

string

Returns

bool

Converts a ModHex string to Base64.

modhex2base64(string $modHex) : string
Static

Parameters

$modHex

string

Returns

string

Converts a ModHex string to hexadecimal.

modhex2hex($modHex) : string
Static

Parameters

$modHex

Returns

string

Validates the YubiKey OTP.

validate(string $pOTP) : array | integer
Static

Checks it against rules and the database, too. Returns with an associative array containing the following fields (extracted from the OTP): secret_id, session_counter, session_use, clock, random Retruns with a negative integer on error.

-1: No OTP provided -2: Corrupt OTP -3: DB failure while trying to read user data -4: User does not exist -5: Wrong AES key -6: User ID mismatch -7: Replay attack -8: DB failure while trying to update user data

Parameters

$pOTP

string

Returns

arrayintegerarray on success, negative integer on error

 Properties

 

Contains the possible validation error codes and messages.

$VALIDATION_ERROR : array

 Constants

 

ERR_CORRUPT_OTP

ERR_CORRUPT_OTP 
 

ERR_DATABASE_READ

ERR_DATABASE_READ 
 

ERR_DATABASE_WRITE

ERR_DATABASE_WRITE 
 

ERR_NO_OTP_PROVIDED

ERR_NO_OTP_PROVIDED 
 

ERR_NO_SUCH_USER

ERR_NO_SUCH_USER 
 

ERR_REPLAY_ATTACK

ERR_REPLAY_ATTACK 
 

ERR_USER_ID_MISMATCH

ERR_USER_ID_MISMATCH 
 

ERR_WRONG_AES_KEY

ERR_WRONG_AES_KEY