lib/auth/set-client-dh-params.js
function checkNonceMatch(context) {
    var newNonce1 = Buffer.concat([utility.string2Buffer(context.newNonce, 32), new Buffer([1]), context.authKeyAuxHash]);
    var newNonceHash = utility.buffer2String(utility.createSHAHash(newNonce1).slice(-16));
    var serverNewNonceHash = context.setClientDHParamsAnswer.new_nonce_hash1;
    if (logger.isDebugEnabled()) {
        logger.debug('newNonceHash = %s, new_nonce_hash1 = %s', newNonceHash.toString(), serverNewNonceHash.toString());
    }
    if (newNonceHash !== serverNewNonceHash) {
        logger.warn('\'dh_gen_ok.new_nonce_hash1\' check fails!');
        throw createError(newNonceHash + ' != ' + serverNewNonceHash, 'EREPLAYATTACK');
    }
    return context;
}
function checkNonceMatch(context) {
    var newNonce1 = Buffer.concat([utility.string2Buffer(context.newNonce, 32), new Buffer([1]), context.authKeyAuxHash]);
    var newNonceHash = utility.buffer2String(utility.createSHAHash(newNonce1).slice(-16));
    var serverNewNonceHash = context.setClientDHParamsAnswer.new_nonce_hash1;
    if (logger.isDebugEnabled()) {
        logger.debug('newNonceHash = %s, new_nonce_hash1 = %s', newNonceHash.toString(), serverNewNonceHash.toString());
    }
    if (newNonceHash !== serverNewNonceHash) {
        logger.warn('\'dh_gen_ok.new_nonce_hash1\' check fails!');
        throw createError(newNonceHash + ' != ' + serverNewNonceHash, 'EREPLAYATTACK');
    }
    return context;
}
function checkNonceMatch ( context ) { var newNonce1 = Buffer . concat ( [ utility . string2Buffer ( context . newNonce , 32 ) , new Buffer ( [ 1 ] ) , context . authKeyAuxHash ] ) ; var newNonceHash = utility . buffer2String ( utility . createSHAHash ( newNonce1 ) . slice ( - 16 ) ) ; var serverNewNonceHash = context . setClientDHParamsAnswer . new_nonce_hash1 ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( 'newNonceHash = %s, new_nonce_hash1 = %s' , newNonceHash . toString ( ) , serverNewNonceHash . toString ( ) ) ; } if ( newNonceHash !== serverNewNonceHash ) { logger . warn ( '\'dh_gen_ok.new_nonce_hash1\' check fails!' ) ; throw createError ( newNonceHash + ' != ' + serverNewNonceHash , 'EREPLAYATTACK' ) ; } return context ; }
Withstand replay-attacks
Withstand replay - attacks