Skip to content

Commit 4c20232

Browse files
committed
Revert to 6cb15fc
1 parent 150d7eb commit 4c20232

File tree

13 files changed

+1124
-386
lines changed

13 files changed

+1124
-386
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.DS_Store
22
.idea
3+
.tmp
34
node_modules/

README.md

+49-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Based on jsbn library from Tom Wu http://www-cs-students.stanford.edu/~tjw/jsbn/
88
* Generating keys
99
* Supports long messages for encrypt/decrypt
1010
* Signing and verifying
11-
11+
1212

1313
## Example
1414

@@ -48,22 +48,48 @@ var NodeRSA = require('node-rsa');
4848

4949
var key = new NodeRSA([key], [options]);
5050
```
51+
5152
**key** - parameters of a generated key or the key in PEM format.<br/>
5253
**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'`.
5554

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
5783
```javascript
5884
var key = new NodeRSA();
5985
```
6086

61-
### Generate new key 512bit-length and with public exponent 65537
87+
#### Generate new key 512bit-length and with public exponent 65537
6288
```javascript
6389
var key = new NodeRSA({b: 512});
6490
```
6591

66-
### Load key from PEM string
92+
#### Load key from PEM string
6793

6894
```javascript
6995
var key = new NodeRSA('-----BEGIN RSA PRIVATE KEY-----\n'+
@@ -81,15 +107,15 @@ Also you can use next methods:
81107

82108
```javascript
83109
key.generateKeyPair([bits], [exp]);
84-
key.loadFromPEM(pem_string|buffer_contains_pem);
110+
key.importKey(pem_string|buffer_contains_pem);
85111
```
86112
**bits** - key size in bits. 2048 by default.
87113
**exp** - public exponent. 65537 by default.
88114

89115
### Export keys
90116
```javascript
91-
key.getPrivatePEM();
92-
key.getPublicPEM();
117+
key.exportPrivate();
118+
key.exportPublic();
93119
```
94120

95121
### Properties
@@ -155,6 +181,20 @@ Questions, comments, bug reports, and pull requests are all welcome.
155181

156182
## Changelog
157183

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+
158198
### 0.1.54
159199
* Added support for loading PEM key from Buffer (`fs.readFileSync()` output)
160200
* Added `isEmpty()` method

gruntfile.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
module.exports = function(grunt) {
1+
module.exports = function (grunt) {
22
grunt.initConfig({
33
jshint: {
4-
options: {
5-
},
4+
options: {},
65
default: {
76
files: {
8-
src: ['src/**/*.js', '!src/libs/**/*']
7+
src: ['gruntfile.js', 'src/**/*.js', '!src/libs/jsbn.js']
98
}
109
},
1110
libs: {
@@ -19,17 +18,16 @@ module.exports = function(grunt) {
1918
options: {
2019
reporter: 'List'
2120
},
22-
all: { src: ['test/**/*.js'] }
21+
all: {src: ['test/**/*.js']}
2322
}
2423
});
2524

2625
require('jit-grunt')(grunt, {
2726
'simplemocha': 'grunt-simple-mocha'
2827
});
2928

30-
3129
grunt.registerTask('lint', ['jshint:default']);
3230
grunt.registerTask('test', ['simplemocha']);
3331

3432
grunt.registerTask('default', ['lint', 'test']);
35-
}
33+
};

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-rsa",
3-
"version": "0.1.54",
3+
"version": "0.2.0",
44
"description": "Node.js RSA library",
55
"main": "src/NodeRSA.js",
66
"scripts": {
@@ -18,7 +18,10 @@
1818
"encryption",
1919
"decryption",
2020
"sign",
21-
"verify"
21+
"verify",
22+
"pkcs1",
23+
"oaep",
24+
"pss"
2225
],
2326
"author": "rzcoder",
2427
"license": "BSD",

0 commit comments

Comments
 (0)