File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -387,23 +387,31 @@ Cam.prototype.updateNC = function() {
387387 return String ( this . _nc ) . padStart ( 8 , '0' ) ;
388388} ;
389389
390+ Cam . prototype . _getHashAlgorithm = function ( ) {
391+ if ( crypto . getFips ( ) === 1 ) {
392+ return 'sha256' ;
393+ } else {
394+ return 'md5' ;
395+ }
396+ }
397+
390398Cam . prototype . digestAuth = function ( wwwAuthenticate , reqOptions ) {
391399 const challenge = this . _parseChallenge ( wwwAuthenticate ) ;
392- const ha1 = crypto . createHash ( 'md5' ) ;
400+ const ha1 = crypto . createHash ( this . _getHashAlgorithm ( ) ) ;
393401 ha1 . update ( [ this . username , challenge . realm , this . password ] . join ( ':' ) ) ;
394- const ha2 = crypto . createHash ( 'md5' ) ;
402+ const ha2 = crypto . createHash ( this . _getHashAlgorithm ( ) ) ;
395403 ha2 . update ( [ reqOptions . method , reqOptions . path ] . join ( ':' ) ) ;
396404
397405 let cnonce = null ;
398406 let nc = null ;
399407 if ( typeof challenge . qop === 'string' ) {
400- const cnonceHash = crypto . createHash ( 'md5' ) ;
408+ const cnonceHash = crypto . createHash ( this . _getHashAlgorithm ( ) ) ;
401409 cnonceHash . update ( Math . random ( ) . toString ( 36 ) ) ;
402410 cnonce = cnonceHash . digest ( 'hex' ) . substring ( 0 , 8 ) ;
403411 nc = this . updateNC ( ) ;
404412 }
405413
406- const response = crypto . createHash ( 'md5' ) ;
414+ const response = crypto . createHash ( this . _getHashAlgorithm ( ) ) ;
407415 const responseParams = [
408416 ha1 . digest ( 'hex' ) ,
409417 challenge . nonce
Original file line number Diff line number Diff line change 11{
22 "name" : " onvif" ,
3- "version" : " 0.8.1 " ,
3+ "version" : " 0.9.0 " ,
44 "author" :
" Andrew D.Laptev <[email protected] >" ,
55 "description" : " Client to ONVIF NVT devices Profile S: cameras" ,
66 "main" : " lib/onvif.js" ,
You can’t perform that action at this time.
0 commit comments