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

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 (108) 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/docs/QuickStartGuide.wiki +470 -0
  7. package/package.json +45 -3
  8. package/src/aes.js +214 -0
  9. package/src/blowfish.js +451 -0
  10. package/src/cipher-core.js +877 -0
  11. package/src/core.js +796 -0
  12. package/src/enc-base64.js +116 -0
  13. package/src/enc-base64url.js +128 -0
  14. package/src/enc-utf16.js +129 -0
  15. package/src/evpkdf.js +114 -0
  16. package/src/format-hex.js +46 -0
  17. package/src/hmac.js +125 -0
  18. package/src/lib-typedarrays.js +56 -0
  19. package/src/md5.js +248 -0
  20. package/src/mode-cfb.js +60 -0
  21. package/src/mode-ctr-gladman.js +96 -0
  22. package/src/mode-ctr.js +38 -0
  23. package/src/mode-ecb.js +20 -0
  24. package/src/mode-ofb.js +34 -0
  25. package/src/pad-ansix923.js +29 -0
  26. package/src/pad-iso10126.js +24 -0
  27. package/src/pad-iso97971.js +20 -0
  28. package/src/pad-nopadding.js +10 -0
  29. package/src/pad-zeropadding.js +27 -0
  30. package/src/pbkdf2.js +125 -0
  31. package/src/rabbit-legacy.js +170 -0
  32. package/src/rabbit.js +172 -0
  33. package/src/rc4.js +119 -0
  34. package/src/ripemd160.js +247 -0
  35. package/src/sha1.js +130 -0
  36. package/src/sha224.js +60 -0
  37. package/src/sha256.js +179 -0
  38. package/src/sha3.js +306 -0
  39. package/src/sha384.js +63 -0
  40. package/src/sha512.js +306 -0
  41. package/src/tripledes.js +759 -0
  42. package/src/x64-core.js +284 -0
  43. package/test/aes-profile.js +31 -0
  44. package/test/aes-test.js +80 -0
  45. package/test/blowfish-test.js +33 -0
  46. package/test/cipher-test.js +522 -0
  47. package/test/config-test.js +51 -0
  48. package/test/des-profile.js +31 -0
  49. package/test/des-test.js +104 -0
  50. package/test/enc-base64-test.js +71 -0
  51. package/test/enc-hex-test.js +15 -0
  52. package/test/enc-latin1-test.js +15 -0
  53. package/test/enc-utf16-test.js +55 -0
  54. package/test/enc-utf8-test.js +39 -0
  55. package/test/evpkdf-profile.js +11 -0
  56. package/test/evpkdf-test.js +32 -0
  57. package/test/format-openssl-test.js +37 -0
  58. package/test/hmac-md5-profile.js +30 -0
  59. package/test/hmac-md5-test.js +59 -0
  60. package/test/hmac-sha224-test.js +59 -0
  61. package/test/hmac-sha256-test.js +59 -0
  62. package/test/hmac-sha384-test.js +59 -0
  63. package/test/hmac-sha512-test.js +59 -0
  64. package/test/kdf-openssl-test.js +15 -0
  65. package/test/lib-base-test.js +92 -0
  66. package/test/lib-cipherparams-test.js +59 -0
  67. package/test/lib-passwordbasedcipher-test.js +25 -0
  68. package/test/lib-serializablecipher-test.js +51 -0
  69. package/test/lib-typedarrays-test.js +57 -0
  70. package/test/lib-wordarray-test.js +85 -0
  71. package/test/md5-profile.js +24 -0
  72. package/test/md5-test.js +70 -0
  73. package/test/mode-cbc-test.js +49 -0
  74. package/test/mode-cfb-test.js +51 -0
  75. package/test/mode-ctr-test.js +55 -0
  76. package/test/mode-ecb-test.js +38 -0
  77. package/test/mode-ofb-test.js +50 -0
  78. package/test/pad-ansix923-test.js +28 -0
  79. package/test/pad-iso10126-test.js +50 -0
  80. package/test/pad-iso97971-test.js +35 -0
  81. package/test/pad-pkcs7-test.js +28 -0
  82. package/test/pad-zeropadding-test.js +28 -0
  83. package/test/pbkdf2-profile.js +11 -0
  84. package/test/pbkdf2-test.js +80 -0
  85. package/test/profile.html +281 -0
  86. package/test/rabbit-legacy-test.js +80 -0
  87. package/test/rabbit-profile.js +30 -0
  88. package/test/rabbit-test.js +84 -0
  89. package/test/rc4-profile.js +30 -0
  90. package/test/rc4-test.js +68 -0
  91. package/test/ripemd160-test.js +19 -0
  92. package/test/sha1-profile.js +24 -0
  93. package/test/sha1-test.js +70 -0
  94. package/test/sha224-test.js +19 -0
  95. package/test/sha256-profile.js +24 -0
  96. package/test/sha256-test.js +70 -0
  97. package/test/sha3-profile.js +24 -0
  98. package/test/sha3-test.js +69 -0
  99. package/test/sha384-test.js +54 -0
  100. package/test/sha512-profile.js +24 -0
  101. package/test/sha512-test.js +54 -0
  102. package/test/test-build.html +105 -0
  103. package/test/test.html +138 -0
  104. package/test/test1.html +63 -0
  105. package/test/tripledes-profile.js +31 -0
  106. package/test/tripledes-test.js +121 -0
  107. package/test/x64-word-test.js +99 -0
  108. package/test/x64-wordarray-test.js +38 -0
