diff options
author | pdlan <pengdinglan@gmail.com> | 2022-04-05 02:40:47 -0400 |
---|---|---|
committer | pdlan <pengdinglan@gmail.com> | 2022-04-05 02:40:47 -0400 |
commit | 19aa9ad6a3842962178b71b7af685c8c4edd20eb (patch) | |
tree | 8c7580bab01436ff025c8527977d0336c407604f /core/rfb.js | |
parent | 42ec5f3321a5a35bee5dd75ff2ee959177c5d95e (diff) | |
download | novnc-19aa9ad6a3842962178b71b7af685c8c4edd20eb.tar.gz |
Remove bigint-mod-arith.js
Diffstat (limited to 'core/rfb.js')
-rw-r--r-- | core/rfb.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/core/rfb.js b/core/rfb.js index 83cfce7..121d9e5 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -27,7 +27,6 @@ import XtScancode from "./input/xtscancodes.js"; import { encodings } from "./encodings.js"; import RSAAESAuthenticationState from "./ra2.js"; import { MD5 } from "./util/md5.js"; -import { modPow } from "./util/bigint-mod-arith.js"; import RawDecoder from "./decoders/raw.js"; import CopyRectDecoder from "./decoders/copyrect.js"; @@ -1595,7 +1594,19 @@ export default class RFB extends EventTargetMixin { let exponentHex = "0x"+Array.from(exponent, byte => ('0' + (byte & 0xFF).toString(16)).slice(-2)).join(''); let modulusHex = "0x"+Array.from(modulus, byte => ('0' + (byte & 0xFF).toString(16)).slice(-2)).join(''); - let hexResult = modPow(BigInt(baseHex), BigInt(exponentHex), BigInt(modulusHex)).toString(16); + let b = BigInt(baseHex); + let e = BigInt(exponentHex); + let m = BigInt(modulusHex); + let r = 1n; + b = b % m; + while (e > 0) { + if (e % 2n === 1n) { + r = (r * b) % m; + } + e = e / 2n; + b = (b * b) % m; + } + let hexResult = r.toString(16); while (hexResult.length/2<exponent.length || (hexResult.length%2 != 0)) { hexResult = "0"+hexResult; |