|
@@ -1,6 +1,7 @@
|
|
|
const Factorizator = require('./crypto/Factorizator')
|
|
|
const { types } = require('./tl')
|
|
|
-const { readBigIntFromBuffer, readBufferFromBigInt, sha256, modExp, generateRandomBytes } = require('./Helpers')
|
|
|
+const { readBigIntFromBuffer, readBufferFromBigInt, sha256, bigIntMod, modExp,
|
|
|
+ generateRandomBytes } = require('./Helpers')
|
|
|
const crypto = require('crypto')
|
|
|
const SIZE_FOR_HASH = 256
|
|
|
|
|
@@ -211,7 +212,7 @@ function computeCheck(request, password) {
|
|
|
const bForHash = numBytesForHash(request.srp_B)
|
|
|
const gX = modExp(BigInt(g), x, p)
|
|
|
const k = readBigIntFromBuffer(sha256(Buffer.concat([ pForHash, gForHash ])), false)
|
|
|
- const kgX = (k.multiply(gX)).remainder(p)
|
|
|
+ const kgX = bigIntMod(k.multiply(gX),p)
|
|
|
const generateAndCheckRandom = () => {
|
|
|
const randomSize = 256
|
|
|
// eslint-disable-next-line no-constant-condition
|
|
@@ -229,7 +230,7 @@ function computeCheck(request, password) {
|
|
|
}
|
|
|
}
|
|
|
const [ a, aForHash, u ] = generateAndCheckRandom()
|
|
|
- const gB = (B.subtract(kgX)).remainder(p)
|
|
|
+ const gB = bigIntMod(B.subtract(kgX),p)
|
|
|
if (!isGoodModExpFirst(gB, p)) {
|
|
|
throw new Error('bad gB')
|
|
|
}
|