package/.jshintrc ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "bitwise": false, // Prohibits the use of bitwise operators (not confuse & with &&)
3
+ "curly": true, // Requires to always put curly braces around blocks in loops and conditionals
4
+ "eqeqeq": false, // Prohibits the use of == and != in favor of === and !==
5
+ "eqnull": true, // Suppresses warnings about == null comparisons
6
+ "immed": true, // Requires immediate invocations to be wrapped in parens e.g. `(function () { } ());`
7
+ "latedef": false, // Prohibits the use of a variable before it was defined
8
+ "newcap": false, // Requires to capitalize names of constructor functions
9
+ "noarg": true, // Prohibits the use of arguments.caller and arguments.callee
10
+ "strict": false, // Requires all functions to run in ECMAScript 5's strict mode
11
+ "undef": true, // Require non-global variables to be declared (prevents global leaks)
12
+ "asi": true, // Suppresses warnings about missing semicolons
13
+ "funcscope": false,
14
+ "shadow": true,
15
+ "expr": true,
16
+ "-W041": true,
17
+ "-W018": true,
18
+ "globals": {
19
+ "CryptoJS": true,
20
+ "escape": true,
21
+ "unescape": true,
22
+ "Int8Array": true,
23
+ "Int16Array": true,
24
+ "Int32Array": true,
25
+ "Uint8Array": true,
26
+ "Uint16Array": true,
27
+ "Uint32Array": true,
28
+ "Uint8ClampedArray": true,
29
+ "ArrayBuffer": true,
30
+ "Float32Array": true,
31
+ "Float64Array": true
32
+ }
33
+ }
package/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ dist: trusty
2
+ sudo: false
3
+
4
+ language: node_js
5
+ node_js:
6
+ - "6"
7
+ - "7"
8
+
9
+ before_script:
10
+ - npm install -g grunt-cli
11
+ - npm install build
12
+
13
+ cache:
14
+ directories:
15
+ - "node_modules"
@@ -0,0 +1,28 @@
1
+ # Contribution
2
+
3
+ # Git Flow
4
+
5
+ The crypto-js project uses [git flow](https://github.com/nvie/gitflow) to manage branches.
6
+ Do your changes on the `develop` or even better on a `feature/*` branch. Don't do any changes on the `master` branch.
7
+
8
+ # Pull request
9
+
10
+ Target your pull request on `develop` branch. Other pull request won't be accepted.
11
+
12
+ # How to build
13
+
14
+ 1. Clone
15
+
16
+ 2. Run
17
+
18
+ ```sh
19
+ npm install
20
+ ```
21
+
22
+ 3. Run
23
+
24
+ ```sh
25
+ npm run build
26
+ ```
27
+
28
+ 4. Check `build` folder
package/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ # License
2
+
3
+ [The MIT License (MIT)](http://opensource.org/licenses/MIT)
4
+
5
+ Copyright (c) 2009-2013 Jeff Mott
6
+ Copyright (c) 2013-2016 Evan Vosberg
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,275 @@
1
- # Security holding package
1
+ # crypto-js
2
+
3
+ JavaScript library of crypto standards.
4
+
5
+ ## Discontinued
6
+
7
+ Active development of CryptoJS has been discontinued. This library is no longer maintained.
8
+
9
+ Nowadays, NodeJS and modern browsers have a native `Crypto` module. The latest version of CryptoJS already uses the native Crypto module for random number generation, since `Math.random()` is not crypto-safe. Further development of CryptoJS would result in it only being a wrapper of native Crypto. Therefore, development and maintenance has been discontinued, it is time to go for the native `crypto` module.
10
+
11
+ ## Node.js (Install)
12
+
13
+ Requirements:
14
+
15
+ - Node.js
16
+ - npm (Node.js package manager)
17
+
18
+ ```bash
19
+ npm install crypto-js
20
+ ```
21
+
22
+ ### Usage
23
+
24
+ ES6 import for typical API call signing use case:
25
+
26
+ ```javascript
27
+ import sha256 from 'crypto-js/sha256';
28
+ import hmacSHA512 from 'crypto-js/hmac-sha512';
29
+ import Base64 from 'crypto-js/enc-base64';
30
+
31
+ const message, nonce, path, privateKey; // ...
32
+ const hashDigest = sha256(nonce + message);
33
+ const hmacDigest = Base64.stringify(hmacSHA512(path + hashDigest, privateKey));
34
+ ```
35
+
36
+ Modular include:
37
+
38
+ ```javascript
39
+ var AES = require("crypto-js/aes");
40
+ var SHA256 = require("crypto-js/sha256");
41
+ ...
42
+ console.log(SHA256("Message"));
43
+ ```
44
+
45
+ Including all libraries, for access to extra methods:
46
+
47
+ ```javascript
48
+ var CryptoJS = require("crypto-js");
49
+ console.log(CryptoJS.HmacSHA1("Message", "Key"));
50
+ ```
51
+
52
+ ## Client (browser)
53
+
54
+ Requirements:
55
+
56
+ - Node.js
57
+ - Bower (package manager for frontend)
58
+
59
+ ```bash
60
+ bower install crypto-js
61
+ ```
62
+
63
+ ### Usage
64
+
65
+ Modular include:
66
+
67
+ ```javascript
68
+ require.config({
69
+ packages: [
70
+ {
71
+ name: 'crypto-js',
72
+ location: 'path-to/bower_components/crypto-js',
73
+ main: 'index'
74
+ }
75
+ ]
76
+ });
77
+
78
+ require(["crypto-js/aes", "crypto-js/sha256"], function (AES, SHA256) {
79
+ console.log(SHA256("Message"));
80
+ });
81
+ ```
82
+
83
+ Including all libraries, for access to extra methods:
84
+
85
+ ```javascript
86
+ // Above-mentioned will work or use this simple form
87
+ require.config({
88
+ paths: {
89
+ 'crypto-js': 'path-to/bower_components/crypto-js/crypto-js'
90
+ }
91
+ });
92
+
93
+ require(["crypto-js"], function (CryptoJS) {
94
+ console.log(CryptoJS.HmacSHA1("Message", "Key"));
95
+ });
96
+ ```
97
+
98
+ ### Usage without RequireJS
99
+
100
+ ```html
101
+ <script type="text/javascript" src="path-to/bower_components/crypto-js/crypto-js.js"></script>
102
+ <script type="text/javascript">
103
+ var encrypted = CryptoJS.AES(...);
104
+ var encrypted = CryptoJS.SHA256(...);
105
+ </script>
106
+ ```
107
+
108
+ ## API
109
+
110
+ See: https://cryptojs.gitbook.io/docs/
111
+
112
+ ### AES Encryption
113
+
114
+ #### Plain text encryption
115
+
116
+ ```javascript
117
+ var CryptoJS = require("crypto-js");
118
+
119
+ // Encrypt
120
+ var ciphertext = CryptoJS.AES.encrypt('my message', 'secret key 123').toString();
121
+
122
+ // Decrypt
123
+ var bytes = CryptoJS.AES.decrypt(ciphertext, 'secret key 123');
124
+ var originalText = bytes.toString(CryptoJS.enc.Utf8);
125
+
126
+ console.log(originalText); // 'my message'
127
+ ```
128
+
129
+ #### Object encryption
130
+
131
+ ```javascript
132
+ var CryptoJS = require("crypto-js");
133
+
134
+ var data = [{id: 1}, {id: 2}]
135
+
136
+ // Encrypt
137
+ var ciphertext = CryptoJS.AES.encrypt(JSON.stringify(data), 'secret key 123').toString();
138
+
139
+ // Decrypt
140
+ var bytes = CryptoJS.AES.decrypt(ciphertext, 'secret key 123');
141
+ var decryptedData = JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
142
+
143
+ console.log(decryptedData); // [{id: 1}, {id: 2}]
144
+ ```
145
+
146
+ ### List of modules
147
+
148
+
149
+ - ```crypto-js/core```
150
+ - ```crypto-js/x64-core```
151
+ - ```crypto-js/lib-typedarrays```
152
+
153
+ ---
154
+
155
+ - ```crypto-js/md5```
156
+ - ```crypto-js/sha1```
157
+ - ```crypto-js/sha256```
158
+ - ```crypto-js/sha224```
159
+ - ```crypto-js/sha512```
160
+ - ```crypto-js/sha384```
161
+ - ```crypto-js/sha3```
162
+ - ```crypto-js/ripemd160```
163
+
164
+ ---
165
+
166
+ - ```crypto-js/hmac-md5```
167
+ - ```crypto-js/hmac-sha1```
168
+ - ```crypto-js/hmac-sha256```
169
+ - ```crypto-js/hmac-sha224```
170
+ - ```crypto-js/hmac-sha512```
171
+ - ```crypto-js/hmac-sha384```
172
+ - ```crypto-js/hmac-sha3```
173
+ - ```crypto-js/hmac-ripemd160```
174
+
175
+ ---
176
+
177
+ - ```crypto-js/pbkdf2```
178
+
179
+ ---
180
+
181
+ - ```crypto-js/aes```
182
+ - ```crypto-js/tripledes```
183
+ - ```crypto-js/rc4```
184
+ - ```crypto-js/rabbit```
185
+ - ```crypto-js/rabbit-legacy```
186
+ - ```crypto-js/evpkdf```
187
+
188
+ ---
189
+
190
+ - ```crypto-js/format-openssl```
191
+ - ```crypto-js/format-hex```
192
+
193
+ ---
194
+
195
+ - ```crypto-js/enc-latin1```
196
+ - ```crypto-js/enc-utf8```
197
+ - ```crypto-js/enc-hex```
198
+ - ```crypto-js/enc-utf16```
199
+ - ```crypto-js/enc-base64```
200
+
201
+ ---
202
+
203
+ - ```crypto-js/mode-cfb```
204
+ - ```crypto-js/mode-ctr```
205
+ - ```crypto-js/mode-ctr-gladman```
206
+ - ```crypto-js/mode-ofb```
207
+ - ```crypto-js/mode-ecb```
208
+
209
+ ---
210
+
211
+ - ```crypto-js/pad-pkcs7```
212
+ - ```crypto-js/pad-ansix923```
213
+ - ```crypto-js/pad-iso10126```
214
+ - ```crypto-js/pad-iso97971```
215
+ - ```crypto-js/pad-zeropadding```
216
+ - ```crypto-js/pad-nopadding```
217
+
218
+
219
+ ## Release notes
220
+
221
+ ### 4.2.0
222
+
223
+ Change default hash algorithm and iteration's for PBKDF2 to prevent weak security by using the default configuration.
224
+
225
+ Custom KDF Hasher
226
+
227
+ Blowfish support
228
+
229
+ ### 4.1.1
230
+
231
+ Fix module order in bundled release.
232
+
233
+ Include the browser field in the released package.json.
234
+
235
+ ### 4.1.0
236
+
237
+ Added url safe variant of base64 encoding. [357](https://github.com/brix/crypto-js/pull/357)
238
+
239
+ Avoid webpack to add crypto-browser package. [364](https://github.com/brix/crypto-js/pull/364)
240
+
241
+ ### 4.0.0
242
+
243
+ This is an update including breaking changes for some environments.
244
+
245
+ In this version `Math.random()` has been replaced by the random methods of the native crypto module.
246
+
247
+ For this reason CryptoJS might not run in some JavaScript environments without native crypto module. Such as IE 10 or before or React Native.
248
+
249
+ ### 3.3.0
250
+
251
+ Rollback, `3.3.0` is the same as `3.1.9-1`.
252
+
253
+ The move of using native secure crypto module will be shifted to a new `4.x.x` version. As it is a breaking change the impact is too big for a minor release.
254
+
255
+ ### 3.2.1
256
+
257
+ The usage of the native crypto module has been fixed. The import and access of the native crypto module has been improved.
258
+
259
+ ### 3.2.0
260
+
261
+ In this version `Math.random()` has been replaced by the random methods of the native crypto module.
262
+
263
+ For this reason CryptoJS might does not run in some JavaScript environments without native crypto module. Such as IE 10 or before.
264
+
265
+ If it's absolute required to run CryptoJS in such an environment, stay with `3.1.x` version. Encrypting and decrypting stays compatible. But keep in mind `3.1.x` versions still use `Math.random()` which is cryptographically not secure, as it's not random enough.
266
+
267
+ This version came along with `CRITICAL` `BUG`.
268
+
269
+ DO NOT USE THIS VERSION! Please, go for a newer version!
270
+
271
+ ### 3.1.x
272
+
273
+ The `3.1.x` are based on the original CryptoJS, wrapped in CommonJS modules.
2
274
 
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
4
275
 
5
- Please refer to www.npmjs.com/advisories?search=%40brix-crypto%2Fcrypto-js for more information.