Subversion Repositories oidplus

Rev

Rev 453 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 453 Rev 459
Line 17... Line 17...
17
 * limitations under the License.
17
 * limitations under the License.
18
 */
18
 */
19
 
19
 
20
class OIDplusAuthPluginBCrypt extends OIDplusAuthPlugin {
20
class OIDplusAuthPluginBCrypt extends OIDplusAuthPlugin {
21
 
21
 
22
        public function verify($authKey, $salt, $check_password) {
22
        public function verify(OIDplusRAAuthInfo $authInfo, $check_password) {
23
                @list($s_authmethod, $s_authkey) = explode('#', $authKey, 2);
23
                @list($s_authmethod, $s_authkey) = explode('#', $authKey, 2);
24
 
24
 
-
 
25
                $authKey = $authInfo->getAuthKey();
-
 
26
                $salt = $authInfo->getSalt();
-
 
27
 
25
                if ($s_authmethod == 'A3') {
28
                if ($s_authmethod == 'A3') {
26
                        // A3#$2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy
29
                        // A3#$2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy
27
                        //    \__/\/ \____________________/\_____________________________/
30
                        //    \__/\/ \____________________/\_____________________________/
28
                        //     Alg Cost      Salt                        Hash
31
                        //     Alg Cost      Salt                        Hash
29
                        if ($salt != '') {
32
                        if ($salt != '') {
Line 34... Line 37...
34
                        // Invalid auth code
37
                        // Invalid auth code
35
                        return false;
38
                        return false;
36
                }
39
                }
37
        }
40
        }
38
 
41
 
39
        public function generate($password) {
42
        public function generate($password): OIDplusRAAuthInfo {
40
                $s_salt = ''; // BCrypt automatically generates a salt
43
                $s_salt = ''; // BCrypt automatically generates a salt
41
                $calc_authkey = 'A3#'.password_hash($password, PASSWORD_BCRYPT);
44
                $calc_authkey = 'A3#'.password_hash($password, PASSWORD_BCRYPT);
42
                return array($s_salt, $calc_authkey);
45
                return array($s_salt, $calc_authkey);
43
        }
46
        }
44
 
47