X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2Fjs%2Fsjcl-bip39.js;h=447b565c3f7b46206afa00805a627a68a9f70cf2;hb=5b689bd6e77f047eff37e43f0ffa487cb59edc45;hp=537e3b814ef805f6b3ba692b183c84eb3c43412b;hpb=e66c8a9b5aade1c6b19c58e5366f777fde3f373f;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FBIP39.git diff --git a/src/js/sjcl-bip39.js b/src/js/sjcl-bip39.js index 537e3b8..447b565 100644 --- a/src/js/sjcl-bip39.js +++ b/src/js/sjcl-bip39.js @@ -26,13 +26,13 @@ var sjcl = { /** @namespace Key exchange functions. Right now only SRP is implemented. */ keyexchange: {}, - + /** @namespace Block cipher modes of operation. */ mode: {}, /** @namespace Miscellaneous. HMAC and PBKDF2. */ misc: {}, - + /** * @namespace Bit array encoders and decoders. * @@ -43,7 +43,7 @@ var sjcl = { * the method names are "fromBits" and "toBits". */ codec: {}, - + /** @namespace Exceptions. */ exception: { /** @constructor Ciphertext is corrupt. */ @@ -51,13 +51,13 @@ var sjcl = { this.toString = function() { return "CORRUPT: "+this.message; }; this.message = message; }, - + /** @constructor Invalid parameter. */ invalid: function(message) { this.toString = function() { return "INVALID: "+this.message; }; this.message = message; }, - + /** @constructor Bug or missing feature in SJCL. @constructor */ bug: function(message) { this.toString = function() { return "BUG: "+this.message; }; @@ -159,7 +159,7 @@ sjcl.bitArray = { if (a1.length === 0 || a2.length === 0) { return a1.concat(a2); } - + var last = a1[a1.length-1], shift = sjcl.bitArray.getPartial(last); if (shift === 32) { return a1.concat(a2); @@ -245,7 +245,7 @@ sjcl.bitArray = { _shiftRight: function (a, shift, carry, out) { var i, last2=0, shift2; if (out === undefined) { out = []; } - + for (; shift >= 32; shift -= 32) { out.push(carry); carry = 0; @@ -253,7 +253,7 @@ sjcl.bitArray = { if (shift === 0) { return out.concat(a); } - + for (i=0; i>>shift); carry = a[i] << (32-shift); @@ -263,7 +263,7 @@ sjcl.bitArray = { out.push(sjcl.bitArray.partial(shift+shift2 & 31, (shift + shift2 > 32) ? carry : out.pop(),1)); return out; }, - + /** xor a block of 4 words together. * @private */ @@ -295,7 +295,7 @@ sjcl.bitArray = { * @author Mike Hamburg * @author Dan Boneh */ - + /** @namespace UTF-8 strings */ sjcl.codec.utf8String = { /** Convert from a bitArray to a UTF-8 string. */ @@ -310,7 +310,7 @@ sjcl.codec.utf8String = { } return decodeURIComponent(escape(out)); }, - + /** Convert from a UTF-8 string to a bitArray. */ toBits: function (str) { str = unescape(encodeURIComponent(str)); @@ -412,7 +412,7 @@ sjcl.hash.sha512.prototype = { * @constant */ blockSize: 1024, - + /** * Reset the hash state. * @return this @@ -423,7 +423,7 @@ sjcl.hash.sha512.prototype = { this._length = 0; return this; }, - + /** * Input several words to the hash. * @param {bitArray|String} data the data to hash. @@ -441,7 +441,7 @@ sjcl.hash.sha512.prototype = { } return this; }, - + /** * Complete hashing and output the hash value. * @return {bitArray} The hash value, an array of 16 big-endian words. @@ -736,12 +736,12 @@ sjcl.misc.hmac = function (key, Hash) { if (key.length > bs) { key = Hash.hash(key); } - + for (i=0; i>>7 ^ a>>>18 ^ a>>>3 ^ a<<25 ^ a<<14) + + tmp = w[i&15] = ((a>>>7 ^ a>>>18 ^ a>>>3 ^ a<<25 ^ a<<14) + (b>>>17 ^ b>>>19 ^ b>>>10 ^ b<<15 ^ b<<13) + w[i&15] + w[(i+9) & 15]) | 0; } - + tmp = (tmp + h7 + (h4>>>6 ^ h4>>>11 ^ h4>>>25 ^ h4<<26 ^ h4<<21 ^ h4<<7) + (h6 ^ h4&(h5^h6)) + k[i]); // | 0; - + // shift register h7 = h6; h6 = h5; h5 = h4; h4 = h3 + tmp | 0;