Skip to content

Commit a0698f5

Browse files
authored
Merge pull request #11 from pear/v0.3.0
mark authentication methods CRAM-MD5, DIGEST-MD5 and LOGIN as deprecated and bugfix broken SCRAM-SHA-244
2 parents e5783ba + 6ab777e commit a0698f5

File tree

8 files changed

+67
-21
lines changed

8 files changed

+67
-21
lines changed

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ php:
66
- 5.6
77
- 7.0
88
- 7.1
9+
- 7.2
10+
- 7.3
11+
- 7.4
12+
- 8.0
13+
- 8.1
14+
- 8.2
915
script:
1016
- pear list
1117
- pear channel-update pear.php.net

Auth/SASL2.php

+17-5
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ class Auth_SASL2
4949
* type.
5050
*
5151
* @param string $type One of: Anonymous
52+
* Login (DEPRECATED)
5253
* Plain
53-
* CramMD5
54-
* DigestMD5
54+
* External
55+
* CramMD5 (DEPRECATED)
56+
* DigestMD5 (DEPRECATED)
5557
* SCRAM-* (any mechanism of the SCRAM family)
5658
* Types are not case sensitive
5759
*/
@@ -64,6 +66,10 @@ function factory($type)
6466
break;
6567

6668
case 'login':
69+
/* TODO trigger deprecation warning in 1.0.0 and remove LOGIN authentication in 2.0.0
70+
trigger_error(__CLASS__ . ': Authentication method LOGIN' .
71+
' is no longer secure and should be avoided.', E_USER_DEPRECATED);
72+
*/
6773
$filename = 'Auth/SASL2/Login.php';
6874
$classname = 'Auth_SASL2_Login';
6975
break;
@@ -82,6 +88,10 @@ function factory($type)
8288
// $msg = 'Deprecated mechanism name. Use IANA-registered name: CRAM-MD5.';
8389
// trigger_error($msg, E_USER_DEPRECATED);
8490
case 'cram-md5':
91+
/* TODO trigger deprecation warning in 1.0.0 and remove CRAM-MD5 authentication in 2.0.0
92+
trigger_error(__CLASS__ . ': Authentication method CRAM-MD5' .
93+
' is no longer secure and should be avoided.', E_USER_DEPRECATED);
94+
*/
8595
$filename = 'Auth/SASL2/CramMD5.php';
8696
$classname = 'Auth_SASL2_CramMD5';
8797
break;
@@ -90,8 +100,10 @@ function factory($type)
90100
// $msg = 'Deprecated mechanism name. Use IANA-registered name: DIGEST-MD5.';
91101
// trigger_error($msg, E_USER_DEPRECATED);
92102
case 'digest-md5':
93-
// $msg = 'DIGEST-MD5 is a deprecated SASL mechanism as per RFC-6331. Using it could be a security risk.';
94-
// trigger_error($msg, E_USER_NOTICE);
103+
/* TODO trigger deprecation warning in 1.0.0 and remove DIGEST-MD5 authentication in 2.0.0
104+
trigger_error(__CLASS__ . ': Authentication method DIGEST-MD5' .
105+
' is no longer secure and should be avoided.', E_USER_DEPRECATED);
106+
*/
95107
$filename = 'Auth/SASL2/DigestMD5.php';
96108
$classname = 'Auth_SASL2_DigestMD5';
97109
break;
@@ -101,7 +113,7 @@ function factory($type)
101113
if (preg_match($scram, $type, $matches))
102114
{
103115
$hash = $matches[1];
104-
$filename = dirname(__FILE__) .'/SASL2/SCRAM.php';
116+
$filename = __DIR__ .'/SASL2/SCRAM.php';
105117
$classname = 'Auth_SASL2_SCRAM';
106118
$parameter = $hash;
107119
break;

Auth/SASL2/CramMD5.php

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
* @author Richard Heyes <[email protected]>
4141
* @access public
4242
* @version 1.0
43+
* @deprecated since 0.3.0
4344
* @package Auth_SASL
4445
*/
4546

Auth/SASL2/DigestMD5.php

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
* @author Richard Heyes <[email protected]>
4141
* @access public
4242
* @version 1.0
43+
* @deprecated since 0.3.0
4344
* @package Auth_SASL
4445
*/
4546

Auth/SASL2/Login.php

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
* @author Richard Heyes <[email protected]>
4444
* @access public
4545
* @version 1.0
46+
* @deprecated since 0.3.0
4647
* @package Auth_SASL2
4748
*/
4849

Auth/SASL2/SCRAM.php

+24-7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@
5050

5151
class Auth_SASL2_SCRAM extends Auth_SASL2_Common
5252
{
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+
5361
/**
5462
* Construct a SCRAM-H client where 'H' is a cryptographic hash function.
5563
*
@@ -70,8 +78,8 @@ function __construct($hash)
7078
'md5' => 'md5',
7179
'sha-1' => 'sha1',
7280
'sha1' => 'sha1',
73-
'sha-224' > 'sha224',
74-
'sha224' > 'sha224',
81+
'sha-224' => 'sha224',
82+
'sha224' => 'sha224',
7583
'sha-256' => 'sha256',
7684
'sha256' => 'sha256',
7785
'sha-384' => 'sha384',
@@ -80,17 +88,26 @@ function __construct($hash)
8088
'sha512' => 'sha512');
8189
if (function_exists('hash_hmac') && isset($hashes[$hash]))
8290
{
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+
};
8598
}
8699
elseif ($hash == 'md5')
87100
{
88-
$this->hash = create_function('$data', 'return md5($data, true);');
101+
$this->hash = function($data) {
102+
return md5($data, true);
103+
};
89104
$this->hmac = array($this, '_HMAC_MD5');
90105
}
91106
elseif (in_array($hash, array('sha1', 'sha-1')))
92107
{
93-
$this->hash = create_function('$data', 'return sha1($data, true);');
108+
$this->hash = function($data) {
109+
return sha1($data, true);
110+
};
94111
$this->hmac = array($this, '_HMAC_SHA1');
95112
}
96113
else {
@@ -258,7 +275,7 @@ public function processOutcome($data)
258275
* Hi() call, which is essentially PBKDF2 (RFC-2898) with HMAC-H() as the pseudorandom function.
259276
*
260277
* @param string $str The string to hash.
261-
* @param string $hash The hash value.
278+
* @param string $salt The salt value.
262279
* @param int $i The iteration count.
263280
* @access private
264281
*/

README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55

66
Provides code to generate responses to common SASL2 mechanisms, including:
7-
- Digest-MD5
8-
- Cram-MD5
9-
- Plain
107
- Anonymous
11-
- Login (Pseudo mechanism)
12-
- SCRAM
8+
- Cram-MD5 (DEPRECATED)
9+
- Digest-MD5 (DEPRECATED)
10+
- External
11+
- Login (Pseudo mechanism) (DEPRECATED)
12+
- Plain
13+
- SCRAM
1314

1415
[Homepage](http://pear.php.net/package/Auth_SASL2/)
1516

package.xml

+11-4
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
<summary>Abstraction of various SASL mechanism responses</summary>
1414
<description>
1515
Provides code to generate responses to common SASL mechanisms, including:
16-
- Digest-MD5
17-
- Cram-MD5
18-
- Plain
1916
- Anonymous
20-
- Login (Pseudo mechanism)
17+
- Cram-MD5 (DEPRECATED)
18+
- Digest-MD5 (DEPRECATED)
19+
- External
20+
- Login (Pseudo mechanism) (DEPRECATED)
21+
- Plain
2122
- SCRAM
2223
</description>
2324

@@ -39,6 +40,12 @@ Provides code to generate responses to common SASL mechanisms, including:
3940
<email>[email protected]</email>
4041
<active>no</active>
4142
</lead>
43+
<lead>
44+
<name>Armin Graefe</name>
45+
<user>schengawegga</user>
46+
<email>[email protected]</email>
47+
<active>yes</active>
48+
</lead>
4249

4350
<date>2017-03-07</date>
4451
<version>

0 commit comments

Comments
 (0)