50
50
51
51
class Auth_SASL2_SCRAM extends Auth_SASL2_Common
52
52
{
53
+ private $ hash ;
54
+ private $ hmac ;
55
+ private $ gs2_header ;
56
+ private $ cnonce ;
57
+ private $ first_message_bare ;
58
+ private $ saltedPassword ;
59
+ private $ authMessage ;
60
+
53
61
/**
54
62
* Construct a SCRAM-H client where 'H' is a cryptographic hash function.
55
63
*
@@ -70,8 +78,8 @@ function __construct($hash)
70
78
'md5 ' => 'md5 ' ,
71
79
'sha-1 ' => 'sha1 ' ,
72
80
'sha1 ' => 'sha1 ' ,
73
- 'sha-224 ' > 'sha224 ' ,
74
- 'sha224 ' > 'sha224 ' ,
81
+ 'sha-224 ' = > 'sha224 ' ,
82
+ 'sha224 ' = > 'sha224 ' ,
75
83
'sha-256 ' => 'sha256 ' ,
76
84
'sha256 ' => 'sha256 ' ,
77
85
'sha-384 ' => 'sha384 ' ,
@@ -80,17 +88,26 @@ function __construct($hash)
80
88
'sha512 ' => 'sha512 ' );
81
89
if (function_exists ('hash_hmac ' ) && isset ($ hashes [$ hash ]))
82
90
{
83
- $ this ->hash = create_function ('$data ' , 'return hash(" ' . $ hashes [$ hash ] . '", $data, TRUE); ' );
84
- $ this ->hmac = create_function ('$key,$str,$raw ' , 'return hash_hmac(" ' . $ hashes [$ hash ] . '", $str, $key, $raw); ' );
91
+ $ selectedHash = $ hashes [$ hash ];
92
+ $ this ->hash = function ($ data ) use ($ selectedHash ) {
93
+ return hash ($ selectedHash , $ data , TRUE );
94
+ };
95
+ $ this ->hmac = function ($ key ,$ str ,$ raw ) use ($ selectedHash ) {
96
+ return hash_hmac ($ selectedHash , $ str , $ key , $ raw );
97
+ };
85
98
}
86
99
elseif ($ hash == 'md5 ' )
87
100
{
88
- $ this ->hash = create_function ('$data ' , 'return md5($data, true); ' );
101
+ $ this ->hash = function ($ data ) {
102
+ return md5 ($ data , true );
103
+ };
89
104
$ this ->hmac = array ($ this , '_HMAC_MD5 ' );
90
105
}
91
106
elseif (in_array ($ hash , array ('sha1 ' , 'sha-1 ' )))
92
107
{
93
- $ this ->hash = create_function ('$data ' , 'return sha1($data, true); ' );
108
+ $ this ->hash = function ($ data ) {
109
+ return sha1 ($ data , true );
110
+ };
94
111
$ this ->hmac = array ($ this , '_HMAC_SHA1 ' );
95
112
}
96
113
else {
@@ -258,7 +275,7 @@ public function processOutcome($data)
258
275
* Hi() call, which is essentially PBKDF2 (RFC-2898) with HMAC-H() as the pseudorandom function.
259
276
*
260
277
* @param string $str The string to hash.
261
- * @param string $hash The hash value.
278
+ * @param string $salt The salt value.
262
279
* @param int $i The iteration count.
263
280
* @access private
264
281
*/
0 commit comments