summaryrefslogtreecommitdiff
path: root/vendor/christian-riesen/otp/src/Otp/OtpInterface.php
blob: 7ff34f2f4a9d075b7d1aef4da26543278fa23057 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace Otp;

/**
 * Interface for HOTP and TOTP
 *
 * Last update: 2012-06-16
 *
 * HMAC-Based One-time Password(HOTP) algorithm specified in RFC 4226
 * @link https://tools.ietf.org/html/rfc4226
 *
 * Time-based One-time Password (TOTP) algorithm specified in RFC 6238
 * @link https://tools.ietf.org/html/rfc6238
 *
 * @author Christian Riesen <chris.riesen@gmail.com>
 * @link http://christianriesen.com
 * @license MIT License see LICENSE file
 */

interface OtpInterface
{
    /**
     * Returns OTP using the HOTP algorithm
     *
     * @param string $secret
     * @param integer $counter
     * @return string One Time Password
     */
    function hotp($secret, $counter);
    
    /**
     * Returns OTP using the TOTP algorithm
     *
     * @param string $secret
     * @param integer $timecounter Optional: Uses current time if null
     * @return string One Time Password
     */
    function totp($secret, $timecounter = null);
    
    /**
     * Checks Hotp against a key
     *
     * This is a helper function, but is here to ensure the Totp can be checked
     * in the same manner.
     *
     * @param string $secret
     * @param integer $counter
     * @param string $key
     *
     * @return boolean If key is correct
     */
    function checkHotp($secret, $counter, $key);
    
    /**
     * Checks Totp agains a key
     *
     *
     * @param string $secret
     * @param integer $key
     * @param integer $timedrift
     *
     * @return boolean If key is correct
     */
    function checkTotp($secret, $key, $timedrift = 1);
}