You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -57,35 +57,22 @@ var key = new NodeRSA([keyData, [format]], [options]);
57
57
#### Options
58
58
You can specify some options by second/third constructor argument, or over `key.setOptions()` method.
59
59
60
-
* environment — working environment, `'browser'` or `'node'`. Default autodetect.
60
+
* environment — working environment (default autodetect):
61
+
*`'browser'` — will run pure js implementation of RSA algorithms.
62
+
*`'node'` for `nodejs >= 0.10.x or io.js >= 1.x` — provide some native methods like sign/verify and encrypt/decrypt.
61
63
* encryptionScheme — padding scheme for encrypt/decrypt. Can be `'pkcs1_oaep'` or `'pkcs1'`. Default `'pkcs1_oaep'`.
62
64
* signingScheme — scheme used for signing and verifying. Can be `'pkcs1'` or `'pss'` or 'scheme-hash' format string (eg `'pss-sha1'`). Default `'pkcs1-sha256'`, or, if chosen pss: `'pss-sha1'`.
63
65
64
-
**Advanced options:**<br/>
65
-
You also can specify advanced options for some schemes like this:
66
-
```javascript
67
-
options = {
68
-
encryptionScheme: {
69
-
scheme:'pkcs1_oaep', //scheme
70
-
hash:'md5', //hash using for scheme
71
-
mgf:function(...) {...} //mask generation function
72
-
},
73
-
signingScheme: {
74
-
scheme:'pss', //scheme
75
-
hash:'sha1', //hash using for scheme
76
-
saltLength:20//salt length for pss sign
77
-
}
78
-
}
79
-
```
66
+
> *Notice:* This lib supporting next hash algorithms: `'md5'`, `'ripemd160'`, `'sha1'`, `'sha256'`, `'sha512'` in browser and node environment and additional `'md4'`, `'sha'`, `'sha224'`, `'sha384'` in node only.
80
67
81
-
This lib supporting next hash algorithms: `'md5'`, `'ripemd160'`, `'sha1'`, `'sha256'`, `'sha512'` in browser and node environment and additional `'md4'`, `'sha'`, `'sha224'`, `'sha384'` in node only.
#### Generate new key 512bit-length and with public exponent 65537
75
+
#### Generate new 512bit-length key
89
76
```javascript
90
77
var key =newNodeRSA({b:512});
91
78
```
@@ -136,7 +123,7 @@ Output type — can be:
136
123
*`'pem'` — Base64 encoded string with header and footer. Used by default.
137
124
*`'der'` — Binary encoded key data.
138
125
139
-
**Notice:** For import, if *keyData* is PEM string or buffer containing string, you can do not specify format, but if you provide *keyData* as DER you must specify it in format string.
126
+
> *Notice:* For import, if *keyData* is PEM string or buffer containing string, you can do not specify format, but if you provide *keyData* as DER you must specify it in format string.
140
127
141
128
**Shortcuts and examples**
142
129
*`'private'` or `'pkcs1'` or `'pkcs1-private'` == `'pkcs1-private-pem'` — private key encoded in pcks1 scheme as pem string.
@@ -183,6 +170,7 @@ Return max data size for encrypt in bytes.
key.encryptPrivate(buffer, [encoding], [source_encoding]); // use private key for encryption
186
174
```
187
175
Return encrypted data.<br/>
188
176
@@ -192,12 +180,15 @@ Return encrypted data.<br/>
192
180
193
181
```javascript
194
182
key.decrypt(buffer, [encoding]);
183
+
key.decryptPublic(buffer, [encoding]); // use public key for decryption
195
184
```
196
185
Return decrypted data.<br/>
197
186
198
187
* buffer — `{buffer}` — data for decrypting. Takes Buffer object or base64 encoded string.<br/>
199
188
* encoding — `{string}` — encoding for result string. Can also take `'buffer'` for raw Buffer object, or `'json'` for automatic JSON.parse result. Default `'buffer'`.
200
189
190
+
> *Notice:* usage `encryptPrivate` and `decryptPublic` with `pkcs1_oaep` padding not described in the RSA [specification](http://www.emc.com/collateral/white-papers/h11300-pkcs-1v2-2-rsa-cryptography-standard-wp.pdf)
191
+
201
192
### Signing/Verifying
202
193
```javascript
203
194
key.sign(buffer, [encoding], [source_encoding]);
@@ -220,6 +211,12 @@ Questions, comments, bug reports, and pull requests are all welcome.
220
211
221
212
## Changelog
222
213
214
+
### 0.2.20
215
+
* Added `.encryptPrivate()` and `.decryptPublic()` methods.
216
+
* Encrypt/decrypt methods in nodejs 0.12.x and io.js using native implementation (> 40x speed boost).
217
+
* Fixed some regex issue causing catastrophic backtracking.
218
+
**KNOWN ISSUE*:`encryptPrivate` and `decryptPublic` don't have native implementation in nodejs and can't be use in native implementation with pkcs1_oaep padding in io.js.
219
+
223
220
### 0.2.10
224
221
***Methods `.exportPrivate()` and `.exportPublic()` was replaced by `.exportKey([format])`.**
225
222
* By default `.exportKey()` returns private key as `.exportPrivate()`, if you need public key from `.exportPublic()` you must specify format as `'public'` or `'pkcs8-public-pem'`.
@@ -229,34 +226,34 @@ Questions, comments, bug reports, and pull requests are all welcome.
229
226
***`.getPublicPEM()` method was renamed to `.exportPublic()`**
230
227
***`.getPrivatePEM()` method was renamed to `.exportPrivate()`**
231
228
***`.loadFromPEM()` method was renamed to `.importKey()`**
232
-
* Added PKCS1_OAEP encrypting/decrypting support
233
-
***PKCS1_OAEP now default scheme, you need to specify 'encryptingScheme' option to 'pkcs1' for compatibility with 0.1.x version of NodeRSA**
234
-
* Added PSS signing/verifying support
229
+
* Added PKCS1_OAEP encrypting/decrypting support.
230
+
***PKCS1_OAEP now default scheme, you need to specify 'encryptingScheme' option to 'pkcs1' for compatibility with 0.1.x version of NodeRSA.**
231
+
* Added PSS signing/verifying support.
235
232
* Signing now supports `'md5'`, `'ripemd160'`, `'sha1'`, `'sha256'`, `'sha512'` hash algorithms in both environments
236
233
and additional `'md4'`, `'sha'`, `'sha224'`, `'sha384'` for nodejs env.
237
234
***`options.signingAlgorithm` was renamed to `options.signingScheme`**
238
-
* Added `encryptingScheme` option
235
+
* Added `encryptingScheme` option.
239
236
* Property `key.options` now mark as private. Added `key.setOptions(options)` method.
240
237
241
238
242
239
### 0.1.54
243
-
* Added support for loading PEM key from Buffer (`fs.readFileSync()` output)
244
-
* Added `isEmpty()` method
240
+
* Added support for loading PEM key from Buffer (`fs.readFileSync()` output).
241
+
* Added `isEmpty()` method.
245
242
246
243
### 0.1.52
247
-
* Improve work with not properly trimming PEM strings
244
+
* Improve work with not properly trimming PEM strings.
248
245
249
246
### 0.1.50
250
-
* Implemented native js signing and verifying for browsers
251
-
*`options.signingAlgorithm` now takes only hash-algorithm name
252
-
* Added `.getKeySize()` and `.getMaxMessageSize()` methods
253
-
*`.loadFromPublicPEM` and `.loadFromPrivatePEM` methods marked as private
247
+
* Implemented native js signing and verifying for browsers.
248
+
*`options.signingAlgorithm` now takes only hash-algorithm name.
249
+
* Added `.getKeySize()` and `.getMaxMessageSize()` methods.
250
+
*`.loadFromPublicPEM` and `.loadFromPrivatePEM` methods marked as private.
0 commit comments