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
Copy file name to clipboardExpand all lines: README.md
+49-9
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Based on jsbn library from Tom Wu http://www-cs-students.stanford.edu/~tjw/jsbn/
8
8
* Generating keys
9
9
* Supports long messages for encrypt/decrypt
10
10
* Signing and verifying
11
-
11
+
12
12
13
13
## Example
14
14
@@ -48,22 +48,48 @@ var NodeRSA = require('node-rsa');
48
48
49
49
var key =newNodeRSA([key], [options]);
50
50
```
51
+
51
52
**key** - parameters of a generated key or the key in PEM format.<br/>
52
53
**options** - additional settings
53
-
***environment** - working environment, `'browser'` or `'node'`. Default autodetect.
54
-
***signingAlgorithm** - hash algorithm used for signing and verifying. Can be `'sha1'`, `'sha256'`, `'md5'`. Default `'sha256'`.
55
54
56
-
#### "Empty" key
55
+
#### Options
56
+
You can specify some options by second constructor argument, or over `key.setOptions()` method.
57
+
58
+
***environment** - working environment, `'browser'` or `'node'`. Default autodetect.
59
+
***encryptionScheme** - padding scheme for encrypt/decrypt. Can be `'pkcs1_oaep'` or `'pkcs1'`. Default `'pkcs1_oaep'`.
60
+
***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'`.
61
+
62
+
**Advanced options:**<br/>
63
+
You also can specify advanced options for some schemes like this:
64
+
```
65
+
options = {
66
+
encryptionScheme: {
67
+
scheme: 'pkcs1_oaep', //scheme
68
+
hash: 'md5', //hash using for scheme
69
+
mgf: function(...) {...} //mask generation function
70
+
},
71
+
signingScheme: {
72
+
scheme: 'pss', //scheme
73
+
hash: 'sha1', //hash using for scheme
74
+
saltLength: 20 //salt length for pss sign
75
+
}
76
+
}
77
+
```
78
+
79
+
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
+
81
+
82
+
#### Creating "empty" key
57
83
```javascript
58
84
var key =newNodeRSA();
59
85
```
60
86
61
-
### Generate new key 512bit-length and with public exponent 65537
87
+
####Generate new key 512bit-length and with public exponent 65537
62
88
```javascript
63
89
var key =newNodeRSA({b:512});
64
90
```
65
91
66
-
### Load key from PEM string
92
+
####Load key from PEM string
67
93
68
94
```javascript
69
95
var key =newNodeRSA('-----BEGIN RSA PRIVATE KEY-----\n'+
@@ -81,15 +107,15 @@ Also you can use next methods:
81
107
82
108
```javascript
83
109
key.generateKeyPair([bits], [exp]);
84
-
key.loadFromPEM(pem_string|buffer_contains_pem);
110
+
key.importKey(pem_string|buffer_contains_pem);
85
111
```
86
112
**bits** - key size in bits. 2048 by default.
87
113
**exp** - public exponent. 65537 by default.
88
114
89
115
### Export keys
90
116
```javascript
91
-
key.getPrivatePEM();
92
-
key.getPublicPEM();
117
+
key.exportPrivate();
118
+
key.exportPublic();
93
119
```
94
120
95
121
### Properties
@@ -155,6 +181,20 @@ Questions, comments, bug reports, and pull requests are all welcome.
155
181
156
182
## Changelog
157
183
184
+
### 0.2.0
185
+
***`.getPublicPEM()` method was renamed to `.exportPublic()`**
186
+
***`.getPrivatePEM()` method was renamed to `.exportPrivate()`**
187
+
***`.loadFromPEM()` method was renamed to `.importKey()`**
188
+
* Added PKCS1_OAEP encrypting/decrypting support
189
+
***PKCS1_OAEP now default scheme, you need to specify 'encryptingScheme' option to 'pkcs1' for compatibility with 0.1.x version of NodeRSA**
190
+
* Added PSS signing/verifying support
191
+
* Signing now supports `'md5'`, `'ripemd160'`, `'sha1'`, `'sha256'`, `'sha512'` hash algorithms in both environments
192
+
and additional `'md4'`, `'sha'`, `'sha224'`, `'sha384'` for nodejs env.
193
+
***`options.signingAlgorithm` was renamed to `options.signingScheme`**
194
+
* Added `encryptingScheme` option
195
+
* Property `key.options` now mark as private. Added `key.setOptions(options)` method.
196
+
197
+
158
198
### 0.1.54
159
199
* Added support for loading PEM key from Buffer (`fs.readFileSync()` output)
0 commit comments