@brix-crypto/crypto-js 0.0.1-security → 4.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @brix-crypto/crypto-js might be problematic. Click here for more details.

Files changed (109) hide show
  1. package/.jshintrc +33 -0
  2. package/.travis.yml +15 -0
  3. package/CONTRIBUTING.md +28 -0
  4. package/LICENSE +24 -0
  5. package/README.md +273 -3
  6. package/aes.js +214 -0
  7. package/blowfish.js +451 -0
  8. package/cipher-core.js +877 -0
  9. package/core.js +796 -0
  10. package/docs/QuickStartGuide.wiki +470 -0
  11. package/enc-base64.js +116 -0
  12. package/enc-base64url.js +128 -0
  13. package/enc-utf16.js +129 -0
  14. package/evpkdf.js +114 -0
  15. package/format-hex.js +46 -0
  16. package/hmac.js +125 -0
  17. package/index.js +18 -0
  18. package/lib-typedarrays.js +56 -0
  19. package/md5.js +248 -0
  20. package/mode-cfb.js +60 -0
  21. package/mode-ctr-gladman.js +96 -0
  22. package/mode-ctr.js +38 -0
  23. package/mode-ecb.js +20 -0
  24. package/mode-ofb.js +34 -0
  25. package/package.json +45 -3
  26. package/pad-ansix923.js +29 -0
  27. package/pad-iso10126.js +24 -0
  28. package/pad-iso97971.js +20 -0
  29. package/pad-nopadding.js +10 -0
  30. package/pad-zeropadding.js +27 -0
  31. package/pbkdf2.js +125 -0
  32. package/rabbit-legacy.js +170 -0
  33. package/rabbit.js +172 -0
  34. package/rc4.js +119 -0
  35. package/ripemd160.js +247 -0
  36. package/sha1.js +130 -0
  37. package/sha224.js +60 -0
  38. package/sha256.js +179 -0
  39. package/sha3.js +306 -0
  40. package/sha384.js +63 -0
  41. package/sha512.js +306 -0
  42. package/test/aes-profile.js +31 -0
  43. package/test/aes-test.js +80 -0
  44. package/test/blowfish-test.js +33 -0
  45. package/test/cipher-test.js +522 -0
  46. package/test/config-test.js +51 -0
  47. package/test/des-profile.js +31 -0
  48. package/test/des-test.js +104 -0
  49. package/test/enc-base64-test.js +71 -0
  50. package/test/enc-hex-test.js +15 -0
  51. package/test/enc-latin1-test.js +15 -0
  52. package/test/enc-utf16-test.js +55 -0
  53. package/test/enc-utf8-test.js +39 -0
  54. package/test/evpkdf-profile.js +11 -0
  55. package/test/evpkdf-test.js +32 -0
  56. package/test/format-openssl-test.js +37 -0
  57. package/test/hmac-md5-profile.js +30 -0
  58. package/test/hmac-md5-test.js +59 -0
  59. package/test/hmac-sha224-test.js +59 -0
  60. package/test/hmac-sha256-test.js +59 -0
  61. package/test/hmac-sha384-test.js +59 -0
  62. package/test/hmac-sha512-test.js +59 -0
  63. package/test/kdf-openssl-test.js +15 -0
  64. package/test/lib-base-test.js +92 -0
  65. package/test/lib-cipherparams-test.js +59 -0
  66. package/test/lib-passwordbasedcipher-test.js +25 -0
  67. package/test/lib-serializablecipher-test.js +51 -0
  68. package/test/lib-typedarrays-test.js +57 -0
  69. package/test/lib-wordarray-test.js +85 -0
  70. package/test/md5-profile.js +24 -0
  71. package/test/md5-test.js +70 -0
  72. package/test/mode-cbc-test.js +49 -0
  73. package/test/mode-cfb-test.js +51 -0
  74. package/test/mode-ctr-test.js +55 -0
  75. package/test/mode-ecb-test.js +38 -0
  76. package/test/mode-ofb-test.js +50 -0
  77. package/test/pad-ansix923-test.js +28 -0
  78. package/test/pad-iso10126-test.js +50 -0
  79. package/test/pad-iso97971-test.js +35 -0
  80. package/test/pad-pkcs7-test.js +28 -0
  81. package/test/pad-zeropadding-test.js +28 -0
  82. package/test/pbkdf2-profile.js +11 -0
  83. package/test/pbkdf2-test.js +80 -0
  84. package/test/profile.html +281 -0
  85. package/test/rabbit-legacy-test.js +80 -0
  86. package/test/rabbit-profile.js +30 -0
  87. package/test/rabbit-test.js +84 -0
  88. package/test/rc4-profile.js +30 -0
  89. package/test/rc4-test.js +68 -0
  90. package/test/ripemd160-test.js +19 -0
  91. package/test/sha1-profile.js +24 -0
  92. package/test/sha1-test.js +70 -0
  93. package/test/sha224-test.js +19 -0
  94. package/test/sha256-profile.js +24 -0
  95. package/test/sha256-test.js +70 -0
  96. package/test/sha3-profile.js +24 -0
  97. package/test/sha3-test.js +69 -0
  98. package/test/sha384-test.js +54 -0
  99. package/test/sha512-profile.js +24 -0
  100. package/test/sha512-test.js +54 -0
  101. package/test/test-build.html +105 -0
  102. package/test/test.html +138 -0
  103. package/test/test1.html +63 -0
  104. package/test/tripledes-profile.js +31 -0
  105. package/test/tripledes-test.js +121 -0
  106. package/test/x64-word-test.js +99 -0
  107. package/test/x64-wordarray-test.js +38 -0
  108. package/tripledes.js +759 -0
  109. package/x64-core.js +284 -0
