Skip to content

Commit ab11629

Browse files
committed
Remove unnecessary top-level MD5 digester functions that cause an exception on FIPS-enabled systems when the www-authenticate module is loaded via require. The MD5 digester functions are already created on demand when using DIGEST authentication.
Use Buffer.from rather than deprecated new Buffer constructor form. Move the Parser_Authenticate_Info prototype statement to after the definition of the function. Add copyright to www-authenticate.
1 parent 507cec1 commit ab11629

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

lib/www-authenticate-patched/md5.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
var crypto= require('crypto')
2-
, md5sum = crypto.createHash('md5')
3-
;
1+
var crypto= require('crypto');
42

53
function md5(s) {
64
return crypto.createHash('md5').update(s).digest('hex');

lib/www-authenticate-patched/parsers.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ function Parse_WWW_Authenticate(to_parse)
8888
}
8989
}
9090

91-
Parse_Authentication_Info.prototype.parse_params= parse_params;
92-
9391
function Parse_Authentication_Info(to_parse)
9492
{
9593
this.scheme= 'Digest';
@@ -102,6 +100,7 @@ function Parse_Authentication_Info(to_parse)
102100
}
103101
}
104102

103+
Parse_Authentication_Info.prototype.parse_params= parse_params;
105104
Parse_WWW_Authenticate.prototype.parse_params= parse_params;
106105

107106
module.exports = {

lib/www-authenticate-patched/user-credentials.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ function user_credentials(username,password,options) {
1616
''
1717
:
1818
(!password && password !== '' ?
19-
new Buffer(username, "ascii").toString("base64")
19+
Buffer.from(username, "ascii").toString("base64")
2020
:
21-
new Buffer(username+':'+password, "ascii").toString("base64")
21+
Buffer.from(username+':'+password, "ascii").toString("base64")
2222
)
2323
function Credentials()
2424
{

lib/www-authenticate-patched/www-authenticate.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
* www-authenticate
43
* https://github.com/randymized/www-authenticate
@@ -7,10 +6,12 @@
76
* Licensed under the MIT license.
87
*/
98

9+
/*
10+
* Copyright © 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
11+
*/
1012
'use strict';
1113

1214
var crypto= require('crypto')
13-
, md5sum = crypto.createHash('md5')
1415
, parsers= require('./parsers')
1516
, md5= require('./md5')
1617
, user_credentials= require('./user-credentials')

0 commit comments

Comments
 (0)