node-forge 0.6.47 → 0.7.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.
- package/CHANGELOG.md +106 -0
- package/LICENSE +3 -3
- package/README.md +254 -175
- package/dist/forge.all.min.js +11 -0
- package/dist/forge.all.min.js.map +1 -0
- package/dist/forge.min.js +10 -0
- package/dist/forge.min.js.map +1 -0
- package/dist/prime.worker.min.js +2 -0
- package/dist/prime.worker.min.js.map +1 -0
- package/flash/README.md +48 -0
- package/flash/package.json +28 -0
- package/flash/swf/SocketPool.swf +0 -0
- package/{js → lib}/aes.js +5 -61
- package/{js → lib}/aesCipherSuites.js +4 -58
- package/{js → lib}/asn1.js +371 -132
- package/{js → lib}/cipher.js +3 -59
- package/{js → lib}/cipherModes.js +3 -65
- package/{js → lib}/debug.js +2 -58
- package/{js → lib}/des.js +6 -63
- package/lib/forge.js +13 -0
- package/{js → lib}/form.js +5 -13
- package/{js → lib}/hmac.js +4 -58
- package/{js → lib}/http.js +15 -20
- package/lib/index.all.js +16 -0
- package/lib/index.js +34 -0
- package/{js → lib}/jsbn.js +3 -60
- package/{js → lib}/kem.js +5 -58
- package/{js → lib}/log.js +3 -58
- package/lib/md.all.js +13 -0
- package/lib/md.js +11 -0
- package/{js → lib}/md5.js +4 -60
- package/lib/mgf.js +12 -0
- package/lib/mgf1.js +57 -0
- package/lib/oids.js +159 -0
- package/{js → lib}/pbe.js +29 -79
- package/{js → lib}/pbkdf2.js +10 -64
- package/{js → lib}/pem.js +3 -58
- package/{js → lib}/pkcs1.js +6 -59
- package/{js → lib}/pkcs12.js +15 -74
- package/{js → lib}/pkcs7.js +12 -72
- package/{js → lib}/pkcs7asn1.js +4 -58
- package/{js → lib}/pki.js +12 -71
- package/{js → lib}/prime.js +18 -58
- package/{js → lib}/prime.worker.js +4 -1
- package/{js → lib}/prng.js +5 -62
- package/{js → lib}/pss.js +7 -61
- package/{js → lib}/random.js +11 -57
- package/{js → lib}/rc2.js +13 -73
- package/{js → lib}/rsa.js +13 -71
- package/{js → lib}/sha1.js +4 -60
- package/{js → lib}/sha256.js +4 -60
- package/{js → lib}/sha512.js +19 -61
- package/{js → lib}/socket.js +8 -63
- package/{js → lib}/ssh.js +7 -66
- package/{js → lib}/task.js +5 -58
- package/{js → lib}/tls.js +10 -67
- package/{js → lib}/tlssocket.js +6 -61
- package/{js → lib}/util.js +39 -68
- package/{js → lib}/x509.js +25 -102
- package/{js → lib}/xhr.js +12 -15
- package/package.json +58 -21
- package/js/forge.js +0 -94
- package/js/md.js +0 -75
- package/js/mgf.js +0 -67
- package/js/mgf1.js +0 -112
- package/js/oids.js +0 -288
- package/swf/SocketPool.swf +0 -0
package/README.md
CHANGED
|
@@ -10,9 +10,9 @@ A native implementation of [TLS][] (and various other cryptographic tools) in
|
|
|
10
10
|
Introduction
|
|
11
11
|
------------
|
|
12
12
|
|
|
13
|
-
The Forge software is a fully native implementation of the [TLS][] protocol
|
|
14
|
-
JavaScript
|
|
15
|
-
network resources.
|
|
13
|
+
The Forge software is a fully native implementation of the [TLS][] protocol
|
|
14
|
+
in JavaScript, a set of cryptography utilities, and a set of tools for
|
|
15
|
+
developing Web Apps that utilize many network resources.
|
|
16
16
|
|
|
17
17
|
Performance
|
|
18
18
|
------------
|
|
@@ -20,16 +20,90 @@ Performance
|
|
|
20
20
|
Forge is fast. Benchmarks against other popular JavaScript cryptography
|
|
21
21
|
libraries can be found here:
|
|
22
22
|
|
|
23
|
-
http://dominictarr.github.io/crypto-bench/
|
|
23
|
+
* http://dominictarr.github.io/crypto-bench/
|
|
24
|
+
* http://cryptojs.altervista.org/test/simulate-threading-speed_test.html
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
Documentation
|
|
27
|
+
-------------
|
|
28
|
+
|
|
29
|
+
* [Introduction](#introduction)
|
|
30
|
+
* [Performance](#performance)
|
|
31
|
+
* [Installation](#installation)
|
|
32
|
+
* [Testing](#testing)
|
|
33
|
+
* [Contributing](#contributing)
|
|
34
|
+
|
|
35
|
+
### API
|
|
36
|
+
|
|
37
|
+
* [Options](#options)
|
|
38
|
+
|
|
39
|
+
### Transports
|
|
40
|
+
|
|
41
|
+
* [TLS](#tls)
|
|
42
|
+
* [HTTP](#http)
|
|
43
|
+
* [SSH](#ssh)
|
|
44
|
+
* [XHR](#xhr)
|
|
45
|
+
* [Sockets](#socket)
|
|
46
|
+
|
|
47
|
+
### Ciphers
|
|
48
|
+
|
|
49
|
+
* [CIPHER](#cipher)
|
|
50
|
+
* [AES](#aes)
|
|
51
|
+
* [DES](#des)
|
|
52
|
+
* [RC2](#rc2)
|
|
26
53
|
|
|
27
|
-
|
|
28
|
-
|
|
54
|
+
### PKI
|
|
55
|
+
|
|
56
|
+
* [RSA](#rsa)
|
|
57
|
+
* [RSA-KEM](#rsakem)
|
|
58
|
+
* [X.509](#x509)
|
|
59
|
+
* [PKCS#5](#pkcs5)
|
|
60
|
+
* [PKCS#7](#pkcs7)
|
|
61
|
+
* [PKCS#8](#pkcs8)
|
|
62
|
+
* [PKCS#10](#pkcs10)
|
|
63
|
+
* [PKCS#12](#pkcs12)
|
|
64
|
+
* [ASN.1](#asn)
|
|
65
|
+
|
|
66
|
+
### Message Digests
|
|
67
|
+
|
|
68
|
+
* [SHA1](#sha1)
|
|
69
|
+
* [SHA256](#sha256)
|
|
70
|
+
* [SHA384](#sha384)
|
|
71
|
+
* [SHA512](#sha512)
|
|
72
|
+
* [MD5](#md5)
|
|
73
|
+
* [HMAC](#hmac)
|
|
74
|
+
|
|
75
|
+
### Utilities
|
|
76
|
+
|
|
77
|
+
* [Prime](#prime)
|
|
78
|
+
* [PRNG](#prng)
|
|
79
|
+
* [Tasks](#task)
|
|
80
|
+
* [Utilities](#util)
|
|
81
|
+
* [Logging](#log)
|
|
82
|
+
* [Debugging](#debug)
|
|
83
|
+
* [Flash Networking Support](#flash)
|
|
84
|
+
|
|
85
|
+
### Other
|
|
86
|
+
|
|
87
|
+
* [Security Considerations](#security-considerations)
|
|
88
|
+
* [Library Background](#library-background)
|
|
89
|
+
* [Contact](#contact)
|
|
90
|
+
* [Donations](#donations)
|
|
91
|
+
|
|
92
|
+
---------------------------------------
|
|
93
|
+
|
|
94
|
+
Installation
|
|
95
|
+
------------
|
|
96
|
+
|
|
97
|
+
**Note**: Please see the [Security Considerations](#security-considerations)
|
|
98
|
+
section before using packaging systems and pre-built files.
|
|
99
|
+
|
|
100
|
+
Forge uses a [CommonJS][] module structure with a build process for browser
|
|
101
|
+
bundles. The older [0.6.x][] branch with standalone files is available but will
|
|
102
|
+
not be regularly updated.
|
|
29
103
|
|
|
30
104
|
### Node.js
|
|
31
105
|
|
|
32
|
-
If you want to use forge with [
|
|
106
|
+
If you want to use forge with [Node.js][], it is available through `npm`:
|
|
33
107
|
|
|
34
108
|
https://npmjs.org/package/node-forge
|
|
35
109
|
|
|
@@ -39,203 +113,184 @@ Installation:
|
|
|
39
113
|
|
|
40
114
|
You can then use forge as a regular module:
|
|
41
115
|
|
|
42
|
-
|
|
116
|
+
```js
|
|
117
|
+
var forge = require('node-forge');
|
|
118
|
+
```
|
|
43
119
|
|
|
44
|
-
|
|
120
|
+
The npm package includes pre-built `forge.min.js`, `forge.all.min.js`, and
|
|
121
|
+
`prime.worker.min.js` using the [UMD][] format.
|
|
45
122
|
|
|
46
|
-
|
|
47
|
-
* Optional: GNU autotools for the build infrastructure if using Flash.
|
|
48
|
-
* Building a Browser Bundle:
|
|
49
|
-
* nodejs
|
|
50
|
-
* npm
|
|
51
|
-
* Testing
|
|
52
|
-
* nodejs
|
|
53
|
-
* Optional: Python and OpenSSL development environment to build
|
|
54
|
-
* a special SSL module with session cache support for testing with flash.
|
|
55
|
-
* http://www.python.org/dev/
|
|
56
|
-
* http://www.openssl.org/
|
|
57
|
-
* Debian users should install python-dev and libssl-dev.
|
|
58
|
-
* Optional: Flash
|
|
59
|
-
* A pre-built SocketPool.swf is included.
|
|
60
|
-
* Adobe Flex 3 SDK to build the Flash socket code.
|
|
61
|
-
* http://opensource.adobe.com/wiki/display/flexsdk/
|
|
123
|
+
### Bundle / Bower
|
|
62
124
|
|
|
63
|
-
|
|
125
|
+
Each release is published in a separate repository as pre-built and minimized
|
|
126
|
+
basic forge bundles using the [UMD][] format.
|
|
64
127
|
|
|
65
|
-
|
|
128
|
+
https://github.com/digitalbazaar/forge-dist
|
|
66
129
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
npm run minify
|
|
70
|
-
```
|
|
130
|
+
This bundle can be used in many environments. In particular it can be installed
|
|
131
|
+
with [Bower][]:
|
|
71
132
|
|
|
72
|
-
|
|
73
|
-
`npm run bundle` command, try this instead:
|
|
133
|
+
bower install forge
|
|
74
134
|
|
|
75
|
-
|
|
76
|
-
node node_modules\requirejs\bin\r.js -o minify.js
|
|
77
|
-
```
|
|
135
|
+
### unpkg
|
|
78
136
|
|
|
79
|
-
|
|
80
|
-
the browser:
|
|
137
|
+
[unpkg][] provides a CDN that can serve files from npm packages directly.
|
|
81
138
|
|
|
82
|
-
|
|
83
|
-
js/forge.min.js
|
|
84
|
-
```
|
|
139
|
+
https://unpkg.com/node-forge@0.7.0/dist/forge.min.js
|
|
85
140
|
|
|
86
|
-
|
|
141
|
+
### Development Requirements
|
|
87
142
|
|
|
88
|
-
|
|
89
|
-
<script src="js/forge.min.js"></script>
|
|
90
|
-
```
|
|
143
|
+
The core JavaScript has the following requirements to build and test:
|
|
91
144
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
145
|
+
* Building a browser bundle:
|
|
146
|
+
* Node.js
|
|
147
|
+
* npm
|
|
148
|
+
* Testing
|
|
149
|
+
* Node.js
|
|
150
|
+
* npm
|
|
151
|
+
* Chrome, Firefox, Safari (optional)
|
|
97
152
|
|
|
98
|
-
|
|
99
|
-
|
|
153
|
+
Some special networking features can optionally use a Flash component. See the
|
|
154
|
+
[Flash README](./flash/README.md) for details.
|
|
100
155
|
|
|
101
|
-
|
|
102
|
-
npm install
|
|
103
|
-
npm run bundle
|
|
104
|
-
```
|
|
156
|
+
### Building for a web browser
|
|
105
157
|
|
|
106
|
-
|
|
107
|
-
`npm run bundle` command, try this instead:
|
|
158
|
+
To create single file bundles for use with browsers run the following:
|
|
108
159
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
```
|
|
160
|
+
npm install
|
|
161
|
+
npm run build
|
|
112
162
|
|
|
113
|
-
This will create
|
|
163
|
+
This will create single non-minimized and minimized files that can be
|
|
164
|
+
included in the browser:
|
|
114
165
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
166
|
+
dist/forge.js
|
|
167
|
+
dist/forge.min.js
|
|
168
|
+
|
|
169
|
+
A bundle that adds some utilities and networking support is also available:
|
|
170
|
+
|
|
171
|
+
dist/forge.all.js
|
|
172
|
+
dist/forge.all.min.js
|
|
118
173
|
|
|
119
174
|
Include the file via:
|
|
120
175
|
|
|
121
176
|
```html
|
|
122
|
-
<script src="
|
|
177
|
+
<script src="YOUR_SCRIPT_PATH/forge.js"></script>
|
|
178
|
+
```
|
|
179
|
+
or
|
|
180
|
+
```html
|
|
181
|
+
<script src="YOUR_SCRIPT_PATH/forge.min.js"></script>
|
|
123
182
|
```
|
|
124
183
|
|
|
125
184
|
The above bundles will synchronously create a global 'forge' object.
|
|
126
185
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
186
|
+
**Note**: These bundles will not include any WebWorker scripts (eg:
|
|
187
|
+
`dist/prime.worker.js`), so these will need to be accessible from the browser
|
|
188
|
+
if any WebWorkers are used.
|
|
189
|
+
|
|
190
|
+
### Building a custom browser bundle
|
|
130
191
|
|
|
131
|
-
|
|
132
|
-
|
|
192
|
+
The build process uses [webpack][] and the [config](./webpack.config.js) file
|
|
193
|
+
can be modified to generate a file or files that only contain the parts of
|
|
194
|
+
forge you need.
|
|
133
195
|
|
|
134
|
-
|
|
196
|
+
[Browserify][] override support is also present in `package.json`.
|
|
135
197
|
|
|
136
|
-
|
|
137
|
-
|
|
198
|
+
Testing
|
|
199
|
+
-------
|
|
138
200
|
|
|
139
|
-
|
|
201
|
+
See the [testing README](./tests/README.md) for full details.
|
|
202
|
+
|
|
203
|
+
### Prepare to run tests
|
|
140
204
|
|
|
141
|
-
cd nodejs
|
|
142
205
|
npm install
|
|
206
|
+
|
|
207
|
+
### Running automated tests with Node.js
|
|
208
|
+
|
|
209
|
+
Forge natively runs in a [Node.js][] environment:
|
|
210
|
+
|
|
143
211
|
npm test
|
|
144
|
-
npm start
|
|
145
212
|
|
|
213
|
+
### Running automated tests with PhantomJS
|
|
146
214
|
|
|
147
|
-
|
|
215
|
+
Automated testing is done via [Karma][]. By default it will run the tests in a
|
|
216
|
+
headless manner with PhantomJS.
|
|
148
217
|
|
|
149
|
-
|
|
218
|
+
npm run test-karma
|
|
150
219
|
|
|
151
|
-
|
|
152
|
-
|
|
220
|
+
Is 'mocha' reporter output too verbose? Other reporters are available. Try
|
|
221
|
+
'dots', 'progress', or 'tap'.
|
|
153
222
|
|
|
154
|
-
|
|
155
|
-
SSL module for testing. To see configure options, run `./configure --help`.
|
|
223
|
+
npm run test-karma -- --reporters progress
|
|
156
224
|
|
|
157
|
-
|
|
225
|
+
By default [webpack][] is used. [Browserify][] can also be used.
|
|
158
226
|
|
|
159
|
-
|
|
160
|
-
the --help option to get help for configuring ports. The server will print out
|
|
161
|
-
the local URL you can vist to run tests.
|
|
227
|
+
BUNDLER=browserify npm run test-karma
|
|
162
228
|
|
|
163
|
-
|
|
229
|
+
### Running automated tests with one or more browsers
|
|
164
230
|
|
|
165
|
-
|
|
231
|
+
You can also specify one or more browsers to use.
|
|
166
232
|
|
|
167
|
-
|
|
233
|
+
npm run test-karma -- --browsers Chrome,Firefox,Safari,PhantomJS
|
|
168
234
|
|
|
169
|
-
|
|
235
|
+
The reporter option and `BUNDLER` environment variable can also be used.
|
|
170
236
|
|
|
171
|
-
|
|
172
|
-
-------------
|
|
237
|
+
### Running manual tests in a browser
|
|
173
238
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
239
|
+
Testing in a browser uses [webpack][] to combine forge and all tests and then
|
|
240
|
+
loading the result in a browser. A simple web server is provided that will
|
|
241
|
+
output the HTTP or HTTPS URLs to load. It also will start a simple Flash Policy
|
|
242
|
+
Server. Unit tests and older legacy tests are provided. Custom ports can be
|
|
243
|
+
used by running `node tests/server.js` manually.
|
|
178
244
|
|
|
179
|
-
|
|
245
|
+
To run the unit tests in a browser a special forge build is required:
|
|
180
246
|
|
|
181
|
-
|
|
182
|
-
may retain it, so long as that license is compatible with the Forge license.
|
|
247
|
+
npm run test-build
|
|
183
248
|
|
|
184
|
-
|
|
185
|
-
-------------
|
|
249
|
+
To run legacy browser based tests the main forge build is required:
|
|
186
250
|
|
|
187
|
-
|
|
251
|
+
npm run build
|
|
188
252
|
|
|
189
|
-
|
|
190
|
-
* [HTTP](#http)
|
|
191
|
-
* [SSH](#ssh)
|
|
192
|
-
* [XHR](#xhr)
|
|
193
|
-
* [Sockets](#socket)
|
|
253
|
+
The tests are run with a custom server that prints out the URLs to use:
|
|
194
254
|
|
|
195
|
-
|
|
255
|
+
npm run test-server
|
|
196
256
|
|
|
197
|
-
|
|
198
|
-
* [AES](#aes)
|
|
199
|
-
* [DES](#des)
|
|
200
|
-
* [RC2](#rc2)
|
|
257
|
+
### Running other tests
|
|
201
258
|
|
|
202
|
-
|
|
259
|
+
There are some other random tests and benchmarks available in the tests
|
|
260
|
+
directory.
|
|
203
261
|
|
|
204
|
-
|
|
205
|
-
* [RSA-KEM](#rsakem)
|
|
206
|
-
* [X.509](#x509)
|
|
207
|
-
* [PKCS#5](#pkcs5)
|
|
208
|
-
* [PKCS#7](#pkcs7)
|
|
209
|
-
* [PKCS#8](#pkcs8)
|
|
210
|
-
* [PKCS#10](#pkcs10)
|
|
211
|
-
* [PKCS#12](#pkcs12)
|
|
212
|
-
* [ASN.1](#asn)
|
|
262
|
+
### Coverage testing
|
|
213
263
|
|
|
214
|
-
|
|
264
|
+
To perform coverage testing of the unit tests, run the following. The results
|
|
265
|
+
will be put in the `coverage/` directory. Note that coverage testing can slow
|
|
266
|
+
down some tests considerably.
|
|
215
267
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
* [SHA384](#sha384)
|
|
219
|
-
* [SHA512](#sha512)
|
|
220
|
-
* [MD5](#md5)
|
|
221
|
-
* [HMAC](#hmac)
|
|
268
|
+
npm install
|
|
269
|
+
npm run coverage
|
|
222
270
|
|
|
223
|
-
|
|
271
|
+
Contributing
|
|
272
|
+
------------
|
|
224
273
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
* [Logging](#log)
|
|
230
|
-
* [Debugging](#debug)
|
|
231
|
-
* [Flash Socket Policy Module](#fsp)
|
|
274
|
+
Any contributions (eg: PRs) that are accepted will be brought under the same
|
|
275
|
+
license used by the rest of the Forge project. This license allows Forge to
|
|
276
|
+
be used under the terms of either the BSD License or the GNU General Public
|
|
277
|
+
License (GPL) Version 2.
|
|
232
278
|
|
|
233
|
-
|
|
279
|
+
See: [LICENSE](https://github.com/digitalbazaar/forge/blob/cbebca3780658703d925b61b2caffb1d263a6c1d/LICENSE)
|
|
280
|
+
|
|
281
|
+
If a contribution contains 3rd party source code with its own license, it
|
|
282
|
+
may retain it, so long as that license is compatible with the Forge license.
|
|
283
|
+
|
|
284
|
+
API
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
<a name="options" />
|
|
288
|
+
### Options
|
|
234
289
|
|
|
235
290
|
If at any time you wish to disable the use of native code, where available,
|
|
236
291
|
for particular forge features like its secure random number generator, you
|
|
237
|
-
may set the ```
|
|
238
|
-
|
|
292
|
+
may set the ```forge.options.usePureJavaScript``` flag to ```true```. It is
|
|
293
|
+
not recommended that you set this flag as native code is typically more
|
|
239
294
|
performant and may have stronger security properties. It may be useful to
|
|
240
295
|
set this flag to test certain features that you plan to run in environments
|
|
241
296
|
that are different from your testing environment.
|
|
@@ -243,27 +298,15 @@ that are different from your testing environment.
|
|
|
243
298
|
To disable native code when including forge in the browser:
|
|
244
299
|
|
|
245
300
|
```js
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
// Note: with this approach, script files *must*
|
|
249
|
-
// be included after initializing the global forge var
|
|
250
|
-
|
|
251
|
-
// alternatively, include script files first and then call
|
|
252
|
-
forge = forge({disableNativeCode: true});
|
|
253
|
-
|
|
254
|
-
// Note: forge will be permanently reconfigured now;
|
|
255
|
-
// to avoid this but use the same "forge" var name,
|
|
256
|
-
// you can wrap your code in a function to shadow the
|
|
257
|
-
// global var, eg:
|
|
258
|
-
(function(forge) {
|
|
259
|
-
// ...
|
|
260
|
-
})(forge({disableNativeCode: true}));
|
|
301
|
+
// run this *after* including the forge script
|
|
302
|
+
forge.options.usePureJavaScript = true;
|
|
261
303
|
```
|
|
262
304
|
|
|
263
|
-
To disable native code when using
|
|
305
|
+
To disable native code when using Node.js:
|
|
264
306
|
|
|
265
307
|
```js
|
|
266
|
-
var forge = require('node-forge')
|
|
308
|
+
var forge = require('node-forge');
|
|
309
|
+
forge.options.usePureJavaScript = true;
|
|
267
310
|
```
|
|
268
311
|
|
|
269
312
|
Transports
|
|
@@ -603,6 +646,7 @@ var key = forge.pkcs5.pbkdf2('password', salt, numIterations, 16);
|
|
|
603
646
|
|
|
604
647
|
// encrypt some bytes using CBC mode
|
|
605
648
|
// (other modes include: ECB, CFB, OFB, CTR, and GCM)
|
|
649
|
+
// Note: CBC and ECB modes use PKCS#7 padding as default
|
|
606
650
|
var cipher = forge.cipher.createCipher('AES-CBC', key);
|
|
607
651
|
cipher.start({iv: iv});
|
|
608
652
|
cipher.update(forge.util.createBuffer(someBytes));
|
|
@@ -653,7 +697,7 @@ if(pass) {
|
|
|
653
697
|
}
|
|
654
698
|
```
|
|
655
699
|
|
|
656
|
-
Using forge in
|
|
700
|
+
Using forge in Node.js to match openssl's "enc" command line tool (**Note**: OpenSSL "enc" uses a non-standard file format with a custom key derivation function and a fixed iteration count of 1, which some consider less secure than alternatives such as [OpenPGP](https://tools.ietf.org/html/rfc4880)/[GnuPG](https://www.gnupg.org/)):
|
|
657
701
|
|
|
658
702
|
```js
|
|
659
703
|
var forge = require('node-forge');
|
|
@@ -1468,7 +1512,7 @@ var object = asn1.fromDer(derBuffer);
|
|
|
1468
1512
|
var derOidBuffer = asn1.oidToDer('1.2.840.113549.1.1.5');
|
|
1469
1513
|
|
|
1470
1514
|
// convert a byte buffer with a DER-encoded OID to a dot-separated string
|
|
1471
|
-
console.log(asn1.
|
|
1515
|
+
console.log(asn1.derToOid(derOidBuffer));
|
|
1472
1516
|
// output: 1.2.840.113549.1.1.5
|
|
1473
1517
|
|
|
1474
1518
|
// validates that an ASN.1 object matches a particular ASN.1 structure and
|
|
@@ -1715,6 +1759,7 @@ Provides queuing and synchronizing tasks in a web application.
|
|
|
1715
1759
|
__Examples__
|
|
1716
1760
|
|
|
1717
1761
|
```js
|
|
1762
|
+
// TODO
|
|
1718
1763
|
```
|
|
1719
1764
|
|
|
1720
1765
|
<a name="util" />
|
|
@@ -1758,12 +1803,12 @@ bytes.bytes(/* count */);
|
|
|
1758
1803
|
// empty this buffer and get its contents
|
|
1759
1804
|
bytes.getBytes(/* count */);
|
|
1760
1805
|
|
|
1761
|
-
// convert a forge buffer into a
|
|
1806
|
+
// convert a forge buffer into a Node.js Buffer
|
|
1762
1807
|
// make sure you specify the encoding as 'binary'
|
|
1763
1808
|
var forgeBuffer = forge.util.createBuffer();
|
|
1764
1809
|
var nodeBuffer = new Buffer(forgeBuffer.getBytes(), 'binary');
|
|
1765
1810
|
|
|
1766
|
-
// convert a
|
|
1811
|
+
// convert a Node.js Buffer into a forge buffer
|
|
1767
1812
|
// make sure you specify the encoding as 'binary'
|
|
1768
1813
|
var nodeBuffer = new Buffer();
|
|
1769
1814
|
var forgeBuffer = forge.util.createBuffer(nodeBuffer.toString('binary'));
|
|
@@ -1797,16 +1842,42 @@ __Examples__
|
|
|
1797
1842
|
// TODO
|
|
1798
1843
|
```
|
|
1799
1844
|
|
|
1800
|
-
<a name="
|
|
1801
|
-
### Flash
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1845
|
+
<a name="flash" />
|
|
1846
|
+
### Flash Networking Support
|
|
1847
|
+
|
|
1848
|
+
The [flash README](./flash/README.md) provides details on rebuilding the
|
|
1849
|
+
optional Flash component used for networking. It also provides details on
|
|
1850
|
+
Policy Server support.
|
|
1851
|
+
|
|
1852
|
+
Security Considerations
|
|
1853
|
+
-----------------------
|
|
1854
|
+
|
|
1855
|
+
When using this code please keep the following in mind:
|
|
1856
|
+
|
|
1857
|
+
- Cryptography is hard. Please review and test this code before depending on it
|
|
1858
|
+
for critical functionality.
|
|
1859
|
+
- The nature of JavaScript is that execution of this code depends on trusting a
|
|
1860
|
+
very large set of JavaScript tools and systems. Consider runtime variations,
|
|
1861
|
+
runtime characteristics, runtime optimization, code optimization, code
|
|
1862
|
+
minimization, code obfuscation, bundling tools, possible bugs, the Forge code
|
|
1863
|
+
itself, and so on.
|
|
1864
|
+
- If using pre-built bundles from [Bower][] or similar be aware someone else
|
|
1865
|
+
ran the tools to create those files.
|
|
1866
|
+
- Use a secure transport channel such as [TLS][] to load scripts and consider
|
|
1867
|
+
using additional security mechanisms such as [Subresource Integrity][] script
|
|
1868
|
+
attributes.
|
|
1869
|
+
- Use "native" functionality where possible. This can be critical when dealing
|
|
1870
|
+
with performance and random number generation. Note that the JavaScript
|
|
1871
|
+
random number algorithms should perform well if given suitable entropy.
|
|
1872
|
+
- Understand possible attacks against cryptographic systems. For instance side
|
|
1873
|
+
channel and timing attacks may be possible due to the difficulty in
|
|
1874
|
+
implementing constant time algorithms in pure JavaScript.
|
|
1875
|
+
- Certain features in this library are less susceptible to attacks depending on
|
|
1876
|
+
usage. This primarily includes features that deal with data format
|
|
1877
|
+
manipulation or those that are not involved in communication.
|
|
1878
|
+
|
|
1879
|
+
Library Background
|
|
1880
|
+
------------------
|
|
1810
1881
|
|
|
1811
1882
|
* http://digitalbazaar.com/2010/07/20/javascript-tls-1/
|
|
1812
1883
|
* http://digitalbazaar.com/2010/07/20/javascript-tls-2/
|
|
@@ -1828,20 +1899,25 @@ Financial support is welcome and helps contribute to futher development:
|
|
|
1828
1899
|
* Something else? Please contact support@digitalbazaar.com.
|
|
1829
1900
|
|
|
1830
1901
|
[#forgejs]: https://webchat.freenode.net/?channels=#forgejs
|
|
1902
|
+
[0.6.x]: https://github.com/digitalbazaar/forge/tree/0.6.x
|
|
1831
1903
|
[3DES]: http://en.wikipedia.org/wiki/Triple_DES
|
|
1832
1904
|
[AES]: http://en.wikipedia.org/wiki/Advanced_Encryption_Standard
|
|
1833
1905
|
[ASN.1]: http://en.wikipedia.org/wiki/ASN.1
|
|
1834
|
-
[
|
|
1906
|
+
[Bower]: https://bower.io/
|
|
1907
|
+
[Browserify]: http://browserify.org/
|
|
1835
1908
|
[CBC]: http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation
|
|
1836
1909
|
[CFB]: http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation
|
|
1837
1910
|
[CTR]: http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation
|
|
1911
|
+
[CommonJS]: https://en.wikipedia.org/wiki/CommonJS
|
|
1838
1912
|
[DES]: http://en.wikipedia.org/wiki/Data_Encryption_Standard
|
|
1839
1913
|
[ECB]: http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation
|
|
1840
1914
|
[Fortuna]: http://en.wikipedia.org/wiki/Fortuna_(PRNG)
|
|
1841
1915
|
[GCM]: http://en.wikipedia.org/wiki/GCM_mode
|
|
1842
1916
|
[HMAC]: http://en.wikipedia.org/wiki/HMAC
|
|
1843
1917
|
[JavaScript]: http://en.wikipedia.org/wiki/JavaScript
|
|
1918
|
+
[Karma]: https://karma-runner.github.io/
|
|
1844
1919
|
[MD5]: http://en.wikipedia.org/wiki/MD5
|
|
1920
|
+
[Node.js]: http://nodejs.org/
|
|
1845
1921
|
[OFB]: http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation
|
|
1846
1922
|
[PKCS#10]: http://en.wikipedia.org/wiki/Certificate_signing_request
|
|
1847
1923
|
[PKCS#12]: http://en.wikipedia.org/wiki/PKCS_%E2%99%AF12
|
|
@@ -1853,7 +1929,10 @@ Financial support is welcome and helps contribute to futher development:
|
|
|
1853
1929
|
[SHA-256]: http://en.wikipedia.org/wiki/SHA-256
|
|
1854
1930
|
[SHA-384]: http://en.wikipedia.org/wiki/SHA-384
|
|
1855
1931
|
[SHA-512]: http://en.wikipedia.org/wiki/SHA-512
|
|
1932
|
+
[Subresource Integrity]: https://www.w3.org/TR/SRI/
|
|
1856
1933
|
[TLS]: http://en.wikipedia.org/wiki/Transport_Layer_Security
|
|
1934
|
+
[UMD]: https://github.com/umdjs/umd
|
|
1857
1935
|
[X.509]: http://en.wikipedia.org/wiki/X.509
|
|
1858
1936
|
[freenode]: https://freenode.net/
|
|
1859
|
-
[
|
|
1937
|
+
[unpkg]: https://unpkg.com/
|
|
1938
|
+
[webpack]: https://webpack.github.io/
|