Blesta
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • blesta
    • app
      • components
        • events
          • default
      • controllers
      • models
    • components
      • auth
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • exchange
        • rates
          • foxrate
          • google
            • finance
          • yahoo
            • finance
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
      • json
      • modules
      • net
        • http
        • net
          • amazon
            • s3
          • geo
            • ip
      • plugins
      • recaptcha
      • security
      • session
        • cart
      • settingscollection
      • upgrades
      • upload
      • vcard
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
  • com
    • tecnick
      • tcpdf
        • blesta
          • components
            • invoice
              • templates
                • quickbooks
                  • invoice
                • templates
                  • default
  • Crypt
    • AES
    • DES
    • Hash
    • Random
    • RC4
    • Rijndael
    • RSA
    • TerraDES
  • File
    • ANSI
    • ASN1
    • X509
  • Math
    • BigInteger
  • minPHP
    • components
      • input
      • record
    • helpers
      • color
      • data
        • structure
      • date
      • html
      • xml
    • lib
  • Net
    • SFTP
    • SSH1
    • SSH2
  • None
  • PHP
  • PHPMailer
  • Services
    • JSON
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Motp
  • Oath

Class Oath

Oath implementation of the OATH specification for both HOTP and TOTP one time passwords (RFC4226 and its extension HOTPTimeBased Internet-Draft, respectively).

See http://www.openauthentication.org

Package: blesta
Subpakage: blesta.components.auth.oath
Located at components/auth/oath/oath.php

Methods summary

public
# __construct( string $secret = null, string $crypto = "sha1" )

Construct a new OATH object using the given secret and HMAC hash function

Construct a new OATH object using the given secret and HMAC hash function

Parameters

$secret
string
$secret The shared secret
$crypto
string
$crypto The crypto system to use during the HMAC calculation
public
# setSecret( string $secret )

Set the secret key to use along with the HMAC calculation

Set the secret key to use along with the HMAC calculation

Parameters

$secret
string
$secret The shared secret
public
# setCrypto( string $crypto )

Set the algorithm to use during the HMAC calculation

Set the algorithm to use during the HMAC calculation

Parameters

$crypto
string
$crypto The crypto system to use during the HMAC calculation
public boolean
# checkHotp( string $otp, integer $counter, integer $vlav = 0 )

Checks whether the given one time password is a valid HOTP password using the given counter and VLAV (Validation Look Ahead Value)

Checks whether the given one time password is a valid HOTP password using the given counter and VLAV (Validation Look Ahead Value)

Parameters

$otp
string
$otp The one time password to validate
$counter
integer
$counter The counter value
$vlav
integer
$vlav The validation look ahead value

Returns

boolean
True if this OTP is valid, false otherwise
public boolean
# checkTotp( string $otp, integer $time )

Checks whether the given one time password is a valid TOTP password using the given time

Checks whether the given one time password is a valid TOTP password using the given time

Parameters

$otp
string
$otp The one time password to validate
$time
integer
$time The time value

Returns

boolean
True if this OTP is valid, false otherwise
public static string
# hotp( string $key, integer $counter, mixed $digit_length = 6, mixed $crypto = "sha1" )

Generate an HOTP pass phrase

Generate an HOTP pass phrase

Parameters

$key
string
$key The secret key
$counter
integer
$counter The counter value
$digit_length
mixed
$digit_length The length of the resulting pass phrase
$crypto
mixed
$crypto The algorithm to use in the HMAC calculation

Returns

string
The HOTP pass pharse
public static string
# totp( string $key, integer $counter, mixed $digit_length = 6, mixed $crypto = "sha1" )

Generate an TOTP pass phrase

Generate an TOTP pass phrase

Parameters

$key
string
$key The secret key
$counter
integer
$counter The counter value (e.g. Unix time)
$digit_length
mixed
$digit_length The length of the resulting pass phrase
$crypto
mixed
$crypto The algorithm to use in the HMAC calculation

Returns

string
The TOTP pass pharse
private static
# hex2Bin( string $string )

Detects if the given string is in hex format, if not, converts it to hex

Detects if the given string is in hex format, if not, converts it to hex

Parameters

$string
string
The string to test/convert to a hex string
private static string
# hexStr2Bin( integer $hex )

Converts a hex string to a binary string

Converts a hex string to a binary string

Parameters

$hex
integer
$hex The hex value to convert

Returns

string
The byte representation of the given hex
private static string
# truncate( string $hash, integer $digit_length = 6 )

Truncates the given hash per the RFC4226 truncation method

Truncates the given hash per the RFC4226 truncation method

Parameters

$hash
string
$hash The hash as a hexadecimal string
$digit_length
integer
$digit_length The length of the result

Returns

string
The truncated hash

Magic methods summary

Properties summary

private static array $digits_power
#

Precomputed power values

Precomputed power values

private string $secret
#

Shared secret

Shared secret

private integer $length
#

Length of one time password

Length of one time password

private integer $moving_factor
#

Moving factor of TOTP

Moving factor of TOTP

private integer $drift
#

The number of seconds of drift to account for (+/- 3 minutes)

The number of seconds of drift to account for (+/- 3 minutes)

private string $crypto
#

The hash function to use during the HMAC calculation

The hash function to use during the HMAC calculation

Blesta API documentation generated by ApiGen 2.8.0