From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- js/src/tests/js1_5/Regress/regress-452008.js | 151 +++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 js/src/tests/js1_5/Regress/regress-452008.js (limited to 'js/src/tests/js1_5/Regress/regress-452008.js') diff --git a/js/src/tests/js1_5/Regress/regress-452008.js b/js/src/tests/js1_5/Regress/regress-452008.js new file mode 100644 index 000000000..8c278a033 --- /dev/null +++ b/js/src/tests/js1_5/Regress/regress-452008.js @@ -0,0 +1,151 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 452008; +var summary = 'Bad math with JIT'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + +// regression test for Bug 452008 - TM: SRP in Clipperz crypto library fails when JIT (TraceMonkey) is enabled. + + var x = [9385, 32112, 25383, 16317, 30138, 14565, 17812, 24500, 2719, 30174, 3546, 9096, 15352, 19120, 20648, 14334, 7426, 0, 0, 0]; + var n = [27875, 25925, 30422, 12227, 27798, 32170, 10873, 21748, 30629, 26296, 20697, 5125, 4815, 2221, 14392, 23369, 5560, 2, 0, 0]; + var np = 18229; + var expected = [18770, 31456, 17999, 32635, 27508, 29131, 2856, 16233, 5439, 27580, 7093, 18192, 30804, 5472, 8529, 28649, 14852, 0, 0, 0]; + +//globals + bpe=0; //bits stored per array element + mask=0; //AND this with an array element to chop it down to bpe bits + +//initialize the global variables + for (bpe=0; (1<<(bpe+1)) > (1<>=1; //bpe=number of bits in one element of the array representing the bigInt + mask=(1<>=bpe; + } + } + +//is x > y? (x and y both nonnegative) + function greater(x,y) { + var i; + var k=(x.length=0;i--) + if (x[i]>y[i]) + return 1; + else if (x[i]0 && n[kn-1]==0;kn--); //ignore leading zeros of n + for (;ky>0 && y[ky-1]==0;ky--); //ignore leading zeros of y + + copyInt_(sa,0); + + //the following loop consumes 95% of the runtime for randTruePrime_() and powMod_() for large keys + for (i=0; i> bpe; + t=x[i]; + + //do sa=(sa+x[i]*y+ui*n)/b where b=2**bpe + for (j=1;j>=bpe; + } + for (;j>=bpe; + } + sa[j-1]=c & mask; + } + + if (!greater(n,sa)) + sub_(sa,n); + copy_(x,sa); + } + + mont_(x, x, n, np); + + var passed = expected.length == x.length; + for (var i = 0; i < expected.length; i++) { + if (passed) + passed = expected[i] == x[i]; + } + print(passed); + + + expect = true; + actual = passed; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} -- cgit v1.2.3