@@ -0,0 +1,128 @@
1
+ (function () {
2
+ // Shortcuts
3
+ var C = CryptoJS;
4
+ var C_lib = C.lib;
5
+ var WordArray = C_lib.WordArray;
6
+ var C_enc = C.enc;
7
+
8
+ /**
9
+ * Base64url encoding strategy.
10
+ */
11
+ var Base64url = C_enc.Base64url = {
12
+ /**
13
+ * Converts a word array to a Base64url string.
14
+ *
15
+ * @param {WordArray} wordArray The word array.
16
+ *
17
+ * @param {boolean} urlSafe Whether to use url safe
18
+ *
19
+ * @return {string} The Base64url string.
20
+ *
21
+ * @static
22
+ *
23
+ * @example
24
+ *
25
+ * var base64String = CryptoJS.enc.Base64url.stringify(wordArray);
26
+ */
27
+ stringify: function (wordArray, urlSafe) {
28
+ if (urlSafe === undefined) {
29
+ urlSafe = true
30
+ }
31
+ // Shortcuts
32
+ var words = wordArray.words;
33
+ var sigBytes = wordArray.sigBytes;
34
+ var map = urlSafe ? this._safe_map : this._map;
35
+
36
+ // Clamp excess bits
37
+ wordArray.clamp();
38
+
39
+ // Convert
40
+ var base64Chars = [];
41
+ for (var i = 0; i < sigBytes; i += 3) {
42
+ var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
43
+ var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
44
+ var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
45
+
46
+ var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
47
+
48
+ for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
49
+ base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
50
+ }
51
+ }
52
+
53
+ // Add padding
54
+ var paddingChar = map.charAt(64);
55
+ if (paddingChar) {
56
+ while (base64Chars.length % 4) {
57
+ base64Chars.push(paddingChar);
58
+ }
59
+ }
60
+
61
+ return base64Chars.join('');
62
+ },
63
+
64
+ /**
65
+ * Converts a Base64url string to a word array.
66
+ *
67
+ * @param {string} base64Str The Base64url string.
68
+ *
69
+ * @param {boolean} urlSafe Whether to use url safe
70
+ *
71
+ * @return {WordArray} The word array.
72
+ *
73
+ * @static
74
+ *
75
+ * @example
76
+ *
77
+ * var wordArray = CryptoJS.enc.Base64url.parse(base64String);
78
+ */
79
+ parse: function (base64Str, urlSafe) {
80
+ if (urlSafe === undefined) {
81
+ urlSafe = true
82
+ }
83
+
84
+ // Shortcuts
85
+ var base64StrLength = base64Str.length;
86
+ var map = urlSafe ? this._safe_map : this._map;
87
+ var reverseMap = this._reverseMap;
88
+
89
+ if (!reverseMap) {
90
+ reverseMap = this._reverseMap = [];
91
+ for (var j = 0; j < map.length; j++) {
92
+ reverseMap[map.charCodeAt(j)] = j;
93
+ }
94
+ }
95
+
96
+ // Ignore padding
97
+ var paddingChar = map.charAt(64);
98
+ if (paddingChar) {
99
+ var paddingIndex = base64Str.indexOf(paddingChar);
100
+ if (paddingIndex !== -1) {
101
+ base64StrLength = paddingIndex;
102
+ }
103
+ }
104
+
105
+ // Convert
106
+ return parseLoop(base64Str, base64StrLength, reverseMap);
107
+
108
+ },
109
+
110
+ _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
111
+ _safe_map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
112
+ };
113
+
114
+ function parseLoop(base64Str, base64StrLength, reverseMap) {
115
+ var words = [];
116
+ var nBytes = 0;
117
+ for (var i = 0; i < base64StrLength; i++) {
118
+ if (i % 4) {
119
+ var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
120
+ var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
121
+ var bitsCombined = bits1 | bits2;
122
+ words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
123
+ nBytes++;
124
+ }
125
+ }
126
+ return WordArray.create(words, nBytes);
127
+ }
128
+ }());
package/enc-utf16.js ADDED
@@ -0,0 +1,129 @@
1
+ (function () {
2
+ // Shortcuts
3
+ var C = CryptoJS;
4
+ var C_lib = C.lib;
5
+ var WordArray = C_lib.WordArray;
6
+ var C_enc = C.enc;
7
+
8
+ /**
9
+ * UTF-16 BE encoding strategy.
10
+ */
11
+ var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
12
+ /**
13
+ * Converts a word array to a UTF-16 BE string.
14
+ *
15
+ * @param {WordArray} wordArray The word array.
16
+ *
17
+ * @return {string} The UTF-16 BE string.
18
+ *
19
+ * @static
20
+ *
21
+ * @example
22
+ *
23
+ * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
24
+ */
25
+ stringify: function (wordArray) {
26
+ // Shortcuts
27
+ var words = wordArray.words;
28
+ var sigBytes = wordArray.sigBytes;
29
+
30
+ // Convert
31
+ var utf16Chars = [];
32
+ for (var i = 0; i < sigBytes; i += 2) {
33
+ var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
34
+ utf16Chars.push(String.fromCharCode(codePoint));
35
+ }
36
+
37
+ return utf16Chars.join('');
38
+ },
39
+
40
+ /**
41
+ * Converts a UTF-16 BE string to a word array.
42
+ *
43
+ * @param {string} utf16Str The UTF-16 BE string.
44
+ *
45
+ * @return {WordArray} The word array.
46
+ *
47
+ * @static
48
+ *
49
+ * @example
50
+ *
51
+ * var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
52
+ */
53
+ parse: function (utf16Str) {
54
+ // Shortcut
55
+ var utf16StrLength = utf16Str.length;
56
+
57
+ // Convert
58
+ var words = [];
59
+ for (var i = 0; i < utf16StrLength; i++) {
60
+ words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
61
+ }
62
+
63
+ return WordArray.create(words, utf16StrLength * 2);
64
+ }
65
+ };
66
+
67
+ /**
68
+ * UTF-16 LE encoding strategy.
69
+ */
70
+ C_enc.Utf16LE = {
71
+ /**
72
+ * Converts a word array to a UTF-16 LE string.
73
+ *
74
+ * @param {WordArray} wordArray The word array.
75
+ *
76
+ * @return {string} The UTF-16 LE string.
77
+ *
78
+ * @static
79
+ *
80
+ * @example
81
+ *
82
+ * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
83
+ */
84
+ stringify: function (wordArray) {
85
+ // Shortcuts
86
+ var words = wordArray.words;
87
+ var sigBytes = wordArray.sigBytes;
88
+
89
+ // Convert
90
+ var utf16Chars = [];
91
+ for (var i = 0; i < sigBytes; i += 2) {
92
+ var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
93
+ utf16Chars.push(String.fromCharCode(codePoint));
94
+ }
95
+
96
+ return utf16Chars.join('');
97
+ },
98
+
99
+ /**
100
+ * Converts a UTF-16 LE string to a word array.
101
+ *
102
+ * @param {string} utf16Str The UTF-16 LE string.
103
+ *
104
+ * @return {WordArray} The word array.
105
+ *
106
+ * @static
107
+ *
108
+ * @example
109
+ *
110
+ * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
111
+ */
112
+ parse: function (utf16Str) {
113
+ // Shortcut
114
+ var utf16StrLength = utf16Str.length;
115
+
116
+ // Convert
117
+ var words = [];
118
+ for (var i = 0; i < utf16StrLength; i++) {
119
+ words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
120
+ }
121
+
122
+ return WordArray.create(words, utf16StrLength * 2);
123
+ }
124
+ };
125
+
126
+ function swapEndian(word) {
127
+ return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
128
+ }
129
+ }());
package/evpkdf.js ADDED
@@ -0,0 +1,114 @@
1
+ (function () {
2
+ // Shortcuts
3
+ var C = CryptoJS;
4
+ var C_lib = C.lib;
5
+ var Base = C_lib.Base;
6
+ var WordArray = C_lib.WordArray;
7
+ var C_algo = C.algo;
8
+ var MD5 = C_algo.MD5;
9
+
10
+ /**
11
+ * This key derivation function is meant to conform with EVP_BytesToKey.
12
+ * www.openssl.org/docs/crypto/EVP_BytesToKey.html
13
+ */
14
+ var EvpKDF = C_algo.EvpKDF = Base.extend({
15
+ /**
16
+ * Configuration options.
17
+ *
18
+ * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
19
+ * @property {Hasher} hasher The hash algorithm to use. Default: MD5
20
+ * @property {number} iterations The number of iterations to perform. Default: 1
21
+ */
22
+ cfg: Base.extend({
23
+ keySize: 128/32,
24
+ hasher: MD5,
25
+ iterations: 1
26
+ }),
27
+
28
+ /**
29
+ * Initializes a newly created key derivation function.
30
+ *
31
+ * @param {Object} cfg (Optional) The configuration options to use for the derivation.
32
+ *
33
+ * @example
34
+ *
35
+ * var kdf = CryptoJS.algo.EvpKDF.create();
36
+ * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
37
+ * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
38
+ */
39
+ init: function (cfg) {
40
+ this.cfg = this.cfg.extend(cfg);
41
+ },
42
+
43
+ /**
44
+ * Derives a key from a password.
45
+ *
46
+ * @param {WordArray|string} password The password.
47
+ * @param {WordArray|string} salt A salt.
48
+ *
49
+ * @return {WordArray} The derived key.
50
+ *
51
+ * @example
52
+ *
53
+ * var key = kdf.compute(password, salt);
54
+ */
55
+ compute: function (password, salt) {
56
+ var block;
57
+
58
+ // Shortcut
59
+ var cfg = this.cfg;
60
+
61
+ // Init hasher
62
+ var hasher = cfg.hasher.create();
63
+
64
+ // Initial values
65
+ var derivedKey = WordArray.create();
66
+
67
+ // Shortcuts
68
+ var derivedKeyWords = derivedKey.words;
69
+ var keySize = cfg.keySize;
70
+ var iterations = cfg.iterations;
71
+
72
+ // Generate key
73
+ while (derivedKeyWords.length < keySize) {
74
+ if (block) {
75
+ hasher.update(block);
76
+ }
77
+ block = hasher.update(password).finalize(salt);
78
+ hasher.reset();
79
+
80
+ // Iterations
81
+ for (var i = 1; i < iterations; i++) {
82
+ block = hasher.finalize(block);
83
+ hasher.reset();
84
+ }
85
+
86
+ derivedKey.concat(block);
87
+ }
88
+ derivedKey.sigBytes = keySize * 4;
89
+
90
+ return derivedKey;
91
+ }
92
+ });
93
+
94
+ /**
95
+ * Derives a key from a password.
96
+ *
97
+ * @param {WordArray|string} password The password.
98
+ * @param {WordArray|string} salt A salt.
99
+ * @param {Object} cfg (Optional) The configuration options to use for this computation.
100
+ *
101
+ * @return {WordArray} The derived key.
102
+ *
103
+ * @static
104
+ *
105
+ * @example
106
+ *
107
+ * var key = CryptoJS.EvpKDF(password, salt);
108
+ * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
109
+ * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
110
+ */
111
+ C.EvpKDF = function (password, salt, cfg) {
112
+ return EvpKDF.create(cfg).compute(password, salt);
113
+ };
114
+ }());
package/format-hex.js ADDED
@@ -0,0 +1,46 @@
1
+ (function (undefined) {
2
+ // Shortcuts
3
+ var C = CryptoJS;
4
+ var C_lib = C.lib;
5
+ var CipherParams = C_lib.CipherParams;
6
+ var C_enc = C.enc;
7
+ var Hex = C_enc.Hex;
8
+ var C_format = C.format;
9
+
10
+ var HexFormatter = C_format.Hex = {
11
+ /**
12
+ * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
13
+ *
14
+ * @param {CipherParams} cipherParams The cipher params object.
15
+ *
16
+ * @return {string} The hexadecimally encoded string.
17
+ *
18
+ * @static
19
+ *
20
+ * @example
21
+ *
22
+ * var hexString = CryptoJS.format.Hex.stringify(cipherParams);
23
+ */
24
+ stringify: function (cipherParams) {
25
+ return cipherParams.ciphertext.toString(Hex);
26
+ },
27
+
28
+ /**
29
+ * Converts a hexadecimally encoded ciphertext string to a cipher params object.
30
+ *
31
+ * @param {string} input The hexadecimally encoded string.
32
+ *
33
+ * @return {CipherParams} The cipher params object.
34
+ *
35
+ * @static
36
+ *
37
+ * @example
38
+ *
39
+ * var cipherParams = CryptoJS.format.Hex.parse(hexString);
40
+ */
41
+ parse: function (input) {
42
+ var ciphertext = Hex.parse(input);
43
+ return CipherParams.create({ ciphertext: ciphertext });
44
+ }
45
+ };
46
+ }());
package/hmac.js ADDED
@@ -0,0 +1,125 @@
1
+ (function () {
2
+ // Shortcuts
3
+ var C = CryptoJS;
4
+ var C_lib = C.lib;
5
+ var Base = C_lib.Base;
6
+ var C_enc = C.enc;
7
+ var Utf8 = C_enc.Utf8;
8
+ var C_algo = C.algo;
9
+
10
+ /**
11
+ * HMAC algorithm.
12
+ */
13
+ var HMAC = C_algo.HMAC = Base.extend({
14
+ /**
15
+ * Initializes a newly created HMAC.
16
+ *
17
+ * @param {Hasher} hasher The hash algorithm to use.
18
+ * @param {WordArray|string} key The secret key.
19
+ *
20
+ * @example
21
+ *
22
+ * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
23
+ */
24
+ init: function (hasher, key) {
25
+ // Init hasher
26
+ hasher = this._hasher = new hasher.init();
27
+
28
+ // Convert string to WordArray, else assume WordArray already
29
+ if (typeof key == 'string') {
30
+ key = Utf8.parse(key);
31
+ }
32
+
33
+ // Shortcuts
34
+ var hasherBlockSize = hasher.blockSize;
35
+ var hasherBlockSizeBytes = hasherBlockSize * 4;
36
+
37
+ // Allow arbitrary length keys
38
+ if (key.sigBytes > hasherBlockSizeBytes) {
39
+ key = hasher.finalize(key);
40
+ }
41
+
42
+ // Clamp excess bits
43
+ key.clamp();
44
+
45
+ // Clone key for inner and outer pads
46
+ var oKey = this._oKey = key.clone();
47
+ var iKey = this._iKey = key.clone();
48
+
49
+ // Shortcuts
50
+ var oKeyWords = oKey.words;
51
+ var iKeyWords = iKey.words;
52
+
53
+ // XOR keys with pad constants
54
+ for (var i = 0; i < hasherBlockSize; i++) {
55
+ oKeyWords[i] ^= 0x5c5c5c5c;
56
+ iKeyWords[i] ^= 0x36363636;
57
+ }
58
+ oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
59
+
60
+ // Set initial values
61
+ this.reset();
62
+ },
63
+
64
+ /**
65
+ * Resets this HMAC to its initial state.
66
+ *
67
+ * @example
68
+ *
69
+ * hmacHasher.reset();
70
+ */
71
+ reset: function () {
72
+ // Shortcut
73
+ var hasher = this._hasher;
74
+
75
+ // Reset
76
+ hasher.reset();
77
+ hasher.update(this._iKey);
78
+ },
79
+
80
+ /**
81
+ * Updates this HMAC with a message.
82
+ *
83
+ * @param {WordArray|string} messageUpdate The message to append.
84
+ *
85
+ * @return {HMAC} This HMAC instance.
86
+ *
87
+ * @example
88
+ *
89
+ * hmacHasher.update('message');
90
+ * hmacHasher.update(wordArray);
91
+ */
92
+ update: function (messageUpdate) {
93
+ this._hasher.update(messageUpdate);
94
+
95
+ // Chainable
96
+ return this;
97
+ },
98
+
99
+ /**
100
+ * Finalizes the HMAC computation.
101
+ * Note that the finalize operation is effectively a destructive, read-once operation.
102
+ *
103
+ * @param {WordArray|string} messageUpdate (Optional) A final message update.
104
+ *
105
+ * @return {WordArray} The HMAC.
106
+ *
107
+ * @example
108
+ *
109
+ * var hmac = hmacHasher.finalize();
110
+ * var hmac = hmacHasher.finalize('message');
111
+ * var hmac = hmacHasher.finalize(wordArray);
112
+ */
113
+ finalize: function (messageUpdate) {
114
+ // Shortcut
115
+ var hasher = this._hasher;
116
+
117
+ // Compute HMAC
118
+ var innerHash = hasher.finalize(messageUpdate);
119
+ hasher.reset();
120
+ var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
121
+
122
+ return hmac;
123
+ }
124
+ });
125
+ }());
package/index.js ADDED
@@ -0,0 +1,18 @@
1
+ ;(function (root, factory, undef) {
2
+ if (typeof exports === "object") {
3
+ // CommonJS
4
+ module.exports = exports = factory(require("./core"), require("./x64-core"), require("./lib-typedarrays"), require("./enc-utf16"), require("./enc-base64"), require("./enc-base64url"), require("./md5"), require("./sha1"), require("./sha256"), require("./sha224"), require("./sha512"), require("./sha384"), require("./sha3"), require("./ripemd160"), require("./hmac"), require("./pbkdf2"), require("./evpkdf"), require("./cipher-core"), require("./mode-cfb"), require("./mode-ctr"), require("./mode-ctr-gladman"), require("./mode-ofb"), require("./mode-ecb"), require("./pad-ansix923"), require("./pad-iso10126"), require("./pad-iso97971"), require("./pad-zeropadding"), require("./pad-nopadding"), require("./format-hex"), require("./aes"), require("./tripledes"), require("./rc4"), require("./rabbit"), require("./rabbit-legacy"), require("./blowfish"));
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ // AMD
8
+ define(["./core", "./x64-core", "./lib-typedarrays", "./enc-utf16", "./enc-base64", "./enc-base64url", "./md5", "./sha1", "./sha256", "./sha224", "./sha512", "./sha384", "./sha3", "./ripemd160", "./hmac", "./pbkdf2", "./evpkdf", "./cipher-core", "./mode-cfb", "./mode-ctr", "./mode-ctr-gladman", "./mode-ofb", "./mode-ecb", "./pad-ansix923", "./pad-iso10126", "./pad-iso97971", "./pad-zeropadding", "./pad-nopadding", "./format-hex", "./aes", "./tripledes", "./rc4", "./rabbit", "./rabbit-legacy", "./blowfish"], factory);
9
+ }
10
+ else {
11
+ // Global (browser)
12
+ root.CryptoJS = factory(root.CryptoJS);
13
+ }
14
+ }(this, function (CryptoJS) {
15
+
16
+ return CryptoJS;
17
+
18
+ }));
@@ -0,0 +1,56 @@
1
+ (function () {
2
+ // Check if typed arrays are supported
3
+ if (typeof ArrayBuffer != 'function') {
4
+ return;
5
+ }
6
+
7
+ // Shortcuts
8
+ var C = CryptoJS;
9
+ var C_lib = C.lib;
10
+ var WordArray = C_lib.WordArray;
11
+
12
+ // Reference original init
13
+ var superInit = WordArray.init;
14
+
15
+ // Augment WordArray.init to handle typed arrays
16
+ var subInit = WordArray.init = function (typedArray) {
17
+ // Convert buffers to uint8
18
+ if (typedArray instanceof ArrayBuffer) {
19
+ typedArray = new Uint8Array(typedArray);
20
+ }
21
+
22
+ // Convert other array views to uint8
23
+ if (
24
+ typedArray instanceof Int8Array ||
25
+ (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) ||
26
+ typedArray instanceof Int16Array ||
27
+ typedArray instanceof Uint16Array ||
28
+ typedArray instanceof Int32Array ||
29
+ typedArray instanceof Uint32Array ||
30
+ typedArray instanceof Float32Array ||
31
+ typedArray instanceof Float64Array
32
+ ) {
33
+ typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
34
+ }
35
+
36
+ // Handle Uint8Array
37
+ if (typedArray instanceof Uint8Array) {
38
+ // Shortcut
39
+ var typedArrayByteLength = typedArray.byteLength;
40
+
41
+ // Extract bytes
42
+ var words = [];
43
+ for (var i = 0; i < typedArrayByteLength; i++) {
44
+ words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
45
+ }
46
+
47
+ // Initialize this word array
48
+ superInit.call(this, words, typedArrayByteLength);
49
+ } else {
50
+ // Else call normal init
51
+ superInit.apply(this, arguments);
52
+ }
53
+ };
54
+
55
+ subInit.prototype = WordArray;
56
+ }());