diff --git a/resources/openpgp.js b/resources/openpgp.js index ad271240..bcc8ba58 100644 --- a/resources/openpgp.js +++ b/resources/openpgp.js @@ -3927,7 +3927,7 @@ function openpgp_config() { keyserver: "keyserver.linux.it" // "pgp.mit.edu:11371" }; - this.versionstring ="OpenPGP.js v.1.20120827"; + this.versionstring ="OpenPGP.js v.1.20120904"; this.commentstring ="http://openpgpjs.org"; /** * reads the config out of the HTML5 local storage @@ -5921,2184 +5921,6 @@ JXG.Util.genUUID = function() { return uuid.join(''); }; -/* - Copyright (c) 2012 Gildas Lormeau. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution. - - 3. The names of the authors may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, - INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -(function(obj) { - - obj.zip = { - useWebWorkers : false - }; - -})(this); - -// include inflate.js - -/* - * zip.js and include.js are merged in one file because of a dependency in the - * execution order: zip.Inflater is only defined if inflate.js is executed after zip.js - */ - -(function(obj) { - - // Global - var MAX_BITS = 15; - - var Z_OK = 0; - var Z_STREAM_END = 1; - var Z_NEED_DICT = 2; - var Z_STREAM_ERROR = -2; - var Z_DATA_ERROR = -3; - var Z_MEM_ERROR = -4; - var Z_BUF_ERROR = -5; - - var inflate_mask = [ 0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, - 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff ]; - - var MANY = 1440; - - var MAX_WBITS = 15; // 32K LZ77 window - var DEF_WBITS = MAX_WBITS; - - // JZlib version : "1.0.2" - var Z_NO_FLUSH = 0; - var Z_FINISH = 4; - - // InfTree - var fixed_bl = 9; - var fixed_bd = 5; - - var fixed_tl = [ 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 192, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 160, 0, 8, 0, - 0, 8, 128, 0, 8, 64, 0, 9, 224, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 144, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 208, 81, 7, 17, 0, 8, 104, 0, 8, 40, - 0, 9, 176, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 240, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 200, 81, 7, 13, - 0, 8, 100, 0, 8, 36, 0, 9, 168, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 232, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 152, 84, 7, 83, 0, 8, 124, 0, 8, 60, - 0, 9, 216, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 184, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 248, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, - 35, 0, 8, 114, 0, 8, 50, 0, 9, 196, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 164, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 228, 80, 7, 7, 0, 8, 90, 0, 8, - 26, 0, 9, 148, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 212, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 180, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 244, 80, - 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 204, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 172, 0, 8, 6, 0, 8, 134, 0, - 8, 70, 0, 9, 236, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 156, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 220, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 188, 0, - 8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 252, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 194, 80, 7, 10, 0, 8, 97, - 0, 8, 33, 0, 9, 162, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 226, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 146, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 210, - 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 178, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 242, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, - 0, 8, 53, 0, 9, 202, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 170, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 234, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 154, - 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 218, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 186, 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 250, 80, 7, 3, 0, 8, 83, - 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 198, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 166, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 230, - 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 150, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 214, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 182, 0, 8, 11, 0, 8, 139, - 0, 8, 75, 0, 9, 246, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 206, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 174, - 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 238, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 158, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 222, 82, 7, 27, 0, 8, 111, - 0, 8, 47, 0, 9, 190, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 254, 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, - 193, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 161, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 225, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 145, 83, 7, 59, 0, 8, - 120, 0, 8, 56, 0, 9, 209, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 177, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 241, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, - 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 201, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 169, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 233, 80, 7, 8, 0, 8, - 92, 0, 8, 28, 0, 9, 153, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 217, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 185, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, - 249, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 197, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 165, 0, 8, 2, 0, 8, - 130, 0, 8, 66, 0, 9, 229, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 149, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 213, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, - 181, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 245, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 205, 81, 7, 15, 0, 8, - 102, 0, 8, 38, 0, 9, 173, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 237, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 157, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, - 221, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 189, 0, 8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 253, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, - 8, 113, 0, 8, 49, 0, 9, 195, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 163, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 227, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, - 147, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 211, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 179, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 243, 80, 7, 4, 0, 8, - 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 203, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 171, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, - 235, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 155, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 219, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 187, 0, 8, 13, 0, 8, - 141, 0, 8, 77, 0, 9, 251, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 199, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, - 167, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 231, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 151, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 215, 82, 7, 19, 0, 8, - 107, 0, 8, 43, 0, 9, 183, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 247, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, - 207, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 175, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 239, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 159, 84, 7, 99, 0, 8, - 127, 0, 8, 63, 0, 9, 223, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 191, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 255 ]; - var fixed_td = [ 80, 5, 1, 87, 5, 257, 83, 5, 17, 91, 5, 4097, 81, 5, 5, 89, 5, 1025, 85, 5, 65, 93, 5, 16385, 80, 5, 3, 88, 5, 513, 84, 5, 33, 92, 5, - 8193, 82, 5, 9, 90, 5, 2049, 86, 5, 129, 192, 5, 24577, 80, 5, 2, 87, 5, 385, 83, 5, 25, 91, 5, 6145, 81, 5, 7, 89, 5, 1537, 85, 5, 97, 93, 5, - 24577, 80, 5, 4, 88, 5, 769, 84, 5, 49, 92, 5, 12289, 82, 5, 13, 90, 5, 3073, 86, 5, 193, 192, 5, 24577 ]; - - // Tables for deflate from PKZIP's appnote.txt. - var cplens = [ // Copy lengths for literal codes 257..285 - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 ]; - - // see note #13 above about 258 - var cplext = [ // Extra bits for literal codes 257..285 - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112 // 112==invalid - ]; - - var cpdist = [ // Copy offsets for distance codes 0..29 - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 ]; - - var cpdext = [ // Extra bits for distance codes - 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 ]; - - // If BMAX needs to be larger than 16, then h and x[] should be uLong. - var BMAX = 15; // maximum bit length of any code - - function InfTree() { - var that = this; - - var hn; // hufts used in space - var v; // work area for huft_build - var c; // bit length count table - var r; // table entry for structure assignment - var u; // table stack - var x; // bit offsets, then code stack - - function huft_build(b, // code lengths in bits (all assumed <= - // BMAX) - bindex, n, // number of codes (assumed <= 288) - s, // number of simple-valued codes (0..s-1) - d, // list of base values for non-simple codes - e, // list of extra bits for non-simple codes - t, // result: starting table - m, // maximum lookup bits, returns actual - hp,// space for trees - hn,// hufts used in space - v // working area: values in order of bit length - ) { - // Given a list of code lengths and a maximum table size, make a set of - // tables to decode that set of codes. Return Z_OK on success, - // Z_BUF_ERROR - // if the given code set is incomplete (the tables are still built in - // this - // case), Z_DATA_ERROR if the input is invalid (an over-subscribed set - // of - // lengths), or Z_MEM_ERROR if not enough memory. - - var a; // counter for codes of length k - var f; // i repeats in table every f entries - var g; // maximum code length - var h; // table level - var i; // counter, current code - var j; // counter - var k; // number of bits in current code - var l; // bits per table (returned in m) - var mask; // (1 << w) - 1, to avoid cc -O bug on HP - var p; // pointer into c[], b[], or v[] - var q; // points to current table - var w; // bits before this table == (l * h) - var xp; // pointer into x - var y; // number of dummy codes added - var z; // number of entries in current table - - // Generate counts for each bit length - - p = 0; - i = n; - do { - c[b[bindex + p]]++; - p++; - i--; // assume all entries <= BMAX - } while (i !== 0); - - if (c[0] == n) { // null input--all zero length codes - t[0] = -1; - m[0] = 0; - return Z_OK; - } - - // Find minimum and maximum length, bound *m by those - l = m[0]; - for (j = 1; j <= BMAX; j++) - if (c[j] !== 0) - break; - k = j; // minimum code length - if (l < j) { - l = j; - } - for (i = BMAX; i !== 0; i--) { - if (c[i] !== 0) - break; - } - g = i; // maximum code length - if (l > i) { - l = i; - } - m[0] = l; - - // Adjust last length count to fill out codes, if needed - for (y = 1 << j; j < i; j++, y <<= 1) { - if ((y -= c[j]) < 0) { - return Z_DATA_ERROR; - } - } - if ((y -= c[i]) < 0) { - return Z_DATA_ERROR; - } - c[i] += y; - - // Generate starting offsets into the value table for each length - x[1] = j = 0; - p = 1; - xp = 2; - while (--i !== 0) { // note that i == g from above - x[xp] = (j += c[p]); - xp++; - p++; - } - - // Make a table of values in order of bit lengths - i = 0; - p = 0; - do { - if ((j = b[bindex + p]) !== 0) { - v[x[j]++] = i; - } - p++; - } while (++i < n); - n = x[g]; // set n to length of v - - // Generate the Huffman codes and for each, make the table entries - x[0] = i = 0; // first Huffman code is zero - p = 0; // grab values in bit order - h = -1; // no tables yet--level -1 - w = -l; // bits decoded == (l * h) - u[0] = 0; // just to keep compilers happy - q = 0; // ditto - z = 0; // ditto - - // go through the bit lengths (k already is bits in shortest code) - for (; k <= g; k++) { - a = c[k]; - while (a-- !== 0) { - // here i is the Huffman code of length k bits for value *p - // make tables up to required level - while (k > w + l) { - h++; - w += l; // previous table always l bits - // compute minimum size table less than or equal to l bits - z = g - w; - z = (z > l) ? l : z; // table size upper limit - if ((f = 1 << (j = k - w)) > a + 1) { // try a k-w bit table - // too few codes for - // k-w bit table - f -= a + 1; // deduct codes from patterns left - xp = k; - if (j < z) { - while (++j < z) { // try smaller tables up to z bits - if ((f <<= 1) <= c[++xp]) - break; // enough codes to use up j bits - f -= c[xp]; // else deduct codes from patterns - } - } - } - z = 1 << j; // table entries for j-bit table - - // allocate new table - if (hn[0] + z > MANY) { // (note: doesn't matter for fixed) - return Z_DATA_ERROR; // overflow of MANY - } - u[h] = q = /* hp+ */hn[0]; // DEBUG - hn[0] += z; - - // connect to last table, if there is one - if (h !== 0) { - x[h] = i; // save pattern for backing up - r[0] = /* (byte) */j; // bits in this table - r[1] = /* (byte) */l; // bits to dump before this table - j = i >>> (w - l); - r[2] = /* (int) */(q - u[h - 1] - j); // offset to this table - hp.set(r, (u[h - 1] + j) * 3); - // to - // last - // table - } else { - t[0] = q; // first table is returned result - } - } - - // set up table entry in r - r[1] = /* (byte) */(k - w); - if (p >= n) { - r[0] = 128 + 64; // out of values--invalid code - } else if (v[p] < s) { - r[0] = /* (byte) */(v[p] < 256 ? 0 : 32 + 64); // 256 is - // end-of-block - r[2] = v[p++]; // simple code is just the value - } else { - r[0] = /* (byte) */(e[v[p] - s] + 16 + 64); // non-simple--look - // up in lists - r[2] = d[v[p++] - s]; - } - - // fill code-like entries with r - f = 1 << (k - w); - for (j = i >>> w; j < z; j += f) { - hp.set(r, (q + j) * 3); - } - - // backwards increment the k-bit code i - for (j = 1 << (k - 1); (i & j) !== 0; j >>>= 1) { - i ^= j; - } - i ^= j; - - // backup over finished tables - mask = (1 << w) - 1; // needed on HP, cc -O bug - while ((i & mask) != x[h]) { - h--; // don't need to update q - w -= l; - mask = (1 << w) - 1; - } - } - } - // Return Z_BUF_ERROR if we were given an incomplete table - return y !== 0 && g != 1 ? Z_BUF_ERROR : Z_OK; - } - - function initWorkArea(vsize) { - var i; - if (!hn) { - hn = []; // []; //new Array(1); - v = []; // new Array(vsize); - c = new Int32Array(BMAX + 1); // new Array(BMAX + 1); - r = []; // new Array(3); - u = new Int32Array(BMAX); // new Array(BMAX); - x = new Int32Array(BMAX + 1); // new Array(BMAX + 1); - } - if (v.length < vsize) { - v = []; // new Array(vsize); - } - for (i = 0; i < vsize; i++) { - v[i] = 0; - } - for (i = 0; i < BMAX + 1; i++) { - c[i] = 0; - } - for (i = 0; i < 3; i++) { - r[i] = 0; - } - // for(int i=0; i 257)) { - if (result == Z_DATA_ERROR) { - z.msg = "oversubscribed distance tree"; - } else if (result == Z_BUF_ERROR) { - z.msg = "incomplete distance tree"; - result = Z_DATA_ERROR; - } else if (result != Z_MEM_ERROR) { - z.msg = "empty distance tree with lengths"; - result = Z_DATA_ERROR; - } - return result; - } - - return Z_OK; - }; - - } - - InfTree.inflate_trees_fixed = function(bl, // literal desired/actual bit depth - bd, // distance desired/actual bit depth - tl,// literal/length tree result - td,// distance tree result - z // for memory allocation - ) { - bl[0] = fixed_bl; - bd[0] = fixed_bd; - tl[0] = fixed_tl; - td[0] = fixed_td; - return Z_OK; - }; - - // InfCodes - - // waiting for "i:"=input, - // "o:"=output, - // "x:"=nothing - var START = 0; // x: set up for LEN - var LEN = 1; // i: get length/literal/eob next - var LENEXT = 2; // i: getting length extra (have base) - var DIST = 3; // i: get distance next - var DISTEXT = 4;// i: getting distance extra - var COPY = 5; // o: copying bytes in window, waiting - // for space - var LIT = 6; // o: got literal, waiting for output - // space - var WASH = 7; // o: got eob, possibly still output - // waiting - var END = 8; // x: got eob and all data flushed - var BADCODE = 9;// x: got error - - function InfCodes() { - var that = this; - - var mode; // current inflate_codes mode - - // mode dependent information - var len = 0; - - var tree; // pointer into tree - var tree_index = 0; - var need = 0; // bits needed - - var lit = 0; - - // if EXT or COPY, where and how much - var get = 0; // bits to get for extra - var dist = 0; // distance back to copy from - - var lbits = 0; // ltree bits decoded per branch - var dbits = 0; // dtree bits decoder per branch - var ltree; // literal/length/eob tree - var ltree_index = 0; // literal/length/eob tree - var dtree; // distance tree - var dtree_index = 0; // distance tree - - // Called with number of bytes left to write in window at least 258 - // (the maximum string length) and number of input bytes available - // at least ten. The ten bytes are six bytes for the longest length/ - // distance pair plus four bytes for overloading the bit buffer. - - function inflate_fast(bl, bd, tl, tl_index, td, td_index, s, z) { - var t; // temporary pointer - var tp; // temporary pointer - var tp_index; // temporary pointer - var e; // extra bits or operation - var b; // bit buffer - var k; // bits in bit buffer - var p; // input data pointer - var n; // bytes available there - var q; // output window write pointer - var m; // bytes to end of window or read pointer - var ml; // mask for literal/length tree - var md; // mask for distance tree - var c; // bytes to copy - var d; // distance back to copy from - var r; // copy source pointer - - var tp_index_t_3; // (tp_index+t)*3 - - // load input, output, bit values - p = z.next_in_index; - n = z.avail_in; - b = s.bitb; - k = s.bitk; - q = s.write; - m = q < s.read ? s.read - q - 1 : s.end - q; - - // initialize masks - ml = inflate_mask[bl]; - md = inflate_mask[bd]; - - // do until not enough input or output space for fast loop - do { // assume called with m >= 258 && n >= 10 - // get literal/length code - while (k < (20)) { // max bits for literal/length code - n--; - b |= (z.read_byte(p++) & 0xff) << k; - k += 8; - } - - t = b & ml; - tp = tl; - tp_index = tl_index; - tp_index_t_3 = (tp_index + t) * 3; - if ((e = tp[tp_index_t_3]) === 0) { - b >>= (tp[tp_index_t_3 + 1]); - k -= (tp[tp_index_t_3 + 1]); - - s.window[q++] = /* (byte) */tp[tp_index_t_3 + 2]; - m--; - continue; - } - do { - - b >>= (tp[tp_index_t_3 + 1]); - k -= (tp[tp_index_t_3 + 1]); - - if ((e & 16) !== 0) { - e &= 15; - c = tp[tp_index_t_3 + 2] + (/* (int) */b & inflate_mask[e]); - - b >>= e; - k -= e; - - // decode distance base of block to copy - while (k < (15)) { // max bits for distance code - n--; - b |= (z.read_byte(p++) & 0xff) << k; - k += 8; - } - - t = b & md; - tp = td; - tp_index = td_index; - tp_index_t_3 = (tp_index + t) * 3; - e = tp[tp_index_t_3]; - - do { - - b >>= (tp[tp_index_t_3 + 1]); - k -= (tp[tp_index_t_3 + 1]); - - if ((e & 16) !== 0) { - // get extra bits to add to distance base - e &= 15; - while (k < (e)) { // get extra bits (up to 13) - n--; - b |= (z.read_byte(p++) & 0xff) << k; - k += 8; - } - - d = tp[tp_index_t_3 + 2] + (b & inflate_mask[e]); - - b >>= (e); - k -= (e); - - // do the copy - m -= c; - if (q >= d) { // offset before dest - // just copy - r = q - d; - if (q - r > 0 && 2 > (q - r)) { - s.window[q++] = s.window[r++]; // minimum - // count is - // three, - s.window[q++] = s.window[r++]; // so unroll - // loop a - // little - c -= 2; - } else { - s.window.set(s.window.subarray(r, r + 2), q); - q += 2; - r += 2; - c -= 2; - } - } else { // else offset after destination - r = q - d; - do { - r += s.end; // force pointer in window - } while (r < 0); // covers invalid distances - e = s.end - r; - if (c > e) { // if source crosses, - c -= e; // wrapped copy - if (q - r > 0 && e > (q - r)) { - do { - s.window[q++] = s.window[r++]; - } while (--e !== 0); - } else { - s.window.set(s.window.subarray(r, r + e), q); - q += e; - r += e; - e = 0; - } - r = 0; // copy rest from start of window - } - - } - - // copy all or what's left - if (q - r > 0 && c > (q - r)) { - do { - s.window[q++] = s.window[r++]; - } while (--c !== 0); - } else { - s.window.set(s.window.subarray(r, r + c), q); - q += c; - r += c; - c = 0; - } - break; - } else if ((e & 64) === 0) { - t += tp[tp_index_t_3 + 2]; - t += (b & inflate_mask[e]); - tp_index_t_3 = (tp_index + t) * 3; - e = tp[tp_index_t_3]; - } else { - z.msg = "invalid distance code"; - - c = z.avail_in - n; - c = (k >> 3) < c ? k >> 3 : c; - n += c; - p -= c; - k -= c << 3; - - s.bitb = b; - s.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - s.write = q; - - return Z_DATA_ERROR; - } - } while (true); - break; - } - - if ((e & 64) === 0) { - t += tp[tp_index_t_3 + 2]; - t += (b & inflate_mask[e]); - tp_index_t_3 = (tp_index + t) * 3; - if ((e = tp[tp_index_t_3]) === 0) { - - b >>= (tp[tp_index_t_3 + 1]); - k -= (tp[tp_index_t_3 + 1]); - - s.window[q++] = /* (byte) */tp[tp_index_t_3 + 2]; - m--; - break; - } - } else if ((e & 32) !== 0) { - - c = z.avail_in - n; - c = (k >> 3) < c ? k >> 3 : c; - n += c; - p -= c; - k -= c << 3; - - s.bitb = b; - s.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - s.write = q; - - return Z_STREAM_END; - } else { - z.msg = "invalid literal/length code"; - - c = z.avail_in - n; - c = (k >> 3) < c ? k >> 3 : c; - n += c; - p -= c; - k -= c << 3; - - s.bitb = b; - s.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - s.write = q; - - return Z_DATA_ERROR; - } - } while (true); - } while (m >= 258 && n >= 10); - - // not enough input or output--restore pointers and return - c = z.avail_in - n; - c = (k >> 3) < c ? k >> 3 : c; - n += c; - p -= c; - k -= c << 3; - - s.bitb = b; - s.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - s.write = q; - - return Z_OK; - } - - that.init = function(bl, bd, tl, tl_index, td, td_index, z) { - mode = START; - lbits = /* (byte) */bl; - dbits = /* (byte) */bd; - ltree = tl; - ltree_index = tl_index; - dtree = td; - dtree_index = td_index; - tree = null; - }; - - that.proc = function(s, z, r) { - var j; // temporary storage - var t; // temporary pointer - var tindex; // temporary pointer - var e; // extra bits or operation - var b = 0; // bit buffer - var k = 0; // bits in bit buffer - var p = 0; // input data pointer - var n; // bytes available there - var q; // output window write pointer - var m; // bytes to end of window or read pointer - var f; // pointer to copy strings from - - // copy input/output information to locals (UPDATE macro restores) - p = z.next_in_index; - n = z.avail_in; - b = s.bitb; - k = s.bitk; - q = s.write; - m = q < s.read ? s.read - q - 1 : s.end - q; - - // process input and output based on current state - while (true) { - switch (mode) { - // waiting for "i:"=input, "o:"=output, "x:"=nothing - case START: // x: set up for LEN - if (m >= 258 && n >= 10) { - - s.bitb = b; - s.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - s.write = q; - r = inflate_fast(lbits, dbits, ltree, ltree_index, dtree, dtree_index, s, z); - - p = z.next_in_index; - n = z.avail_in; - b = s.bitb; - k = s.bitk; - q = s.write; - m = q < s.read ? s.read - q - 1 : s.end - q; - - if (r != Z_OK) { - mode = r == Z_STREAM_END ? WASH : BADCODE; - break; - } - } - need = lbits; - tree = ltree; - tree_index = ltree_index; - - mode = LEN; - case LEN: // i: get length/literal/eob next - j = need; - - while (k < (j)) { - if (n !== 0) - r = Z_OK; - else { - - s.bitb = b; - s.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - } - n--; - b |= (z.read_byte(p++) & 0xff) << k; - k += 8; - } - - tindex = (tree_index + (b & inflate_mask[j])) * 3; - - b >>>= (tree[tindex + 1]); - k -= (tree[tindex + 1]); - - e = tree[tindex]; - - if (e === 0) { // literal - lit = tree[tindex + 2]; - mode = LIT; - break; - } - if ((e & 16) !== 0) { // length - get = e & 15; - len = tree[tindex + 2]; - mode = LENEXT; - break; - } - if ((e & 64) === 0) { // next table - need = e; - tree_index = tindex / 3 + tree[tindex + 2]; - break; - } - if ((e & 32) !== 0) { // end of block - mode = WASH; - break; - } - mode = BADCODE; // invalid code - z.msg = "invalid literal/length code"; - r = Z_DATA_ERROR; - - s.bitb = b; - s.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - - case LENEXT: // i: getting length extra (have base) - j = get; - - while (k < (j)) { - if (n !== 0) - r = Z_OK; - else { - - s.bitb = b; - s.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - } - n--; - b |= (z.read_byte(p++) & 0xff) << k; - k += 8; - } - - len += (b & inflate_mask[j]); - - b >>= j; - k -= j; - - need = dbits; - tree = dtree; - tree_index = dtree_index; - mode = DIST; - case DIST: // i: get distance next - j = need; - - while (k < (j)) { - if (n !== 0) - r = Z_OK; - else { - - s.bitb = b; - s.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - } - n--; - b |= (z.read_byte(p++) & 0xff) << k; - k += 8; - } - - tindex = (tree_index + (b & inflate_mask[j])) * 3; - - b >>= tree[tindex + 1]; - k -= tree[tindex + 1]; - - e = (tree[tindex]); - if ((e & 16) !== 0) { // distance - get = e & 15; - dist = tree[tindex + 2]; - mode = DISTEXT; - break; - } - if ((e & 64) === 0) { // next table - need = e; - tree_index = tindex / 3 + tree[tindex + 2]; - break; - } - mode = BADCODE; // invalid code - z.msg = "invalid distance code"; - r = Z_DATA_ERROR; - - s.bitb = b; - s.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - - case DISTEXT: // i: getting distance extra - j = get; - - while (k < (j)) { - if (n !== 0) - r = Z_OK; - else { - - s.bitb = b; - s.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - } - n--; - b |= (z.read_byte(p++) & 0xff) << k; - k += 8; - } - - dist += (b & inflate_mask[j]); - - b >>= j; - k -= j; - - mode = COPY; - case COPY: // o: copying bytes in window, waiting for space - f = q - dist; - while (f < 0) { // modulo window size-"while" instead - f += s.end; // of "if" handles invalid distances - } - while (len !== 0) { - - if (m === 0) { - if (q == s.end && s.read !== 0) { - q = 0; - m = q < s.read ? s.read - q - 1 : s.end - q; - } - if (m === 0) { - s.write = q; - r = s.inflate_flush(z, r); - q = s.write; - m = q < s.read ? s.read - q - 1 : s.end - q; - - if (q == s.end && s.read !== 0) { - q = 0; - m = q < s.read ? s.read - q - 1 : s.end - q; - } - - if (m === 0) { - s.bitb = b; - s.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - } - } - } - - s.window[q++] = s.window[f++]; - m--; - - if (f == s.end) - f = 0; - len--; - } - mode = START; - break; - case LIT: // o: got literal, waiting for output space - if (m === 0) { - if (q == s.end && s.read !== 0) { - q = 0; - m = q < s.read ? s.read - q - 1 : s.end - q; - } - if (m === 0) { - s.write = q; - r = s.inflate_flush(z, r); - q = s.write; - m = q < s.read ? s.read - q - 1 : s.end - q; - - if (q == s.end && s.read !== 0) { - q = 0; - m = q < s.read ? s.read - q - 1 : s.end - q; - } - if (m === 0) { - s.bitb = b; - s.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - } - } - } - r = Z_OK; - - s.window[q++] = /* (byte) */lit; - m--; - - mode = START; - break; - case WASH: // o: got eob, possibly more output - if (k > 7) { // return unused byte, if any - k -= 8; - n++; - p--; // can always return one - } - - s.write = q; - r = s.inflate_flush(z, r); - q = s.write; - m = q < s.read ? s.read - q - 1 : s.end - q; - - if (s.read != s.write) { - s.bitb = b; - s.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - } - mode = END; - case END: - r = Z_STREAM_END; - s.bitb = b; - s.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - - case BADCODE: // x: got error - - r = Z_DATA_ERROR; - - s.bitb = b; - s.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - - default: - r = Z_STREAM_ERROR; - - s.bitb = b; - s.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - s.write = q; - return s.inflate_flush(z, r); - } - } - }; - - that.free = function(z) { - // ZFREE(z, c); - }; - - } - - // InfBlocks - - // Table for deflate from PKZIP's appnote.txt. - var border = [ // Order of the bit length code lengths - 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]; - - var TYPE = 0; // get type bits (3, including end bit) - var LENS = 1; // get lengths for stored - var STORED = 2;// processing stored block - var TABLE = 3; // get table lengths - var BTREE = 4; // get bit lengths tree for a dynamic - // block - var DTREE = 5; // get length, distance trees for a - // dynamic block - var CODES = 6; // processing fixed or dynamic block - var DRY = 7; // output remaining window bytes - var DONELOCKS = 8; // finished last block, done - var BADBLOCKS = 9; // ot a data error--stuck here - - function InfBlocks(z, w) { - var that = this; - - var mode = TYPE; // current inflate_block mode - - var left = 0; // if STORED, bytes left to copy - - var table = 0; // table lengths (14 bits) - var index = 0; // index into blens (or border) - var blens; // bit lengths of codes - var bb = [ 0 ]; // bit length tree depth - var tb = [ 0 ]; // bit length decoding tree - - var codes = new InfCodes(); // if CODES, current state - - var last = 0; // true if this block is the last block - - var hufts = new Int32Array(MANY * 3); // single malloc for tree space - var check = 0; // check on output - var inftree = new InfTree(); - - that.bitk = 0; // bits in bit buffer - that.bitb = 0; // bit buffer - that.window = new Uint8Array(w); // sliding window - that.end = w; // one byte after sliding window - that.read = 0; // window read pointer - that.write = 0; // window write pointer - - that.reset = function(z, c) { - if (c) - c[0] = check; - // if (mode == BTREE || mode == DTREE) { - // } - if (mode == CODES) { - codes.free(z); - } - mode = TYPE; - that.bitk = 0; - that.bitb = 0; - that.read = that.write = 0; - }; - - that.reset(z, null); - - // copy as much as possible from the sliding window to the output area - that.inflate_flush = function(z, r) { - var n; - var p; - var q; - - // local copies of source and destination pointers - p = z.next_out_index; - q = that.read; - - // compute number of bytes to copy as far as end of window - n = /* (int) */((q <= that.write ? that.write : that.end) - q); - if (n > z.avail_out) - n = z.avail_out; - if (n !== 0 && r == Z_BUF_ERROR) - r = Z_OK; - - // update counters - z.avail_out -= n; - z.total_out += n; - - // copy as far as end of window - z.next_out.set(that.window.subarray(q, q + n), p); - p += n; - q += n; - - // see if more to copy at beginning of window - if (q == that.end) { - // wrap pointers - q = 0; - if (that.write == that.end) - that.write = 0; - - // compute bytes to copy - n = that.write - q; - if (n > z.avail_out) - n = z.avail_out; - if (n !== 0 && r == Z_BUF_ERROR) - r = Z_OK; - - // update counters - z.avail_out -= n; - z.total_out += n; - - // copy - z.next_out.set(that.window.subarray(q, q + n), p); - p += n; - q += n; - } - - // update pointers - z.next_out_index = p; - that.read = q; - - // done - return r; - }; - - that.proc = function(z, r) { - var t; // temporary storage - var b; // bit buffer - var k; // bits in bit buffer - var p; // input data pointer - var n; // bytes available there - var q; // output window write pointer - var m; // bytes to end of window or read pointer - - var i; - - // copy input/output information to locals (UPDATE macro restores) - // { - p = z.next_in_index; - n = z.avail_in; - b = that.bitb; - k = that.bitk; - // } - // { - q = that.write; - m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); - // } - - // process input based on current state - // DEBUG dtree - while (true) { - switch (mode) { - case TYPE: - - while (k < (3)) { - if (n !== 0) { - r = Z_OK; - } else { - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - return that.inflate_flush(z, r); - } - n--; - b |= (z.read_byte(p++) & 0xff) << k; - k += 8; - } - t = /* (int) */(b & 7); - last = t & 1; - - switch (t >>> 1) { - case 0: // stored - // { - b >>>= (3); - k -= (3); - // } - t = k & 7; // go to byte boundary - - // { - b >>>= (t); - k -= (t); - // } - mode = LENS; // get length of stored block - break; - case 1: // fixed - // { - var bl = []; // new Array(1); - var bd = []; // new Array(1); - var tl = [ [] ]; // new Array(1); - var td = [ [] ]; // new Array(1); - - InfTree.inflate_trees_fixed(bl, bd, tl, td, z); - codes.init(bl[0], bd[0], tl[0], 0, td[0], 0, z); - // } - - // { - b >>>= (3); - k -= (3); - // } - - mode = CODES; - break; - case 2: // dynamic - - // { - b >>>= (3); - k -= (3); - // } - - mode = TABLE; - break; - case 3: // illegal - - // { - b >>>= (3); - k -= (3); - // } - mode = BADBLOCKS; - z.msg = "invalid block type"; - r = Z_DATA_ERROR; - - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - return that.inflate_flush(z, r); - } - break; - case LENS: - - while (k < (32)) { - if (n !== 0) { - r = Z_OK; - } else { - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - return that.inflate_flush(z, r); - } - n--; - b |= (z.read_byte(p++) & 0xff) << k; - k += 8; - } - - if ((((~b) >>> 16) & 0xffff) != (b & 0xffff)) { - mode = BADBLOCKS; - z.msg = "invalid stored block lengths"; - r = Z_DATA_ERROR; - - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - return that.inflate_flush(z, r); - } - left = (b & 0xffff); - b = k = 0; // dump bits - mode = left !== 0 ? STORED : (last !== 0 ? DRY : TYPE); - break; - case STORED: - if (n === 0) { - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - return that.inflate_flush(z, r); - } - - if (m === 0) { - if (q == that.end && that.read !== 0) { - q = 0; - m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); - } - if (m === 0) { - that.write = q; - r = that.inflate_flush(z, r); - q = that.write; - m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); - if (q == that.end && that.read !== 0) { - q = 0; - m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); - } - if (m === 0) { - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - return that.inflate_flush(z, r); - } - } - } - r = Z_OK; - - t = left; - if (t > n) - t = n; - if (t > m) - t = m; - that.window.set(z.read_buf(p, t), q); - p += t; - n -= t; - q += t; - m -= t; - if ((left -= t) !== 0) - break; - mode = last !== 0 ? DRY : TYPE; - break; - case TABLE: - - while (k < (14)) { - if (n !== 0) { - r = Z_OK; - } else { - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - return that.inflate_flush(z, r); - } - - n--; - b |= (z.read_byte(p++) & 0xff) << k; - k += 8; - } - - table = t = (b & 0x3fff); - if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) { - mode = BADBLOCKS; - z.msg = "too many length or distance symbols"; - r = Z_DATA_ERROR; - - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - return that.inflate_flush(z, r); - } - t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); - if (!blens || blens.length < t) { - blens = []; // new Array(t); - } else { - for (i = 0; i < t; i++) { - blens[i] = 0; - } - } - - // { - b >>>= (14); - k -= (14); - // } - - index = 0; - mode = BTREE; - case BTREE: - while (index < 4 + (table >>> 10)) { - while (k < (3)) { - if (n !== 0) { - r = Z_OK; - } else { - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - return that.inflate_flush(z, r); - } - n--; - b |= (z.read_byte(p++) & 0xff) << k; - k += 8; - } - - blens[border[index++]] = b & 7; - - // { - b >>>= (3); - k -= (3); - // } - } - - while (index < 19) { - blens[border[index++]] = 0; - } - - bb[0] = 7; - t = inftree.inflate_trees_bits(blens, bb, tb, hufts, z); - if (t != Z_OK) { - r = t; - if (r == Z_DATA_ERROR) { - blens = null; - mode = BADBLOCKS; - } - - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - return that.inflate_flush(z, r); - } - - index = 0; - mode = DTREE; - case DTREE: - while (true) { - t = table; - if (!(index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))) { - break; - } - - var h; - var j, c; - - t = bb[0]; - - while (k < (t)) { - if (n !== 0) { - r = Z_OK; - } else { - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - return that.inflate_flush(z, r); - } - n--; - b |= (z.read_byte(p++) & 0xff) << k; - k += 8; - } - - // if (tb[0] == -1) { - // System.err.println("null..."); - // } - - t = hufts[(tb[0] + (b & inflate_mask[t])) * 3 + 1]; - c = hufts[(tb[0] + (b & inflate_mask[t])) * 3 + 2]; - - if (c < 16) { - b >>>= (t); - k -= (t); - blens[index++] = c; - } else { // c == 16..18 - i = c == 18 ? 7 : c - 14; - j = c == 18 ? 11 : 3; - - while (k < (t + i)) { - if (n !== 0) { - r = Z_OK; - } else { - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - return that.inflate_flush(z, r); - } - n--; - b |= (z.read_byte(p++) & 0xff) << k; - k += 8; - } - - b >>>= (t); - k -= (t); - - j += (b & inflate_mask[i]); - - b >>>= (i); - k -= (i); - - i = index; - t = table; - if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || (c == 16 && i < 1)) { - blens = null; - mode = BADBLOCKS; - z.msg = "invalid bit length repeat"; - r = Z_DATA_ERROR; - - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - return that.inflate_flush(z, r); - } - - c = c == 16 ? blens[i - 1] : 0; - do { - blens[i++] = c; - } while (--j !== 0); - index = i; - } - } - - tb[0] = -1; - // { - var bl_ = []; // new Array(1); - var bd_ = []; // new Array(1); - var tl_ = []; // new Array(1); - var td_ = []; // new Array(1); - bl_[0] = 9; // must be <= 9 for lookahead assumptions - bd_[0] = 6; // must be <= 9 for lookahead assumptions - - t = table; - t = inftree.inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), blens, bl_, bd_, tl_, td_, hufts, z); - - if (t != Z_OK) { - if (t == Z_DATA_ERROR) { - blens = null; - mode = BADBLOCKS; - } - r = t; - - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - return that.inflate_flush(z, r); - } - codes.init(bl_[0], bd_[0], hufts, tl_[0], hufts, td_[0], z); - // } - mode = CODES; - case CODES: - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - - if ((r = codes.proc(that, z, r)) != Z_STREAM_END) { - return that.inflate_flush(z, r); - } - r = Z_OK; - codes.free(z); - - p = z.next_in_index; - n = z.avail_in; - b = that.bitb; - k = that.bitk; - q = that.write; - m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); - - if (last === 0) { - mode = TYPE; - break; - } - mode = DRY; - case DRY: - that.write = q; - r = that.inflate_flush(z, r); - q = that.write; - m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); - if (that.read != that.write) { - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - return that.inflate_flush(z, r); - } - mode = DONELOCKS; - case DONELOCKS: - r = Z_STREAM_END; - - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - return that.inflate_flush(z, r); - case BADBLOCKS: - r = Z_DATA_ERROR; - - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - return that.inflate_flush(z, r); - - default: - r = Z_STREAM_ERROR; - - that.bitb = b; - that.bitk = k; - z.avail_in = n; - z.total_in += p - z.next_in_index; - z.next_in_index = p; - that.write = q; - return that.inflate_flush(z, r); - } - } - }; - - that.free = function(z) { - that.reset(z, null); - that.window = null; - hufts = null; - // ZFREE(z, s); - }; - - that.set_dictionary = function(d, start, n) { - that.window.set(d.subarray(start, start + n), 0); - that.read = that.write = n; - }; - - // Returns true if inflate is currently at the end of a block generated - // by Z_SYNC_FLUSH or Z_FULL_FLUSH. - that.sync_point = function() { - return mode == LENS ? 1 : 0; - }; - - } - - // Inflate - - // preset dictionary flag in zlib header - var PRESET_DICT = 0x20; - - var Z_DEFLATED = 8; - - var METHOD = 0; // waiting for method byte - var FLAG = 1; // waiting for flag byte - var DICT4 = 2; // four dictionary check bytes to go - var DICT3 = 3; // three dictionary check bytes to go - var DICT2 = 4; // two dictionary check bytes to go - var DICT1 = 5; // one dictionary check byte to go - var DICT0 = 6; // waiting for inflateSetDictionary - var BLOCKS = 7; // decompressing blocks - var DONE = 12; // finished check, done - var BAD = 13; // got an error--stay here - - var mark = [ 0, 0, 0xff, 0xff ]; - - function Inflate() { - var that = this; - - that.mode = 0; // current inflate mode - - // mode dependent information - that.method = 0; // if FLAGS, method byte - - // if CHECK, check values to compare - that.was = [ 0 ]; // new Array(1); // computed check value - that.need = 0; // stream check value - - // if BAD, inflateSync's marker bytes count - that.marker = 0; - - // mode independent information - that.wbits = 0; // log2(window size) (8..15, defaults to 15) - - // this.blocks; // current inflate_blocks state - - function inflateReset(z) { - if (!z || !z.istate) - return Z_STREAM_ERROR; - - z.total_in = z.total_out = 0; - z.msg = null; - z.istate.mode = BLOCKS; - z.istate.blocks.reset(z, null); - return Z_OK; - } - - that.inflateEnd = function(z) { - if (that.blocks) - that.blocks.free(z); - that.blocks = null; - // ZFREE(z, z->state); - return Z_OK; - }; - - that.inflateInit = function(z, w) { - z.msg = null; - that.blocks = null; - - // set window size - if (w < 8 || w > 15) { - that.inflateEnd(z); - return Z_STREAM_ERROR; - } - that.wbits = w; - - z.istate.blocks = new InfBlocks(z, 1 << w); - - // reset state - inflateReset(z); - return Z_OK; - }; - - that.inflate = function(z, f) { - var r; - var b; - - if (!z || !z.istate || !z.next_in) - return Z_STREAM_ERROR; - f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK; - r = Z_BUF_ERROR; - while (true) { - // System.out.println("mode: "+z.istate.mode); - switch (z.istate.mode) { - case METHOD: - - if (z.avail_in === 0) - return r; - r = f; - - z.avail_in--; - z.total_in++; - if (((z.istate.method = z.read_byte(z.next_in_index++)) & 0xf) != Z_DEFLATED) { - z.istate.mode = BAD; - z.msg = "unknown compression method"; - z.istate.marker = 5; // can't try inflateSync - break; - } - if ((z.istate.method >> 4) + 8 > z.istate.wbits) { - z.istate.mode = BAD; - z.msg = "invalid window size"; - z.istate.marker = 5; // can't try inflateSync - break; - } - z.istate.mode = FLAG; - case FLAG: - - if (z.avail_in === 0) - return r; - r = f; - - z.avail_in--; - z.total_in++; - b = (z.read_byte(z.next_in_index++)) & 0xff; - - if ((((z.istate.method << 8) + b) % 31) !== 0) { - z.istate.mode = BAD; - z.msg = "incorrect header check"; - z.istate.marker = 5; // can't try inflateSync - break; - } - - if ((b & PRESET_DICT) === 0) { - z.istate.mode = BLOCKS; - break; - } - z.istate.mode = DICT4; - case DICT4: - - if (z.avail_in === 0) - return r; - r = f; - - z.avail_in--; - z.total_in++; - z.istate.need = ((z.read_byte(z.next_in_index++) & 0xff) << 24) & 0xff000000; - z.istate.mode = DICT3; - case DICT3: - - if (z.avail_in === 0) - return r; - r = f; - - z.avail_in--; - z.total_in++; - z.istate.need += ((z.read_byte(z.next_in_index++) & 0xff) << 16) & 0xff0000; - z.istate.mode = DICT2; - case DICT2: - - if (z.avail_in === 0) - return r; - r = f; - - z.avail_in--; - z.total_in++; - z.istate.need += ((z.read_byte(z.next_in_index++) & 0xff) << 8) & 0xff00; - z.istate.mode = DICT1; - case DICT1: - - if (z.avail_in === 0) - return r; - r = f; - - z.avail_in--; - z.total_in++; - z.istate.need += (z.read_byte(z.next_in_index++) & 0xff); - z.istate.mode = DICT0; - return Z_NEED_DICT; - case DICT0: - z.istate.mode = BAD; - z.msg = "need dictionary"; - z.istate.marker = 0; // can try inflateSync - return Z_STREAM_ERROR; - case BLOCKS: - - r = z.istate.blocks.proc(z, r); - if (r == Z_DATA_ERROR) { - z.istate.mode = BAD; - z.istate.marker = 0; // can try inflateSync - break; - } - if (r == Z_OK) { - r = f; - } - if (r != Z_STREAM_END) { - return r; - } - r = f; - z.istate.blocks.reset(z, z.istate.was); - z.istate.mode = DONE; - case DONE: - return Z_STREAM_END; - case BAD: - return Z_DATA_ERROR; - default: - return Z_STREAM_ERROR; - } - } - }; - - that.inflateSetDictionary = function(z, dictionary, dictLength) { - var index = 0; - var length = dictLength; - if (!z || !z.istate || z.istate.mode != DICT0) - return Z_STREAM_ERROR; - - if (length >= (1 << z.istate.wbits)) { - length = (1 << z.istate.wbits) - 1; - index = dictLength - length; - } - z.istate.blocks.set_dictionary(dictionary, index, length); - z.istate.mode = BLOCKS; - return Z_OK; - }; - - that.inflateSync = function(z) { - var n; // number of bytes to look at - var p; // pointer to bytes - var m; // number of marker bytes found in a row - var r, w; // temporaries to save total_in and total_out - - // set up - if (!z || !z.istate) - return Z_STREAM_ERROR; - if (z.istate.mode != BAD) { - z.istate.mode = BAD; - z.istate.marker = 0; - } - if ((n = z.avail_in) === 0) - return Z_BUF_ERROR; - p = z.next_in_index; - m = z.istate.marker; - - // search - while (n !== 0 && m < 4) { - if (z.read_byte(p) == mark[m]) { - m++; - } else if (z.read_byte(p) !== 0) { - m = 0; - } else { - m = 4 - m; - } - p++; - n--; - } - - // restore - z.total_in += p - z.next_in_index; - z.next_in_index = p; - z.avail_in = n; - z.istate.marker = m; - - // return no joy or set up to restart on a new block - if (m != 4) { - return Z_DATA_ERROR; - } - r = z.total_in; - w = z.total_out; - inflateReset(z); - z.total_in = r; - z.total_out = w; - z.istate.mode = BLOCKS; - return Z_OK; - }; - - // Returns true if inflate is currently at the end of a block generated - // by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP - // implementation to provide an additional safety check. PPP uses - // Z_SYNC_FLUSH - // but removes the length bytes of the resulting empty stored block. When - // decompressing, PPP checks that at the end of input packet, inflate is - // waiting for these length bytes. - that.inflateSyncPoint = function(z) { - if (!z || !z.istate || !z.istate.blocks) - return Z_STREAM_ERROR; - return z.istate.blocks.sync_point(); - }; - } - - // ZStream - - function ZStream() { - } - - ZStream.prototype = { - inflateInit : function(bits) { - var that = this; - that.istate = new Inflate(); - if (!bits) - bits = MAX_BITS; - return that.istate.inflateInit(that, bits); - }, - - inflate : function(f) { - var that = this; - if (!that.istate) - return Z_STREAM_ERROR; - return that.istate.inflate(that, f); - }, - - inflateEnd : function() { - var that = this; - if (!that.istate) - return Z_STREAM_ERROR; - var ret = that.istate.inflateEnd(that); - that.istate = null; - return ret; - }, - - inflateSync : function() { - var that = this; - if (!that.istate) - return Z_STREAM_ERROR; - return that.istate.inflateSync(that); - }, - inflateSetDictionary : function(dictionary, dictLength) { - var that = this; - if (!that.istate) - return Z_STREAM_ERROR; - return that.istate.inflateSetDictionary(that, dictionary, dictLength); - }, - read_byte : function(start) { - var that = this; - return that.next_in.subarray(start, start + 1)[0]; - }, - read_buf : function(start, size) { - var that = this; - return that.next_in.subarray(start, start + size); - } - }; - - // Inflater - - function Inflater() { - var that = this; - var z = new ZStream(); - var bufsize = 512; - var flush = Z_NO_FLUSH; - var buf = new Uint8Array(bufsize); - var nomoreinput = false; - - z.inflateInit(); - z.next_out = buf; - - that.append = function(data, onprogress) { - var err, buffers = [], lastIndex = 0, bufferIndex = 0, bufferSize = 0, array; - if (data.length === 0) - return; - z.next_in_index = 0; - z.next_in = data; - z.avail_in = data.length; - do { - z.next_out_index = 0; - z.avail_out = bufsize; - if ((z.avail_in === 0) && (!nomoreinput)) { // if buffer is empty and more input is available, refill it - z.next_in_index = 0; - nomoreinput = true; - } - err = z.inflate(flush); - if (nomoreinput && (err == Z_BUF_ERROR)) - return -1; - if (err != Z_OK && err != Z_STREAM_END) - throw "inflating: " + z.msg; - if ((nomoreinput || err == Z_STREAM_END) && (z.avail_out == data.length)) - return -1; - if (z.next_out_index) - if (z.next_out_index == bufsize) - buffers.push(new Uint8Array(buf)); - else - buffers.push(new Uint8Array(buf.subarray(0, z.next_out_index))); - bufferSize += z.next_out_index; - if (onprogress && z.next_in_index > 0 && z.next_in_index != lastIndex) { - onprogress(z.next_in_index); - lastIndex = z.next_in_index; - } - } while (z.avail_in > 0 || z.avail_out === 0); - array = new Uint8Array(bufferSize); - buffers.forEach(function(chunk) { - array.set(chunk, bufferIndex); - bufferIndex += chunk.length; - }); - return array; - }; - that.flush = function() { - z.inflateEnd(); - }; - } - - var inflater; - - if (obj.zip) - obj.zip.Inflater = Inflater; - else { - inflater = new Inflater(); - obj.addEventListener("message", function(event) { - var message = event.data; - - if (message.append) - obj.postMessage({ - onappend : true, - data : inflater.append(message.data, function(current) { - obj.postMessage({ - progress : true, - current : current - }); - }) - }); - if (message.flush) { - inflater.flush(); - obj.postMessage({ - onflush : true - }); - } - }, false); - } - -})(this); - // GPG4Browsers - An OpenPGP implementation in javascript // Copyright (C) 2011 Recurity Labs GmbH // @@ -14567,6 +12389,48 @@ function openpgp_msg_privatekey() { function revoke() { } + + /** + * extracts the public key part + * @return {String} OpenPGP armored text containing the public key + * returns null if no sufficient data to extract public key + */ + function extractPublicKey() { + // add public key + var key = this.privateKeyPacket.publicKey.header + this.privateKeyPacket.publicKey.data; + for (var i = 0; i < this.userIds.length; i++) { + // verify userids + if (this.userIds[i].certificationSignatures.length === 0) { + util.print_error("extractPublicKey - missing certification signatures"); + return null; + } + var userIdPacket = new openpgp_packet_userid(); + // add userids + key += userIdPacket.write_packet(this.userIds[i].text); + for (var j = 0; j < this.userIds[i].certificationSignatures.length; j++) { + var certSig = this.userIds[i].certificationSignatures[j]; + // add signatures + key += openpgp_packet.write_packet_header(2, certSig.data.length) + certSig.data; + } + } + for (var k = 0; k < this.subKeys.length; k++) { + var pubSubKey = this.subKeys[k].publicKey; + // add public subkey package + key += openpgp_packet.write_old_packet_header(14, pubSubKey.data.length) + pubSubKey.data; + var subKeySig = this.subKeys[k].subKeySignature; + if (subKeySig !== null) { + // add subkey signature + key += openpgp_packet.write_packet_header(2, subKeySig.data.length) + subKeySig.data; + } else { + util.print_error("extractPublicKey - missing subkey signature"); + return null; + } + } + var publicArmored = openpgp_encoding_armor(4, key); + return publicArmored; + } + + this.extractPublicKey = extractPublicKey; this.getSigningKey = getSigningKey; this.getFingerprint = getFingerprint; this.getPreferredSignatureHashAlgorithm = getPreferredSignatureHashAlgorithm; diff --git a/resources/openpgp.min.js b/resources/openpgp.min.js index 258df823..16feb8c6 100644 --- a/resources/openpgp.min.js +++ b/resources/openpgp.min.js @@ -1,13 +1,13 @@ function _openpgp(){this.tostring="";this.generate_key_pair=function(a,b,c,d){var e=(new openpgp_packet_userid).write_packet(c),b=openpgp_crypto_generateKeyPair(a,b,d,openpgp.config.config.prefer_hash_algorithm,3),a=b.privateKey,f=(new openpgp_packet_keymaterial).read_priv_key(a.string,3,a.string.length);f.decryptSecretMPIs(d)||util.print_error("Issue creating key. Unable to read resulting private key");d=new openpgp_msg_privatekey;d.privateKeyPacket=f;d.getPreferredSignatureHashAlgorithm=function(){return openpgp.config.config.prefer_hash_algorithm}; f=d.privateKeyPacket.publicKey.data;f=String.fromCharCode(153)+String.fromCharCode(f.length>>8&255)+String.fromCharCode(f.length&255)+f+String.fromCharCode(180)+String.fromCharCode(c.length>>24)+String.fromCharCode(c.length>>16&255)+String.fromCharCode(c.length>>8&255)+String.fromCharCode(c.length&255)+c;c=new openpgp_packet_signature;c=c.write_message_signature(16,f,d);b=openpgp_encoding_armor(4,b.publicKey.string+e+c.openpgp);e=openpgp_encoding_armor(5,a.string+e+c.openpgp);return{privateKey:d, privateKeyArmored:e,publicKeyArmored:b}};this.write_signed_message=function(a,b){var c=(new openpgp_packet_signature).write_message_signature(1,b.replace(/\r\n/g,"\n").replace(/\n/,"\r\n"),a),c={text:b.replace(/\r\n/g,"\n").replace(/\n/,"\r\n"),openpgp:c.openpgp,hash:c.hash};return openpgp_encoding_armor(2,c,null,null)};this.write_signed_and_encrypted_message=function(a,b,c){var d="",e=(new openpgp_packet_literaldata).write_packet(c.replace(/\r\n/g,"\n").replace(/\n/g,"\r\n"));util.print_debug_hexstr_dump("literal_packet: |"+ -e+"|\n",e);for(var f=0;fh.signatureType||3==h.tagType||8==h.tagType||9==h.tagType||10==h.tagType||11==h.tagType||18==h.tagType||19==h.tagType)if(d[d.length]=new openpgp_msg_message,d[e].messagePacket=h,d[e].type=b.type,9==h.tagType||1==h.tagType||3==h.tagType||18==h.tagType)if(9==h.tagType){util.print_error("unexpected openpgp packet");break}else if(1==h.tagType){util.print_debug("session key found:\n "+ -h.toString());var k=!0;d[e].sessionKeys=[];for(var j=0;k;)d[e].sessionKeys[j]=h,f+=h.packetLength+h.headerLength,g-=h.packetLength+h.headerLength,h=openpgp_packet.read_packet(a,f,g),1!=h.tagType&&3!=h.tagType&&(k=!1),j++;18==h.tagType||9==h.tagType?(util.print_debug("encrypted data found:\n "+h.toString()),d[e].encryptedData=h,f+=h.packetLength+h.headerLength,g-=h.packetLength+h.headerLength,e++):util.print_debug("something is wrong: "+h.tagType)}else{if(18==h.tagType){util.print_debug("symmetric encrypted data"); -break}}else if(2==h.tagType&&3>h.signatureType){d[e].text=b.text;d[e].signature=h;break}else if(8==h.tagType){util.print_error("A directly compressed message is currently not supported");break}else if(10==h.tagType)d.length=0,f+=h.packetLength+h.headerLength,g-=h.packetLength+h.headerLength;else{if(11==h.tagType){util.print_error("A direct literal message is currently not supported.");break}}else return util.print_error("no message found!"),null}return d};this.read_publicKey=function(a){for(var b= +a,d);return openpgp_encoding_armor(3,c,null,null)};this.write_encrypted_message=function(a,b){var c="",c=(new openpgp_packet_literaldata).write_packet(b.replace(/\r\n/g,"\n").replace(/\n/g,"\r\n"));util.print_debug_hexstr_dump("literal_packet: |"+c+"|\n",c);for(var d=openpgp_crypto_generateSessionKey(openpgp.config.config.encryption_cipher),e="",f=0;fg.signatureType||3==g.tagType||8==g.tagType||9==g.tagType||10==g.tagType||11==g.tagType||18==g.tagType||19==g.tagType)if(d[d.length]=new openpgp_msg_message,d[e].messagePacket=g,d[e].type=b.type,9==g.tagType||1==g.tagType||3==g.tagType||18==g.tagType)if(9==g.tagType){util.print_error("unexpected openpgp packet");break}else if(1==g.tagType){util.print_debug("session key found:\n "+ +g.toString());var k=!0;d[e].sessionKeys=[];for(var j=0;k;)d[e].sessionKeys[j]=g,f+=g.packetLength+g.headerLength,h-=g.packetLength+g.headerLength,g=openpgp_packet.read_packet(a,f,h),1!=g.tagType&&3!=g.tagType&&(k=!1),j++;18==g.tagType||9==g.tagType?(util.print_debug("encrypted data found:\n "+g.toString()),d[e].encryptedData=g,f+=g.packetLength+g.headerLength,h-=g.packetLength+g.headerLength,e++):util.print_debug("something is wrong: "+g.tagType)}else{if(18==g.tagType){util.print_debug("symmetric encrypted data"); +break}}else if(2==g.tagType&&3>g.signatureType){d[e].text=b.text;d[e].signature=g;break}else if(8==g.tagType){util.print_error("A directly compressed message is currently not supported");break}else if(10==g.tagType)d.length=0,f+=g.packetLength+g.headerLength,h-=g.packetLength+g.headerLength;else{if(11==g.tagType){util.print_error("A direct literal message is currently not supported.");break}}else return util.print_error("no message found!"),null}return d};this.read_publicKey=function(a){for(var b= 0,c=[],d=0,a=openpgp_encoding_deArmor(a.replace(/\r/g,"")).openpgp,e=a.length;b!=a.length;){var f=openpgp_packet.read_packet(a,b,e);if(153==a[b].charCodeAt()||6==f.tagType)c[d]=new openpgp_msg_publickey,c[d].header=a.substring(b,b+3),153==a[b].charCodeAt()?(b++,e=a[b++].charCodeAt()<<8|a[b++].charCodeAt(),c[d].publicKeyPacket=new openpgp_packet_keymaterial,c[d].publicKeyPacket.header=c[d].header,c[d].publicKeyPacket.read_tag6(a,b,e),b+=c[d].publicKeyPacket.packetLength,b+=c[d].read_nodes(c[d].publicKeyPacket, a,b,a.length-b)):(c[d]=new openpgp_msg_publickey,c[d].publicKeyPacket=f,b+=f.headerLength+f.packetLength,b+=c[d].read_nodes(f,a,b,a.length-b));else return util.print_error("no public key found!"),null;c[d].data=a.substring(0,b);d++}return c};this.read_privateKey=function(a){for(var b=[],c=0,d=0,a=openpgp_encoding_deArmor(a.replace(/\r/g,"")).openpgp,e=a.length;d!=a.length;){var f=openpgp_packet.read_packet(a,d,e);if(5==f.tagType)b[b.length]=new openpgp_msg_privatekey,d+=f.headerLength+f.packetLength, d+=b[c].read_nodes(f,a,d,e);else return util.print_error("no block packet found!"),null;b[c].data=a.substring(0,d);c++}return b};this.init=function(){this.config=new openpgp_config;this.config.read();this.keyring=new openpgp_keyring;this.keyring.init()}}var openpgp=new _openpgp; @@ -18,24 +18,24 @@ return f=openpgp_packet.write_packet_header(1,f.length)+f};this.toString=functio this.packetLength+"\n version:"+this.version+"\n symKeyA:"+this.symmetricKeyAlgorithmUsed+"\n s2k: "+this.s2k+"\n"};this.decrypt=function(a,b){if(1==this.tagType){var c=openpgp_crypto_asymetricDecrypt(this.publicKeyAlgorithmUsed,b.publicKey.MPIs,b.secMPIs,this.MPIs).toMPI();c.charCodeAt(c.length-2);c.charCodeAt(c.length-1);var d=openpgp_encoding_eme_pkcs1_decode(c.substring(2,c.length-2),b.publicKey.MPIs[0].getByteLength()),c=d.substring(1),d=d.charCodeAt(0);return 18==a.encryptedData.tagType? a.encryptedData.decrypt(d,c):a.encryptedData.decrypt_sym(d,c)}if(3==this.tagType)return util.print_error("Symmetric encrypted sessionkey is not supported!"),null}} function openpgp_packet_userattribute(){this.tagType=17;this.certificationSignatures=[];this.certificationRevocationSignatures=[];this.revocationSignatures=[];this.parentNode=null;this.read_packet=function(a,b,c){var d=0;this.packetLength=c;this.userattributes=[];for(var e=b;c!=d;){var f=0;192>a[e].charCodeAt()?(packet_length=a[e++].charCodeAt(),f=1):192<=a[e].charCodeAt()&&224>a[e].charCodeAt()?(packet_length=(a[e++].charCodeAt()-192<<8)+a[e++].charCodeAt()+192,f=2):223a[e].charCodeAt()? -(packet_length=1<<(a[e++].charCodeAt()&31),f=1):(f=5,e++,packet_length=a[e++].charCodeAt()<<24|a[e++].charCodeAt()<<16|a[e++].charCodeAt()<<8|a[e++].charCodeAt());a[e++].charCodeAt();packet_length--;f++;this.userattributes[0]=[];this.userattributes[0]=a.substring(e,e+packet_length);e+=packet_length;d+=f+packet_length}this.packetLength=e-b;return this};this.read_nodes=function(a,b,c,d){this.parentNode=a;for(var e=c,f=d;b.length!=e;){var g=openpgp_packet.read_packet(b,e,f);if(null==g){util.print_error("openpgp.packet.userattribute.js\n[user_attr] parsing ends here @:"+ -e+" l:"+f);break}else switch(g.tagType){case 2:15g.signatureType?this.certificationSignatures[this.certificationSignatures.length]=g:32==g.signatureType&&(this.certificationRevocationSignatures[this.certificationRevocationSignatures.length]=g);e+=g.packetLength+g.headerLength;f=d-(e-c);break;default:return this.data=b,this.position=c-a.packetLength,this.len=e-c}}this.data=b;this.position=c-a.packetLength;return this.len=e-c};this.toString=function(){for(var a="5.12. User Attribute Packet (Tag 17)\n AttributePackets: (count = "+ +(packet_length=1<<(a[e++].charCodeAt()&31),f=1):(f=5,e++,packet_length=a[e++].charCodeAt()<<24|a[e++].charCodeAt()<<16|a[e++].charCodeAt()<<8|a[e++].charCodeAt());a[e++].charCodeAt();packet_length--;f++;this.userattributes[0]=[];this.userattributes[0]=a.substring(e,e+packet_length);e+=packet_length;d+=f+packet_length}this.packetLength=e-b;return this};this.read_nodes=function(a,b,c,d){this.parentNode=a;for(var e=c,f=d;b.length!=e;){var h=openpgp_packet.read_packet(b,e,f);if(null==h){util.print_error("openpgp.packet.userattribute.js\n[user_attr] parsing ends here @:"+ +e+" l:"+f);break}else switch(h.tagType){case 2:15h.signatureType?this.certificationSignatures[this.certificationSignatures.length]=h:32==h.signatureType&&(this.certificationRevocationSignatures[this.certificationRevocationSignatures.length]=h);e+=h.packetLength+h.headerLength;f=d-(e-c);break;default:return this.data=b,this.position=c-a.packetLength,this.len=e-c}}this.data=b;this.position=c-a.packetLength;return this.len=e-c};this.toString=function(){for(var a="5.12. User Attribute Packet (Tag 17)\n AttributePackets: (count = "+ this.userattributes.length+")\n",b=0;bd&&util.print_debug("openpgp.packet.signature.js\n_raw_read_signature_sub_packet length < 0 @:"+a);var e=a,f=0;192>b[e].charCodeAt()?f=b[e++].charCodeAt():192<=b[e].charCodeAt()&&224>b[e].charCodeAt()?f=(b[e++].charCodeAt()-192<<8)+b[e++].charCodeAt()+192:223b[e].charCodeAt()?f=1<<(b[e++].charCodeAt()&31):255>b[e].charCodeAt()&&(e++,f=b[e++].charCodeAt()<<24|b[e++].charCodeAt()<<16|b[e++].charCodeAt()<<8|b[e++].charCodeAt()); -var g=b[e++].charCodeAt()&127;switch(g){case 2:this.creationTime=new Date(1E3*(b[e++].charCodeAt()<<24|b[e++].charCodeAt()<<16|b[e++].charCodeAt()<<8|b[e++].charCodeAt()));break;case 3:this.signatureExpirationTime=b[e++].charCodeAt()<<24|b[e++].charCodeAt()<<16|b[e++].charCodeAt()<<8|b[e++].charCodeAt();this.signatureNeverExpires=0==this.signature_expiration_time;break;case 4:this.exportable=1==b[e++].charCodeAt();break;case 5:this.trustLevel=b[e++].charCodeAt();this.trustAmount=b[e++].charCodeAt(); -break;case 6:this.regular_expression=new String;for(g=0;gg;g++)this.revocationKeyFingerprint=b[e++].charCodeAt();break;case 16:this.issuerKeyId=b.substring(e,e+8);e+=8;break;case 20:this.notationFlags=b[e++].charCodeAt()<<24|b[e++].charCodeAt()<<16|b[e++].charCodeAt()<<8|b[e++].charCodeAt();d=b[e++].charCodeAt()<<8|b[e++].charCodeAt();f=b[e++].charCodeAt()<<8|b[e++].charCodeAt();this.notationName="";for(g=0;g>24&255)+String.fromCharCode(b>>16&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255)),h=a(16,d.getKeyId()),g=g+String.fromCharCode(b.length+h.length>>8&255),g=g+String.fromCharCode(b.length+h.length&255),g=g+b+h,b=""+String.fromCharCode(4),b=b+String.fromCharCode(255),b=b+String.fromCharCode(g.length>>24),b=b+String.fromCharCode(g.length>>16&255),b=b+String.fromCharCode(g.length>>8&255),b=b+String.fromCharCode(g.length&255),h=String.fromCharCode(0), -h=h+String.fromCharCode(0),k=openpgp_crypto_hashData(f,c+g+b);util.print_debug("DSA Signature is calculated with:|"+c+g+b+"|\n"+util.hexstrdump(c+g+b)+"\n hash:"+util.hexstrdump(k));h+=k.charAt(0);h+=k.charAt(1);h+=openpgp_crypto_signData(f,d.privateKeyPacket.publicKey.publicKeyAlgorithm,e.MPIs,d.privateKeyPacket.secMPIs,c+g+b);return{openpgp:openpgp_packet.write_packet_header(2,(g+h).length)+g+h,hash:util.get_hashAlgorithmString(f)}};this.verify=function(b,a){switch(this.signatureType){case 0:if(4== +var h=b[e++].charCodeAt()&127;switch(h){case 2:this.creationTime=new Date(1E3*(b[e++].charCodeAt()<<24|b[e++].charCodeAt()<<16|b[e++].charCodeAt()<<8|b[e++].charCodeAt()));break;case 3:this.signatureExpirationTime=b[e++].charCodeAt()<<24|b[e++].charCodeAt()<<16|b[e++].charCodeAt()<<8|b[e++].charCodeAt();this.signatureNeverExpires=0==this.signature_expiration_time;break;case 4:this.exportable=1==b[e++].charCodeAt();break;case 5:this.trustLevel=b[e++].charCodeAt();this.trustAmount=b[e++].charCodeAt(); +break;case 6:this.regular_expression=new String;for(h=0;hh;h++)this.revocationKeyFingerprint=b[e++].charCodeAt();break;case 16:this.issuerKeyId=b.substring(e,e+8);e+=8;break;case 20:this.notationFlags=b[e++].charCodeAt()<<24|b[e++].charCodeAt()<<16|b[e++].charCodeAt()<<8|b[e++].charCodeAt();d=b[e++].charCodeAt()<<8|b[e++].charCodeAt();f=b[e++].charCodeAt()<<8|b[e++].charCodeAt();this.notationName="";for(h=0;h>24&255)+String.fromCharCode(b>>16&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255)),g=a(16,d.getKeyId()),h=h+String.fromCharCode(b.length+g.length>>8&255),h=h+String.fromCharCode(b.length+g.length&255),h=h+b+g,b=""+String.fromCharCode(4),b=b+String.fromCharCode(255),b=b+String.fromCharCode(h.length>>24),b=b+String.fromCharCode(h.length>>16&255),b=b+String.fromCharCode(h.length>>8&255),b=b+String.fromCharCode(h.length&255),g=String.fromCharCode(0), +g=g+String.fromCharCode(0),k=openpgp_crypto_hashData(f,c+h+b);util.print_debug("DSA Signature is calculated with:|"+c+h+b+"|\n"+util.hexstrdump(c+h+b)+"\n hash:"+util.hexstrdump(k));g+=k.charAt(0);g+=k.charAt(1);g+=openpgp_crypto_signData(f,d.privateKeyPacket.publicKey.publicKeyAlgorithm,e.MPIs,d.privateKeyPacket.secMPIs,c+h+b);return{openpgp:openpgp_packet.write_packet_header(2,(h+g).length)+h+g,hash:util.get_hashAlgorithmString(f)}};this.verify=function(b,a){switch(this.signatureType){case 0:if(4== this.version){var d;d=""+String.fromCharCode(this.version);d+=String.fromCharCode(255);d+=String.fromCharCode(this.signatureData.length>>24);d+=String.fromCharCode(this.signatureData.length>>16&255);d+=String.fromCharCode(this.signatureData.length>>8&255);d+=String.fromCharCode(this.signatureData.length&255);return openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,a.obj.publicKeyPacket.MPIs,b.substring(i)+this.signatureData+d)}if(3==this.version)return!1;case 1:if(4== this.version)return d=""+String.fromCharCode(this.version),d+=String.fromCharCode(255),d+=String.fromCharCode(this.signatureData.length>>24),d+=String.fromCharCode(this.signatureData.length>>16&255),d+=String.fromCharCode(this.signatureData.length>>8&255),d+=String.fromCharCode(this.signatureData.length&255),openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,a.obj.publicKeyPacket.MPIs,b+this.signatureData+d);if(3==this.version)return!1;case 2:if(3==this.version)return!1; d=""+String.fromCharCode(this.version);d+=String.fromCharCode(255);d+=String.fromCharCode(this.signatureData.length>>24);d+=String.fromCharCode(this.signatureData.length>>16&255);d+=String.fromCharCode(this.signatureData.length>>8&255);d+=String.fromCharCode(this.signatureData.length&255);return openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,a.obj.publicKeyPacket.MPIs,this.signatureData+d);case 16:case 17:case 18:case 19:case 48:return d=""+String.fromCharCode(this.version), @@ -83,14 +83,14 @@ function openpgp_packet_marker(){this.tagType=10;this.read_packet=function(a,b){ function openpgp_packet_modificationdetectioncode(){this.tagType=19;this.hash=null;this.read_packet=function(a,b,c){this.packetLength=c;if(20!=c)return util.print_error("openpgp.packet.modificationdetectioncode.js\ninvalid length for a modification detection code packet!"+c),null;this.hash=a.substring(b,b+20);return this};this.toString=function(){return"5.14 Modification detection code packet\n bytes ("+this.hash.length+"): ["+util.hexstrdump(this.hash)+"]"}} function _openpgp_packet(){function a(b){result="";192>b?result+=String.fromCharCode(b):191b?(result+=String.fromCharCode((b-192>>8)+192),result+=String.fromCharCode(b-192&255)):(result+=String.fromCharCode(255),result+=String.fromCharCode(b>>24&255),result+=String.fromCharCode(b>>16&255),result+=String.fromCharCode(b>>8&255),result+=String.fromCharCode(b&255));return result}this.encode_length=a;this.write_old_packet_header=function(b,a){var d="";256>a?(d+=String.fromCharCode(128|b<<2),d+= String.fromCharCode(a)):(65536>a?(d+=String.fromCharCode(b<<2|129),d+=String.fromCharCode(a>>8)):(d+=String.fromCharCode(b<<2|130),d+=String.fromCharCode(a>>24&255),d+=String.fromCharCode(a>>16&255),d+=String.fromCharCode(a>>8&255)),d+=String.fromCharCode(a&255));return d};this.write_packet_header=function(b,c){var d;d=""+String.fromCharCode(192|b);return d+=a(c)};this.read_packet=function(b,a){if(null==b||b.length<=a||2>b.substring(a).length||0==(b[a].charCodeAt()&128))return util.print_error("Error during parsing. This message / key is propably not containing a valid OpenPGP format."), -null;var d=a,e=-1,f=-1,f=0;0!=(b[d].charCodeAt()&64)&&(f=1);var g;f?e=b[d].charCodeAt()&63:(e=(b[d].charCodeAt()&63)>>2,g=b[d].charCodeAt()&3);d++;var h=null,k=-1;if(f)if(192>b[d].charCodeAt())packet_length=b[d++].charCodeAt(),util.print_debug("1 byte length:"+packet_length);else if(192<=b[d].charCodeAt()&&224>b[d].charCodeAt())packet_length=(b[d++].charCodeAt()-192<<8)+b[d++].charCodeAt()+192,util.print_debug("2 byte length:"+packet_length);else if(223b[d].charCodeAt()){packet_length= -1<<(b[d++].charCodeAt()&31);util.print_debug("4 byte length:"+packet_length);k=d+packet_length;for(h=b.substring(d,d+packet_length);;)if(192>b[k].charCodeAt()){f=b[k++].charCodeAt();packet_length+=f;h+=b.substring(k,k+f);k+=f;break}else if(192<=b[k].charCodeAt()&&224>b[k].charCodeAt()){f=(b[k++].charCodeAt()-192<<8)+b[k++].charCodeAt()+192;packet_length+=f;h+=b.substring(k,k+f);k+=f;break}else if(223b[k].charCodeAt())f=1<<(b[k++].charCodeAt()&31),packet_length+=f,h+=b.substring(k, -k+f),k+=f;else{k++;f=b[k++].charCodeAt()<<24|b[k++].charCodeAt()<<16|b[k++].charCodeAt()<<8|b[k++].charCodeAt();h+=b.substring(k,k+f);packet_length+=f;k+=f;break}}else d++,packet_length=b[d++].charCodeAt()<<24|b[d++].charCodeAt()<<16|b[d++].charCodeAt()<<8|b[d++].charCodeAt();else switch(g){case 0:packet_length=b[d++].charCodeAt();break;case 1:packet_length=b[d++].charCodeAt()<<8|b[d++].charCodeAt();break;case 2:packet_length=b[d++].charCodeAt()<<24|b[d++].charCodeAt()<<16|b[d++].charCodeAt()<<8| -b[d++].charCodeAt()}-1==k&&(k=packet_length);null==h&&(h=b.substring(d,d+k));switch(e){case 0:break;case 1:e=new openpgp_packet_encryptedsessionkey;if(null!=e.read_pub_key_packet(h,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 2:e=new openpgp_packet_signature;if(null!=e.read_packet(h,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 3:e=new openpgp_packet_encryptedsessionkey;if(null!=e.read_symmetric_key_packet(h,0,packet_length))return e.headerLength= -d-a,e.packetLength=k,e;break;case 4:e=new openpgp_packet_onepasssignature;if(e.read_packet(h,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 5:e=new openpgp_packet_keymaterial;e.header=b.substring(a,d);if(null!=e.read_tag5(h,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 6:e=new openpgp_packet_keymaterial;e.header=b.substring(a,d);if(null!=e.read_tag6(h,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 7:e=new openpgp_packet_keymaterial; -if(null!=e.read_tag7(h,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 8:e=new openpgp_packet_compressed;if(null!=e.read_packet(h,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 9:e=new openpgp_packet_encrypteddata;if(null!=e.read_packet(h,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 10:e=new openpgp_packet_marker;if(null!=e.read_packet(h,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 11:e=new openpgp_packet_literaldata; -if(null!=e.read_packet(h,0,packet_length))return e.headerLength=d-a,e.header=b.substring(a,d),e.packetLength=k,e;break;case 12:break;case 13:e=new openpgp_packet_userid;if(null!=e.read_packet(h,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 14:e=new openpgp_packet_keymaterial;e.header=b.substring(a,d);if(null!=e.read_tag14(h,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 17:e=new openpgp_packet_userattribute;if(null!=e.read_packet(h,0,packet_length))return e.headerLength= -d-a,e.packetLength=k,e;break;case 18:e=new openpgp_packet_encryptedintegrityprotecteddata;if(null!=e.read_packet(h,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 19:e=new openpgp_packet_modificationdetectioncode;if(null!=e.read_packet(h,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;default:return util.print_error("openpgp.packet.js\n[ERROR] openpgp_packet: failed to parse packet @:"+d+"\nchar:'"+util.hexstrdump(b.substring(d))+"'\ninput:"+util.hexstrdump(b)), +null;var d=a,e=-1,f=-1,f=0;0!=(b[d].charCodeAt()&64)&&(f=1);var h;f?e=b[d].charCodeAt()&63:(e=(b[d].charCodeAt()&63)>>2,h=b[d].charCodeAt()&3);d++;var g=null,k=-1;if(f)if(192>b[d].charCodeAt())packet_length=b[d++].charCodeAt(),util.print_debug("1 byte length:"+packet_length);else if(192<=b[d].charCodeAt()&&224>b[d].charCodeAt())packet_length=(b[d++].charCodeAt()-192<<8)+b[d++].charCodeAt()+192,util.print_debug("2 byte length:"+packet_length);else if(223b[d].charCodeAt()){packet_length= +1<<(b[d++].charCodeAt()&31);util.print_debug("4 byte length:"+packet_length);k=d+packet_length;for(g=b.substring(d,d+packet_length);;)if(192>b[k].charCodeAt()){f=b[k++].charCodeAt();packet_length+=f;g+=b.substring(k,k+f);k+=f;break}else if(192<=b[k].charCodeAt()&&224>b[k].charCodeAt()){f=(b[k++].charCodeAt()-192<<8)+b[k++].charCodeAt()+192;packet_length+=f;g+=b.substring(k,k+f);k+=f;break}else if(223b[k].charCodeAt())f=1<<(b[k++].charCodeAt()&31),packet_length+=f,g+=b.substring(k, +k+f),k+=f;else{k++;f=b[k++].charCodeAt()<<24|b[k++].charCodeAt()<<16|b[k++].charCodeAt()<<8|b[k++].charCodeAt();g+=b.substring(k,k+f);packet_length+=f;k+=f;break}}else d++,packet_length=b[d++].charCodeAt()<<24|b[d++].charCodeAt()<<16|b[d++].charCodeAt()<<8|b[d++].charCodeAt();else switch(h){case 0:packet_length=b[d++].charCodeAt();break;case 1:packet_length=b[d++].charCodeAt()<<8|b[d++].charCodeAt();break;case 2:packet_length=b[d++].charCodeAt()<<24|b[d++].charCodeAt()<<16|b[d++].charCodeAt()<<8| +b[d++].charCodeAt()}-1==k&&(k=packet_length);null==g&&(g=b.substring(d,d+k));switch(e){case 0:break;case 1:e=new openpgp_packet_encryptedsessionkey;if(null!=e.read_pub_key_packet(g,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 2:e=new openpgp_packet_signature;if(null!=e.read_packet(g,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 3:e=new openpgp_packet_encryptedsessionkey;if(null!=e.read_symmetric_key_packet(g,0,packet_length))return e.headerLength= +d-a,e.packetLength=k,e;break;case 4:e=new openpgp_packet_onepasssignature;if(e.read_packet(g,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 5:e=new openpgp_packet_keymaterial;e.header=b.substring(a,d);if(null!=e.read_tag5(g,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 6:e=new openpgp_packet_keymaterial;e.header=b.substring(a,d);if(null!=e.read_tag6(g,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 7:e=new openpgp_packet_keymaterial; +if(null!=e.read_tag7(g,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 8:e=new openpgp_packet_compressed;if(null!=e.read_packet(g,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 9:e=new openpgp_packet_encrypteddata;if(null!=e.read_packet(g,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 10:e=new openpgp_packet_marker;if(null!=e.read_packet(g,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 11:e=new openpgp_packet_literaldata; +if(null!=e.read_packet(g,0,packet_length))return e.headerLength=d-a,e.header=b.substring(a,d),e.packetLength=k,e;break;case 12:break;case 13:e=new openpgp_packet_userid;if(null!=e.read_packet(g,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 14:e=new openpgp_packet_keymaterial;e.header=b.substring(a,d);if(null!=e.read_tag14(g,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 17:e=new openpgp_packet_userattribute;if(null!=e.read_packet(g,0,packet_length))return e.headerLength= +d-a,e.packetLength=k,e;break;case 18:e=new openpgp_packet_encryptedintegrityprotecteddata;if(null!=e.read_packet(g,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;case 19:e=new openpgp_packet_modificationdetectioncode;if(null!=e.read_packet(g,0,packet_length))return e.headerLength=d-a,e.packetLength=k,e;break;default:return util.print_error("openpgp.packet.js\n[ERROR] openpgp_packet: failed to parse packet @:"+d+"\nchar:'"+util.hexstrdump(b.substring(d))+"'\ninput:"+util.hexstrdump(b)), null}}}var openpgp_packet=new _openpgp_packet; function openpgp_packet_literaldata(){this.tagType=11;this.read_packet=function(a,b,c){this.packetLength=c;this.format=a[b];this.filename=a.substr(b+2,a.charCodeAt(b+1));this.date=new Date(1E3*parseInt(a.substr(b+2+a.charCodeAt(b+1),4)));this.data=a.substring(b+6+a.charCodeAt(b+1));return this};this.toString=function(){return"5.9. Literal Data Packet (Tag 11)\n length: "+this.packetLength+"\n format: "+this.format+"\n filename:"+this.filename+"\n date: "+this.date+"\n data: |"+ this.data+"|\n rdata: |"+this.real_data+"|\n"};this.write_packet=function(a){a=a.replace(/\r\n/g,"\n").replace(/\n/g,"\r\n");this.filename="msg.txt";this.date=new Date;this.format="t";var b=openpgp_packet.write_packet_header(11,a.length+6+this.filename.length),b=b+this.format,b=b+String.fromCharCode(this.filename.length),b=b+this.filename,b=b+String.fromCharCode(Math.round(this.date.getTime()/1E3)>>24&255),b=b+String.fromCharCode(Math.round(this.date.getTime()/1E3)>>16&255),b=b+String.fromCharCode(Math.round(this.date.getTime()/ @@ -107,10 +107,10 @@ d&&d.creationTime>this.certificationSignatures[b].creationTime){var e=String.fro String.fromCharCode(this.text.length>>24&255)+String.fromCharCode(this.text.length>>16&255)+String.fromCharCode(this.text.length>>8&255)+String.fromCharCode(this.text.length&255)+this.text;result[b]=this.certificationSignatures[b].verify(e,c)?4:0}}else if(3==this.certificationSignatures[b].version)if(null==this.certificationSignatures[b].keyId)result[b]=0;else if(c=openpgp.keyring.getPublicKeysForKeyId(this.certificationSignatures[b].keyId),null==c||0==c.length)result[b]=2;else if(c=publicKey.obj.getSigningKey(), null==c)result[b]=0;else{d=this.hasCertificationRevocationSignature(this.certificationSignatures[b].keyId);if(null!=d&&d.creationTime>this.certificationSignatures[b].creationTime&&(e=String.fromCharCode(153)+this.publicKeyPacket.header.substring(1)+this.publicKeyPacket.data+this.text,d.verify(e,c))){result[b]=d.keyId==a.getKeyId()?6:3;continue}e=String.fromCharCode(153)+a.header.substring(1)+a.data+this.text;result[b]=this.certificationSignatures[b].verify(e,c)?4:0}else result[b]=0;return result}; this.verify=function(a){a=this.verifyCertificationSignatures(a);return-1!=a.indexOf(6)?2:-1!=a.indexOf(5)?1:0};this.read_packet=function(a,b,c){this.text="";this.packetLength=c;for(var d=0;dg.signatureType){this.certificationSignatures[this.certificationSignatures.length]=g;break}else if(48==g.signatureType){this.certificationRevocationSignatures[this.certificationRevocationSignatures.length]=g;break}else if(24==g.signatureType){this.certificationSignatures[this.certificationSignatures.length]=g;break}else util.debug("unknown sig t: "+g.signatureType+"@"+(e-(g.packetLength+g.headerLength))); -default:return this.data=b,this.position=c-a.packetLength,this.len=e-c-(g.headerLength+g.packetLength)}}this.data=b;this.position=c-a.packetLength;return this.len=e-c-(g.headerLength+g.packetLength)}if(5==a.tagType){this.parentNode=a;for(e=c;b.length!=e;)if(g=openpgp_packet.read_packet(b,e,f-(e-c)),null==g){util.print_error("parsing ends here @:"+e+" l:"+f);break}else switch(e+=g.packetLength+g.headerLength,g.tagType){case 2:15g.signatureType?this.certificationSignatures[this.certificationSignatures.length]= -g:48==g.signatureType&&(this.certificationRevocationSignatures[this.certificationRevocationSignatures.length]=g);default:return this.data=b,this.position=c-a.packetLength,this.len=e-c-(g.headerLength+g.packetLength)}}else util.print_error("unknown parent node for a userId packet "+a.tagType)}} +b=0;bh.signatureType){this.certificationSignatures[this.certificationSignatures.length]=h;break}else if(48==h.signatureType){this.certificationRevocationSignatures[this.certificationRevocationSignatures.length]=h;break}else if(24==h.signatureType){this.certificationSignatures[this.certificationSignatures.length]=h;break}else util.debug("unknown sig t: "+h.signatureType+"@"+(e-(h.packetLength+h.headerLength))); +default:return this.data=b,this.position=c-a.packetLength,this.len=e-c-(h.headerLength+h.packetLength)}}this.data=b;this.position=c-a.packetLength;return this.len=e-c-(h.headerLength+h.packetLength)}if(5==a.tagType){this.parentNode=a;for(e=c;b.length!=e;)if(h=openpgp_packet.read_packet(b,e,f-(e-c)),null==h){util.print_error("parsing ends here @:"+e+" l:"+f);break}else switch(e+=h.packetLength+h.headerLength,h.tagType){case 2:15h.signatureType?this.certificationSignatures[this.certificationSignatures.length]= +h:48==h.signatureType&&(this.certificationRevocationSignatures[this.certificationRevocationSignatures.length]=h);default:return this.data=b,this.position=c-a.packetLength,this.len=e-c-(h.headerLength+h.packetLength)}}else util.print_error("unknown parent node for a userId packet "+a.tagType)}} function openpgp_packet_encryptedintegrityprotecteddata(){this.tagType=18;this.hash=this.decrytpedData=this.encryptedData=this.packetLength=this.version=null;this.write_packet=function(a,b,c){var d=openpgp_crypto_getPrefixRandom(a),e=d+d.charAt(d.length-2)+d.charAt(d.length-1),c=c+String.fromCharCode(211),c=c+String.fromCharCode(20);util.print_debug_hexstr_dump("data to be hashed:",e+c);c+=str_sha1(e+c);util.print_debug_hexstr_dump("hash:",c.substring(c.length-20,c.length));a=openpgp_crypto_symmetricEncrypt(d, a,b,c,!1).substring(0,e.length+c.length);b=openpgp_packet.write_packet_header(18,a.length+1)+String.fromCharCode(1);this.encryptedData=a;return b+a};this.read_packet=function(a,b,c){this.packetLength=c;this.version=a[b].charCodeAt();if(1!=this.version)return util.print_error("openpgp.packet.encryptedintegrityprotecteddata.js\nunknown encrypted integrity protected data packet version: "+this.version+" , @ "+b+"hex:"+util.hexstrdump(a)),null;this.encryptedData=a.substring(b+1,b+1+c);util.print_debug("openpgp.packet.encryptedintegrityprotecteddata.js\n"+ this.toString());return this};this.toString=function(){var a="";openpgp.config.debug&&(a=" data: Bytes ["+util.hexstrdump(this.encryptedData)+"]");return"5.13. Sym. Encrypted Integrity Protected Data Packet (Tag 18)\n length: "+this.packetLength+"\n version: "+this.version+"\n"+a};this.decrypt=function(a,b){this.decryptedData=openpgp_crypto_symmetricDecrypt(a,b,this.encryptedData,!1);this.hash=str_sha1(openpgp_crypto_MDCSystemBytes(a,b,this.encryptedData)+this.decryptedData.substring(0, @@ -118,7 +118,7 @@ this.decryptedData.length-20));util.print_debug_hexstr_dump("calc hash = ",this. function openpgp_packet_onepasssignature(){this.tagType=4;this.flags=this.signingKeyId=this.publicKeyAlgorithm=this.hashAlgorithm=this.version=null;this.read_packet=function(a,b,c){this.packetLength=c;this.version=a.charCodeAt(b++);this.type=a.charCodeAt(b++);this.hashAlgorithm=a.charCodeAt(b++);this.publicKeyAlgorithm=a.charCodeAt(b++);this.signingKeyId=new openpgp_type_keyid;this.signingKeyId.read_packet(a,b);b+=8;this.flags=a.charCodeAt(b++);return this};this.toString=function(){return"5.4. One-Pass Signature Packets (Tag 4)\n length: "+ this.packetLength+"\n type: "+this.type+"\n keyID: "+this.signingKeyId.toString()+"\n hashA: "+this.hashAlgorithm+"\n pubKeyA:"+this.publicKeyAlgorithm+"\n flags: "+this.flags+"\n version:"+this.version+"\n"};this.write_packet=function(a,b,c,d,e){d=""+openpgp_packet.write_packet_header(4,13);d+=String.fromCharCode(3);d+=String.fromCharCode(a);d+=String.fromCharCode(b);d+=String.fromCharCode(c.privateKeyPacket.publicKey.publicKeyAlgorithm);d+=c.getKeyId();return d=e?d+String.fromCharCode(0): d+String.fromCharCode(1)}} -function openpgp_config(){this.config=null;this.default_config={prefer_hash_algorithm:2,encryption_cipher:9,compression:1,show_version:!0,show_comment:!0,integrity_protect:!0,composition_behavior:0,keyserver:"keyserver.linux.it"};this.versionstring="OpenPGP.js v.1.20120827";this.commentstring="http://openpgpjs.org";this.debug=!1;this.read=function(){var a=JSON.parse(window.localStorage.getItem("config"));null==a?(this.config=this.default_config,this.write()):this.config=a};this.write=function(){window.localStorage.setItem("config", +function openpgp_config(){this.config=null;this.default_config={prefer_hash_algorithm:2,encryption_cipher:9,compression:1,show_version:!0,show_comment:!0,integrity_protect:!0,composition_behavior:0,keyserver:"keyserver.linux.it"};this.versionstring="OpenPGP.js v.1.20120904";this.commentstring="http://openpgpjs.org";this.debug=!1;this.read=function(){var a=JSON.parse(window.localStorage.getItem("config"));null==a?(this.config=this.default_config,this.write()):this.config=a};this.write=function(){window.localStorage.setItem("config", JSON.stringify(this.config))}} function openpgp_type_s2k(){this.read=function(a,b){var c=b;this.type=a[c++].charCodeAt();switch(this.type){case 0:this.hashAlgorithm=a[c++].charCodeAt();this.s2kLength=1;break;case 1:this.hashAlgorithm=a[c++].charCodeAt();this.saltValue=a.substring(c,c+8);this.s2kLength=9;break;case 3:this.hashAlgorithm=a[c++].charCodeAt();this.saltValue=a.substring(c,c+8);c+=8;this.EXPBIAS=6;c=a[c++].charCodeAt();this.count=16+(c&15)<<(c>>4)+this.EXPBIAS;this.s2kLength=10;break;default:util.print_error("unknown s2k type! "+this.type)}return this}; this.write=function(a,b,c,d,e){this.type=a;if(3==this.type)this.saltValue=d,this.hashAlgorithm=b,this.count=16+(e&15)<<(e>>4)+6,this.s2kLength=10;return this.produce_key(c)};this.produce_key=function(a,b){if(0==this.type)return openpgp_crypto_hashData(this.hashAlgorithm,a);if(1==this.type)return openpgp_crypto_hashData(this.hashAlgorithm,this.saltValue+a);if(3==this.type){var c=[];for(c[0]=this.saltValue+a;c.length*(this.saltValue+a).length @@ -139,73 +139,28 @@ a.replace(/\n/g,"
")+"

"))};this.print_debug_hexstr_dump=function(a,b a.replace(/\n/g,"
")+"

")};this.print_info=function(a){a=openpgp_encoding_html_encode(a);showMessages('

INFO:\t'+a.replace(/\n/g,"
")+"

")};this.print_warning=function(a){a=openpgp_encoding_html_encode(a);showMessages('

WARNING:\t'+ a.replace(/\n/g,"
")+"

")};this.getLeftNBits=function(a,b){var c=b%8;return 0==c?a.substring(0,b/8):this.shiftRight(a.substring(0,(b-c)/8+1),8-c)};this.shiftRight=function(a,b){var c=util.str2bin(a);if(0!=b%8)for(var d=c.length-1;0<=d;d--)c[d]>>=b%8,0>=1;0==da&&(da=b(),a=da&1,da=da>>1|128);return a}function d(b){for(var a=0,d=b;d--;)a=a<<1|c();b&&(a=fa[a]>>8-b);return a}function e(b){na++;o[A++]=b;l.push(String.fromCharCode(b));32768==A&&(A=0)}function f(){this.b1=this.b0=0;this.jump=null;this.jumppos=-1}function g(){for(;;){if(ga[T]>=sa)return-1;if(oa[ga[T]]==T)return ga[T]++;ga[T]++}}function h(){var b=P[ha],a;p&&document.write("
len:"+ -T+" treepos:"+ha);if(17==T)return-1;ha++;T++;a=g();p&&document.write("
IsPat "+a);if(0<=a)b.b0=a,p&&document.write("
b0 "+b.b0);else if(b.b0=32768,p&&document.write("
b0 "+b.b0),h())return-1;a=g();if(0<=a)b.b1=a,p&&document.write("
b1 "+b.b1),b.jump=null;else if(b.b1=32768,p&&document.write("
b1 "+b.b1),b.jump=P[ha],b.jumppos=ha,h())return-1;T--;return 0}function k(b,a,c,d){p&&document.write("currentTree "+b+" numval "+a+" lengths "+c+" show "+d);P=b;ha=0;oa=c;sa=a;for(b=0;17>b;b++)ga[b]= -0;T=0;if(h())return p&&alert("invalid huffman tree\n"),-1;if(p){document.write("
Tree: "+P.length);for(b=0;32>b;b++)document.write("Places["+b+"].b0="+P[b].b0+"
"),document.write("Places["+b+"].b1="+P[b].b1+"
")}return 0}function j(b){for(var a,d,e=0,f=b[e];;)if(a=c(),p&&document.write("b="+a),a){if(!(f.b1&32768))return p&&document.write("ret1"),f.b1;f=f.jump;a=b.length;for(d=0;d>1,23g)e(g);else if(256==g)break;else{var N;g-=257;m=d(O[g])+la[g];g=fa[d(5)]>>3;8g;g++)u[g]=0;for(g=0;gdistanceTree");for(g=0;g"+K[g].b0+" "+K[g].b1+" "+K[g].jump+" "+K[g].jumppos)}m= -h+N;E=0;var Y=-1;for(p&&document.write("
n="+m+" bits: "+Q+"
");E"+Y+" i:"+E+" decode: "+g+" bits "+Q+"
"),16>g)u[E++]=g;else if(16==g){var l;g=3+d(2);if(E+g>m)return A=0,1;for(l=E?u[E-1]:0;g--;)u[E++]=l}else{g=17==g?3+d(3):11+d(7);if(E+g>m)return A=0,1;for(;g--;)u[E++]=0}m=aa.length;for(E=0;EliteralTree");;)if(g=j(aa),256<=g){g-=256;if(0==g)break;g--;m=d(O[g])+la[g];g=j(K);8>2,c=(c&3)<<4|d>>4,g=(d&15)<<2|e>>6,h=e&63,isNaN(d)?g=h=64:isNaN(e)&&(h=64),b.push([this._keyStr.charAt(f),this._keyStr.charAt(c),this._keyStr.charAt(g),this._keyStr.charAt(h)].join(""));return b.join("")},decode:function(a,b){for(var c=[],d,e,f,g,h, -k=0,a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k>4,e=(e&15)<<4|g>>2,f=(g&3)<<6|h,c.push(String.fromCharCode(d)),64!=g&&c.push(String.fromCharCode(e)),64!=h&&c.push(String.fromCharCode(f));c=c.join("");b&&(c=JXG.Util.Base64._utf8_decode(c));return c},_utf8_encode:function(a){for(var a=a.replace(/\r\n/g,"\n"),b="",c=0;c>=1;0==D&&(D=b(),a=D&1,D=D>>1|128);return a}function d(b){for(var a=0,d=b;d--;)a=a<<1|c();b&&(a=K[a]>>8-b);return a}function e(b){T++;t[r++]=b;q.push(String.fromCharCode(b));32768==r&&(r=0)}function f(){this.b1=this.b0=0;this.jump=null;this.jumppos=-1}function h(){for(;;){if(V[O]>=pa)return-1;if(qa[V[O]]==O)return V[O]++;V[O]++}}function g(){var b=Z[aa],a;m&&document.write("
len:"+O+" treepos:"+ +aa);if(17==O)return-1;aa++;O++;a=h();m&&document.write("
IsPat "+a);if(0<=a)b.b0=a,m&&document.write("
b0 "+b.b0);else if(b.b0=32768,m&&document.write("
b0 "+b.b0),g())return-1;a=h();if(0<=a)b.b1=a,m&&document.write("
b1 "+b.b1),b.jump=null;else if(b.b1=32768,m&&document.write("
b1 "+b.b1),b.jump=Z[aa],b.jumppos=aa,g())return-1;O--;return 0}function k(b,a,c,d){m&&document.write("currentTree "+b+" numval "+a+" lengths "+c+" show "+d);Z=b;aa=0;qa=c;pa=a;for(b=0;17>b;b++)V[b]=0;O=0;if(g())return m&& +alert("invalid huffman tree\n"),-1;if(m){document.write("
Tree: "+Z.length);for(b=0;32>b;b++)document.write("Places["+b+"].b0="+Z[b].b0+"
"),document.write("Places["+b+"].b1="+Z[b].b1+"
")}return 0}function j(b){for(var a,d,e=0,f=b[e];;)if(a=c(),m&&document.write("b="+a),a){if(!(f.b1&32768))return m&&document.write("ret1"),f.b1;f=f.jump;a=b.length;for(d=0;d>1,23g)e(g);else if(256==g)break;else{var A;g-=257;l=d(M[g])+P[g];g=K[d(5)]>>3;8g;g++)R[g]=0;for(g=0;gdistanceTree");for(g=0;g"+U[g].b0+" "+U[g].b1+" "+U[g].jump+" "+U[g].jumppos)}l=h+A;y=0;var q= +-1;for(m&&document.write("
n="+l+" bits: "+ca+"
");y"+q+" i:"+y+" decode: "+g+" bits "+ca+"
"),16>g)R[y++]=g;else if(16==g){var o;g=3+d(2);if(y+g>l)return r=0,1;for(o=y?R[y-1]:0;g--;)R[y++]=o}else{g=17==g?3+d(3):11+d(7);if(y+g>l)return r=0,1;for(;g--;)R[y++]=0}l=da.length;for(y=0;yliteralTree");;)if(g= +j(da),256<=g){g-=256;if(0==g)break;g--;l=d(M[g])+P[g];g=j(U);8>2,c=(c&3)<<4|d>>4,h=(d&15)<<2|e>>6,g=e&63,isNaN(d)?h=g=64:isNaN(e)&&(g=64),b.push([this._keyStr.charAt(f),this._keyStr.charAt(c),this._keyStr.charAt(h),this._keyStr.charAt(g)].join(""));return b.join("")},decode:function(a,b){for(var c=[],d,e,f,h,g, +k=0,a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k>4,e=(e&15)<<4|h>>2,f=(h&3)<<6|g,c.push(String.fromCharCode(d)),64!=h&&c.push(String.fromCharCode(e)),64!=g&&c.push(String.fromCharCode(f));c=c.join("");b&&(c=JXG.Util.Base64._utf8_decode(c));return c},_utf8_encode:function(a){for(var a=a.replace(/\r\n/g,"\n"),b="",c=0;cd?b+=String.fromCharCode(d):(127d?b+=String.fromCharCode(d>>6|192):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128)),b+=String.fromCharCode(d&63|128))}return b},_utf8_decode:function(a){for(var b=[],c=0,d=0,e=0,f=0;cd?(b.push(String.fromCharCode(d)),c++):191d?(e=a.charCodeAt(c+1),b.push(String.fromCharCode((d&31)<<6|e&63)),c+=2):(e=a.charCodeAt(c+1),f=a.charCodeAt(c+2),b.push(String.fromCharCode((d&15)<<12| (e&63)<<6|f&63)),c+=3);return b.join("")},_destrip:function(a,b){var c=[],d,e,f=[];null==b&&(b=76);a.replace(/ /g,"");d=a.length/b;for(e=0;ed?(b.push(String.fromCharCode(d)),c++):191d?(e=a.charCodeAt(c+1),b.push(String.fromCharCode((d&31)<<6|e&63)),c+=2):(e=a.charCodeAt(c+1),f=a.charCodeAt(c+2),b.push(String.fromCharCode((d&15)<<12|(e&63)<<6|f&63)),c+=3);return b.join("")}; -JXG.Util.genUUID=function(){for(var a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),b=Array(36),c=0,d,e=0;36>e;e++)8==e||13==e||18==e||23==e?b[e]="-":14==e?b[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,b[e]=a[19==e?d&3|8:d]);return b.join("")};(function(a){a.zip={useWebWorkers:!1}})(this); -(function(a){function b(){function a(b,c,d,Ca,j,Q,w,E,m,q,r){var N,p,v,s,x,t,Y,B,aa,ba;Y=0;v=d;do e[b[c+Y]]++,Y++,v--;while(0!==v);if(e[0]==d)return w[0]=-1,E[0]=0,h;t=E[0];for(s=1;s<=O&&!(0!==e[s]);s++);x=s;tv&&(t=v);E[0]=t;for(E=1<(E-=e[s]))return u;if(0>(E-=e[v]))return u;e[v]+=E;k[1]=s=0;Y=1;for(B=2;0!==--v;)k[B]=s+=e[Y],B++,Y++;Y=v=0;do{if(0!==(s=b[c+Y]))r[k[s]++]=v;Y++}while(++vaa+t;){c++;aa+=t;ba=p-aa;ba=ba>t?t:ba;if((N=1<<(s=x-aa))>b+1)if(N-=b+1,B=x,sW)return u;g[c]=B=q[0];q[0]+=ba;0!==c?(k[c]=v,f[0]=s,f[1]=t,s=v>>>aa-t,f[2]=B-g[c-1]-s,m.set(f,3*(g[c-1]+s))):w[0]=B}f[1]=x-aa;Y>=d?f[0]=192:r[Y]r[Y]?0:96,f[2]=r[Y++]):(f[0]=Q[r[Y]-Ca]+16+64,f[2]=j[r[Y++]-Ca]);N=1<>>aa;s>>=1)v^=s;v^=s;for(s=(1<< -aa)-1;(v&s)!=k[c];)c--,aa-=t,s=(1<h;h++)f[h]=0;g.set(e.subarray(0,O),0);k.set(e.subarray(0,O+1),0)}var c,d,e,f,g,k;this.inflate_trees_bits=function(e,f,g,h,k){b(19);c[0]=0;e=a(e,0,19,19,null,null,g,f,h,c,d);if(e==u)k.msg="oversubscribed dynamic bit lengths tree";else if(e==l||0===f[0])k.msg= -"incomplete dynamic bit lengths tree",e=u;return e};this.inflate_trees_dynamic=function(e,f,g,k,j,Q,w,E,m){b(288);c[0]=0;Q=a(g,0,e,257,ka,na,Q,k,E,c,d);if(Q!=h||0===k[0]){if(Q==u)m.msg="oversubscribed literal/length tree";else if(Q!=D)m.msg="incomplete literal/length tree",Q=u;return Q}b(288);Q=a(g,e,f,0,fa,la,w,j,E,c,d);if(Q!=h||0===j[0]&&257r;)T--,q|=(x.read_byte(L++)&255)<>=z[O+1],r-=z[O+1],s.window[P++]=z[O+2],oa--;else{do{q>>=z[O+1];r-=z[O+1];if(0!==(o&16)){o&=15;R=z[O+2]+(q&p[o]);q>>=o;for(r-=o;15>r;)T--,q|=(x.read_byte(L++)&255)<>=z[O+1],r-=z[O+1], -0!==(o&16)){for(o&=15;r>=o;r-=o;oa-=R;if(P>=K)K=P-K,0P-K?(s.window[P++]=s.window[K++],s.window[P++]=s.window[K++]):(s.window.set(s.window.subarray(K,K+2),P),P+=2,K+=2),R-=2;else{K=P-K;do K+=s.end;while(0>K);o=s.end-K;if(R>o){R-=o;if(0P-K){do s.window[P++]=s.window[K++];while(0!==--o)}else s.window.set(s.window.subarray(K,K+o),P),P+=o;K=0}}if(0P-K){do s.window[P++]=s.window[K++];while(0!==--R)}else s.window.set(s.window.subarray(K, -K+R),P),P+=R;break}else if(0===(o&64))K+=z[O+2],K+=q&p[o],O=3*(ha+K),o=z[O];else{x.msg="invalid distance code";R=x.avail_in-T;R=r>>3>3:R;T+=R;L-=R;r-=R<<3;s.bitb=q;s.bitk=r;x.avail_in=T;x.total_in+=L-x.next_in_index;x.next_in_index=L;s.write=P;V=u;break a}while(1);break}if(0===(o&64)){if(K+=z[O+2],K+=q&p[o],O=3*(ha+K),0===(o=z[O])){q>>=z[O+1];r-=z[O+1];s.window[P++]=z[O+2];oa--;break}}else{if(0!==(o&32)){R=x.avail_in-T;R=r>>3>3:R;T+=R;L-=R;r-=R<<3;s.bitb=q;s.bitk=r;x.avail_in=T;x.total_in+= -L-x.next_in_index;x.next_in_index=L;s.write=P;V=k;break a}x.msg="invalid literal/length code";R=x.avail_in-T;R=r>>3>3:R;T+=R;L-=R;r-=R<<3;s.bitb=q;s.bitk=r;x.avail_in=T;x.total_in+=L-x.next_in_index;x.next_in_index=L;s.write=P;V=u;break a}}while(1)}}while(258<=oa&&10<=T);R=x.avail_in-T;R=r>>3>3:R;T+=R;L-=R;r-=R<<3;s.bitb=q;s.bitk=r;x.avail_in=T;x.total_in+=L-x.next_in_index;x.next_in_index=L;s.write=P;V=h}v=y.next_in_index;s=y.avail_in;U=w.bitb;C=w.bitk;x=w.write;o=x>>=c[q+1];C-=c[q+1];r=c[q];if(0===r){f=c[q+2];a=Q;break}if(0!==(r&16)){g=r&15;b=c[q+2];a=qa;break}if(0===(r&64)){e=r;d=q/3+c[q+2];break}if(0!==(r&32)){a=E;break}a=Y;y.msg="invalid literal/length code";V=u;w.bitb=U;w.bitk=C;y.avail_in=s;y.total_in+= -v-y.next_in_index;y.next_in_index=v;w.write=x;return w.inflate_flush(y,V);case qa:for(q=g;C>=q;C-=q;e=B;c=A;d=D;a=ea;case ea:for(q=e;C>=c[q+1];C-=c[q+1];r=c[q];if(0!==(r&16)){g=r&15;j=c[q+2];a=ca;break}if(0===(r&64)){e=r;d=q/3+c[q+2];break}a=Y;y.msg="invalid distance code";V=u;w.bitb=U;w.bitk=C;y.avail_in=s;y.total_in+=v-y.next_in_index;y.next_in_index=v;w.write=x;return w.inflate_flush(y,V);case ca:for(q=g;C>=q;C-=q;a=da;case da:for(q= -x-j;0>q;)q+=w.end;for(;0!==b;){if(0===o&&(x==w.end&&0!==w.read&&(x=0,o=xa.avail_out)c=a.avail_out;0!==c&&b==l&&(b=h);a.avail_out-=c;a.total_out+=c;a.next_out.set(e.window.subarray(f,f+c),d);d+=c;f+=c;if(f==e.end){f=0;if(e.write==e.end)e.write=0;c=e.write-f;if(c>a.avail_out)c=a.avail_out; -0!==c&&b==l&&(b=h);a.avail_out-=c;a.total_out+=c;a.next_out.set(e.window.subarray(f,f+c),d);d+=c;f+=c}a.next_out_index=d;e.read=f;return b};e.proc=function(a,c){var d,q,r,l,C,v,s;l=a.next_in_index;C=a.avail_in;q=e.bitb;r=e.bitk;v=e.write;for(s=vr;){if(0!==C)c=h;else return e.bitb=q,e.bitk=r,a.avail_in=C,a.total_in+=l-a.next_in_index,a.next_in_index=l,e.write=v,e.inflate_flush(a,c);C--;q|=(a.read_byte(l++)&255)<>>1){case 0:q>>>= -3;r-=3;d=r&7;q>>>=d;r-=d;f=ha;break;case 1:d=[];var x=[],z=[[]],ba=[[]];b.inflate_trees_fixed(d,x,z,ba,a);o.init(d[0],x[0],z[0],0,ba[0],0,a);q>>>=3;r-=3;f=sa;break;case 2:q>>>=3;r-=3;f=T;break;case 3:return q>>>=3,r-=3,f=ma,a.msg="invalid block type",c=u,e.bitb=q,e.bitk=r,a.avail_in=C,a.total_in+=l-a.next_in_index,a.next_in_index=l,e.write=v,e.inflate_flush(a,c)}break;case ha:for(;32>r;){if(0!==C)c=h;else return e.bitb=q,e.bitk=r,a.avail_in=C,a.total_in+=l-a.next_in_index,a.next_in_index=l,e.write= -v,e.inflate_flush(a,c);C--;q|=(a.read_byte(l++)&255)<>>16&65535)!=(q&65535))return f=ma,a.msg="invalid stored block lengths",c=u,e.bitb=q,e.bitk=r,a.avail_in=C,a.total_in+=l-a.next_in_index,a.next_in_index=l,e.write=v,e.inflate_flush(a,c);g=q&65535;q=r=0;f=0!==g?P:0!==Y?B:K;break;case P:if(0===C||0===s&&(v==e.end&&0!==e.read&&(v=0,s=vC&&(d=C);d>s&&(d=s);e.window.set(a.read_buf(l,d),v);l+=d;C-=d;v+=d;s-=d;if(0!==(g-=d))break;f=0!==Y?B:K;break;case T:for(;14>r;){if(0!==C)c=h;else return e.bitb=q,e.bitk=r,a.avail_in=C,a.total_in+=l-a.next_in_index,a.next_in_index=l,e.write=v,e.inflate_flush(a,c);C--;q|=(a.read_byte(l++)&255)<>5&31))return f=ma, -a.msg="too many length or distance symbols",c=u,e.bitb=q,e.bitk=r,a.avail_in=C,a.total_in+=l-a.next_in_index,a.next_in_index=l,e.write=v,e.inflate_flush(a,c);d=258+(d&31)+(d>>5&31);if(!E||E.length>>=14;r-=14;Q=0;f=ga;case ga:for(;Q<4+(j>>>10);){for(;3>r;){if(0!==C)c=h;else return e.bitb=q,e.bitk=r,a.avail_in=C,a.total_in+=l-a.next_in_index,a.next_in_index=l,e.write=v,e.inflate_flush(a,c);C--;q|=(a.read_byte(l++)&255)<>>=3;r-=3}for(;19> -Q;)E[aa[Q++]]=0;N[0]=7;d=D.inflate_trees_bits(E,N,t,A,a);if(d!=h)return c=d,c==u&&(E=null,f=ma),e.bitb=q,e.bitk=r,a.avail_in=C,a.total_in+=l-a.next_in_index,a.next_in_index=l,e.write=v,e.inflate_flush(a,c);Q=0;f=oa;case oa:for(;;){d=j;if(!(Q<258+(d&31)+(d>>5&31)))break;for(d=N[0];rz)q>>>=d,r-=d,E[Q++]=z;else{s=18==z?7:z-14;for(x=18==z?11:3;r>>=d;r-=d;x+=q&p[s];q>>>=s;r-=s;s=Q;d=j;if(s+x>258+(d&31)+(d>>5&31)||16==z&&1>s)return E=null,f=ma,a.msg="invalid bit length repeat",c=u,e.bitb=q,e.bitk=r,a.avail_in=C,a.total_in+=l-a.next_in_index,a.next_in_index=l,e.write=v,e.inflate_flush(a,c);z= -16==z?E[s-1]:0;do E[s++]=z;while(0!==--x);Q=s}}t[0]=-1;s=[];x=[];z=[];ba=[];s[0]=9;x[0]=6;d=j;d=D.inflate_trees_dynamic(257+(d&31),1+(d>>5&31),E,s,x,z,ba,A,a);if(d!=h)return d==u&&(E=null,f=ma),c=d,e.bitb=q,e.bitk=r,a.avail_in=C,a.total_in+=l-a.next_in_index,a.next_in_index=l,e.write=v,e.inflate_flush(a,c);o.init(s[0],x[0],A,z[0],A,ba[0],a);f=sa;case sa:e.bitb=q;e.bitk=r;a.avail_in=C;a.total_in+=l-a.next_in_index;a.next_in_index=l;e.write=v;if((c=o.proc(e,a,c))!=k)return e.inflate_flush(a,c);c=h; -o.free(a);l=a.next_in_index;C=a.avail_in;q=e.bitb;r=e.bitk;v=e.write;s=ve||15>4)+8>a.istate.wbits){a.istate.mode=pa;a.msg="invalid window size";a.istate.marker=5;break}a.istate.mode=ja;case ja:if(0===a.avail_in)return c;c=b;a.avail_in--;a.total_in++;d=a.read_byte(a.next_in_index++)&255;if(0!==((a.istate.method<<8)+d)%31){a.istate.mode=pa;a.msg="incorrect header check";a.istate.marker=5;break}if(0===(d&ia)){a.istate.mode=ra;break}a.istate.mode= -wa;case wa:if(0===a.avail_in)return c;c=b;a.avail_in--;a.total_in++;a.istate.need=(a.read_byte(a.next_in_index++)&255)<<24&4278190080;a.istate.mode=xa;case xa:if(0===a.avail_in)return c;c=b;a.avail_in--;a.total_in++;a.istate.need+=(a.read_byte(a.next_in_index++)&255)<<16&16711680;a.istate.mode=ya;case ya:if(0===a.avail_in)return c;c=b;a.avail_in--;a.total_in++;a.istate.need+=(a.read_byte(a.next_in_index++)&255)<<8&65280;a.istate.mode=za;case za:if(0===a.avail_in)return c;a.avail_in--;a.total_in++; -a.istate.need+=a.read_byte(a.next_in_index++)&255;a.istate.mode=ta;return j;case ta:return a.istate.mode=pa,a.msg="need dictionary",a.istate.marker=0,m;case ra:c=a.istate.blocks.proc(a,c);if(c==u){a.istate.mode=pa;a.istate.marker=0;break}c==h&&(c=b);if(c!=k)return c;a.istate.blocks.reset(a,a.istate.was);a.istate.mode=Aa;case Aa:return k;case pa:return u;default:return m}};b.inflateSetDictionary=function(a,b,c){var d=0,e=c;if(!a||!a.istate||a.istate.mode!=ta)return m;e>=1<e;)b.read_byte(d)==t[e]?e++:e=0!==b.read_byte(d)?0:4-e,d++,c--;b.total_in+=d-b.next_in_index;b.next_in_index=d;b.avail_in=c;b.istate.marker=e;if(4!=e)return u;c=b.total_in;d=b.total_out;a(b);b.total_in=c;b.total_out=d;b.istate.mode= -ra;return h};b.inflateSyncPoint=function(a){return!a||!a.istate||!a.istate.blocks?m:a.istate.blocks.sync_point()}}function f(){}function g(){var a=new f,b=L,c=new Uint8Array(512),d=!1;a.inflateInit();a.next_out=c;this.append=function(e,f){var g,j=[],Q=0,E=0,m=0,N;if(0!==e.length){a.next_in_index=0;a.next_in=e;a.avail_in=e.length;do{a.next_out_index=0;a.avail_out=512;if(0===a.avail_in&&!d)a.next_in_index=0,d=!0;g=a.inflate(b);if(d&&g==l)return-1;if(g!=h&&g!=k)throw"inflating: "+a.msg;if((d||g==k)&& -a.avail_out==e.length)return-1;a.next_out_index&&(512==a.next_out_index?j.push(new Uint8Array(c)):j.push(new Uint8Array(c.subarray(0,a.next_out_index))));m+=a.next_out_index;if(f&&0e;e++)8==e||13==e||18==e||23==e?b[e]="-":14==e?b[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,b[e]=a[19==e?d&3|8:d]);return b.join("")}; function openpgp_crypto_symmetricEncrypt(a,b,c,d,e){switch(b){case 0:return d;case 2:return openpgp_cfb_encrypt(a,desede,d,8,c,e).substring(0,d.length+10);case 3:return openpgp_cfb_encrypt(a,cast5_encrypt,d,8,c,e).substring(0,d.length+10);case 4:return openpgp_cfb_encrypt(a,BFencrypt,d,8,c,e).substring(0,d.length+10);case 7:case 8:case 9:return openpgp_cfb_encrypt(a,AESencrypt,d,16,keyExpansion(c),e).substring(0,d.length+18);case 10:return openpgp_cfb_encrypt(a,TFencrypt,d,16,c,e).substring(0,d.length+ 18);case 1:return util.print_error("IDEA Algorithm not implemented"),null;default:return null}} function openpgp_crypto_symmetricDecrypt(a,b,c,d){util.print_debug_hexstr_dump("openpgp_crypto_symmetricDecrypt:\nalgo:"+a+"\nencrypteddata:",c);var e=0;d||(e=2);switch(a){case 0:return c;case 2:return openpgp_cfb_decrypt(desede,8,b,c,d).substring(e,c.length+e-10);case 3:return openpgp_cfb_decrypt(cast5_encrypt,8,b,c,d).substring(e,c.length+e-10);case 4:return openpgp_cfb_decrypt(BFencrypt,8,b,c,d).substring(e,c.length+e-10);case 7:case 8:case 9:return openpgp_cfb_decrypt(AESencrypt,16,keyExpansion(b), @@ -216,43 +171,43 @@ function openpgp_crypto_getPrefixRandom(a){switch(a){case 2:case 3:case 4:return function openpgp_crypto_MDCSystemBytes(a,b,c){util.print_debug_hexstr_dump("openpgp_crypto_symmetricDecrypt:\nencrypteddata:",c);switch(a){case 0:return c;case 2:return openpgp_cfb_mdc(desede,8,b,c,openpgp_cfb);case 3:return openpgp_cfb_mdc(cast5_encrypt,8,b,c);case 4:return openpgp_cfb_mdc(BFencrypt,8,b,c);case 7:case 8:case 9:return openpgp_cfb_mdc(AESencrypt,16,keyExpansion(b),c);case 10:return openpgp_cfb_mdc(TFencrypt,16,b,c);case 1:util.print_error(""+(1==a?"IDEA Algorithm not implemented": "Twofish Algorithm not implemented"))}return null}function openpgp_crypto_generateSessionKey(a){switch(a){case 2:case 8:return openpgp_crypto_getRandomBytes(24);case 3:case 4:case 7:return util.print_debug("length = 16:\n"+util.hexstrdump(openpgp_crypto_getRandomBytes(16))),openpgp_crypto_getRandomBytes(16);case 9:case 10:return openpgp_crypto_getRandomBytes(32)}return null} function openpgp_crypto_verifySignature(a,b,c,d,e){var f=openpgp_crypto_hashData(b,e);switch(a){case 1:case 2:case 3:e=new RSA;a=d[0].toBigInteger();d=d[1].toBigInteger();c=c[0].toBigInteger();d=e.verify(c,d,a);b=openpgp_encoding_emsa_pkcs1_decode(b,d.toMPI().substring(2));return-1==b?(util.print_error("PKCS1 padding in message or key incorrect. Aborting..."),!1):b==f;case 16:return util.print_error("signing with Elgamal is not defined in the OpenPGP standard."),null;case 17:var a=new DSA,f=c[0].toBigInteger(), -c=c[1].toBigInteger(),g=d[0].toBigInteger(),h=d[1].toBigInteger(),k=d[2].toBigInteger(),d=d[3].toBigInteger(),d=a.verify(b,f,c,e,g,h,k,d);return 0==d.compareTo(f);default:return null}} -function openpgp_crypto_signData(a,b,c,d,e){switch(b){case 1:case 2:case 3:var b=new RSA,d=d[0].toBigInteger(),f=c[0].toBigInteger(),a=openpgp_encoding_emsa_pkcs1_encode(a,e,c[0].mpiByteLength);util.print_debug("signing using RSA");return b.sign(a,d,f).toMPI();case 17:b=new DSA;util.print_debug("DSA Sign: q size in Bytes:"+c[1].getByteLength());var f=c[0].toBigInteger(),g=c[1].toBigInteger(),h=c[2].toBigInteger();c[3].toBigInteger();c=d[0].toBigInteger();a=b.sign(a,e,h,f,g,c);util.print_debug("signing using DSA\n result:"+ +c=c[1].toBigInteger(),h=d[0].toBigInteger(),g=d[1].toBigInteger(),k=d[2].toBigInteger(),d=d[3].toBigInteger(),d=a.verify(b,f,c,e,h,g,k,d);return 0==d.compareTo(f);default:return null}} +function openpgp_crypto_signData(a,b,c,d,e){switch(b){case 1:case 2:case 3:var b=new RSA,d=d[0].toBigInteger(),f=c[0].toBigInteger(),a=openpgp_encoding_emsa_pkcs1_encode(a,e,c[0].mpiByteLength);util.print_debug("signing using RSA");return b.sign(a,d,f).toMPI();case 17:b=new DSA;util.print_debug("DSA Sign: q size in Bytes:"+c[1].getByteLength());var f=c[0].toBigInteger(),h=c[1].toBigInteger(),g=c[2].toBigInteger();c[3].toBigInteger();c=d[0].toBigInteger();a=b.sign(a,e,g,f,h,c);util.print_debug("signing using DSA\n result:"+ util.hexstrdump(a[0])+"|"+util.hexstrdump(a[1]));return a[0]+a[1];case 16:return util.print_debug("signing with Elgamal is not defined in the OpenPGP standard."),null;default:return null}}function openpgp_crypto_hashData(a,b){var c=null;switch(a){case 1:c=MD5(b);break;case 2:c=str_sha1(b);break;case 3:c=RMDstring(b);break;case 8:c=str_sha256(b);break;case 9:c=str_sha384(b);break;case 10:c=str_sha512(b);break;case 11:c=str_sha224(b)}return c} function openpgp_crypto_getHashByteLength(a){switch(a){case 1:return 16;case 2:case 3:return 20;case 8:return 32;case 9:return 48;case 10:return 64;case 11:return 28}return null}function openpgp_crypto_getRandomBytes(a){for(var b="",c=0;cb-a;)window.crypto.getRandomValues(c);return a+Math.abs(c[0]&Math.pow(2,d)-1)}function openpgp_crypto_getSecureRandomOctet(){var a=new Uint32Array(1);window.crypto.getRandomValues(a);return a[0]&255} function openpgp_crypto_getRandomBigInteger(a){if(0>a)return null;var b=openpgp_crypto_getRandomBytes(Math.floor((a+7)/8));0=b.compareTo(a))){for(var c=b.subtract(a),d=openpgp_crypto_getRandomBigInteger(c.bitLength());d>c;)d=openpgp_crypto_getRandomBigInteger(c.bitLength());return a.add(d)}} function openpgp_crypto_testRSA(a){debugger;var b=new RSA,c=new openpgp_type_mpi;c.create(openpgp_encoding_eme_pkcs1_encode("ABABABAB",128));c=b.encrypt(c.toBigInteger(),a.ee,a.n);b.decrypt(c,a.d,a.p,a.q,a.u)} -function openpgp_crypto_generateKeyPair(a,b,c,d,e){var f,g,h=new Date,h=h.getTime()/1E3,h=String.fromCharCode(Math.floor(h/16777216%256))+String.fromCharCode(Math.floor(h/65536%256))+String.fromCharCode(Math.floor(h/256%256))+String.fromCharCode(Math.floor(h%256));switch(a){case 1:b=(new RSA).generate(b,"10001");f=(new openpgp_packet_keymaterial).write_private_key(a,b,c,d,e,h);g=(new openpgp_packet_keymaterial).write_public_key(a,b,h);break;default:util.print_error("Unknown keytype "+a)}return{privateKey:f, -publicKey:g}}var dbits,canary=244837814094590,j_lm=15715070==(canary&16777215);function BigInteger(a,b,c){null!=a&&("number"==typeof a?this.fromNumber(a,b,c):null==b&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,b))}function nbi(){return new BigInteger(null)}function am1(a,b,c,d,e,f){for(;0<=--f;){var g=b*this[a++]+c[d]+e,e=Math.floor(g/67108864);c[d++]=g&67108863}return e} -function am2(a,b,c,d,e,f){for(var g=b&32767,b=b>>15;0<=--f;){var h=this[a]&32767,k=this[a++]>>15,j=b*h+k*g,h=g*h+((j&32767)<<15)+c[d]+(e&1073741823),e=(h>>>30)+(j>>>15)+b*k+(e>>>30);c[d++]=h&1073741823}return e}function am3(a,b,c,d,e,f){for(var g=b&16383,b=b>>14;0<=--f;){var h=this[a]&16383,k=this[a++]>>14,j=b*h+k*g,h=g*h+((j&16383)<<14)+c[d]+e,e=(h>>28)+(j>>14)+b*k;c[d++]=h&268435455}return e} +function openpgp_crypto_generateKeyPair(a,b,c,d,e){var f,h,g=new Date,g=g.getTime()/1E3,g=String.fromCharCode(Math.floor(g/16777216%256))+String.fromCharCode(Math.floor(g/65536%256))+String.fromCharCode(Math.floor(g/256%256))+String.fromCharCode(Math.floor(g%256));switch(a){case 1:b=(new RSA).generate(b,"10001");f=(new openpgp_packet_keymaterial).write_private_key(a,b,c,d,e,g);h=(new openpgp_packet_keymaterial).write_public_key(a,b,g);break;default:util.print_error("Unknown keytype "+a)}return{privateKey:f, +publicKey:h}}var dbits,canary=244837814094590,j_lm=15715070==(canary&16777215);function BigInteger(a,b,c){null!=a&&("number"==typeof a?this.fromNumber(a,b,c):null==b&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,b))}function nbi(){return new BigInteger(null)}function am1(a,b,c,d,e,f){for(;0<=--f;){var h=b*this[a++]+c[d]+e,e=Math.floor(h/67108864);c[d++]=h&67108863}return e} +function am2(a,b,c,d,e,f){for(var h=b&32767,b=b>>15;0<=--f;){var g=this[a]&32767,k=this[a++]>>15,j=b*g+k*h,g=h*g+((j&32767)<<15)+c[d]+(e&1073741823),e=(g>>>30)+(j>>>15)+b*k+(e>>>30);c[d++]=g&1073741823}return e}function am3(a,b,c,d,e,f){for(var h=b&16383,b=b>>14;0<=--f;){var g=this[a]&16383,k=this[a++]>>14,j=b*g+k*h,g=h*g+((j&16383)<<14)+c[d]+e,e=(g>>28)+(j>>14)+b*k;c[d++]=g&268435455}return e} j_lm&&"Microsoft Internet Explorer"==navigator.appName?(BigInteger.prototype.am=am2,dbits=30):j_lm&&"Netscape"!=navigator.appName?(BigInteger.prototype.am=am1,dbits=26):(BigInteger.prototype.am=am3,dbits=28);BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=(1<=vv;++vv)BI_RC[rr++]=vv;rr=97;for(vv=10;36>vv;++vv)BI_RC[rr++]=vv;rr=65;for(vv=10;36>vv;++vv)BI_RC[rr++]=vv;function int2char(a){return BI_RM.charAt(a)}function intAt(a,b){var c=BI_RC[a.charCodeAt(b)];return null==c?-1:c}function bnpCopyTo(a){for(var b=this.t-1;0<=b;--b)a[b]=this[b];a.t=this.t;a.s=this.s}function bnpFromInt(a){this.t=1;this.s=0>a?-1:0;0a?this[0]=a+DV:this.t=0}function nbv(a){var b=nbi();b.fromInt(a);return b} -function bnpFromString(a,b){var c;if(16==b)c=4;else if(8==b)c=3;else if(256==b)c=8;else if(2==b)c=1;else if(32==b)c=5;else if(4==b)c=2;else{this.fromRadix(a,b);return}this.s=this.t=0;for(var d=a.length,e=!1,f=0;0<=--d;){var g=8==c?a[d]&255:intAt(a,d);0>g?"-"==a.charAt(d)&&(e=!0):(e=!1,0==f?this[this.t++]=g:f+c>this.DB?(this[this.t-1]|=(g&(1<>this.DB-f):this[this.t-1]|=g<=this.DB&&(f-=this.DB))}if(8==c&&0!=(a[0]&128))this.s=-1,0h?"-"==a.charAt(d)&&(e=!0):(e=!1,0==f?this[this.t++]=h:f+c>this.DB?(this[this.t-1]|=(h&(1<>this.DB-f):this[this.t-1]|=h<=this.DB&&(f-=this.DB))}if(8==c&&0!=(a[0]&128))this.s=-1,0this.s)return"-"+this.negate().toString(a);if(16==a)a=4;else if(8==a)a=3;else if(2==a)a=1;else if(32==a)a=5;else if(4==a)a=2;else return this.toRadix(a);var b=(1<>g))d=!0,e=int2char(c);for(;0<=f;)g>(g+=this.DB-a)):(c=this[f]>>(g-=a)&b,0>=g&&(g+=this.DB,--f)),0this.s)return"-"+this.negate().toString(a);if(16==a)a=4;else if(8==a)a=3;else if(2==a)a=1;else if(32==a)a=5;else if(4==a)a=2;else return this.toRadix(a);var b=(1<>h))d=!0,e=int2char(c);for(;0<=f;)h>(h+=this.DB-a)):(c=this[f]>>(h-=a)&b,0>=h&&(h+=this.DB,--f)),0this.s?this.negate():this}function bnCompareTo(a){var b=this.s-a.s;if(0!=b)return b;var c=this.t,b=c-a.t;if(0!=b)return b;for(;0<=--c;)if(0!=(b=this[c]-a[c]))return b;return 0}function nbits(a){var b=1,c;if(0!=(c=a>>>16))a=c,b+=16;if(0!=(c=a>>8))a=c,b+=8;if(0!=(c=a>>4))a=c,b+=4;if(0!=(c=a>>2))a=c,b+=2;0!=a>>1&&(b+=1);return b} function bnBitLength(){return 0>=this.t?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(a,b){var c;for(c=this.t-1;0<=c;--c)b[c+a]=this[c];for(c=a-1;0<=c;--c)b[c]=0;b.t=this.t+a;b.s=this.s}function bnpDRShiftTo(a,b){for(var c=a;c>d|g,g=(this[h]&e)<=this.t)b.t=0;else{var d=a%this.DB,e=this.DB-d,f=(1<>d;for(var g=c+1;g>d;0>d|h,h=(this[g]&e)<=this.t)b.t=0;else{var d=a%this.DB,e=this.DB-d,f=(1<>d;for(var h=c+1;h>d;0>=this.DB;if(a.t>=this.DB;d+=this.s}else{for(d+=this.s;c>=this.DB;d-=a.s}b.s=0>d?-1:0;-1>d?b[c++]=this.DV+d:0=b.DV)a[c+b.t]-=b.DV,a[c+b.t+1]=1}0=d.t)){var e=this.abs();if(e.t>this.F2:0),j=this.FV/k,k=(1<g&&BigInteger.ZERO.subTo(c,c)}}}}function bnMod(a){var b=nbi();this.abs().divRemTo(a,null,b);0>this.s&&0=d.t)){var e=this.abs();if(e.t>this.F2:0),j=this.FV/k,k=(1<h&&BigInteger.ZERO.subTo(c,c)}}}}function bnMod(a){var b=nbi();this.abs().divRemTo(a,null,b);0>this.s&&0a.s||0<=a.compareTo(this.m)?a.mod(this.m):a}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,b,c){a.multiplyTo(b,c);this.reduce(c)}function cSqrTo(a,b){a.squareTo(b);this.reduce(b)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo; function bnpInvDigit(){if(1>this.t)return 0;var a=this[0];if(0==(a&1))return 0;var b=a&3,b=b*(2-(a&15)*b)&15,b=b*(2-(a&255)*b)&255,b=b*(2-((a&65535)*b&65535))&65535,b=b*(2-a*b%this.DV)%this.DV;return 0>15;this.um=(1<a.s&&0>15)*this.mpl&this.um)<<15)&a.DM,c=b+this.m.t;for(a[c]+=this.m.am(0,d,a,b,0,this.m.t);a[c]>=a.DV;)a[c]-=a.DV,a[++c]++}a.clamp();a.drShiftTo(this.m.t,a);0<=a.compareTo(this.m)&&a.subTo(this.m,a)}function montSqrTo(a,b){a.squareTo(b);this.reduce(b)}function montMulTo(a,b,c){a.multiplyTo(b,c);this.reduce(c)}Montgomery.prototype.convert=montConvert; -Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return 0==(0a)return BigInteger.ONE;var c=nbi(),d=nbi(),e=b.convert(this),f=nbits(a)-1;for(e.copyTo(c);0<=--f;)if(b.sqrTo(c,d),0<(a&1<a)return BigInteger.ONE;var c=nbi(),d=nbi(),e=b.convert(this),f=nbits(a)-1;for(e.copyTo(c);0<=--f;)if(b.sqrTo(c,d),0<(a&1<a||b.isEven()?new Classic(b):new Montgomery(b);return this.exp(a,c)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo; BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt; BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);function SecureRandom(){this.nextBytes=function(a){for(var b=0;b>1;d.e=parseInt(c,16);for(d.ee=new BigInteger(c,16);;){for(;!(d.p=new BigInteger(b-f,1,e),0==d.p.subtract(BigInteger.ONE).gcd(d.ee).compareTo(BigInteger.ONE)&&d.p.isProbablePrime(10)););for(;!(d.q=new BigInteger(f,1,e),0==d.q.subtract(BigInteger.ONE).gcd(d.ee).compareTo(BigInteger.ONE)&&d.q.isProbablePrime(10));); -if(0>=d.p.compareTo(d.q)){var g=d.p;d.p=d.q;d.q=g}var g=d.p.subtract(BigInteger.ONE),h=d.q.subtract(BigInteger.ONE),k=g.multiply(h);if(0==k.gcd(d.ee).compareTo(BigInteger.ONE)){d.n=d.p.multiply(d.q);d.d=d.ee.modInverse(k);d.dmp1=d.d.mod(g);d.dmq1=d.d.mod(h);d.u=d.p.modInverse(d.q);break}}return d};this.keyObject=a}function bnClone(){var a=nbi();this.copyTo(a);return a} +function RSA(){function a(){this.n=null;this.e=0;this.u=this.dmq1=this.dmp1=this.q=this.p=this.d=this.ee=null}this.encrypt=function(a,c,d){return a.modPowInt(c,d)};this.decrypt=function(a,c,d,e,f){var h=a.mod(d).modPow(c.mod(d.subtract(BigInteger.ONE)),d),a=a.mod(e).modPow(c.mod(e.subtract(BigInteger.ONE)),e);util.print_debug("rsa.js decrypt\nxpn:"+util.hexstrdump(h.toMPI())+"\nxqn:"+util.hexstrdump(a.toMPI()));c=a.subtract(h);0==c[0]?(c=h.subtract(a),c=c.multiply(f).mod(e),c=e.subtract(c)):c=c.multiply(f).mod(e); +return c.multiply(d).add(h)};this.verify=function(a,c,d){return a.modPowInt(c,d)};this.sign=function(a,c,d){return a.modPow(c,d)};this.generate=function(b,c){var d=new a,e=new SecureRandom,f=b>>1;d.e=parseInt(c,16);for(d.ee=new BigInteger(c,16);;){for(;!(d.p=new BigInteger(b-f,1,e),0==d.p.subtract(BigInteger.ONE).gcd(d.ee).compareTo(BigInteger.ONE)&&d.p.isProbablePrime(10)););for(;!(d.q=new BigInteger(f,1,e),0==d.q.subtract(BigInteger.ONE).gcd(d.ee).compareTo(BigInteger.ONE)&&d.q.isProbablePrime(10));); +if(0>=d.p.compareTo(d.q)){var h=d.p;d.p=d.q;d.q=h}var h=d.p.subtract(BigInteger.ONE),g=d.q.subtract(BigInteger.ONE),k=h.multiply(g);if(0==k.gcd(d.ee).compareTo(BigInteger.ONE)){d.n=d.p.multiply(d.q);d.d=d.ee.modInverse(k);d.dmp1=d.d.mod(h);d.dmq1=d.d.mod(g);d.u=d.p.modInverse(d.q);break}}return d};this.keyObject=a}function bnClone(){var a=nbi();this.copyTo(a);return a} function bnIntValue(){if(0>this.s){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){return 0>this.s?-1:0>=this.t||1==this.t&&0>=this[0]?0:1} function bnpToRadix(a){null==a&&(a=10);if(0==this.signum()||2>a||36k?"-"==a.charAt(h)&&0==this.signum()&&(e=!0):(g=b*g+k,++f>=c&&(this.dMultiply(d),this.dAddOffset(g,0),g=f=0))}0k?"-"==a.charAt(g)&&0==this.signum()&&(e=!0):(h=b*h+k,++f>=c&&(this.dMultiply(d),this.dAddOffset(h,0),h=f=0))}0a)this.fromInt(1);else{this.fromNumber(a,c);this.testBit(a-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this);for(this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(b);)this.dAddOffset(2,0),this.bitLength()>a&&this.subTo(BigInteger.ONE.shiftLeft(a-1),this)}else{var c=[],d=a&7;c.length=(a>>3)+1;b.nextBytes(c);c[0]=0>c)!=(this.s&this.DM)>>c)b[e++]=d|this.s<c?(d=(this[a]&(1<>(c+=this.DB-8)):(d=this[a]>>(c-=8)&255,0>=c&&(c+=this.DB,--a)),0this.compareTo(a)?this:a}function bnMax(a){return 0a.s||a.t>2*this.m.t)return a.mod(this.m);if(0>a.compareTo(this.m))return a;var b=nbi();a.copyTo(b);this.reduce(b);return b}function barrettRevert(a){return a} function barrettReduce(a){a.drShiftTo(this.m.t-1,this.r2);if(a.t>this.m.t+1)a.t=this.m.t+1,a.clamp();this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);for(this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);0>a.compareTo(this.r2);)a.dAddOffset(1,this.m.t+1);for(a.subTo(this.r2,a);0<=a.compareTo(this.m);)a.subTo(this.m,a)}function barrettSqrTo(a,b){a.squareTo(b);this.reduce(b)}function barrettMulTo(a,b,c){a.multiplyTo(b,c);this.reduce(c)}Barrett.prototype.convert=barrettConvert; Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo; -function bnModPow(a,b){var c=a.bitLength(),d,e=nbv(1),f;if(0>=c)return e;d=18>c?1:48>c?3:144>c?4:768>c?5:6;f=8>c?new Classic(b):b.isEven()?new Barrett(b):new Montgomery(b);var g=[],h=3,k=d-1,j=(1<=k?u=a[m]>>c-k&j:(u=(a[m]&(1<>this.DB+c-k));for(h=d;0==(u&1);)u>>=1,--h;if(0>(c-=h))c+=this.DB,--m;if(D)g[u].copyTo(e), -D=!1;else{for(;1--c&&(c=this.DB-1,--m)}return f.revert(e)} +function bnModPow(a,b){var c=a.bitLength(),d,e=nbv(1),f;if(0>=c)return e;d=18>c?1:48>c?3:144>c?4:768>c?5:6;f=8>c?new Classic(b):b.isEven()?new Barrett(b):new Montgomery(b);var h=[],g=3,k=d-1,j=(1<=k?o=a[l]>>c-k&j:(o=(a[l]&(1<>this.DB+c-k));for(g=d;0==(o&1);)o>>=1,--g;if(0>(c-=g))c+=this.DB,--l;if(s)h[o].copyTo(e), +s=!1;else{for(;1--c&&(c=this.DB-1,--l)}return f.revert(e)} function bnGCD(a){var b=0>this.s?this.negate():this.clone(),a=0>a.s?a.negate():a.clone();if(0>b.compareTo(a))var c=b,b=a,a=c;var c=b.getLowestSetBit(),d=a.getLowestSetBit();if(0>d)return b;c=a)return 0;var b=this.DV%a,c=0>this.s?a-1:0;if(0h.signum())h.addTo(a,h);else return h;return 0>h.signum()?h.add(a):h} +function bnModInverse(a){var b=a.isEven();if(this.isEven()&&b||0==a.signum())return BigInteger.ZERO;for(var c=a.clone(),d=this.clone(),e=nbv(1),f=nbv(0),h=nbv(0),g=nbv(1);0!=c.signum();){for(;c.isEven();){c.rShiftTo(1,c);if(b){if(!e.isEven()||!f.isEven())e.addTo(this,e),f.subTo(a,f);e.rShiftTo(1,e)}else f.isEven()||f.subTo(a,f);f.rShiftTo(1,f)}for(;d.isEven();){d.rShiftTo(1,d);if(b){if(!h.isEven()||!g.isEven())h.addTo(this,h),g.subTo(a,g);h.rShiftTo(1,h)}else g.isEven()||g.subTo(a,g);g.rShiftTo(1, +g)}0<=c.compareTo(d)?(c.subTo(d,c),b&&e.subTo(h,e),f.subTo(g,f)):(d.subTo(c,d),b&&h.subTo(e,h),g.subTo(f,g))}if(0!=d.compareTo(BigInteger.ONE))return BigInteger.ZERO;if(0<=g.compareTo(a))return g.subtract(a);if(0>g.signum())g.addTo(a,g);else return g;return 0>g.signum()?g.add(a):g} var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727, 733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],lplim=67108864/lowprimes[lowprimes.length-1]; function bnIsProbablePrime(a){var b,c=this.abs();if(1==c.t&&c[0]<=lowprimes[lowprimes.length-1]){for(b=0;b>>16))a=c,b+=16;if(0!=(c=a>>8))a=c,b+=8;if(0!=(c=a>>4))a=c,b+=4;if(0!=(c=a>>2))a=c,b+=2;0!=a>>1&&(b+=1);return b}function bnToMPI(){var a=this.toByteArray(),b=8*(a.length-1)+nbits(a[0]),c;c=""+String.fromCharCode((b&65280)>>8);c+=String.fromCharCode(b&255);return c+=util.bin2str(a)} -function bnpMillerRabin(a){var b=this.subtract(BigInteger.ONE),c=b.getLowestSetBit();if(0>=c)return!1;var d=b.shiftRight(c),a=a+1>>1;if(a>lowprimes.length)a=lowprimes.length;for(var e=nbi(),f=0;f=c)return!1;var d=b.shiftRight(c),a=a+1>>1;if(a>lowprimes.length)a=lowprimes.length;for(var e=nbi(),f=0;fb?2:b;case 28:return 11b?11:b;case 32:return 10b?8:b;default:return util.print_debug("DSA select hash algorithm: returning null for an unknown length of q"),null}};this.sign=function(a,b,c,d,e,f){a=util.getLeftNBits(openpgp_crypto_hashData(a,b),e.bitLength());a=new BigInteger(util.hexstrdump(a),16);b=openpgp_crypto_getRandomBigIntegerInRange(BigInteger.ONE.add(BigInteger.ONE), -e.subtract(BigInteger.ONE));c=c.modPow(b,d).mod(e);e=b.modInverse(e).multiply(a.add(f.multiply(c))).mod(e);f=[];f[0]=c.toMPI();f[1]=e.toMPI();return f};this.verify=function(a,b,c,d,e,f,g,h){a=util.getLeftNBits(openpgp_crypto_hashData(a,d),f.bitLength());a=new BigInteger(util.hexstrdump(a),16);if(0>>4^A)&252645135;A^=f;o^=f<<4;f=(o>>>16^A)&65535;A^=f;o^=f<<16;f=(A>>>2^o)&858993459;o^=f;A^=f<<2;f=(A>>>8^o)&16711935;o^=f;A^=f<<8;f=(o>>>1^A)&1431655765;A^=f;o^=f<<1;o=o<<1|o>>>31;A=A<<1|A>>>31;for(W=0;W>>4|A<<28)^a[e+1],f=o,o=A,A=f^(h[L>>>24&63]|j[L>>>16&63]|u[L>>>8&63]|l[L& -63]|g[z>>>24&63]|k[z>>>16&63]|m[z>>>8&63]|D[z&63]);f=o;o=A;A=f}o=o>>>1|o<<31;A=A>>>1|A<<31;f=(o>>>1^A)&1431655765;A^=f;o^=f<<1;f=(A>>>8^o)&16711935;o^=f;A^=f<<8;f=(A>>>2^o)&858993459;o^=f;A^=f<<2;f=(o>>>16^A)&65535;A^=f;o^=f<<16;f=(o>>>4^A)&252645135;A^=f;o^=f<<4;1==d&&(c?(na=o,la=A):(o^=fa,A^=O));tempresult+=String.fromCharCode(o>>>24,o>>>16&255,o>>>8&255,o&255,A>>>24,A>>>16&255,A>>>8&255,A&255);ea+=8;512==ea&&(result+=tempresult,tempresult="",ea=0)}result+=tempresult;return result=result.replace(/\0*$/g, -"")} -function des_createKeys(a){pc2bytes0=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964];pc2bytes1=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697];pc2bytes2=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272];pc2bytes3=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264, -2236416,134356992,136454144];pc2bytes4=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256];pc2bytes5=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488];pc2bytes6=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746];pc2bytes7=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568]; -pc2bytes8=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578];pc2bytes9=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488];pc2bytes10=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800];pc2bytes11=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744];pc2bytes12= -[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128];pc2bytes13=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261];for(var b=8>>4^right)&252645135;right^= -k;left^=k<<4;k=(right>>>-16^left)&65535;left^=k;right^=k<<-16;k=(left>>>2^right)&858993459;right^=k;left^=k<<2;k=(right>>>-16^left)&65535;left^=k;right^=k<<-16;k=(left>>>1^right)&1431655765;right^=k;left^=k<<1;k=(right>>>8^left)&16711935;left^=k;right^=k<<8;k=(left>>>1^right)&1431655765;right^=k;left^=k<<1;k=left<<8|right>>>20&240;left=right<<24|right<<8&16711680|right>>>8&65280|right>>>24&240;right=k;for(i=0;i>>26,right=right<<2|right>>>26):(left=left<<1|left>>> -27,right=right<<1|right>>>27),left&=-15,right&=-15,e=pc2bytes0[left>>>28]|pc2bytes1[left>>>24&15]|pc2bytes2[left>>>20&15]|pc2bytes3[left>>>16&15]|pc2bytes4[left>>>12&15]|pc2bytes5[left>>>8&15]|pc2bytes6[left>>>4&15],f=pc2bytes7[right>>>28]|pc2bytes8[right>>>24&15]|pc2bytes9[right>>>20&15]|pc2bytes10[right>>>16&15]|pc2bytes11[right>>>12&15]|pc2bytes12[right>>>8&15]|pc2bytes13[right>>>4&15],k=(f>>>16^e)&65535,c[h++]=e^k,c[h++]=f^k<<16}return c} +131592,8,134348808,131584],j=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],l=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688, +1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],o=[536870928,541065216, +16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],s=[2097152, +69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],q=[268439616,4096,262144,268701760,268435456, +268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696],m=0,z,x,v,t,r,N,T,K,P,M,w,B,W=b.length,E=0,C=32==a.length? +3:9;N=3==C?c?[0,32,2]:[30,-2,-2]:c?[0,32,2,62,30,-2,64,96,2]:[94,62,-2,32,64,2,30,-2,-2];2==f?b+=" ":1==f?(f=8-W%8,b+=String.fromCharCode(f,f,f,f,f,f,f,f),8==f&&(W+=8)):f||(b+="\x00\x00\x00\x00\x00\x00\x00\x00");tempresult=result="";1==d&&(T=e.charCodeAt(m++)<<24|e.charCodeAt(m++)<<16|e.charCodeAt(m++)<<8|e.charCodeAt(m++),P=e.charCodeAt(m++)<<24|e.charCodeAt(m++)<<16|e.charCodeAt(m++)<<8|e.charCodeAt(m++),m=0);for(;m>>4^r)&252645135;r^=f;t^=f<<4;f=(t>>>16^r)&65535;r^=f;t^=f<<16;f=(r>>>2^t)&858993459;t^=f;r^=f<<2;f=(r>>>8^t)&16711935;t^=f;r^=f<<8;f=(t>>>1^r)&1431655765;r^=f;t^=f<<1;t=t<<1|t>>>31;r=r<<1|r>>>31;for(z=0;z>>4|r<<28)^a[e+1],f=t,t=r,r=f^(g[x>>>24&63]|j[x>>>16&63]|o[x>>>8&63]|q[x&63]|h[v>>>24&63]|k[v>>>16&63]|l[v>>> +8&63]|s[v&63]);f=t;t=r;r=f}t=t>>>1|t<<31;r=r>>>1|r<<31;f=(t>>>1^r)&1431655765;r^=f;t^=f<<1;f=(r>>>8^t)&16711935;t^=f;r^=f<<8;f=(r>>>2^t)&858993459;t^=f;r^=f<<2;f=(t>>>16^r)&65535;r^=f;t^=f<<16;f=(t>>>4^r)&252645135;r^=f;t^=f<<4;1==d&&(c?(T=t,P=r):(t^=K,r^=M));tempresult+=String.fromCharCode(t>>>24,t>>>16&255,t>>>8&255,t&255,r>>>24,r>>>16&255,r>>>8&255,r&255);E+=8;512==E&&(result+=tempresult,tempresult="",E=0)}result+=tempresult;return result=result.replace(/\0*$/g,"")} +function des_createKeys(a){pc2bytes0=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964];pc2bytes1=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697];pc2bytes2=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272];pc2bytes3=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952, +139264,2236416,134356992,136454144];pc2bytes4=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256];pc2bytes5=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488];pc2bytes6=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746];pc2bytes7=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032, +537069568];pc2bytes8=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578];pc2bytes9=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488];pc2bytes10=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800];pc2bytes11=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744]; +pc2bytes12=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128];pc2bytes13=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261];for(var b=8>>4^right)&252645135; +right^=k;left^=k<<4;k=(right>>>-16^left)&65535;left^=k;right^=k<<-16;k=(left>>>2^right)&858993459;right^=k;left^=k<<2;k=(right>>>-16^left)&65535;left^=k;right^=k<<-16;k=(left>>>1^right)&1431655765;right^=k;left^=k<<1;k=(right>>>8^left)&16711935;left^=k;right^=k<<8;k=(left>>>1^right)&1431655765;right^=k;left^=k<<1;k=left<<8|right>>>20&240;left=right<<24|right<<8&16711680|right>>>8&65280|right>>>24&240;right=k;for(i=0;i>>26,right=right<<2|right>>>26):(left=left<< +1|left>>>27,right=right<<1|right>>>27),left&=-15,right&=-15,e=pc2bytes0[left>>>28]|pc2bytes1[left>>>24&15]|pc2bytes2[left>>>20&15]|pc2bytes3[left>>>16&15]|pc2bytes4[left>>>12&15]|pc2bytes5[left>>>8&15]|pc2bytes6[left>>>4&15],f=pc2bytes7[right>>>28]|pc2bytes8[right>>>24&15]|pc2bytes9[right>>>20&15]|pc2bytes10[right>>>16&15]|pc2bytes11[right>>>12&15]|pc2bytes12[right>>>8&15]|pc2bytes13[right>>>4&15],k=(f>>>16^e)&65535,c[g++]=e^k,c[g++]=f^k<<16}return c} function cast5_encrypt(a,b){var c=new openpgp_symenc_cast5;c.setKey(util.str2bin(b));return c.encrypt(a)} function openpgp_symenc_cast5(){function a(a,b,c){a=b+a;c=a<>>32-c;return(f[0][c>>>24]^f[1][c>>>16&255])-f[2][c>>>8&255]+f[3][c&255]}function b(a,b,c){a^=b;c=a<>>32-c;return f[0][c>>>24]-f[1][c>>>16&255]+f[2][c>>>8&255]^f[3][c&255]}function c(a,b,c){a=b-a;c=a<>>32-c;return(f[0][c>>>24]+f[1][c>>>16&255]^f[2][c>>>8&255])-f[3][c&255]}this.BlockSize=8;this.KeySize=16;this.setKey=function(a){this.masking=Array(16);this.rotate=Array(16);this.reset();if(a.length==this.KeySize)this.keySchedule(a); -else return util.print_error("cast5.js: CAST-128: keys must be 16 bytes"),!1;return!0};this.reset=function(){for(var a=0;16>a;a++)this.masking[a]=0,this.rotate[a]=0};this.getBlockSize=function(){return BlockSize};this.encrypt=function(d){var e=Array(d.length);for(i=0;i>>24&255;e[i+1]=j>>>16&255;e[i+2]=j>>>8&255;e[i+3]=j&255;e[i+4]=f>>>24&255;e[i+5]=f>>>16&255;e[i+6]=f>>>8&255;e[i+7]=f&255}return e};this.decrypt=function(d){var e=Array(d.length);for(i=0;i>>24&255;e[i+1]=j>>>16&255;e[i+2]=j>>>8&255;e[i+3]=j&255;e[i+4]=f>>>24&255;e[i+5]=f>>16&255;e[i+6]=f>>8&255;e[i+7]=f&255}return e};var d=Array(4);d[0]=Array(4);d[0][0]=[4,0,13,15,12,14,8];d[0][1]=[5,2,16,18,17,19,10];d[0][2]=[6,3,23,22,21,20,9];d[0][3]=[7,1,26,25,27,24,11];d[1]=Array(4);d[1][0]=[0, +else return util.print_error("cast5.js: CAST-128: keys must be 16 bytes"),!1;return!0};this.reset=function(){for(var a=0;16>a;a++)this.masking[a]=0,this.rotate[a]=0};this.getBlockSize=function(){return BlockSize};this.encrypt=function(d){var e=Array(d.length);for(i=0;i>>24&255;e[i+1]=j>>>16&255;e[i+2]=j>>>8&255;e[i+3]=j&255;e[i+4]=f>>>24&255;e[i+5]=f>>>16&255;e[i+6]=f>>>8&255;e[i+7]=f&255}return e};this.decrypt=function(d){var e=Array(d.length);for(i=0;i>>24&255;e[i+1]=j>>>16&255;e[i+2]=j>>>8&255;e[i+3]=j&255;e[i+4]=f>>>24&255;e[i+5]=f>>16&255;e[i+6]=f>>8&255;e[i+7]=f&255}return e};var d=Array(4);d[0]=Array(4);d[0][0]=[4,0,13,15,12,14,8];d[0][1]=[5,2,16,18,17,19,10];d[0][2]=[6,3,23,22,21,20,9];d[0][3]=[7,1,26,25,27,24,11];d[1]=Array(4);d[1][0]=[0, 6,21,23,20,22,16];d[1][1]=[1,4,0,2,1,3,18];d[1][2]=[2,5,7,6,5,4,17];d[1][3]=[3,7,10,9,11,8,19];d[2]=Array(4);d[2][0]=[4,0,13,15,12,14,8];d[2][1]=[5,2,16,18,17,19,10];d[2][2]=[6,3,23,22,21,20,9];d[2][3]=[7,1,26,25,27,24,11];d[3]=Array(4);d[3][0]=[0,6,21,23,20,22,16];d[3][1]=[1,4,0,2,1,3,18];d[3][2]=[2,5,7,6,5,4,17];d[3][3]=[3,7,10,9,11,8,19];var e=Array(4);e[0]=Array(4);e[0][0]=[24,25,23,22,18];e[0][1]=[26,27,21,20,22];e[0][2]=[28,29,19,18,25];e[0][3]=[30,31,17,16,28];e[1]=Array(4);e[1][0]=[3,2,12, -13,8];e[1][1]=[1,0,14,15,13];e[1][2]=[7,6,8,9,3];e[1][3]=[5,4,10,11,7];e[2]=Array(4);e[2][0]=[19,18,28,29,25];e[2][1]=[17,16,30,31,28];e[2][2]=[23,22,24,25,18];e[2][3]=[21,20,26,27,22];e[3]=Array(4);e[3][0]=[8,9,7,6,3];e[3][1]=[10,11,5,4,7];e[3][2]=[12,13,3,2,8];e[3][3]=[14,15,1,0,13];this.keySchedule=function(a){for(var b=Array(8),c=Array(32),j=0;4>j;j++){var m=4*j;b[j]=a[m]<<24|a[m+1]<<16|a[m+2]<<8|a[m+3]}for(var a=[6,7,4,5],u=j=0;2>u;u++)for(var D=0;4>D;D++){for(m=0;4>m;m++){var l=d[D][m],p=b[l[1]], -p=p^f[4][b[l[2]>>>2]>>>24-8*(l[2]&3)&255],p=p^f[5][b[l[3]>>>2]>>>24-8*(l[3]&3)&255],p=p^f[6][b[l[4]>>>2]>>>24-8*(l[4]&3)&255],p=p^f[7][b[l[5]>>>2]>>>24-8*(l[5]&3)&255],p=p^f[a[m]][b[l[6]>>>2]>>>24-8*(l[6]&3)&255];b[l[0]]=p}for(m=0;4>m;m++)l=e[D][m],p=f[4][b[l[0]>>>2]>>>24-8*(l[0]&3)&255],p^=f[5][b[l[1]>>>2]>>>24-8*(l[1]&3)&255],p^=f[6][b[l[2]>>>2]>>>24-8*(l[2]&3)&255],p^=f[7][b[l[3]>>>2]>>>24-8*(l[3]&3)&255],p^=f[4+m][b[l[4]>>>2]>>>24-8*(l[4]&3)&255],c[j]=p,j++}for(j=0;16>j;j++)this.masking[j]=c[j], +13,8];e[1][1]=[1,0,14,15,13];e[1][2]=[7,6,8,9,3];e[1][3]=[5,4,10,11,7];e[2]=Array(4);e[2][0]=[19,18,28,29,25];e[2][1]=[17,16,30,31,28];e[2][2]=[23,22,24,25,18];e[2][3]=[21,20,26,27,22];e[3]=Array(4);e[3][0]=[8,9,7,6,3];e[3][1]=[10,11,5,4,7];e[3][2]=[12,13,3,2,8];e[3][3]=[14,15,1,0,13];this.keySchedule=function(a){for(var b=Array(8),c=Array(32),j=0;4>j;j++){var l=4*j;b[j]=a[l]<<24|a[l+1]<<16|a[l+2]<<8|a[l+3]}for(var a=[6,7,4,5],o=j=0;2>o;o++)for(var s=0;4>s;s++){for(l=0;4>l;l++){var q=d[s][l],m=b[q[1]], +m=m^f[4][b[q[2]>>>2]>>>24-8*(q[2]&3)&255],m=m^f[5][b[q[3]>>>2]>>>24-8*(q[3]&3)&255],m=m^f[6][b[q[4]>>>2]>>>24-8*(q[4]&3)&255],m=m^f[7][b[q[5]>>>2]>>>24-8*(q[5]&3)&255],m=m^f[a[l]][b[q[6]>>>2]>>>24-8*(q[6]&3)&255];b[q[0]]=m}for(l=0;4>l;l++)q=e[s][l],m=f[4][b[q[0]>>>2]>>>24-8*(q[0]&3)&255],m^=f[5][b[q[1]>>>2]>>>24-8*(q[1]&3)&255],m^=f[6][b[q[2]>>>2]>>>24-8*(q[2]&3)&255],m^=f[7][b[q[3]>>>2]>>>24-8*(q[3]&3)&255],m^=f[4+l][b[q[4]>>>2]>>>24-8*(q[4]&3)&255],c[j]=m,j++}for(j=0;16>j;j++)this.masking[j]=c[j], this.rotate[j]=c[16+j]&31};var f=Array(8);f[0]=[821772500,2678128395,1810681135,1059425402,505495343,2617265619,1610868032,3483355465,3218386727,2294005173,3791863952,2563806837,1852023008,365126098,3269944861,584384398,677919599,3229601881,4280515016,2002735330,1136869587,3744433750,2289869850,2731719981,2714362070,879511577,1639411079,575934255,717107937,2857637483,576097850,2731753936,1725645E3,2810460463,5111599,767152862,2543075244,1251459544,1383482551,3052681127,3089939183,3612463449,1878520045, 1510570527,2189125840,2431448366,582008916,3163445557,1265446783,1354458274,3529918736,3202711853,3073581712,3912963487,3029263377,1275016285,4249207360,2905708351,3304509486,1442611557,3585198765,2712415662,2731849581,3248163920,2283946226,208555832,2766454743,1331405426,1447828783,3315356441,3108627284,2957404670,2981538698,3339933917,1669711173,286233437,1465092821,1782121619,3862771680,710211251,980974943,1651941557,430374111,2051154026,704238805,4128970897,3144820574,2857402727,948965521,3333752299, 2227686284,718756367,2269778983,2731643755,718440111,2857816721,3616097120,1113355533,2478022182,410092745,1811985197,1944238868,2696854588,1415722873,1682284203,1060277122,1998114690,1503841958,82706478,2315155686,1068173648,845149890,2167947013,1768146376,1993038550,3566826697,3390574031,940016341,3355073782,2328040721,904371731,1205506512,4094660742,2816623006,825647681,85914773,2857843460,1249926541,1417871568,3287612,3211054559,3126306446,1975924523,1353700161,2814456437,2438597621,1800716203, @@ -359,13 +313,13 @@ f[2]=[2381300288,637164959,3952098751,3893414151,1197506559,916448331,2350892612 4066861423,3242773476,2421326174,1581322155,3028952165,786071460,3900391652,3918438532,1485433313,4023619836,3708277595,3678951060,953673138,1467089153,1930354364,1533292819,2492563023,1346121658,1685000834,1965281866,3765933717,4190206607,2052792609,3515332758,690371149,3125873887,2180283551,2903598061,3933952357,436236910,289419410,14314871,1242357089,2904507907,1616633776,2666382180,585885352,3471299210,2699507360,1432659641,277164553,3354103607,770115018,2303809295,3741942315,3177781868,2853364978, 2269453327,3774259834,987383833,1290892879,225909803,1741533526,890078084,1496906255,1111072499,916028167,243534141,1252605537,2204162171,531204876,290011180,3916834213,102027703,237315147,209093447,1486785922,220223953,2758195998,4175039106,82940208,3127791296,2569425252,518464269,1353887104,3941492737,2377294467,3935040926]}function TFencrypt(a,b){var c=[].concat(a),d=createTwofish();d.open(util.str2bin(b),0);c=d.encrypt(c,0);d.close();return c}var MAXINT=4294967295; function rotb(a,b){return(a<>>8-b)&255}function rotw(a,b){return(a<>>32-b)&MAXINT}function getW(a,b){return a[b]|a[b+1]<<8|a[b+2]<<16|a[b+3]<<24}function setW(a,b,c){a.splice(b,4,c&255,c>>>8&255,c>>>16&255,c>>>24&255)}function setWInv(a,b,c){a.splice(b,4,c>>>24&255,c>>>16&255,c>>>8&255,c&255)}function getB(a,b){return a>>>8*b&255}function getNrBits(a){for(var b=0;0>>=1;return b}function getMask(a){return(1<d;d++)e=c>>>24,c=c<<8&MAXINT|a>>>24,a=a<<8&MAXINT,f=e<<1,e&128&&(f^=333),c^=e^f<<16,f^=e>>>1,e&1&&(f^=166),c^=f<<24|f<<8;return c}function d(a,b){var c,e,f;c=b>>4;e=b&15;f=A[a][c^ -e];c=ka[a][la[e]^O[c]];return fa[a][la[c]^O[f]]<<4|na[a][f^c]}function e(a,b){var c=getB(a,0),d=getB(a,1),f=getB(a,2),g=getB(a,3);switch(L){case 4:c=M[1][c]^getB(b[3],0),d=M[0][d]^getB(b[3],1),f=M[0][f]^getB(b[3],2),g=M[1][g]^getB(b[3],3);case 3:c=M[1][c]^getB(b[2],0),d=M[1][d]^getB(b[2],1),f=M[0][f]^getB(b[2],2),g=M[0][g]^getB(b[2],3);case 2:c=M[0][M[0][c]^getB(b[1],0)]^getB(b[0],0),d=M[0][M[1][d]^getB(b[1],1)]^getB(b[0],1),f=M[1][M[0][f]^getB(b[1],2)]^getB(b[0],2),g=M[1][M[1][g]^getB(b[1],3)]^getB(b[0], -3)}return Z[0][c]^Z[1][d]^Z[2][f]^Z[3][g]}c=a;var u,D,l,p;l=[];p=[];var W=[],L,z=[],o,A=[[8,1,7,13,6,15,3,2,0,11,5,9,14,12,10,4],[2,8,11,13,15,7,6,14,3,1,9,4,0,10,12,5]],ka=[[14,12,11,8,1,2,3,5,15,4,10,6,7,0,9,13],[1,14,2,11,4,12,3,7,6,13,10,5,15,9,0,8]],na=[[11,10,5,14,6,13,9,0,12,8,15,3,2,4,7,1],[4,12,7,5,1,6,9,10,0,14,13,8,2,11,3,15]],fa=[[13,7,15,4,1,2,6,14,9,11,3,0,8,5,12,10],[11,9,5,1,12,3,13,14,6,4,7,15,2,0,8,10]],la=[0,8,1,9,2,10,3,11,4,12,5,13,6,14,7,15],O=[0,9,2,11,4,13,6,15,8,1,10,3,12, -5,14,7],M=[[],[]],Z=[[],[],[],[]];c=c.slice(0,32);for(a=c.length;16!=a&&24!=a&&32!=a;)c[a++]=0;for(a=0;a>2]=getW(c,a);for(a=0;256>a;a++)M[0][a]=d(0,a),M[1][a]=d(1,a);for(a=0;256>a;a++)u=M[1][a],D=u^u>>2^[0,90,180,238][u&3],o=u^u>>1^u>>2^[0,238,180,90][u&3],Z[0][a]=u+(D<<8)+(o<<16)+(o<<24),Z[2][a]=D+(o<<8)+(u<<16)+(o<<24),u=M[0][a],D=u^u>>2^[0,90,180,238][u&3],o=u^u>>1^u>>2^[0,238,180,90][u&3],Z[1][a]=o+(o<<8)+(D<<16)+(u<<24),Z[3][a]=D+(u<<8)+(o<<16)+(D<<24);L=W.length/2;for(a=0;a< -L;a++)u=W[a+a],l[a]=u,D=W[a+a+1],p[a]=D,z[L-a-1]=b(u,D);for(a=0;40>a;a+=2)u=16843009*a,D=u+16843009,u=e(u,l),D=rotw(e(D,p),8),f[a]=u+D&MAXINT,f[a+1]=rotw(u+2*D,9);for(a=0;256>a;a++)switch(u=D=l=p=a,L){case 4:u=M[1][u]^getB(z[3],0),D=M[0][D]^getB(z[3],1),l=M[0][l]^getB(z[3],2),p=M[1][p]^getB(z[3],3);case 3:u=M[1][u]^getB(z[2],0),D=M[1][D]^getB(z[2],1),l=M[0][l]^getB(z[2],2),p=M[0][p]^getB(z[2],3);case 2:g[0][a]=Z[0][M[0][M[0][u]^getB(z[1],0)]^getB(z[0],0)],g[1][a]=Z[1][M[0][M[1][D]^getB(z[1],1)]^getB(z[0], -1)],g[2][a]=Z[2][M[1][M[0][l]^getB(z[1],2)]^getB(z[0],2)],g[3][a]=Z[3][M[1][M[1][p]^getB(z[1],3)]^getB(z[0],3)]}},close:function(){f=[];g=[[],[],[],[]]},encrypt:function(c,g){d=c;e=g;for(var j=[getW(d,e)^f[0],getW(d,e+4)^f[1],getW(d,e+8)^f[2],getW(d,e+12)^f[3]],m=0;8>m;m++){var u=m,D=j,l=a(D[0]),p=b(D[1]);D[2]=rotw(D[2]^l+p+f[4*u+8]&MAXINT,31);D[3]=rotw(D[3],1)^l+2*p+f[4*u+9]&MAXINT;l=a(D[2]);p=b(D[3]);D[0]=rotw(D[0]^l+p+f[4*u+10]&MAXINT,31);D[1]=rotw(D[1],1)^l+2*p+f[4*u+11]&MAXINT}setW(d,e,j[2]^ -f[4]);setW(d,e+4,j[3]^f[5]);setW(d,e+8,j[0]^f[6]);setW(d,e+12,j[1]^f[7]);e+=16;return d},decrypt:function(c,g){d=c;e=g;for(var j=[getW(d,e)^f[4],getW(d,e+4)^f[5],getW(d,e+8)^f[6],getW(d,e+12)^f[7]],m=7;0<=m;m--){var u=m,D=j,l=a(D[0]),p=b(D[1]);D[2]=rotw(D[2],1)^l+p+f[4*u+10]&MAXINT;D[3]=rotw(D[3]^l+2*p+f[4*u+11]&MAXINT,31);l=a(D[2]);p=b(D[3]);D[0]=rotw(D[0],1)^l+p+f[4*u+8]&MAXINT;D[1]=rotw(D[1]^l+2*p+f[4*u+9]&MAXINT,31)}setW(d,e,j[2]^f[0]);setW(d,e+4,j[3]^f[1]);setW(d,e+8,j[0]^f[2]);setW(d,e+12,j[1]^ +function createTwofish(){function a(a){return h[0][getB(a,0)]^h[1][getB(a,1)]^h[2][getB(a,2)]^h[3][getB(a,3)]}function b(a){return h[0][getB(a,3)]^h[1][getB(a,0)]^h[2][getB(a,1)]^h[3][getB(a,2)]}var c=null,d=null,e=-1,f=[],h=[[],[],[],[]];return{name:"twofish",blocksize:16,open:function(a){function b(a,c){var d,e,f;for(d=0;8>d;d++)e=c>>>24,c=c<<8&MAXINT|a>>>24,a=a<<8&MAXINT,f=e<<1,e&128&&(f^=333),c^=e^f<<16,f^=e>>>1,e&1&&(f^=166),c^=f<<24|f<<8;return c}function d(a,b){var c,e,f;c=b>>4;e=b&15;f=r[a][c^ +e];c=N[a][P[e]^M[c]];return K[a][P[c]^M[f]]<<4|T[a][f^c]}function e(a,b){var c=getB(a,0),d=getB(a,1),f=getB(a,2),g=getB(a,3);switch(x){case 4:c=w[1][c]^getB(b[3],0),d=w[0][d]^getB(b[3],1),f=w[0][f]^getB(b[3],2),g=w[1][g]^getB(b[3],3);case 3:c=w[1][c]^getB(b[2],0),d=w[1][d]^getB(b[2],1),f=w[0][f]^getB(b[2],2),g=w[0][g]^getB(b[2],3);case 2:c=w[0][w[0][c]^getB(b[1],0)]^getB(b[0],0),d=w[0][w[1][d]^getB(b[1],1)]^getB(b[0],1),f=w[1][w[0][f]^getB(b[1],2)]^getB(b[0],2),g=w[1][w[1][g]^getB(b[1],3)]^getB(b[0], +3)}return B[0][c]^B[1][d]^B[2][f]^B[3][g]}c=a;var o,s,q,m;q=[];m=[];var z=[],x,v=[],t,r=[[8,1,7,13,6,15,3,2,0,11,5,9,14,12,10,4],[2,8,11,13,15,7,6,14,3,1,9,4,0,10,12,5]],N=[[14,12,11,8,1,2,3,5,15,4,10,6,7,0,9,13],[1,14,2,11,4,12,3,7,6,13,10,5,15,9,0,8]],T=[[11,10,5,14,6,13,9,0,12,8,15,3,2,4,7,1],[4,12,7,5,1,6,9,10,0,14,13,8,2,11,3,15]],K=[[13,7,15,4,1,2,6,14,9,11,3,0,8,5,12,10],[11,9,5,1,12,3,13,14,6,4,7,15,2,0,8,10]],P=[0,8,1,9,2,10,3,11,4,12,5,13,6,14,7,15],M=[0,9,2,11,4,13,6,15,8,1,10,3,12,5,14, +7],w=[[],[]],B=[[],[],[],[]];c=c.slice(0,32);for(a=c.length;16!=a&&24!=a&&32!=a;)c[a++]=0;for(a=0;a>2]=getW(c,a);for(a=0;256>a;a++)w[0][a]=d(0,a),w[1][a]=d(1,a);for(a=0;256>a;a++)o=w[1][a],s=o^o>>2^[0,90,180,238][o&3],t=o^o>>1^o>>2^[0,238,180,90][o&3],B[0][a]=o+(s<<8)+(t<<16)+(t<<24),B[2][a]=s+(t<<8)+(o<<16)+(t<<24),o=w[0][a],s=o^o>>2^[0,90,180,238][o&3],t=o^o>>1^o>>2^[0,238,180,90][o&3],B[1][a]=t+(t<<8)+(s<<16)+(o<<24),B[3][a]=s+(o<<8)+(t<<16)+(s<<24);x=z.length/2;for(a=0;aa;a+=2)o=16843009*a,s=o+16843009,o=e(o,q),s=rotw(e(s,m),8),f[a]=o+s&MAXINT,f[a+1]=rotw(o+2*s,9);for(a=0;256>a;a++)switch(o=s=q=m=a,x){case 4:o=w[1][o]^getB(v[3],0),s=w[0][s]^getB(v[3],1),q=w[0][q]^getB(v[3],2),m=w[1][m]^getB(v[3],3);case 3:o=w[1][o]^getB(v[2],0),s=w[1][s]^getB(v[2],1),q=w[0][q]^getB(v[2],2),m=w[0][m]^getB(v[2],3);case 2:h[0][a]=B[0][w[0][w[0][o]^getB(v[1],0)]^getB(v[0],0)],h[1][a]=B[1][w[0][w[1][s]^getB(v[1],1)]^getB(v[0], +1)],h[2][a]=B[2][w[1][w[0][q]^getB(v[1],2)]^getB(v[0],2)],h[3][a]=B[3][w[1][w[1][m]^getB(v[1],3)]^getB(v[0],3)]}},close:function(){f=[];h=[[],[],[],[]]},encrypt:function(c,h){d=c;e=h;for(var j=[getW(d,e)^f[0],getW(d,e+4)^f[1],getW(d,e+8)^f[2],getW(d,e+12)^f[3]],l=0;8>l;l++){var o=l,s=j,q=a(s[0]),m=b(s[1]);s[2]=rotw(s[2]^q+m+f[4*o+8]&MAXINT,31);s[3]=rotw(s[3],1)^q+2*m+f[4*o+9]&MAXINT;q=a(s[2]);m=b(s[3]);s[0]=rotw(s[0]^q+m+f[4*o+10]&MAXINT,31);s[1]=rotw(s[1],1)^q+2*m+f[4*o+11]&MAXINT}setW(d,e,j[2]^ +f[4]);setW(d,e+4,j[3]^f[5]);setW(d,e+8,j[0]^f[6]);setW(d,e+12,j[1]^f[7]);e+=16;return d},decrypt:function(c,h){d=c;e=h;for(var j=[getW(d,e)^f[4],getW(d,e+4)^f[5],getW(d,e+8)^f[6],getW(d,e+12)^f[7]],l=7;0<=l;l--){var o=l,s=j,q=a(s[0]),m=b(s[1]);s[2]=rotw(s[2],1)^q+m+f[4*o+10]&MAXINT;s[3]=rotw(s[3]^q+2*m+f[4*o+11]&MAXINT,31);q=a(s[2]);m=b(s[3]);s[0]=rotw(s[0],1)^q+m+f[4*o+8]&MAXINT;s[1]=rotw(s[1]^q+2*m+f[4*o+9]&MAXINT,31)}setW(d,e,j[2]^f[0]);setW(d,e+4,j[3]^f[1]);setW(d,e+8,j[0]^f[2]);setW(d,e+12,j[1]^ f[3]);e+=16},finalize:function(){return d}}}function Blowfish(){}Blowfish.prototype.BLOCKSIZE=8; Blowfish.prototype.SBOXES=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110, 2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150, @@ -419,58 +373,58 @@ var Rcon=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53, 967348625,832869781,3543655652,4069226873,3576883175,2336475336,1851340599,3669454189,25988493,2976175573,2631028302,1239460265,3635702892,2902087254,4077384948,3475368682,3400492389,4102978170,1206496942,270010376,1876277946,4035475576,1248797989,1550986798,941890588,1475454630,1942467764,2538718918,3408128232,2709315037,3902567540,1042358047,2531085131,1641856445,226921355,260409994,3767562352,2084716094,1908716981,3433719398,2430093384,100991747,4144101110,470945294,3265487201,1784624437,2935576407, 1775286713,395413126,2572730817,975641885,666476190,3644383713,3943954680,733190296,573772049,3535497577,2842745305,126455438,866620564,766942107,1008868894,361924487,3374377449,2269761230,2868860245,1350051880,2776293343,59739276,1509466529,159418761,437718285,1708834751,3610371814,2227585602,3501746280,2193834305,699439513,1517759789,504434447,2076946608,2835108948,1842789307,742004246];function B0(a){return a&255}function B1(a){return a>>8&255}function B2(a){return a>>16&255} function B3(a){return a>>24&255}function F1(a,b,c,d){return B1(T1[a&255])|B1(T1[b>>8&255])<<8|B1(T1[c>>16&255])<<16|B1(T1[d>>>24])<<24}function packBytes(a){var b,c,d=a.length,e=Array(d/4);if(a&&!(d%4)){for(b=0,c=0;cc;d++,c++)f[a][c]=k[d];4==c&&(a++,c=0)}for(;ac;d++,c++)f[a][c]=k[d];4==c&&(a++,c=0)}for(;ac;d++,c++)f[a][c]=k[d];4==c&&(a++,c=0)}}this.rounds=e;this.rk=f;return this} -function AESencrypt(a,b){var c,d,e,f,g,h=packBytes(a),k=b.rounds,j=h[0],m=h[1],u=h[2];g=h[3];for(c=0;c>8&255]^T3[f>>16&255]^T4[g>>>24],m=T1[e&255]^T2[f>>8&255]^T3[g>>16&255]^T4[d>>>24],u=T1[f&255]^T2[g>>8&255]^T3[d>>16&255]^T4[e>>>24],g=T1[g&255]^T2[d>>8&255]^T3[e>>16&255]^T4[f>>>24];c=k-1;d=j^b.rk[c][0];e=m^b.rk[c][1];f=u^b.rk[c][2];g^=b.rk[c][3];h[0]=F1(d,e,f,g)^b.rk[k][0];h[1]=F1(e,f,g,d)^b.rk[k][1];h[2]=F1(f, -g,d,e)^b.rk[k][2];h[3]=F1(g,d,e,f)^b.rk[k][3];return unpackBytes(h)} -function openpgp_cfb_encrypt(a,b,c,d,e,f){var g=Array(d),h=Array(d),a=a+a.charAt(d-2)+a.charAt(d-1);util.print_debug("prefixrandom:"+util.hexstrdump(a));for(var k="",j=0;jb*g;){for(var e=a(f,c),f=d.substring(g*b,g*b+b),j=0;jb*g;){for(var k=a(f,c),f=d.substring(g*b+0,g*b+b+0),e=0;e>8&255]^T3[f>>16&255]^T4[h>>>24],l=T1[e&255]^T2[f>>8&255]^T3[h>>16&255]^T4[d>>>24],o=T1[f&255]^T2[h>>8&255]^T3[d>>16&255]^T4[e>>>24],h=T1[h&255]^T2[d>>8&255]^T3[e>>16&255]^T4[f>>>24];c=k-1;d=j^b.rk[c][0];e=l^b.rk[c][1];f=o^b.rk[c][2];h^=b.rk[c][3];g[0]=F1(d,e,f,h)^b.rk[k][0];g[1]=F1(e,f,h,d)^b.rk[k][1];g[2]=F1(f, +h,d,e)^b.rk[k][2];g[3]=F1(h,d,e,f)^b.rk[k][3];return unpackBytes(g)} +function openpgp_cfb_encrypt(a,b,c,d,e,f){var h=Array(d),g=Array(d),a=a+a.charAt(d-2)+a.charAt(d-1);util.print_debug("prefixrandom:"+util.hexstrdump(a));for(var k="",j=0;jb*h;){for(var e=a(f,c),f=d.substring(h*b,h*b+b),j=0;jb*h;){for(var k=a(f,c),f=d.substring(h*b+0,h*b+b+0),e=0;e>5]|=(a.charCodeAt(d/8)&255)<<24-d%32;return b},c=function(a){var b=[],c=a.length,d,e;for(d=0;d>3]|=e<<24-4*(d%8)}return b},d=function(a){var b="",c=4*a.length,d,e;for(d=0;d>2]>>8*(3-d%4),b+="0123456789abcdef".charAt(e>>4&15)+"0123456789abcdef".charAt(e&15);return b},e=function(a){var b= -"",c=4*a.length,d,e,f;for(d=0;d>2]>>8*(3-d%4)&255)<<16|(a[d+1>>2]>>8*(3-(d+1)%4)&255)<<8|a[d+2>>2]>>8*(3-(d+2)%4)&255;for(e=0;4>e;e+=1)b=8*d+6*e<=32*a.length?b+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(f>>6*(3-e)&63):b+""}return b},f=function(a){for(var b="",c=0;c<32*a.length;c+=8)b+=String.fromCharCode(a[c>>5]>>>24-c%32&255);return b},g=function(a,b){return a<>>32-b},h=function(a,b){return a>>>b|a<<32-b},k=function(b,c){return 32>=c?new a(b.highOrder>>> -c|b.lowOrder<<32-c,b.lowOrder>>>c|b.highOrder<<32-c):new a(b.lowOrder>>>c|b.highOrder<<32-c,b.highOrder>>>c|b.lowOrder<<32-c)},j=function(b,c){return 32>=c?new a(b.highOrder>>>c,b.lowOrder>>>c|b.highOrder<<32-c):new a(0,b.highOrder<<32-c)},m=function(a,b,c){return a&b^~a&c},u=function(b,c,d){return new a(b.highOrder&c.highOrder^~b.highOrder&d.highOrder,b.lowOrder&c.lowOrder^~b.lowOrder&d.lowOrder)},D=function(a,b,c){return a&b^a&c^b&c},l=function(b,c,d){return new a(b.highOrder&c.highOrder^b.highOrder& -d.highOrder^c.highOrder&d.highOrder,b.lowOrder&c.lowOrder^b.lowOrder&d.lowOrder^c.lowOrder&d.lowOrder)},p=function(a){return h(a,2)^h(a,13)^h(a,22)},W=function(b){var c=k(b,28),d=k(b,34),b=k(b,39);return new a(c.highOrder^d.highOrder^b.highOrder,c.lowOrder^d.lowOrder^b.lowOrder)},L=function(a){return h(a,6)^h(a,11)^h(a,25)},z=function(b){var c=k(b,14),d=k(b,18),b=k(b,41);return new a(c.highOrder^d.highOrder^b.highOrder,c.lowOrder^d.lowOrder^b.lowOrder)},o=function(a){return h(a,7)^h(a,18)^a>>>3}, -A=function(b){var c=k(b,1),d=k(b,8),b=j(b,7);return new a(c.highOrder^d.highOrder^b.highOrder,c.lowOrder^d.lowOrder^b.lowOrder)},ka=function(a){return h(a,17)^h(a,19)^a>>>10},na=function(b){var c=k(b,19),d=k(b,61),b=j(b,6);return new a(c.highOrder^d.highOrder^b.highOrder,c.lowOrder^d.lowOrder^b.lowOrder)},fa=function(a,b){var c=(a&65535)+(b&65535);return((a>>>16)+(b>>>16)+(c>>>16)&65535)<<16|c&65535},la=function(a,b,c,d){var e=(a&65535)+(b&65535)+(c&65535)+(d&65535);return((a>>>16)+(b>>>16)+(c>>> -16)+(d>>>16)+(e>>>16)&65535)<<16|e&65535},O=function(a,b,c,d,e){var f=(a&65535)+(b&65535)+(c&65535)+(d&65535)+(e&65535);return((a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(e>>>16)+(f>>>16)&65535)<<16|f&65535},M=function(b,c){var d,e,f;d=(b.lowOrder&65535)+(c.lowOrder&65535);e=(b.lowOrder>>>16)+(c.lowOrder>>>16)+(d>>>16);f=(e&65535)<<16|d&65535;d=(b.highOrder&65535)+(c.highOrder&65535)+(e>>>16);e=(b.highOrder>>>16)+(c.highOrder>>>16)+(d>>>16);return new a((e&65535)<<16|d&65535,f)},Z=function(b,c,d,e){var f, -g,h;f=(b.lowOrder&65535)+(c.lowOrder&65535)+(d.lowOrder&65535)+(e.lowOrder&65535);g=(b.lowOrder>>>16)+(c.lowOrder>>>16)+(d.lowOrder>>>16)+(e.lowOrder>>>16)+(f>>>16);h=(g&65535)<<16|f&65535;f=(b.highOrder&65535)+(c.highOrder&65535)+(d.highOrder&65535)+(e.highOrder&65535)+(g>>>16);g=(b.highOrder>>>16)+(c.highOrder>>>16)+(d.highOrder>>>16)+(e.highOrder>>>16)+(f>>>16);return new a((g&65535)<<16|f&65535,h)},qa=function(b,c,d,e,f){var g,h,j;g=(b.lowOrder&65535)+(c.lowOrder&65535)+(d.lowOrder&65535)+(e.lowOrder& -65535)+(f.lowOrder&65535);h=(b.lowOrder>>>16)+(c.lowOrder>>>16)+(d.lowOrder>>>16)+(e.lowOrder>>>16)+(f.lowOrder>>>16)+(g>>>16);j=(h&65535)<<16|g&65535;g=(b.highOrder&65535)+(c.highOrder&65535)+(d.highOrder&65535)+(e.highOrder&65535)+(f.highOrder&65535)+(h>>>16);h=(b.highOrder>>>16)+(c.highOrder>>>16)+(d.highOrder>>>16)+(e.highOrder>>>16)+(f.highOrder>>>16)+(g>>>16);return new a((h&65535)<<16|g&65535,j)},ea=function(a,b){var c=[],d,e,f,h,j,k,m,l,p,o=[1732584193,4023233417,2562383102,271733878,3285377520], -u=[1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708, -2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782];a[b>>5]|=128<<24-b%32;a[(b+65>>9<<4)+15]=b;p=a.length;for(m=0;ml;l+=1)c[l]= -16>l?a[l+m]:g(c[l-3]^c[l-8]^c[l-14]^c[l-16],1),k=20>l?O(g(d,5),e&f^~e&h,j,u[l],c[l]):40>l?O(g(d,5),e^f^h,j,u[l],c[l]):60>l?O(g(d,5),D(e,f,h),j,u[l],c[l]):O(g(d,5),e^f^h,j,u[l],c[l]),j=h,h=f,f=g(e,30),e=d,d=k;o[0]=fa(d,o[0]);o[1]=fa(e,o[1]);o[2]=fa(f,o[2]);o[3]=fa(h,o[3]);o[4]=fa(j,o[4])}return o},ca=function(b,c,d){var e,f,g,h,j,k,ga,ca,ea,B,da,ma,ia,Ba,va,ja,wa,xa,ya,za,ta,ra,Aa,pa,t,ua,ba=[],Ea;if("SHA-224"===d||"SHA-256"===d)da=64,e=(c+65>>9<<4)+15,Ba=16,va=1,t=Number,ja=fa,wa=la,xa=O,ya=o,za= -ka,ta=p,ra=L,pa=D,Aa=m,ua=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771, -3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],B="SHA-224"===d?[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]:[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];else if("SHA-384"===d||"SHA-512"===d)da=80,e=(c+128>>10<<5)+31,Ba=32,va=2,t=a,ja=M,wa=Z,xa=qa, -ya=A,za=na,ta=W,ra=z,pa=l,Aa=u,ua=[new t(1116352408,3609767458),new t(1899447441,602891725),new t(3049323471,3964484399),new t(3921009573,2173295548),new t(961987163,4081628472),new t(1508970993,3053834265),new t(2453635748,2937671579),new t(2870763221,3664609560),new t(3624381080,2734883394),new t(310598401,1164996542),new t(607225278,1323610764),new t(1426881987,3590304994),new t(1925078388,4068182383),new t(2162078206,991336113),new t(2614888103,633803317),new t(3248222580,3479774868),new t(3835390401, -2666613458),new t(4022224774,944711139),new t(264347078,2341262773),new t(604807628,2007800933),new t(770255983,1495990901),new t(1249150122,1856431235),new t(1555081692,3175218132),new t(1996064986,2198950837),new t(2554220882,3999719339),new t(2821834349,766784016),new t(2952996808,2566594879),new t(3210313671,3203337956),new t(3336571891,1034457026),new t(3584528711,2466948901),new t(113926993,3758326383),new t(338241895,168717936),new t(666307205,1188179964),new t(773529912,1546045734),new t(1294757372, -1522805485),new t(1396182291,2643833823),new t(1695183700,2343527390),new t(1986661051,1014477480),new t(2177026350,1206759142),new t(2456956037,344077627),new t(2730485921,1290863460),new t(2820302411,3158454273),new t(3259730800,3505952657),new t(3345764771,106217008),new t(3516065817,3606008344),new t(3600352804,1432725776),new t(4094571909,1467031594),new t(275423344,851169720),new t(430227734,3100823752),new t(506948616,1363258195),new t(659060556,3750685593),new t(883997877,3785050280),new t(958139571, -3318307427),new t(1322822218,3812723403),new t(1537002063,2003034995),new t(1747873779,3602036899),new t(1955562222,1575990012),new t(2024104815,1125592928),new t(2227730452,2716904306),new t(2361852424,442776044),new t(2428436474,593698344),new t(2756734187,3733110249),new t(3204031479,2999351573),new t(3329325298,3815920427),new t(3391569614,3928383900),new t(3515267271,566280711),new t(3940187606,3454069534),new t(4118630271,4000239992),new t(116418474,1914138554),new t(174292421,2731055270),new t(289380356, -3203993006),new t(460393269,320620315),new t(685471733,587496836),new t(852142971,1086792851),new t(1017036298,365543100),new t(1126000580,2618297676),new t(1288033470,3409855158),new t(1501505948,4234509866),new t(1607167915,987167468),new t(1816402316,1246189591)],B="SHA-384"===d?[new t(3418070365,3238371032),new t(1654270250,914150663),new t(2438529370,812702999),new t(355462360,4144912697),new t(1731405415,4290775857),new t(41048885895,1750603025),new t(3675008525,1694076839),new t(1203062813, -3204075428)]:[new t(1779033703,4089235720),new t(3144134277,2227873595),new t(1013904242,4271175723),new t(2773480762,1595750129),new t(1359893119,2917565137),new t(2600822924,725511199),new t(528734635,4215389547),new t(1541459225,327033209)];b[c>>5]|=128<<24-c%32;b[e]=c;Ea=b.length;for(ma=0;maia?new t(b[ia*va+ma],b[ia*va+ma+1]):wa(za(ba[ia-2]),ba[ia-7],ya(ba[ia-15]),ba[ia-16]),ca=xa(ga,ra(h),Aa(h, -j,k),ua[ia],ba[ia]),ea=ja(ta(c),pa(c,e,f)),ga=k,k=j,j=h,h=ja(g,ca),g=f,f=e,e=c,c=ja(ca,ea);B[0]=ja(c,B[0]);B[1]=ja(e,B[1]);B[2]=ja(f,B[2]);B[3]=ja(g,B[3]);B[4]=ja(h,B[4]);B[5]=ja(j,B[5]);B[6]=ja(k,B[6]);B[7]=ja(ga,B[7])}switch(d){case "SHA-224":return[B[0],B[1],B[2],B[3],B[4],B[5],B[6]];case "SHA-256":return B;case "SHA-384":return[B[0].highOrder,B[0].lowOrder,B[1].highOrder,B[1].lowOrder,B[2].highOrder,B[2].lowOrder,B[3].highOrder,B[3].lowOrder,B[4].highOrder,B[4].lowOrder,B[5].highOrder,B[5].lowOrder]; -case "SHA-512":return[B[0].highOrder,B[0].lowOrder,B[1].highOrder,B[1].lowOrder,B[2].highOrder,B[2].lowOrder,B[3].highOrder,B[3].lowOrder,B[4].highOrder,B[4].lowOrder,B[5].highOrder,B[5].lowOrder,B[6].highOrder,B[6].lowOrder,B[7].highOrder,B[7].lowOrder];default:return[]}},da=function(a,d){this.strToHash=this.strBinLen=this.sha512=this.sha384=this.sha256=this.sha224=this.sha1=null;if("HEX"===d){if(0!==a.length%2)return"TEXT MUST BE IN BYTE INCREMENTS";this.strBinLen=4*a.length;this.strToHash=c(a)}else if("ASCII"=== -d||"undefined"===typeof d)this.strBinLen=8*a.length,this.strToHash=b(a);else return"UNKNOWN TEXT INPUT TYPE"};da.prototype={getHash:function(a,b){var c=null,g=this.strToHash.slice();switch(b){case "HEX":c=d;break;case "B64":c=e;break;case "ASCII":c=f;break;default:return"FORMAT NOT RECOGNIZED"}switch(a){case "SHA-1":if(null===this.sha1)this.sha1=ea(g,this.strBinLen);return c(this.sha1);case "SHA-224":if(null===this.sha224)this.sha224=ca(g,this.strBinLen,a);return c(this.sha224);case "SHA-256":if(null=== -this.sha256)this.sha256=ca(g,this.strBinLen,a);return c(this.sha256);case "SHA-384":if(null===this.sha384)this.sha384=ca(g,this.strBinLen,a);return c(this.sha384);case "SHA-512":if(null===this.sha512)this.sha512=ca(g,this.strBinLen,a);return c(this.sha512);default:return"HASH NOT RECOGNIZED"}},getHMAC:function(a,g,h,j){var k,l,m,o,p;l=[];var u=[];switch(j){case "HEX":j=d;break;case "B64":j=e;break;case "ASCII":j=f;break;default:return"FORMAT NOT RECOGNIZED"}switch(h){case "SHA-1":k=64;p=160;break; -case "SHA-224":k=64;p=224;break;case "SHA-256":k=64;p=256;break;case "SHA-384":k=128;p=384;break;case "SHA-512":k=128;p=512;break;default:return"HASH NOT RECOGNIZED"}if("HEX"===g){if(0!==a.length%2)return"KEY MUST BE IN BYTE INCREMENTS";g=c(a);o=4*a.length}else if("ASCII"===g)g=b(a),o=8*a.length;else return"UNKNOWN KEY INPUT TYPE";a=8*k;m=k/4-1;ko/8&&(g[m]&=4294967040);for(k=0;k<=m;k+=1)l[k]=g[k]^909522486,u[k]=g[k]^1549556828;"SHA-1"===h? -(l=ea(l.concat(this.strToHash),a+this.strBinLen),l=ea(u.concat(l),a+p)):(l=ca(l.concat(this.strToHash),a+this.strBinLen,h),l=ca(u.concat(l),a+p,h));return j(l)}};return da}();function str_sha1(a){return(new jsSHA(a,"ASCII")).getHash("SHA-1","ASCII")}function str_sha224(a){return(new jsSHA(a,"ASCII")).getHash("SHA-224","ASCII")}function str_sha256(a){return(new jsSHA(a,"ASCII")).getHash("SHA-256","ASCII")}function str_sha384(a){return(new jsSHA(a,"ASCII")).getHash("SHA-384","ASCII")} -function str_sha512(a){return(new jsSHA(a,"ASCII")).getHash("SHA-512","ASCII")}var RMDsize=160,X=[];function ROL(a,b){return new Number(a<>>32-b)}function F(a,b,c){return new Number(a^b^c)}function G(a,b,c){return new Number(a&b|~a&c)}function H(a,b,c){return new Number((a|~b)^c)}function I(a,b,c){return new Number(a&c|b&~c)}function J(a,b,c){return new Number(a^(b|~c))} -function mixOneRound(a,b,c,d,e,f,g,h){switch(h){case 0:a+=F(b,c,d)+f+0;break;case 1:a+=G(b,c,d)+f+1518500249;break;case 2:a+=H(b,c,d)+f+1859775393;break;case 3:a+=I(b,c,d)+f+2400959708;break;case 4:a+=J(b,c,d)+f+2840853838;break;case 5:a+=J(b,c,d)+f+1352829926;break;case 6:a+=I(b,c,d)+f+1548603684;break;case 7:a+=H(b,c,d)+f+1836072691;break;case 8:a+=G(b,c,d)+f+2053994217;break;case 9:a+=F(b,c,d)+f+0;break;default:document.write("Bogus round number")}a=ROL(a,g)+e;c=ROL(c,10);h=[];h[0]=a&4294967295; -h[1]=b&4294967295;h[2]=c&4294967295;h[3]=d&4294967295;h[4]=e&4294967295;h[5]=f;h[6]=g;return h}function MDinit(a){a[0]=1732584193;a[1]=4023233417;a[2]=2562383102;a[3]=271733878;a[4]=3285377520} +"",c=4*a.length,d,e,f;for(d=0;d>2]>>8*(3-d%4)&255)<<16|(a[d+1>>2]>>8*(3-(d+1)%4)&255)<<8|a[d+2>>2]>>8*(3-(d+2)%4)&255;for(e=0;4>e;e+=1)b=8*d+6*e<=32*a.length?b+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(f>>6*(3-e)&63):b+""}return b},f=function(a){for(var b="",c=0;c<32*a.length;c+=8)b+=String.fromCharCode(a[c>>5]>>>24-c%32&255);return b},h=function(a,b){return a<>>32-b},g=function(a,b){return a>>>b|a<<32-b},k=function(b,c){return 32>=c?new a(b.highOrder>>> +c|b.lowOrder<<32-c,b.lowOrder>>>c|b.highOrder<<32-c):new a(b.lowOrder>>>c|b.highOrder<<32-c,b.highOrder>>>c|b.lowOrder<<32-c)},j=function(b,c){return 32>=c?new a(b.highOrder>>>c,b.lowOrder>>>c|b.highOrder<<32-c):new a(0,b.highOrder<<32-c)},l=function(a,b,c){return a&b^~a&c},o=function(b,c,d){return new a(b.highOrder&c.highOrder^~b.highOrder&d.highOrder,b.lowOrder&c.lowOrder^~b.lowOrder&d.lowOrder)},s=function(a,b,c){return a&b^a&c^b&c},q=function(b,c,d){return new a(b.highOrder&c.highOrder^b.highOrder& +d.highOrder^c.highOrder&d.highOrder,b.lowOrder&c.lowOrder^b.lowOrder&d.lowOrder^c.lowOrder&d.lowOrder)},m=function(a){return g(a,2)^g(a,13)^g(a,22)},z=function(b){var c=k(b,28),d=k(b,34),b=k(b,39);return new a(c.highOrder^d.highOrder^b.highOrder,c.lowOrder^d.lowOrder^b.lowOrder)},x=function(a){return g(a,6)^g(a,11)^g(a,25)},v=function(b){var c=k(b,14),d=k(b,18),b=k(b,41);return new a(c.highOrder^d.highOrder^b.highOrder,c.lowOrder^d.lowOrder^b.lowOrder)},t=function(a){return g(a,7)^g(a,18)^a>>>3}, +r=function(b){var c=k(b,1),d=k(b,8),b=j(b,7);return new a(c.highOrder^d.highOrder^b.highOrder,c.lowOrder^d.lowOrder^b.lowOrder)},N=function(a){return g(a,17)^g(a,19)^a>>>10},T=function(b){var c=k(b,19),d=k(b,61),b=j(b,6);return new a(c.highOrder^d.highOrder^b.highOrder,c.lowOrder^d.lowOrder^b.lowOrder)},K=function(a,b){var c=(a&65535)+(b&65535);return((a>>>16)+(b>>>16)+(c>>>16)&65535)<<16|c&65535},P=function(a,b,c,d){var e=(a&65535)+(b&65535)+(c&65535)+(d&65535);return((a>>>16)+(b>>>16)+(c>>>16)+ +(d>>>16)+(e>>>16)&65535)<<16|e&65535},M=function(a,b,c,d,e){var f=(a&65535)+(b&65535)+(c&65535)+(d&65535)+(e&65535);return((a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(e>>>16)+(f>>>16)&65535)<<16|f&65535},w=function(b,c){var d,e,f;d=(b.lowOrder&65535)+(c.lowOrder&65535);e=(b.lowOrder>>>16)+(c.lowOrder>>>16)+(d>>>16);f=(e&65535)<<16|d&65535;d=(b.highOrder&65535)+(c.highOrder&65535)+(e>>>16);e=(b.highOrder>>>16)+(c.highOrder>>>16)+(d>>>16);return new a((e&65535)<<16|d&65535,f)},B=function(b,c,d,e){var f,g, +h;f=(b.lowOrder&65535)+(c.lowOrder&65535)+(d.lowOrder&65535)+(e.lowOrder&65535);g=(b.lowOrder>>>16)+(c.lowOrder>>>16)+(d.lowOrder>>>16)+(e.lowOrder>>>16)+(f>>>16);h=(g&65535)<<16|f&65535;f=(b.highOrder&65535)+(c.highOrder&65535)+(d.highOrder&65535)+(e.highOrder&65535)+(g>>>16);g=(b.highOrder>>>16)+(c.highOrder>>>16)+(d.highOrder>>>16)+(e.highOrder>>>16)+(f>>>16);return new a((g&65535)<<16|f&65535,h)},W=function(b,c,d,e,f){var g,h,j;g=(b.lowOrder&65535)+(c.lowOrder&65535)+(d.lowOrder&65535)+(e.lowOrder& +65535)+(f.lowOrder&65535);h=(b.lowOrder>>>16)+(c.lowOrder>>>16)+(d.lowOrder>>>16)+(e.lowOrder>>>16)+(f.lowOrder>>>16)+(g>>>16);j=(h&65535)<<16|g&65535;g=(b.highOrder&65535)+(c.highOrder&65535)+(d.highOrder&65535)+(e.highOrder&65535)+(f.highOrder&65535)+(h>>>16);h=(b.highOrder>>>16)+(c.highOrder>>>16)+(d.highOrder>>>16)+(e.highOrder>>>16)+(f.highOrder>>>16)+(g>>>16);return new a((h&65535)<<16|g&65535,j)},E=function(a,b){var c=[],d,e,f,g,j,k,l,m,q,o=[1732584193,4023233417,2562383102,271733878,3285377520], +r=[1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708, +2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782];a[b>>5]|=128<<24-b%32;a[(b+65>>9<<4)+15]=b;q=a.length;for(l=0;lm;m+=1)c[m]= +16>m?a[m+l]:h(c[m-3]^c[m-8]^c[m-14]^c[m-16],1),k=20>m?M(h(d,5),e&f^~e&g,j,r[m],c[m]):40>m?M(h(d,5),e^f^g,j,r[m],c[m]):60>m?M(h(d,5),s(e,f,g),j,r[m],c[m]):M(h(d,5),e^f^g,j,r[m],c[m]),j=g,g=f,f=h(e,30),e=d,d=k;o[0]=K(d,o[0]);o[1]=K(e,o[1]);o[2]=K(f,o[2]);o[3]=K(g,o[3]);o[4]=K(j,o[4])}return o},C=function(b,c,d){var e,f,g,h,j,k,V,C,E,u,D,Y,L,fa,ea,Q,ga,ha,ia,ja,ka,la,ma,na,p,oa,ba=[],ra;if("SHA-224"===d||"SHA-256"===d)D=64,e=(c+65>>9<<4)+15,fa=16,ea=1,p=Number,Q=K,ga=P,ha=M,ia=t,ja=N,ka=m,la=x,na=s, +ma=l,oa=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804, +4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],u="SHA-224"===d?[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]:[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];else if("SHA-384"===d||"SHA-512"===d)D=80,e=(c+128>>10<<5)+31,fa=32,ea=2,p=a,Q=w,ga=B,ha=W,ia=r,ja=T,ka=z,la=v,na=q, +ma=o,oa=[new p(1116352408,3609767458),new p(1899447441,602891725),new p(3049323471,3964484399),new p(3921009573,2173295548),new p(961987163,4081628472),new p(1508970993,3053834265),new p(2453635748,2937671579),new p(2870763221,3664609560),new p(3624381080,2734883394),new p(310598401,1164996542),new p(607225278,1323610764),new p(1426881987,3590304994),new p(1925078388,4068182383),new p(2162078206,991336113),new p(2614888103,633803317),new p(3248222580,3479774868),new p(3835390401,2666613458),new p(4022224774, +944711139),new p(264347078,2341262773),new p(604807628,2007800933),new p(770255983,1495990901),new p(1249150122,1856431235),new p(1555081692,3175218132),new p(1996064986,2198950837),new p(2554220882,3999719339),new p(2821834349,766784016),new p(2952996808,2566594879),new p(3210313671,3203337956),new p(3336571891,1034457026),new p(3584528711,2466948901),new p(113926993,3758326383),new p(338241895,168717936),new p(666307205,1188179964),new p(773529912,1546045734),new p(1294757372,1522805485),new p(1396182291, +2643833823),new p(1695183700,2343527390),new p(1986661051,1014477480),new p(2177026350,1206759142),new p(2456956037,344077627),new p(2730485921,1290863460),new p(2820302411,3158454273),new p(3259730800,3505952657),new p(3345764771,106217008),new p(3516065817,3606008344),new p(3600352804,1432725776),new p(4094571909,1467031594),new p(275423344,851169720),new p(430227734,3100823752),new p(506948616,1363258195),new p(659060556,3750685593),new p(883997877,3785050280),new p(958139571,3318307427),new p(1322822218, +3812723403),new p(1537002063,2003034995),new p(1747873779,3602036899),new p(1955562222,1575990012),new p(2024104815,1125592928),new p(2227730452,2716904306),new p(2361852424,442776044),new p(2428436474,593698344),new p(2756734187,3733110249),new p(3204031479,2999351573),new p(3329325298,3815920427),new p(3391569614,3928383900),new p(3515267271,566280711),new p(3940187606,3454069534),new p(4118630271,4000239992),new p(116418474,1914138554),new p(174292421,2731055270),new p(289380356,3203993006),new p(460393269, +320620315),new p(685471733,587496836),new p(852142971,1086792851),new p(1017036298,365543100),new p(1126000580,2618297676),new p(1288033470,3409855158),new p(1501505948,4234509866),new p(1607167915,987167468),new p(1816402316,1246189591)],u="SHA-384"===d?[new p(3418070365,3238371032),new p(1654270250,914150663),new p(2438529370,812702999),new p(355462360,4144912697),new p(1731405415,4290775857),new p(41048885895,1750603025),new p(3675008525,1694076839),new p(1203062813,3204075428)]:[new p(1779033703, +4089235720),new p(3144134277,2227873595),new p(1013904242,4271175723),new p(2773480762,1595750129),new p(1359893119,2917565137),new p(2600822924,725511199),new p(528734635,4215389547),new p(1541459225,327033209)];b[c>>5]|=128<<24-c%32;b[e]=c;ra=b.length;for(Y=0;YL?new p(b[L*ea+Y],b[L*ea+Y+1]):ga(ja(ba[L-2]),ba[L-7],ia(ba[L-15]),ba[L-16]),C=ha(V,la(h),ma(h,j,k),oa[L],ba[L]),E=Q(ka(c),na(c,e,f)),V=k,k=j,j=h, +h=Q(g,C),g=f,f=e,e=c,c=Q(C,E);u[0]=Q(c,u[0]);u[1]=Q(e,u[1]);u[2]=Q(f,u[2]);u[3]=Q(g,u[3]);u[4]=Q(h,u[4]);u[5]=Q(j,u[5]);u[6]=Q(k,u[6]);u[7]=Q(V,u[7])}switch(d){case "SHA-224":return[u[0],u[1],u[2],u[3],u[4],u[5],u[6]];case "SHA-256":return u;case "SHA-384":return[u[0].highOrder,u[0].lowOrder,u[1].highOrder,u[1].lowOrder,u[2].highOrder,u[2].lowOrder,u[3].highOrder,u[3].lowOrder,u[4].highOrder,u[4].lowOrder,u[5].highOrder,u[5].lowOrder];case "SHA-512":return[u[0].highOrder,u[0].lowOrder,u[1].highOrder, +u[1].lowOrder,u[2].highOrder,u[2].lowOrder,u[3].highOrder,u[3].lowOrder,u[4].highOrder,u[4].lowOrder,u[5].highOrder,u[5].lowOrder,u[6].highOrder,u[6].lowOrder,u[7].highOrder,u[7].lowOrder];default:return[]}},D=function(a,d){this.strToHash=this.strBinLen=this.sha512=this.sha384=this.sha256=this.sha224=this.sha1=null;if("HEX"===d){if(0!==a.length%2)return"TEXT MUST BE IN BYTE INCREMENTS";this.strBinLen=4*a.length;this.strToHash=c(a)}else if("ASCII"===d||"undefined"===typeof d)this.strBinLen=8*a.length, +this.strToHash=b(a);else return"UNKNOWN TEXT INPUT TYPE"};D.prototype={getHash:function(a,b){var c=null,g=this.strToHash.slice();switch(b){case "HEX":c=d;break;case "B64":c=e;break;case "ASCII":c=f;break;default:return"FORMAT NOT RECOGNIZED"}switch(a){case "SHA-1":if(null===this.sha1)this.sha1=E(g,this.strBinLen);return c(this.sha1);case "SHA-224":if(null===this.sha224)this.sha224=C(g,this.strBinLen,a);return c(this.sha224);case "SHA-256":if(null===this.sha256)this.sha256=C(g,this.strBinLen,a);return c(this.sha256); +case "SHA-384":if(null===this.sha384)this.sha384=C(g,this.strBinLen,a);return c(this.sha384);case "SHA-512":if(null===this.sha512)this.sha512=C(g,this.strBinLen,a);return c(this.sha512);default:return"HASH NOT RECOGNIZED"}},getHMAC:function(a,g,h,j){var k,l,m,o,q;l=[];var r=[];switch(j){case "HEX":j=d;break;case "B64":j=e;break;case "ASCII":j=f;break;default:return"FORMAT NOT RECOGNIZED"}switch(h){case "SHA-1":k=64;q=160;break;case "SHA-224":k=64;q=224;break;case "SHA-256":k=64;q=256;break;case "SHA-384":k= +128;q=384;break;case "SHA-512":k=128;q=512;break;default:return"HASH NOT RECOGNIZED"}if("HEX"===g){if(0!==a.length%2)return"KEY MUST BE IN BYTE INCREMENTS";g=c(a);o=4*a.length}else if("ASCII"===g)g=b(a),o=8*a.length;else return"UNKNOWN KEY INPUT TYPE";a=8*k;m=k/4-1;ko/8&&(g[m]&=4294967040);for(k=0;k<=m;k+=1)l[k]=g[k]^909522486,r[k]=g[k]^1549556828;"SHA-1"===h?(l=E(l.concat(this.strToHash),a+this.strBinLen),l=E(r.concat(l),a+q)):(l=C(l.concat(this.strToHash), +a+this.strBinLen,h),l=C(r.concat(l),a+q,h));return j(l)}};return D}();function str_sha1(a){return(new jsSHA(a,"ASCII")).getHash("SHA-1","ASCII")}function str_sha224(a){return(new jsSHA(a,"ASCII")).getHash("SHA-224","ASCII")}function str_sha256(a){return(new jsSHA(a,"ASCII")).getHash("SHA-256","ASCII")}function str_sha384(a){return(new jsSHA(a,"ASCII")).getHash("SHA-384","ASCII")}function str_sha512(a){return(new jsSHA(a,"ASCII")).getHash("SHA-512","ASCII")}var RMDsize=160,X=[]; +function ROL(a,b){return new Number(a<>>32-b)}function F(a,b,c){return new Number(a^b^c)}function G(a,b,c){return new Number(a&b|~a&c)}function H(a,b,c){return new Number((a|~b)^c)}function I(a,b,c){return new Number(a&c|b&~c)}function J(a,b,c){return new Number(a^(b|~c))} +function mixOneRound(a,b,c,d,e,f,h,g){switch(g){case 0:a+=F(b,c,d)+f+0;break;case 1:a+=G(b,c,d)+f+1518500249;break;case 2:a+=H(b,c,d)+f+1859775393;break;case 3:a+=I(b,c,d)+f+2400959708;break;case 4:a+=J(b,c,d)+f+2840853838;break;case 5:a+=J(b,c,d)+f+1352829926;break;case 6:a+=I(b,c,d)+f+1548603684;break;case 7:a+=H(b,c,d)+f+1836072691;break;case 8:a+=G(b,c,d)+f+2053994217;break;case 9:a+=F(b,c,d)+f+0;break;default:document.write("Bogus round number")}a=ROL(a,h)+e;c=ROL(c,10);g=[];g[0]=a&4294967295; +g[1]=b&4294967295;g[2]=c&4294967295;g[3]=d&4294967295;g[4]=e&4294967295;g[5]=f;g[6]=h;return g}function MDinit(a){a[0]=1732584193;a[1]=4023233417;a[2]=2562383102;a[3]=271733878;a[4]=3285377520} var ROLs=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12],[11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5],[11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12],[9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6],[9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11],[9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5],[15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8],[8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]],indexes=[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],[7,4,13,1,10,6,15,3,12, 0,9,5,2,14,11,8],[3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12],[1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2],[4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12],[6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2],[15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13],[8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14],[12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]]; function compress(a,b){blockA=[];blockB=[];for(var c,d=0;5>d;d++)blockA[d]=new Number(a[d]),blockB[d]=new Number(a[d]);for(var e=0,f=0;5>f;f++)for(d=0;16>d;d++)c=mixOneRound(blockA[(e+0)%5],blockA[(e+1)%5],blockA[(e+2)%5],blockA[(e+3)%5],blockA[(e+4)%5],b[indexes[f][d]],ROLs[f][d],f),blockA[(e+0)%5]=c[0],blockA[(e+1)%5]=c[1],blockA[(e+2)%5]=c[2],blockA[(e+3)%5]=c[3],blockA[(e+4)%5]=c[4],e+=4;e=0;for(f=5;10>f;f++)for(d=0;16>d;d++)c=mixOneRound(blockB[(e+0)%5],blockB[(e+1)%5],blockB[(e+2)%5],blockB[(e+ 3)%5],blockB[(e+4)%5],b[indexes[f][d]],ROLs[f][d],f),blockB[(e+0)%5]=c[0],blockB[(e+1)%5]=c[1],blockB[(e+2)%5]=c[2],blockB[(e+3)%5]=c[3],blockB[(e+4)%5]=c[4],e+=4;blockB[3]+=blockA[2]+a[1];a[1]=a[2]+blockA[3]+blockB[4];a[2]=a[3]+blockA[4]+blockB[0];a[3]=a[4]+blockA[0]+blockB[1];a[4]=a[0]+blockA[1]+blockB[2];a[0]=blockB[3]}function zeroX(a){for(var b=0;16>b;b++)a[b]=0} -function MDfinish(a,b,c,d){var e=Array(16);zeroX(e);for(var f=0,g=0;g<(c&63);g++)e[g>>>2]^=(b.charCodeAt(f++)&255)<<8*(g&3);e[c>>>2&15]^=1<<8*(c&3)+7;55<(c&63)&&(compress(a,e),e=Array(16),zeroX(e));e[14]=c<<3;e[15]=c>>>29|d<<3;compress(a,e)}function BYTES_TO_DWORD(a){var b=(a.charCodeAt(3)&255)<<24,b=b|(a.charCodeAt(2)&255)<<16,b=b|(a.charCodeAt(1)&255)<<8;return b|=a.charCodeAt(0)&255} -function RMD(a){var b=Array(RMDsize/32),c=Array(RMDsize/8),d,e;MDinit(b);d=a.length;var f=Array(16);zeroX(f);var g=0;for(e=d;63h;h++)f[h]=BYTES_TO_DWORD(a.substr(g,4)),g+=4;compress(b,f)}MDfinish(b,a.substr(g),d,0);for(h=0;h>>2]&255,c[h+1]=b[h>>>2]>>>8&255,c[h+2]=b[h>>>2]>>>16&255,c[h+3]=b[h>>>2]>>>24&255;return c}function RMDstring(a){for(var a=RMD(a),b="",c=0;c>>2]^=(b.charCodeAt(f++)&255)<<8*(h&3);e[c>>>2&15]^=1<<8*(c&3)+7;55<(c&63)&&(compress(a,e),e=Array(16),zeroX(e));e[14]=c<<3;e[15]=c>>>29|d<<3;compress(a,e)}function BYTES_TO_DWORD(a){var b=(a.charCodeAt(3)&255)<<24,b=b|(a.charCodeAt(2)&255)<<16,b=b|(a.charCodeAt(1)&255)<<8;return b|=a.charCodeAt(0)&255} +function RMD(a){var b=Array(RMDsize/32),c=Array(RMDsize/8),d,e;MDinit(b);d=a.length;var f=Array(16);zeroX(f);var h=0;for(e=d;63g;g++)f[g]=BYTES_TO_DWORD(a.substr(h,4)),h+=4;compress(b,f)}MDfinish(b,a.substr(h),d,0);for(g=0;g>>2]&255,c[g+1]=b[g>>>2]>>>8&255,c[g+2]=b[g>>>2]>>>16&255,c[g+3]=b[g>>>2]>>>24&255;return c}function RMDstring(a){for(var a=RMD(a),b="",c=0;c>>32-e,c)}function ff(a,b,c,d,e,f,g){return cmn(b&c|~b&d,a,b,e,f,g)}function gg(a,b,c,d,e,f,g){return cmn(b&d|c&~d,a,b,e,f,g)}function hh(a,b,c,d,e,f,g){return cmn(b^c^d,a,b,e,f,g)} -function ii(a,b,c,d,e,f,g){return cmn(c^(b|~d),a,b,e,f,g)}function md51(a){txt="";var b=a.length,c=[1732584193,-271733879,-1732584194,271733878],d;for(d=64;d<=a.length;d+=64)md5cycle(c,md5blk(a.substring(d-64,d)));var a=a.substring(d-64),e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(d=0;d>2]|=a.charCodeAt(d)<<(d%4<<3);e[d>>2]|=128<<(d%4<<3);if(55d;d++)e[d]=0}e[14]=8*b;md5cycle(c,e);return c} +21,1309151649),c=ii(c,d,e,f,b[4],6,-145523070),f=ii(f,c,d,e,b[11],10,-1120210379),e=ii(e,f,c,d,b[2],15,718787259),d=ii(d,e,f,c,b[9],21,-343485551);a[0]=add32(c,a[0]);a[1]=add32(d,a[1]);a[2]=add32(e,a[2]);a[3]=add32(f,a[3])}function cmn(a,b,c,d,e,f){b=add32(add32(b,a),add32(d,f));return add32(b<>>32-e,c)}function ff(a,b,c,d,e,f,h){return cmn(b&c|~b&d,a,b,e,f,h)}function gg(a,b,c,d,e,f,h){return cmn(b&d|c&~d,a,b,e,f,h)}function hh(a,b,c,d,e,f,h){return cmn(b^c^d,a,b,e,f,h)} +function ii(a,b,c,d,e,f,h){return cmn(c^(b|~d),a,b,e,f,h)}function md51(a){txt="";var b=a.length,c=[1732584193,-271733879,-1732584194,271733878],d;for(d=64;d<=a.length;d+=64)md5cycle(c,md5blk(a.substring(d-64,d)));var a=a.substring(d-64),e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(d=0;d>2]|=a.charCodeAt(d)<<(d%4<<3);e[d>>2]|=128<<(d%4<<3);if(55d;d++)e[d]=0}e[14]=8*b;md5cycle(c,e);return c} function md5blk(a){var b=[],c;for(c=0;64>c;c+=4)b[c>>2]=a.charCodeAt(c)+(a.charCodeAt(c+1)<<8)+(a.charCodeAt(c+2)<<16)+(a.charCodeAt(c+3)<<24);return b}var hex_chr="0123456789abcdef".split("");function rhex(a){for(var b="",c=0;4>c;c++)b+=hex_chr[a>>8*c+4&15]+hex_chr[a>>8*c&15];return b}function hex(a){for(var b=0;b>16)+(b>>16)+(c>>16)<<16|c&65535}); function openpgp_keyring(){this.init=function(){var a=JSON.parse(window.localStorage.getItem("privatekeys")),b=JSON.parse(window.localStorage.getItem("publickeys"));if(null==a||0==a.length)a=[];if(null==b||0==b.length)b=[];this.publicKeys=[];this.privateKeys=[];for(var c=0,d=0;da;){var e=openpgp_packet.read_packet(b,a,b.length-a);if(null==e){util.print_error("openpgp.msg.messge decrypt:\n[pub/priv_key]parsing ends here @:"+a+" l:"+d);break}else switch(e.tagType){case 2:if(32==e.signatureType)this.revocationSignatures[this.revocationSignatures.length]=e;else if(15e.signatureType){if(null==this.certificationsignatures)this.certificationSignatures= -[];this.certificationSignatures[this.certificationSignatures.length]=e}else util.print_error("openpgp.msg.messge decrypt:\nunknown signature type directly on key "+e.signatureType+" @"+a);a+=e.packetLength+e.headerLength;break;case 7:this.subKeys[this.subKeys.length]=e;a+=e.packetLength+e.headerLength;a+=e.read_nodes(this.privateKeyPacket,b,a,b.length-a);break;case 17:this.userAttributes[this.userAttributes.length]=e;a+=e.packetLength+e.headerLength;a+=e.read_nodes(this.privateKeyPacket,b,a,b.length- -a);break;case 13:this.userIds[this.userIds.length]=e;a+=e.packetLength+e.headerLength;a+=e.read_nodes(this.privateKeyPacket,b,a,b.length-a);break;default:return this.position=c-this.privateKeyPacket.packetLength-this.privateKeyPacket.headerLength,this.len=a-c}}this.position=c-this.privateKeyPacket.packetLength-this.privateKeyPacket.headerLength;return this.len=a-c};this.decryptSecretMPIs=function(a){return this.privateKeyPacket.decryptSecretMPIs(a)};this.getSubKeyIds=function(){if(4==this.privateKeyPacket.publicKey.version)var a= -[];for(var b=0;b +a;){var e=openpgp_packet.read_packet(b,a,b.length-a);if(null==e){util.print_error("openpgp.msg.messge decrypt:\n[pub/priv_key]parsing ends here @:"+a+" l:"+d);break}else switch(e.tagType){case 2:if(32==e.signatureType)this.revocationSignatures[this.revocationSignatures.length]=e;else if(15e.signatureType){if(null==this.certificationsignatures)this.certificationSignatures=[];this.certificationSignatures[this.certificationSignatures.length]=e}else util.print_error("openpgp.msg.messge decrypt:\nunknown signature type directly on key "+ +e.signatureType+" @"+a);a+=e.packetLength+e.headerLength;break;case 7:this.subKeys[this.subKeys.length]=e;a+=e.packetLength+e.headerLength;a+=e.read_nodes(this.privateKeyPacket,b,a,b.length-a);break;case 17:this.userAttributes[this.userAttributes.length]=e;a+=e.packetLength+e.headerLength;a+=e.read_nodes(this.privateKeyPacket,b,a,b.length-a);break;case 13:this.userIds[this.userIds.length]=e;a+=e.packetLength+e.headerLength;a+=e.read_nodes(this.privateKeyPacket,b,a,b.length-a);break;default:return this.position= +c-this.privateKeyPacket.packetLength-this.privateKeyPacket.headerLength,this.len=a-c}}this.position=c-this.privateKeyPacket.packetLength-this.privateKeyPacket.headerLength;return this.len=a-c};this.decryptSecretMPIs=function(a){return this.privateKeyPacket.decryptSecretMPIs(a)};this.getSubKeyIds=function(){if(4==this.privateKeyPacket.publicKey.version)var a=[];for(var b=0;bb-11)return-1;var c; hash_headers=[,[48,32,48,12,6,8,42,134,72,134,247,13,2,5,5,0,4,16],[48,33,48,9,6,5,43,14,3,2,26,5,0,4,20],[48,33,48,9,6,5,43,36,3,2,1,5,0,4,20]];hash_headers[8]=[48,49,48,13,6,9,96,134,72,1,101,3,4,2,1,5,0,4,32];hash_headers[9]=[48,65,48,13,6,9,96,134,72,1,101,3,4,2,2,5,0,4,48];hash_headers[10]=[48,81,48,13,6,9,96,134,72,1,101,3,4,2,3,5,0,4,64];hash_headers[11]=[48,49,48,13,6,9,96,134,72,1,101,3,4,2,4,5,0,4,28]; function openpgp_encoding_emsa_pkcs1_encode(a,b,c){var d;d=""+String.fromCharCode(0);d+=String.fromCharCode(1);for(var e=0;e>2&63),b=(c&3)<<4):1==g?(e+=b64s.charAt(b|c>>4&15),b=(c&15)<<2):2==g&&(e+=b64s.charAt(b|c>>6&3),f+=1,0==f%60&&(e+="\n"),e+=b64s.charAt(c&63)),f+=1,0==f%60&&(e+="\n"),g+=1,3==g&&(g=0);0>6-e&255)),e=e+2&7,f=b<>2&63),b=(c&3)<<4):1==h?(e+=b64s.charAt(b|c>>4&15),b=(c&15)<<2):2==h&&(e+=b64s.charAt(b|c>>6&3),f+=1,0==f%60&&(e+="\n"),e+=b64s.charAt(c&63)),f+=1,0==f%60&&(e+="\n"),h+=1,3==h&&(h=0);0>6-e&255)),e=e+2&7,f=b<