Permalink
Browse files

Updating cryptojs to 3.1.2 from https://code.google.com/p/crypto-js/

  • Loading branch information...
1 parent 19aec7c commit 46af2dc3a48c0c765dbbb89f918cd77cb4f50252 @Incognito Incognito committed Mar 6, 2013
Showing with 6,922 additions and 0 deletions.
  1. +10 −0 cryptojs/components/aes-min.js
  2. +213 −0 cryptojs/components/aes.js
  3. +14 −0 cryptojs/components/cipher-core-min.js
  4. +863 −0 cryptojs/components/cipher-core.js
  5. +13 −0 cryptojs/components/core-min.js
  6. +712 −0 cryptojs/components/core.js
  7. +8 −0 cryptojs/components/enc-base64-min.js
  8. +109 −0 cryptojs/components/enc-base64.js
  9. +8 −0 cryptojs/components/enc-utf16-min.js
  10. +135 −0 cryptojs/components/enc-utf16.js
  11. +8 −0 cryptojs/components/evpkdf-min.js
  12. +118 −0 cryptojs/components/evpkdf.js
  13. +7 −0 cryptojs/components/format-hex-min.js
  14. +52 −0 cryptojs/components/format-hex.js
  15. +8 −0 cryptojs/components/hmac-min.js
  16. +131 −0 cryptojs/components/hmac.js
  17. +8 −0 cryptojs/components/lib-typedarrays-min.js
  18. +62 −0 cryptojs/components/lib-typedarrays.js
  19. +12 −0 cryptojs/components/md5-min.js
  20. +254 −0 cryptojs/components/md5.js
  21. +7 −0 cryptojs/components/mode-cfb-min.js
  22. +64 −0 cryptojs/components/mode-cfb.js
  23. +14 −0 cryptojs/components/mode-ctr-gladman-min.js
  24. +102 −0 cryptojs/components/mode-ctr-gladman.js
  25. +7 −0 cryptojs/components/mode-ctr-min.js
  26. +44 −0 cryptojs/components/mode-ctr.js
  27. +7 −0 cryptojs/components/mode-ecb-min.js
  28. +26 −0 cryptojs/components/mode-ecb.js
  29. +7 −0 cryptojs/components/mode-ofb-min.js
  30. +40 −0 cryptojs/components/mode-ofb.js
  31. +7 −0 cryptojs/components/pad-ansix923-min.js
  32. +35 −0 cryptojs/components/pad-ansix923.js
  33. +7 −0 cryptojs/components/pad-iso10126-min.js
  34. +30 −0 cryptojs/components/pad-iso10126.js
  35. +7 −0 cryptojs/components/pad-iso97971-min.js
  36. +26 −0 cryptojs/components/pad-iso97971.js
  37. +7 −0 cryptojs/components/pad-nopadding-min.js
  38. +16 −0 cryptojs/components/pad-nopadding.js
  39. +7 −0 cryptojs/components/pad-zeropadding-min.js
  40. +31 −0 cryptojs/components/pad-zeropadding.js
  41. +8 −0 cryptojs/components/pbkdf2-min.js
  42. +131 −0 cryptojs/components/pbkdf2.js
  43. +11 −0 cryptojs/components/rabbit-legacy-min.js
  44. +176 −0 cryptojs/components/rabbit-legacy.js
  45. +11 −0 cryptojs/components/rabbit-min.js
  46. +178 −0 cryptojs/components/rabbit.js
  47. +8 −0 cryptojs/components/rc4-min.js
  48. +125 −0 cryptojs/components/rc4.js
  49. +22 −0 cryptojs/components/ripemd160-min.js
  50. +253 −0 cryptojs/components/ripemd160.js
  51. +8 −0 cryptojs/components/sha1-min.js
  52. +136 −0 cryptojs/components/sha1.js
  53. +7 −0 cryptojs/components/sha224-min.js
  54. +66 −0 cryptojs/components/sha224.js
  55. +9 −0 cryptojs/components/sha256-min.js
  56. +185 −0 cryptojs/components/sha256.js
  57. +11 −0 cryptojs/components/sha3-min.js
  58. +309 −0 cryptojs/components/sha3.js
  59. +8 −0 cryptojs/components/sha384-min.js
  60. +69 −0 cryptojs/components/sha384.js
  61. +15 −0 cryptojs/components/sha512-min.js
  62. +309 −0 cryptojs/components/sha512.js
  63. +26 −0 cryptojs/components/tripledes-min.js
  64. +756 −0 cryptojs/components/tripledes.js
  65. +7 −0 cryptojs/components/x64-core-min.js
  66. +290 −0 cryptojs/components/x64-core.js
  67. +35 −0 cryptojs/rollups/aes.js
  68. +21 −0 cryptojs/rollups/hmac-md5.js
  69. +31 −0 cryptojs/rollups/hmac-ripemd160.js
  70. +17 −0 cryptojs/rollups/hmac-sha1.js
  71. +19 −0 cryptojs/rollups/hmac-sha224.js
  72. +18 −0 cryptojs/rollups/hmac-sha256.js
  73. +21 −0 cryptojs/rollups/hmac-sha3.js
  74. +27 −0 cryptojs/rollups/hmac-sha384.js
  75. +25 −0 cryptojs/rollups/hmac-sha512.js
  76. +19 −0 cryptojs/rollups/md5.js
  77. +19 −0 cryptojs/rollups/pbkdf2.js
  78. +36 −0 cryptojs/rollups/rabbit-legacy.js
  79. +36 −0 cryptojs/rollups/rabbit.js
  80. +33 −0 cryptojs/rollups/rc4.js
  81. +29 −0 cryptojs/rollups/ripemd160.js
  82. +15 −0 cryptojs/rollups/sha1.js
  83. +17 −0 cryptojs/rollups/sha224.js
  84. +16 −0 cryptojs/rollups/sha256.js
  85. +19 −0 cryptojs/rollups/sha3.js
  86. +25 −0 cryptojs/rollups/sha384.js
  87. +23 −0 cryptojs/rollups/sha512.js
  88. +51 −0 cryptojs/rollups/tripledes.js

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -0,0 +1,213 @@
+/*
+CryptoJS v3.1.2
+code.google.com/p/crypto-js
+(c) 2009-2013 by Jeff Mott. All rights reserved.
+code.google.com/p/crypto-js/wiki/License
+*/
+(function () {
+ // Shortcuts
+ var C = CryptoJS;
+ var C_lib = C.lib;
+ var BlockCipher = C_lib.BlockCipher;
+ var C_algo = C.algo;
+
+ // Lookup tables
+ var SBOX = [];
+ var INV_SBOX = [];
+ var SUB_MIX_0 = [];
+ var SUB_MIX_1 = [];
+ var SUB_MIX_2 = [];
+ var SUB_MIX_3 = [];
+ var INV_SUB_MIX_0 = [];
+ var INV_SUB_MIX_1 = [];
+ var INV_SUB_MIX_2 = [];
+ var INV_SUB_MIX_3 = [];
+
+ // Compute lookup tables
+ (function () {
+ // Compute double table
+ var d = [];
+ for (var i = 0; i < 256; i++) {
+ if (i < 128) {
+ d[i] = i << 1;
+ } else {
+ d[i] = (i << 1) ^ 0x11b;
+ }
+ }
+
+ // Walk GF(2^8)
+ var x = 0;
+ var xi = 0;
+ for (var i = 0; i < 256; i++) {
+ // Compute sbox
+ var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
+ sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
+ SBOX[x] = sx;
+ INV_SBOX[sx] = x;
+
+ // Compute multiplication
+ var x2 = d[x];
+ var x4 = d[x2];
+ var x8 = d[x4];
+
+ // Compute sub bytes, mix columns tables
+ var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
+ SUB_MIX_0[x] = (t << 24) | (t >>> 8);
+ SUB_MIX_1[x] = (t << 16) | (t >>> 16);
+ SUB_MIX_2[x] = (t << 8) | (t >>> 24);
+ SUB_MIX_3[x] = t;
+
+ // Compute inv sub bytes, inv mix columns tables
+ var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
+ INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
+ INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
+ INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
+ INV_SUB_MIX_3[sx] = t;
+
+ // Compute next counter
+ if (!x) {
+ x = xi = 1;
+ } else {
+ x = x2 ^ d[d[d[x8 ^ x2]]];
+ xi ^= d[d[xi]];
+ }
+ }
+ }());
+
+ // Precomputed Rcon lookup
+ var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
+
+ /**
+ * AES block cipher algorithm.
+ */
+ var AES = C_algo.AES = BlockCipher.extend({
+ _doReset: function () {
+ // Shortcuts
+ var key = this._key;
+ var keyWords = key.words;
+ var keySize = key.sigBytes / 4;
+
+ // Compute number of rounds
+ var nRounds = this._nRounds = keySize + 6
+
+ // Compute number of key schedule rows
+ var ksRows = (nRounds + 1) * 4;
+
+ // Compute key schedule
+ var keySchedule = this._keySchedule = [];
+ for (var ksRow = 0; ksRow < ksRows; ksRow++) {
+ if (ksRow < keySize) {
+ keySchedule[ksRow] = keyWords[ksRow];
+ } else {
+ var t = keySchedule[ksRow - 1];
+
+ if (!(ksRow % keySize)) {
+ // Rot word
+ t = (t << 8) | (t >>> 24);
+
+ // Sub word
+ t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
+
+ // Mix Rcon
+ t ^= RCON[(ksRow / keySize) | 0] << 24;
+ } else if (keySize > 6 && ksRow % keySize == 4) {
+ // Sub word
+ t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
+ }
+
+ keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
+ }
+ }
+
+ // Compute inv key schedule
+ var invKeySchedule = this._invKeySchedule = [];
+ for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
+ var ksRow = ksRows - invKsRow;
+
+ if (invKsRow % 4) {
+ var t = keySchedule[ksRow];
+ } else {
+ var t = keySchedule[ksRow - 4];
+ }
+
+ if (invKsRow < 4 || ksRow <= 4) {
+ invKeySchedule[invKsRow] = t;
+ } else {
+ invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
+ INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
+ }
+ }
+ },
+
+ encryptBlock: function (M, offset) {
+ this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
+ },
+
+ decryptBlock: function (M, offset) {
+ // Swap 2nd and 4th rows
+ var t = M[offset + 1];
+ M[offset + 1] = M[offset + 3];
+ M[offset + 3] = t;
+
+ this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
+
+ // Inv swap 2nd and 4th rows
+ var t = M[offset + 1];
+ M[offset + 1] = M[offset + 3];
+ M[offset + 3] = t;
+ },
+
+ _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
+ // Shortcut
+ var nRounds = this._nRounds;
+
+ // Get input, add round key
+ var s0 = M[offset] ^ keySchedule[0];
+ var s1 = M[offset + 1] ^ keySchedule[1];
+ var s2 = M[offset + 2] ^ keySchedule[2];
+ var s3 = M[offset + 3] ^ keySchedule[3];
+
+ // Key schedule row counter
+ var ksRow = 4;
+
+ // Rounds
+ for (var round = 1; round < nRounds; round++) {
+ // Shift rows, sub bytes, mix columns, add round key
+ 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++];
+ 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++];
+ 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++];
+ 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++];
+
+ // Update state
+ s0 = t0;
+ s1 = t1;
+ s2 = t2;
+ s3 = t3;
+ }
+
+ // Shift rows, sub bytes, add round key
+ var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
+ var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
+ var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
+ var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
+
+ // Set output
+ M[offset] = t0;
+ M[offset + 1] = t1;
+ M[offset + 2] = t2;
+ M[offset + 3] = t3;
+ },
+
+ keySize: 256/32
+ });
+
+ /**
+ * Shortcut functions to the cipher's object interface.
+ *
+ * @example
+ *
+ * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
+ * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
+ */
+ C.AES = BlockCipher._createHelper(AES);
+}());

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 46af2dc

Please sign in to comment.