use native BigInt instead of the big-integer library#385
use native BigInt instead of the big-integer library#385
Conversation
…y points (clientProof and serverSession
…le number inputs in toBigInt.
…u * x) % PRIME.N reduction, ensuring it matches the logic in clientSession and the Firebird engine.
…it calculates the session secret using the reduced exponent logic
…citly calculating x and applying the modulo reduction to the exponent
…ey contain a decimal point . or if they are NOT valid hexadecimal strings.
… indefinitely if authentication stalls. add math formulas to the debug logs , remove big-integer that caused the issue where big-integer objects were being converted to decimal strings and then incorrectly parsed as hex by srp.js, causing authentication failures and timeouts.
|
The authentication failure was caused by a conflict between the big-integer library and JavaScript's native BigInt implementation, leading to data corruption in the SRP key exchange. The Root Causes Incorrect Hex Parsing: When parsing the server's public key: javascript Data Corruption via String Conversion: Even if the big-integer object held the correct value, passing it to lib/srp.js caused corruption. The toBigInt helper in test/srp.js converts inputs to strings: javascript Value: 16 The Fix |
…8 bytes), making overflow unlikely, applying the modulo ensures consistency with the Firebird implementation and other clients.
…p256) when generating the session key K, instead of hardcoding sha1. This ensures compatibility with Firebird's Srp256 implementation. test/srp.js was updated to pass the algorithm to serverSession to match the client behavior during tests
…cates that the Firebird server running in the CI environment is not configured to support the Srp256 authentication plugin (it likely only supports Legacy_Auth or Srp).
use native BigInt instead of the big-integer library. This removes the dependency and uses the performant modPow implementation
Changes in lib/srp.js
Removed require('big-integer').
Replaced BigInt(val, 16) with BigInt('0x' + val).
Replaced library methods (.multiply, .add, .mod, etc.) with native operators (*, +, %).
Added the modPow helper function at the end of the file.
Updated toBigInt and toBuffer helpers to handle native BigInt.
Changes in test/srp.js
Removed require('big-integer').
Updated test vectors to use native BigInt syntax (prefixed with 0x).
Replaced .equals() assertions with strict equality ===.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt