From 1e5d0d4ca09483d1a6c4fbd292a974caebd33d44 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 26 Nov 2024 15:21:19 +0100 Subject: [PATCH] fix safe add --- SunSpider/crypto-md5.js | 4 +--- SunSpider/crypto-sha1.js | 4 +--- worker/bomb-subtests/crypto-md5.js | 4 +--- worker/bomb-subtests/crypto-sha1.js | 4 +--- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/SunSpider/crypto-md5.js b/SunSpider/crypto-md5.js index ca33650..2af8459 100644 --- a/SunSpider/crypto-md5.js +++ b/SunSpider/crypto-md5.js @@ -181,9 +181,7 @@ function core_hmac_md5(key, data) */ function safe_add(x, y) { - var lsw = (x & 0xFFFF) + (y & 0xFFFF); - var msw = (x >> 16) + (y >> 16) + (lsw >> 16); - return (msw << 16) | (lsw & 0xFFFF); + return ((x & 0xffffffff) + (y & 0xffffffff)) & 0xffffffff } /* diff --git a/SunSpider/crypto-sha1.js b/SunSpider/crypto-sha1.js index fb5c4cb..1ed248b 100644 --- a/SunSpider/crypto-sha1.js +++ b/SunSpider/crypto-sha1.js @@ -127,9 +127,7 @@ function core_hmac_sha1(key, data) */ function safe_add(x, y) { - var lsw = (x & 0xFFFF) + (y & 0xFFFF); - var msw = (x >> 16) + (y >> 16) + (lsw >> 16); - return (msw << 16) | (lsw & 0xFFFF); + return ((x & 0xffffffff) + (y & 0xffffffff)) & 0xffffffff } /* diff --git a/worker/bomb-subtests/crypto-md5.js b/worker/bomb-subtests/crypto-md5.js index a93bedb..938081c 100644 --- a/worker/bomb-subtests/crypto-md5.js +++ b/worker/bomb-subtests/crypto-md5.js @@ -181,9 +181,7 @@ function core_hmac_md5(key, data) */ function safe_add(x, y) { - var lsw = (x & 0xFFFF) + (y & 0xFFFF); - var msw = (x >> 16) + (y >> 16) + (lsw >> 16); - return (msw << 16) | (lsw & 0xFFFF); + return ((x & 0xffffffff) + (y & 0xffffffff)) & 0xffffffff } /* diff --git a/worker/bomb-subtests/crypto-sha1.js b/worker/bomb-subtests/crypto-sha1.js index abea4b1..5cd0c5d 100644 --- a/worker/bomb-subtests/crypto-sha1.js +++ b/worker/bomb-subtests/crypto-sha1.js @@ -127,9 +127,7 @@ function core_hmac_sha1(key, data) */ function safe_add(x, y) { - var lsw = (x & 0xFFFF) + (y & 0xFFFF); - var msw = (x >> 16) + (y >> 16) + (lsw >> 16); - return (msw << 16) | (lsw & 0xFFFF); + return ((x & 0xffffffff) + (y & 0xffffffff)) & 0xffffffff } /*