1 | ;(function (root, factory) {
|
2 | if (typeof exports === "object") {
|
3 |
|
4 | module.exports = exports = factory();
|
5 | }
|
6 | else if (typeof define === "function" && define.amd) {
|
7 |
|
8 | define([], factory);
|
9 | }
|
10 | else {
|
11 |
|
12 | root.CryptoJS = factory();
|
13 | }
|
14 | }(this, function () {
|
15 |
|
16 |
|
17 |
|
18 | |
19 |
|
20 |
|
21 | var CryptoJS = CryptoJS || (function (Math, undefined) {
|
22 |
|
23 | var crypto;
|
24 |
|
25 |
|
26 | if (typeof window !== 'undefined' && window.crypto) {
|
27 | crypto = window.crypto;
|
28 | }
|
29 |
|
30 |
|
31 | if (typeof self !== 'undefined' && self.crypto) {
|
32 | crypto = self.crypto;
|
33 | }
|
34 |
|
35 |
|
36 | if (typeof globalThis !== 'undefined' && globalThis.crypto) {
|
37 | crypto = globalThis.crypto;
|
38 | }
|
39 |
|
40 |
|
41 | if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
|
42 | crypto = window.msCrypto;
|
43 | }
|
44 |
|
45 |
|
46 | if (!crypto && typeof global !== 'undefined' && global.crypto) {
|
47 | crypto = global.crypto;
|
48 | }
|
49 |
|
50 |
|
51 | if (!crypto && typeof require === 'function') {
|
52 | try {
|
53 | crypto = require('crypto');
|
54 | } catch (err) {}
|
55 | }
|
56 |
|
57 | |
58 |
|
59 |
|
60 |
|
61 |
|
62 | var cryptoSecureRandomInt = function () {
|
63 | if (crypto) {
|
64 |
|
65 | if (typeof crypto.getRandomValues === 'function') {
|
66 | try {
|
67 | return crypto.getRandomValues(new Uint32Array(1))[0];
|
68 | } catch (err) {}
|
69 | }
|
70 |
|
71 |
|
72 | if (typeof crypto.randomBytes === 'function') {
|
73 | try {
|
74 | return crypto.randomBytes(4).readInt32LE();
|
75 | } catch (err) {}
|
76 | }
|
77 | }
|
78 |
|
79 | throw new Error('Native crypto module could not be used to get secure random number.');
|
80 | };
|
81 |
|
82 | |
83 |
|
84 |
|
85 |
|
86 | var create = Object.create || (function () {
|
87 | function F() {}
|
88 |
|
89 | return function (obj) {
|
90 | var subtype;
|
91 |
|
92 | F.prototype = obj;
|
93 |
|
94 | subtype = new F();
|
95 |
|
96 | F.prototype = null;
|
97 |
|
98 | return subtype;
|
99 | };
|
100 | }());
|
101 |
|
102 | |
103 |
|
104 |
|
105 | var C = {};
|
106 |
|
107 | |
108 |
|
109 |
|
110 | var C_lib = C.lib = {};
|
111 |
|
112 | |
113 |
|
114 |
|
115 | var Base = C_lib.Base = (function () {
|
116 |
|
117 |
|
118 | return {
|
119 | |
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 | extend: function (overrides) {
|
138 |
|
139 | var subtype = create(this);
|
140 |
|
141 |
|
142 | if (overrides) {
|
143 | subtype.mixIn(overrides);
|
144 | }
|
145 |
|
146 |
|
147 | if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
|
148 | subtype.init = function () {
|
149 | subtype.$super.init.apply(this, arguments);
|
150 | };
|
151 | }
|
152 |
|
153 |
|
154 | subtype.init.prototype = subtype;
|
155 |
|
156 |
|
157 | subtype.$super = this;
|
158 |
|
159 | return subtype;
|
160 | },
|
161 |
|
162 | |
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 | create: function () {
|
175 | var instance = this.extend();
|
176 | instance.init.apply(instance, arguments);
|
177 |
|
178 | return instance;
|
179 | },
|
180 |
|
181 | |
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 | init: function () {
|
194 | },
|
195 |
|
196 | |
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 | mixIn: function (properties) {
|
208 | for (var propertyName in properties) {
|
209 | if (properties.hasOwnProperty(propertyName)) {
|
210 | this[propertyName] = properties[propertyName];
|
211 | }
|
212 | }
|
213 |
|
214 |
|
215 | if (properties.hasOwnProperty('toString')) {
|
216 | this.toString = properties.toString;
|
217 | }
|
218 | },
|
219 |
|
220 | |
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 | clone: function () {
|
230 | return this.init.prototype.extend(this);
|
231 | }
|
232 | };
|
233 | }());
|
234 |
|
235 | |
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 | var WordArray = C_lib.WordArray = Base.extend({
|
242 | |
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 | init: function (words, sigBytes) {
|
255 | words = this.words = words || [];
|
256 |
|
257 | if (sigBytes != undefined) {
|
258 | this.sigBytes = sigBytes;
|
259 | } else {
|
260 | this.sigBytes = words.length * 4;
|
261 | }
|
262 | },
|
263 |
|
264 | |
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 | toString: function (encoder) {
|
278 | return (encoder || Hex).stringify(this);
|
279 | },
|
280 |
|
281 | |
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 | concat: function (wordArray) {
|
293 |
|
294 | var thisWords = this.words;
|
295 | var thatWords = wordArray.words;
|
296 | var thisSigBytes = this.sigBytes;
|
297 | var thatSigBytes = wordArray.sigBytes;
|
298 |
|
299 |
|
300 | this.clamp();
|
301 |
|
302 |
|
303 | if (thisSigBytes % 4) {
|
304 |
|
305 | for (var i = 0; i < thatSigBytes; i++) {
|
306 | var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
307 | thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
|
308 | }
|
309 | } else {
|
310 |
|
311 | for (var j = 0; j < thatSigBytes; j += 4) {
|
312 | thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];
|
313 | }
|
314 | }
|
315 | this.sigBytes += thatSigBytes;
|
316 |
|
317 |
|
318 | return this;
|
319 | },
|
320 |
|
321 | |
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 | clamp: function () {
|
329 |
|
330 | var words = this.words;
|
331 | var sigBytes = this.sigBytes;
|
332 |
|
333 |
|
334 | words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
|
335 | words.length = Math.ceil(sigBytes / 4);
|
336 | },
|
337 |
|
338 | |
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 | clone: function () {
|
348 | var clone = Base.clone.call(this);
|
349 | clone.words = this.words.slice(0);
|
350 |
|
351 | return clone;
|
352 | },
|
353 |
|
354 | |
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 | random: function (nBytes) {
|
368 | var words = [];
|
369 |
|
370 | for (var i = 0; i < nBytes; i += 4) {
|
371 | words.push(cryptoSecureRandomInt());
|
372 | }
|
373 |
|
374 | return new WordArray.init(words, nBytes);
|
375 | }
|
376 | });
|
377 |
|
378 | |
379 |
|
380 |
|
381 | var C_enc = C.enc = {};
|
382 |
|
383 | |
384 |
|
385 |
|
386 | var Hex = C_enc.Hex = {
|
387 | |
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 | stringify: function (wordArray) {
|
401 |
|
402 | var words = wordArray.words;
|
403 | var sigBytes = wordArray.sigBytes;
|
404 |
|
405 |
|
406 | var hexChars = [];
|
407 | for (var i = 0; i < sigBytes; i++) {
|
408 | var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
409 | hexChars.push((bite >>> 4).toString(16));
|
410 | hexChars.push((bite & 0x0f).toString(16));
|
411 | }
|
412 |
|
413 | return hexChars.join('');
|
414 | },
|
415 |
|
416 | |
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 | parse: function (hexStr) {
|
430 |
|
431 | var hexStrLength = hexStr.length;
|
432 |
|
433 |
|
434 | var words = [];
|
435 | for (var i = 0; i < hexStrLength; i += 2) {
|
436 | words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
|
437 | }
|
438 |
|
439 | return new WordArray.init(words, hexStrLength / 2);
|
440 | }
|
441 | };
|
442 |
|
443 | |
444 |
|
445 |
|
446 | var Latin1 = C_enc.Latin1 = {
|
447 | |
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 | stringify: function (wordArray) {
|
461 |
|
462 | var words = wordArray.words;
|
463 | var sigBytes = wordArray.sigBytes;
|
464 |
|
465 |
|
466 | var latin1Chars = [];
|
467 | for (var i = 0; i < sigBytes; i++) {
|
468 | var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
469 | latin1Chars.push(String.fromCharCode(bite));
|
470 | }
|
471 |
|
472 | return latin1Chars.join('');
|
473 | },
|
474 |
|
475 | |
476 |
|
477 |
|
478 |
|
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 | parse: function (latin1Str) {
|
489 |
|
490 | var latin1StrLength = latin1Str.length;
|
491 |
|
492 |
|
493 | var words = [];
|
494 | for (var i = 0; i < latin1StrLength; i++) {
|
495 | words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
|
496 | }
|
497 |
|
498 | return new WordArray.init(words, latin1StrLength);
|
499 | }
|
500 | };
|
501 |
|
502 | |
503 |
|
504 |
|
505 | var Utf8 = C_enc.Utf8 = {
|
506 | |
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 | stringify: function (wordArray) {
|
520 | try {
|
521 | return decodeURIComponent(escape(Latin1.stringify(wordArray)));
|
522 | } catch (e) {
|
523 | throw new Error('Malformed UTF-8 data');
|
524 | }
|
525 | },
|
526 |
|
527 | |
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 |
|
538 |
|
539 |
|
540 | parse: function (utf8Str) {
|
541 | return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
|
542 | }
|
543 | };
|
544 |
|
545 | |
546 |
|
547 |
|
548 |
|
549 |
|
550 |
|
551 |
|
552 | var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
|
553 | |
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 | reset: function () {
|
561 |
|
562 | this._data = new WordArray.init();
|
563 | this._nDataBytes = 0;
|
564 | },
|
565 |
|
566 | |
567 |
|
568 |
|
569 |
|
570 |
|
571 |
|
572 |
|
573 |
|
574 |
|
575 |
|
576 | _append: function (data) {
|
577 |
|
578 | if (typeof data == 'string') {
|
579 | data = Utf8.parse(data);
|
580 | }
|
581 |
|
582 |
|
583 | this._data.concat(data);
|
584 | this._nDataBytes += data.sigBytes;
|
585 | },
|
586 |
|
587 | |
588 |
|
589 |
|
590 |
|
591 |
|
592 |
|
593 |
|
594 |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 | _process: function (doFlush) {
|
602 | var processedWords;
|
603 |
|
604 |
|
605 | var data = this._data;
|
606 | var dataWords = data.words;
|
607 | var dataSigBytes = data.sigBytes;
|
608 | var blockSize = this.blockSize;
|
609 | var blockSizeBytes = blockSize * 4;
|
610 |
|
611 |
|
612 | var nBlocksReady = dataSigBytes / blockSizeBytes;
|
613 | if (doFlush) {
|
614 |
|
615 | nBlocksReady = Math.ceil(nBlocksReady);
|
616 | } else {
|
617 |
|
618 |
|
619 | nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
|
620 | }
|
621 |
|
622 |
|
623 | var nWordsReady = nBlocksReady * blockSize;
|
624 |
|
625 |
|
626 | var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
|
627 |
|
628 |
|
629 | if (nWordsReady) {
|
630 | for (var offset = 0; offset < nWordsReady; offset += blockSize) {
|
631 |
|
632 | this._doProcessBlock(dataWords, offset);
|
633 | }
|
634 |
|
635 |
|
636 | processedWords = dataWords.splice(0, nWordsReady);
|
637 | data.sigBytes -= nBytesReady;
|
638 | }
|
639 |
|
640 |
|
641 | return new WordArray.init(processedWords, nBytesReady);
|
642 | },
|
643 |
|
644 | |
645 |
|
646 |
|
647 |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 | clone: function () {
|
654 | var clone = Base.clone.call(this);
|
655 | clone._data = this._data.clone();
|
656 |
|
657 | return clone;
|
658 | },
|
659 |
|
660 | _minBufferSize: 0
|
661 | });
|
662 |
|
663 | |
664 |
|
665 |
|
666 |
|
667 |
|
668 | var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
|
669 | |
670 |
|
671 |
|
672 | cfg: Base.extend(),
|
673 |
|
674 | |
675 |
|
676 |
|
677 |
|
678 |
|
679 |
|
680 |
|
681 |
|
682 |
|
683 | init: function (cfg) {
|
684 |
|
685 | this.cfg = this.cfg.extend(cfg);
|
686 |
|
687 |
|
688 | this.reset();
|
689 | },
|
690 |
|
691 | |
692 |
|
693 |
|
694 |
|
695 |
|
696 |
|
697 |
|
698 | reset: function () {
|
699 |
|
700 | BufferedBlockAlgorithm.reset.call(this);
|
701 |
|
702 |
|
703 | this._doReset();
|
704 | },
|
705 |
|
706 | |
707 |
|
708 |
|
709 |
|
710 |
|
711 |
|
712 |
|
713 |
|
714 |
|
715 |
|
716 |
|
717 |
|
718 | update: function (messageUpdate) {
|
719 |
|
720 | this._append(messageUpdate);
|
721 |
|
722 |
|
723 | this._process();
|
724 |
|
725 |
|
726 | return this;
|
727 | },
|
728 |
|
729 | |
730 |
|
731 |
|
732 |
|
733 |
|
734 |
|
735 |
|
736 |
|
737 |
|
738 |
|
739 |
|
740 |
|
741 |
|
742 |
|
743 | finalize: function (messageUpdate) {
|
744 |
|
745 | if (messageUpdate) {
|
746 | this._append(messageUpdate);
|
747 | }
|
748 |
|
749 |
|
750 | var hash = this._doFinalize();
|
751 |
|
752 | return hash;
|
753 | },
|
754 |
|
755 | blockSize: 512/32,
|
756 |
|
757 | |
758 |
|
759 |
|
760 |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 |
|
766 |
|
767 |
|
768 |
|
769 |
|
770 | _createHelper: function (hasher) {
|
771 | return function (message, cfg) {
|
772 | return new hasher.init(cfg).finalize(message);
|
773 | };
|
774 | },
|
775 |
|
776 | |
777 |
|
778 |
|
779 |
|
780 |
|
781 |
|
782 |
|
783 |
|
784 |
|
785 |
|
786 |
|
787 |
|
788 |
|
789 | _createHmacHelper: function (hasher) {
|
790 | return function (message, key) {
|
791 | return new C_algo.HMAC.init(hasher, key).finalize(message);
|
792 | };
|
793 | }
|
794 | });
|
795 |
|
796 | |
797 |
|
798 |
|
799 | var C_algo = C.algo = {};
|
800 |
|
801 | return C;
|
802 | }(Math));
|
803 |
|
804 |
|
805 | (function (undefined) {
|
806 |
|
807 | var C = CryptoJS;
|
808 | var C_lib = C.lib;
|
809 | var Base = C_lib.Base;
|
810 | var X32WordArray = C_lib.WordArray;
|
811 |
|
812 | |
813 |
|
814 |
|
815 | var C_x64 = C.x64 = {};
|
816 |
|
817 | |
818 |
|
819 |
|
820 | var X64Word = C_x64.Word = Base.extend({
|
821 | |
822 |
|
823 |
|
824 |
|
825 |
|
826 |
|
827 |
|
828 |
|
829 |
|
830 |
|
831 | init: function (high, low) {
|
832 | this.high = high;
|
833 | this.low = low;
|
834 | }
|
835 |
|
836 | |
837 |
|
838 |
|
839 |
|
840 |
|
841 |
|
842 |
|
843 |
|
844 |
|
845 |
|
846 |
|
847 |
|
848 |
|
849 |
|
850 |
|
851 |
|
852 | |
853 |
|
854 |
|
855 |
|
856 |
|
857 |
|
858 |
|
859 |
|
860 |
|
861 |
|
862 |
|
863 |
|
864 |
|
865 |
|
866 |
|
867 |
|
868 |
|
869 |
|
870 | |
871 |
|
872 |
|
873 |
|
874 |
|
875 |
|
876 |
|
877 |
|
878 |
|
879 |
|
880 |
|
881 |
|
882 |
|
883 |
|
884 |
|
885 |
|
886 |
|
887 |
|
888 | |
889 |
|
890 |
|
891 |
|
892 |
|
893 |
|
894 |
|
895 |
|
896 |
|
897 |
|
898 |
|
899 |
|
900 |
|
901 |
|
902 |
|
903 |
|
904 |
|
905 |
|
906 | |
907 |
|
908 |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 |
|
914 |
|
915 |
|
916 |
|
917 |
|
918 |
|
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 | |
930 |
|
931 |
|
932 |
|
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
940 |
|
941 |
|
942 |
|
943 |
|
944 |
|
945 |
|
946 |
|
947 |
|
948 |
|
949 |
|
950 |
|
951 |
|
952 | |
953 |
|
954 |
|
955 |
|
956 |
|
957 |
|
958 |
|
959 |
|
960 |
|
961 |
|
962 |
|
963 |
|
964 |
|
965 |
|
966 |
|
967 | |
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 |
|
974 |
|
975 |
|
976 |
|
977 |
|
978 |
|
979 |
|
980 |
|
981 |
|
982 | |
983 |
|
984 |
|
985 |
|
986 |
|
987 |
|
988 |
|
989 |
|
990 |
|
991 |
|
992 |
|
993 |
|
994 |
|
995 |
|
996 |
|
997 |
|
998 |
|
999 |
|
1000 | });
|
1001 |
|
1002 | |
1003 |
|
1004 |
|
1005 |
|
1006 |
|
1007 |
|
1008 | var X64WordArray = C_x64.WordArray = Base.extend({
|
1009 | |
1010 |
|
1011 |
|
1012 |
|
1013 |
|
1014 |
|
1015 |
|
1016 |
|
1017 |
|
1018 |
|
1019 |
|
1020 |
|
1021 |
|
1022 |
|
1023 |
|
1024 |
|
1025 |
|
1026 |
|
1027 |
|
1028 |
|
1029 | init: function (words, sigBytes) {
|
1030 | words = this.words = words || [];
|
1031 |
|
1032 | if (sigBytes != undefined) {
|
1033 | this.sigBytes = sigBytes;
|
1034 | } else {
|
1035 | this.sigBytes = words.length * 8;
|
1036 | }
|
1037 | },
|
1038 |
|
1039 | |
1040 |
|
1041 |
|
1042 |
|
1043 |
|
1044 |
|
1045 |
|
1046 |
|
1047 |
|
1048 | toX32: function () {
|
1049 |
|
1050 | var x64Words = this.words;
|
1051 | var x64WordsLength = x64Words.length;
|
1052 |
|
1053 |
|
1054 | var x32Words = [];
|
1055 | for (var i = 0; i < x64WordsLength; i++) {
|
1056 | var x64Word = x64Words[i];
|
1057 | x32Words.push(x64Word.high);
|
1058 | x32Words.push(x64Word.low);
|
1059 | }
|
1060 |
|
1061 | return X32WordArray.create(x32Words, this.sigBytes);
|
1062 | },
|
1063 |
|
1064 | |
1065 |
|
1066 |
|
1067 |
|
1068 |
|
1069 |
|
1070 |
|
1071 |
|
1072 |
|
1073 | clone: function () {
|
1074 | var clone = Base.clone.call(this);
|
1075 |
|
1076 |
|
1077 | var words = clone.words = this.words.slice(0);
|
1078 |
|
1079 |
|
1080 | var wordsLength = words.length;
|
1081 | for (var i = 0; i < wordsLength; i++) {
|
1082 | words[i] = words[i].clone();
|
1083 | }
|
1084 |
|
1085 | return clone;
|
1086 | }
|
1087 | });
|
1088 | }());
|
1089 |
|
1090 |
|
1091 | (function () {
|
1092 |
|
1093 | if (typeof ArrayBuffer != 'function') {
|
1094 | return;
|
1095 | }
|
1096 |
|
1097 |
|
1098 | var C = CryptoJS;
|
1099 | var C_lib = C.lib;
|
1100 | var WordArray = C_lib.WordArray;
|
1101 |
|
1102 |
|
1103 | var superInit = WordArray.init;
|
1104 |
|
1105 |
|
1106 | var subInit = WordArray.init = function (typedArray) {
|
1107 |
|
1108 | if (typedArray instanceof ArrayBuffer) {
|
1109 | typedArray = new Uint8Array(typedArray);
|
1110 | }
|
1111 |
|
1112 |
|
1113 | if (
|
1114 | typedArray instanceof Int8Array ||
|
1115 | (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) ||
|
1116 | typedArray instanceof Int16Array ||
|
1117 | typedArray instanceof Uint16Array ||
|
1118 | typedArray instanceof Int32Array ||
|
1119 | typedArray instanceof Uint32Array ||
|
1120 | typedArray instanceof Float32Array ||
|
1121 | typedArray instanceof Float64Array
|
1122 | ) {
|
1123 | typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
|
1124 | }
|
1125 |
|
1126 |
|
1127 | if (typedArray instanceof Uint8Array) {
|
1128 |
|
1129 | var typedArrayByteLength = typedArray.byteLength;
|
1130 |
|
1131 |
|
1132 | var words = [];
|
1133 | for (var i = 0; i < typedArrayByteLength; i++) {
|
1134 | words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
|
1135 | }
|
1136 |
|
1137 |
|
1138 | superInit.call(this, words, typedArrayByteLength);
|
1139 | } else {
|
1140 |
|
1141 | superInit.apply(this, arguments);
|
1142 | }
|
1143 | };
|
1144 |
|
1145 | subInit.prototype = WordArray;
|
1146 | }());
|
1147 |
|
1148 |
|
1149 | (function () {
|
1150 |
|
1151 | var C = CryptoJS;
|
1152 | var C_lib = C.lib;
|
1153 | var WordArray = C_lib.WordArray;
|
1154 | var C_enc = C.enc;
|
1155 |
|
1156 | |
1157 |
|
1158 |
|
1159 | var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
|
1160 | |
1161 |
|
1162 |
|
1163 |
|
1164 |
|
1165 |
|
1166 |
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 | stringify: function (wordArray) {
|
1174 |
|
1175 | var words = wordArray.words;
|
1176 | var sigBytes = wordArray.sigBytes;
|
1177 |
|
1178 |
|
1179 | var utf16Chars = [];
|
1180 | for (var i = 0; i < sigBytes; i += 2) {
|
1181 | var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
|
1182 | utf16Chars.push(String.fromCharCode(codePoint));
|
1183 | }
|
1184 |
|
1185 | return utf16Chars.join('');
|
1186 | },
|
1187 |
|
1188 | |
1189 |
|
1190 |
|
1191 |
|
1192 |
|
1193 |
|
1194 |
|
1195 |
|
1196 |
|
1197 |
|
1198 |
|
1199 |
|
1200 |
|
1201 | parse: function (utf16Str) {
|
1202 |
|
1203 | var utf16StrLength = utf16Str.length;
|
1204 |
|
1205 |
|
1206 | var words = [];
|
1207 | for (var i = 0; i < utf16StrLength; i++) {
|
1208 | words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
|
1209 | }
|
1210 |
|
1211 | return WordArray.create(words, utf16StrLength * 2);
|
1212 | }
|
1213 | };
|
1214 |
|
1215 | |
1216 |
|
1217 |
|
1218 | C_enc.Utf16LE = {
|
1219 | |
1220 |
|
1221 |
|
1222 |
|
1223 |
|
1224 |
|
1225 |
|
1226 |
|
1227 |
|
1228 |
|
1229 |
|
1230 |
|
1231 |
|
1232 | stringify: function (wordArray) {
|
1233 |
|
1234 | var words = wordArray.words;
|
1235 | var sigBytes = wordArray.sigBytes;
|
1236 |
|
1237 |
|
1238 | var utf16Chars = [];
|
1239 | for (var i = 0; i < sigBytes; i += 2) {
|
1240 | var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
|
1241 | utf16Chars.push(String.fromCharCode(codePoint));
|
1242 | }
|
1243 |
|
1244 | return utf16Chars.join('');
|
1245 | },
|
1246 |
|
1247 | |
1248 |
|
1249 |
|
1250 |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 |
|
1256 |
|
1257 |
|
1258 |
|
1259 |
|
1260 | parse: function (utf16Str) {
|
1261 |
|
1262 | var utf16StrLength = utf16Str.length;
|
1263 |
|
1264 |
|
1265 | var words = [];
|
1266 | for (var i = 0; i < utf16StrLength; i++) {
|
1267 | words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
|
1268 | }
|
1269 |
|
1270 | return WordArray.create(words, utf16StrLength * 2);
|
1271 | }
|
1272 | };
|
1273 |
|
1274 | function swapEndian(word) {
|
1275 | return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
|
1276 | }
|
1277 | }());
|
1278 |
|
1279 |
|
1280 | (function () {
|
1281 |
|
1282 | var C = CryptoJS;
|
1283 | var C_lib = C.lib;
|
1284 | var WordArray = C_lib.WordArray;
|
1285 | var C_enc = C.enc;
|
1286 |
|
1287 | |
1288 |
|
1289 |
|
1290 | var Base64 = C_enc.Base64 = {
|
1291 | |
1292 |
|
1293 |
|
1294 |
|
1295 |
|
1296 |
|
1297 |
|
1298 |
|
1299 |
|
1300 |
|
1301 |
|
1302 |
|
1303 |
|
1304 | stringify: function (wordArray) {
|
1305 |
|
1306 | var words = wordArray.words;
|
1307 | var sigBytes = wordArray.sigBytes;
|
1308 | var map = this._map;
|
1309 |
|
1310 |
|
1311 | wordArray.clamp();
|
1312 |
|
1313 |
|
1314 | var base64Chars = [];
|
1315 | for (var i = 0; i < sigBytes; i += 3) {
|
1316 | var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
1317 | var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
|
1318 | var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
|
1319 |
|
1320 | var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
|
1321 |
|
1322 | for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
|
1323 | base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
|
1324 | }
|
1325 | }
|
1326 |
|
1327 |
|
1328 | var paddingChar = map.charAt(64);
|
1329 | if (paddingChar) {
|
1330 | while (base64Chars.length % 4) {
|
1331 | base64Chars.push(paddingChar);
|
1332 | }
|
1333 | }
|
1334 |
|
1335 | return base64Chars.join('');
|
1336 | },
|
1337 |
|
1338 | |
1339 |
|
1340 |
|
1341 |
|
1342 |
|
1343 |
|
1344 |
|
1345 |
|
1346 |
|
1347 |
|
1348 |
|
1349 |
|
1350 |
|
1351 | parse: function (base64Str) {
|
1352 |
|
1353 | var base64StrLength = base64Str.length;
|
1354 | var map = this._map;
|
1355 | var reverseMap = this._reverseMap;
|
1356 |
|
1357 | if (!reverseMap) {
|
1358 | reverseMap = this._reverseMap = [];
|
1359 | for (var j = 0; j < map.length; j++) {
|
1360 | reverseMap[map.charCodeAt(j)] = j;
|
1361 | }
|
1362 | }
|
1363 |
|
1364 |
|
1365 | var paddingChar = map.charAt(64);
|
1366 | if (paddingChar) {
|
1367 | var paddingIndex = base64Str.indexOf(paddingChar);
|
1368 | if (paddingIndex !== -1) {
|
1369 | base64StrLength = paddingIndex;
|
1370 | }
|
1371 | }
|
1372 |
|
1373 |
|
1374 | return parseLoop(base64Str, base64StrLength, reverseMap);
|
1375 |
|
1376 | },
|
1377 |
|
1378 | _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
|
1379 | };
|
1380 |
|
1381 | function parseLoop(base64Str, base64StrLength, reverseMap) {
|
1382 | var words = [];
|
1383 | var nBytes = 0;
|
1384 | for (var i = 0; i < base64StrLength; i++) {
|
1385 | if (i % 4) {
|
1386 | var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
|
1387 | var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
|
1388 | var bitsCombined = bits1 | bits2;
|
1389 | words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
|
1390 | nBytes++;
|
1391 | }
|
1392 | }
|
1393 | return WordArray.create(words, nBytes);
|
1394 | }
|
1395 | }());
|
1396 |
|
1397 |
|
1398 | (function () {
|
1399 |
|
1400 | var C = CryptoJS;
|
1401 | var C_lib = C.lib;
|
1402 | var WordArray = C_lib.WordArray;
|
1403 | var C_enc = C.enc;
|
1404 |
|
1405 | |
1406 |
|
1407 |
|
1408 | var Base64url = C_enc.Base64url = {
|
1409 | |
1410 |
|
1411 |
|
1412 |
|
1413 |
|
1414 |
|
1415 |
|
1416 |
|
1417 |
|
1418 |
|
1419 |
|
1420 |
|
1421 |
|
1422 |
|
1423 |
|
1424 | stringify: function (wordArray, urlSafe) {
|
1425 | if (urlSafe === undefined) {
|
1426 | urlSafe = true
|
1427 | }
|
1428 |
|
1429 | var words = wordArray.words;
|
1430 | var sigBytes = wordArray.sigBytes;
|
1431 | var map = urlSafe ? this._safe_map : this._map;
|
1432 |
|
1433 |
|
1434 | wordArray.clamp();
|
1435 |
|
1436 |
|
1437 | var base64Chars = [];
|
1438 | for (var i = 0; i < sigBytes; i += 3) {
|
1439 | var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
1440 | var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
|
1441 | var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
|
1442 |
|
1443 | var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
|
1444 |
|
1445 | for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
|
1446 | base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
|
1447 | }
|
1448 | }
|
1449 |
|
1450 |
|
1451 | var paddingChar = map.charAt(64);
|
1452 | if (paddingChar) {
|
1453 | while (base64Chars.length % 4) {
|
1454 | base64Chars.push(paddingChar);
|
1455 | }
|
1456 | }
|
1457 |
|
1458 | return base64Chars.join('');
|
1459 | },
|
1460 |
|
1461 | |
1462 |
|
1463 |
|
1464 |
|
1465 |
|
1466 |
|
1467 |
|
1468 |
|
1469 |
|
1470 |
|
1471 |
|
1472 |
|
1473 |
|
1474 |
|
1475 |
|
1476 | parse: function (base64Str, urlSafe) {
|
1477 | if (urlSafe === undefined) {
|
1478 | urlSafe = true
|
1479 | }
|
1480 |
|
1481 |
|
1482 | var base64StrLength = base64Str.length;
|
1483 | var map = urlSafe ? this._safe_map : this._map;
|
1484 | var reverseMap = this._reverseMap;
|
1485 |
|
1486 | if (!reverseMap) {
|
1487 | reverseMap = this._reverseMap = [];
|
1488 | for (var j = 0; j < map.length; j++) {
|
1489 | reverseMap[map.charCodeAt(j)] = j;
|
1490 | }
|
1491 | }
|
1492 |
|
1493 |
|
1494 | var paddingChar = map.charAt(64);
|
1495 | if (paddingChar) {
|
1496 | var paddingIndex = base64Str.indexOf(paddingChar);
|
1497 | if (paddingIndex !== -1) {
|
1498 | base64StrLength = paddingIndex;
|
1499 | }
|
1500 | }
|
1501 |
|
1502 |
|
1503 | return parseLoop(base64Str, base64StrLength, reverseMap);
|
1504 |
|
1505 | },
|
1506 |
|
1507 | _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
|
1508 | _safe_map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
|
1509 | };
|
1510 |
|
1511 | function parseLoop(base64Str, base64StrLength, reverseMap) {
|
1512 | var words = [];
|
1513 | var nBytes = 0;
|
1514 | for (var i = 0; i < base64StrLength; i++) {
|
1515 | if (i % 4) {
|
1516 | var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
|
1517 | var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
|
1518 | var bitsCombined = bits1 | bits2;
|
1519 | words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
|
1520 | nBytes++;
|
1521 | }
|
1522 | }
|
1523 | return WordArray.create(words, nBytes);
|
1524 | }
|
1525 | }());
|
1526 |
|
1527 |
|
1528 | (function (Math) {
|
1529 |
|
1530 | var C = CryptoJS;
|
1531 | var C_lib = C.lib;
|
1532 | var WordArray = C_lib.WordArray;
|
1533 | var Hasher = C_lib.Hasher;
|
1534 | var C_algo = C.algo;
|
1535 |
|
1536 |
|
1537 | var T = [];
|
1538 |
|
1539 |
|
1540 | (function () {
|
1541 | for (var i = 0; i < 64; i++) {
|
1542 | T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
|
1543 | }
|
1544 | }());
|
1545 |
|
1546 | |
1547 |
|
1548 |
|
1549 | var MD5 = C_algo.MD5 = Hasher.extend({
|
1550 | _doReset: function () {
|
1551 | this._hash = new WordArray.init([
|
1552 | 0x67452301, 0xefcdab89,
|
1553 | 0x98badcfe, 0x10325476
|
1554 | ]);
|
1555 | },
|
1556 |
|
1557 | _doProcessBlock: function (M, offset) {
|
1558 |
|
1559 | for (var i = 0; i < 16; i++) {
|
1560 |
|
1561 | var offset_i = offset + i;
|
1562 | var M_offset_i = M[offset_i];
|
1563 |
|
1564 | M[offset_i] = (
|
1565 | (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
|
1566 | (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
|
1567 | );
|
1568 | }
|
1569 |
|
1570 |
|
1571 | var H = this._hash.words;
|
1572 |
|
1573 | var M_offset_0 = M[offset + 0];
|
1574 | var M_offset_1 = M[offset + 1];
|
1575 | var M_offset_2 = M[offset + 2];
|
1576 | var M_offset_3 = M[offset + 3];
|
1577 | var M_offset_4 = M[offset + 4];
|
1578 | var M_offset_5 = M[offset + 5];
|
1579 | var M_offset_6 = M[offset + 6];
|
1580 | var M_offset_7 = M[offset + 7];
|
1581 | var M_offset_8 = M[offset + 8];
|
1582 | var M_offset_9 = M[offset + 9];
|
1583 | var M_offset_10 = M[offset + 10];
|
1584 | var M_offset_11 = M[offset + 11];
|
1585 | var M_offset_12 = M[offset + 12];
|
1586 | var M_offset_13 = M[offset + 13];
|
1587 | var M_offset_14 = M[offset + 14];
|
1588 | var M_offset_15 = M[offset + 15];
|
1589 |
|
1590 |
|
1591 | var a = H[0];
|
1592 | var b = H[1];
|
1593 | var c = H[2];
|
1594 | var d = H[3];
|
1595 |
|
1596 |
|
1597 | a = FF(a, b, c, d, M_offset_0, 7, T[0]);
|
1598 | d = FF(d, a, b, c, M_offset_1, 12, T[1]);
|
1599 | c = FF(c, d, a, b, M_offset_2, 17, T[2]);
|
1600 | b = FF(b, c, d, a, M_offset_3, 22, T[3]);
|
1601 | a = FF(a, b, c, d, M_offset_4, 7, T[4]);
|
1602 | d = FF(d, a, b, c, M_offset_5, 12, T[5]);
|
1603 | c = FF(c, d, a, b, M_offset_6, 17, T[6]);
|
1604 | b = FF(b, c, d, a, M_offset_7, 22, T[7]);
|
1605 | a = FF(a, b, c, d, M_offset_8, 7, T[8]);
|
1606 | d = FF(d, a, b, c, M_offset_9, 12, T[9]);
|
1607 | c = FF(c, d, a, b, M_offset_10, 17, T[10]);
|
1608 | b = FF(b, c, d, a, M_offset_11, 22, T[11]);
|
1609 | a = FF(a, b, c, d, M_offset_12, 7, T[12]);
|
1610 | d = FF(d, a, b, c, M_offset_13, 12, T[13]);
|
1611 | c = FF(c, d, a, b, M_offset_14, 17, T[14]);
|
1612 | b = FF(b, c, d, a, M_offset_15, 22, T[15]);
|
1613 |
|
1614 | a = GG(a, b, c, d, M_offset_1, 5, T[16]);
|
1615 | d = GG(d, a, b, c, M_offset_6, 9, T[17]);
|
1616 | c = GG(c, d, a, b, M_offset_11, 14, T[18]);
|
1617 | b = GG(b, c, d, a, M_offset_0, 20, T[19]);
|
1618 | a = GG(a, b, c, d, M_offset_5, 5, T[20]);
|
1619 | d = GG(d, a, b, c, M_offset_10, 9, T[21]);
|
1620 | c = GG(c, d, a, b, M_offset_15, 14, T[22]);
|
1621 | b = GG(b, c, d, a, M_offset_4, 20, T[23]);
|
1622 | a = GG(a, b, c, d, M_offset_9, 5, T[24]);
|
1623 | d = GG(d, a, b, c, M_offset_14, 9, T[25]);
|
1624 | c = GG(c, d, a, b, M_offset_3, 14, T[26]);
|
1625 | b = GG(b, c, d, a, M_offset_8, 20, T[27]);
|
1626 | a = GG(a, b, c, d, M_offset_13, 5, T[28]);
|
1627 | d = GG(d, a, b, c, M_offset_2, 9, T[29]);
|
1628 | c = GG(c, d, a, b, M_offset_7, 14, T[30]);
|
1629 | b = GG(b, c, d, a, M_offset_12, 20, T[31]);
|
1630 |
|
1631 | a = HH(a, b, c, d, M_offset_5, 4, T[32]);
|
1632 | d = HH(d, a, b, c, M_offset_8, 11, T[33]);
|
1633 | c = HH(c, d, a, b, M_offset_11, 16, T[34]);
|
1634 | b = HH(b, c, d, a, M_offset_14, 23, T[35]);
|
1635 | a = HH(a, b, c, d, M_offset_1, 4, T[36]);
|
1636 | d = HH(d, a, b, c, M_offset_4, 11, T[37]);
|
1637 | c = HH(c, d, a, b, M_offset_7, 16, T[38]);
|
1638 | b = HH(b, c, d, a, M_offset_10, 23, T[39]);
|
1639 | a = HH(a, b, c, d, M_offset_13, 4, T[40]);
|
1640 | d = HH(d, a, b, c, M_offset_0, 11, T[41]);
|
1641 | c = HH(c, d, a, b, M_offset_3, 16, T[42]);
|
1642 | b = HH(b, c, d, a, M_offset_6, 23, T[43]);
|
1643 | a = HH(a, b, c, d, M_offset_9, 4, T[44]);
|
1644 | d = HH(d, a, b, c, M_offset_12, 11, T[45]);
|
1645 | c = HH(c, d, a, b, M_offset_15, 16, T[46]);
|
1646 | b = HH(b, c, d, a, M_offset_2, 23, T[47]);
|
1647 |
|
1648 | a = II(a, b, c, d, M_offset_0, 6, T[48]);
|
1649 | d = II(d, a, b, c, M_offset_7, 10, T[49]);
|
1650 | c = II(c, d, a, b, M_offset_14, 15, T[50]);
|
1651 | b = II(b, c, d, a, M_offset_5, 21, T[51]);
|
1652 | a = II(a, b, c, d, M_offset_12, 6, T[52]);
|
1653 | d = II(d, a, b, c, M_offset_3, 10, T[53]);
|
1654 | c = II(c, d, a, b, M_offset_10, 15, T[54]);
|
1655 | b = II(b, c, d, a, M_offset_1, 21, T[55]);
|
1656 | a = II(a, b, c, d, M_offset_8, 6, T[56]);
|
1657 | d = II(d, a, b, c, M_offset_15, 10, T[57]);
|
1658 | c = II(c, d, a, b, M_offset_6, 15, T[58]);
|
1659 | b = II(b, c, d, a, M_offset_13, 21, T[59]);
|
1660 | a = II(a, b, c, d, M_offset_4, 6, T[60]);
|
1661 | d = II(d, a, b, c, M_offset_11, 10, T[61]);
|
1662 | c = II(c, d, a, b, M_offset_2, 15, T[62]);
|
1663 | b = II(b, c, d, a, M_offset_9, 21, T[63]);
|
1664 |
|
1665 |
|
1666 | H[0] = (H[0] + a) | 0;
|
1667 | H[1] = (H[1] + b) | 0;
|
1668 | H[2] = (H[2] + c) | 0;
|
1669 | H[3] = (H[3] + d) | 0;
|
1670 | },
|
1671 |
|
1672 | _doFinalize: function () {
|
1673 |
|
1674 | var data = this._data;
|
1675 | var dataWords = data.words;
|
1676 |
|
1677 | var nBitsTotal = this._nDataBytes * 8;
|
1678 | var nBitsLeft = data.sigBytes * 8;
|
1679 |
|
1680 |
|
1681 | dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
1682 |
|
1683 | var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
|
1684 | var nBitsTotalL = nBitsTotal;
|
1685 | dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
|
1686 | (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
|
1687 | (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
|
1688 | );
|
1689 | dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
|
1690 | (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
|
1691 | (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
|
1692 | );
|
1693 |
|
1694 | data.sigBytes = (dataWords.length + 1) * 4;
|
1695 |
|
1696 |
|
1697 | this._process();
|
1698 |
|
1699 |
|
1700 | var hash = this._hash;
|
1701 | var H = hash.words;
|
1702 |
|
1703 |
|
1704 | for (var i = 0; i < 4; i++) {
|
1705 |
|
1706 | var H_i = H[i];
|
1707 |
|
1708 | H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
|
1709 | (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
|
1710 | }
|
1711 |
|
1712 |
|
1713 | return hash;
|
1714 | },
|
1715 |
|
1716 | clone: function () {
|
1717 | var clone = Hasher.clone.call(this);
|
1718 | clone._hash = this._hash.clone();
|
1719 |
|
1720 | return clone;
|
1721 | }
|
1722 | });
|
1723 |
|
1724 | function FF(a, b, c, d, x, s, t) {
|
1725 | var n = a + ((b & c) | (~b & d)) + x + t;
|
1726 | return ((n << s) | (n >>> (32 - s))) + b;
|
1727 | }
|
1728 |
|
1729 | function GG(a, b, c, d, x, s, t) {
|
1730 | var n = a + ((b & d) | (c & ~d)) + x + t;
|
1731 | return ((n << s) | (n >>> (32 - s))) + b;
|
1732 | }
|
1733 |
|
1734 | function HH(a, b, c, d, x, s, t) {
|
1735 | var n = a + (b ^ c ^ d) + x + t;
|
1736 | return ((n << s) | (n >>> (32 - s))) + b;
|
1737 | }
|
1738 |
|
1739 | function II(a, b, c, d, x, s, t) {
|
1740 | var n = a + (c ^ (b | ~d)) + x + t;
|
1741 | return ((n << s) | (n >>> (32 - s))) + b;
|
1742 | }
|
1743 |
|
1744 | |
1745 |
|
1746 |
|
1747 |
|
1748 |
|
1749 |
|
1750 |
|
1751 |
|
1752 |
|
1753 |
|
1754 |
|
1755 |
|
1756 |
|
1757 |
|
1758 | C.MD5 = Hasher._createHelper(MD5);
|
1759 |
|
1760 | |
1761 |
|
1762 |
|
1763 |
|
1764 |
|
1765 |
|
1766 |
|
1767 |
|
1768 |
|
1769 |
|
1770 |
|
1771 |
|
1772 |
|
1773 |
|
1774 | C.HmacMD5 = Hasher._createHmacHelper(MD5);
|
1775 | }(Math));
|
1776 |
|
1777 |
|
1778 | (function () {
|
1779 |
|
1780 | var C = CryptoJS;
|
1781 | var C_lib = C.lib;
|
1782 | var WordArray = C_lib.WordArray;
|
1783 | var Hasher = C_lib.Hasher;
|
1784 | var C_algo = C.algo;
|
1785 |
|
1786 |
|
1787 | var W = [];
|
1788 |
|
1789 | |
1790 |
|
1791 |
|
1792 | var SHA1 = C_algo.SHA1 = Hasher.extend({
|
1793 | _doReset: function () {
|
1794 | this._hash = new WordArray.init([
|
1795 | 0x67452301, 0xefcdab89,
|
1796 | 0x98badcfe, 0x10325476,
|
1797 | 0xc3d2e1f0
|
1798 | ]);
|
1799 | },
|
1800 |
|
1801 | _doProcessBlock: function (M, offset) {
|
1802 |
|
1803 | var H = this._hash.words;
|
1804 |
|
1805 |
|
1806 | var a = H[0];
|
1807 | var b = H[1];
|
1808 | var c = H[2];
|
1809 | var d = H[3];
|
1810 | var e = H[4];
|
1811 |
|
1812 |
|
1813 | for (var i = 0; i < 80; i++) {
|
1814 | if (i < 16) {
|
1815 | W[i] = M[offset + i] | 0;
|
1816 | } else {
|
1817 | var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
|
1818 | W[i] = (n << 1) | (n >>> 31);
|
1819 | }
|
1820 |
|
1821 | var t = ((a << 5) | (a >>> 27)) + e + W[i];
|
1822 | if (i < 20) {
|
1823 | t += ((b & c) | (~b & d)) + 0x5a827999;
|
1824 | } else if (i < 40) {
|
1825 | t += (b ^ c ^ d) + 0x6ed9eba1;
|
1826 | } else if (i < 60) {
|
1827 | t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
|
1828 | } else {
|
1829 | t += (b ^ c ^ d) - 0x359d3e2a;
|
1830 | }
|
1831 |
|
1832 | e = d;
|
1833 | d = c;
|
1834 | c = (b << 30) | (b >>> 2);
|
1835 | b = a;
|
1836 | a = t;
|
1837 | }
|
1838 |
|
1839 |
|
1840 | H[0] = (H[0] + a) | 0;
|
1841 | H[1] = (H[1] + b) | 0;
|
1842 | H[2] = (H[2] + c) | 0;
|
1843 | H[3] = (H[3] + d) | 0;
|
1844 | H[4] = (H[4] + e) | 0;
|
1845 | },
|
1846 |
|
1847 | _doFinalize: function () {
|
1848 |
|
1849 | var data = this._data;
|
1850 | var dataWords = data.words;
|
1851 |
|
1852 | var nBitsTotal = this._nDataBytes * 8;
|
1853 | var nBitsLeft = data.sigBytes * 8;
|
1854 |
|
1855 |
|
1856 | dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
1857 | dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
|
1858 | dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
|
1859 | data.sigBytes = dataWords.length * 4;
|
1860 |
|
1861 |
|
1862 | this._process();
|
1863 |
|
1864 |
|
1865 | return this._hash;
|
1866 | },
|
1867 |
|
1868 | clone: function () {
|
1869 | var clone = Hasher.clone.call(this);
|
1870 | clone._hash = this._hash.clone();
|
1871 |
|
1872 | return clone;
|
1873 | }
|
1874 | });
|
1875 |
|
1876 | |
1877 |
|
1878 |
|
1879 |
|
1880 |
|
1881 |
|
1882 |
|
1883 |
|
1884 |
|
1885 |
|
1886 |
|
1887 |
|
1888 |
|
1889 |
|
1890 | C.SHA1 = Hasher._createHelper(SHA1);
|
1891 |
|
1892 | |
1893 |
|
1894 |
|
1895 |
|
1896 |
|
1897 |
|
1898 |
|
1899 |
|
1900 |
|
1901 |
|
1902 |
|
1903 |
|
1904 |
|
1905 |
|
1906 | C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
|
1907 | }());
|
1908 |
|
1909 |
|
1910 | (function (Math) {
|
1911 |
|
1912 | var C = CryptoJS;
|
1913 | var C_lib = C.lib;
|
1914 | var WordArray = C_lib.WordArray;
|
1915 | var Hasher = C_lib.Hasher;
|
1916 | var C_algo = C.algo;
|
1917 |
|
1918 |
|
1919 | var H = [];
|
1920 | var K = [];
|
1921 |
|
1922 |
|
1923 | (function () {
|
1924 | function isPrime(n) {
|
1925 | var sqrtN = Math.sqrt(n);
|
1926 | for (var factor = 2; factor <= sqrtN; factor++) {
|
1927 | if (!(n % factor)) {
|
1928 | return false;
|
1929 | }
|
1930 | }
|
1931 |
|
1932 | return true;
|
1933 | }
|
1934 |
|
1935 | function getFractionalBits(n) {
|
1936 | return ((n - (n | 0)) * 0x100000000) | 0;
|
1937 | }
|
1938 |
|
1939 | var n = 2;
|
1940 | var nPrime = 0;
|
1941 | while (nPrime < 64) {
|
1942 | if (isPrime(n)) {
|
1943 | if (nPrime < 8) {
|
1944 | H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
|
1945 | }
|
1946 | K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
|
1947 |
|
1948 | nPrime++;
|
1949 | }
|
1950 |
|
1951 | n++;
|
1952 | }
|
1953 | }());
|
1954 |
|
1955 |
|
1956 | var W = [];
|
1957 |
|
1958 | |
1959 |
|
1960 |
|
1961 | var SHA256 = C_algo.SHA256 = Hasher.extend({
|
1962 | _doReset: function () {
|
1963 | this._hash = new WordArray.init(H.slice(0));
|
1964 | },
|
1965 |
|
1966 | _doProcessBlock: function (M, offset) {
|
1967 |
|
1968 | var H = this._hash.words;
|
1969 |
|
1970 |
|
1971 | var a = H[0];
|
1972 | var b = H[1];
|
1973 | var c = H[2];
|
1974 | var d = H[3];
|
1975 | var e = H[4];
|
1976 | var f = H[5];
|
1977 | var g = H[6];
|
1978 | var h = H[7];
|
1979 |
|
1980 |
|
1981 | for (var i = 0; i < 64; i++) {
|
1982 | if (i < 16) {
|
1983 | W[i] = M[offset + i] | 0;
|
1984 | } else {
|
1985 | var gamma0x = W[i - 15];
|
1986 | var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
|
1987 | ((gamma0x << 14) | (gamma0x >>> 18)) ^
|
1988 | (gamma0x >>> 3);
|
1989 |
|
1990 | var gamma1x = W[i - 2];
|
1991 | var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
|
1992 | ((gamma1x << 13) | (gamma1x >>> 19)) ^
|
1993 | (gamma1x >>> 10);
|
1994 |
|
1995 | W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
|
1996 | }
|
1997 |
|
1998 | var ch = (e & f) ^ (~e & g);
|
1999 | var maj = (a & b) ^ (a & c) ^ (b & c);
|
2000 |
|
2001 | var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
|
2002 | var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
|
2003 |
|
2004 | var t1 = h + sigma1 + ch + K[i] + W[i];
|
2005 | var t2 = sigma0 + maj;
|
2006 |
|
2007 | h = g;
|
2008 | g = f;
|
2009 | f = e;
|
2010 | e = (d + t1) | 0;
|
2011 | d = c;
|
2012 | c = b;
|
2013 | b = a;
|
2014 | a = (t1 + t2) | 0;
|
2015 | }
|
2016 |
|
2017 |
|
2018 | H[0] = (H[0] + a) | 0;
|
2019 | H[1] = (H[1] + b) | 0;
|
2020 | H[2] = (H[2] + c) | 0;
|
2021 | H[3] = (H[3] + d) | 0;
|
2022 | H[4] = (H[4] + e) | 0;
|
2023 | H[5] = (H[5] + f) | 0;
|
2024 | H[6] = (H[6] + g) | 0;
|
2025 | H[7] = (H[7] + h) | 0;
|
2026 | },
|
2027 |
|
2028 | _doFinalize: function () {
|
2029 |
|
2030 | var data = this._data;
|
2031 | var dataWords = data.words;
|
2032 |
|
2033 | var nBitsTotal = this._nDataBytes * 8;
|
2034 | var nBitsLeft = data.sigBytes * 8;
|
2035 |
|
2036 |
|
2037 | dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
2038 | dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
|
2039 | dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
|
2040 | data.sigBytes = dataWords.length * 4;
|
2041 |
|
2042 |
|
2043 | this._process();
|
2044 |
|
2045 |
|
2046 | return this._hash;
|
2047 | },
|
2048 |
|
2049 | clone: function () {
|
2050 | var clone = Hasher.clone.call(this);
|
2051 | clone._hash = this._hash.clone();
|
2052 |
|
2053 | return clone;
|
2054 | }
|
2055 | });
|
2056 |
|
2057 | |
2058 |
|
2059 |
|
2060 |
|
2061 |
|
2062 |
|
2063 |
|
2064 |
|
2065 |
|
2066 |
|
2067 |
|
2068 |
|
2069 |
|
2070 |
|
2071 | C.SHA256 = Hasher._createHelper(SHA256);
|
2072 |
|
2073 | |
2074 |
|
2075 |
|
2076 |
|
2077 |
|
2078 |
|
2079 |
|
2080 |
|
2081 |
|
2082 |
|
2083 |
|
2084 |
|
2085 |
|
2086 |
|
2087 | C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
|
2088 | }(Math));
|
2089 |
|
2090 |
|
2091 | (function () {
|
2092 |
|
2093 | var C = CryptoJS;
|
2094 | var C_lib = C.lib;
|
2095 | var WordArray = C_lib.WordArray;
|
2096 | var C_algo = C.algo;
|
2097 | var SHA256 = C_algo.SHA256;
|
2098 |
|
2099 | |
2100 |
|
2101 |
|
2102 | var SHA224 = C_algo.SHA224 = SHA256.extend({
|
2103 | _doReset: function () {
|
2104 | this._hash = new WordArray.init([
|
2105 | 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
|
2106 | 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
|
2107 | ]);
|
2108 | },
|
2109 |
|
2110 | _doFinalize: function () {
|
2111 | var hash = SHA256._doFinalize.call(this);
|
2112 |
|
2113 | hash.sigBytes -= 4;
|
2114 |
|
2115 | return hash;
|
2116 | }
|
2117 | });
|
2118 |
|
2119 | |
2120 |
|
2121 |
|
2122 |
|
2123 |
|
2124 |
|
2125 |
|
2126 |
|
2127 |
|
2128 |
|
2129 |
|
2130 |
|
2131 |
|
2132 |
|
2133 | C.SHA224 = SHA256._createHelper(SHA224);
|
2134 |
|
2135 | |
2136 |
|
2137 |
|
2138 |
|
2139 |
|
2140 |
|
2141 |
|
2142 |
|
2143 |
|
2144 |
|
2145 |
|
2146 |
|
2147 |
|
2148 |
|
2149 | C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
|
2150 | }());
|
2151 |
|
2152 |
|
2153 | (function () {
|
2154 |
|
2155 | var C = CryptoJS;
|
2156 | var C_lib = C.lib;
|
2157 | var Hasher = C_lib.Hasher;
|
2158 | var C_x64 = C.x64;
|
2159 | var X64Word = C_x64.Word;
|
2160 | var X64WordArray = C_x64.WordArray;
|
2161 | var C_algo = C.algo;
|
2162 |
|
2163 | function X64Word_create() {
|
2164 | return X64Word.create.apply(X64Word, arguments);
|
2165 | }
|
2166 |
|
2167 |
|
2168 | var K = [
|
2169 | X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
|
2170 | X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
|
2171 | X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
|
2172 | X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
|
2173 | X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
|
2174 | X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
|
2175 | X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
|
2176 | X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
|
2177 | X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
|
2178 | X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
|
2179 | X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
|
2180 | X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
|
2181 | X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
|
2182 | X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
|
2183 | X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
|
2184 | X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
|
2185 | X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
|
2186 | X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
|
2187 | X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
|
2188 | X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
|
2189 | X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
|
2190 | X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
|
2191 | X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
|
2192 | X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
|
2193 | X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
|
2194 | X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
|
2195 | X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
|
2196 | X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
|
2197 | X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
|
2198 | X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
|
2199 | X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
|
2200 | X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
|
2201 | X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
|
2202 | X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
|
2203 | X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
|
2204 | X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
|
2205 | X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
|
2206 | X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
|
2207 | X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
|
2208 | X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
|
2209 | ];
|
2210 |
|
2211 |
|
2212 | var W = [];
|
2213 | (function () {
|
2214 | for (var i = 0; i < 80; i++) {
|
2215 | W[i] = X64Word_create();
|
2216 | }
|
2217 | }());
|
2218 |
|
2219 | |
2220 |
|
2221 |
|
2222 | var SHA512 = C_algo.SHA512 = Hasher.extend({
|
2223 | _doReset: function () {
|
2224 | this._hash = new X64WordArray.init([
|
2225 | new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
|
2226 | new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
|
2227 | new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
|
2228 | new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
|
2229 | ]);
|
2230 | },
|
2231 |
|
2232 | _doProcessBlock: function (M, offset) {
|
2233 |
|
2234 | var H = this._hash.words;
|
2235 |
|
2236 | var H0 = H[0];
|
2237 | var H1 = H[1];
|
2238 | var H2 = H[2];
|
2239 | var H3 = H[3];
|
2240 | var H4 = H[4];
|
2241 | var H5 = H[5];
|
2242 | var H6 = H[6];
|
2243 | var H7 = H[7];
|
2244 |
|
2245 | var H0h = H0.high;
|
2246 | var H0l = H0.low;
|
2247 | var H1h = H1.high;
|
2248 | var H1l = H1.low;
|
2249 | var H2h = H2.high;
|
2250 | var H2l = H2.low;
|
2251 | var H3h = H3.high;
|
2252 | var H3l = H3.low;
|
2253 | var H4h = H4.high;
|
2254 | var H4l = H4.low;
|
2255 | var H5h = H5.high;
|
2256 | var H5l = H5.low;
|
2257 | var H6h = H6.high;
|
2258 | var H6l = H6.low;
|
2259 | var H7h = H7.high;
|
2260 | var H7l = H7.low;
|
2261 |
|
2262 |
|
2263 | var ah = H0h;
|
2264 | var al = H0l;
|
2265 | var bh = H1h;
|
2266 | var bl = H1l;
|
2267 | var ch = H2h;
|
2268 | var cl = H2l;
|
2269 | var dh = H3h;
|
2270 | var dl = H3l;
|
2271 | var eh = H4h;
|
2272 | var el = H4l;
|
2273 | var fh = H5h;
|
2274 | var fl = H5l;
|
2275 | var gh = H6h;
|
2276 | var gl = H6l;
|
2277 | var hh = H7h;
|
2278 | var hl = H7l;
|
2279 |
|
2280 |
|
2281 | for (var i = 0; i < 80; i++) {
|
2282 | var Wil;
|
2283 | var Wih;
|
2284 |
|
2285 |
|
2286 | var Wi = W[i];
|
2287 |
|
2288 |
|
2289 | if (i < 16) {
|
2290 | Wih = Wi.high = M[offset + i * 2] | 0;
|
2291 | Wil = Wi.low = M[offset + i * 2 + 1] | 0;
|
2292 | } else {
|
2293 |
|
2294 | var gamma0x = W[i - 15];
|
2295 | var gamma0xh = gamma0x.high;
|
2296 | var gamma0xl = gamma0x.low;
|
2297 | var gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
|
2298 | var gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
|
2299 |
|
2300 |
|
2301 | var gamma1x = W[i - 2];
|
2302 | var gamma1xh = gamma1x.high;
|
2303 | var gamma1xl = gamma1x.low;
|
2304 | var gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
|
2305 | var gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
|
2306 |
|
2307 |
|
2308 | var Wi7 = W[i - 7];
|
2309 | var Wi7h = Wi7.high;
|
2310 | var Wi7l = Wi7.low;
|
2311 |
|
2312 | var Wi16 = W[i - 16];
|
2313 | var Wi16h = Wi16.high;
|
2314 | var Wi16l = Wi16.low;
|
2315 |
|
2316 | Wil = gamma0l + Wi7l;
|
2317 | Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
|
2318 | Wil = Wil + gamma1l;
|
2319 | Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
|
2320 | Wil = Wil + Wi16l;
|
2321 | Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
|
2322 |
|
2323 | Wi.high = Wih;
|
2324 | Wi.low = Wil;
|
2325 | }
|
2326 |
|
2327 | var chh = (eh & fh) ^ (~eh & gh);
|
2328 | var chl = (el & fl) ^ (~el & gl);
|
2329 | var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
|
2330 | var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
|
2331 |
|
2332 | var sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
|
2333 | var sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
|
2334 | var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
|
2335 | var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
|
2336 |
|
2337 |
|
2338 | var Ki = K[i];
|
2339 | var Kih = Ki.high;
|
2340 | var Kil = Ki.low;
|
2341 |
|
2342 | var t1l = hl + sigma1l;
|
2343 | var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
|
2344 | var t1l = t1l + chl;
|
2345 | var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
|
2346 | var t1l = t1l + Kil;
|
2347 | var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
|
2348 | var t1l = t1l + Wil;
|
2349 | var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
|
2350 |
|
2351 |
|
2352 | var t2l = sigma0l + majl;
|
2353 | var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
|
2354 |
|
2355 |
|
2356 | hh = gh;
|
2357 | hl = gl;
|
2358 | gh = fh;
|
2359 | gl = fl;
|
2360 | fh = eh;
|
2361 | fl = el;
|
2362 | el = (dl + t1l) | 0;
|
2363 | eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
|
2364 | dh = ch;
|
2365 | dl = cl;
|
2366 | ch = bh;
|
2367 | cl = bl;
|
2368 | bh = ah;
|
2369 | bl = al;
|
2370 | al = (t1l + t2l) | 0;
|
2371 | ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
|
2372 | }
|
2373 |
|
2374 |
|
2375 | H0l = H0.low = (H0l + al);
|
2376 | H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
|
2377 | H1l = H1.low = (H1l + bl);
|
2378 | H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
|
2379 | H2l = H2.low = (H2l + cl);
|
2380 | H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
|
2381 | H3l = H3.low = (H3l + dl);
|
2382 | H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
|
2383 | H4l = H4.low = (H4l + el);
|
2384 | H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
|
2385 | H5l = H5.low = (H5l + fl);
|
2386 | H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
|
2387 | H6l = H6.low = (H6l + gl);
|
2388 | H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
|
2389 | H7l = H7.low = (H7l + hl);
|
2390 | H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
|
2391 | },
|
2392 |
|
2393 | _doFinalize: function () {
|
2394 |
|
2395 | var data = this._data;
|
2396 | var dataWords = data.words;
|
2397 |
|
2398 | var nBitsTotal = this._nDataBytes * 8;
|
2399 | var nBitsLeft = data.sigBytes * 8;
|
2400 |
|
2401 |
|
2402 | dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
2403 | dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
|
2404 | dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
|
2405 | data.sigBytes = dataWords.length * 4;
|
2406 |
|
2407 |
|
2408 | this._process();
|
2409 |
|
2410 |
|
2411 | var hash = this._hash.toX32();
|
2412 |
|
2413 |
|
2414 | return hash;
|
2415 | },
|
2416 |
|
2417 | clone: function () {
|
2418 | var clone = Hasher.clone.call(this);
|
2419 | clone._hash = this._hash.clone();
|
2420 |
|
2421 | return clone;
|
2422 | },
|
2423 |
|
2424 | blockSize: 1024/32
|
2425 | });
|
2426 |
|
2427 | |
2428 |
|
2429 |
|
2430 |
|
2431 |
|
2432 |
|
2433 |
|
2434 |
|
2435 |
|
2436 |
|
2437 |
|
2438 |
|
2439 |
|
2440 |
|
2441 | C.SHA512 = Hasher._createHelper(SHA512);
|
2442 |
|
2443 | |
2444 |
|
2445 |
|
2446 |
|
2447 |
|
2448 |
|
2449 |
|
2450 |
|
2451 |
|
2452 |
|
2453 |
|
2454 |
|
2455 |
|
2456 |
|
2457 | C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
|
2458 | }());
|
2459 |
|
2460 |
|
2461 | (function () {
|
2462 |
|
2463 | var C = CryptoJS;
|
2464 | var C_x64 = C.x64;
|
2465 | var X64Word = C_x64.Word;
|
2466 | var X64WordArray = C_x64.WordArray;
|
2467 | var C_algo = C.algo;
|
2468 | var SHA512 = C_algo.SHA512;
|
2469 |
|
2470 | |
2471 |
|
2472 |
|
2473 | var SHA384 = C_algo.SHA384 = SHA512.extend({
|
2474 | _doReset: function () {
|
2475 | this._hash = new X64WordArray.init([
|
2476 | new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
|
2477 | new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
|
2478 | new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
|
2479 | new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
|
2480 | ]);
|
2481 | },
|
2482 |
|
2483 | _doFinalize: function () {
|
2484 | var hash = SHA512._doFinalize.call(this);
|
2485 |
|
2486 | hash.sigBytes -= 16;
|
2487 |
|
2488 | return hash;
|
2489 | }
|
2490 | });
|
2491 |
|
2492 | |
2493 |
|
2494 |
|
2495 |
|
2496 |
|
2497 |
|
2498 |
|
2499 |
|
2500 |
|
2501 |
|
2502 |
|
2503 |
|
2504 |
|
2505 |
|
2506 | C.SHA384 = SHA512._createHelper(SHA384);
|
2507 |
|
2508 | |
2509 |
|
2510 |
|
2511 |
|
2512 |
|
2513 |
|
2514 |
|
2515 |
|
2516 |
|
2517 |
|
2518 |
|
2519 |
|
2520 |
|
2521 |
|
2522 | C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
|
2523 | }());
|
2524 |
|
2525 |
|
2526 | (function (Math) {
|
2527 |
|
2528 | var C = CryptoJS;
|
2529 | var C_lib = C.lib;
|
2530 | var WordArray = C_lib.WordArray;
|
2531 | var Hasher = C_lib.Hasher;
|
2532 | var C_x64 = C.x64;
|
2533 | var X64Word = C_x64.Word;
|
2534 | var C_algo = C.algo;
|
2535 |
|
2536 |
|
2537 | var RHO_OFFSETS = [];
|
2538 | var PI_INDEXES = [];
|
2539 | var ROUND_CONSTANTS = [];
|
2540 |
|
2541 |
|
2542 | (function () {
|
2543 |
|
2544 | var x = 1, y = 0;
|
2545 | for (var t = 0; t < 24; t++) {
|
2546 | RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
|
2547 |
|
2548 | var newX = y % 5;
|
2549 | var newY = (2 * x + 3 * y) % 5;
|
2550 | x = newX;
|
2551 | y = newY;
|
2552 | }
|
2553 |
|
2554 |
|
2555 | for (var x = 0; x < 5; x++) {
|
2556 | for (var y = 0; y < 5; y++) {
|
2557 | PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
|
2558 | }
|
2559 | }
|
2560 |
|
2561 |
|
2562 | var LFSR = 0x01;
|
2563 | for (var i = 0; i < 24; i++) {
|
2564 | var roundConstantMsw = 0;
|
2565 | var roundConstantLsw = 0;
|
2566 |
|
2567 | for (var j = 0; j < 7; j++) {
|
2568 | if (LFSR & 0x01) {
|
2569 | var bitPosition = (1 << j) - 1;
|
2570 | if (bitPosition < 32) {
|
2571 | roundConstantLsw ^= 1 << bitPosition;
|
2572 | } else {
|
2573 | roundConstantMsw ^= 1 << (bitPosition - 32);
|
2574 | }
|
2575 | }
|
2576 |
|
2577 |
|
2578 | if (LFSR & 0x80) {
|
2579 |
|
2580 | LFSR = (LFSR << 1) ^ 0x71;
|
2581 | } else {
|
2582 | LFSR <<= 1;
|
2583 | }
|
2584 | }
|
2585 |
|
2586 | ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
|
2587 | }
|
2588 | }());
|
2589 |
|
2590 |
|
2591 | var T = [];
|
2592 | (function () {
|
2593 | for (var i = 0; i < 25; i++) {
|
2594 | T[i] = X64Word.create();
|
2595 | }
|
2596 | }());
|
2597 |
|
2598 | |
2599 |
|
2600 |
|
2601 | var SHA3 = C_algo.SHA3 = Hasher.extend({
|
2602 | |
2603 |
|
2604 |
|
2605 |
|
2606 |
|
2607 |
|
2608 |
|
2609 |
|
2610 | cfg: Hasher.cfg.extend({
|
2611 | outputLength: 512
|
2612 | }),
|
2613 |
|
2614 | _doReset: function () {
|
2615 | var state = this._state = []
|
2616 | for (var i = 0; i < 25; i++) {
|
2617 | state[i] = new X64Word.init();
|
2618 | }
|
2619 |
|
2620 | this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
|
2621 | },
|
2622 |
|
2623 | _doProcessBlock: function (M, offset) {
|
2624 |
|
2625 | var state = this._state;
|
2626 | var nBlockSizeLanes = this.blockSize / 2;
|
2627 |
|
2628 |
|
2629 | for (var i = 0; i < nBlockSizeLanes; i++) {
|
2630 |
|
2631 | var M2i = M[offset + 2 * i];
|
2632 | var M2i1 = M[offset + 2 * i + 1];
|
2633 |
|
2634 |
|
2635 | M2i = (
|
2636 | (((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) |
|
2637 | (((M2i << 24) | (M2i >>> 8)) & 0xff00ff00)
|
2638 | );
|
2639 | M2i1 = (
|
2640 | (((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) |
|
2641 | (((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00)
|
2642 | );
|
2643 |
|
2644 |
|
2645 | var lane = state[i];
|
2646 | lane.high ^= M2i1;
|
2647 | lane.low ^= M2i;
|
2648 | }
|
2649 |
|
2650 |
|
2651 | for (var round = 0; round < 24; round++) {
|
2652 |
|
2653 | for (var x = 0; x < 5; x++) {
|
2654 |
|
2655 | var tMsw = 0, tLsw = 0;
|
2656 | for (var y = 0; y < 5; y++) {
|
2657 | var lane = state[x + 5 * y];
|
2658 | tMsw ^= lane.high;
|
2659 | tLsw ^= lane.low;
|
2660 | }
|
2661 |
|
2662 |
|
2663 | var Tx = T[x];
|
2664 | Tx.high = tMsw;
|
2665 | Tx.low = tLsw;
|
2666 | }
|
2667 | for (var x = 0; x < 5; x++) {
|
2668 |
|
2669 | var Tx4 = T[(x + 4) % 5];
|
2670 | var Tx1 = T[(x + 1) % 5];
|
2671 | var Tx1Msw = Tx1.high;
|
2672 | var Tx1Lsw = Tx1.low;
|
2673 |
|
2674 |
|
2675 | var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
|
2676 | var tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
|
2677 | for (var y = 0; y < 5; y++) {
|
2678 | var lane = state[x + 5 * y];
|
2679 | lane.high ^= tMsw;
|
2680 | lane.low ^= tLsw;
|
2681 | }
|
2682 | }
|
2683 |
|
2684 |
|
2685 | for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
|
2686 | var tMsw;
|
2687 | var tLsw;
|
2688 |
|
2689 |
|
2690 | var lane = state[laneIndex];
|
2691 | var laneMsw = lane.high;
|
2692 | var laneLsw = lane.low;
|
2693 | var rhoOffset = RHO_OFFSETS[laneIndex];
|
2694 |
|
2695 |
|
2696 | if (rhoOffset < 32) {
|
2697 | tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
|
2698 | tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
|
2699 | } else {
|
2700 | tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
|
2701 | tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
|
2702 | }
|
2703 |
|
2704 |
|
2705 | var TPiLane = T[PI_INDEXES[laneIndex]];
|
2706 | TPiLane.high = tMsw;
|
2707 | TPiLane.low = tLsw;
|
2708 | }
|
2709 |
|
2710 |
|
2711 | var T0 = T[0];
|
2712 | var state0 = state[0];
|
2713 | T0.high = state0.high;
|
2714 | T0.low = state0.low;
|
2715 |
|
2716 |
|
2717 | for (var x = 0; x < 5; x++) {
|
2718 | for (var y = 0; y < 5; y++) {
|
2719 |
|
2720 | var laneIndex = x + 5 * y;
|
2721 | var lane = state[laneIndex];
|
2722 | var TLane = T[laneIndex];
|
2723 | var Tx1Lane = T[((x + 1) % 5) + 5 * y];
|
2724 | var Tx2Lane = T[((x + 2) % 5) + 5 * y];
|
2725 |
|
2726 |
|
2727 | lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
|
2728 | lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low);
|
2729 | }
|
2730 | }
|
2731 |
|
2732 |
|
2733 | var lane = state[0];
|
2734 | var roundConstant = ROUND_CONSTANTS[round];
|
2735 | lane.high ^= roundConstant.high;
|
2736 | lane.low ^= roundConstant.low;
|
2737 | }
|
2738 | },
|
2739 |
|
2740 | _doFinalize: function () {
|
2741 |
|
2742 | var data = this._data;
|
2743 | var dataWords = data.words;
|
2744 | var nBitsTotal = this._nDataBytes * 8;
|
2745 | var nBitsLeft = data.sigBytes * 8;
|
2746 | var blockSizeBits = this.blockSize * 32;
|
2747 |
|
2748 |
|
2749 | dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
|
2750 | dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
|
2751 | data.sigBytes = dataWords.length * 4;
|
2752 |
|
2753 |
|
2754 | this._process();
|
2755 |
|
2756 |
|
2757 | var state = this._state;
|
2758 | var outputLengthBytes = this.cfg.outputLength / 8;
|
2759 | var outputLengthLanes = outputLengthBytes / 8;
|
2760 |
|
2761 |
|
2762 | var hashWords = [];
|
2763 | for (var i = 0; i < outputLengthLanes; i++) {
|
2764 |
|
2765 | var lane = state[i];
|
2766 | var laneMsw = lane.high;
|
2767 | var laneLsw = lane.low;
|
2768 |
|
2769 |
|
2770 | laneMsw = (
|
2771 | (((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) |
|
2772 | (((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00)
|
2773 | );
|
2774 | laneLsw = (
|
2775 | (((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) |
|
2776 | (((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00)
|
2777 | );
|
2778 |
|
2779 |
|
2780 | hashWords.push(laneLsw);
|
2781 | hashWords.push(laneMsw);
|
2782 | }
|
2783 |
|
2784 |
|
2785 | return new WordArray.init(hashWords, outputLengthBytes);
|
2786 | },
|
2787 |
|
2788 | clone: function () {
|
2789 | var clone = Hasher.clone.call(this);
|
2790 |
|
2791 | var state = clone._state = this._state.slice(0);
|
2792 | for (var i = 0; i < 25; i++) {
|
2793 | state[i] = state[i].clone();
|
2794 | }
|
2795 |
|
2796 | return clone;
|
2797 | }
|
2798 | });
|
2799 |
|
2800 | |
2801 |
|
2802 |
|
2803 |
|
2804 |
|
2805 |
|
2806 |
|
2807 |
|
2808 |
|
2809 |
|
2810 |
|
2811 |
|
2812 |
|
2813 |
|
2814 | C.SHA3 = Hasher._createHelper(SHA3);
|
2815 |
|
2816 | |
2817 |
|
2818 |
|
2819 |
|
2820 |
|
2821 |
|
2822 |
|
2823 |
|
2824 |
|
2825 |
|
2826 |
|
2827 |
|
2828 |
|
2829 |
|
2830 | C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
|
2831 | }(Math));
|
2832 |
|
2833 |
|
2834 | |
2835 |
|
2836 |
|
2837 |
|
2838 |
|
2839 |
|
2840 |
|
2841 |
|
2842 |
|
2843 |
|
2844 |
|
2845 | (function (Math) {
|
2846 |
|
2847 | var C = CryptoJS;
|
2848 | var C_lib = C.lib;
|
2849 | var WordArray = C_lib.WordArray;
|
2850 | var Hasher = C_lib.Hasher;
|
2851 | var C_algo = C.algo;
|
2852 |
|
2853 |
|
2854 | var _zl = WordArray.create([
|
2855 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
2856 | 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
|
2857 | 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
|
2858 | 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
|
2859 | 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]);
|
2860 | var _zr = WordArray.create([
|
2861 | 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
|
2862 | 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
|
2863 | 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
|
2864 | 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
|
2865 | 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]);
|
2866 | var _sl = WordArray.create([
|
2867 | 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
|
2868 | 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
|
2869 | 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
|
2870 | 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
|
2871 | 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]);
|
2872 | var _sr = WordArray.create([
|
2873 | 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
|
2874 | 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
|
2875 | 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
|
2876 | 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
|
2877 | 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]);
|
2878 |
|
2879 | var _hl = WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
|
2880 | var _hr = WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
|
2881 |
|
2882 | |
2883 |
|
2884 |
|
2885 | var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
|
2886 | _doReset: function () {
|
2887 | this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
|
2888 | },
|
2889 |
|
2890 | _doProcessBlock: function (M, offset) {
|
2891 |
|
2892 |
|
2893 | for (var i = 0; i < 16; i++) {
|
2894 |
|
2895 | var offset_i = offset + i;
|
2896 | var M_offset_i = M[offset_i];
|
2897 |
|
2898 |
|
2899 | M[offset_i] = (
|
2900 | (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
|
2901 | (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
|
2902 | );
|
2903 | }
|
2904 |
|
2905 | var H = this._hash.words;
|
2906 | var hl = _hl.words;
|
2907 | var hr = _hr.words;
|
2908 | var zl = _zl.words;
|
2909 | var zr = _zr.words;
|
2910 | var sl = _sl.words;
|
2911 | var sr = _sr.words;
|
2912 |
|
2913 |
|
2914 | var al, bl, cl, dl, el;
|
2915 | var ar, br, cr, dr, er;
|
2916 |
|
2917 | ar = al = H[0];
|
2918 | br = bl = H[1];
|
2919 | cr = cl = H[2];
|
2920 | dr = dl = H[3];
|
2921 | er = el = H[4];
|
2922 |
|
2923 | var t;
|
2924 | for (var i = 0; i < 80; i += 1) {
|
2925 | t = (al + M[offset+zl[i]])|0;
|
2926 | if (i<16){
|
2927 | t += f1(bl,cl,dl) + hl[0];
|
2928 | } else if (i<32) {
|
2929 | t += f2(bl,cl,dl) + hl[1];
|
2930 | } else if (i<48) {
|
2931 | t += f3(bl,cl,dl) + hl[2];
|
2932 | } else if (i<64) {
|
2933 | t += f4(bl,cl,dl) + hl[3];
|
2934 | } else {
|
2935 | t += f5(bl,cl,dl) + hl[4];
|
2936 | }
|
2937 | t = t|0;
|
2938 | t = rotl(t,sl[i]);
|
2939 | t = (t+el)|0;
|
2940 | al = el;
|
2941 | el = dl;
|
2942 | dl = rotl(cl, 10);
|
2943 | cl = bl;
|
2944 | bl = t;
|
2945 |
|
2946 | t = (ar + M[offset+zr[i]])|0;
|
2947 | if (i<16){
|
2948 | t += f5(br,cr,dr) + hr[0];
|
2949 | } else if (i<32) {
|
2950 | t += f4(br,cr,dr) + hr[1];
|
2951 | } else if (i<48) {
|
2952 | t += f3(br,cr,dr) + hr[2];
|
2953 | } else if (i<64) {
|
2954 | t += f2(br,cr,dr) + hr[3];
|
2955 | } else {
|
2956 | t += f1(br,cr,dr) + hr[4];
|
2957 | }
|
2958 | t = t|0;
|
2959 | t = rotl(t,sr[i]) ;
|
2960 | t = (t+er)|0;
|
2961 | ar = er;
|
2962 | er = dr;
|
2963 | dr = rotl(cr, 10);
|
2964 | cr = br;
|
2965 | br = t;
|
2966 | }
|
2967 |
|
2968 | t = (H[1] + cl + dr)|0;
|
2969 | H[1] = (H[2] + dl + er)|0;
|
2970 | H[2] = (H[3] + el + ar)|0;
|
2971 | H[3] = (H[4] + al + br)|0;
|
2972 | H[4] = (H[0] + bl + cr)|0;
|
2973 | H[0] = t;
|
2974 | },
|
2975 |
|
2976 | _doFinalize: function () {
|
2977 |
|
2978 | var data = this._data;
|
2979 | var dataWords = data.words;
|
2980 |
|
2981 | var nBitsTotal = this._nDataBytes * 8;
|
2982 | var nBitsLeft = data.sigBytes * 8;
|
2983 |
|
2984 |
|
2985 | dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
2986 | dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
|
2987 | (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
|
2988 | (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
|
2989 | );
|
2990 | data.sigBytes = (dataWords.length + 1) * 4;
|
2991 |
|
2992 |
|
2993 | this._process();
|
2994 |
|
2995 |
|
2996 | var hash = this._hash;
|
2997 | var H = hash.words;
|
2998 |
|
2999 |
|
3000 | for (var i = 0; i < 5; i++) {
|
3001 |
|
3002 | var H_i = H[i];
|
3003 |
|
3004 |
|
3005 | H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
|
3006 | (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
|
3007 | }
|
3008 |
|
3009 |
|
3010 | return hash;
|
3011 | },
|
3012 |
|
3013 | clone: function () {
|
3014 | var clone = Hasher.clone.call(this);
|
3015 | clone._hash = this._hash.clone();
|
3016 |
|
3017 | return clone;
|
3018 | }
|
3019 | });
|
3020 |
|
3021 |
|
3022 | function f1(x, y, z) {
|
3023 | return ((x) ^ (y) ^ (z));
|
3024 |
|
3025 | }
|
3026 |
|
3027 | function f2(x, y, z) {
|
3028 | return (((x)&(y)) | ((~x)&(z)));
|
3029 | }
|
3030 |
|
3031 | function f3(x, y, z) {
|
3032 | return (((x) | (~(y))) ^ (z));
|
3033 | }
|
3034 |
|
3035 | function f4(x, y, z) {
|
3036 | return (((x) & (z)) | ((y)&(~(z))));
|
3037 | }
|
3038 |
|
3039 | function f5(x, y, z) {
|
3040 | return ((x) ^ ((y) |(~(z))));
|
3041 |
|
3042 | }
|
3043 |
|
3044 | function rotl(x,n) {
|
3045 | return (x<<n) | (x>>>(32-n));
|
3046 | }
|
3047 |
|
3048 |
|
3049 | |
3050 |
|
3051 |
|
3052 |
|
3053 |
|
3054 |
|
3055 |
|
3056 |
|
3057 |
|
3058 |
|
3059 |
|
3060 |
|
3061 |
|
3062 |
|
3063 | C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
|
3064 |
|
3065 | |
3066 |
|
3067 |
|
3068 |
|
3069 |
|
3070 |
|
3071 |
|
3072 |
|
3073 |
|
3074 |
|
3075 |
|
3076 |
|
3077 |
|
3078 |
|
3079 | C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
|
3080 | }(Math));
|
3081 |
|
3082 |
|
3083 | (function () {
|
3084 |
|
3085 | var C = CryptoJS;
|
3086 | var C_lib = C.lib;
|
3087 | var Base = C_lib.Base;
|
3088 | var C_enc = C.enc;
|
3089 | var Utf8 = C_enc.Utf8;
|
3090 | var C_algo = C.algo;
|
3091 |
|
3092 | |
3093 |
|
3094 |
|
3095 | var HMAC = C_algo.HMAC = Base.extend({
|
3096 | |
3097 |
|
3098 |
|
3099 |
|
3100 |
|
3101 |
|
3102 |
|
3103 |
|
3104 |
|
3105 |
|
3106 | init: function (hasher, key) {
|
3107 |
|
3108 | hasher = this._hasher = new hasher.init();
|
3109 |
|
3110 |
|
3111 | if (typeof key == 'string') {
|
3112 | key = Utf8.parse(key);
|
3113 | }
|
3114 |
|
3115 |
|
3116 | var hasherBlockSize = hasher.blockSize;
|
3117 | var hasherBlockSizeBytes = hasherBlockSize * 4;
|
3118 |
|
3119 |
|
3120 | if (key.sigBytes > hasherBlockSizeBytes) {
|
3121 | key = hasher.finalize(key);
|
3122 | }
|
3123 |
|
3124 |
|
3125 | key.clamp();
|
3126 |
|
3127 |
|
3128 | var oKey = this._oKey = key.clone();
|
3129 | var iKey = this._iKey = key.clone();
|
3130 |
|
3131 |
|
3132 | var oKeyWords = oKey.words;
|
3133 | var iKeyWords = iKey.words;
|
3134 |
|
3135 |
|
3136 | for (var i = 0; i < hasherBlockSize; i++) {
|
3137 | oKeyWords[i] ^= 0x5c5c5c5c;
|
3138 | iKeyWords[i] ^= 0x36363636;
|
3139 | }
|
3140 | oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
|
3141 |
|
3142 |
|
3143 | this.reset();
|
3144 | },
|
3145 |
|
3146 | |
3147 |
|
3148 |
|
3149 |
|
3150 |
|
3151 |
|
3152 |
|
3153 | reset: function () {
|
3154 |
|
3155 | var hasher = this._hasher;
|
3156 |
|
3157 |
|
3158 | hasher.reset();
|
3159 | hasher.update(this._iKey);
|
3160 | },
|
3161 |
|
3162 | |
3163 |
|
3164 |
|
3165 |
|
3166 |
|
3167 |
|
3168 |
|
3169 |
|
3170 |
|
3171 |
|
3172 |
|
3173 |
|
3174 | update: function (messageUpdate) {
|
3175 | this._hasher.update(messageUpdate);
|
3176 |
|
3177 |
|
3178 | return this;
|
3179 | },
|
3180 |
|
3181 | |
3182 |
|
3183 |
|
3184 |
|
3185 |
|
3186 |
|
3187 |
|
3188 |
|
3189 |
|
3190 |
|
3191 |
|
3192 |
|
3193 |
|
3194 |
|
3195 | finalize: function (messageUpdate) {
|
3196 |
|
3197 | var hasher = this._hasher;
|
3198 |
|
3199 |
|
3200 | var innerHash = hasher.finalize(messageUpdate);
|
3201 | hasher.reset();
|
3202 | var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
|
3203 |
|
3204 | return hmac;
|
3205 | }
|
3206 | });
|
3207 | }());
|
3208 |
|
3209 |
|
3210 | (function () {
|
3211 |
|
3212 | var C = CryptoJS;
|
3213 | var C_lib = C.lib;
|
3214 | var Base = C_lib.Base;
|
3215 | var WordArray = C_lib.WordArray;
|
3216 | var C_algo = C.algo;
|
3217 | var SHA256 = C_algo.SHA256;
|
3218 | var HMAC = C_algo.HMAC;
|
3219 |
|
3220 | |
3221 |
|
3222 |
|
3223 | var PBKDF2 = C_algo.PBKDF2 = Base.extend({
|
3224 | |
3225 |
|
3226 |
|
3227 |
|
3228 |
|
3229 |
|
3230 |
|
3231 | cfg: Base.extend({
|
3232 | keySize: 128/32,
|
3233 | hasher: SHA256,
|
3234 | iterations: 250000
|
3235 | }),
|
3236 |
|
3237 | |
3238 |
|
3239 |
|
3240 |
|
3241 |
|
3242 |
|
3243 |
|
3244 |
|
3245 |
|
3246 |
|
3247 |
|
3248 | init: function (cfg) {
|
3249 | this.cfg = this.cfg.extend(cfg);
|
3250 | },
|
3251 |
|
3252 | |
3253 |
|
3254 |
|
3255 |
|
3256 |
|
3257 |
|
3258 |
|
3259 |
|
3260 |
|
3261 |
|
3262 |
|
3263 |
|
3264 | compute: function (password, salt) {
|
3265 |
|
3266 | var cfg = this.cfg;
|
3267 |
|
3268 |
|
3269 | var hmac = HMAC.create(cfg.hasher, password);
|
3270 |
|
3271 |
|
3272 | var derivedKey = WordArray.create();
|
3273 | var blockIndex = WordArray.create([0x00000001]);
|
3274 |
|
3275 |
|
3276 | var derivedKeyWords = derivedKey.words;
|
3277 | var blockIndexWords = blockIndex.words;
|
3278 | var keySize = cfg.keySize;
|
3279 | var iterations = cfg.iterations;
|
3280 |
|
3281 |
|
3282 | while (derivedKeyWords.length < keySize) {
|
3283 | var block = hmac.update(salt).finalize(blockIndex);
|
3284 | hmac.reset();
|
3285 |
|
3286 |
|
3287 | var blockWords = block.words;
|
3288 | var blockWordsLength = blockWords.length;
|
3289 |
|
3290 |
|
3291 | var intermediate = block;
|
3292 | for (var i = 1; i < iterations; i++) {
|
3293 | intermediate = hmac.finalize(intermediate);
|
3294 | hmac.reset();
|
3295 |
|
3296 |
|
3297 | var intermediateWords = intermediate.words;
|
3298 |
|
3299 |
|
3300 | for (var j = 0; j < blockWordsLength; j++) {
|
3301 | blockWords[j] ^= intermediateWords[j];
|
3302 | }
|
3303 | }
|
3304 |
|
3305 | derivedKey.concat(block);
|
3306 | blockIndexWords[0]++;
|
3307 | }
|
3308 | derivedKey.sigBytes = keySize * 4;
|
3309 |
|
3310 | return derivedKey;
|
3311 | }
|
3312 | });
|
3313 |
|
3314 | |
3315 |
|
3316 |
|
3317 |
|
3318 |
|
3319 |
|
3320 |
|
3321 |
|
3322 |
|
3323 |
|
3324 |
|
3325 |
|
3326 |
|
3327 |
|
3328 |
|
3329 |
|
3330 |
|
3331 | C.PBKDF2 = function (password, salt, cfg) {
|
3332 | return PBKDF2.create(cfg).compute(password, salt);
|
3333 | };
|
3334 | }());
|
3335 |
|
3336 |
|
3337 | (function () {
|
3338 |
|
3339 | var C = CryptoJS;
|
3340 | var C_lib = C.lib;
|
3341 | var Base = C_lib.Base;
|
3342 | var WordArray = C_lib.WordArray;
|
3343 | var C_algo = C.algo;
|
3344 | var MD5 = C_algo.MD5;
|
3345 |
|
3346 | |
3347 |
|
3348 |
|
3349 |
|
3350 | var EvpKDF = C_algo.EvpKDF = Base.extend({
|
3351 | |
3352 |
|
3353 |
|
3354 |
|
3355 |
|
3356 |
|
3357 |
|
3358 | cfg: Base.extend({
|
3359 | keySize: 128/32,
|
3360 | hasher: MD5,
|
3361 | iterations: 1
|
3362 | }),
|
3363 |
|
3364 | |
3365 |
|
3366 |
|
3367 |
|
3368 |
|
3369 |
|
3370 |
|
3371 |
|
3372 |
|
3373 |
|
3374 |
|
3375 | init: function (cfg) {
|
3376 | this.cfg = this.cfg.extend(cfg);
|
3377 | },
|
3378 |
|
3379 | |
3380 |
|
3381 |
|
3382 |
|
3383 |
|
3384 |
|
3385 |
|
3386 |
|
3387 |
|
3388 |
|
3389 |
|
3390 |
|
3391 | compute: function (password, salt) {
|
3392 | var block;
|
3393 |
|
3394 |
|
3395 | var cfg = this.cfg;
|
3396 |
|
3397 |
|
3398 | var hasher = cfg.hasher.create();
|
3399 |
|
3400 |
|
3401 | var derivedKey = WordArray.create();
|
3402 |
|
3403 |
|
3404 | var derivedKeyWords = derivedKey.words;
|
3405 | var keySize = cfg.keySize;
|
3406 | var iterations = cfg.iterations;
|
3407 |
|
3408 |
|
3409 | while (derivedKeyWords.length < keySize) {
|
3410 | if (block) {
|
3411 | hasher.update(block);
|
3412 | }
|
3413 | block = hasher.update(password).finalize(salt);
|
3414 | hasher.reset();
|
3415 |
|
3416 |
|
3417 | for (var i = 1; i < iterations; i++) {
|
3418 | block = hasher.finalize(block);
|
3419 | hasher.reset();
|
3420 | }
|
3421 |
|
3422 | derivedKey.concat(block);
|
3423 | }
|
3424 | derivedKey.sigBytes = keySize * 4;
|
3425 |
|
3426 | return derivedKey;
|
3427 | }
|
3428 | });
|
3429 |
|
3430 | |
3431 |
|
3432 |
|
3433 |
|
3434 |
|
3435 |
|
3436 |
|
3437 |
|
3438 |
|
3439 |
|
3440 |
|
3441 |
|
3442 |
|
3443 |
|
3444 |
|
3445 |
|
3446 |
|
3447 | C.EvpKDF = function (password, salt, cfg) {
|
3448 | return EvpKDF.create(cfg).compute(password, salt);
|
3449 | };
|
3450 | }());
|
3451 |
|
3452 |
|
3453 | |
3454 |
|
3455 |
|
3456 | CryptoJS.lib.Cipher || (function (undefined) {
|
3457 |
|
3458 | var C = CryptoJS;
|
3459 | var C_lib = C.lib;
|
3460 | var Base = C_lib.Base;
|
3461 | var WordArray = C_lib.WordArray;
|
3462 | var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
|
3463 | var C_enc = C.enc;
|
3464 | var Utf8 = C_enc.Utf8;
|
3465 | var Base64 = C_enc.Base64;
|
3466 | var C_algo = C.algo;
|
3467 | var EvpKDF = C_algo.EvpKDF;
|
3468 |
|
3469 | |
3470 |
|
3471 |
|
3472 |
|
3473 |
|
3474 |
|
3475 |
|
3476 |
|
3477 | var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
|
3478 | |
3479 |
|
3480 |
|
3481 |
|
3482 |
|
3483 | cfg: Base.extend(),
|
3484 |
|
3485 | |
3486 |
|
3487 |
|
3488 |
|
3489 |
|
3490 |
|
3491 |
|
3492 |
|
3493 |
|
3494 |
|
3495 |
|
3496 |
|
3497 |
|
3498 |
|
3499 | createEncryptor: function (key, cfg) {
|
3500 | return this.create(this._ENC_XFORM_MODE, key, cfg);
|
3501 | },
|
3502 |
|
3503 | |
3504 |
|
3505 |
|
3506 |
|
3507 |
|
3508 |
|
3509 |
|
3510 |
|
3511 |
|
3512 |
|
3513 |
|
3514 |
|
3515 |
|
3516 |
|
3517 | createDecryptor: function (key, cfg) {
|
3518 | return this.create(this._DEC_XFORM_MODE, key, cfg);
|
3519 | },
|
3520 |
|
3521 | |
3522 |
|
3523 |
|
3524 |
|
3525 |
|
3526 |
|
3527 |
|
3528 |
|
3529 |
|
3530 |
|
3531 |
|
3532 | init: function (xformMode, key, cfg) {
|
3533 |
|
3534 | this.cfg = this.cfg.extend(cfg);
|
3535 |
|
3536 |
|
3537 | this._xformMode = xformMode;
|
3538 | this._key = key;
|
3539 |
|
3540 |
|
3541 | this.reset();
|
3542 | },
|
3543 |
|
3544 | |
3545 |
|
3546 |
|
3547 |
|
3548 |
|
3549 |
|
3550 |
|
3551 | reset: function () {
|
3552 |
|
3553 | BufferedBlockAlgorithm.reset.call(this);
|
3554 |
|
3555 |
|
3556 | this._doReset();
|
3557 | },
|
3558 |
|
3559 | |
3560 |
|
3561 |
|
3562 |
|
3563 |
|
3564 |
|
3565 |
|
3566 |
|
3567 |
|
3568 |
|
3569 |
|
3570 |
|
3571 | process: function (dataUpdate) {
|
3572 |
|
3573 | this._append(dataUpdate);
|
3574 |
|
3575 |
|
3576 | return this._process();
|
3577 | },
|
3578 |
|
3579 | |
3580 |
|
3581 |
|
3582 |
|
3583 |
|
3584 |
|
3585 |
|
3586 |
|
3587 |
|
3588 |
|
3589 |
|
3590 |
|
3591 |
|
3592 |
|
3593 | finalize: function (dataUpdate) {
|
3594 |
|
3595 | if (dataUpdate) {
|
3596 | this._append(dataUpdate);
|
3597 | }
|
3598 |
|
3599 |
|
3600 | var finalProcessedData = this._doFinalize();
|
3601 |
|
3602 | return finalProcessedData;
|
3603 | },
|
3604 |
|
3605 | keySize: 128/32,
|
3606 |
|
3607 | ivSize: 128/32,
|
3608 |
|
3609 | _ENC_XFORM_MODE: 1,
|
3610 |
|
3611 | _DEC_XFORM_MODE: 2,
|
3612 |
|
3613 | |
3614 |
|
3615 |
|
3616 |
|
3617 |
|
3618 |
|
3619 |
|
3620 |
|
3621 |
|
3622 |
|
3623 |
|
3624 |
|
3625 |
|
3626 | _createHelper: (function () {
|
3627 | function selectCipherStrategy(key) {
|
3628 | if (typeof key == 'string') {
|
3629 | return PasswordBasedCipher;
|
3630 | } else {
|
3631 | return SerializableCipher;
|
3632 | }
|
3633 | }
|
3634 |
|
3635 | return function (cipher) {
|
3636 | return {
|
3637 | encrypt: function (message, key, cfg) {
|
3638 | return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
|
3639 | },
|
3640 |
|
3641 | decrypt: function (ciphertext, key, cfg) {
|
3642 | return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
|
3643 | }
|
3644 | };
|
3645 | };
|
3646 | }())
|
3647 | });
|
3648 |
|
3649 | |
3650 |
|
3651 |
|
3652 |
|
3653 |
|
3654 | var StreamCipher = C_lib.StreamCipher = Cipher.extend({
|
3655 | _doFinalize: function () {
|
3656 |
|
3657 | var finalProcessedBlocks = this._process(!!'flush');
|
3658 |
|
3659 | return finalProcessedBlocks;
|
3660 | },
|
3661 |
|
3662 | blockSize: 1
|
3663 | });
|
3664 |
|
3665 | |
3666 |
|
3667 |
|
3668 | var C_mode = C.mode = {};
|
3669 |
|
3670 | |
3671 |
|
3672 |
|
3673 | var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
|
3674 | |
3675 |
|
3676 |
|
3677 |
|
3678 |
|
3679 |
|
3680 |
|
3681 |
|
3682 |
|
3683 |
|
3684 |
|
3685 |
|
3686 | createEncryptor: function (cipher, iv) {
|
3687 | return this.Encryptor.create(cipher, iv);
|
3688 | },
|
3689 |
|
3690 | |
3691 |
|
3692 |
|
3693 |
|
3694 |
|
3695 |
|
3696 |
|
3697 |
|
3698 |
|
3699 |
|
3700 |
|
3701 |
|
3702 | createDecryptor: function (cipher, iv) {
|
3703 | return this.Decryptor.create(cipher, iv);
|
3704 | },
|
3705 |
|
3706 | |
3707 |
|
3708 |
|
3709 |
|
3710 |
|
3711 |
|
3712 |
|
3713 |
|
3714 |
|
3715 |
|
3716 | init: function (cipher, iv) {
|
3717 | this._cipher = cipher;
|
3718 | this._iv = iv;
|
3719 | }
|
3720 | });
|
3721 |
|
3722 | |
3723 |
|
3724 |
|
3725 | var CBC = C_mode.CBC = (function () {
|
3726 | |
3727 |
|
3728 |
|
3729 | var CBC = BlockCipherMode.extend();
|
3730 |
|
3731 | |
3732 |
|
3733 |
|
3734 | CBC.Encryptor = CBC.extend({
|
3735 | |
3736 |
|
3737 |
|
3738 |
|
3739 |
|
3740 |
|
3741 |
|
3742 |
|
3743 |
|
3744 |
|
3745 | processBlock: function (words, offset) {
|
3746 |
|
3747 | var cipher = this._cipher;
|
3748 | var blockSize = cipher.blockSize;
|
3749 |
|
3750 |
|
3751 | xorBlock.call(this, words, offset, blockSize);
|
3752 | cipher.encryptBlock(words, offset);
|
3753 |
|
3754 |
|
3755 | this._prevBlock = words.slice(offset, offset + blockSize);
|
3756 | }
|
3757 | });
|
3758 |
|
3759 | |
3760 |
|
3761 |
|
3762 | CBC.Decryptor = CBC.extend({
|
3763 | |
3764 |
|
3765 |
|
3766 |
|
3767 |
|
3768 |
|
3769 |
|
3770 |
|
3771 |
|
3772 |
|
3773 | processBlock: function (words, offset) {
|
3774 |
|
3775 | var cipher = this._cipher;
|
3776 | var blockSize = cipher.blockSize;
|
3777 |
|
3778 |
|
3779 | var thisBlock = words.slice(offset, offset + blockSize);
|
3780 |
|
3781 |
|
3782 | cipher.decryptBlock(words, offset);
|
3783 | xorBlock.call(this, words, offset, blockSize);
|
3784 |
|
3785 |
|
3786 | this._prevBlock = thisBlock;
|
3787 | }
|
3788 | });
|
3789 |
|
3790 | function xorBlock(words, offset, blockSize) {
|
3791 | var block;
|
3792 |
|
3793 |
|
3794 | var iv = this._iv;
|
3795 |
|
3796 |
|
3797 | if (iv) {
|
3798 | block = iv;
|
3799 |
|
3800 |
|
3801 | this._iv = undefined;
|
3802 | } else {
|
3803 | block = this._prevBlock;
|
3804 | }
|
3805 |
|
3806 |
|
3807 | for (var i = 0; i < blockSize; i++) {
|
3808 | words[offset + i] ^= block[i];
|
3809 | }
|
3810 | }
|
3811 |
|
3812 | return CBC;
|
3813 | }());
|
3814 |
|
3815 | |
3816 |
|
3817 |
|
3818 | var C_pad = C.pad = {};
|
3819 |
|
3820 | |
3821 |
|
3822 |
|
3823 | var Pkcs7 = C_pad.Pkcs7 = {
|
3824 | |
3825 |
|
3826 |
|
3827 |
|
3828 |
|
3829 |
|
3830 |
|
3831 |
|
3832 |
|
3833 |
|
3834 |
|
3835 |
|
3836 | pad: function (data, blockSize) {
|
3837 |
|
3838 | var blockSizeBytes = blockSize * 4;
|
3839 |
|
3840 |
|
3841 | var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
|
3842 |
|
3843 |
|
3844 | var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
|
3845 |
|
3846 |
|
3847 | var paddingWords = [];
|
3848 | for (var i = 0; i < nPaddingBytes; i += 4) {
|
3849 | paddingWords.push(paddingWord);
|
3850 | }
|
3851 | var padding = WordArray.create(paddingWords, nPaddingBytes);
|
3852 |
|
3853 |
|
3854 | data.concat(padding);
|
3855 | },
|
3856 |
|
3857 | |
3858 |
|
3859 |
|
3860 |
|
3861 |
|
3862 |
|
3863 |
|
3864 |
|
3865 |
|
3866 |
|
3867 |
|
3868 | unpad: function (data) {
|
3869 |
|
3870 | var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
|
3871 |
|
3872 |
|
3873 | data.sigBytes -= nPaddingBytes;
|
3874 | }
|
3875 | };
|
3876 |
|
3877 | |
3878 |
|
3879 |
|
3880 |
|
3881 |
|
3882 | var BlockCipher = C_lib.BlockCipher = Cipher.extend({
|
3883 | |
3884 |
|
3885 |
|
3886 |
|
3887 |
|
3888 |
|
3889 | cfg: Cipher.cfg.extend({
|
3890 | mode: CBC,
|
3891 | padding: Pkcs7
|
3892 | }),
|
3893 |
|
3894 | reset: function () {
|
3895 | var modeCreator;
|
3896 |
|
3897 |
|
3898 | Cipher.reset.call(this);
|
3899 |
|
3900 |
|
3901 | var cfg = this.cfg;
|
3902 | var iv = cfg.iv;
|
3903 | var mode = cfg.mode;
|
3904 |
|
3905 |
|
3906 | if (this._xformMode == this._ENC_XFORM_MODE) {
|
3907 | modeCreator = mode.createEncryptor;
|
3908 | } else {
|
3909 | modeCreator = mode.createDecryptor;
|
3910 |
|
3911 | this._minBufferSize = 1;
|
3912 | }
|
3913 |
|
3914 | if (this._mode && this._mode.__creator == modeCreator) {
|
3915 | this._mode.init(this, iv && iv.words);
|
3916 | } else {
|
3917 | this._mode = modeCreator.call(mode, this, iv && iv.words);
|
3918 | this._mode.__creator = modeCreator;
|
3919 | }
|
3920 | },
|
3921 |
|
3922 | _doProcessBlock: function (words, offset) {
|
3923 | this._mode.processBlock(words, offset);
|
3924 | },
|
3925 |
|
3926 | _doFinalize: function () {
|
3927 | var finalProcessedBlocks;
|
3928 |
|
3929 |
|
3930 | var padding = this.cfg.padding;
|
3931 |
|
3932 |
|
3933 | if (this._xformMode == this._ENC_XFORM_MODE) {
|
3934 |
|
3935 | padding.pad(this._data, this.blockSize);
|
3936 |
|
3937 |
|
3938 | finalProcessedBlocks = this._process(!!'flush');
|
3939 | } else {
|
3940 |
|
3941 | finalProcessedBlocks = this._process(!!'flush');
|
3942 |
|
3943 |
|
3944 | padding.unpad(finalProcessedBlocks);
|
3945 | }
|
3946 |
|
3947 | return finalProcessedBlocks;
|
3948 | },
|
3949 |
|
3950 | blockSize: 128/32
|
3951 | });
|
3952 |
|
3953 | |
3954 |
|
3955 |
|
3956 |
|
3957 |
|
3958 |
|
3959 |
|
3960 |
|
3961 |
|
3962 |
|
3963 |
|
3964 |
|
3965 |
|
3966 | var CipherParams = C_lib.CipherParams = Base.extend({
|
3967 | |
3968 |
|
3969 |
|
3970 |
|
3971 |
|
3972 |
|
3973 |
|
3974 |
|
3975 |
|
3976 |
|
3977 |
|
3978 |
|
3979 |
|
3980 |
|
3981 |
|
3982 |
|
3983 |
|
3984 |
|
3985 |
|
3986 | init: function (cipherParams) {
|
3987 | this.mixIn(cipherParams);
|
3988 | },
|
3989 |
|
3990 | |
3991 |
|
3992 |
|
3993 |
|
3994 |
|
3995 |
|
3996 |
|
3997 |
|
3998 |
|
3999 |
|
4000 |
|
4001 |
|
4002 |
|
4003 |
|
4004 |
|
4005 | toString: function (formatter) {
|
4006 | return (formatter || this.formatter).stringify(this);
|
4007 | }
|
4008 | });
|
4009 |
|
4010 | |
4011 |
|
4012 |
|
4013 | var C_format = C.format = {};
|
4014 |
|
4015 | |
4016 |
|
4017 |
|
4018 | var OpenSSLFormatter = C_format.OpenSSL = {
|
4019 | |
4020 |
|
4021 |
|
4022 |
|
4023 |
|
4024 |
|
4025 |
|
4026 |
|
4027 |
|
4028 |
|
4029 |
|
4030 |
|
4031 |
|
4032 | stringify: function (cipherParams) {
|
4033 | var wordArray;
|
4034 |
|
4035 |
|
4036 | var ciphertext = cipherParams.ciphertext;
|
4037 | var salt = cipherParams.salt;
|
4038 |
|
4039 |
|
4040 | if (salt) {
|
4041 | wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
|
4042 | } else {
|
4043 | wordArray = ciphertext;
|
4044 | }
|
4045 |
|
4046 | return wordArray.toString(Base64);
|
4047 | },
|
4048 |
|
4049 | |
4050 |
|
4051 |
|
4052 |
|
4053 |
|
4054 |
|
4055 |
|
4056 |
|
4057 |
|
4058 |
|
4059 |
|
4060 |
|
4061 |
|
4062 | parse: function (openSSLStr) {
|
4063 | var salt;
|
4064 |
|
4065 |
|
4066 | var ciphertext = Base64.parse(openSSLStr);
|
4067 |
|
4068 |
|
4069 | var ciphertextWords = ciphertext.words;
|
4070 |
|
4071 |
|
4072 | if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
|
4073 |
|
4074 | salt = WordArray.create(ciphertextWords.slice(2, 4));
|
4075 |
|
4076 |
|
4077 | ciphertextWords.splice(0, 4);
|
4078 | ciphertext.sigBytes -= 16;
|
4079 | }
|
4080 |
|
4081 | return CipherParams.create({ ciphertext: ciphertext, salt: salt });
|
4082 | }
|
4083 | };
|
4084 |
|
4085 | |
4086 |
|
4087 |
|
4088 | var SerializableCipher = C_lib.SerializableCipher = Base.extend({
|
4089 | |
4090 |
|
4091 |
|
4092 |
|
4093 |
|
4094 | cfg: Base.extend({
|
4095 | format: OpenSSLFormatter
|
4096 | }),
|
4097 |
|
4098 | |
4099 |
|
4100 |
|
4101 |
|
4102 |
|
4103 |
|
4104 |
|
4105 |
|
4106 |
|
4107 |
|
4108 |
|
4109 |
|
4110 |
|
4111 |
|
4112 |
|
4113 |
|
4114 |
|
4115 |
|
4116 | encrypt: function (cipher, message, key, cfg) {
|
4117 |
|
4118 | cfg = this.cfg.extend(cfg);
|
4119 |
|
4120 |
|
4121 | var encryptor = cipher.createEncryptor(key, cfg);
|
4122 | var ciphertext = encryptor.finalize(message);
|
4123 |
|
4124 |
|
4125 | var cipherCfg = encryptor.cfg;
|
4126 |
|
4127 |
|
4128 | return CipherParams.create({
|
4129 | ciphertext: ciphertext,
|
4130 | key: key,
|
4131 | iv: cipherCfg.iv,
|
4132 | algorithm: cipher,
|
4133 | mode: cipherCfg.mode,
|
4134 | padding: cipherCfg.padding,
|
4135 | blockSize: cipher.blockSize,
|
4136 | formatter: cfg.format
|
4137 | });
|
4138 | },
|
4139 |
|
4140 | |
4141 |
|
4142 |
|
4143 |
|
4144 |
|
4145 |
|
4146 |
|
4147 |
|
4148 |
|
4149 |
|
4150 |
|
4151 |
|
4152 |
|
4153 |
|
4154 |
|
4155 |
|
4156 |
|
4157 | decrypt: function (cipher, ciphertext, key, cfg) {
|
4158 |
|
4159 | cfg = this.cfg.extend(cfg);
|
4160 |
|
4161 |
|
4162 | ciphertext = this._parse(ciphertext, cfg.format);
|
4163 |
|
4164 |
|
4165 | var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
|
4166 |
|
4167 | return plaintext;
|
4168 | },
|
4169 |
|
4170 | |
4171 |
|
4172 |
|
4173 |
|
4174 |
|
4175 |
|
4176 |
|
4177 |
|
4178 |
|
4179 |
|
4180 |
|
4181 |
|
4182 |
|
4183 |
|
4184 |
|
4185 | _parse: function (ciphertext, format) {
|
4186 | if (typeof ciphertext == 'string') {
|
4187 | return format.parse(ciphertext, this);
|
4188 | } else {
|
4189 | return ciphertext;
|
4190 | }
|
4191 | }
|
4192 | });
|
4193 |
|
4194 | |
4195 |
|
4196 |
|
4197 | var C_kdf = C.kdf = {};
|
4198 |
|
4199 | |
4200 |
|
4201 |
|
4202 | var OpenSSLKdf = C_kdf.OpenSSL = {
|
4203 | |
4204 |
|
4205 |
|
4206 |
|
4207 |
|
4208 |
|
4209 |
|
4210 |
|
4211 |
|
4212 |
|
4213 |
|
4214 |
|
4215 |
|
4216 |
|
4217 |
|
4218 |
|
4219 |
|
4220 | execute: function (password, keySize, ivSize, salt, hasher) {
|
4221 |
|
4222 | if (!salt) {
|
4223 | salt = WordArray.random(64/8);
|
4224 | }
|
4225 |
|
4226 |
|
4227 | if (!hasher) {
|
4228 | var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
|
4229 | } else {
|
4230 | var key = EvpKDF.create({ keySize: keySize + ivSize, hasher: hasher }).compute(password, salt);
|
4231 | }
|
4232 |
|
4233 |
|
4234 |
|
4235 | var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
|
4236 | key.sigBytes = keySize * 4;
|
4237 |
|
4238 |
|
4239 | return CipherParams.create({ key: key, iv: iv, salt: salt });
|
4240 | }
|
4241 | };
|
4242 |
|
4243 | |
4244 |
|
4245 |
|
4246 |
|
4247 | var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
|
4248 | |
4249 |
|
4250 |
|
4251 |
|
4252 |
|
4253 | cfg: SerializableCipher.cfg.extend({
|
4254 | kdf: OpenSSLKdf
|
4255 | }),
|
4256 |
|
4257 | |
4258 |
|
4259 |
|
4260 |
|
4261 |
|
4262 |
|
4263 |
|
4264 |
|
4265 |
|
4266 |
|
4267 |
|
4268 |
|
4269 |
|
4270 |
|
4271 |
|
4272 |
|
4273 |
|
4274 | encrypt: function (cipher, message, password, cfg) {
|
4275 |
|
4276 | cfg = this.cfg.extend(cfg);
|
4277 |
|
4278 |
|
4279 | var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, cfg.salt, cfg.hasher);
|
4280 |
|
4281 |
|
4282 | cfg.iv = derivedParams.iv;
|
4283 |
|
4284 |
|
4285 | var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
|
4286 |
|
4287 |
|
4288 | ciphertext.mixIn(derivedParams);
|
4289 |
|
4290 | return ciphertext;
|
4291 | },
|
4292 |
|
4293 | |
4294 |
|
4295 |
|
4296 |
|
4297 |
|
4298 |
|
4299 |
|
4300 |
|
4301 |
|
4302 |
|
4303 |
|
4304 |
|
4305 |
|
4306 |
|
4307 |
|
4308 |
|
4309 |
|
4310 | decrypt: function (cipher, ciphertext, password, cfg) {
|
4311 |
|
4312 | cfg = this.cfg.extend(cfg);
|
4313 |
|
4314 |
|
4315 | ciphertext = this._parse(ciphertext, cfg.format);
|
4316 |
|
4317 |
|
4318 | var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt, cfg.hasher);
|
4319 |
|
4320 |
|
4321 | cfg.iv = derivedParams.iv;
|
4322 |
|
4323 |
|
4324 | var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
|
4325 |
|
4326 | return plaintext;
|
4327 | }
|
4328 | });
|
4329 | }());
|
4330 |
|
4331 |
|
4332 | |
4333 |
|
4334 |
|
4335 | CryptoJS.mode.CFB = (function () {
|
4336 | var CFB = CryptoJS.lib.BlockCipherMode.extend();
|
4337 |
|
4338 | CFB.Encryptor = CFB.extend({
|
4339 | processBlock: function (words, offset) {
|
4340 |
|
4341 | var cipher = this._cipher;
|
4342 | var blockSize = cipher.blockSize;
|
4343 |
|
4344 | generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
|
4345 |
|
4346 |
|
4347 | this._prevBlock = words.slice(offset, offset + blockSize);
|
4348 | }
|
4349 | });
|
4350 |
|
4351 | CFB.Decryptor = CFB.extend({
|
4352 | processBlock: function (words, offset) {
|
4353 |
|
4354 | var cipher = this._cipher;
|
4355 | var blockSize = cipher.blockSize;
|
4356 |
|
4357 |
|
4358 | var thisBlock = words.slice(offset, offset + blockSize);
|
4359 |
|
4360 | generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
|
4361 |
|
4362 |
|
4363 | this._prevBlock = thisBlock;
|
4364 | }
|
4365 | });
|
4366 |
|
4367 | function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
|
4368 | var keystream;
|
4369 |
|
4370 |
|
4371 | var iv = this._iv;
|
4372 |
|
4373 |
|
4374 | if (iv) {
|
4375 | keystream = iv.slice(0);
|
4376 |
|
4377 |
|
4378 | this._iv = undefined;
|
4379 | } else {
|
4380 | keystream = this._prevBlock;
|
4381 | }
|
4382 | cipher.encryptBlock(keystream, 0);
|
4383 |
|
4384 |
|
4385 | for (var i = 0; i < blockSize; i++) {
|
4386 | words[offset + i] ^= keystream[i];
|
4387 | }
|
4388 | }
|
4389 |
|
4390 | return CFB;
|
4391 | }());
|
4392 |
|
4393 |
|
4394 | |
4395 |
|
4396 |
|
4397 | CryptoJS.mode.CTR = (function () {
|
4398 | var CTR = CryptoJS.lib.BlockCipherMode.extend();
|
4399 |
|
4400 | var Encryptor = CTR.Encryptor = CTR.extend({
|
4401 | processBlock: function (words, offset) {
|
4402 |
|
4403 | var cipher = this._cipher
|
4404 | var blockSize = cipher.blockSize;
|
4405 | var iv = this._iv;
|
4406 | var counter = this._counter;
|
4407 |
|
4408 |
|
4409 | if (iv) {
|
4410 | counter = this._counter = iv.slice(0);
|
4411 |
|
4412 |
|
4413 | this._iv = undefined;
|
4414 | }
|
4415 | var keystream = counter.slice(0);
|
4416 | cipher.encryptBlock(keystream, 0);
|
4417 |
|
4418 |
|
4419 | counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
|
4420 |
|
4421 |
|
4422 | for (var i = 0; i < blockSize; i++) {
|
4423 | words[offset + i] ^= keystream[i];
|
4424 | }
|
4425 | }
|
4426 | });
|
4427 |
|
4428 | CTR.Decryptor = Encryptor;
|
4429 |
|
4430 | return CTR;
|
4431 | }());
|
4432 |
|
4433 |
|
4434 | |
4435 |
|
4436 |
|
4437 |
|
4438 |
|
4439 | CryptoJS.mode.CTRGladman = (function () {
|
4440 | var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
|
4441 |
|
4442 | function incWord(word)
|
4443 | {
|
4444 | if (((word >> 24) & 0xff) === 0xff) {
|
4445 | var b1 = (word >> 16)&0xff;
|
4446 | var b2 = (word >> 8)&0xff;
|
4447 | var b3 = word & 0xff;
|
4448 |
|
4449 | if (b1 === 0xff)
|
4450 | {
|
4451 | b1 = 0;
|
4452 | if (b2 === 0xff)
|
4453 | {
|
4454 | b2 = 0;
|
4455 | if (b3 === 0xff)
|
4456 | {
|
4457 | b3 = 0;
|
4458 | }
|
4459 | else
|
4460 | {
|
4461 | ++b3;
|
4462 | }
|
4463 | }
|
4464 | else
|
4465 | {
|
4466 | ++b2;
|
4467 | }
|
4468 | }
|
4469 | else
|
4470 | {
|
4471 | ++b1;
|
4472 | }
|
4473 |
|
4474 | word = 0;
|
4475 | word += (b1 << 16);
|
4476 | word += (b2 << 8);
|
4477 | word += b3;
|
4478 | }
|
4479 | else
|
4480 | {
|
4481 | word += (0x01 << 24);
|
4482 | }
|
4483 | return word;
|
4484 | }
|
4485 |
|
4486 | function incCounter(counter)
|
4487 | {
|
4488 | if ((counter[0] = incWord(counter[0])) === 0)
|
4489 | {
|
4490 |
|
4491 | counter[1] = incWord(counter[1]);
|
4492 | }
|
4493 | return counter;
|
4494 | }
|
4495 |
|
4496 | var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
|
4497 | processBlock: function (words, offset) {
|
4498 |
|
4499 | var cipher = this._cipher
|
4500 | var blockSize = cipher.blockSize;
|
4501 | var iv = this._iv;
|
4502 | var counter = this._counter;
|
4503 |
|
4504 |
|
4505 | if (iv) {
|
4506 | counter = this._counter = iv.slice(0);
|
4507 |
|
4508 |
|
4509 | this._iv = undefined;
|
4510 | }
|
4511 |
|
4512 | incCounter(counter);
|
4513 |
|
4514 | var keystream = counter.slice(0);
|
4515 | cipher.encryptBlock(keystream, 0);
|
4516 |
|
4517 |
|
4518 | for (var i = 0; i < blockSize; i++) {
|
4519 | words[offset + i] ^= keystream[i];
|
4520 | }
|
4521 | }
|
4522 | });
|
4523 |
|
4524 | CTRGladman.Decryptor = Encryptor;
|
4525 |
|
4526 | return CTRGladman;
|
4527 | }());
|
4528 |
|
4529 |
|
4530 |
|
4531 |
|
4532 | |
4533 |
|
4534 |
|
4535 | CryptoJS.mode.OFB = (function () {
|
4536 | var OFB = CryptoJS.lib.BlockCipherMode.extend();
|
4537 |
|
4538 | var Encryptor = OFB.Encryptor = OFB.extend({
|
4539 | processBlock: function (words, offset) {
|
4540 |
|
4541 | var cipher = this._cipher
|
4542 | var blockSize = cipher.blockSize;
|
4543 | var iv = this._iv;
|
4544 | var keystream = this._keystream;
|
4545 |
|
4546 |
|
4547 | if (iv) {
|
4548 | keystream = this._keystream = iv.slice(0);
|
4549 |
|
4550 |
|
4551 | this._iv = undefined;
|
4552 | }
|
4553 | cipher.encryptBlock(keystream, 0);
|
4554 |
|
4555 |
|
4556 | for (var i = 0; i < blockSize; i++) {
|
4557 | words[offset + i] ^= keystream[i];
|
4558 | }
|
4559 | }
|
4560 | });
|
4561 |
|
4562 | OFB.Decryptor = Encryptor;
|
4563 |
|
4564 | return OFB;
|
4565 | }());
|
4566 |
|
4567 |
|
4568 | |
4569 |
|
4570 |
|
4571 | CryptoJS.mode.ECB = (function () {
|
4572 | var ECB = CryptoJS.lib.BlockCipherMode.extend();
|
4573 |
|
4574 | ECB.Encryptor = ECB.extend({
|
4575 | processBlock: function (words, offset) {
|
4576 | this._cipher.encryptBlock(words, offset);
|
4577 | }
|
4578 | });
|
4579 |
|
4580 | ECB.Decryptor = ECB.extend({
|
4581 | processBlock: function (words, offset) {
|
4582 | this._cipher.decryptBlock(words, offset);
|
4583 | }
|
4584 | });
|
4585 |
|
4586 | return ECB;
|
4587 | }());
|
4588 |
|
4589 |
|
4590 | |
4591 |
|
4592 |
|
4593 | CryptoJS.pad.AnsiX923 = {
|
4594 | pad: function (data, blockSize) {
|
4595 |
|
4596 | var dataSigBytes = data.sigBytes;
|
4597 | var blockSizeBytes = blockSize * 4;
|
4598 |
|
4599 |
|
4600 | var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
|
4601 |
|
4602 |
|
4603 | var lastBytePos = dataSigBytes + nPaddingBytes - 1;
|
4604 |
|
4605 |
|
4606 | data.clamp();
|
4607 | data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
|
4608 | data.sigBytes += nPaddingBytes;
|
4609 | },
|
4610 |
|
4611 | unpad: function (data) {
|
4612 |
|
4613 | var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
|
4614 |
|
4615 |
|
4616 | data.sigBytes -= nPaddingBytes;
|
4617 | }
|
4618 | };
|
4619 |
|
4620 |
|
4621 | |
4622 |
|
4623 |
|
4624 | CryptoJS.pad.Iso10126 = {
|
4625 | pad: function (data, blockSize) {
|
4626 |
|
4627 | var blockSizeBytes = blockSize * 4;
|
4628 |
|
4629 |
|
4630 | var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
|
4631 |
|
4632 |
|
4633 | data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
|
4634 | concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
|
4635 | },
|
4636 |
|
4637 | unpad: function (data) {
|
4638 |
|
4639 | var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
|
4640 |
|
4641 |
|
4642 | data.sigBytes -= nPaddingBytes;
|
4643 | }
|
4644 | };
|
4645 |
|
4646 |
|
4647 | |
4648 |
|
4649 |
|
4650 | CryptoJS.pad.Iso97971 = {
|
4651 | pad: function (data, blockSize) {
|
4652 |
|
4653 | data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
|
4654 |
|
4655 |
|
4656 | CryptoJS.pad.ZeroPadding.pad(data, blockSize);
|
4657 | },
|
4658 |
|
4659 | unpad: function (data) {
|
4660 |
|
4661 | CryptoJS.pad.ZeroPadding.unpad(data);
|
4662 |
|
4663 |
|
4664 | data.sigBytes--;
|
4665 | }
|
4666 | };
|
4667 |
|
4668 |
|
4669 | |
4670 |
|
4671 |
|
4672 | CryptoJS.pad.ZeroPadding = {
|
4673 | pad: function (data, blockSize) {
|
4674 |
|
4675 | var blockSizeBytes = blockSize * 4;
|
4676 |
|
4677 |
|
4678 | data.clamp();
|
4679 | data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
|
4680 | },
|
4681 |
|
4682 | unpad: function (data) {
|
4683 |
|
4684 | var dataWords = data.words;
|
4685 |
|
4686 |
|
4687 | var i = data.sigBytes - 1;
|
4688 | for (var i = data.sigBytes - 1; i >= 0; i--) {
|
4689 | if (((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
|
4690 | data.sigBytes = i + 1;
|
4691 | break;
|
4692 | }
|
4693 | }
|
4694 | }
|
4695 | };
|
4696 |
|
4697 |
|
4698 | |
4699 |
|
4700 |
|
4701 | CryptoJS.pad.NoPadding = {
|
4702 | pad: function () {
|
4703 | },
|
4704 |
|
4705 | unpad: function () {
|
4706 | }
|
4707 | };
|
4708 |
|
4709 |
|
4710 | (function (undefined) {
|
4711 |
|
4712 | var C = CryptoJS;
|
4713 | var C_lib = C.lib;
|
4714 | var CipherParams = C_lib.CipherParams;
|
4715 | var C_enc = C.enc;
|
4716 | var Hex = C_enc.Hex;
|
4717 | var C_format = C.format;
|
4718 |
|
4719 | var HexFormatter = C_format.Hex = {
|
4720 | |
4721 |
|
4722 |
|
4723 |
|
4724 |
|
4725 |
|
4726 |
|
4727 |
|
4728 |
|
4729 |
|
4730 |
|
4731 |
|
4732 |
|
4733 | stringify: function (cipherParams) {
|
4734 | return cipherParams.ciphertext.toString(Hex);
|
4735 | },
|
4736 |
|
4737 | |
4738 |
|
4739 |
|
4740 |
|
4741 |
|
4742 |
|
4743 |
|
4744 |
|
4745 |
|
4746 |
|
4747 |
|
4748 |
|
4749 |
|
4750 | parse: function (input) {
|
4751 | var ciphertext = Hex.parse(input);
|
4752 | return CipherParams.create({ ciphertext: ciphertext });
|
4753 | }
|
4754 | };
|
4755 | }());
|
4756 |
|
4757 |
|
4758 | (function () {
|
4759 |
|
4760 | var C = CryptoJS;
|
4761 | var C_lib = C.lib;
|
4762 | var BlockCipher = C_lib.BlockCipher;
|
4763 | var C_algo = C.algo;
|
4764 |
|
4765 |
|
4766 | var SBOX = [];
|
4767 | var INV_SBOX = [];
|
4768 | var SUB_MIX_0 = [];
|
4769 | var SUB_MIX_1 = [];
|
4770 | var SUB_MIX_2 = [];
|
4771 | var SUB_MIX_3 = [];
|
4772 | var INV_SUB_MIX_0 = [];
|
4773 | var INV_SUB_MIX_1 = [];
|
4774 | var INV_SUB_MIX_2 = [];
|
4775 | var INV_SUB_MIX_3 = [];
|
4776 |
|
4777 |
|
4778 | (function () {
|
4779 |
|
4780 | var d = [];
|
4781 | for (var i = 0; i < 256; i++) {
|
4782 | if (i < 128) {
|
4783 | d[i] = i << 1;
|
4784 | } else {
|
4785 | d[i] = (i << 1) ^ 0x11b;
|
4786 | }
|
4787 | }
|
4788 |
|
4789 |
|
4790 | var x = 0;
|
4791 | var xi = 0;
|
4792 | for (var i = 0; i < 256; i++) {
|
4793 |
|
4794 | var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
|
4795 | sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
|
4796 | SBOX[x] = sx;
|
4797 | INV_SBOX[sx] = x;
|
4798 |
|
4799 |
|
4800 | var x2 = d[x];
|
4801 | var x4 = d[x2];
|
4802 | var x8 = d[x4];
|
4803 |
|
4804 |
|
4805 | var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
|
4806 | SUB_MIX_0[x] = (t << 24) | (t >>> 8);
|
4807 | SUB_MIX_1[x] = (t << 16) | (t >>> 16);
|
4808 | SUB_MIX_2[x] = (t << 8) | (t >>> 24);
|
4809 | SUB_MIX_3[x] = t;
|
4810 |
|
4811 |
|
4812 | var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
|
4813 | INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
|
4814 | INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
|
4815 | INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
|
4816 | INV_SUB_MIX_3[sx] = t;
|
4817 |
|
4818 |
|
4819 | if (!x) {
|
4820 | x = xi = 1;
|
4821 | } else {
|
4822 | x = x2 ^ d[d[d[x8 ^ x2]]];
|
4823 | xi ^= d[d[xi]];
|
4824 | }
|
4825 | }
|
4826 | }());
|
4827 |
|
4828 |
|
4829 | var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
|
4830 |
|
4831 | |
4832 |
|
4833 |
|
4834 | var AES = C_algo.AES = BlockCipher.extend({
|
4835 | _doReset: function () {
|
4836 | var t;
|
4837 |
|
4838 |
|
4839 | if (this._nRounds && this._keyPriorReset === this._key) {
|
4840 | return;
|
4841 | }
|
4842 |
|
4843 |
|
4844 | var key = this._keyPriorReset = this._key;
|
4845 | var keyWords = key.words;
|
4846 | var keySize = key.sigBytes / 4;
|
4847 |
|
4848 |
|
4849 | var nRounds = this._nRounds = keySize + 6;
|
4850 |
|
4851 |
|
4852 | var ksRows = (nRounds + 1) * 4;
|
4853 |
|
4854 |
|
4855 | var keySchedule = this._keySchedule = [];
|
4856 | for (var ksRow = 0; ksRow < ksRows; ksRow++) {
|
4857 | if (ksRow < keySize) {
|
4858 | keySchedule[ksRow] = keyWords[ksRow];
|
4859 | } else {
|
4860 | t = keySchedule[ksRow - 1];
|
4861 |
|
4862 | if (!(ksRow % keySize)) {
|
4863 |
|
4864 | t = (t << 8) | (t >>> 24);
|
4865 |
|
4866 |
|
4867 | t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
|
4868 |
|
4869 |
|
4870 | t ^= RCON[(ksRow / keySize) | 0] << 24;
|
4871 | } else if (keySize > 6 && ksRow % keySize == 4) {
|
4872 |
|
4873 | t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
|
4874 | }
|
4875 |
|
4876 | keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
|
4877 | }
|
4878 | }
|
4879 |
|
4880 |
|
4881 | var invKeySchedule = this._invKeySchedule = [];
|
4882 | for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
|
4883 | var ksRow = ksRows - invKsRow;
|
4884 |
|
4885 | if (invKsRow % 4) {
|
4886 | var t = keySchedule[ksRow];
|
4887 | } else {
|
4888 | var t = keySchedule[ksRow - 4];
|
4889 | }
|
4890 |
|
4891 | if (invKsRow < 4 || ksRow <= 4) {
|
4892 | invKeySchedule[invKsRow] = t;
|
4893 | } else {
|
4894 | invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
|
4895 | INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
|
4896 | }
|
4897 | }
|
4898 | },
|
4899 |
|
4900 | encryptBlock: function (M, offset) {
|
4901 | this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
|
4902 | },
|
4903 |
|
4904 | decryptBlock: function (M, offset) {
|
4905 |
|
4906 | var t = M[offset + 1];
|
4907 | M[offset + 1] = M[offset + 3];
|
4908 | M[offset + 3] = t;
|
4909 |
|
4910 | this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
|
4911 |
|
4912 |
|
4913 | var t = M[offset + 1];
|
4914 | M[offset + 1] = M[offset + 3];
|
4915 | M[offset + 3] = t;
|
4916 | },
|
4917 |
|
4918 | _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
|
4919 |
|
4920 | var nRounds = this._nRounds;
|
4921 |
|
4922 |
|
4923 | var s0 = M[offset] ^ keySchedule[0];
|
4924 | var s1 = M[offset + 1] ^ keySchedule[1];
|
4925 | var s2 = M[offset + 2] ^ keySchedule[2];
|
4926 | var s3 = M[offset + 3] ^ keySchedule[3];
|
4927 |
|
4928 |
|
4929 | var ksRow = 4;
|
4930 |
|
4931 |
|
4932 | for (var round = 1; round < nRounds; round++) {
|
4933 |
|
4934 | var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
|
4935 | var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
|
4936 | var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
|
4937 | var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
|
4938 |
|
4939 |
|
4940 | s0 = t0;
|
4941 | s1 = t1;
|
4942 | s2 = t2;
|
4943 | s3 = t3;
|
4944 | }
|
4945 |
|
4946 |
|
4947 | var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
|
4948 | var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
|
4949 | var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
|
4950 | var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
|
4951 |
|
4952 |
|
4953 | M[offset] = t0;
|
4954 | M[offset + 1] = t1;
|
4955 | M[offset + 2] = t2;
|
4956 | M[offset + 3] = t3;
|
4957 | },
|
4958 |
|
4959 | keySize: 256/32
|
4960 | });
|
4961 |
|
4962 | |
4963 |
|
4964 |
|
4965 |
|
4966 |
|
4967 |
|
4968 |
|
4969 |
|
4970 | C.AES = BlockCipher._createHelper(AES);
|
4971 | }());
|
4972 |
|
4973 |
|
4974 | (function () {
|
4975 |
|
4976 | var C = CryptoJS;
|
4977 | var C_lib = C.lib;
|
4978 | var WordArray = C_lib.WordArray;
|
4979 | var BlockCipher = C_lib.BlockCipher;
|
4980 | var C_algo = C.algo;
|
4981 |
|
4982 |
|
4983 | var PC1 = [
|
4984 | 57, 49, 41, 33, 25, 17, 9, 1,
|
4985 | 58, 50, 42, 34, 26, 18, 10, 2,
|
4986 | 59, 51, 43, 35, 27, 19, 11, 3,
|
4987 | 60, 52, 44, 36, 63, 55, 47, 39,
|
4988 | 31, 23, 15, 7, 62, 54, 46, 38,
|
4989 | 30, 22, 14, 6, 61, 53, 45, 37,
|
4990 | 29, 21, 13, 5, 28, 20, 12, 4
|
4991 | ];
|
4992 |
|
4993 |
|
4994 | var PC2 = [
|
4995 | 14, 17, 11, 24, 1, 5,
|
4996 | 3, 28, 15, 6, 21, 10,
|
4997 | 23, 19, 12, 4, 26, 8,
|
4998 | 16, 7, 27, 20, 13, 2,
|
4999 | 41, 52, 31, 37, 47, 55,
|
5000 | 30, 40, 51, 45, 33, 48,
|
5001 | 44, 49, 39, 56, 34, 53,
|
5002 | 46, 42, 50, 36, 29, 32
|
5003 | ];
|
5004 |
|
5005 |
|
5006 | var BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
|
5007 |
|
5008 |
|
5009 | var SBOX_P = [
|
5010 | {
|
5011 | 0x0: 0x808200,
|
5012 | 0x10000000: 0x8000,
|
5013 | 0x20000000: 0x808002,
|
5014 | 0x30000000: 0x2,
|
5015 | 0x40000000: 0x200,
|
5016 | 0x50000000: 0x808202,
|
5017 | 0x60000000: 0x800202,
|
5018 | 0x70000000: 0x800000,
|
5019 | 0x80000000: 0x202,
|
5020 | 0x90000000: 0x800200,
|
5021 | 0xa0000000: 0x8200,
|
5022 | 0xb0000000: 0x808000,
|
5023 | 0xc0000000: 0x8002,
|
5024 | 0xd0000000: 0x800002,
|
5025 | 0xe0000000: 0x0,
|
5026 | 0xf0000000: 0x8202,
|
5027 | 0x8000000: 0x0,
|
5028 | 0x18000000: 0x808202,
|
5029 | 0x28000000: 0x8202,
|
5030 | 0x38000000: 0x8000,
|
5031 | 0x48000000: 0x808200,
|
5032 | 0x58000000: 0x200,
|
5033 | 0x68000000: 0x808002,
|
5034 | 0x78000000: 0x2,
|
5035 | 0x88000000: 0x800200,
|
5036 | 0x98000000: 0x8200,
|
5037 | 0xa8000000: 0x808000,
|
5038 | 0xb8000000: 0x800202,
|
5039 | 0xc8000000: 0x800002,
|
5040 | 0xd8000000: 0x8002,
|
5041 | 0xe8000000: 0x202,
|
5042 | 0xf8000000: 0x800000,
|
5043 | 0x1: 0x8000,
|
5044 | 0x10000001: 0x2,
|
5045 | 0x20000001: 0x808200,
|
5046 | 0x30000001: 0x800000,
|
5047 | 0x40000001: 0x808002,
|
5048 | 0x50000001: 0x8200,
|
5049 | 0x60000001: 0x200,
|
5050 | 0x70000001: 0x800202,
|
5051 | 0x80000001: 0x808202,
|
5052 | 0x90000001: 0x808000,
|
5053 | 0xa0000001: 0x800002,
|
5054 | 0xb0000001: 0x8202,
|
5055 | 0xc0000001: 0x202,
|
5056 | 0xd0000001: 0x800200,
|
5057 | 0xe0000001: 0x8002,
|
5058 | 0xf0000001: 0x0,
|
5059 | 0x8000001: 0x808202,
|
5060 | 0x18000001: 0x808000,
|
5061 | 0x28000001: 0x800000,
|
5062 | 0x38000001: 0x200,
|
5063 | 0x48000001: 0x8000,
|
5064 | 0x58000001: 0x800002,
|
5065 | 0x68000001: 0x2,
|
5066 | 0x78000001: 0x8202,
|
5067 | 0x88000001: 0x8002,
|
5068 | 0x98000001: 0x800202,
|
5069 | 0xa8000001: 0x202,
|
5070 | 0xb8000001: 0x808200,
|
5071 | 0xc8000001: 0x800200,
|
5072 | 0xd8000001: 0x0,
|
5073 | 0xe8000001: 0x8200,
|
5074 | 0xf8000001: 0x808002
|
5075 | },
|
5076 | {
|
5077 | 0x0: 0x40084010,
|
5078 | 0x1000000: 0x4000,
|
5079 | 0x2000000: 0x80000,
|
5080 | 0x3000000: 0x40080010,
|
5081 | 0x4000000: 0x40000010,
|
5082 | 0x5000000: 0x40084000,
|
5083 | 0x6000000: 0x40004000,
|
5084 | 0x7000000: 0x10,
|
5085 | 0x8000000: 0x84000,
|
5086 | 0x9000000: 0x40004010,
|
5087 | 0xa000000: 0x40000000,
|
5088 | 0xb000000: 0x84010,
|
5089 | 0xc000000: 0x80010,
|
5090 | 0xd000000: 0x0,
|
5091 | 0xe000000: 0x4010,
|
5092 | 0xf000000: 0x40080000,
|
5093 | 0x800000: 0x40004000,
|
5094 | 0x1800000: 0x84010,
|
5095 | 0x2800000: 0x10,
|
5096 | 0x3800000: 0x40004010,
|
5097 | 0x4800000: 0x40084010,
|
5098 | 0x5800000: 0x40000000,
|
5099 | 0x6800000: 0x80000,
|
5100 | 0x7800000: 0x40080010,
|
5101 | 0x8800000: 0x80010,
|
5102 | 0x9800000: 0x0,
|
5103 | 0xa800000: 0x4000,
|
5104 | 0xb800000: 0x40080000,
|
5105 | 0xc800000: 0x40000010,
|
5106 | 0xd800000: 0x84000,
|
5107 | 0xe800000: 0x40084000,
|
5108 | 0xf800000: 0x4010,
|
5109 | 0x10000000: 0x0,
|
5110 | 0x11000000: 0x40080010,
|
5111 | 0x12000000: 0x40004010,
|
5112 | 0x13000000: 0x40084000,
|
5113 | 0x14000000: 0x40080000,
|
5114 | 0x15000000: 0x10,
|
5115 | 0x16000000: 0x84010,
|
5116 | 0x17000000: 0x4000,
|
5117 | 0x18000000: 0x4010,
|
5118 | 0x19000000: 0x80000,
|
5119 | 0x1a000000: 0x80010,
|
5120 | 0x1b000000: 0x40000010,
|
5121 | 0x1c000000: 0x84000,
|
5122 | 0x1d000000: 0x40004000,
|
5123 | 0x1e000000: 0x40000000,
|
5124 | 0x1f000000: 0x40084010,
|
5125 | 0x10800000: 0x84010,
|
5126 | 0x11800000: 0x80000,
|
5127 | 0x12800000: 0x40080000,
|
5128 | 0x13800000: 0x4000,
|
5129 | 0x14800000: 0x40004000,
|
5130 | 0x15800000: 0x40084010,
|
5131 | 0x16800000: 0x10,
|
5132 | 0x17800000: 0x40000000,
|
5133 | 0x18800000: 0x40084000,
|
5134 | 0x19800000: 0x40000010,
|
5135 | 0x1a800000: 0x40004010,
|
5136 | 0x1b800000: 0x80010,
|
5137 | 0x1c800000: 0x0,
|
5138 | 0x1d800000: 0x4010,
|
5139 | 0x1e800000: 0x40080010,
|
5140 | 0x1f800000: 0x84000
|
5141 | },
|
5142 | {
|
5143 | 0x0: 0x104,
|
5144 | 0x100000: 0x0,
|
5145 | 0x200000: 0x4000100,
|
5146 | 0x300000: 0x10104,
|
5147 | 0x400000: 0x10004,
|
5148 | 0x500000: 0x4000004,
|
5149 | 0x600000: 0x4010104,
|
5150 | 0x700000: 0x4010000,
|
5151 | 0x800000: 0x4000000,
|
5152 | 0x900000: 0x4010100,
|
5153 | 0xa00000: 0x10100,
|
5154 | 0xb00000: 0x4010004,
|
5155 | 0xc00000: 0x4000104,
|
5156 | 0xd00000: 0x10000,
|
5157 | 0xe00000: 0x4,
|
5158 | 0xf00000: 0x100,
|
5159 | 0x80000: 0x4010100,
|
5160 | 0x180000: 0x4010004,
|
5161 | 0x280000: 0x0,
|
5162 | 0x380000: 0x4000100,
|
5163 | 0x480000: 0x4000004,
|
5164 | 0x580000: 0x10000,
|
5165 | 0x680000: 0x10004,
|
5166 | 0x780000: 0x104,
|
5167 | 0x880000: 0x4,
|
5168 | 0x980000: 0x100,
|
5169 | 0xa80000: 0x4010000,
|
5170 | 0xb80000: 0x10104,
|
5171 | 0xc80000: 0x10100,
|
5172 | 0xd80000: 0x4000104,
|
5173 | 0xe80000: 0x4010104,
|
5174 | 0xf80000: 0x4000000,
|
5175 | 0x1000000: 0x4010100,
|
5176 | 0x1100000: 0x10004,
|
5177 | 0x1200000: 0x10000,
|
5178 | 0x1300000: 0x4000100,
|
5179 | 0x1400000: 0x100,
|
5180 | 0x1500000: 0x4010104,
|
5181 | 0x1600000: 0x4000004,
|
5182 | 0x1700000: 0x0,
|
5183 | 0x1800000: 0x4000104,
|
5184 | 0x1900000: 0x4000000,
|
5185 | 0x1a00000: 0x4,
|
5186 | 0x1b00000: 0x10100,
|
5187 | 0x1c00000: 0x4010000,
|
5188 | 0x1d00000: 0x104,
|
5189 | 0x1e00000: 0x10104,
|
5190 | 0x1f00000: 0x4010004,
|
5191 | 0x1080000: 0x4000000,
|
5192 | 0x1180000: 0x104,
|
5193 | 0x1280000: 0x4010100,
|
5194 | 0x1380000: 0x0,
|
5195 | 0x1480000: 0x10004,
|
5196 | 0x1580000: 0x4000100,
|
5197 | 0x1680000: 0x100,
|
5198 | 0x1780000: 0x4010004,
|
5199 | 0x1880000: 0x10000,
|
5200 | 0x1980000: 0x4010104,
|
5201 | 0x1a80000: 0x10104,
|
5202 | 0x1b80000: 0x4000004,
|
5203 | 0x1c80000: 0x4000104,
|
5204 | 0x1d80000: 0x4010000,
|
5205 | 0x1e80000: 0x4,
|
5206 | 0x1f80000: 0x10100
|
5207 | },
|
5208 | {
|
5209 | 0x0: 0x80401000,
|
5210 | 0x10000: 0x80001040,
|
5211 | 0x20000: 0x401040,
|
5212 | 0x30000: 0x80400000,
|
5213 | 0x40000: 0x0,
|
5214 | 0x50000: 0x401000,
|
5215 | 0x60000: 0x80000040,
|
5216 | 0x70000: 0x400040,
|
5217 | 0x80000: 0x80000000,
|
5218 | 0x90000: 0x400000,
|
5219 | 0xa0000: 0x40,
|
5220 | 0xb0000: 0x80001000,
|
5221 | 0xc0000: 0x80400040,
|
5222 | 0xd0000: 0x1040,
|
5223 | 0xe0000: 0x1000,
|
5224 | 0xf0000: 0x80401040,
|
5225 | 0x8000: 0x80001040,
|
5226 | 0x18000: 0x40,
|
5227 | 0x28000: 0x80400040,
|
5228 | 0x38000: 0x80001000,
|
5229 | 0x48000: 0x401000,
|
5230 | 0x58000: 0x80401040,
|
5231 | 0x68000: 0x0,
|
5232 | 0x78000: 0x80400000,
|
5233 | 0x88000: 0x1000,
|
5234 | 0x98000: 0x80401000,
|
5235 | 0xa8000: 0x400000,
|
5236 | 0xb8000: 0x1040,
|
5237 | 0xc8000: 0x80000000,
|
5238 | 0xd8000: 0x400040,
|
5239 | 0xe8000: 0x401040,
|
5240 | 0xf8000: 0x80000040,
|
5241 | 0x100000: 0x400040,
|
5242 | 0x110000: 0x401000,
|
5243 | 0x120000: 0x80000040,
|
5244 | 0x130000: 0x0,
|
5245 | 0x140000: 0x1040,
|
5246 | 0x150000: 0x80400040,
|
5247 | 0x160000: 0x80401000,
|
5248 | 0x170000: 0x80001040,
|
5249 | 0x180000: 0x80401040,
|
5250 | 0x190000: 0x80000000,
|
5251 | 0x1a0000: 0x80400000,
|
5252 | 0x1b0000: 0x401040,
|
5253 | 0x1c0000: 0x80001000,
|
5254 | 0x1d0000: 0x400000,
|
5255 | 0x1e0000: 0x40,
|
5256 | 0x1f0000: 0x1000,
|
5257 | 0x108000: 0x80400000,
|
5258 | 0x118000: 0x80401040,
|
5259 | 0x128000: 0x0,
|
5260 | 0x138000: 0x401000,
|
5261 | 0x148000: 0x400040,
|
5262 | 0x158000: 0x80000000,
|
5263 | 0x168000: 0x80001040,
|
5264 | 0x178000: 0x40,
|
5265 | 0x188000: 0x80000040,
|
5266 | 0x198000: 0x1000,
|
5267 | 0x1a8000: 0x80001000,
|
5268 | 0x1b8000: 0x80400040,
|
5269 | 0x1c8000: 0x1040,
|
5270 | 0x1d8000: 0x80401000,
|
5271 | 0x1e8000: 0x400000,
|
5272 | 0x1f8000: 0x401040
|
5273 | },
|
5274 | {
|
5275 | 0x0: 0x80,
|
5276 | 0x1000: 0x1040000,
|
5277 | 0x2000: 0x40000,
|
5278 | 0x3000: 0x20000000,
|
5279 | 0x4000: 0x20040080,
|
5280 | 0x5000: 0x1000080,
|
5281 | 0x6000: 0x21000080,
|
5282 | 0x7000: 0x40080,
|
5283 | 0x8000: 0x1000000,
|
5284 | 0x9000: 0x20040000,
|
5285 | 0xa000: 0x20000080,
|
5286 | 0xb000: 0x21040080,
|
5287 | 0xc000: 0x21040000,
|
5288 | 0xd000: 0x0,
|
5289 | 0xe000: 0x1040080,
|
5290 | 0xf000: 0x21000000,
|
5291 | 0x800: 0x1040080,
|
5292 | 0x1800: 0x21000080,
|
5293 | 0x2800: 0x80,
|
5294 | 0x3800: 0x1040000,
|
5295 | 0x4800: 0x40000,
|
5296 | 0x5800: 0x20040080,
|
5297 | 0x6800: 0x21040000,
|
5298 | 0x7800: 0x20000000,
|
5299 | 0x8800: 0x20040000,
|
5300 | 0x9800: 0x0,
|
5301 | 0xa800: 0x21040080,
|
5302 | 0xb800: 0x1000080,
|
5303 | 0xc800: 0x20000080,
|
5304 | 0xd800: 0x21000000,
|
5305 | 0xe800: 0x1000000,
|
5306 | 0xf800: 0x40080,
|
5307 | 0x10000: 0x40000,
|
5308 | 0x11000: 0x80,
|
5309 | 0x12000: 0x20000000,
|
5310 | 0x13000: 0x21000080,
|
5311 | 0x14000: 0x1000080,
|
5312 | 0x15000: 0x21040000,
|
5313 | 0x16000: 0x20040080,
|
5314 | 0x17000: 0x1000000,
|
5315 | 0x18000: 0x21040080,
|
5316 | 0x19000: 0x21000000,
|
5317 | 0x1a000: 0x1040000,
|
5318 | 0x1b000: 0x20040000,
|
5319 | 0x1c000: 0x40080,
|
5320 | 0x1d000: 0x20000080,
|
5321 | 0x1e000: 0x0,
|
5322 | 0x1f000: 0x1040080,
|
5323 | 0x10800: 0x21000080,
|
5324 | 0x11800: 0x1000000,
|
5325 | 0x12800: 0x1040000,
|
5326 | 0x13800: 0x20040080,
|
5327 | 0x14800: 0x20000000,
|
5328 | 0x15800: 0x1040080,
|
5329 | 0x16800: 0x80,
|
5330 | 0x17800: 0x21040000,
|
5331 | 0x18800: 0x40080,
|
5332 | 0x19800: 0x21040080,
|
5333 | 0x1a800: 0x0,
|
5334 | 0x1b800: 0x21000000,
|
5335 | 0x1c800: 0x1000080,
|
5336 | 0x1d800: 0x40000,
|
5337 | 0x1e800: 0x20040000,
|
5338 | 0x1f800: 0x20000080
|
5339 | },
|
5340 | {
|
5341 | 0x0: 0x10000008,
|
5342 | 0x100: 0x2000,
|
5343 | 0x200: 0x10200000,
|
5344 | 0x300: 0x10202008,
|
5345 | 0x400: 0x10002000,
|
5346 | 0x500: 0x200000,
|
5347 | 0x600: 0x200008,
|
5348 | 0x700: 0x10000000,
|
5349 | 0x800: 0x0,
|
5350 | 0x900: 0x10002008,
|
5351 | 0xa00: 0x202000,
|
5352 | 0xb00: 0x8,
|
5353 | 0xc00: 0x10200008,
|
5354 | 0xd00: 0x202008,
|
5355 | 0xe00: 0x2008,
|
5356 | 0xf00: 0x10202000,
|
5357 | 0x80: 0x10200000,
|
5358 | 0x180: 0x10202008,
|
5359 | 0x280: 0x8,
|
5360 | 0x380: 0x200000,
|
5361 | 0x480: 0x202008,
|
5362 | 0x580: 0x10000008,
|
5363 | 0x680: 0x10002000,
|
5364 | 0x780: 0x2008,
|
5365 | 0x880: 0x200008,
|
5366 | 0x980: 0x2000,
|
5367 | 0xa80: 0x10002008,
|
5368 | 0xb80: 0x10200008,
|
5369 | 0xc80: 0x0,
|
5370 | 0xd80: 0x10202000,
|
5371 | 0xe80: 0x202000,
|
5372 | 0xf80: 0x10000000,
|
5373 | 0x1000: 0x10002000,
|
5374 | 0x1100: 0x10200008,
|
5375 | 0x1200: 0x10202008,
|
5376 | 0x1300: 0x2008,
|
5377 | 0x1400: 0x200000,
|
5378 | 0x1500: 0x10000000,
|
5379 | 0x1600: 0x10000008,
|
5380 | 0x1700: 0x202000,
|
5381 | 0x1800: 0x202008,
|
5382 | 0x1900: 0x0,
|
5383 | 0x1a00: 0x8,
|
5384 | 0x1b00: 0x10200000,
|
5385 | 0x1c00: 0x2000,
|
5386 | 0x1d00: 0x10002008,
|
5387 | 0x1e00: 0x10202000,
|
5388 | 0x1f00: 0x200008,
|
5389 | 0x1080: 0x8,
|
5390 | 0x1180: 0x202000,
|
5391 | 0x1280: 0x200000,
|
5392 | 0x1380: 0x10000008,
|
5393 | 0x1480: 0x10002000,
|
5394 | 0x1580: 0x2008,
|
5395 | 0x1680: 0x10202008,
|
5396 | 0x1780: 0x10200000,
|
5397 | 0x1880: 0x10202000,
|
5398 | 0x1980: 0x10200008,
|
5399 | 0x1a80: 0x2000,
|
5400 | 0x1b80: 0x202008,
|
5401 | 0x1c80: 0x200008,
|
5402 | 0x1d80: 0x0,
|
5403 | 0x1e80: 0x10000000,
|
5404 | 0x1f80: 0x10002008
|
5405 | },
|
5406 | {
|
5407 | 0x0: 0x100000,
|
5408 | 0x10: 0x2000401,
|
5409 | 0x20: 0x400,
|
5410 | 0x30: 0x100401,
|
5411 | 0x40: 0x2100401,
|
5412 | 0x50: 0x0,
|
5413 | 0x60: 0x1,
|
5414 | 0x70: 0x2100001,
|
5415 | 0x80: 0x2000400,
|
5416 | 0x90: 0x100001,
|
5417 | 0xa0: 0x2000001,
|
5418 | 0xb0: 0x2100400,
|
5419 | 0xc0: 0x2100000,
|
5420 | 0xd0: 0x401,
|
5421 | 0xe0: 0x100400,
|
5422 | 0xf0: 0x2000000,
|
5423 | 0x8: 0x2100001,
|
5424 | 0x18: 0x0,
|
5425 | 0x28: 0x2000401,
|
5426 | 0x38: 0x2100400,
|
5427 | 0x48: 0x100000,
|
5428 | 0x58: 0x2000001,
|
5429 | 0x68: 0x2000000,
|
5430 | 0x78: 0x401,
|
5431 | 0x88: 0x100401,
|
5432 | 0x98: 0x2000400,
|
5433 | 0xa8: 0x2100000,
|
5434 | 0xb8: 0x100001,
|
5435 | 0xc8: 0x400,
|
5436 | 0xd8: 0x2100401,
|
5437 | 0xe8: 0x1,
|
5438 | 0xf8: 0x100400,
|
5439 | 0x100: 0x2000000,
|
5440 | 0x110: 0x100000,
|
5441 | 0x120: 0x2000401,
|
5442 | 0x130: 0x2100001,
|
5443 | 0x140: 0x100001,
|
5444 | 0x150: 0x2000400,
|
5445 | 0x160: 0x2100400,
|
5446 | 0x170: 0x100401,
|
5447 | 0x180: 0x401,
|
5448 | 0x190: 0x2100401,
|
5449 | 0x1a0: 0x100400,
|
5450 | 0x1b0: 0x1,
|
5451 | 0x1c0: 0x0,
|
5452 | 0x1d0: 0x2100000,
|
5453 | 0x1e0: 0x2000001,
|
5454 | 0x1f0: 0x400,
|
5455 | 0x108: 0x100400,
|
5456 | 0x118: 0x2000401,
|
5457 | 0x128: 0x2100001,
|
5458 | 0x138: 0x1,
|
5459 | 0x148: 0x2000000,
|
5460 | 0x158: 0x100000,
|
5461 | 0x168: 0x401,
|
5462 | 0x178: 0x2100400,
|
5463 | 0x188: 0x2000001,
|
5464 | 0x198: 0x2100000,
|
5465 | 0x1a8: 0x0,
|
5466 | 0x1b8: 0x2100401,
|
5467 | 0x1c8: 0x100401,
|
5468 | 0x1d8: 0x400,
|
5469 | 0x1e8: 0x2000400,
|
5470 | 0x1f8: 0x100001
|
5471 | },
|
5472 | {
|
5473 | 0x0: 0x8000820,
|
5474 | 0x1: 0x20000,
|
5475 | 0x2: 0x8000000,
|
5476 | 0x3: 0x20,
|
5477 | 0x4: 0x20020,
|
5478 | 0x5: 0x8020820,
|
5479 | 0x6: 0x8020800,
|
5480 | 0x7: 0x800,
|
5481 | 0x8: 0x8020000,
|
5482 | 0x9: 0x8000800,
|
5483 | 0xa: 0x20800,
|
5484 | 0xb: 0x8020020,
|
5485 | 0xc: 0x820,
|
5486 | 0xd: 0x0,
|
5487 | 0xe: 0x8000020,
|
5488 | 0xf: 0x20820,
|
5489 | 0x80000000: 0x800,
|
5490 | 0x80000001: 0x8020820,
|
5491 | 0x80000002: 0x8000820,
|
5492 | 0x80000003: 0x8000000,
|
5493 | 0x80000004: 0x8020000,
|
5494 | 0x80000005: 0x20800,
|
5495 | 0x80000006: 0x20820,
|
5496 | 0x80000007: 0x20,
|
5497 | 0x80000008: 0x8000020,
|
5498 | 0x80000009: 0x820,
|
5499 | 0x8000000a: 0x20020,
|
5500 | 0x8000000b: 0x8020800,
|
5501 | 0x8000000c: 0x0,
|
5502 | 0x8000000d: 0x8020020,
|
5503 | 0x8000000e: 0x8000800,
|
5504 | 0x8000000f: 0x20000,
|
5505 | 0x10: 0x20820,
|
5506 | 0x11: 0x8020800,
|
5507 | 0x12: 0x20,
|
5508 | 0x13: 0x800,
|
5509 | 0x14: 0x8000800,
|
5510 | 0x15: 0x8000020,
|
5511 | 0x16: 0x8020020,
|
5512 | 0x17: 0x20000,
|
5513 | 0x18: 0x0,
|
5514 | 0x19: 0x20020,
|
5515 | 0x1a: 0x8020000,
|
5516 | 0x1b: 0x8000820,
|
5517 | 0x1c: 0x8020820,
|
5518 | 0x1d: 0x20800,
|
5519 | 0x1e: 0x820,
|
5520 | 0x1f: 0x8000000,
|
5521 | 0x80000010: 0x20000,
|
5522 | 0x80000011: 0x800,
|
5523 | 0x80000012: 0x8020020,
|
5524 | 0x80000013: 0x20820,
|
5525 | 0x80000014: 0x20,
|
5526 | 0x80000015: 0x8020000,
|
5527 | 0x80000016: 0x8000000,
|
5528 | 0x80000017: 0x8000820,
|
5529 | 0x80000018: 0x8020820,
|
5530 | 0x80000019: 0x8000020,
|
5531 | 0x8000001a: 0x8000800,
|
5532 | 0x8000001b: 0x0,
|
5533 | 0x8000001c: 0x20800,
|
5534 | 0x8000001d: 0x820,
|
5535 | 0x8000001e: 0x20020,
|
5536 | 0x8000001f: 0x8020800
|
5537 | }
|
5538 | ];
|
5539 |
|
5540 |
|
5541 | var SBOX_MASK = [
|
5542 | 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
|
5543 | 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
|
5544 | ];
|
5545 |
|
5546 | |
5547 |
|
5548 |
|
5549 | var DES = C_algo.DES = BlockCipher.extend({
|
5550 | _doReset: function () {
|
5551 |
|
5552 | var key = this._key;
|
5553 | var keyWords = key.words;
|
5554 |
|
5555 |
|
5556 | var keyBits = [];
|
5557 | for (var i = 0; i < 56; i++) {
|
5558 | var keyBitPos = PC1[i] - 1;
|
5559 | keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
|
5560 | }
|
5561 |
|
5562 |
|
5563 | var subKeys = this._subKeys = [];
|
5564 | for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
|
5565 |
|
5566 | var subKey = subKeys[nSubKey] = [];
|
5567 |
|
5568 |
|
5569 | var bitShift = BIT_SHIFTS[nSubKey];
|
5570 |
|
5571 |
|
5572 | for (var i = 0; i < 24; i++) {
|
5573 |
|
5574 | subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
|
5575 |
|
5576 |
|
5577 | subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
|
5578 | }
|
5579 |
|
5580 |
|
5581 |
|
5582 |
|
5583 | subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
|
5584 | for (var i = 1; i < 7; i++) {
|
5585 | subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
|
5586 | }
|
5587 | subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
|
5588 | }
|
5589 |
|
5590 |
|
5591 | var invSubKeys = this._invSubKeys = [];
|
5592 | for (var i = 0; i < 16; i++) {
|
5593 | invSubKeys[i] = subKeys[15 - i];
|
5594 | }
|
5595 | },
|
5596 |
|
5597 | encryptBlock: function (M, offset) {
|
5598 | this._doCryptBlock(M, offset, this._subKeys);
|
5599 | },
|
5600 |
|
5601 | decryptBlock: function (M, offset) {
|
5602 | this._doCryptBlock(M, offset, this._invSubKeys);
|
5603 | },
|
5604 |
|
5605 | _doCryptBlock: function (M, offset, subKeys) {
|
5606 |
|
5607 | this._lBlock = M[offset];
|
5608 | this._rBlock = M[offset + 1];
|
5609 |
|
5610 |
|
5611 | exchangeLR.call(this, 4, 0x0f0f0f0f);
|
5612 | exchangeLR.call(this, 16, 0x0000ffff);
|
5613 | exchangeRL.call(this, 2, 0x33333333);
|
5614 | exchangeRL.call(this, 8, 0x00ff00ff);
|
5615 | exchangeLR.call(this, 1, 0x55555555);
|
5616 |
|
5617 |
|
5618 | for (var round = 0; round < 16; round++) {
|
5619 |
|
5620 | var subKey = subKeys[round];
|
5621 | var lBlock = this._lBlock;
|
5622 | var rBlock = this._rBlock;
|
5623 |
|
5624 |
|
5625 | var f = 0;
|
5626 | for (var i = 0; i < 8; i++) {
|
5627 | f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
|
5628 | }
|
5629 | this._lBlock = rBlock;
|
5630 | this._rBlock = lBlock ^ f;
|
5631 | }
|
5632 |
|
5633 |
|
5634 | var t = this._lBlock;
|
5635 | this._lBlock = this._rBlock;
|
5636 | this._rBlock = t;
|
5637 |
|
5638 |
|
5639 | exchangeLR.call(this, 1, 0x55555555);
|
5640 | exchangeRL.call(this, 8, 0x00ff00ff);
|
5641 | exchangeRL.call(this, 2, 0x33333333);
|
5642 | exchangeLR.call(this, 16, 0x0000ffff);
|
5643 | exchangeLR.call(this, 4, 0x0f0f0f0f);
|
5644 |
|
5645 |
|
5646 | M[offset] = this._lBlock;
|
5647 | M[offset + 1] = this._rBlock;
|
5648 | },
|
5649 |
|
5650 | keySize: 64/32,
|
5651 |
|
5652 | ivSize: 64/32,
|
5653 |
|
5654 | blockSize: 64/32
|
5655 | });
|
5656 |
|
5657 |
|
5658 | function exchangeLR(offset, mask) {
|
5659 | var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
|
5660 | this._rBlock ^= t;
|
5661 | this._lBlock ^= t << offset;
|
5662 | }
|
5663 |
|
5664 | function exchangeRL(offset, mask) {
|
5665 | var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
|
5666 | this._lBlock ^= t;
|
5667 | this._rBlock ^= t << offset;
|
5668 | }
|
5669 |
|
5670 | |
5671 |
|
5672 |
|
5673 |
|
5674 |
|
5675 |
|
5676 |
|
5677 |
|
5678 | C.DES = BlockCipher._createHelper(DES);
|
5679 |
|
5680 | |
5681 |
|
5682 |
|
5683 | var TripleDES = C_algo.TripleDES = BlockCipher.extend({
|
5684 | _doReset: function () {
|
5685 |
|
5686 | var key = this._key;
|
5687 | var keyWords = key.words;
|
5688 |
|
5689 | if (keyWords.length !== 2 && keyWords.length !== 4 && keyWords.length < 6) {
|
5690 | throw new Error('Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.');
|
5691 | }
|
5692 |
|
5693 |
|
5694 | var key1 = keyWords.slice(0, 2);
|
5695 | var key2 = keyWords.length < 4 ? keyWords.slice(0, 2) : keyWords.slice(2, 4);
|
5696 | var key3 = keyWords.length < 6 ? keyWords.slice(0, 2) : keyWords.slice(4, 6);
|
5697 |
|
5698 |
|
5699 | this._des1 = DES.createEncryptor(WordArray.create(key1));
|
5700 | this._des2 = DES.createEncryptor(WordArray.create(key2));
|
5701 | this._des3 = DES.createEncryptor(WordArray.create(key3));
|
5702 | },
|
5703 |
|
5704 | encryptBlock: function (M, offset) {
|
5705 | this._des1.encryptBlock(M, offset);
|
5706 | this._des2.decryptBlock(M, offset);
|
5707 | this._des3.encryptBlock(M, offset);
|
5708 | },
|
5709 |
|
5710 | decryptBlock: function (M, offset) {
|
5711 | this._des3.decryptBlock(M, offset);
|
5712 | this._des2.encryptBlock(M, offset);
|
5713 | this._des1.decryptBlock(M, offset);
|
5714 | },
|
5715 |
|
5716 | keySize: 192/32,
|
5717 |
|
5718 | ivSize: 64/32,
|
5719 |
|
5720 | blockSize: 64/32
|
5721 | });
|
5722 |
|
5723 | |
5724 |
|
5725 |
|
5726 |
|
5727 |
|
5728 |
|
5729 |
|
5730 |
|
5731 | C.TripleDES = BlockCipher._createHelper(TripleDES);
|
5732 | }());
|
5733 |
|
5734 |
|
5735 | (function () {
|
5736 |
|
5737 | var C = CryptoJS;
|
5738 | var C_lib = C.lib;
|
5739 | var StreamCipher = C_lib.StreamCipher;
|
5740 | var C_algo = C.algo;
|
5741 |
|
5742 | |
5743 |
|
5744 |
|
5745 | var RC4 = C_algo.RC4 = StreamCipher.extend({
|
5746 | _doReset: function () {
|
5747 |
|
5748 | var key = this._key;
|
5749 | var keyWords = key.words;
|
5750 | var keySigBytes = key.sigBytes;
|
5751 |
|
5752 |
|
5753 | var S = this._S = [];
|
5754 | for (var i = 0; i < 256; i++) {
|
5755 | S[i] = i;
|
5756 | }
|
5757 |
|
5758 |
|
5759 | for (var i = 0, j = 0; i < 256; i++) {
|
5760 | var keyByteIndex = i % keySigBytes;
|
5761 | var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
|
5762 |
|
5763 | j = (j + S[i] + keyByte) % 256;
|
5764 |
|
5765 |
|
5766 | var t = S[i];
|
5767 | S[i] = S[j];
|
5768 | S[j] = t;
|
5769 | }
|
5770 |
|
5771 |
|
5772 | this._i = this._j = 0;
|
5773 | },
|
5774 |
|
5775 | _doProcessBlock: function (M, offset) {
|
5776 | M[offset] ^= generateKeystreamWord.call(this);
|
5777 | },
|
5778 |
|
5779 | keySize: 256/32,
|
5780 |
|
5781 | ivSize: 0
|
5782 | });
|
5783 |
|
5784 | function generateKeystreamWord() {
|
5785 |
|
5786 | var S = this._S;
|
5787 | var i = this._i;
|
5788 | var j = this._j;
|
5789 |
|
5790 |
|
5791 | var keystreamWord = 0;
|
5792 | for (var n = 0; n < 4; n++) {
|
5793 | i = (i + 1) % 256;
|
5794 | j = (j + S[i]) % 256;
|
5795 |
|
5796 |
|
5797 | var t = S[i];
|
5798 | S[i] = S[j];
|
5799 | S[j] = t;
|
5800 |
|
5801 | keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
|
5802 | }
|
5803 |
|
5804 |
|
5805 | this._i = i;
|
5806 | this._j = j;
|
5807 |
|
5808 | return keystreamWord;
|
5809 | }
|
5810 |
|
5811 | |
5812 |
|
5813 |
|
5814 |
|
5815 |
|
5816 |
|
5817 |
|
5818 |
|
5819 | C.RC4 = StreamCipher._createHelper(RC4);
|
5820 |
|
5821 | |
5822 |
|
5823 |
|
5824 | var RC4Drop = C_algo.RC4Drop = RC4.extend({
|
5825 | |
5826 |
|
5827 |
|
5828 |
|
5829 |
|
5830 | cfg: RC4.cfg.extend({
|
5831 | drop: 192
|
5832 | }),
|
5833 |
|
5834 | _doReset: function () {
|
5835 | RC4._doReset.call(this);
|
5836 |
|
5837 |
|
5838 | for (var i = this.cfg.drop; i > 0; i--) {
|
5839 | generateKeystreamWord.call(this);
|
5840 | }
|
5841 | }
|
5842 | });
|
5843 |
|
5844 | |
5845 |
|
5846 |
|
5847 |
|
5848 |
|
5849 |
|
5850 |
|
5851 |
|
5852 | C.RC4Drop = StreamCipher._createHelper(RC4Drop);
|
5853 | }());
|
5854 |
|
5855 |
|
5856 | (function () {
|
5857 |
|
5858 | var C = CryptoJS;
|
5859 | var C_lib = C.lib;
|
5860 | var StreamCipher = C_lib.StreamCipher;
|
5861 | var C_algo = C.algo;
|
5862 |
|
5863 |
|
5864 | var S = [];
|
5865 | var C_ = [];
|
5866 | var G = [];
|
5867 |
|
5868 | |
5869 |
|
5870 |
|
5871 | var Rabbit = C_algo.Rabbit = StreamCipher.extend({
|
5872 | _doReset: function () {
|
5873 |
|
5874 | var K = this._key.words;
|
5875 | var iv = this.cfg.iv;
|
5876 |
|
5877 |
|
5878 | for (var i = 0; i < 4; i++) {
|
5879 | K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) |
|
5880 | (((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00);
|
5881 | }
|
5882 |
|
5883 |
|
5884 | var X = this._X = [
|
5885 | K[0], (K[3] << 16) | (K[2] >>> 16),
|
5886 | K[1], (K[0] << 16) | (K[3] >>> 16),
|
5887 | K[2], (K[1] << 16) | (K[0] >>> 16),
|
5888 | K[3], (K[2] << 16) | (K[1] >>> 16)
|
5889 | ];
|
5890 |
|
5891 |
|
5892 | var C = this._C = [
|
5893 | (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
|
5894 | (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
|
5895 | (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
|
5896 | (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
|
5897 | ];
|
5898 |
|
5899 |
|
5900 | this._b = 0;
|
5901 |
|
5902 |
|
5903 | for (var i = 0; i < 4; i++) {
|
5904 | nextState.call(this);
|
5905 | }
|
5906 |
|
5907 |
|
5908 | for (var i = 0; i < 8; i++) {
|
5909 | C[i] ^= X[(i + 4) & 7];
|
5910 | }
|
5911 |
|
5912 |
|
5913 | if (iv) {
|
5914 |
|
5915 | var IV = iv.words;
|
5916 | var IV_0 = IV[0];
|
5917 | var IV_1 = IV[1];
|
5918 |
|
5919 |
|
5920 | var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
|
5921 | var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
|
5922 | var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
|
5923 | var i3 = (i2 << 16) | (i0 & 0x0000ffff);
|
5924 |
|
5925 |
|
5926 | C[0] ^= i0;
|
5927 | C[1] ^= i1;
|
5928 | C[2] ^= i2;
|
5929 | C[3] ^= i3;
|
5930 | C[4] ^= i0;
|
5931 | C[5] ^= i1;
|
5932 | C[6] ^= i2;
|
5933 | C[7] ^= i3;
|
5934 |
|
5935 |
|
5936 | for (var i = 0; i < 4; i++) {
|
5937 | nextState.call(this);
|
5938 | }
|
5939 | }
|
5940 | },
|
5941 |
|
5942 | _doProcessBlock: function (M, offset) {
|
5943 |
|
5944 | var X = this._X;
|
5945 |
|
5946 |
|
5947 | nextState.call(this);
|
5948 |
|
5949 |
|
5950 | S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
|
5951 | S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
|
5952 | S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
|
5953 | S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
|
5954 |
|
5955 | for (var i = 0; i < 4; i++) {
|
5956 |
|
5957 | S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
|
5958 | (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
|
5959 |
|
5960 |
|
5961 | M[offset + i] ^= S[i];
|
5962 | }
|
5963 | },
|
5964 |
|
5965 | blockSize: 128/32,
|
5966 |
|
5967 | ivSize: 64/32
|
5968 | });
|
5969 |
|
5970 | function nextState() {
|
5971 |
|
5972 | var X = this._X;
|
5973 | var C = this._C;
|
5974 |
|
5975 |
|
5976 | for (var i = 0; i < 8; i++) {
|
5977 | C_[i] = C[i];
|
5978 | }
|
5979 |
|
5980 |
|
5981 | C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
|
5982 | C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
|
5983 | C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
|
5984 | C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
|
5985 | C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
|
5986 | C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
|
5987 | C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
|
5988 | C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
|
5989 | this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
|
5990 |
|
5991 |
|
5992 | for (var i = 0; i < 8; i++) {
|
5993 | var gx = X[i] + C[i];
|
5994 |
|
5995 |
|
5996 | var ga = gx & 0xffff;
|
5997 | var gb = gx >>> 16;
|
5998 |
|
5999 |
|
6000 | var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
|
6001 | var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
|
6002 |
|
6003 |
|
6004 | G[i] = gh ^ gl;
|
6005 | }
|
6006 |
|
6007 |
|
6008 | X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
|
6009 | X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
|
6010 | X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
|
6011 | X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
|
6012 | X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
|
6013 | X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
|
6014 | X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
|
6015 | X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
|
6016 | }
|
6017 |
|
6018 | |
6019 |
|
6020 |
|
6021 |
|
6022 |
|
6023 |
|
6024 |
|
6025 |
|
6026 | C.Rabbit = StreamCipher._createHelper(Rabbit);
|
6027 | }());
|
6028 |
|
6029 |
|
6030 | (function () {
|
6031 |
|
6032 | var C = CryptoJS;
|
6033 | var C_lib = C.lib;
|
6034 | var StreamCipher = C_lib.StreamCipher;
|
6035 | var C_algo = C.algo;
|
6036 |
|
6037 |
|
6038 | var S = [];
|
6039 | var C_ = [];
|
6040 | var G = [];
|
6041 |
|
6042 | |
6043 |
|
6044 |
|
6045 |
|
6046 |
|
6047 |
|
6048 |
|
6049 | var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
|
6050 | _doReset: function () {
|
6051 |
|
6052 | var K = this._key.words;
|
6053 | var iv = this.cfg.iv;
|
6054 |
|
6055 |
|
6056 | var X = this._X = [
|
6057 | K[0], (K[3] << 16) | (K[2] >>> 16),
|
6058 | K[1], (K[0] << 16) | (K[3] >>> 16),
|
6059 | K[2], (K[1] << 16) | (K[0] >>> 16),
|
6060 | K[3], (K[2] << 16) | (K[1] >>> 16)
|
6061 | ];
|
6062 |
|
6063 |
|
6064 | var C = this._C = [
|
6065 | (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
|
6066 | (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
|
6067 | (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
|
6068 | (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
|
6069 | ];
|
6070 |
|
6071 |
|
6072 | this._b = 0;
|
6073 |
|
6074 |
|
6075 | for (var i = 0; i < 4; i++) {
|
6076 | nextState.call(this);
|
6077 | }
|
6078 |
|
6079 |
|
6080 | for (var i = 0; i < 8; i++) {
|
6081 | C[i] ^= X[(i + 4) & 7];
|
6082 | }
|
6083 |
|
6084 |
|
6085 | if (iv) {
|
6086 |
|
6087 | var IV = iv.words;
|
6088 | var IV_0 = IV[0];
|
6089 | var IV_1 = IV[1];
|
6090 |
|
6091 |
|
6092 | var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
|
6093 | var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
|
6094 | var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
|
6095 | var i3 = (i2 << 16) | (i0 & 0x0000ffff);
|
6096 |
|
6097 |
|
6098 | C[0] ^= i0;
|
6099 | C[1] ^= i1;
|
6100 | C[2] ^= i2;
|
6101 | C[3] ^= i3;
|
6102 | C[4] ^= i0;
|
6103 | C[5] ^= i1;
|
6104 | C[6] ^= i2;
|
6105 | C[7] ^= i3;
|
6106 |
|
6107 |
|
6108 | for (var i = 0; i < 4; i++) {
|
6109 | nextState.call(this);
|
6110 | }
|
6111 | }
|
6112 | },
|
6113 |
|
6114 | _doProcessBlock: function (M, offset) {
|
6115 |
|
6116 | var X = this._X;
|
6117 |
|
6118 |
|
6119 | nextState.call(this);
|
6120 |
|
6121 |
|
6122 | S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
|
6123 | S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
|
6124 | S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
|
6125 | S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
|
6126 |
|
6127 | for (var i = 0; i < 4; i++) {
|
6128 |
|
6129 | S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
|
6130 | (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
|
6131 |
|
6132 |
|
6133 | M[offset + i] ^= S[i];
|
6134 | }
|
6135 | },
|
6136 |
|
6137 | blockSize: 128/32,
|
6138 |
|
6139 | ivSize: 64/32
|
6140 | });
|
6141 |
|
6142 | function nextState() {
|
6143 |
|
6144 | var X = this._X;
|
6145 | var C = this._C;
|
6146 |
|
6147 |
|
6148 | for (var i = 0; i < 8; i++) {
|
6149 | C_[i] = C[i];
|
6150 | }
|
6151 |
|
6152 |
|
6153 | C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
|
6154 | C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
|
6155 | C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
|
6156 | C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
|
6157 | C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
|
6158 | C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
|
6159 | C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
|
6160 | C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
|
6161 | this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
|
6162 |
|
6163 |
|
6164 | for (var i = 0; i < 8; i++) {
|
6165 | var gx = X[i] + C[i];
|
6166 |
|
6167 |
|
6168 | var ga = gx & 0xffff;
|
6169 | var gb = gx >>> 16;
|
6170 |
|
6171 |
|
6172 | var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
|
6173 | var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
|
6174 |
|
6175 |
|
6176 | G[i] = gh ^ gl;
|
6177 | }
|
6178 |
|
6179 |
|
6180 | X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
|
6181 | X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
|
6182 | X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
|
6183 | X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
|
6184 | X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
|
6185 | X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
|
6186 | X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
|
6187 | X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
|
6188 | }
|
6189 |
|
6190 | |
6191 |
|
6192 |
|
6193 |
|
6194 |
|
6195 |
|
6196 |
|
6197 |
|
6198 | C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
|
6199 | }());
|
6200 |
|
6201 |
|
6202 | (function () {
|
6203 |
|
6204 | var C = CryptoJS;
|
6205 | var C_lib = C.lib;
|
6206 | var BlockCipher = C_lib.BlockCipher;
|
6207 | var C_algo = C.algo;
|
6208 |
|
6209 | const N = 16;
|
6210 |
|
6211 |
|
6212 | const ORIG_P = [
|
6213 | 0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344,
|
6214 | 0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89,
|
6215 | 0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
|
6216 | 0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917,
|
6217 | 0x9216D5D9, 0x8979FB1B
|
6218 | ];
|
6219 |
|
6220 | const ORIG_S = [
|
6221 | [ 0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7,
|
6222 | 0xB8E1AFED, 0x6A267E96, 0xBA7C9045, 0xF12C7F99,
|
6223 | 0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16,
|
6224 | 0x636920D8, 0x71574E69, 0xA458FEA3, 0xF4933D7E,
|
6225 | 0x0D95748F, 0x728EB658, 0x718BCD58, 0x82154AEE,
|
6226 | 0x7B54A41D, 0xC25A59B5, 0x9C30D539, 0x2AF26013,
|
6227 | 0xC5D1B023, 0x286085F0, 0xCA417918, 0xB8DB38EF,
|
6228 | 0x8E79DCB0, 0x603A180E, 0x6C9E0E8B, 0xB01E8A3E,
|
6229 | 0xD71577C1, 0xBD314B27, 0x78AF2FDA, 0x55605C60,
|
6230 | 0xE65525F3, 0xAA55AB94, 0x57489862, 0x63E81440,
|
6231 | 0x55CA396A, 0x2AAB10B6, 0xB4CC5C34, 0x1141E8CE,
|
6232 | 0xA15486AF, 0x7C72E993, 0xB3EE1411, 0x636FBC2A,
|
6233 | 0x2BA9C55D, 0x741831F6, 0xCE5C3E16, 0x9B87931E,
|
6234 | 0xAFD6BA33, 0x6C24CF5C, 0x7A325381, 0x28958677,
|
6235 | 0x3B8F4898, 0x6B4BB9AF, 0xC4BFE81B, 0x66282193,
|
6236 | 0x61D809CC, 0xFB21A991, 0x487CAC60, 0x5DEC8032,
|
6237 | 0xEF845D5D, 0xE98575B1, 0xDC262302, 0xEB651B88,
|
6238 | 0x23893E81, 0xD396ACC5, 0x0F6D6FF3, 0x83F44239,
|
6239 | 0x2E0B4482, 0xA4842004, 0x69C8F04A, 0x9E1F9B5E,
|
6240 | 0x21C66842, 0xF6E96C9A, 0x670C9C61, 0xABD388F0,
|
6241 | 0x6A51A0D2, 0xD8542F68, 0x960FA728, 0xAB5133A3,
|
6242 | 0x6EEF0B6C, 0x137A3BE4, 0xBA3BF050, 0x7EFB2A98,
|
6243 | 0xA1F1651D, 0x39AF0176, 0x66CA593E, 0x82430E88,
|
6244 | 0x8CEE8619, 0x456F9FB4, 0x7D84A5C3, 0x3B8B5EBE,
|
6245 | 0xE06F75D8, 0x85C12073, 0x401A449F, 0x56C16AA6,
|
6246 | 0x4ED3AA62, 0x363F7706, 0x1BFEDF72, 0x429B023D,
|
6247 | 0x37D0D724, 0xD00A1248, 0xDB0FEAD3, 0x49F1C09B,
|
6248 | 0x075372C9, 0x80991B7B, 0x25D479D8, 0xF6E8DEF7,
|
6249 | 0xE3FE501A, 0xB6794C3B, 0x976CE0BD, 0x04C006BA,
|
6250 | 0xC1A94FB6, 0x409F60C4, 0x5E5C9EC2, 0x196A2463,
|
6251 | 0x68FB6FAF, 0x3E6C53B5, 0x1339B2EB, 0x3B52EC6F,
|
6252 | 0x6DFC511F, 0x9B30952C, 0xCC814544, 0xAF5EBD09,
|
6253 | 0xBEE3D004, 0xDE334AFD, 0x660F2807, 0x192E4BB3,
|
6254 | 0xC0CBA857, 0x45C8740F, 0xD20B5F39, 0xB9D3FBDB,
|
6255 | 0x5579C0BD, 0x1A60320A, 0xD6A100C6, 0x402C7279,
|
6256 | 0x679F25FE, 0xFB1FA3CC, 0x8EA5E9F8, 0xDB3222F8,
|
6257 | 0x3C7516DF, 0xFD616B15, 0x2F501EC8, 0xAD0552AB,
|
6258 | 0x323DB5FA, 0xFD238760, 0x53317B48, 0x3E00DF82,
|
6259 | 0x9E5C57BB, 0xCA6F8CA0, 0x1A87562E, 0xDF1769DB,
|
6260 | 0xD542A8F6, 0x287EFFC3, 0xAC6732C6, 0x8C4F5573,
|
6261 | 0x695B27B0, 0xBBCA58C8, 0xE1FFA35D, 0xB8F011A0,
|
6262 | 0x10FA3D98, 0xFD2183B8, 0x4AFCB56C, 0x2DD1D35B,
|
6263 | 0x9A53E479, 0xB6F84565, 0xD28E49BC, 0x4BFB9790,
|
6264 | 0xE1DDF2DA, 0xA4CB7E33, 0x62FB1341, 0xCEE4C6E8,
|
6265 | 0xEF20CADA, 0x36774C01, 0xD07E9EFE, 0x2BF11FB4,
|
6266 | 0x95DBDA4D, 0xAE909198, 0xEAAD8E71, 0x6B93D5A0,
|
6267 | 0xD08ED1D0, 0xAFC725E0, 0x8E3C5B2F, 0x8E7594B7,
|
6268 | 0x8FF6E2FB, 0xF2122B64, 0x8888B812, 0x900DF01C,
|
6269 | 0x4FAD5EA0, 0x688FC31C, 0xD1CFF191, 0xB3A8C1AD,
|
6270 | 0x2F2F2218, 0xBE0E1777, 0xEA752DFE, 0x8B021FA1,
|
6271 | 0xE5A0CC0F, 0xB56F74E8, 0x18ACF3D6, 0xCE89E299,
|
6272 | 0xB4A84FE0, 0xFD13E0B7, 0x7CC43B81, 0xD2ADA8D9,
|
6273 | 0x165FA266, 0x80957705, 0x93CC7314, 0x211A1477,
|
6274 | 0xE6AD2065, 0x77B5FA86, 0xC75442F5, 0xFB9D35CF,
|
6275 | 0xEBCDAF0C, 0x7B3E89A0, 0xD6411BD3, 0xAE1E7E49,
|
6276 | 0x00250E2D, 0x2071B35E, 0x226800BB, 0x57B8E0AF,
|
6277 | 0x2464369B, 0xF009B91E, 0x5563911D, 0x59DFA6AA,
|
6278 | 0x78C14389, 0xD95A537F, 0x207D5BA2, 0x02E5B9C5,
|
6279 | 0x83260376, 0x6295CFA9, 0x11C81968, 0x4E734A41,
|
6280 | 0xB3472DCA, 0x7B14A94A, 0x1B510052, 0x9A532915,
|
6281 | 0xD60F573F, 0xBC9BC6E4, 0x2B60A476, 0x81E67400,
|
6282 | 0x08BA6FB5, 0x571BE91F, 0xF296EC6B, 0x2A0DD915,
|
6283 | 0xB6636521, 0xE7B9F9B6, 0xFF34052E, 0xC5855664,
|
6284 | 0x53B02D5D, 0xA99F8FA1, 0x08BA4799, 0x6E85076A ],
|
6285 | [ 0x4B7A70E9, 0xB5B32944, 0xDB75092E, 0xC4192623,
|
6286 | 0xAD6EA6B0, 0x49A7DF7D, 0x9CEE60B8, 0x8FEDB266,
|
6287 | 0xECAA8C71, 0x699A17FF, 0x5664526C, 0xC2B19EE1,
|
6288 | 0x193602A5, 0x75094C29, 0xA0591340, 0xE4183A3E,
|
6289 | 0x3F54989A, 0x5B429D65, 0x6B8FE4D6, 0x99F73FD6,
|
6290 | 0xA1D29C07, 0xEFE830F5, 0x4D2D38E6, 0xF0255DC1,
|
6291 | 0x4CDD2086, 0x8470EB26, 0x6382E9C6, 0x021ECC5E,
|
6292 | 0x09686B3F, 0x3EBAEFC9, 0x3C971814, 0x6B6A70A1,
|
6293 | 0x687F3584, 0x52A0E286, 0xB79C5305, 0xAA500737,
|
6294 | 0x3E07841C, 0x7FDEAE5C, 0x8E7D44EC, 0x5716F2B8,
|
6295 | 0xB03ADA37, 0xF0500C0D, 0xF01C1F04, 0x0200B3FF,
|
6296 | 0xAE0CF51A, 0x3CB574B2, 0x25837A58, 0xDC0921BD,
|
6297 | 0xD19113F9, 0x7CA92FF6, 0x94324773, 0x22F54701,
|
6298 | 0x3AE5E581, 0x37C2DADC, 0xC8B57634, 0x9AF3DDA7,
|
6299 | 0xA9446146, 0x0FD0030E, 0xECC8C73E, 0xA4751E41,
|
6300 | 0xE238CD99, 0x3BEA0E2F, 0x3280BBA1, 0x183EB331,
|
6301 | 0x4E548B38, 0x4F6DB908, 0x6F420D03, 0xF60A04BF,
|
6302 | 0x2CB81290, 0x24977C79, 0x5679B072, 0xBCAF89AF,
|
6303 | 0xDE9A771F, 0xD9930810, 0xB38BAE12, 0xDCCF3F2E,
|
6304 | 0x5512721F, 0x2E6B7124, 0x501ADDE6, 0x9F84CD87,
|
6305 | 0x7A584718, 0x7408DA17, 0xBC9F9ABC, 0xE94B7D8C,
|
6306 | 0xEC7AEC3A, 0xDB851DFA, 0x63094366, 0xC464C3D2,
|
6307 | 0xEF1C1847, 0x3215D908, 0xDD433B37, 0x24C2BA16,
|
6308 | 0x12A14D43, 0x2A65C451, 0x50940002, 0x133AE4DD,
|
6309 | 0x71DFF89E, 0x10314E55, 0x81AC77D6, 0x5F11199B,
|
6310 | 0x043556F1, 0xD7A3C76B, 0x3C11183B, 0x5924A509,
|
6311 | 0xF28FE6ED, 0x97F1FBFA, 0x9EBABF2C, 0x1E153C6E,
|
6312 | 0x86E34570, 0xEAE96FB1, 0x860E5E0A, 0x5A3E2AB3,
|
6313 | 0x771FE71C, 0x4E3D06FA, 0x2965DCB9, 0x99E71D0F,
|
6314 | 0x803E89D6, 0x5266C825, 0x2E4CC978, 0x9C10B36A,
|
6315 | 0xC6150EBA, 0x94E2EA78, 0xA5FC3C53, 0x1E0A2DF4,
|
6316 | 0xF2F74EA7, 0x361D2B3D, 0x1939260F, 0x19C27960,
|
6317 | 0x5223A708, 0xF71312B6, 0xEBADFE6E, 0xEAC31F66,
|
6318 | 0xE3BC4595, 0xA67BC883, 0xB17F37D1, 0x018CFF28,
|
6319 | 0xC332DDEF, 0xBE6C5AA5, 0x65582185, 0x68AB9802,
|
6320 | 0xEECEA50F, 0xDB2F953B, 0x2AEF7DAD, 0x5B6E2F84,
|
6321 | 0x1521B628, 0x29076170, 0xECDD4775, 0x619F1510,
|
6322 | 0x13CCA830, 0xEB61BD96, 0x0334FE1E, 0xAA0363CF,
|
6323 | 0xB5735C90, 0x4C70A239, 0xD59E9E0B, 0xCBAADE14,
|
6324 | 0xEECC86BC, 0x60622CA7, 0x9CAB5CAB, 0xB2F3846E,
|
6325 | 0x648B1EAF, 0x19BDF0CA, 0xA02369B9, 0x655ABB50,
|
6326 | 0x40685A32, 0x3C2AB4B3, 0x319EE9D5, 0xC021B8F7,
|
6327 | 0x9B540B19, 0x875FA099, 0x95F7997E, 0x623D7DA8,
|
6328 | 0xF837889A, 0x97E32D77, 0x11ED935F, 0x16681281,
|
6329 | 0x0E358829, 0xC7E61FD6, 0x96DEDFA1, 0x7858BA99,
|
6330 | 0x57F584A5, 0x1B227263, 0x9B83C3FF, 0x1AC24696,
|
6331 | 0xCDB30AEB, 0x532E3054, 0x8FD948E4, 0x6DBC3128,
|
6332 | 0x58EBF2EF, 0x34C6FFEA, 0xFE28ED61, 0xEE7C3C73,
|
6333 | 0x5D4A14D9, 0xE864B7E3, 0x42105D14, 0x203E13E0,
|
6334 | 0x45EEE2B6, 0xA3AAABEA, 0xDB6C4F15, 0xFACB4FD0,
|
6335 | 0xC742F442, 0xEF6ABBB5, 0x654F3B1D, 0x41CD2105,
|
6336 | 0xD81E799E, 0x86854DC7, 0xE44B476A, 0x3D816250,
|
6337 | 0xCF62A1F2, 0x5B8D2646, 0xFC8883A0, 0xC1C7B6A3,
|
6338 | 0x7F1524C3, 0x69CB7492, 0x47848A0B, 0x5692B285,
|
6339 | 0x095BBF00, 0xAD19489D, 0x1462B174, 0x23820E00,
|
6340 | 0x58428D2A, 0x0C55F5EA, 0x1DADF43E, 0x233F7061,
|
6341 | 0x3372F092, 0x8D937E41, 0xD65FECF1, 0x6C223BDB,
|
6342 | 0x7CDE3759, 0xCBEE7460, 0x4085F2A7, 0xCE77326E,
|
6343 | 0xA6078084, 0x19F8509E, 0xE8EFD855, 0x61D99735,
|
6344 | 0xA969A7AA, 0xC50C06C2, 0x5A04ABFC, 0x800BCADC,
|
6345 | 0x9E447A2E, 0xC3453484, 0xFDD56705, 0x0E1E9EC9,
|
6346 | 0xDB73DBD3, 0x105588CD, 0x675FDA79, 0xE3674340,
|
6347 | 0xC5C43465, 0x713E38D8, 0x3D28F89E, 0xF16DFF20,
|
6348 | 0x153E21E7, 0x8FB03D4A, 0xE6E39F2B, 0xDB83ADF7 ],
|
6349 | [ 0xE93D5A68, 0x948140F7, 0xF64C261C, 0x94692934,
|
6350 | 0x411520F7, 0x7602D4F7, 0xBCF46B2E, 0xD4A20068,
|
6351 | 0xD4082471, 0x3320F46A, 0x43B7D4B7, 0x500061AF,
|
6352 | 0x1E39F62E, 0x97244546, 0x14214F74, 0xBF8B8840,
|
6353 | 0x4D95FC1D, 0x96B591AF, 0x70F4DDD3, 0x66A02F45,
|
6354 | 0xBFBC09EC, 0x03BD9785, 0x7FAC6DD0, 0x31CB8504,
|
6355 | 0x96EB27B3, 0x55FD3941, 0xDA2547E6, 0xABCA0A9A,
|
6356 | 0x28507825, 0x530429F4, 0x0A2C86DA, 0xE9B66DFB,
|
6357 | 0x68DC1462, 0xD7486900, 0x680EC0A4, 0x27A18DEE,
|
6358 | 0x4F3FFEA2, 0xE887AD8C, 0xB58CE006, 0x7AF4D6B6,
|
6359 | 0xAACE1E7C, 0xD3375FEC, 0xCE78A399, 0x406B2A42,
|
6360 | 0x20FE9E35, 0xD9F385B9, 0xEE39D7AB, 0x3B124E8B,
|
6361 | 0x1DC9FAF7, 0x4B6D1856, 0x26A36631, 0xEAE397B2,
|
6362 | 0x3A6EFA74, 0xDD5B4332, 0x6841E7F7, 0xCA7820FB,
|
6363 | 0xFB0AF54E, 0xD8FEB397, 0x454056AC, 0xBA489527,
|
6364 | 0x55533A3A, 0x20838D87, 0xFE6BA9B7, 0xD096954B,
|
6365 | 0x55A867BC, 0xA1159A58, 0xCCA92963, 0x99E1DB33,
|
6366 | 0xA62A4A56, 0x3F3125F9, 0x5EF47E1C, 0x9029317C,
|
6367 | 0xFDF8E802, 0x04272F70, 0x80BB155C, 0x05282CE3,
|
6368 | 0x95C11548, 0xE4C66D22, 0x48C1133F, 0xC70F86DC,
|
6369 | 0x07F9C9EE, 0x41041F0F, 0x404779A4, 0x5D886E17,
|
6370 | 0x325F51EB, 0xD59BC0D1, 0xF2BCC18F, 0x41113564,
|
6371 | 0x257B7834, 0x602A9C60, 0xDFF8E8A3, 0x1F636C1B,
|
6372 | 0x0E12B4C2, 0x02E1329E, 0xAF664FD1, 0xCAD18115,
|
6373 | 0x6B2395E0, 0x333E92E1, 0x3B240B62, 0xEEBEB922,
|
6374 | 0x85B2A20E, 0xE6BA0D99, 0xDE720C8C, 0x2DA2F728,
|
6375 | 0xD0127845, 0x95B794FD, 0x647D0862, 0xE7CCF5F0,
|
6376 | 0x5449A36F, 0x877D48FA, 0xC39DFD27, 0xF33E8D1E,
|
6377 | 0x0A476341, 0x992EFF74, 0x3A6F6EAB, 0xF4F8FD37,
|
6378 | 0xA812DC60, 0xA1EBDDF8, 0x991BE14C, 0xDB6E6B0D,
|
6379 | 0xC67B5510, 0x6D672C37, 0x2765D43B, 0xDCD0E804,
|
6380 | 0xF1290DC7, 0xCC00FFA3, 0xB5390F92, 0x690FED0B,
|
6381 | 0x667B9FFB, 0xCEDB7D9C, 0xA091CF0B, 0xD9155EA3,
|
6382 | 0xBB132F88, 0x515BAD24, 0x7B9479BF, 0x763BD6EB,
|
6383 | 0x37392EB3, 0xCC115979, 0x8026E297, 0xF42E312D,
|
6384 | 0x6842ADA7, 0xC66A2B3B, 0x12754CCC, 0x782EF11C,
|
6385 | 0x6A124237, 0xB79251E7, 0x06A1BBE6, 0x4BFB6350,
|
6386 | 0x1A6B1018, 0x11CAEDFA, 0x3D25BDD8, 0xE2E1C3C9,
|
6387 | 0x44421659, 0x0A121386, 0xD90CEC6E, 0xD5ABEA2A,
|
6388 | 0x64AF674E, 0xDA86A85F, 0xBEBFE988, 0x64E4C3FE,
|
6389 | 0x9DBC8057, 0xF0F7C086, 0x60787BF8, 0x6003604D,
|
6390 | 0xD1FD8346, 0xF6381FB0, 0x7745AE04, 0xD736FCCC,
|
6391 | 0x83426B33, 0xF01EAB71, 0xB0804187, 0x3C005E5F,
|
6392 | 0x77A057BE, 0xBDE8AE24, 0x55464299, 0xBF582E61,
|
6393 | 0x4E58F48F, 0xF2DDFDA2, 0xF474EF38, 0x8789BDC2,
|
6394 | 0x5366F9C3, 0xC8B38E74, 0xB475F255, 0x46FCD9B9,
|
6395 | 0x7AEB2661, 0x8B1DDF84, 0x846A0E79, 0x915F95E2,
|
6396 | 0x466E598E, 0x20B45770, 0x8CD55591, 0xC902DE4C,
|
6397 | 0xB90BACE1, 0xBB8205D0, 0x11A86248, 0x7574A99E,
|
6398 | 0xB77F19B6, 0xE0A9DC09, 0x662D09A1, 0xC4324633,
|
6399 | 0xE85A1F02, 0x09F0BE8C, 0x4A99A025, 0x1D6EFE10,
|
6400 | 0x1AB93D1D, 0x0BA5A4DF, 0xA186F20F, 0x2868F169,
|
6401 | 0xDCB7DA83, 0x573906FE, 0xA1E2CE9B, 0x4FCD7F52,
|
6402 | 0x50115E01, 0xA70683FA, 0xA002B5C4, 0x0DE6D027,
|
6403 | 0x9AF88C27, 0x773F8641, 0xC3604C06, 0x61A806B5,
|
6404 | 0xF0177A28, 0xC0F586E0, 0x006058AA, 0x30DC7D62,
|
6405 | 0x11E69ED7, 0x2338EA63, 0x53C2DD94, 0xC2C21634,
|
6406 | 0xBBCBEE56, 0x90BCB6DE, 0xEBFC7DA1, 0xCE591D76,
|
6407 | 0x6F05E409, 0x4B7C0188, 0x39720A3D, 0x7C927C24,
|
6408 | 0x86E3725F, 0x724D9DB9, 0x1AC15BB4, 0xD39EB8FC,
|
6409 | 0xED545578, 0x08FCA5B5, 0xD83D7CD3, 0x4DAD0FC4,
|
6410 | 0x1E50EF5E, 0xB161E6F8, 0xA28514D9, 0x6C51133C,
|
6411 | 0x6FD5C7E7, 0x56E14EC4, 0x362ABFCE, 0xDDC6C837,
|
6412 | 0xD79A3234, 0x92638212, 0x670EFA8E, 0x406000E0 ],
|
6413 | [ 0x3A39CE37, 0xD3FAF5CF, 0xABC27737, 0x5AC52D1B,
|
6414 | 0x5CB0679E, 0x4FA33742, 0xD3822740, 0x99BC9BBE,
|
6415 | 0xD5118E9D, 0xBF0F7315, 0xD62D1C7E, 0xC700C47B,
|
6416 | 0xB78C1B6B, 0x21A19045, 0xB26EB1BE, 0x6A366EB4,
|
6417 | 0x5748AB2F, 0xBC946E79, 0xC6A376D2, 0x6549C2C8,
|
6418 | 0x530FF8EE, 0x468DDE7D, 0xD5730A1D, 0x4CD04DC6,
|
6419 | 0x2939BBDB, 0xA9BA4650, 0xAC9526E8, 0xBE5EE304,
|
6420 | 0xA1FAD5F0, 0x6A2D519A, 0x63EF8CE2, 0x9A86EE22,
|
6421 | 0xC089C2B8, 0x43242EF6, 0xA51E03AA, 0x9CF2D0A4,
|
6422 | 0x83C061BA, 0x9BE96A4D, 0x8FE51550, 0xBA645BD6,
|
6423 | 0x2826A2F9, 0xA73A3AE1, 0x4BA99586, 0xEF5562E9,
|
6424 | 0xC72FEFD3, 0xF752F7DA, 0x3F046F69, 0x77FA0A59,
|
6425 | 0x80E4A915, 0x87B08601, 0x9B09E6AD, 0x3B3EE593,
|
6426 | 0xE990FD5A, 0x9E34D797, 0x2CF0B7D9, 0x022B8B51,
|
6427 | 0x96D5AC3A, 0x017DA67D, 0xD1CF3ED6, 0x7C7D2D28,
|
6428 | 0x1F9F25CF, 0xADF2B89B, 0x5AD6B472, 0x5A88F54C,
|
6429 | 0xE029AC71, 0xE019A5E6, 0x47B0ACFD, 0xED93FA9B,
|
6430 | 0xE8D3C48D, 0x283B57CC, 0xF8D56629, 0x79132E28,
|
6431 | 0x785F0191, 0xED756055, 0xF7960E44, 0xE3D35E8C,
|
6432 | 0x15056DD4, 0x88F46DBA, 0x03A16125, 0x0564F0BD,
|
6433 | 0xC3EB9E15, 0x3C9057A2, 0x97271AEC, 0xA93A072A,
|
6434 | 0x1B3F6D9B, 0x1E6321F5, 0xF59C66FB, 0x26DCF319,
|
6435 | 0x7533D928, 0xB155FDF5, 0x03563482, 0x8ABA3CBB,
|
6436 | 0x28517711, 0xC20AD9F8, 0xABCC5167, 0xCCAD925F,
|
6437 | 0x4DE81751, 0x3830DC8E, 0x379D5862, 0x9320F991,
|
6438 | 0xEA7A90C2, 0xFB3E7BCE, 0x5121CE64, 0x774FBE32,
|
6439 | 0xA8B6E37E, 0xC3293D46, 0x48DE5369, 0x6413E680,
|
6440 | 0xA2AE0810, 0xDD6DB224, 0x69852DFD, 0x09072166,
|
6441 | 0xB39A460A, 0x6445C0DD, 0x586CDECF, 0x1C20C8AE,
|
6442 | 0x5BBEF7DD, 0x1B588D40, 0xCCD2017F, 0x6BB4E3BB,
|
6443 | 0xDDA26A7E, 0x3A59FF45, 0x3E350A44, 0xBCB4CDD5,
|
6444 | 0x72EACEA8, 0xFA6484BB, 0x8D6612AE, 0xBF3C6F47,
|
6445 | 0xD29BE463, 0x542F5D9E, 0xAEC2771B, 0xF64E6370,
|
6446 | 0x740E0D8D, 0xE75B1357, 0xF8721671, 0xAF537D5D,
|
6447 | 0x4040CB08, 0x4EB4E2CC, 0x34D2466A, 0x0115AF84,
|
6448 | 0xE1B00428, 0x95983A1D, 0x06B89FB4, 0xCE6EA048,
|
6449 | 0x6F3F3B82, 0x3520AB82, 0x011A1D4B, 0x277227F8,
|
6450 | 0x611560B1, 0xE7933FDC, 0xBB3A792B, 0x344525BD,
|
6451 | 0xA08839E1, 0x51CE794B, 0x2F32C9B7, 0xA01FBAC9,
|
6452 | 0xE01CC87E, 0xBCC7D1F6, 0xCF0111C3, 0xA1E8AAC7,
|
6453 | 0x1A908749, 0xD44FBD9A, 0xD0DADECB, 0xD50ADA38,
|
6454 | 0x0339C32A, 0xC6913667, 0x8DF9317C, 0xE0B12B4F,
|
6455 | 0xF79E59B7, 0x43F5BB3A, 0xF2D519FF, 0x27D9459C,
|
6456 | 0xBF97222C, 0x15E6FC2A, 0x0F91FC71, 0x9B941525,
|
6457 | 0xFAE59361, 0xCEB69CEB, 0xC2A86459, 0x12BAA8D1,
|
6458 | 0xB6C1075E, 0xE3056A0C, 0x10D25065, 0xCB03A442,
|
6459 | 0xE0EC6E0E, 0x1698DB3B, 0x4C98A0BE, 0x3278E964,
|
6460 | 0x9F1F9532, 0xE0D392DF, 0xD3A0342B, 0x8971F21E,
|
6461 | 0x1B0A7441, 0x4BA3348C, 0xC5BE7120, 0xC37632D8,
|
6462 | 0xDF359F8D, 0x9B992F2E, 0xE60B6F47, 0x0FE3F11D,
|
6463 | 0xE54CDA54, 0x1EDAD891, 0xCE6279CF, 0xCD3E7E6F,
|
6464 | 0x1618B166, 0xFD2C1D05, 0x848FD2C5, 0xF6FB2299,
|
6465 | 0xF523F357, 0xA6327623, 0x93A83531, 0x56CCCD02,
|
6466 | 0xACF08162, 0x5A75EBB5, 0x6E163697, 0x88D273CC,
|
6467 | 0xDE966292, 0x81B949D0, 0x4C50901B, 0x71C65614,
|
6468 | 0xE6C6C7BD, 0x327A140A, 0x45E1D006, 0xC3F27B9A,
|
6469 | 0xC9AA53FD, 0x62A80F00, 0xBB25BFE2, 0x35BDD2F6,
|
6470 | 0x71126905, 0xB2040222, 0xB6CBCF7C, 0xCD769C2B,
|
6471 | 0x53113EC0, 0x1640E3D3, 0x38ABBD60, 0x2547ADF0,
|
6472 | 0xBA38209C, 0xF746CE76, 0x77AFA1C5, 0x20756060,
|
6473 | 0x85CBFE4E, 0x8AE88DD8, 0x7AAAF9B0, 0x4CF9AA7E,
|
6474 | 0x1948C25C, 0x02FB8A8C, 0x01C36AE4, 0xD6EBE1F9,
|
6475 | 0x90D4F869, 0xA65CDEA0, 0x3F09252D, 0xC208E69F,
|
6476 | 0xB74E6132, 0xCE77E25B, 0x578FDFE3, 0x3AC372E6 ]
|
6477 | ];
|
6478 |
|
6479 | var BLOWFISH_CTX = {
|
6480 | pbox: [],
|
6481 | sbox: []
|
6482 | }
|
6483 |
|
6484 | function F(ctx, x){
|
6485 | let a = (x >> 24) & 0xFF;
|
6486 | let b = (x >> 16) & 0xFF;
|
6487 | let c = (x >> 8) & 0xFF;
|
6488 | let d = x & 0xFF;
|
6489 |
|
6490 | let y = ctx.sbox[0][a] + ctx.sbox[1][b];
|
6491 | y = y ^ ctx.sbox[2][c];
|
6492 | y = y + ctx.sbox[3][d];
|
6493 |
|
6494 | return y;
|
6495 | }
|
6496 |
|
6497 | function BlowFish_Encrypt(ctx, left, right){
|
6498 | let Xl = left;
|
6499 | let Xr = right;
|
6500 | let temp;
|
6501 |
|
6502 | for(let i = 0; i < N; ++i){
|
6503 | Xl = Xl ^ ctx.pbox[i];
|
6504 | Xr = F(ctx, Xl) ^ Xr;
|
6505 |
|
6506 | temp = Xl;
|
6507 | Xl = Xr;
|
6508 | Xr = temp;
|
6509 | }
|
6510 |
|
6511 | temp = Xl;
|
6512 | Xl = Xr;
|
6513 | Xr = temp;
|
6514 |
|
6515 | Xr = Xr ^ ctx.pbox[N];
|
6516 | Xl = Xl ^ ctx.pbox[N + 1];
|
6517 |
|
6518 | return {left: Xl, right: Xr};
|
6519 | }
|
6520 |
|
6521 | function BlowFish_Decrypt(ctx, left, right){
|
6522 | let Xl = left;
|
6523 | let Xr = right;
|
6524 | let temp;
|
6525 |
|
6526 | for(let i = N + 1; i > 1; --i){
|
6527 | Xl = Xl ^ ctx.pbox[i];
|
6528 | Xr = F(ctx, Xl) ^ Xr;
|
6529 |
|
6530 | temp = Xl;
|
6531 | Xl = Xr;
|
6532 | Xr = temp;
|
6533 | }
|
6534 |
|
6535 | temp = Xl;
|
6536 | Xl = Xr;
|
6537 | Xr = temp;
|
6538 |
|
6539 | Xr = Xr ^ ctx.pbox[1];
|
6540 | Xl = Xl ^ ctx.pbox[0];
|
6541 |
|
6542 | return {left: Xl, right: Xr};
|
6543 | }
|
6544 |
|
6545 | |
6546 |
|
6547 |
|
6548 |
|
6549 |
|
6550 |
|
6551 |
|
6552 |
|
6553 |
|
6554 |
|
6555 |
|
6556 | function BlowFishInit(ctx, key, keysize)
|
6557 | {
|
6558 | for(let Row = 0; Row < 4; Row++)
|
6559 | {
|
6560 | ctx.sbox[Row] = [];
|
6561 | for(let Col = 0; Col < 256; Col++)
|
6562 | {
|
6563 | ctx.sbox[Row][Col] = ORIG_S[Row][Col];
|
6564 | }
|
6565 | }
|
6566 |
|
6567 | let keyIndex = 0;
|
6568 | for(let index = 0; index < N + 2; index++)
|
6569 | {
|
6570 | ctx.pbox[index] = ORIG_P[index] ^ key[keyIndex];
|
6571 | keyIndex++;
|
6572 | if(keyIndex >= keysize)
|
6573 | {
|
6574 | keyIndex = 0;
|
6575 | }
|
6576 | }
|
6577 |
|
6578 | let Data1 = 0;
|
6579 | let Data2 = 0;
|
6580 | let res = 0;
|
6581 | for(let i = 0; i < N + 2; i += 2)
|
6582 | {
|
6583 | res = BlowFish_Encrypt(ctx, Data1, Data2);
|
6584 | Data1 = res.left;
|
6585 | Data2 = res.right;
|
6586 | ctx.pbox[i] = Data1;
|
6587 | ctx.pbox[i + 1] = Data2;
|
6588 | }
|
6589 |
|
6590 | for(let i = 0; i < 4; i++)
|
6591 | {
|
6592 | for(let j = 0; j < 256; j += 2)
|
6593 | {
|
6594 | res = BlowFish_Encrypt(ctx, Data1, Data2);
|
6595 | Data1 = res.left;
|
6596 | Data2 = res.right;
|
6597 | ctx.sbox[i][j] = Data1;
|
6598 | ctx.sbox[i][j + 1] = Data2;
|
6599 | }
|
6600 | }
|
6601 |
|
6602 | return true;
|
6603 | }
|
6604 |
|
6605 | |
6606 |
|
6607 |
|
6608 | var Blowfish = C_algo.Blowfish = BlockCipher.extend({
|
6609 | _doReset: function () {
|
6610 |
|
6611 | if (this._keyPriorReset === this._key) {
|
6612 | return;
|
6613 | }
|
6614 |
|
6615 |
|
6616 | var key = this._keyPriorReset = this._key;
|
6617 | var keyWords = key.words;
|
6618 | var keySize = key.sigBytes / 4;
|
6619 |
|
6620 |
|
6621 | BlowFishInit(BLOWFISH_CTX, keyWords, keySize);
|
6622 | },
|
6623 |
|
6624 | encryptBlock: function (M, offset) {
|
6625 | var res = BlowFish_Encrypt(BLOWFISH_CTX, M[offset], M[offset + 1]);
|
6626 | M[offset] = res.left;
|
6627 | M[offset + 1] = res.right;
|
6628 | },
|
6629 |
|
6630 | decryptBlock: function (M, offset) {
|
6631 | var res = BlowFish_Decrypt(BLOWFISH_CTX, M[offset], M[offset + 1]);
|
6632 | M[offset] = res.left;
|
6633 | M[offset + 1] = res.right;
|
6634 | },
|
6635 |
|
6636 | blockSize: 64/32,
|
6637 |
|
6638 | keySize: 128/32,
|
6639 |
|
6640 | ivSize: 64/32
|
6641 | });
|
6642 |
|
6643 | |
6644 |
|
6645 |
|
6646 |
|
6647 |
|
6648 |
|
6649 |
|
6650 |
|
6651 | C.Blowfish = BlockCipher._createHelper(Blowfish);
|
6652 | }());
|
6653 |
|
6654 |
|
6655 | return CryptoJS;
|
6656 |
|
6657 | })); |
\ | No newline at end of file |