mirror of
https://github.com/danog/fast-srp.git
synced 2024-11-26 20:04:49 +01:00
Fixup for node v0.12.7
This commit is contained in:
parent
c0b32d8e78
commit
99e62191dc
47
lib/jsbn.js
47
lib/jsbn.js
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Basic JavaScript BN library - subset useful for RSA encryption.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2003-2005 Tom Wu
|
||||
* All Rights Reserved.
|
||||
*
|
||||
@ -15,9 +15,9 @@
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
|
||||
@ -32,6 +32,12 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2015 Zarmack Tanen
|
||||
* Fixed .toString(16) to be compatible with node >0.12.7 because hexWrite()
|
||||
* only accepts %2=0 strings
|
||||
*
|
||||
*
|
||||
* Added Node.js Buffers support
|
||||
* 2014 rzcoder
|
||||
*/
|
||||
@ -112,7 +118,7 @@ function am3(i, x, w, j, c, n) {
|
||||
return c;
|
||||
}
|
||||
|
||||
// We need to select the fastest one that works in this environment.
|
||||
// We need to select the fastest one that works in this environment.
|
||||
//if (j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
|
||||
// BigInteger.prototype.am = am2;
|
||||
// dbits = 30;
|
||||
@ -286,8 +292,9 @@ function bnToString(b) {
|
||||
if (m) r += int2char(d);
|
||||
}
|
||||
}
|
||||
if(r.length == 1)
|
||||
r = '0' + r;
|
||||
//! Fix to be compatible with node >0.12.7 Buffer.js
|
||||
if(b == 16 && r.length % 2 != 0)
|
||||
r = "0" + r;
|
||||
return m ? r : "0";
|
||||
}
|
||||
|
||||
@ -314,6 +321,27 @@ function bnCompareTo(a) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function bnEqual(a) {
|
||||
console.log(this.compareTo(a));
|
||||
return (this.compareTo(a) == 0) ? true: false;
|
||||
}
|
||||
|
||||
function bnGreater(a) {
|
||||
return (this.compareTo(a) > 0) ? true : false;
|
||||
}
|
||||
|
||||
function bnGreaterOrEqual(a) {
|
||||
return (this.compareTo(a) > 0) ? true : false;
|
||||
}
|
||||
|
||||
function bnLesser(a) {
|
||||
return (this.compareTo(a) < 0) ? true : false;
|
||||
}
|
||||
|
||||
function bnLesserOrEqual(a) {
|
||||
return (this.compareTo(a) <= 0) ? true : false;
|
||||
}
|
||||
|
||||
// returns bit length of the integer x
|
||||
function nbits(x) {
|
||||
var r = 1, t;
|
||||
@ -1495,6 +1523,11 @@ BigInteger.prototype.signum = bnSigNum;
|
||||
BigInteger.prototype.toByteArray = bnToByteArray;
|
||||
BigInteger.prototype.toBuffer = bnToBuffer;
|
||||
BigInteger.prototype.equals = bnEquals;
|
||||
BigInteger.prototype.eq = bnEqual;
|
||||
BigInteger.prototype.gt = bnGreater;
|
||||
BigInteger.prototype.gte = bnGreaterOrEqual;
|
||||
BigInteger.prototype.lt = bnLesser;
|
||||
BigInteger.prototype.lte = bnLesserOrEqual;
|
||||
BigInteger.prototype.min = bnMin;
|
||||
BigInteger.prototype.max = bnMax;
|
||||
BigInteger.prototype.and = bnAnd;
|
||||
|
Loading…
Reference in New Issue
Block a user