jsencrypt.js 105 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813
  1. // ../../../../wpl/hjy/workApp/node_modules/jsencrypt/lib/lib/jsbn/util.js
  2. var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
  3. function int2char(n) {
  4. return BI_RM.charAt(n);
  5. }
  6. function op_and(x, y) {
  7. return x & y;
  8. }
  9. function op_or(x, y) {
  10. return x | y;
  11. }
  12. function op_xor(x, y) {
  13. return x ^ y;
  14. }
  15. function op_andnot(x, y) {
  16. return x & ~y;
  17. }
  18. function lbit(x) {
  19. if (x == 0) {
  20. return -1;
  21. }
  22. var r = 0;
  23. if ((x & 65535) == 0) {
  24. x >>= 16;
  25. r += 16;
  26. }
  27. if ((x & 255) == 0) {
  28. x >>= 8;
  29. r += 8;
  30. }
  31. if ((x & 15) == 0) {
  32. x >>= 4;
  33. r += 4;
  34. }
  35. if ((x & 3) == 0) {
  36. x >>= 2;
  37. r += 2;
  38. }
  39. if ((x & 1) == 0) {
  40. ++r;
  41. }
  42. return r;
  43. }
  44. function cbit(x) {
  45. var r = 0;
  46. while (x != 0) {
  47. x &= x - 1;
  48. ++r;
  49. }
  50. return r;
  51. }
  52. // ../../../../wpl/hjy/workApp/node_modules/jsencrypt/lib/lib/jsbn/base64.js
  53. var b64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  54. var b64pad = "=";
  55. function hex2b64(h) {
  56. var i;
  57. var c;
  58. var ret = "";
  59. for (i = 0; i + 3 <= h.length; i += 3) {
  60. c = parseInt(h.substring(i, i + 3), 16);
  61. ret += b64map.charAt(c >> 6) + b64map.charAt(c & 63);
  62. }
  63. if (i + 1 == h.length) {
  64. c = parseInt(h.substring(i, i + 1), 16);
  65. ret += b64map.charAt(c << 2);
  66. } else if (i + 2 == h.length) {
  67. c = parseInt(h.substring(i, i + 2), 16);
  68. ret += b64map.charAt(c >> 2) + b64map.charAt((c & 3) << 4);
  69. }
  70. while ((ret.length & 3) > 0) {
  71. ret += b64pad;
  72. }
  73. return ret;
  74. }
  75. function b64tohex(s) {
  76. var ret = "";
  77. var i;
  78. var k = 0;
  79. var slop = 0;
  80. for (i = 0; i < s.length; ++i) {
  81. if (s.charAt(i) == b64pad) {
  82. break;
  83. }
  84. var v = b64map.indexOf(s.charAt(i));
  85. if (v < 0) {
  86. continue;
  87. }
  88. if (k == 0) {
  89. ret += int2char(v >> 2);
  90. slop = v & 3;
  91. k = 1;
  92. } else if (k == 1) {
  93. ret += int2char(slop << 2 | v >> 4);
  94. slop = v & 15;
  95. k = 2;
  96. } else if (k == 2) {
  97. ret += int2char(slop);
  98. ret += int2char(v >> 2);
  99. slop = v & 3;
  100. k = 3;
  101. } else {
  102. ret += int2char(slop << 2 | v >> 4);
  103. ret += int2char(v & 15);
  104. k = 0;
  105. }
  106. }
  107. if (k == 1) {
  108. ret += int2char(slop << 2);
  109. }
  110. return ret;
  111. }
  112. // ../../../../wpl/hjy/workApp/node_modules/jsencrypt/lib/lib/asn1js/hex.js
  113. var decoder;
  114. var Hex = {
  115. decode: function(a) {
  116. var i;
  117. if (decoder === void 0) {
  118. var hex = "0123456789ABCDEF";
  119. var ignore = " \f\n\r  \u2028\u2029";
  120. decoder = {};
  121. for (i = 0; i < 16; ++i) {
  122. decoder[hex.charAt(i)] = i;
  123. }
  124. hex = hex.toLowerCase();
  125. for (i = 10; i < 16; ++i) {
  126. decoder[hex.charAt(i)] = i;
  127. }
  128. for (i = 0; i < ignore.length; ++i) {
  129. decoder[ignore.charAt(i)] = -1;
  130. }
  131. }
  132. var out = [];
  133. var bits = 0;
  134. var char_count = 0;
  135. for (i = 0; i < a.length; ++i) {
  136. var c = a.charAt(i);
  137. if (c == "=") {
  138. break;
  139. }
  140. c = decoder[c];
  141. if (c == -1) {
  142. continue;
  143. }
  144. if (c === void 0) {
  145. throw new Error("Illegal character at offset " + i);
  146. }
  147. bits |= c;
  148. if (++char_count >= 2) {
  149. out[out.length] = bits;
  150. bits = 0;
  151. char_count = 0;
  152. } else {
  153. bits <<= 4;
  154. }
  155. }
  156. if (char_count) {
  157. throw new Error("Hex encoding incomplete: 4 bits missing");
  158. }
  159. return out;
  160. }
  161. };
  162. // ../../../../wpl/hjy/workApp/node_modules/jsencrypt/lib/lib/asn1js/base64.js
  163. var decoder2;
  164. var Base64 = {
  165. decode: function(a) {
  166. var i;
  167. if (decoder2 === void 0) {
  168. var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  169. var ignore = "= \f\n\r  \u2028\u2029";
  170. decoder2 = /* @__PURE__ */ Object.create(null);
  171. for (i = 0; i < 64; ++i) {
  172. decoder2[b64.charAt(i)] = i;
  173. }
  174. decoder2["-"] = 62;
  175. decoder2["_"] = 63;
  176. for (i = 0; i < ignore.length; ++i) {
  177. decoder2[ignore.charAt(i)] = -1;
  178. }
  179. }
  180. var out = [];
  181. var bits = 0;
  182. var char_count = 0;
  183. for (i = 0; i < a.length; ++i) {
  184. var c = a.charAt(i);
  185. if (c == "=") {
  186. break;
  187. }
  188. c = decoder2[c];
  189. if (c == -1) {
  190. continue;
  191. }
  192. if (c === void 0) {
  193. throw new Error("Illegal character at offset " + i);
  194. }
  195. bits |= c;
  196. if (++char_count >= 4) {
  197. out[out.length] = bits >> 16;
  198. out[out.length] = bits >> 8 & 255;
  199. out[out.length] = bits & 255;
  200. bits = 0;
  201. char_count = 0;
  202. } else {
  203. bits <<= 6;
  204. }
  205. }
  206. switch (char_count) {
  207. case 1:
  208. throw new Error("Base64 encoding incomplete: at least 2 bits missing");
  209. case 2:
  210. out[out.length] = bits >> 10;
  211. break;
  212. case 3:
  213. out[out.length] = bits >> 16;
  214. out[out.length] = bits >> 8 & 255;
  215. break;
  216. }
  217. return out;
  218. },
  219. re: /-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,
  220. unarmor: function(a) {
  221. var m = Base64.re.exec(a);
  222. if (m) {
  223. if (m[1]) {
  224. a = m[1];
  225. } else if (m[2]) {
  226. a = m[2];
  227. } else {
  228. throw new Error("RegExp out of sync");
  229. }
  230. }
  231. return Base64.decode(a);
  232. }
  233. };
  234. // ../../../../wpl/hjy/workApp/node_modules/jsencrypt/lib/lib/asn1js/int10.js
  235. var max = 1e13;
  236. var Int10 = (
  237. /** @class */
  238. function() {
  239. function Int102(value) {
  240. this.buf = [+value || 0];
  241. }
  242. Int102.prototype.mulAdd = function(m, c) {
  243. var b = this.buf;
  244. var l = b.length;
  245. var i;
  246. var t;
  247. for (i = 0; i < l; ++i) {
  248. t = b[i] * m + c;
  249. if (t < max) {
  250. c = 0;
  251. } else {
  252. c = 0 | t / max;
  253. t -= c * max;
  254. }
  255. b[i] = t;
  256. }
  257. if (c > 0) {
  258. b[i] = c;
  259. }
  260. };
  261. Int102.prototype.sub = function(c) {
  262. var b = this.buf;
  263. var l = b.length;
  264. var i;
  265. var t;
  266. for (i = 0; i < l; ++i) {
  267. t = b[i] - c;
  268. if (t < 0) {
  269. t += max;
  270. c = 1;
  271. } else {
  272. c = 0;
  273. }
  274. b[i] = t;
  275. }
  276. while (b[b.length - 1] === 0) {
  277. b.pop();
  278. }
  279. };
  280. Int102.prototype.toString = function(base) {
  281. if ((base || 10) != 10) {
  282. throw new Error("only base 10 is supported");
  283. }
  284. var b = this.buf;
  285. var s = b[b.length - 1].toString();
  286. for (var i = b.length - 2; i >= 0; --i) {
  287. s += (max + b[i]).toString().substring(1);
  288. }
  289. return s;
  290. };
  291. Int102.prototype.valueOf = function() {
  292. var b = this.buf;
  293. var v = 0;
  294. for (var i = b.length - 1; i >= 0; --i) {
  295. v = v * max + b[i];
  296. }
  297. return v;
  298. };
  299. Int102.prototype.simplify = function() {
  300. var b = this.buf;
  301. return b.length == 1 ? b[0] : this;
  302. };
  303. return Int102;
  304. }()
  305. );
  306. // ../../../../wpl/hjy/workApp/node_modules/jsencrypt/lib/lib/asn1js/asn1.js
  307. var ellipsis = "…";
  308. var reTimeS = /^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;
  309. var reTimeL = /^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;
  310. function stringCut(str, len) {
  311. if (str.length > len) {
  312. str = str.substring(0, len) + ellipsis;
  313. }
  314. return str;
  315. }
  316. var Stream = (
  317. /** @class */
  318. function() {
  319. function Stream2(enc, pos) {
  320. this.hexDigits = "0123456789ABCDEF";
  321. if (enc instanceof Stream2) {
  322. this.enc = enc.enc;
  323. this.pos = enc.pos;
  324. } else {
  325. this.enc = enc;
  326. this.pos = pos;
  327. }
  328. }
  329. Stream2.prototype.get = function(pos) {
  330. if (pos === void 0) {
  331. pos = this.pos++;
  332. }
  333. if (pos >= this.enc.length) {
  334. throw new Error("Requesting byte offset ".concat(pos, " on a stream of length ").concat(this.enc.length));
  335. }
  336. return "string" === typeof this.enc ? this.enc.charCodeAt(pos) : this.enc[pos];
  337. };
  338. Stream2.prototype.hexByte = function(b) {
  339. return this.hexDigits.charAt(b >> 4 & 15) + this.hexDigits.charAt(b & 15);
  340. };
  341. Stream2.prototype.hexDump = function(start, end, raw) {
  342. var s = "";
  343. for (var i = start; i < end; ++i) {
  344. s += this.hexByte(this.get(i));
  345. if (raw !== true) {
  346. switch (i & 15) {
  347. case 7:
  348. s += " ";
  349. break;
  350. case 15:
  351. s += "\n";
  352. break;
  353. default:
  354. s += " ";
  355. }
  356. }
  357. }
  358. return s;
  359. };
  360. Stream2.prototype.isASCII = function(start, end) {
  361. for (var i = start; i < end; ++i) {
  362. var c = this.get(i);
  363. if (c < 32 || c > 176) {
  364. return false;
  365. }
  366. }
  367. return true;
  368. };
  369. Stream2.prototype.parseStringISO = function(start, end) {
  370. var s = "";
  371. for (var i = start; i < end; ++i) {
  372. s += String.fromCharCode(this.get(i));
  373. }
  374. return s;
  375. };
  376. Stream2.prototype.parseStringUTF = function(start, end) {
  377. var s = "";
  378. for (var i = start; i < end; ) {
  379. var c = this.get(i++);
  380. if (c < 128) {
  381. s += String.fromCharCode(c);
  382. } else if (c > 191 && c < 224) {
  383. s += String.fromCharCode((c & 31) << 6 | this.get(i++) & 63);
  384. } else {
  385. s += String.fromCharCode((c & 15) << 12 | (this.get(i++) & 63) << 6 | this.get(i++) & 63);
  386. }
  387. }
  388. return s;
  389. };
  390. Stream2.prototype.parseStringBMP = function(start, end) {
  391. var str = "";
  392. var hi;
  393. var lo;
  394. for (var i = start; i < end; ) {
  395. hi = this.get(i++);
  396. lo = this.get(i++);
  397. str += String.fromCharCode(hi << 8 | lo);
  398. }
  399. return str;
  400. };
  401. Stream2.prototype.parseTime = function(start, end, shortYear) {
  402. var s = this.parseStringISO(start, end);
  403. var m = (shortYear ? reTimeS : reTimeL).exec(s);
  404. if (!m) {
  405. return "Unrecognized time: " + s;
  406. }
  407. if (shortYear) {
  408. m[1] = +m[1];
  409. m[1] += +m[1] < 70 ? 2e3 : 1900;
  410. }
  411. s = m[1] + "-" + m[2] + "-" + m[3] + " " + m[4];
  412. if (m[5]) {
  413. s += ":" + m[5];
  414. if (m[6]) {
  415. s += ":" + m[6];
  416. if (m[7]) {
  417. s += "." + m[7];
  418. }
  419. }
  420. }
  421. if (m[8]) {
  422. s += " UTC";
  423. if (m[8] != "Z") {
  424. s += m[8];
  425. if (m[9]) {
  426. s += ":" + m[9];
  427. }
  428. }
  429. }
  430. return s;
  431. };
  432. Stream2.prototype.parseInteger = function(start, end) {
  433. var v = this.get(start);
  434. var neg = v > 127;
  435. var pad = neg ? 255 : 0;
  436. var len;
  437. var s = "";
  438. while (v == pad && ++start < end) {
  439. v = this.get(start);
  440. }
  441. len = end - start;
  442. if (len === 0) {
  443. return neg ? -1 : 0;
  444. }
  445. if (len > 4) {
  446. s = v;
  447. len <<= 3;
  448. while (((+s ^ pad) & 128) == 0) {
  449. s = +s << 1;
  450. --len;
  451. }
  452. s = "(" + len + " bit)\n";
  453. }
  454. if (neg) {
  455. v = v - 256;
  456. }
  457. var n = new Int10(v);
  458. for (var i = start + 1; i < end; ++i) {
  459. n.mulAdd(256, this.get(i));
  460. }
  461. return s + n.toString();
  462. };
  463. Stream2.prototype.parseBitString = function(start, end, maxLength) {
  464. var unusedBit = this.get(start);
  465. var lenBit = (end - start - 1 << 3) - unusedBit;
  466. var intro = "(" + lenBit + " bit)\n";
  467. var s = "";
  468. for (var i = start + 1; i < end; ++i) {
  469. var b = this.get(i);
  470. var skip = i == end - 1 ? unusedBit : 0;
  471. for (var j = 7; j >= skip; --j) {
  472. s += b >> j & 1 ? "1" : "0";
  473. }
  474. if (s.length > maxLength) {
  475. return intro + stringCut(s, maxLength);
  476. }
  477. }
  478. return intro + s;
  479. };
  480. Stream2.prototype.parseOctetString = function(start, end, maxLength) {
  481. if (this.isASCII(start, end)) {
  482. return stringCut(this.parseStringISO(start, end), maxLength);
  483. }
  484. var len = end - start;
  485. var s = "(" + len + " byte)\n";
  486. maxLength /= 2;
  487. if (len > maxLength) {
  488. end = start + maxLength;
  489. }
  490. for (var i = start; i < end; ++i) {
  491. s += this.hexByte(this.get(i));
  492. }
  493. if (len > maxLength) {
  494. s += ellipsis;
  495. }
  496. return s;
  497. };
  498. Stream2.prototype.parseOID = function(start, end, maxLength) {
  499. var s = "";
  500. var n = new Int10();
  501. var bits = 0;
  502. for (var i = start; i < end; ++i) {
  503. var v = this.get(i);
  504. n.mulAdd(128, v & 127);
  505. bits += 7;
  506. if (!(v & 128)) {
  507. if (s === "") {
  508. n = n.simplify();
  509. if (n instanceof Int10) {
  510. n.sub(80);
  511. s = "2." + n.toString();
  512. } else {
  513. var m = n < 80 ? n < 40 ? 0 : 1 : 2;
  514. s = m + "." + (n - m * 40);
  515. }
  516. } else {
  517. s += "." + n.toString();
  518. }
  519. if (s.length > maxLength) {
  520. return stringCut(s, maxLength);
  521. }
  522. n = new Int10();
  523. bits = 0;
  524. }
  525. }
  526. if (bits > 0) {
  527. s += ".incomplete";
  528. }
  529. return s;
  530. };
  531. return Stream2;
  532. }()
  533. );
  534. var ASN1 = (
  535. /** @class */
  536. function() {
  537. function ASN12(stream, header, length, tag, sub) {
  538. if (!(tag instanceof ASN1Tag)) {
  539. throw new Error("Invalid tag value.");
  540. }
  541. this.stream = stream;
  542. this.header = header;
  543. this.length = length;
  544. this.tag = tag;
  545. this.sub = sub;
  546. }
  547. ASN12.prototype.typeName = function() {
  548. switch (this.tag.tagClass) {
  549. case 0:
  550. switch (this.tag.tagNumber) {
  551. case 0:
  552. return "EOC";
  553. case 1:
  554. return "BOOLEAN";
  555. case 2:
  556. return "INTEGER";
  557. case 3:
  558. return "BIT_STRING";
  559. case 4:
  560. return "OCTET_STRING";
  561. case 5:
  562. return "NULL";
  563. case 6:
  564. return "OBJECT_IDENTIFIER";
  565. case 7:
  566. return "ObjectDescriptor";
  567. case 8:
  568. return "EXTERNAL";
  569. case 9:
  570. return "REAL";
  571. case 10:
  572. return "ENUMERATED";
  573. case 11:
  574. return "EMBEDDED_PDV";
  575. case 12:
  576. return "UTF8String";
  577. case 16:
  578. return "SEQUENCE";
  579. case 17:
  580. return "SET";
  581. case 18:
  582. return "NumericString";
  583. case 19:
  584. return "PrintableString";
  585. case 20:
  586. return "TeletexString";
  587. case 21:
  588. return "VideotexString";
  589. case 22:
  590. return "IA5String";
  591. case 23:
  592. return "UTCTime";
  593. case 24:
  594. return "GeneralizedTime";
  595. case 25:
  596. return "GraphicString";
  597. case 26:
  598. return "VisibleString";
  599. case 27:
  600. return "GeneralString";
  601. case 28:
  602. return "UniversalString";
  603. case 30:
  604. return "BMPString";
  605. }
  606. return "Universal_" + this.tag.tagNumber.toString();
  607. case 1:
  608. return "Application_" + this.tag.tagNumber.toString();
  609. case 2:
  610. return "[" + this.tag.tagNumber.toString() + "]";
  611. case 3:
  612. return "Private_" + this.tag.tagNumber.toString();
  613. }
  614. };
  615. ASN12.prototype.content = function(maxLength) {
  616. if (this.tag === void 0) {
  617. return null;
  618. }
  619. if (maxLength === void 0) {
  620. maxLength = Infinity;
  621. }
  622. var content = this.posContent();
  623. var len = Math.abs(this.length);
  624. if (!this.tag.isUniversal()) {
  625. if (this.sub !== null) {
  626. return "(" + this.sub.length + " elem)";
  627. }
  628. return this.stream.parseOctetString(content, content + len, maxLength);
  629. }
  630. switch (this.tag.tagNumber) {
  631. case 1:
  632. return this.stream.get(content) === 0 ? "false" : "true";
  633. case 2:
  634. return this.stream.parseInteger(content, content + len);
  635. case 3:
  636. return this.sub ? "(" + this.sub.length + " elem)" : this.stream.parseBitString(content, content + len, maxLength);
  637. case 4:
  638. return this.sub ? "(" + this.sub.length + " elem)" : this.stream.parseOctetString(content, content + len, maxLength);
  639. case 6:
  640. return this.stream.parseOID(content, content + len, maxLength);
  641. case 16:
  642. case 17:
  643. if (this.sub !== null) {
  644. return "(" + this.sub.length + " elem)";
  645. } else {
  646. return "(no elem)";
  647. }
  648. case 12:
  649. return stringCut(this.stream.parseStringUTF(content, content + len), maxLength);
  650. case 18:
  651. case 19:
  652. case 20:
  653. case 21:
  654. case 22:
  655. case 26:
  656. return stringCut(this.stream.parseStringISO(content, content + len), maxLength);
  657. case 30:
  658. return stringCut(this.stream.parseStringBMP(content, content + len), maxLength);
  659. case 23:
  660. case 24:
  661. return this.stream.parseTime(content, content + len, this.tag.tagNumber == 23);
  662. }
  663. return null;
  664. };
  665. ASN12.prototype.toString = function() {
  666. return this.typeName() + "@" + this.stream.pos + "[header:" + this.header + ",length:" + this.length + ",sub:" + (this.sub === null ? "null" : this.sub.length) + "]";
  667. };
  668. ASN12.prototype.toPrettyString = function(indent) {
  669. if (indent === void 0) {
  670. indent = "";
  671. }
  672. var s = indent + this.typeName() + " @" + this.stream.pos;
  673. if (this.length >= 0) {
  674. s += "+";
  675. }
  676. s += this.length;
  677. if (this.tag.tagConstructed) {
  678. s += " (constructed)";
  679. } else if (this.tag.isUniversal() && (this.tag.tagNumber == 3 || this.tag.tagNumber == 4) && this.sub !== null) {
  680. s += " (encapsulates)";
  681. }
  682. s += "\n";
  683. if (this.sub !== null) {
  684. indent += " ";
  685. for (var i = 0, max2 = this.sub.length; i < max2; ++i) {
  686. s += this.sub[i].toPrettyString(indent);
  687. }
  688. }
  689. return s;
  690. };
  691. ASN12.prototype.posStart = function() {
  692. return this.stream.pos;
  693. };
  694. ASN12.prototype.posContent = function() {
  695. return this.stream.pos + this.header;
  696. };
  697. ASN12.prototype.posEnd = function() {
  698. return this.stream.pos + this.header + Math.abs(this.length);
  699. };
  700. ASN12.prototype.toHexString = function() {
  701. return this.stream.hexDump(this.posStart(), this.posEnd(), true);
  702. };
  703. ASN12.decodeLength = function(stream) {
  704. var buf = stream.get();
  705. var len = buf & 127;
  706. if (len == buf) {
  707. return len;
  708. }
  709. if (len > 6) {
  710. throw new Error("Length over 48 bits not supported at position " + (stream.pos - 1));
  711. }
  712. if (len === 0) {
  713. return null;
  714. }
  715. buf = 0;
  716. for (var i = 0; i < len; ++i) {
  717. buf = buf * 256 + stream.get();
  718. }
  719. return buf;
  720. };
  721. ASN12.prototype.getHexStringValue = function() {
  722. var hexString = this.toHexString();
  723. var offset = this.header * 2;
  724. var length = this.length * 2;
  725. return hexString.substr(offset, length);
  726. };
  727. ASN12.decode = function(str) {
  728. var stream;
  729. if (!(str instanceof Stream)) {
  730. stream = new Stream(str, 0);
  731. } else {
  732. stream = str;
  733. }
  734. var streamStart = new Stream(stream);
  735. var tag = new ASN1Tag(stream);
  736. var len = ASN12.decodeLength(stream);
  737. var start = stream.pos;
  738. var header = start - streamStart.pos;
  739. var sub = null;
  740. var getSub = function() {
  741. var ret = [];
  742. if (len !== null) {
  743. var end = start + len;
  744. while (stream.pos < end) {
  745. ret[ret.length] = ASN12.decode(stream);
  746. }
  747. if (stream.pos != end) {
  748. throw new Error("Content size is not correct for container starting at offset " + start);
  749. }
  750. } else {
  751. try {
  752. for (; ; ) {
  753. var s = ASN12.decode(stream);
  754. if (s.tag.isEOC()) {
  755. break;
  756. }
  757. ret[ret.length] = s;
  758. }
  759. len = start - stream.pos;
  760. } catch (e) {
  761. throw new Error("Exception while decoding undefined length content: " + e);
  762. }
  763. }
  764. return ret;
  765. };
  766. if (tag.tagConstructed) {
  767. sub = getSub();
  768. } else if (tag.isUniversal() && (tag.tagNumber == 3 || tag.tagNumber == 4)) {
  769. try {
  770. if (tag.tagNumber == 3) {
  771. if (stream.get() != 0) {
  772. throw new Error("BIT STRINGs with unused bits cannot encapsulate.");
  773. }
  774. }
  775. sub = getSub();
  776. for (var i = 0; i < sub.length; ++i) {
  777. if (sub[i].tag.isEOC()) {
  778. throw new Error("EOC is not supposed to be actual content.");
  779. }
  780. }
  781. } catch (e) {
  782. sub = null;
  783. }
  784. }
  785. if (sub === null) {
  786. if (len === null) {
  787. throw new Error("We can't skip over an invalid tag with undefined length at offset " + start);
  788. }
  789. stream.pos = start + Math.abs(len);
  790. }
  791. return new ASN12(streamStart, header, len, tag, sub);
  792. };
  793. return ASN12;
  794. }()
  795. );
  796. var ASN1Tag = (
  797. /** @class */
  798. function() {
  799. function ASN1Tag2(stream) {
  800. var buf = stream.get();
  801. this.tagClass = buf >> 6;
  802. this.tagConstructed = (buf & 32) !== 0;
  803. this.tagNumber = buf & 31;
  804. if (this.tagNumber == 31) {
  805. var n = new Int10();
  806. do {
  807. buf = stream.get();
  808. n.mulAdd(128, buf & 127);
  809. } while (buf & 128);
  810. this.tagNumber = n.simplify();
  811. }
  812. }
  813. ASN1Tag2.prototype.isUniversal = function() {
  814. return this.tagClass === 0;
  815. };
  816. ASN1Tag2.prototype.isEOC = function() {
  817. return this.tagClass === 0 && this.tagNumber === 0;
  818. };
  819. return ASN1Tag2;
  820. }()
  821. );
  822. // ../../../../wpl/hjy/workApp/node_modules/jsencrypt/lib/lib/jsbn/jsbn.js
  823. var dbits;
  824. var canary = 244837814094590;
  825. var j_lm = (canary & 16777215) == 15715070;
  826. 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];
  827. var lplim = (1 << 26) / lowprimes[lowprimes.length - 1];
  828. var BigInteger = (
  829. /** @class */
  830. function() {
  831. function BigInteger2(a, b, c) {
  832. if (a != null) {
  833. if ("number" == typeof a) {
  834. this.fromNumber(a, b, c);
  835. } else if (b == null && "string" != typeof a) {
  836. this.fromString(a, 256);
  837. } else {
  838. this.fromString(a, b);
  839. }
  840. }
  841. }
  842. BigInteger2.prototype.toString = function(b) {
  843. if (this.s < 0) {
  844. return "-" + this.negate().toString(b);
  845. }
  846. var k;
  847. if (b == 16) {
  848. k = 4;
  849. } else if (b == 8) {
  850. k = 3;
  851. } else if (b == 2) {
  852. k = 1;
  853. } else if (b == 32) {
  854. k = 5;
  855. } else if (b == 4) {
  856. k = 2;
  857. } else {
  858. return this.toRadix(b);
  859. }
  860. var km = (1 << k) - 1;
  861. var d;
  862. var m = false;
  863. var r = "";
  864. var i = this.t;
  865. var p = this.DB - i * this.DB % k;
  866. if (i-- > 0) {
  867. if (p < this.DB && (d = this[i] >> p) > 0) {
  868. m = true;
  869. r = int2char(d);
  870. }
  871. while (i >= 0) {
  872. if (p < k) {
  873. d = (this[i] & (1 << p) - 1) << k - p;
  874. d |= this[--i] >> (p += this.DB - k);
  875. } else {
  876. d = this[i] >> (p -= k) & km;
  877. if (p <= 0) {
  878. p += this.DB;
  879. --i;
  880. }
  881. }
  882. if (d > 0) {
  883. m = true;
  884. }
  885. if (m) {
  886. r += int2char(d);
  887. }
  888. }
  889. }
  890. return m ? r : "0";
  891. };
  892. BigInteger2.prototype.negate = function() {
  893. var r = nbi();
  894. BigInteger2.ZERO.subTo(this, r);
  895. return r;
  896. };
  897. BigInteger2.prototype.abs = function() {
  898. return this.s < 0 ? this.negate() : this;
  899. };
  900. BigInteger2.prototype.compareTo = function(a) {
  901. var r = this.s - a.s;
  902. if (r != 0) {
  903. return r;
  904. }
  905. var i = this.t;
  906. r = i - a.t;
  907. if (r != 0) {
  908. return this.s < 0 ? -r : r;
  909. }
  910. while (--i >= 0) {
  911. if ((r = this[i] - a[i]) != 0) {
  912. return r;
  913. }
  914. }
  915. return 0;
  916. };
  917. BigInteger2.prototype.bitLength = function() {
  918. if (this.t <= 0) {
  919. return 0;
  920. }
  921. return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ this.s & this.DM);
  922. };
  923. BigInteger2.prototype.mod = function(a) {
  924. var r = nbi();
  925. this.abs().divRemTo(a, null, r);
  926. if (this.s < 0 && r.compareTo(BigInteger2.ZERO) > 0) {
  927. a.subTo(r, r);
  928. }
  929. return r;
  930. };
  931. BigInteger2.prototype.modPowInt = function(e, m) {
  932. var z;
  933. if (e < 256 || m.isEven()) {
  934. z = new Classic(m);
  935. } else {
  936. z = new Montgomery(m);
  937. }
  938. return this.exp(e, z);
  939. };
  940. BigInteger2.prototype.clone = function() {
  941. var r = nbi();
  942. this.copyTo(r);
  943. return r;
  944. };
  945. BigInteger2.prototype.intValue = function() {
  946. if (this.s < 0) {
  947. if (this.t == 1) {
  948. return this[0] - this.DV;
  949. } else if (this.t == 0) {
  950. return -1;
  951. }
  952. } else if (this.t == 1) {
  953. return this[0];
  954. } else if (this.t == 0) {
  955. return 0;
  956. }
  957. return (this[1] & (1 << 32 - this.DB) - 1) << this.DB | this[0];
  958. };
  959. BigInteger2.prototype.byteValue = function() {
  960. return this.t == 0 ? this.s : this[0] << 24 >> 24;
  961. };
  962. BigInteger2.prototype.shortValue = function() {
  963. return this.t == 0 ? this.s : this[0] << 16 >> 16;
  964. };
  965. BigInteger2.prototype.signum = function() {
  966. if (this.s < 0) {
  967. return -1;
  968. } else if (this.t <= 0 || this.t == 1 && this[0] <= 0) {
  969. return 0;
  970. } else {
  971. return 1;
  972. }
  973. };
  974. BigInteger2.prototype.toByteArray = function() {
  975. var i = this.t;
  976. var r = [];
  977. r[0] = this.s;
  978. var p = this.DB - i * this.DB % 8;
  979. var d;
  980. var k = 0;
  981. if (i-- > 0) {
  982. if (p < this.DB && (d = this[i] >> p) != (this.s & this.DM) >> p) {
  983. r[k++] = d | this.s << this.DB - p;
  984. }
  985. while (i >= 0) {
  986. if (p < 8) {
  987. d = (this[i] & (1 << p) - 1) << 8 - p;
  988. d |= this[--i] >> (p += this.DB - 8);
  989. } else {
  990. d = this[i] >> (p -= 8) & 255;
  991. if (p <= 0) {
  992. p += this.DB;
  993. --i;
  994. }
  995. }
  996. if ((d & 128) != 0) {
  997. d |= -256;
  998. }
  999. if (k == 0 && (this.s & 128) != (d & 128)) {
  1000. ++k;
  1001. }
  1002. if (k > 0 || d != this.s) {
  1003. r[k++] = d;
  1004. }
  1005. }
  1006. }
  1007. return r;
  1008. };
  1009. BigInteger2.prototype.equals = function(a) {
  1010. return this.compareTo(a) == 0;
  1011. };
  1012. BigInteger2.prototype.min = function(a) {
  1013. return this.compareTo(a) < 0 ? this : a;
  1014. };
  1015. BigInteger2.prototype.max = function(a) {
  1016. return this.compareTo(a) > 0 ? this : a;
  1017. };
  1018. BigInteger2.prototype.and = function(a) {
  1019. var r = nbi();
  1020. this.bitwiseTo(a, op_and, r);
  1021. return r;
  1022. };
  1023. BigInteger2.prototype.or = function(a) {
  1024. var r = nbi();
  1025. this.bitwiseTo(a, op_or, r);
  1026. return r;
  1027. };
  1028. BigInteger2.prototype.xor = function(a) {
  1029. var r = nbi();
  1030. this.bitwiseTo(a, op_xor, r);
  1031. return r;
  1032. };
  1033. BigInteger2.prototype.andNot = function(a) {
  1034. var r = nbi();
  1035. this.bitwiseTo(a, op_andnot, r);
  1036. return r;
  1037. };
  1038. BigInteger2.prototype.not = function() {
  1039. var r = nbi();
  1040. for (var i = 0; i < this.t; ++i) {
  1041. r[i] = this.DM & ~this[i];
  1042. }
  1043. r.t = this.t;
  1044. r.s = ~this.s;
  1045. return r;
  1046. };
  1047. BigInteger2.prototype.shiftLeft = function(n) {
  1048. var r = nbi();
  1049. if (n < 0) {
  1050. this.rShiftTo(-n, r);
  1051. } else {
  1052. this.lShiftTo(n, r);
  1053. }
  1054. return r;
  1055. };
  1056. BigInteger2.prototype.shiftRight = function(n) {
  1057. var r = nbi();
  1058. if (n < 0) {
  1059. this.lShiftTo(-n, r);
  1060. } else {
  1061. this.rShiftTo(n, r);
  1062. }
  1063. return r;
  1064. };
  1065. BigInteger2.prototype.getLowestSetBit = function() {
  1066. for (var i = 0; i < this.t; ++i) {
  1067. if (this[i] != 0) {
  1068. return i * this.DB + lbit(this[i]);
  1069. }
  1070. }
  1071. if (this.s < 0) {
  1072. return this.t * this.DB;
  1073. }
  1074. return -1;
  1075. };
  1076. BigInteger2.prototype.bitCount = function() {
  1077. var r = 0;
  1078. var x = this.s & this.DM;
  1079. for (var i = 0; i < this.t; ++i) {
  1080. r += cbit(this[i] ^ x);
  1081. }
  1082. return r;
  1083. };
  1084. BigInteger2.prototype.testBit = function(n) {
  1085. var j = Math.floor(n / this.DB);
  1086. if (j >= this.t) {
  1087. return this.s != 0;
  1088. }
  1089. return (this[j] & 1 << n % this.DB) != 0;
  1090. };
  1091. BigInteger2.prototype.setBit = function(n) {
  1092. return this.changeBit(n, op_or);
  1093. };
  1094. BigInteger2.prototype.clearBit = function(n) {
  1095. return this.changeBit(n, op_andnot);
  1096. };
  1097. BigInteger2.prototype.flipBit = function(n) {
  1098. return this.changeBit(n, op_xor);
  1099. };
  1100. BigInteger2.prototype.add = function(a) {
  1101. var r = nbi();
  1102. this.addTo(a, r);
  1103. return r;
  1104. };
  1105. BigInteger2.prototype.subtract = function(a) {
  1106. var r = nbi();
  1107. this.subTo(a, r);
  1108. return r;
  1109. };
  1110. BigInteger2.prototype.multiply = function(a) {
  1111. var r = nbi();
  1112. this.multiplyTo(a, r);
  1113. return r;
  1114. };
  1115. BigInteger2.prototype.divide = function(a) {
  1116. var r = nbi();
  1117. this.divRemTo(a, r, null);
  1118. return r;
  1119. };
  1120. BigInteger2.prototype.remainder = function(a) {
  1121. var r = nbi();
  1122. this.divRemTo(a, null, r);
  1123. return r;
  1124. };
  1125. BigInteger2.prototype.divideAndRemainder = function(a) {
  1126. var q = nbi();
  1127. var r = nbi();
  1128. this.divRemTo(a, q, r);
  1129. return [q, r];
  1130. };
  1131. BigInteger2.prototype.modPow = function(e, m) {
  1132. var i = e.bitLength();
  1133. var k;
  1134. var r = nbv(1);
  1135. var z;
  1136. if (i <= 0) {
  1137. return r;
  1138. } else if (i < 18) {
  1139. k = 1;
  1140. } else if (i < 48) {
  1141. k = 3;
  1142. } else if (i < 144) {
  1143. k = 4;
  1144. } else if (i < 768) {
  1145. k = 5;
  1146. } else {
  1147. k = 6;
  1148. }
  1149. if (i < 8) {
  1150. z = new Classic(m);
  1151. } else if (m.isEven()) {
  1152. z = new Barrett(m);
  1153. } else {
  1154. z = new Montgomery(m);
  1155. }
  1156. var g = [];
  1157. var n = 3;
  1158. var k1 = k - 1;
  1159. var km = (1 << k) - 1;
  1160. g[1] = z.convert(this);
  1161. if (k > 1) {
  1162. var g2 = nbi();
  1163. z.sqrTo(g[1], g2);
  1164. while (n <= km) {
  1165. g[n] = nbi();
  1166. z.mulTo(g2, g[n - 2], g[n]);
  1167. n += 2;
  1168. }
  1169. }
  1170. var j = e.t - 1;
  1171. var w;
  1172. var is1 = true;
  1173. var r2 = nbi();
  1174. var t;
  1175. i = nbits(e[j]) - 1;
  1176. while (j >= 0) {
  1177. if (i >= k1) {
  1178. w = e[j] >> i - k1 & km;
  1179. } else {
  1180. w = (e[j] & (1 << i + 1) - 1) << k1 - i;
  1181. if (j > 0) {
  1182. w |= e[j - 1] >> this.DB + i - k1;
  1183. }
  1184. }
  1185. n = k;
  1186. while ((w & 1) == 0) {
  1187. w >>= 1;
  1188. --n;
  1189. }
  1190. if ((i -= n) < 0) {
  1191. i += this.DB;
  1192. --j;
  1193. }
  1194. if (is1) {
  1195. g[w].copyTo(r);
  1196. is1 = false;
  1197. } else {
  1198. while (n > 1) {
  1199. z.sqrTo(r, r2);
  1200. z.sqrTo(r2, r);
  1201. n -= 2;
  1202. }
  1203. if (n > 0) {
  1204. z.sqrTo(r, r2);
  1205. } else {
  1206. t = r;
  1207. r = r2;
  1208. r2 = t;
  1209. }
  1210. z.mulTo(r2, g[w], r);
  1211. }
  1212. while (j >= 0 && (e[j] & 1 << i) == 0) {
  1213. z.sqrTo(r, r2);
  1214. t = r;
  1215. r = r2;
  1216. r2 = t;
  1217. if (--i < 0) {
  1218. i = this.DB - 1;
  1219. --j;
  1220. }
  1221. }
  1222. }
  1223. return z.revert(r);
  1224. };
  1225. BigInteger2.prototype.modInverse = function(m) {
  1226. var ac = m.isEven();
  1227. if (this.isEven() && ac || m.signum() == 0) {
  1228. return BigInteger2.ZERO;
  1229. }
  1230. var u = m.clone();
  1231. var v = this.clone();
  1232. var a = nbv(1);
  1233. var b = nbv(0);
  1234. var c = nbv(0);
  1235. var d = nbv(1);
  1236. while (u.signum() != 0) {
  1237. while (u.isEven()) {
  1238. u.rShiftTo(1, u);
  1239. if (ac) {
  1240. if (!a.isEven() || !b.isEven()) {
  1241. a.addTo(this, a);
  1242. b.subTo(m, b);
  1243. }
  1244. a.rShiftTo(1, a);
  1245. } else if (!b.isEven()) {
  1246. b.subTo(m, b);
  1247. }
  1248. b.rShiftTo(1, b);
  1249. }
  1250. while (v.isEven()) {
  1251. v.rShiftTo(1, v);
  1252. if (ac) {
  1253. if (!c.isEven() || !d.isEven()) {
  1254. c.addTo(this, c);
  1255. d.subTo(m, d);
  1256. }
  1257. c.rShiftTo(1, c);
  1258. } else if (!d.isEven()) {
  1259. d.subTo(m, d);
  1260. }
  1261. d.rShiftTo(1, d);
  1262. }
  1263. if (u.compareTo(v) >= 0) {
  1264. u.subTo(v, u);
  1265. if (ac) {
  1266. a.subTo(c, a);
  1267. }
  1268. b.subTo(d, b);
  1269. } else {
  1270. v.subTo(u, v);
  1271. if (ac) {
  1272. c.subTo(a, c);
  1273. }
  1274. d.subTo(b, d);
  1275. }
  1276. }
  1277. if (v.compareTo(BigInteger2.ONE) != 0) {
  1278. return BigInteger2.ZERO;
  1279. }
  1280. if (d.compareTo(m) >= 0) {
  1281. return d.subtract(m);
  1282. }
  1283. if (d.signum() < 0) {
  1284. d.addTo(m, d);
  1285. } else {
  1286. return d;
  1287. }
  1288. if (d.signum() < 0) {
  1289. return d.add(m);
  1290. } else {
  1291. return d;
  1292. }
  1293. };
  1294. BigInteger2.prototype.pow = function(e) {
  1295. return this.exp(e, new NullExp());
  1296. };
  1297. BigInteger2.prototype.gcd = function(a) {
  1298. var x = this.s < 0 ? this.negate() : this.clone();
  1299. var y = a.s < 0 ? a.negate() : a.clone();
  1300. if (x.compareTo(y) < 0) {
  1301. var t = x;
  1302. x = y;
  1303. y = t;
  1304. }
  1305. var i = x.getLowestSetBit();
  1306. var g = y.getLowestSetBit();
  1307. if (g < 0) {
  1308. return x;
  1309. }
  1310. if (i < g) {
  1311. g = i;
  1312. }
  1313. if (g > 0) {
  1314. x.rShiftTo(g, x);
  1315. y.rShiftTo(g, y);
  1316. }
  1317. while (x.signum() > 0) {
  1318. if ((i = x.getLowestSetBit()) > 0) {
  1319. x.rShiftTo(i, x);
  1320. }
  1321. if ((i = y.getLowestSetBit()) > 0) {
  1322. y.rShiftTo(i, y);
  1323. }
  1324. if (x.compareTo(y) >= 0) {
  1325. x.subTo(y, x);
  1326. x.rShiftTo(1, x);
  1327. } else {
  1328. y.subTo(x, y);
  1329. y.rShiftTo(1, y);
  1330. }
  1331. }
  1332. if (g > 0) {
  1333. y.lShiftTo(g, y);
  1334. }
  1335. return y;
  1336. };
  1337. BigInteger2.prototype.isProbablePrime = function(t) {
  1338. var i;
  1339. var x = this.abs();
  1340. if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) {
  1341. for (i = 0; i < lowprimes.length; ++i) {
  1342. if (x[0] == lowprimes[i]) {
  1343. return true;
  1344. }
  1345. }
  1346. return false;
  1347. }
  1348. if (x.isEven()) {
  1349. return false;
  1350. }
  1351. i = 1;
  1352. while (i < lowprimes.length) {
  1353. var m = lowprimes[i];
  1354. var j = i + 1;
  1355. while (j < lowprimes.length && m < lplim) {
  1356. m *= lowprimes[j++];
  1357. }
  1358. m = x.modInt(m);
  1359. while (i < j) {
  1360. if (m % lowprimes[i++] == 0) {
  1361. return false;
  1362. }
  1363. }
  1364. }
  1365. return x.millerRabin(t);
  1366. };
  1367. BigInteger2.prototype.copyTo = function(r) {
  1368. for (var i = this.t - 1; i >= 0; --i) {
  1369. r[i] = this[i];
  1370. }
  1371. r.t = this.t;
  1372. r.s = this.s;
  1373. };
  1374. BigInteger2.prototype.fromInt = function(x) {
  1375. this.t = 1;
  1376. this.s = x < 0 ? -1 : 0;
  1377. if (x > 0) {
  1378. this[0] = x;
  1379. } else if (x < -1) {
  1380. this[0] = x + this.DV;
  1381. } else {
  1382. this.t = 0;
  1383. }
  1384. };
  1385. BigInteger2.prototype.fromString = function(s, b) {
  1386. var k;
  1387. if (b == 16) {
  1388. k = 4;
  1389. } else if (b == 8) {
  1390. k = 3;
  1391. } else if (b == 256) {
  1392. k = 8;
  1393. } else if (b == 2) {
  1394. k = 1;
  1395. } else if (b == 32) {
  1396. k = 5;
  1397. } else if (b == 4) {
  1398. k = 2;
  1399. } else {
  1400. this.fromRadix(s, b);
  1401. return;
  1402. }
  1403. this.t = 0;
  1404. this.s = 0;
  1405. var i = s.length;
  1406. var mi = false;
  1407. var sh = 0;
  1408. while (--i >= 0) {
  1409. var x = k == 8 ? +s[i] & 255 : intAt(s, i);
  1410. if (x < 0) {
  1411. if (s.charAt(i) == "-") {
  1412. mi = true;
  1413. }
  1414. continue;
  1415. }
  1416. mi = false;
  1417. if (sh == 0) {
  1418. this[this.t++] = x;
  1419. } else if (sh + k > this.DB) {
  1420. this[this.t - 1] |= (x & (1 << this.DB - sh) - 1) << sh;
  1421. this[this.t++] = x >> this.DB - sh;
  1422. } else {
  1423. this[this.t - 1] |= x << sh;
  1424. }
  1425. sh += k;
  1426. if (sh >= this.DB) {
  1427. sh -= this.DB;
  1428. }
  1429. }
  1430. if (k == 8 && (+s[0] & 128) != 0) {
  1431. this.s = -1;
  1432. if (sh > 0) {
  1433. this[this.t - 1] |= (1 << this.DB - sh) - 1 << sh;
  1434. }
  1435. }
  1436. this.clamp();
  1437. if (mi) {
  1438. BigInteger2.ZERO.subTo(this, this);
  1439. }
  1440. };
  1441. BigInteger2.prototype.clamp = function() {
  1442. var c = this.s & this.DM;
  1443. while (this.t > 0 && this[this.t - 1] == c) {
  1444. --this.t;
  1445. }
  1446. };
  1447. BigInteger2.prototype.dlShiftTo = function(n, r) {
  1448. var i;
  1449. for (i = this.t - 1; i >= 0; --i) {
  1450. r[i + n] = this[i];
  1451. }
  1452. for (i = n - 1; i >= 0; --i) {
  1453. r[i] = 0;
  1454. }
  1455. r.t = this.t + n;
  1456. r.s = this.s;
  1457. };
  1458. BigInteger2.prototype.drShiftTo = function(n, r) {
  1459. for (var i = n; i < this.t; ++i) {
  1460. r[i - n] = this[i];
  1461. }
  1462. r.t = Math.max(this.t - n, 0);
  1463. r.s = this.s;
  1464. };
  1465. BigInteger2.prototype.lShiftTo = function(n, r) {
  1466. var bs = n % this.DB;
  1467. var cbs = this.DB - bs;
  1468. var bm = (1 << cbs) - 1;
  1469. var ds = Math.floor(n / this.DB);
  1470. var c = this.s << bs & this.DM;
  1471. for (var i = this.t - 1; i >= 0; --i) {
  1472. r[i + ds + 1] = this[i] >> cbs | c;
  1473. c = (this[i] & bm) << bs;
  1474. }
  1475. for (var i = ds - 1; i >= 0; --i) {
  1476. r[i] = 0;
  1477. }
  1478. r[ds] = c;
  1479. r.t = this.t + ds + 1;
  1480. r.s = this.s;
  1481. r.clamp();
  1482. };
  1483. BigInteger2.prototype.rShiftTo = function(n, r) {
  1484. r.s = this.s;
  1485. var ds = Math.floor(n / this.DB);
  1486. if (ds >= this.t) {
  1487. r.t = 0;
  1488. return;
  1489. }
  1490. var bs = n % this.DB;
  1491. var cbs = this.DB - bs;
  1492. var bm = (1 << bs) - 1;
  1493. r[0] = this[ds] >> bs;
  1494. for (var i = ds + 1; i < this.t; ++i) {
  1495. r[i - ds - 1] |= (this[i] & bm) << cbs;
  1496. r[i - ds] = this[i] >> bs;
  1497. }
  1498. if (bs > 0) {
  1499. r[this.t - ds - 1] |= (this.s & bm) << cbs;
  1500. }
  1501. r.t = this.t - ds;
  1502. r.clamp();
  1503. };
  1504. BigInteger2.prototype.subTo = function(a, r) {
  1505. var i = 0;
  1506. var c = 0;
  1507. var m = Math.min(a.t, this.t);
  1508. while (i < m) {
  1509. c += this[i] - a[i];
  1510. r[i++] = c & this.DM;
  1511. c >>= this.DB;
  1512. }
  1513. if (a.t < this.t) {
  1514. c -= a.s;
  1515. while (i < this.t) {
  1516. c += this[i];
  1517. r[i++] = c & this.DM;
  1518. c >>= this.DB;
  1519. }
  1520. c += this.s;
  1521. } else {
  1522. c += this.s;
  1523. while (i < a.t) {
  1524. c -= a[i];
  1525. r[i++] = c & this.DM;
  1526. c >>= this.DB;
  1527. }
  1528. c -= a.s;
  1529. }
  1530. r.s = c < 0 ? -1 : 0;
  1531. if (c < -1) {
  1532. r[i++] = this.DV + c;
  1533. } else if (c > 0) {
  1534. r[i++] = c;
  1535. }
  1536. r.t = i;
  1537. r.clamp();
  1538. };
  1539. BigInteger2.prototype.multiplyTo = function(a, r) {
  1540. var x = this.abs();
  1541. var y = a.abs();
  1542. var i = x.t;
  1543. r.t = i + y.t;
  1544. while (--i >= 0) {
  1545. r[i] = 0;
  1546. }
  1547. for (i = 0; i < y.t; ++i) {
  1548. r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);
  1549. }
  1550. r.s = 0;
  1551. r.clamp();
  1552. if (this.s != a.s) {
  1553. BigInteger2.ZERO.subTo(r, r);
  1554. }
  1555. };
  1556. BigInteger2.prototype.squareTo = function(r) {
  1557. var x = this.abs();
  1558. var i = r.t = 2 * x.t;
  1559. while (--i >= 0) {
  1560. r[i] = 0;
  1561. }
  1562. for (i = 0; i < x.t - 1; ++i) {
  1563. var c = x.am(i, x[i], r, 2 * i, 0, 1);
  1564. if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {
  1565. r[i + x.t] -= x.DV;
  1566. r[i + x.t + 1] = 1;
  1567. }
  1568. }
  1569. if (r.t > 0) {
  1570. r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);
  1571. }
  1572. r.s = 0;
  1573. r.clamp();
  1574. };
  1575. BigInteger2.prototype.divRemTo = function(m, q, r) {
  1576. var pm = m.abs();
  1577. if (pm.t <= 0) {
  1578. return;
  1579. }
  1580. var pt = this.abs();
  1581. if (pt.t < pm.t) {
  1582. if (q != null) {
  1583. q.fromInt(0);
  1584. }
  1585. if (r != null) {
  1586. this.copyTo(r);
  1587. }
  1588. return;
  1589. }
  1590. if (r == null) {
  1591. r = nbi();
  1592. }
  1593. var y = nbi();
  1594. var ts = this.s;
  1595. var ms = m.s;
  1596. var nsh = this.DB - nbits(pm[pm.t - 1]);
  1597. if (nsh > 0) {
  1598. pm.lShiftTo(nsh, y);
  1599. pt.lShiftTo(nsh, r);
  1600. } else {
  1601. pm.copyTo(y);
  1602. pt.copyTo(r);
  1603. }
  1604. var ys = y.t;
  1605. var y0 = y[ys - 1];
  1606. if (y0 == 0) {
  1607. return;
  1608. }
  1609. var yt = y0 * (1 << this.F1) + (ys > 1 ? y[ys - 2] >> this.F2 : 0);
  1610. var d1 = this.FV / yt;
  1611. var d2 = (1 << this.F1) / yt;
  1612. var e = 1 << this.F2;
  1613. var i = r.t;
  1614. var j = i - ys;
  1615. var t = q == null ? nbi() : q;
  1616. y.dlShiftTo(j, t);
  1617. if (r.compareTo(t) >= 0) {
  1618. r[r.t++] = 1;
  1619. r.subTo(t, r);
  1620. }
  1621. BigInteger2.ONE.dlShiftTo(ys, t);
  1622. t.subTo(y, y);
  1623. while (y.t < ys) {
  1624. y[y.t++] = 0;
  1625. }
  1626. while (--j >= 0) {
  1627. var qd = r[--i] == y0 ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);
  1628. if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) {
  1629. y.dlShiftTo(j, t);
  1630. r.subTo(t, r);
  1631. while (r[i] < --qd) {
  1632. r.subTo(t, r);
  1633. }
  1634. }
  1635. }
  1636. if (q != null) {
  1637. r.drShiftTo(ys, q);
  1638. if (ts != ms) {
  1639. BigInteger2.ZERO.subTo(q, q);
  1640. }
  1641. }
  1642. r.t = ys;
  1643. r.clamp();
  1644. if (nsh > 0) {
  1645. r.rShiftTo(nsh, r);
  1646. }
  1647. if (ts < 0) {
  1648. BigInteger2.ZERO.subTo(r, r);
  1649. }
  1650. };
  1651. BigInteger2.prototype.invDigit = function() {
  1652. if (this.t < 1) {
  1653. return 0;
  1654. }
  1655. var x = this[0];
  1656. if ((x & 1) == 0) {
  1657. return 0;
  1658. }
  1659. var y = x & 3;
  1660. y = y * (2 - (x & 15) * y) & 15;
  1661. y = y * (2 - (x & 255) * y) & 255;
  1662. y = y * (2 - ((x & 65535) * y & 65535)) & 65535;
  1663. y = y * (2 - x * y % this.DV) % this.DV;
  1664. return y > 0 ? this.DV - y : -y;
  1665. };
  1666. BigInteger2.prototype.isEven = function() {
  1667. return (this.t > 0 ? this[0] & 1 : this.s) == 0;
  1668. };
  1669. BigInteger2.prototype.exp = function(e, z) {
  1670. if (e > 4294967295 || e < 1) {
  1671. return BigInteger2.ONE;
  1672. }
  1673. var r = nbi();
  1674. var r2 = nbi();
  1675. var g = z.convert(this);
  1676. var i = nbits(e) - 1;
  1677. g.copyTo(r);
  1678. while (--i >= 0) {
  1679. z.sqrTo(r, r2);
  1680. if ((e & 1 << i) > 0) {
  1681. z.mulTo(r2, g, r);
  1682. } else {
  1683. var t = r;
  1684. r = r2;
  1685. r2 = t;
  1686. }
  1687. }
  1688. return z.revert(r);
  1689. };
  1690. BigInteger2.prototype.chunkSize = function(r) {
  1691. return Math.floor(Math.LN2 * this.DB / Math.log(r));
  1692. };
  1693. BigInteger2.prototype.toRadix = function(b) {
  1694. if (b == null) {
  1695. b = 10;
  1696. }
  1697. if (this.signum() == 0 || b < 2 || b > 36) {
  1698. return "0";
  1699. }
  1700. var cs = this.chunkSize(b);
  1701. var a = Math.pow(b, cs);
  1702. var d = nbv(a);
  1703. var y = nbi();
  1704. var z = nbi();
  1705. var r = "";
  1706. this.divRemTo(d, y, z);
  1707. while (y.signum() > 0) {
  1708. r = (a + z.intValue()).toString(b).substr(1) + r;
  1709. y.divRemTo(d, y, z);
  1710. }
  1711. return z.intValue().toString(b) + r;
  1712. };
  1713. BigInteger2.prototype.fromRadix = function(s, b) {
  1714. this.fromInt(0);
  1715. if (b == null) {
  1716. b = 10;
  1717. }
  1718. var cs = this.chunkSize(b);
  1719. var d = Math.pow(b, cs);
  1720. var mi = false;
  1721. var j = 0;
  1722. var w = 0;
  1723. for (var i = 0; i < s.length; ++i) {
  1724. var x = intAt(s, i);
  1725. if (x < 0) {
  1726. if (s.charAt(i) == "-" && this.signum() == 0) {
  1727. mi = true;
  1728. }
  1729. continue;
  1730. }
  1731. w = b * w + x;
  1732. if (++j >= cs) {
  1733. this.dMultiply(d);
  1734. this.dAddOffset(w, 0);
  1735. j = 0;
  1736. w = 0;
  1737. }
  1738. }
  1739. if (j > 0) {
  1740. this.dMultiply(Math.pow(b, j));
  1741. this.dAddOffset(w, 0);
  1742. }
  1743. if (mi) {
  1744. BigInteger2.ZERO.subTo(this, this);
  1745. }
  1746. };
  1747. BigInteger2.prototype.fromNumber = function(a, b, c) {
  1748. if ("number" == typeof b) {
  1749. if (a < 2) {
  1750. this.fromInt(1);
  1751. } else {
  1752. this.fromNumber(a, c);
  1753. if (!this.testBit(a - 1)) {
  1754. this.bitwiseTo(BigInteger2.ONE.shiftLeft(a - 1), op_or, this);
  1755. }
  1756. if (this.isEven()) {
  1757. this.dAddOffset(1, 0);
  1758. }
  1759. while (!this.isProbablePrime(b)) {
  1760. this.dAddOffset(2, 0);
  1761. if (this.bitLength() > a) {
  1762. this.subTo(BigInteger2.ONE.shiftLeft(a - 1), this);
  1763. }
  1764. }
  1765. }
  1766. } else {
  1767. var x = [];
  1768. var t = a & 7;
  1769. x.length = (a >> 3) + 1;
  1770. b.nextBytes(x);
  1771. if (t > 0) {
  1772. x[0] &= (1 << t) - 1;
  1773. } else {
  1774. x[0] = 0;
  1775. }
  1776. this.fromString(x, 256);
  1777. }
  1778. };
  1779. BigInteger2.prototype.bitwiseTo = function(a, op, r) {
  1780. var i;
  1781. var f;
  1782. var m = Math.min(a.t, this.t);
  1783. for (i = 0; i < m; ++i) {
  1784. r[i] = op(this[i], a[i]);
  1785. }
  1786. if (a.t < this.t) {
  1787. f = a.s & this.DM;
  1788. for (i = m; i < this.t; ++i) {
  1789. r[i] = op(this[i], f);
  1790. }
  1791. r.t = this.t;
  1792. } else {
  1793. f = this.s & this.DM;
  1794. for (i = m; i < a.t; ++i) {
  1795. r[i] = op(f, a[i]);
  1796. }
  1797. r.t = a.t;
  1798. }
  1799. r.s = op(this.s, a.s);
  1800. r.clamp();
  1801. };
  1802. BigInteger2.prototype.changeBit = function(n, op) {
  1803. var r = BigInteger2.ONE.shiftLeft(n);
  1804. this.bitwiseTo(r, op, r);
  1805. return r;
  1806. };
  1807. BigInteger2.prototype.addTo = function(a, r) {
  1808. var i = 0;
  1809. var c = 0;
  1810. var m = Math.min(a.t, this.t);
  1811. while (i < m) {
  1812. c += this[i] + a[i];
  1813. r[i++] = c & this.DM;
  1814. c >>= this.DB;
  1815. }
  1816. if (a.t < this.t) {
  1817. c += a.s;
  1818. while (i < this.t) {
  1819. c += this[i];
  1820. r[i++] = c & this.DM;
  1821. c >>= this.DB;
  1822. }
  1823. c += this.s;
  1824. } else {
  1825. c += this.s;
  1826. while (i < a.t) {
  1827. c += a[i];
  1828. r[i++] = c & this.DM;
  1829. c >>= this.DB;
  1830. }
  1831. c += a.s;
  1832. }
  1833. r.s = c < 0 ? -1 : 0;
  1834. if (c > 0) {
  1835. r[i++] = c;
  1836. } else if (c < -1) {
  1837. r[i++] = this.DV + c;
  1838. }
  1839. r.t = i;
  1840. r.clamp();
  1841. };
  1842. BigInteger2.prototype.dMultiply = function(n) {
  1843. this[this.t] = this.am(0, n - 1, this, 0, 0, this.t);
  1844. ++this.t;
  1845. this.clamp();
  1846. };
  1847. BigInteger2.prototype.dAddOffset = function(n, w) {
  1848. if (n == 0) {
  1849. return;
  1850. }
  1851. while (this.t <= w) {
  1852. this[this.t++] = 0;
  1853. }
  1854. this[w] += n;
  1855. while (this[w] >= this.DV) {
  1856. this[w] -= this.DV;
  1857. if (++w >= this.t) {
  1858. this[this.t++] = 0;
  1859. }
  1860. ++this[w];
  1861. }
  1862. };
  1863. BigInteger2.prototype.multiplyLowerTo = function(a, n, r) {
  1864. var i = Math.min(this.t + a.t, n);
  1865. r.s = 0;
  1866. r.t = i;
  1867. while (i > 0) {
  1868. r[--i] = 0;
  1869. }
  1870. for (var j = r.t - this.t; i < j; ++i) {
  1871. r[i + this.t] = this.am(0, a[i], r, i, 0, this.t);
  1872. }
  1873. for (var j = Math.min(a.t, n); i < j; ++i) {
  1874. this.am(0, a[i], r, i, 0, n - i);
  1875. }
  1876. r.clamp();
  1877. };
  1878. BigInteger2.prototype.multiplyUpperTo = function(a, n, r) {
  1879. --n;
  1880. var i = r.t = this.t + a.t - n;
  1881. r.s = 0;
  1882. while (--i >= 0) {
  1883. r[i] = 0;
  1884. }
  1885. for (i = Math.max(n - this.t, 0); i < a.t; ++i) {
  1886. r[this.t + i - n] = this.am(n - i, a[i], r, 0, 0, this.t + i - n);
  1887. }
  1888. r.clamp();
  1889. r.drShiftTo(1, r);
  1890. };
  1891. BigInteger2.prototype.modInt = function(n) {
  1892. if (n <= 0) {
  1893. return 0;
  1894. }
  1895. var d = this.DV % n;
  1896. var r = this.s < 0 ? n - 1 : 0;
  1897. if (this.t > 0) {
  1898. if (d == 0) {
  1899. r = this[0] % n;
  1900. } else {
  1901. for (var i = this.t - 1; i >= 0; --i) {
  1902. r = (d * r + this[i]) % n;
  1903. }
  1904. }
  1905. }
  1906. return r;
  1907. };
  1908. BigInteger2.prototype.millerRabin = function(t) {
  1909. var n1 = this.subtract(BigInteger2.ONE);
  1910. var k = n1.getLowestSetBit();
  1911. if (k <= 0) {
  1912. return false;
  1913. }
  1914. var r = n1.shiftRight(k);
  1915. t = t + 1 >> 1;
  1916. if (t > lowprimes.length) {
  1917. t = lowprimes.length;
  1918. }
  1919. var a = nbi();
  1920. for (var i = 0; i < t; ++i) {
  1921. a.fromInt(lowprimes[Math.floor(Math.random() * lowprimes.length)]);
  1922. var y = a.modPow(r, this);
  1923. if (y.compareTo(BigInteger2.ONE) != 0 && y.compareTo(n1) != 0) {
  1924. var j = 1;
  1925. while (j++ < k && y.compareTo(n1) != 0) {
  1926. y = y.modPowInt(2, this);
  1927. if (y.compareTo(BigInteger2.ONE) == 0) {
  1928. return false;
  1929. }
  1930. }
  1931. if (y.compareTo(n1) != 0) {
  1932. return false;
  1933. }
  1934. }
  1935. }
  1936. return true;
  1937. };
  1938. BigInteger2.prototype.square = function() {
  1939. var r = nbi();
  1940. this.squareTo(r);
  1941. return r;
  1942. };
  1943. BigInteger2.prototype.gcda = function(a, callback) {
  1944. var x = this.s < 0 ? this.negate() : this.clone();
  1945. var y = a.s < 0 ? a.negate() : a.clone();
  1946. if (x.compareTo(y) < 0) {
  1947. var t = x;
  1948. x = y;
  1949. y = t;
  1950. }
  1951. var i = x.getLowestSetBit();
  1952. var g = y.getLowestSetBit();
  1953. if (g < 0) {
  1954. callback(x);
  1955. return;
  1956. }
  1957. if (i < g) {
  1958. g = i;
  1959. }
  1960. if (g > 0) {
  1961. x.rShiftTo(g, x);
  1962. y.rShiftTo(g, y);
  1963. }
  1964. var gcda1 = function() {
  1965. if ((i = x.getLowestSetBit()) > 0) {
  1966. x.rShiftTo(i, x);
  1967. }
  1968. if ((i = y.getLowestSetBit()) > 0) {
  1969. y.rShiftTo(i, y);
  1970. }
  1971. if (x.compareTo(y) >= 0) {
  1972. x.subTo(y, x);
  1973. x.rShiftTo(1, x);
  1974. } else {
  1975. y.subTo(x, y);
  1976. y.rShiftTo(1, y);
  1977. }
  1978. if (!(x.signum() > 0)) {
  1979. if (g > 0) {
  1980. y.lShiftTo(g, y);
  1981. }
  1982. setTimeout(function() {
  1983. callback(y);
  1984. }, 0);
  1985. } else {
  1986. setTimeout(gcda1, 0);
  1987. }
  1988. };
  1989. setTimeout(gcda1, 10);
  1990. };
  1991. BigInteger2.prototype.fromNumberAsync = function(a, b, c, callback) {
  1992. if ("number" == typeof b) {
  1993. if (a < 2) {
  1994. this.fromInt(1);
  1995. } else {
  1996. this.fromNumber(a, c);
  1997. if (!this.testBit(a - 1)) {
  1998. this.bitwiseTo(BigInteger2.ONE.shiftLeft(a - 1), op_or, this);
  1999. }
  2000. if (this.isEven()) {
  2001. this.dAddOffset(1, 0);
  2002. }
  2003. var bnp_1 = this;
  2004. var bnpfn1_1 = function() {
  2005. bnp_1.dAddOffset(2, 0);
  2006. if (bnp_1.bitLength() > a) {
  2007. bnp_1.subTo(BigInteger2.ONE.shiftLeft(a - 1), bnp_1);
  2008. }
  2009. if (bnp_1.isProbablePrime(b)) {
  2010. setTimeout(function() {
  2011. callback();
  2012. }, 0);
  2013. } else {
  2014. setTimeout(bnpfn1_1, 0);
  2015. }
  2016. };
  2017. setTimeout(bnpfn1_1, 0);
  2018. }
  2019. } else {
  2020. var x = [];
  2021. var t = a & 7;
  2022. x.length = (a >> 3) + 1;
  2023. b.nextBytes(x);
  2024. if (t > 0) {
  2025. x[0] &= (1 << t) - 1;
  2026. } else {
  2027. x[0] = 0;
  2028. }
  2029. this.fromString(x, 256);
  2030. }
  2031. };
  2032. return BigInteger2;
  2033. }()
  2034. );
  2035. var NullExp = (
  2036. /** @class */
  2037. function() {
  2038. function NullExp2() {
  2039. }
  2040. NullExp2.prototype.convert = function(x) {
  2041. return x;
  2042. };
  2043. NullExp2.prototype.revert = function(x) {
  2044. return x;
  2045. };
  2046. NullExp2.prototype.mulTo = function(x, y, r) {
  2047. x.multiplyTo(y, r);
  2048. };
  2049. NullExp2.prototype.sqrTo = function(x, r) {
  2050. x.squareTo(r);
  2051. };
  2052. return NullExp2;
  2053. }()
  2054. );
  2055. var Classic = (
  2056. /** @class */
  2057. function() {
  2058. function Classic2(m) {
  2059. this.m = m;
  2060. }
  2061. Classic2.prototype.convert = function(x) {
  2062. if (x.s < 0 || x.compareTo(this.m) >= 0) {
  2063. return x.mod(this.m);
  2064. } else {
  2065. return x;
  2066. }
  2067. };
  2068. Classic2.prototype.revert = function(x) {
  2069. return x;
  2070. };
  2071. Classic2.prototype.reduce = function(x) {
  2072. x.divRemTo(this.m, null, x);
  2073. };
  2074. Classic2.prototype.mulTo = function(x, y, r) {
  2075. x.multiplyTo(y, r);
  2076. this.reduce(r);
  2077. };
  2078. Classic2.prototype.sqrTo = function(x, r) {
  2079. x.squareTo(r);
  2080. this.reduce(r);
  2081. };
  2082. return Classic2;
  2083. }()
  2084. );
  2085. var Montgomery = (
  2086. /** @class */
  2087. function() {
  2088. function Montgomery2(m) {
  2089. this.m = m;
  2090. this.mp = m.invDigit();
  2091. this.mpl = this.mp & 32767;
  2092. this.mph = this.mp >> 15;
  2093. this.um = (1 << m.DB - 15) - 1;
  2094. this.mt2 = 2 * m.t;
  2095. }
  2096. Montgomery2.prototype.convert = function(x) {
  2097. var r = nbi();
  2098. x.abs().dlShiftTo(this.m.t, r);
  2099. r.divRemTo(this.m, null, r);
  2100. if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) {
  2101. this.m.subTo(r, r);
  2102. }
  2103. return r;
  2104. };
  2105. Montgomery2.prototype.revert = function(x) {
  2106. var r = nbi();
  2107. x.copyTo(r);
  2108. this.reduce(r);
  2109. return r;
  2110. };
  2111. Montgomery2.prototype.reduce = function(x) {
  2112. while (x.t <= this.mt2) {
  2113. x[x.t++] = 0;
  2114. }
  2115. for (var i = 0; i < this.m.t; ++i) {
  2116. var j = x[i] & 32767;
  2117. var u0 = j * this.mpl + ((j * this.mph + (x[i] >> 15) * this.mpl & this.um) << 15) & x.DM;
  2118. j = i + this.m.t;
  2119. x[j] += this.m.am(0, u0, x, i, 0, this.m.t);
  2120. while (x[j] >= x.DV) {
  2121. x[j] -= x.DV;
  2122. x[++j]++;
  2123. }
  2124. }
  2125. x.clamp();
  2126. x.drShiftTo(this.m.t, x);
  2127. if (x.compareTo(this.m) >= 0) {
  2128. x.subTo(this.m, x);
  2129. }
  2130. };
  2131. Montgomery2.prototype.mulTo = function(x, y, r) {
  2132. x.multiplyTo(y, r);
  2133. this.reduce(r);
  2134. };
  2135. Montgomery2.prototype.sqrTo = function(x, r) {
  2136. x.squareTo(r);
  2137. this.reduce(r);
  2138. };
  2139. return Montgomery2;
  2140. }()
  2141. );
  2142. var Barrett = (
  2143. /** @class */
  2144. function() {
  2145. function Barrett2(m) {
  2146. this.m = m;
  2147. this.r2 = nbi();
  2148. this.q3 = nbi();
  2149. BigInteger.ONE.dlShiftTo(2 * m.t, this.r2);
  2150. this.mu = this.r2.divide(m);
  2151. }
  2152. Barrett2.prototype.convert = function(x) {
  2153. if (x.s < 0 || x.t > 2 * this.m.t) {
  2154. return x.mod(this.m);
  2155. } else if (x.compareTo(this.m) < 0) {
  2156. return x;
  2157. } else {
  2158. var r = nbi();
  2159. x.copyTo(r);
  2160. this.reduce(r);
  2161. return r;
  2162. }
  2163. };
  2164. Barrett2.prototype.revert = function(x) {
  2165. return x;
  2166. };
  2167. Barrett2.prototype.reduce = function(x) {
  2168. x.drShiftTo(this.m.t - 1, this.r2);
  2169. if (x.t > this.m.t + 1) {
  2170. x.t = this.m.t + 1;
  2171. x.clamp();
  2172. }
  2173. this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3);
  2174. this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2);
  2175. while (x.compareTo(this.r2) < 0) {
  2176. x.dAddOffset(1, this.m.t + 1);
  2177. }
  2178. x.subTo(this.r2, x);
  2179. while (x.compareTo(this.m) >= 0) {
  2180. x.subTo(this.m, x);
  2181. }
  2182. };
  2183. Barrett2.prototype.mulTo = function(x, y, r) {
  2184. x.multiplyTo(y, r);
  2185. this.reduce(r);
  2186. };
  2187. Barrett2.prototype.sqrTo = function(x, r) {
  2188. x.squareTo(r);
  2189. this.reduce(r);
  2190. };
  2191. return Barrett2;
  2192. }()
  2193. );
  2194. function nbi() {
  2195. return new BigInteger(null);
  2196. }
  2197. function parseBigInt(str, r) {
  2198. return new BigInteger(str, r);
  2199. }
  2200. var inBrowser = typeof navigator !== "undefined";
  2201. if (inBrowser && j_lm && navigator.appName == "Microsoft Internet Explorer") {
  2202. BigInteger.prototype.am = function am2(i, x, w, j, c, n) {
  2203. var xl = x & 32767;
  2204. var xh = x >> 15;
  2205. while (--n >= 0) {
  2206. var l = this[i] & 32767;
  2207. var h = this[i++] >> 15;
  2208. var m = xh * l + h * xl;
  2209. l = xl * l + ((m & 32767) << 15) + w[j] + (c & 1073741823);
  2210. c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30);
  2211. w[j++] = l & 1073741823;
  2212. }
  2213. return c;
  2214. };
  2215. dbits = 30;
  2216. } else if (inBrowser && j_lm && navigator.appName != "Netscape") {
  2217. BigInteger.prototype.am = function am1(i, x, w, j, c, n) {
  2218. while (--n >= 0) {
  2219. var v = x * this[i++] + w[j] + c;
  2220. c = Math.floor(v / 67108864);
  2221. w[j++] = v & 67108863;
  2222. }
  2223. return c;
  2224. };
  2225. dbits = 26;
  2226. } else {
  2227. BigInteger.prototype.am = function am3(i, x, w, j, c, n) {
  2228. var xl = x & 16383;
  2229. var xh = x >> 14;
  2230. while (--n >= 0) {
  2231. var l = this[i] & 16383;
  2232. var h = this[i++] >> 14;
  2233. var m = xh * l + h * xl;
  2234. l = xl * l + ((m & 16383) << 14) + w[j] + c;
  2235. c = (l >> 28) + (m >> 14) + xh * h;
  2236. w[j++] = l & 268435455;
  2237. }
  2238. return c;
  2239. };
  2240. dbits = 28;
  2241. }
  2242. BigInteger.prototype.DB = dbits;
  2243. BigInteger.prototype.DM = (1 << dbits) - 1;
  2244. BigInteger.prototype.DV = 1 << dbits;
  2245. var BI_FP = 52;
  2246. BigInteger.prototype.FV = Math.pow(2, BI_FP);
  2247. BigInteger.prototype.F1 = BI_FP - dbits;
  2248. BigInteger.prototype.F2 = 2 * dbits - BI_FP;
  2249. var BI_RC = [];
  2250. var rr;
  2251. var vv;
  2252. rr = "0".charCodeAt(0);
  2253. for (vv = 0; vv <= 9; ++vv) {
  2254. BI_RC[rr++] = vv;
  2255. }
  2256. rr = "a".charCodeAt(0);
  2257. for (vv = 10; vv < 36; ++vv) {
  2258. BI_RC[rr++] = vv;
  2259. }
  2260. rr = "A".charCodeAt(0);
  2261. for (vv = 10; vv < 36; ++vv) {
  2262. BI_RC[rr++] = vv;
  2263. }
  2264. function intAt(s, i) {
  2265. var c = BI_RC[s.charCodeAt(i)];
  2266. return c == null ? -1 : c;
  2267. }
  2268. function nbv(i) {
  2269. var r = nbi();
  2270. r.fromInt(i);
  2271. return r;
  2272. }
  2273. function nbits(x) {
  2274. var r = 1;
  2275. var t;
  2276. if ((t = x >>> 16) != 0) {
  2277. x = t;
  2278. r += 16;
  2279. }
  2280. if ((t = x >> 8) != 0) {
  2281. x = t;
  2282. r += 8;
  2283. }
  2284. if ((t = x >> 4) != 0) {
  2285. x = t;
  2286. r += 4;
  2287. }
  2288. if ((t = x >> 2) != 0) {
  2289. x = t;
  2290. r += 2;
  2291. }
  2292. if ((t = x >> 1) != 0) {
  2293. x = t;
  2294. r += 1;
  2295. }
  2296. return r;
  2297. }
  2298. BigInteger.ZERO = nbv(0);
  2299. BigInteger.ONE = nbv(1);
  2300. // ../../../../wpl/hjy/workApp/node_modules/jsencrypt/lib/lib/jsbn/prng4.js
  2301. var Arcfour = (
  2302. /** @class */
  2303. function() {
  2304. function Arcfour2() {
  2305. this.i = 0;
  2306. this.j = 0;
  2307. this.S = [];
  2308. }
  2309. Arcfour2.prototype.init = function(key) {
  2310. var i;
  2311. var j;
  2312. var t;
  2313. for (i = 0; i < 256; ++i) {
  2314. this.S[i] = i;
  2315. }
  2316. j = 0;
  2317. for (i = 0; i < 256; ++i) {
  2318. j = j + this.S[i] + key[i % key.length] & 255;
  2319. t = this.S[i];
  2320. this.S[i] = this.S[j];
  2321. this.S[j] = t;
  2322. }
  2323. this.i = 0;
  2324. this.j = 0;
  2325. };
  2326. Arcfour2.prototype.next = function() {
  2327. var t;
  2328. this.i = this.i + 1 & 255;
  2329. this.j = this.j + this.S[this.i] & 255;
  2330. t = this.S[this.i];
  2331. this.S[this.i] = this.S[this.j];
  2332. this.S[this.j] = t;
  2333. return this.S[t + this.S[this.i] & 255];
  2334. };
  2335. return Arcfour2;
  2336. }()
  2337. );
  2338. function prng_newstate() {
  2339. return new Arcfour();
  2340. }
  2341. var rng_psize = 256;
  2342. // ../../../../wpl/hjy/workApp/node_modules/jsencrypt/lib/lib/jsbn/rng.js
  2343. var rng_state;
  2344. var rng_pool = null;
  2345. var rng_pptr;
  2346. if (rng_pool == null) {
  2347. rng_pool = [];
  2348. rng_pptr = 0;
  2349. t = void 0;
  2350. if (typeof window !== "undefined" && window.crypto && window.crypto.getRandomValues) {
  2351. z = new Uint32Array(256);
  2352. window.crypto.getRandomValues(z);
  2353. for (t = 0; t < z.length; ++t) {
  2354. rng_pool[rng_pptr++] = z[t] & 255;
  2355. }
  2356. }
  2357. count = 0;
  2358. onMouseMoveListener_1 = function(ev) {
  2359. count = count || 0;
  2360. if (count >= 256 || rng_pptr >= rng_psize) {
  2361. if (window.removeEventListener) {
  2362. window.removeEventListener("mousemove", onMouseMoveListener_1, false);
  2363. } else if (window.detachEvent) {
  2364. window.detachEvent("onmousemove", onMouseMoveListener_1);
  2365. }
  2366. return;
  2367. }
  2368. try {
  2369. var mouseCoordinates = ev.x + ev.y;
  2370. rng_pool[rng_pptr++] = mouseCoordinates & 255;
  2371. count += 1;
  2372. } catch (e) {
  2373. }
  2374. };
  2375. if (typeof window !== "undefined") {
  2376. if (window.addEventListener) {
  2377. window.addEventListener("mousemove", onMouseMoveListener_1, false);
  2378. } else if (window.attachEvent) {
  2379. window.attachEvent("onmousemove", onMouseMoveListener_1);
  2380. }
  2381. }
  2382. }
  2383. var t;
  2384. var z;
  2385. var count;
  2386. var onMouseMoveListener_1;
  2387. function rng_get_byte() {
  2388. if (rng_state == null) {
  2389. rng_state = prng_newstate();
  2390. while (rng_pptr < rng_psize) {
  2391. var random = Math.floor(65536 * Math.random());
  2392. rng_pool[rng_pptr++] = random & 255;
  2393. }
  2394. rng_state.init(rng_pool);
  2395. for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) {
  2396. rng_pool[rng_pptr] = 0;
  2397. }
  2398. rng_pptr = 0;
  2399. }
  2400. return rng_state.next();
  2401. }
  2402. var SecureRandom = (
  2403. /** @class */
  2404. function() {
  2405. function SecureRandom2() {
  2406. }
  2407. SecureRandom2.prototype.nextBytes = function(ba) {
  2408. for (var i = 0; i < ba.length; ++i) {
  2409. ba[i] = rng_get_byte();
  2410. }
  2411. };
  2412. return SecureRandom2;
  2413. }()
  2414. );
  2415. // ../../../../wpl/hjy/workApp/node_modules/jsencrypt/lib/lib/jsbn/rsa.js
  2416. function pkcs1pad1(s, n) {
  2417. if (n < s.length + 22) {
  2418. console.error("Message too long for RSA");
  2419. return null;
  2420. }
  2421. var len = n - s.length - 6;
  2422. var filler = "";
  2423. for (var f = 0; f < len; f += 2) {
  2424. filler += "ff";
  2425. }
  2426. var m = "0001" + filler + "00" + s;
  2427. return parseBigInt(m, 16);
  2428. }
  2429. function pkcs1pad2(s, n) {
  2430. if (n < s.length + 11) {
  2431. console.error("Message too long for RSA");
  2432. return null;
  2433. }
  2434. var ba = [];
  2435. var i = s.length - 1;
  2436. while (i >= 0 && n > 0) {
  2437. var c = s.charCodeAt(i--);
  2438. if (c < 128) {
  2439. ba[--n] = c;
  2440. } else if (c > 127 && c < 2048) {
  2441. ba[--n] = c & 63 | 128;
  2442. ba[--n] = c >> 6 | 192;
  2443. } else {
  2444. ba[--n] = c & 63 | 128;
  2445. ba[--n] = c >> 6 & 63 | 128;
  2446. ba[--n] = c >> 12 | 224;
  2447. }
  2448. }
  2449. ba[--n] = 0;
  2450. var rng = new SecureRandom();
  2451. var x = [];
  2452. while (n > 2) {
  2453. x[0] = 0;
  2454. while (x[0] == 0) {
  2455. rng.nextBytes(x);
  2456. }
  2457. ba[--n] = x[0];
  2458. }
  2459. ba[--n] = 2;
  2460. ba[--n] = 0;
  2461. return new BigInteger(ba);
  2462. }
  2463. var RSAKey = (
  2464. /** @class */
  2465. function() {
  2466. function RSAKey2() {
  2467. this.n = null;
  2468. this.e = 0;
  2469. this.d = null;
  2470. this.p = null;
  2471. this.q = null;
  2472. this.dmp1 = null;
  2473. this.dmq1 = null;
  2474. this.coeff = null;
  2475. }
  2476. RSAKey2.prototype.doPublic = function(x) {
  2477. return x.modPowInt(this.e, this.n);
  2478. };
  2479. RSAKey2.prototype.doPrivate = function(x) {
  2480. if (this.p == null || this.q == null) {
  2481. return x.modPow(this.d, this.n);
  2482. }
  2483. var xp = x.mod(this.p).modPow(this.dmp1, this.p);
  2484. var xq = x.mod(this.q).modPow(this.dmq1, this.q);
  2485. while (xp.compareTo(xq) < 0) {
  2486. xp = xp.add(this.p);
  2487. }
  2488. return xp.subtract(xq).multiply(this.coeff).mod(this.p).multiply(this.q).add(xq);
  2489. };
  2490. RSAKey2.prototype.setPublic = function(N, E) {
  2491. if (N != null && E != null && N.length > 0 && E.length > 0) {
  2492. this.n = parseBigInt(N, 16);
  2493. this.e = parseInt(E, 16);
  2494. } else {
  2495. console.error("Invalid RSA public key");
  2496. }
  2497. };
  2498. RSAKey2.prototype.encrypt = function(text) {
  2499. var maxLength = this.n.bitLength() + 7 >> 3;
  2500. var m = pkcs1pad2(text, maxLength);
  2501. if (m == null) {
  2502. return null;
  2503. }
  2504. var c = this.doPublic(m);
  2505. if (c == null) {
  2506. return null;
  2507. }
  2508. var h = c.toString(16);
  2509. var length = h.length;
  2510. for (var i = 0; i < maxLength * 2 - length; i++) {
  2511. h = "0" + h;
  2512. }
  2513. return h;
  2514. };
  2515. RSAKey2.prototype.setPrivate = function(N, E, D) {
  2516. if (N != null && E != null && N.length > 0 && E.length > 0) {
  2517. this.n = parseBigInt(N, 16);
  2518. this.e = parseInt(E, 16);
  2519. this.d = parseBigInt(D, 16);
  2520. } else {
  2521. console.error("Invalid RSA private key");
  2522. }
  2523. };
  2524. RSAKey2.prototype.setPrivateEx = function(N, E, D, P, Q, DP, DQ, C) {
  2525. if (N != null && E != null && N.length > 0 && E.length > 0) {
  2526. this.n = parseBigInt(N, 16);
  2527. this.e = parseInt(E, 16);
  2528. this.d = parseBigInt(D, 16);
  2529. this.p = parseBigInt(P, 16);
  2530. this.q = parseBigInt(Q, 16);
  2531. this.dmp1 = parseBigInt(DP, 16);
  2532. this.dmq1 = parseBigInt(DQ, 16);
  2533. this.coeff = parseBigInt(C, 16);
  2534. } else {
  2535. console.error("Invalid RSA private key");
  2536. }
  2537. };
  2538. RSAKey2.prototype.generate = function(B, E) {
  2539. var rng = new SecureRandom();
  2540. var qs = B >> 1;
  2541. this.e = parseInt(E, 16);
  2542. var ee = new BigInteger(E, 16);
  2543. for (; ; ) {
  2544. for (; ; ) {
  2545. this.p = new BigInteger(B - qs, 1, rng);
  2546. if (this.p.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE) == 0 && this.p.isProbablePrime(10)) {
  2547. break;
  2548. }
  2549. }
  2550. for (; ; ) {
  2551. this.q = new BigInteger(qs, 1, rng);
  2552. if (this.q.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE) == 0 && this.q.isProbablePrime(10)) {
  2553. break;
  2554. }
  2555. }
  2556. if (this.p.compareTo(this.q) <= 0) {
  2557. var t = this.p;
  2558. this.p = this.q;
  2559. this.q = t;
  2560. }
  2561. var p1 = this.p.subtract(BigInteger.ONE);
  2562. var q1 = this.q.subtract(BigInteger.ONE);
  2563. var phi = p1.multiply(q1);
  2564. if (phi.gcd(ee).compareTo(BigInteger.ONE) == 0) {
  2565. this.n = this.p.multiply(this.q);
  2566. this.d = ee.modInverse(phi);
  2567. this.dmp1 = this.d.mod(p1);
  2568. this.dmq1 = this.d.mod(q1);
  2569. this.coeff = this.q.modInverse(this.p);
  2570. break;
  2571. }
  2572. }
  2573. };
  2574. RSAKey2.prototype.decrypt = function(ctext) {
  2575. var c = parseBigInt(ctext, 16);
  2576. var m = this.doPrivate(c);
  2577. if (m == null) {
  2578. return null;
  2579. }
  2580. return pkcs1unpad2(m, this.n.bitLength() + 7 >> 3);
  2581. };
  2582. RSAKey2.prototype.generateAsync = function(B, E, callback) {
  2583. var rng = new SecureRandom();
  2584. var qs = B >> 1;
  2585. this.e = parseInt(E, 16);
  2586. var ee = new BigInteger(E, 16);
  2587. var rsa = this;
  2588. var loop1 = function() {
  2589. var loop4 = function() {
  2590. if (rsa.p.compareTo(rsa.q) <= 0) {
  2591. var t = rsa.p;
  2592. rsa.p = rsa.q;
  2593. rsa.q = t;
  2594. }
  2595. var p1 = rsa.p.subtract(BigInteger.ONE);
  2596. var q1 = rsa.q.subtract(BigInteger.ONE);
  2597. var phi = p1.multiply(q1);
  2598. if (phi.gcd(ee).compareTo(BigInteger.ONE) == 0) {
  2599. rsa.n = rsa.p.multiply(rsa.q);
  2600. rsa.d = ee.modInverse(phi);
  2601. rsa.dmp1 = rsa.d.mod(p1);
  2602. rsa.dmq1 = rsa.d.mod(q1);
  2603. rsa.coeff = rsa.q.modInverse(rsa.p);
  2604. setTimeout(function() {
  2605. callback();
  2606. }, 0);
  2607. } else {
  2608. setTimeout(loop1, 0);
  2609. }
  2610. };
  2611. var loop3 = function() {
  2612. rsa.q = nbi();
  2613. rsa.q.fromNumberAsync(qs, 1, rng, function() {
  2614. rsa.q.subtract(BigInteger.ONE).gcda(ee, function(r) {
  2615. if (r.compareTo(BigInteger.ONE) == 0 && rsa.q.isProbablePrime(10)) {
  2616. setTimeout(loop4, 0);
  2617. } else {
  2618. setTimeout(loop3, 0);
  2619. }
  2620. });
  2621. });
  2622. };
  2623. var loop2 = function() {
  2624. rsa.p = nbi();
  2625. rsa.p.fromNumberAsync(B - qs, 1, rng, function() {
  2626. rsa.p.subtract(BigInteger.ONE).gcda(ee, function(r) {
  2627. if (r.compareTo(BigInteger.ONE) == 0 && rsa.p.isProbablePrime(10)) {
  2628. setTimeout(loop3, 0);
  2629. } else {
  2630. setTimeout(loop2, 0);
  2631. }
  2632. });
  2633. });
  2634. };
  2635. setTimeout(loop2, 0);
  2636. };
  2637. setTimeout(loop1, 0);
  2638. };
  2639. RSAKey2.prototype.sign = function(text, digestMethod, digestName) {
  2640. var header = getDigestHeader(digestName);
  2641. var digest = header + digestMethod(text).toString();
  2642. var m = pkcs1pad1(digest, this.n.bitLength() / 4);
  2643. if (m == null) {
  2644. return null;
  2645. }
  2646. var c = this.doPrivate(m);
  2647. if (c == null) {
  2648. return null;
  2649. }
  2650. var h = c.toString(16);
  2651. if ((h.length & 1) == 0) {
  2652. return h;
  2653. } else {
  2654. return "0" + h;
  2655. }
  2656. };
  2657. RSAKey2.prototype.verify = function(text, signature, digestMethod) {
  2658. var c = parseBigInt(signature, 16);
  2659. var m = this.doPublic(c);
  2660. if (m == null) {
  2661. return null;
  2662. }
  2663. var unpadded = m.toString(16).replace(/^1f+00/, "");
  2664. var digest = removeDigestHeader(unpadded);
  2665. return digest == digestMethod(text).toString();
  2666. };
  2667. return RSAKey2;
  2668. }()
  2669. );
  2670. function pkcs1unpad2(d, n) {
  2671. var b = d.toByteArray();
  2672. var i = 0;
  2673. while (i < b.length && b[i] == 0) {
  2674. ++i;
  2675. }
  2676. if (b.length - i != n - 1 || b[i] != 2) {
  2677. return null;
  2678. }
  2679. ++i;
  2680. while (b[i] != 0) {
  2681. if (++i >= b.length) {
  2682. return null;
  2683. }
  2684. }
  2685. var ret = "";
  2686. while (++i < b.length) {
  2687. var c = b[i] & 255;
  2688. if (c < 128) {
  2689. ret += String.fromCharCode(c);
  2690. } else if (c > 191 && c < 224) {
  2691. ret += String.fromCharCode((c & 31) << 6 | b[i + 1] & 63);
  2692. ++i;
  2693. } else {
  2694. ret += String.fromCharCode((c & 15) << 12 | (b[i + 1] & 63) << 6 | b[i + 2] & 63);
  2695. i += 2;
  2696. }
  2697. }
  2698. return ret;
  2699. }
  2700. var DIGEST_HEADERS = {
  2701. md2: "3020300c06082a864886f70d020205000410",
  2702. md5: "3020300c06082a864886f70d020505000410",
  2703. sha1: "3021300906052b0e03021a05000414",
  2704. sha224: "302d300d06096086480165030402040500041c",
  2705. sha256: "3031300d060960864801650304020105000420",
  2706. sha384: "3041300d060960864801650304020205000430",
  2707. sha512: "3051300d060960864801650304020305000440",
  2708. ripemd160: "3021300906052b2403020105000414"
  2709. };
  2710. function getDigestHeader(name) {
  2711. return DIGEST_HEADERS[name] || "";
  2712. }
  2713. function removeDigestHeader(str) {
  2714. for (var name_1 in DIGEST_HEADERS) {
  2715. if (DIGEST_HEADERS.hasOwnProperty(name_1)) {
  2716. var header = DIGEST_HEADERS[name_1];
  2717. var len = header.length;
  2718. if (str.substr(0, len) == header) {
  2719. return str.substr(len);
  2720. }
  2721. }
  2722. }
  2723. return str;
  2724. }
  2725. // ../../../../wpl/hjy/workApp/node_modules/jsencrypt/lib/lib/jsrsasign/yahoo.js
  2726. var YAHOO = {};
  2727. YAHOO.lang = {
  2728. /**
  2729. * Utility to set up the prototype, constructor and superclass properties to
  2730. * support an inheritance strategy that can chain constructors and methods.
  2731. * Static members will not be inherited.
  2732. *
  2733. * @method extend
  2734. * @static
  2735. * @param {Function} subc the object to modify
  2736. * @param {Function} superc the object to inherit
  2737. * @param {Object} overrides additional properties/methods to add to the
  2738. * subclass prototype. These will override the
  2739. * matching items obtained from the superclass
  2740. * if present.
  2741. */
  2742. extend: function(subc, superc, overrides) {
  2743. if (!superc || !subc) {
  2744. throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");
  2745. }
  2746. var F = function() {
  2747. };
  2748. F.prototype = superc.prototype;
  2749. subc.prototype = new F();
  2750. subc.prototype.constructor = subc;
  2751. subc.superclass = superc.prototype;
  2752. if (superc.prototype.constructor == Object.prototype.constructor) {
  2753. superc.prototype.constructor = superc;
  2754. }
  2755. if (overrides) {
  2756. var i;
  2757. for (i in overrides) {
  2758. subc.prototype[i] = overrides[i];
  2759. }
  2760. var _IEEnumFix = function() {
  2761. }, ADD = ["toString", "valueOf"];
  2762. try {
  2763. if (/MSIE/.test(navigator.userAgent)) {
  2764. _IEEnumFix = function(r, s) {
  2765. for (i = 0; i < ADD.length; i = i + 1) {
  2766. var fname = ADD[i], f = s[fname];
  2767. if (typeof f === "function" && f != Object.prototype[fname]) {
  2768. r[fname] = f;
  2769. }
  2770. }
  2771. };
  2772. }
  2773. } catch (ex) {
  2774. }
  2775. ;
  2776. _IEEnumFix(subc.prototype, overrides);
  2777. }
  2778. }
  2779. };
  2780. // ../../../../wpl/hjy/workApp/node_modules/jsencrypt/lib/lib/jsrsasign/asn1-1.0.js
  2781. var KJUR = {};
  2782. if (typeof KJUR.asn1 == "undefined" || !KJUR.asn1)
  2783. KJUR.asn1 = {};
  2784. KJUR.asn1.ASN1Util = new function() {
  2785. this.integerToByteHex = function(i) {
  2786. var h = i.toString(16);
  2787. if (h.length % 2 == 1)
  2788. h = "0" + h;
  2789. return h;
  2790. };
  2791. this.bigIntToMinTwosComplementsHex = function(bigIntegerValue) {
  2792. var h = bigIntegerValue.toString(16);
  2793. if (h.substr(0, 1) != "-") {
  2794. if (h.length % 2 == 1) {
  2795. h = "0" + h;
  2796. } else {
  2797. if (!h.match(/^[0-7]/)) {
  2798. h = "00" + h;
  2799. }
  2800. }
  2801. } else {
  2802. var hPos = h.substr(1);
  2803. var xorLen = hPos.length;
  2804. if (xorLen % 2 == 1) {
  2805. xorLen += 1;
  2806. } else {
  2807. if (!h.match(/^[0-7]/)) {
  2808. xorLen += 2;
  2809. }
  2810. }
  2811. var hMask = "";
  2812. for (var i = 0; i < xorLen; i++) {
  2813. hMask += "f";
  2814. }
  2815. var biMask = new BigInteger(hMask, 16);
  2816. var biNeg = biMask.xor(bigIntegerValue).add(BigInteger.ONE);
  2817. h = biNeg.toString(16).replace(/^-/, "");
  2818. }
  2819. return h;
  2820. };
  2821. this.getPEMStringFromHex = function(dataHex, pemHeader) {
  2822. return hextopem(dataHex, pemHeader);
  2823. };
  2824. this.newObject = function(param) {
  2825. var _KJUR = KJUR, _KJUR_asn1 = _KJUR.asn1, _DERBoolean = _KJUR_asn1.DERBoolean, _DERInteger = _KJUR_asn1.DERInteger, _DERBitString = _KJUR_asn1.DERBitString, _DEROctetString = _KJUR_asn1.DEROctetString, _DERNull = _KJUR_asn1.DERNull, _DERObjectIdentifier = _KJUR_asn1.DERObjectIdentifier, _DEREnumerated = _KJUR_asn1.DEREnumerated, _DERUTF8String = _KJUR_asn1.DERUTF8String, _DERNumericString = _KJUR_asn1.DERNumericString, _DERPrintableString = _KJUR_asn1.DERPrintableString, _DERTeletexString = _KJUR_asn1.DERTeletexString, _DERIA5String = _KJUR_asn1.DERIA5String, _DERUTCTime = _KJUR_asn1.DERUTCTime, _DERGeneralizedTime = _KJUR_asn1.DERGeneralizedTime, _DERSequence = _KJUR_asn1.DERSequence, _DERSet = _KJUR_asn1.DERSet, _DERTaggedObject = _KJUR_asn1.DERTaggedObject, _newObject = _KJUR_asn1.ASN1Util.newObject;
  2826. var keys = Object.keys(param);
  2827. if (keys.length != 1)
  2828. throw "key of param shall be only one.";
  2829. var key = keys[0];
  2830. if (":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":" + key + ":") == -1)
  2831. throw "undefined key: " + key;
  2832. if (key == "bool")
  2833. return new _DERBoolean(param[key]);
  2834. if (key == "int")
  2835. return new _DERInteger(param[key]);
  2836. if (key == "bitstr")
  2837. return new _DERBitString(param[key]);
  2838. if (key == "octstr")
  2839. return new _DEROctetString(param[key]);
  2840. if (key == "null")
  2841. return new _DERNull(param[key]);
  2842. if (key == "oid")
  2843. return new _DERObjectIdentifier(param[key]);
  2844. if (key == "enum")
  2845. return new _DEREnumerated(param[key]);
  2846. if (key == "utf8str")
  2847. return new _DERUTF8String(param[key]);
  2848. if (key == "numstr")
  2849. return new _DERNumericString(param[key]);
  2850. if (key == "prnstr")
  2851. return new _DERPrintableString(param[key]);
  2852. if (key == "telstr")
  2853. return new _DERTeletexString(param[key]);
  2854. if (key == "ia5str")
  2855. return new _DERIA5String(param[key]);
  2856. if (key == "utctime")
  2857. return new _DERUTCTime(param[key]);
  2858. if (key == "gentime")
  2859. return new _DERGeneralizedTime(param[key]);
  2860. if (key == "seq") {
  2861. var paramList = param[key];
  2862. var a = [];
  2863. for (var i = 0; i < paramList.length; i++) {
  2864. var asn1Obj = _newObject(paramList[i]);
  2865. a.push(asn1Obj);
  2866. }
  2867. return new _DERSequence({ "array": a });
  2868. }
  2869. if (key == "set") {
  2870. var paramList = param[key];
  2871. var a = [];
  2872. for (var i = 0; i < paramList.length; i++) {
  2873. var asn1Obj = _newObject(paramList[i]);
  2874. a.push(asn1Obj);
  2875. }
  2876. return new _DERSet({ "array": a });
  2877. }
  2878. if (key == "tag") {
  2879. var tagParam = param[key];
  2880. if (Object.prototype.toString.call(tagParam) === "[object Array]" && tagParam.length == 3) {
  2881. var obj = _newObject(tagParam[2]);
  2882. return new _DERTaggedObject({
  2883. tag: tagParam[0],
  2884. explicit: tagParam[1],
  2885. obj
  2886. });
  2887. } else {
  2888. var newParam = {};
  2889. if (tagParam.explicit !== void 0)
  2890. newParam.explicit = tagParam.explicit;
  2891. if (tagParam.tag !== void 0)
  2892. newParam.tag = tagParam.tag;
  2893. if (tagParam.obj === void 0)
  2894. throw "obj shall be specified for 'tag'.";
  2895. newParam.obj = _newObject(tagParam.obj);
  2896. return new _DERTaggedObject(newParam);
  2897. }
  2898. }
  2899. };
  2900. this.jsonToASN1HEX = function(param) {
  2901. var asn1Obj = this.newObject(param);
  2902. return asn1Obj.getEncodedHex();
  2903. };
  2904. }();
  2905. KJUR.asn1.ASN1Util.oidHexToInt = function(hex) {
  2906. var s = "";
  2907. var i01 = parseInt(hex.substr(0, 2), 16);
  2908. var i0 = Math.floor(i01 / 40);
  2909. var i1 = i01 % 40;
  2910. var s = i0 + "." + i1;
  2911. var binbuf = "";
  2912. for (var i = 2; i < hex.length; i += 2) {
  2913. var value = parseInt(hex.substr(i, 2), 16);
  2914. var bin = ("00000000" + value.toString(2)).slice(-8);
  2915. binbuf = binbuf + bin.substr(1, 7);
  2916. if (bin.substr(0, 1) == "0") {
  2917. var bi = new BigInteger(binbuf, 2);
  2918. s = s + "." + bi.toString(10);
  2919. binbuf = "";
  2920. }
  2921. }
  2922. ;
  2923. return s;
  2924. };
  2925. KJUR.asn1.ASN1Util.oidIntToHex = function(oidString) {
  2926. var itox = function(i2) {
  2927. var h2 = i2.toString(16);
  2928. if (h2.length == 1)
  2929. h2 = "0" + h2;
  2930. return h2;
  2931. };
  2932. var roidtox = function(roid) {
  2933. var h2 = "";
  2934. var bi = new BigInteger(roid, 10);
  2935. var b = bi.toString(2);
  2936. var padLen = 7 - b.length % 7;
  2937. if (padLen == 7)
  2938. padLen = 0;
  2939. var bPad = "";
  2940. for (var i2 = 0; i2 < padLen; i2++)
  2941. bPad += "0";
  2942. b = bPad + b;
  2943. for (var i2 = 0; i2 < b.length - 1; i2 += 7) {
  2944. var b8 = b.substr(i2, 7);
  2945. if (i2 != b.length - 7)
  2946. b8 = "1" + b8;
  2947. h2 += itox(parseInt(b8, 2));
  2948. }
  2949. return h2;
  2950. };
  2951. if (!oidString.match(/^[0-9.]+$/)) {
  2952. throw "malformed oid string: " + oidString;
  2953. }
  2954. var h = "";
  2955. var a = oidString.split(".");
  2956. var i0 = parseInt(a[0]) * 40 + parseInt(a[1]);
  2957. h += itox(i0);
  2958. a.splice(0, 2);
  2959. for (var i = 0; i < a.length; i++) {
  2960. h += roidtox(a[i]);
  2961. }
  2962. return h;
  2963. };
  2964. KJUR.asn1.ASN1Object = function() {
  2965. var isModified = true;
  2966. var hTLV = null;
  2967. var hT = "00";
  2968. var hL = "00";
  2969. var hV = "";
  2970. this.getLengthHexFromValue = function() {
  2971. if (typeof this.hV == "undefined" || this.hV == null) {
  2972. throw "this.hV is null or undefined.";
  2973. }
  2974. if (this.hV.length % 2 == 1) {
  2975. throw "value hex must be even length: n=" + hV.length + ",v=" + this.hV;
  2976. }
  2977. var n = this.hV.length / 2;
  2978. var hN = n.toString(16);
  2979. if (hN.length % 2 == 1) {
  2980. hN = "0" + hN;
  2981. }
  2982. if (n < 128) {
  2983. return hN;
  2984. } else {
  2985. var hNlen = hN.length / 2;
  2986. if (hNlen > 15) {
  2987. throw "ASN.1 length too long to represent by 8x: n = " + n.toString(16);
  2988. }
  2989. var head = 128 + hNlen;
  2990. return head.toString(16) + hN;
  2991. }
  2992. };
  2993. this.getEncodedHex = function() {
  2994. if (this.hTLV == null || this.isModified) {
  2995. this.hV = this.getFreshValueHex();
  2996. this.hL = this.getLengthHexFromValue();
  2997. this.hTLV = this.hT + this.hL + this.hV;
  2998. this.isModified = false;
  2999. }
  3000. return this.hTLV;
  3001. };
  3002. this.getValueHex = function() {
  3003. this.getEncodedHex();
  3004. return this.hV;
  3005. };
  3006. this.getFreshValueHex = function() {
  3007. return "";
  3008. };
  3009. };
  3010. KJUR.asn1.DERAbstractString = function(params) {
  3011. KJUR.asn1.DERAbstractString.superclass.constructor.call(this);
  3012. var s = null;
  3013. var hV = null;
  3014. this.getString = function() {
  3015. return this.s;
  3016. };
  3017. this.setString = function(newS) {
  3018. this.hTLV = null;
  3019. this.isModified = true;
  3020. this.s = newS;
  3021. this.hV = stohex(this.s);
  3022. };
  3023. this.setStringHex = function(newHexString) {
  3024. this.hTLV = null;
  3025. this.isModified = true;
  3026. this.s = null;
  3027. this.hV = newHexString;
  3028. };
  3029. this.getFreshValueHex = function() {
  3030. return this.hV;
  3031. };
  3032. if (typeof params != "undefined") {
  3033. if (typeof params == "string") {
  3034. this.setString(params);
  3035. } else if (typeof params["str"] != "undefined") {
  3036. this.setString(params["str"]);
  3037. } else if (typeof params["hex"] != "undefined") {
  3038. this.setStringHex(params["hex"]);
  3039. }
  3040. }
  3041. };
  3042. YAHOO.lang.extend(KJUR.asn1.DERAbstractString, KJUR.asn1.ASN1Object);
  3043. KJUR.asn1.DERAbstractTime = function(params) {
  3044. KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);
  3045. var s = null;
  3046. var date = null;
  3047. this.localDateToUTC = function(d) {
  3048. utc = d.getTime() + d.getTimezoneOffset() * 6e4;
  3049. var utcDate = new Date(utc);
  3050. return utcDate;
  3051. };
  3052. this.formatDate = function(dateObject, type, withMillis) {
  3053. var pad = this.zeroPadding;
  3054. var d = this.localDateToUTC(dateObject);
  3055. var year = String(d.getFullYear());
  3056. if (type == "utc")
  3057. year = year.substr(2, 2);
  3058. var month = pad(String(d.getMonth() + 1), 2);
  3059. var day = pad(String(d.getDate()), 2);
  3060. var hour = pad(String(d.getHours()), 2);
  3061. var min = pad(String(d.getMinutes()), 2);
  3062. var sec = pad(String(d.getSeconds()), 2);
  3063. var s2 = year + month + day + hour + min + sec;
  3064. if (withMillis === true) {
  3065. var millis = d.getMilliseconds();
  3066. if (millis != 0) {
  3067. var sMillis = pad(String(millis), 3);
  3068. sMillis = sMillis.replace(/[0]+$/, "");
  3069. s2 = s2 + "." + sMillis;
  3070. }
  3071. }
  3072. return s2 + "Z";
  3073. };
  3074. this.zeroPadding = function(s2, len) {
  3075. if (s2.length >= len)
  3076. return s2;
  3077. return new Array(len - s2.length + 1).join("0") + s2;
  3078. };
  3079. this.getString = function() {
  3080. return this.s;
  3081. };
  3082. this.setString = function(newS) {
  3083. this.hTLV = null;
  3084. this.isModified = true;
  3085. this.s = newS;
  3086. this.hV = stohex(newS);
  3087. };
  3088. this.setByDateValue = function(year, month, day, hour, min, sec) {
  3089. var dateObject = new Date(Date.UTC(year, month - 1, day, hour, min, sec, 0));
  3090. this.setByDate(dateObject);
  3091. };
  3092. this.getFreshValueHex = function() {
  3093. return this.hV;
  3094. };
  3095. };
  3096. YAHOO.lang.extend(KJUR.asn1.DERAbstractTime, KJUR.asn1.ASN1Object);
  3097. KJUR.asn1.DERAbstractStructured = function(params) {
  3098. KJUR.asn1.DERAbstractString.superclass.constructor.call(this);
  3099. var asn1Array = null;
  3100. this.setByASN1ObjectArray = function(asn1ObjectArray) {
  3101. this.hTLV = null;
  3102. this.isModified = true;
  3103. this.asn1Array = asn1ObjectArray;
  3104. };
  3105. this.appendASN1Object = function(asn1Object) {
  3106. this.hTLV = null;
  3107. this.isModified = true;
  3108. this.asn1Array.push(asn1Object);
  3109. };
  3110. this.asn1Array = new Array();
  3111. if (typeof params != "undefined") {
  3112. if (typeof params["array"] != "undefined") {
  3113. this.asn1Array = params["array"];
  3114. }
  3115. }
  3116. };
  3117. YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured, KJUR.asn1.ASN1Object);
  3118. KJUR.asn1.DERBoolean = function() {
  3119. KJUR.asn1.DERBoolean.superclass.constructor.call(this);
  3120. this.hT = "01";
  3121. this.hTLV = "0101ff";
  3122. };
  3123. YAHOO.lang.extend(KJUR.asn1.DERBoolean, KJUR.asn1.ASN1Object);
  3124. KJUR.asn1.DERInteger = function(params) {
  3125. KJUR.asn1.DERInteger.superclass.constructor.call(this);
  3126. this.hT = "02";
  3127. this.setByBigInteger = function(bigIntegerValue) {
  3128. this.hTLV = null;
  3129. this.isModified = true;
  3130. this.hV = KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(bigIntegerValue);
  3131. };
  3132. this.setByInteger = function(intValue) {
  3133. var bi = new BigInteger(String(intValue), 10);
  3134. this.setByBigInteger(bi);
  3135. };
  3136. this.setValueHex = function(newHexString) {
  3137. this.hV = newHexString;
  3138. };
  3139. this.getFreshValueHex = function() {
  3140. return this.hV;
  3141. };
  3142. if (typeof params != "undefined") {
  3143. if (typeof params["bigint"] != "undefined") {
  3144. this.setByBigInteger(params["bigint"]);
  3145. } else if (typeof params["int"] != "undefined") {
  3146. this.setByInteger(params["int"]);
  3147. } else if (typeof params == "number") {
  3148. this.setByInteger(params);
  3149. } else if (typeof params["hex"] != "undefined") {
  3150. this.setValueHex(params["hex"]);
  3151. }
  3152. }
  3153. };
  3154. YAHOO.lang.extend(KJUR.asn1.DERInteger, KJUR.asn1.ASN1Object);
  3155. KJUR.asn1.DERBitString = function(params) {
  3156. if (params !== void 0 && typeof params.obj !== "undefined") {
  3157. var o = KJUR.asn1.ASN1Util.newObject(params.obj);
  3158. params.hex = "00" + o.getEncodedHex();
  3159. }
  3160. KJUR.asn1.DERBitString.superclass.constructor.call(this);
  3161. this.hT = "03";
  3162. this.setHexValueIncludingUnusedBits = function(newHexStringIncludingUnusedBits) {
  3163. this.hTLV = null;
  3164. this.isModified = true;
  3165. this.hV = newHexStringIncludingUnusedBits;
  3166. };
  3167. this.setUnusedBitsAndHexValue = function(unusedBits, hValue) {
  3168. if (unusedBits < 0 || 7 < unusedBits) {
  3169. throw "unused bits shall be from 0 to 7: u = " + unusedBits;
  3170. }
  3171. var hUnusedBits = "0" + unusedBits;
  3172. this.hTLV = null;
  3173. this.isModified = true;
  3174. this.hV = hUnusedBits + hValue;
  3175. };
  3176. this.setByBinaryString = function(binaryString) {
  3177. binaryString = binaryString.replace(/0+$/, "");
  3178. var unusedBits = 8 - binaryString.length % 8;
  3179. if (unusedBits == 8)
  3180. unusedBits = 0;
  3181. for (var i = 0; i <= unusedBits; i++) {
  3182. binaryString += "0";
  3183. }
  3184. var h = "";
  3185. for (var i = 0; i < binaryString.length - 1; i += 8) {
  3186. var b = binaryString.substr(i, 8);
  3187. var x = parseInt(b, 2).toString(16);
  3188. if (x.length == 1)
  3189. x = "0" + x;
  3190. h += x;
  3191. }
  3192. this.hTLV = null;
  3193. this.isModified = true;
  3194. this.hV = "0" + unusedBits + h;
  3195. };
  3196. this.setByBooleanArray = function(booleanArray) {
  3197. var s = "";
  3198. for (var i = 0; i < booleanArray.length; i++) {
  3199. if (booleanArray[i] == true) {
  3200. s += "1";
  3201. } else {
  3202. s += "0";
  3203. }
  3204. }
  3205. this.setByBinaryString(s);
  3206. };
  3207. this.newFalseArray = function(nLength) {
  3208. var a = new Array(nLength);
  3209. for (var i = 0; i < nLength; i++) {
  3210. a[i] = false;
  3211. }
  3212. return a;
  3213. };
  3214. this.getFreshValueHex = function() {
  3215. return this.hV;
  3216. };
  3217. if (typeof params != "undefined") {
  3218. if (typeof params == "string" && params.toLowerCase().match(/^[0-9a-f]+$/)) {
  3219. this.setHexValueIncludingUnusedBits(params);
  3220. } else if (typeof params["hex"] != "undefined") {
  3221. this.setHexValueIncludingUnusedBits(params["hex"]);
  3222. } else if (typeof params["bin"] != "undefined") {
  3223. this.setByBinaryString(params["bin"]);
  3224. } else if (typeof params["array"] != "undefined") {
  3225. this.setByBooleanArray(params["array"]);
  3226. }
  3227. }
  3228. };
  3229. YAHOO.lang.extend(KJUR.asn1.DERBitString, KJUR.asn1.ASN1Object);
  3230. KJUR.asn1.DEROctetString = function(params) {
  3231. if (params !== void 0 && typeof params.obj !== "undefined") {
  3232. var o = KJUR.asn1.ASN1Util.newObject(params.obj);
  3233. params.hex = o.getEncodedHex();
  3234. }
  3235. KJUR.asn1.DEROctetString.superclass.constructor.call(this, params);
  3236. this.hT = "04";
  3237. };
  3238. YAHOO.lang.extend(KJUR.asn1.DEROctetString, KJUR.asn1.DERAbstractString);
  3239. KJUR.asn1.DERNull = function() {
  3240. KJUR.asn1.DERNull.superclass.constructor.call(this);
  3241. this.hT = "05";
  3242. this.hTLV = "0500";
  3243. };
  3244. YAHOO.lang.extend(KJUR.asn1.DERNull, KJUR.asn1.ASN1Object);
  3245. KJUR.asn1.DERObjectIdentifier = function(params) {
  3246. var itox = function(i) {
  3247. var h = i.toString(16);
  3248. if (h.length == 1)
  3249. h = "0" + h;
  3250. return h;
  3251. };
  3252. var roidtox = function(roid) {
  3253. var h = "";
  3254. var bi = new BigInteger(roid, 10);
  3255. var b = bi.toString(2);
  3256. var padLen = 7 - b.length % 7;
  3257. if (padLen == 7)
  3258. padLen = 0;
  3259. var bPad = "";
  3260. for (var i = 0; i < padLen; i++)
  3261. bPad += "0";
  3262. b = bPad + b;
  3263. for (var i = 0; i < b.length - 1; i += 7) {
  3264. var b8 = b.substr(i, 7);
  3265. if (i != b.length - 7)
  3266. b8 = "1" + b8;
  3267. h += itox(parseInt(b8, 2));
  3268. }
  3269. return h;
  3270. };
  3271. KJUR.asn1.DERObjectIdentifier.superclass.constructor.call(this);
  3272. this.hT = "06";
  3273. this.setValueHex = function(newHexString) {
  3274. this.hTLV = null;
  3275. this.isModified = true;
  3276. this.s = null;
  3277. this.hV = newHexString;
  3278. };
  3279. this.setValueOidString = function(oidString) {
  3280. if (!oidString.match(/^[0-9.]+$/)) {
  3281. throw "malformed oid string: " + oidString;
  3282. }
  3283. var h = "";
  3284. var a = oidString.split(".");
  3285. var i0 = parseInt(a[0]) * 40 + parseInt(a[1]);
  3286. h += itox(i0);
  3287. a.splice(0, 2);
  3288. for (var i = 0; i < a.length; i++) {
  3289. h += roidtox(a[i]);
  3290. }
  3291. this.hTLV = null;
  3292. this.isModified = true;
  3293. this.s = null;
  3294. this.hV = h;
  3295. };
  3296. this.setValueName = function(oidName) {
  3297. var oid = KJUR.asn1.x509.OID.name2oid(oidName);
  3298. if (oid !== "") {
  3299. this.setValueOidString(oid);
  3300. } else {
  3301. throw "DERObjectIdentifier oidName undefined: " + oidName;
  3302. }
  3303. };
  3304. this.getFreshValueHex = function() {
  3305. return this.hV;
  3306. };
  3307. if (params !== void 0) {
  3308. if (typeof params === "string") {
  3309. if (params.match(/^[0-2].[0-9.]+$/)) {
  3310. this.setValueOidString(params);
  3311. } else {
  3312. this.setValueName(params);
  3313. }
  3314. } else if (params.oid !== void 0) {
  3315. this.setValueOidString(params.oid);
  3316. } else if (params.hex !== void 0) {
  3317. this.setValueHex(params.hex);
  3318. } else if (params.name !== void 0) {
  3319. this.setValueName(params.name);
  3320. }
  3321. }
  3322. };
  3323. YAHOO.lang.extend(KJUR.asn1.DERObjectIdentifier, KJUR.asn1.ASN1Object);
  3324. KJUR.asn1.DEREnumerated = function(params) {
  3325. KJUR.asn1.DEREnumerated.superclass.constructor.call(this);
  3326. this.hT = "0a";
  3327. this.setByBigInteger = function(bigIntegerValue) {
  3328. this.hTLV = null;
  3329. this.isModified = true;
  3330. this.hV = KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(bigIntegerValue);
  3331. };
  3332. this.setByInteger = function(intValue) {
  3333. var bi = new BigInteger(String(intValue), 10);
  3334. this.setByBigInteger(bi);
  3335. };
  3336. this.setValueHex = function(newHexString) {
  3337. this.hV = newHexString;
  3338. };
  3339. this.getFreshValueHex = function() {
  3340. return this.hV;
  3341. };
  3342. if (typeof params != "undefined") {
  3343. if (typeof params["int"] != "undefined") {
  3344. this.setByInteger(params["int"]);
  3345. } else if (typeof params == "number") {
  3346. this.setByInteger(params);
  3347. } else if (typeof params["hex"] != "undefined") {
  3348. this.setValueHex(params["hex"]);
  3349. }
  3350. }
  3351. };
  3352. YAHOO.lang.extend(KJUR.asn1.DEREnumerated, KJUR.asn1.ASN1Object);
  3353. KJUR.asn1.DERUTF8String = function(params) {
  3354. KJUR.asn1.DERUTF8String.superclass.constructor.call(this, params);
  3355. this.hT = "0c";
  3356. };
  3357. YAHOO.lang.extend(KJUR.asn1.DERUTF8String, KJUR.asn1.DERAbstractString);
  3358. KJUR.asn1.DERNumericString = function(params) {
  3359. KJUR.asn1.DERNumericString.superclass.constructor.call(this, params);
  3360. this.hT = "12";
  3361. };
  3362. YAHOO.lang.extend(KJUR.asn1.DERNumericString, KJUR.asn1.DERAbstractString);
  3363. KJUR.asn1.DERPrintableString = function(params) {
  3364. KJUR.asn1.DERPrintableString.superclass.constructor.call(this, params);
  3365. this.hT = "13";
  3366. };
  3367. YAHOO.lang.extend(KJUR.asn1.DERPrintableString, KJUR.asn1.DERAbstractString);
  3368. KJUR.asn1.DERTeletexString = function(params) {
  3369. KJUR.asn1.DERTeletexString.superclass.constructor.call(this, params);
  3370. this.hT = "14";
  3371. };
  3372. YAHOO.lang.extend(KJUR.asn1.DERTeletexString, KJUR.asn1.DERAbstractString);
  3373. KJUR.asn1.DERIA5String = function(params) {
  3374. KJUR.asn1.DERIA5String.superclass.constructor.call(this, params);
  3375. this.hT = "16";
  3376. };
  3377. YAHOO.lang.extend(KJUR.asn1.DERIA5String, KJUR.asn1.DERAbstractString);
  3378. KJUR.asn1.DERUTCTime = function(params) {
  3379. KJUR.asn1.DERUTCTime.superclass.constructor.call(this, params);
  3380. this.hT = "17";
  3381. this.setByDate = function(dateObject) {
  3382. this.hTLV = null;
  3383. this.isModified = true;
  3384. this.date = dateObject;
  3385. this.s = this.formatDate(this.date, "utc");
  3386. this.hV = stohex(this.s);
  3387. };
  3388. this.getFreshValueHex = function() {
  3389. if (typeof this.date == "undefined" && typeof this.s == "undefined") {
  3390. this.date = /* @__PURE__ */ new Date();
  3391. this.s = this.formatDate(this.date, "utc");
  3392. this.hV = stohex(this.s);
  3393. }
  3394. return this.hV;
  3395. };
  3396. if (params !== void 0) {
  3397. if (params.str !== void 0) {
  3398. this.setString(params.str);
  3399. } else if (typeof params == "string" && params.match(/^[0-9]{12}Z$/)) {
  3400. this.setString(params);
  3401. } else if (params.hex !== void 0) {
  3402. this.setStringHex(params.hex);
  3403. } else if (params.date !== void 0) {
  3404. this.setByDate(params.date);
  3405. }
  3406. }
  3407. };
  3408. YAHOO.lang.extend(KJUR.asn1.DERUTCTime, KJUR.asn1.DERAbstractTime);
  3409. KJUR.asn1.DERGeneralizedTime = function(params) {
  3410. KJUR.asn1.DERGeneralizedTime.superclass.constructor.call(this, params);
  3411. this.hT = "18";
  3412. this.withMillis = false;
  3413. this.setByDate = function(dateObject) {
  3414. this.hTLV = null;
  3415. this.isModified = true;
  3416. this.date = dateObject;
  3417. this.s = this.formatDate(this.date, "gen", this.withMillis);
  3418. this.hV = stohex(this.s);
  3419. };
  3420. this.getFreshValueHex = function() {
  3421. if (this.date === void 0 && this.s === void 0) {
  3422. this.date = /* @__PURE__ */ new Date();
  3423. this.s = this.formatDate(this.date, "gen", this.withMillis);
  3424. this.hV = stohex(this.s);
  3425. }
  3426. return this.hV;
  3427. };
  3428. if (params !== void 0) {
  3429. if (params.str !== void 0) {
  3430. this.setString(params.str);
  3431. } else if (typeof params == "string" && params.match(/^[0-9]{14}Z$/)) {
  3432. this.setString(params);
  3433. } else if (params.hex !== void 0) {
  3434. this.setStringHex(params.hex);
  3435. } else if (params.date !== void 0) {
  3436. this.setByDate(params.date);
  3437. }
  3438. if (params.millis === true) {
  3439. this.withMillis = true;
  3440. }
  3441. }
  3442. };
  3443. YAHOO.lang.extend(KJUR.asn1.DERGeneralizedTime, KJUR.asn1.DERAbstractTime);
  3444. KJUR.asn1.DERSequence = function(params) {
  3445. KJUR.asn1.DERSequence.superclass.constructor.call(this, params);
  3446. this.hT = "30";
  3447. this.getFreshValueHex = function() {
  3448. var h = "";
  3449. for (var i = 0; i < this.asn1Array.length; i++) {
  3450. var asn1Obj = this.asn1Array[i];
  3451. h += asn1Obj.getEncodedHex();
  3452. }
  3453. this.hV = h;
  3454. return this.hV;
  3455. };
  3456. };
  3457. YAHOO.lang.extend(KJUR.asn1.DERSequence, KJUR.asn1.DERAbstractStructured);
  3458. KJUR.asn1.DERSet = function(params) {
  3459. KJUR.asn1.DERSet.superclass.constructor.call(this, params);
  3460. this.hT = "31";
  3461. this.sortFlag = true;
  3462. this.getFreshValueHex = function() {
  3463. var a = new Array();
  3464. for (var i = 0; i < this.asn1Array.length; i++) {
  3465. var asn1Obj = this.asn1Array[i];
  3466. a.push(asn1Obj.getEncodedHex());
  3467. }
  3468. if (this.sortFlag == true)
  3469. a.sort();
  3470. this.hV = a.join("");
  3471. return this.hV;
  3472. };
  3473. if (typeof params != "undefined") {
  3474. if (typeof params.sortflag != "undefined" && params.sortflag == false)
  3475. this.sortFlag = false;
  3476. }
  3477. };
  3478. YAHOO.lang.extend(KJUR.asn1.DERSet, KJUR.asn1.DERAbstractStructured);
  3479. KJUR.asn1.DERTaggedObject = function(params) {
  3480. KJUR.asn1.DERTaggedObject.superclass.constructor.call(this);
  3481. this.hT = "a0";
  3482. this.hV = "";
  3483. this.isExplicit = true;
  3484. this.asn1Object = null;
  3485. this.setASN1Object = function(isExplicitFlag, tagNoHex, asn1Object) {
  3486. this.hT = tagNoHex;
  3487. this.isExplicit = isExplicitFlag;
  3488. this.asn1Object = asn1Object;
  3489. if (this.isExplicit) {
  3490. this.hV = this.asn1Object.getEncodedHex();
  3491. this.hTLV = null;
  3492. this.isModified = true;
  3493. } else {
  3494. this.hV = null;
  3495. this.hTLV = asn1Object.getEncodedHex();
  3496. this.hTLV = this.hTLV.replace(/^../, tagNoHex);
  3497. this.isModified = false;
  3498. }
  3499. };
  3500. this.getFreshValueHex = function() {
  3501. return this.hV;
  3502. };
  3503. if (typeof params != "undefined") {
  3504. if (typeof params["tag"] != "undefined") {
  3505. this.hT = params["tag"];
  3506. }
  3507. if (typeof params["explicit"] != "undefined") {
  3508. this.isExplicit = params["explicit"];
  3509. }
  3510. if (typeof params["obj"] != "undefined") {
  3511. this.asn1Object = params["obj"];
  3512. this.setASN1Object(this.isExplicit, this.hT, this.asn1Object);
  3513. }
  3514. }
  3515. };
  3516. YAHOO.lang.extend(KJUR.asn1.DERTaggedObject, KJUR.asn1.ASN1Object);
  3517. // ../../../../wpl/hjy/workApp/node_modules/jsencrypt/lib/JSEncryptRSAKey.js
  3518. var __extends = /* @__PURE__ */ function() {
  3519. var extendStatics = function(d, b) {
  3520. extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
  3521. d2.__proto__ = b2;
  3522. } || function(d2, b2) {
  3523. for (var p in b2)
  3524. if (Object.prototype.hasOwnProperty.call(b2, p))
  3525. d2[p] = b2[p];
  3526. };
  3527. return extendStatics(d, b);
  3528. };
  3529. return function(d, b) {
  3530. if (typeof b !== "function" && b !== null)
  3531. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  3532. extendStatics(d, b);
  3533. function __() {
  3534. this.constructor = d;
  3535. }
  3536. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3537. };
  3538. }();
  3539. var JSEncryptRSAKey = (
  3540. /** @class */
  3541. function(_super) {
  3542. __extends(JSEncryptRSAKey2, _super);
  3543. function JSEncryptRSAKey2(key) {
  3544. var _this = _super.call(this) || this;
  3545. if (key) {
  3546. if (typeof key === "string") {
  3547. _this.parseKey(key);
  3548. } else if (JSEncryptRSAKey2.hasPrivateKeyProperty(key) || JSEncryptRSAKey2.hasPublicKeyProperty(key)) {
  3549. _this.parsePropertiesFrom(key);
  3550. }
  3551. }
  3552. return _this;
  3553. }
  3554. JSEncryptRSAKey2.prototype.parseKey = function(pem) {
  3555. try {
  3556. var modulus = 0;
  3557. var public_exponent = 0;
  3558. var reHex = /^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/;
  3559. var der = reHex.test(pem) ? Hex.decode(pem) : Base64.unarmor(pem);
  3560. var asn1 = ASN1.decode(der);
  3561. if (asn1.sub.length === 3) {
  3562. asn1 = asn1.sub[2].sub[0];
  3563. }
  3564. if (asn1.sub.length === 9) {
  3565. modulus = asn1.sub[1].getHexStringValue();
  3566. this.n = parseBigInt(modulus, 16);
  3567. public_exponent = asn1.sub[2].getHexStringValue();
  3568. this.e = parseInt(public_exponent, 16);
  3569. var private_exponent = asn1.sub[3].getHexStringValue();
  3570. this.d = parseBigInt(private_exponent, 16);
  3571. var prime1 = asn1.sub[4].getHexStringValue();
  3572. this.p = parseBigInt(prime1, 16);
  3573. var prime2 = asn1.sub[5].getHexStringValue();
  3574. this.q = parseBigInt(prime2, 16);
  3575. var exponent1 = asn1.sub[6].getHexStringValue();
  3576. this.dmp1 = parseBigInt(exponent1, 16);
  3577. var exponent2 = asn1.sub[7].getHexStringValue();
  3578. this.dmq1 = parseBigInt(exponent2, 16);
  3579. var coefficient = asn1.sub[8].getHexStringValue();
  3580. this.coeff = parseBigInt(coefficient, 16);
  3581. } else if (asn1.sub.length === 2) {
  3582. if (asn1.sub[0].sub) {
  3583. var bit_string = asn1.sub[1];
  3584. var sequence = bit_string.sub[0];
  3585. modulus = sequence.sub[0].getHexStringValue();
  3586. this.n = parseBigInt(modulus, 16);
  3587. public_exponent = sequence.sub[1].getHexStringValue();
  3588. this.e = parseInt(public_exponent, 16);
  3589. } else {
  3590. modulus = asn1.sub[0].getHexStringValue();
  3591. this.n = parseBigInt(modulus, 16);
  3592. public_exponent = asn1.sub[1].getHexStringValue();
  3593. this.e = parseInt(public_exponent, 16);
  3594. }
  3595. } else {
  3596. return false;
  3597. }
  3598. return true;
  3599. } catch (ex) {
  3600. return false;
  3601. }
  3602. };
  3603. JSEncryptRSAKey2.prototype.getPrivateBaseKey = function() {
  3604. var options = {
  3605. array: [
  3606. new KJUR.asn1.DERInteger({ int: 0 }),
  3607. new KJUR.asn1.DERInteger({ bigint: this.n }),
  3608. new KJUR.asn1.DERInteger({ int: this.e }),
  3609. new KJUR.asn1.DERInteger({ bigint: this.d }),
  3610. new KJUR.asn1.DERInteger({ bigint: this.p }),
  3611. new KJUR.asn1.DERInteger({ bigint: this.q }),
  3612. new KJUR.asn1.DERInteger({ bigint: this.dmp1 }),
  3613. new KJUR.asn1.DERInteger({ bigint: this.dmq1 }),
  3614. new KJUR.asn1.DERInteger({ bigint: this.coeff })
  3615. ]
  3616. };
  3617. var seq = new KJUR.asn1.DERSequence(options);
  3618. return seq.getEncodedHex();
  3619. };
  3620. JSEncryptRSAKey2.prototype.getPrivateBaseKeyB64 = function() {
  3621. return hex2b64(this.getPrivateBaseKey());
  3622. };
  3623. JSEncryptRSAKey2.prototype.getPublicBaseKey = function() {
  3624. var first_sequence = new KJUR.asn1.DERSequence({
  3625. array: [
  3626. new KJUR.asn1.DERObjectIdentifier({ oid: "1.2.840.113549.1.1.1" }),
  3627. new KJUR.asn1.DERNull()
  3628. ]
  3629. });
  3630. var second_sequence = new KJUR.asn1.DERSequence({
  3631. array: [
  3632. new KJUR.asn1.DERInteger({ bigint: this.n }),
  3633. new KJUR.asn1.DERInteger({ int: this.e })
  3634. ]
  3635. });
  3636. var bit_string = new KJUR.asn1.DERBitString({
  3637. hex: "00" + second_sequence.getEncodedHex()
  3638. });
  3639. var seq = new KJUR.asn1.DERSequence({
  3640. array: [first_sequence, bit_string]
  3641. });
  3642. return seq.getEncodedHex();
  3643. };
  3644. JSEncryptRSAKey2.prototype.getPublicBaseKeyB64 = function() {
  3645. return hex2b64(this.getPublicBaseKey());
  3646. };
  3647. JSEncryptRSAKey2.wordwrap = function(str, width) {
  3648. width = width || 64;
  3649. if (!str) {
  3650. return str;
  3651. }
  3652. var regex = "(.{1," + width + "})( +|$\n?)|(.{1," + width + "})";
  3653. return str.match(RegExp(regex, "g")).join("\n");
  3654. };
  3655. JSEncryptRSAKey2.prototype.getPrivateKey = function() {
  3656. var key = "-----BEGIN RSA PRIVATE KEY-----\n";
  3657. key += JSEncryptRSAKey2.wordwrap(this.getPrivateBaseKeyB64()) + "\n";
  3658. key += "-----END RSA PRIVATE KEY-----";
  3659. return key;
  3660. };
  3661. JSEncryptRSAKey2.prototype.getPublicKey = function() {
  3662. var key = "-----BEGIN PUBLIC KEY-----\n";
  3663. key += JSEncryptRSAKey2.wordwrap(this.getPublicBaseKeyB64()) + "\n";
  3664. key += "-----END PUBLIC KEY-----";
  3665. return key;
  3666. };
  3667. JSEncryptRSAKey2.hasPublicKeyProperty = function(obj) {
  3668. obj = obj || {};
  3669. return obj.hasOwnProperty("n") && obj.hasOwnProperty("e");
  3670. };
  3671. JSEncryptRSAKey2.hasPrivateKeyProperty = function(obj) {
  3672. obj = obj || {};
  3673. return obj.hasOwnProperty("n") && obj.hasOwnProperty("e") && obj.hasOwnProperty("d") && obj.hasOwnProperty("p") && obj.hasOwnProperty("q") && obj.hasOwnProperty("dmp1") && obj.hasOwnProperty("dmq1") && obj.hasOwnProperty("coeff");
  3674. };
  3675. JSEncryptRSAKey2.prototype.parsePropertiesFrom = function(obj) {
  3676. this.n = obj.n;
  3677. this.e = obj.e;
  3678. if (obj.hasOwnProperty("d")) {
  3679. this.d = obj.d;
  3680. this.p = obj.p;
  3681. this.q = obj.q;
  3682. this.dmp1 = obj.dmp1;
  3683. this.dmq1 = obj.dmq1;
  3684. this.coeff = obj.coeff;
  3685. }
  3686. };
  3687. return JSEncryptRSAKey2;
  3688. }(RSAKey)
  3689. );
  3690. // ../../../../wpl/hjy/workApp/node_modules/jsencrypt/lib/JSEncrypt.js
  3691. var _a;
  3692. var version = typeof process !== "undefined" ? (_a = process.env) === null || _a === void 0 ? void 0 : _a.npm_package_version : void 0;
  3693. var JSEncrypt = (
  3694. /** @class */
  3695. function() {
  3696. function JSEncrypt2(options) {
  3697. if (options === void 0) {
  3698. options = {};
  3699. }
  3700. options = options || {};
  3701. this.default_key_size = options.default_key_size ? parseInt(options.default_key_size, 10) : 1024;
  3702. this.default_public_exponent = options.default_public_exponent || "010001";
  3703. this.log = options.log || false;
  3704. this.key = null;
  3705. }
  3706. JSEncrypt2.prototype.setKey = function(key) {
  3707. if (this.log && this.key) {
  3708. console.warn("A key was already set, overriding existing.");
  3709. }
  3710. this.key = new JSEncryptRSAKey(key);
  3711. };
  3712. JSEncrypt2.prototype.setPrivateKey = function(privkey) {
  3713. this.setKey(privkey);
  3714. };
  3715. JSEncrypt2.prototype.setPublicKey = function(pubkey) {
  3716. this.setKey(pubkey);
  3717. };
  3718. JSEncrypt2.prototype.decrypt = function(str) {
  3719. try {
  3720. return this.getKey().decrypt(b64tohex(str));
  3721. } catch (ex) {
  3722. return false;
  3723. }
  3724. };
  3725. JSEncrypt2.prototype.encrypt = function(str) {
  3726. try {
  3727. return hex2b64(this.getKey().encrypt(str));
  3728. } catch (ex) {
  3729. return false;
  3730. }
  3731. };
  3732. JSEncrypt2.prototype.sign = function(str, digestMethod, digestName) {
  3733. try {
  3734. return hex2b64(this.getKey().sign(str, digestMethod, digestName));
  3735. } catch (ex) {
  3736. return false;
  3737. }
  3738. };
  3739. JSEncrypt2.prototype.verify = function(str, signature, digestMethod) {
  3740. try {
  3741. return this.getKey().verify(str, b64tohex(signature), digestMethod);
  3742. } catch (ex) {
  3743. return false;
  3744. }
  3745. };
  3746. JSEncrypt2.prototype.getKey = function(cb) {
  3747. if (!this.key) {
  3748. this.key = new JSEncryptRSAKey();
  3749. if (cb && {}.toString.call(cb) === "[object Function]") {
  3750. this.key.generateAsync(this.default_key_size, this.default_public_exponent, cb);
  3751. return;
  3752. }
  3753. this.key.generate(this.default_key_size, this.default_public_exponent);
  3754. }
  3755. return this.key;
  3756. };
  3757. JSEncrypt2.prototype.getPrivateKey = function() {
  3758. return this.getKey().getPrivateKey();
  3759. };
  3760. JSEncrypt2.prototype.getPrivateKeyB64 = function() {
  3761. return this.getKey().getPrivateBaseKeyB64();
  3762. };
  3763. JSEncrypt2.prototype.getPublicKey = function() {
  3764. return this.getKey().getPublicKey();
  3765. };
  3766. JSEncrypt2.prototype.getPublicKeyB64 = function() {
  3767. return this.getKey().getPublicBaseKeyB64();
  3768. };
  3769. JSEncrypt2.version = version;
  3770. return JSEncrypt2;
  3771. }()
  3772. );
  3773. // ../../../../wpl/hjy/workApp/node_modules/jsencrypt/lib/index.js
  3774. var lib_default = JSEncrypt;
  3775. export {
  3776. JSEncrypt,
  3777. lib_default as default
  3778. };
  3779. /*! Bundled license information:
  3780. jsencrypt/lib/lib/jsrsasign/yahoo.js:
  3781. (*!
  3782. Copyright (c) 2011, Yahoo! Inc. All rights reserved.
  3783. Code licensed under the BSD License:
  3784. http://developer.yahoo.com/yui/license.html
  3785. version: 2.9.0
  3786. *)
  3787. jsencrypt/lib/lib/jsrsasign/asn1-1.0.js:
  3788. (**
  3789. * @fileOverview
  3790. * @name asn1-1.0.js
  3791. * @author Kenji Urushima kenji.urushima@gmail.com
  3792. * @version asn1 1.0.13 (2017-Jun-02)
  3793. * @since jsrsasign 2.1
  3794. * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
  3795. *)
  3796. */
  3797. //# sourceMappingURL=jsencrypt.js.map