Skip to content

Commit

Permalink
Revert to 6cb15fc
Browse files Browse the repository at this point in the history
  • Loading branch information
rzcoder committed Nov 24, 2014
1 parent 150d7eb commit 4c20232
Show file tree
Hide file tree
Showing 13 changed files with 1,124 additions and 386 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
.idea
.tmp
node_modules/
58 changes: 49 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Based on jsbn library from Tom Wu http://www-cs-students.stanford.edu/~tjw/jsbn/
* Generating keys
* Supports long messages for encrypt/decrypt
* Signing and verifying


## Example

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

var key = new NodeRSA([key], [options]);
```

**key** - parameters of a generated key or the key in PEM format.<br/>
**options** - additional settings
* **environment** - working environment, `'browser'` or `'node'`. Default autodetect.
* **signingAlgorithm** - hash algorithm used for signing and verifying. Can be `'sha1'`, `'sha256'`, `'md5'`. Default `'sha256'`.

#### "Empty" key
#### Options
You can specify some options by second constructor argument, or over `key.setOptions()` method.

* **environment** - working environment, `'browser'` or `'node'`. Default autodetect.
* **encryptionScheme** - padding scheme for encrypt/decrypt. Can be `'pkcs1_oaep'` or `'pkcs1'`. Default `'pkcs1_oaep'`.
* **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'`.

**Advanced options:**<br/>
You also can specify advanced options for some schemes like this:
```
options = {
encryptionScheme: {
scheme: 'pkcs1_oaep', //scheme
hash: 'md5', //hash using for scheme
mgf: function(...) {...} //mask generation function
},
signingScheme: {
scheme: 'pss', //scheme
hash: 'sha1', //hash using for scheme
saltLength: 20 //salt length for pss sign
}
}
```

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.


#### Creating "empty" key
```javascript
var key = new NodeRSA();
```

### Generate new key 512bit-length and with public exponent 65537
#### Generate new key 512bit-length and with public exponent 65537
```javascript
var key = new NodeRSA({b: 512});
```

### Load key from PEM string
#### Load key from PEM string

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

```javascript
key.generateKeyPair([bits], [exp]);
key.loadFromPEM(pem_string|buffer_contains_pem);
key.importKey(pem_string|buffer_contains_pem);
```
**bits** - key size in bits. 2048 by default.
**exp** - public exponent. 65537 by default.

### Export keys
```javascript
key.getPrivatePEM();
key.getPublicPEM();
key.exportPrivate();
key.exportPublic();
```

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

## Changelog

### 0.2.0
* **`.getPublicPEM()` method was renamed to `.exportPublic()`**
* **`.getPrivatePEM()` method was renamed to `.exportPrivate()`**
* **`.loadFromPEM()` method was renamed to `.importKey()`**
* Added PKCS1_OAEP encrypting/decrypting support
* **PKCS1_OAEP now default scheme, you need to specify 'encryptingScheme' option to 'pkcs1' for compatibility with 0.1.x version of NodeRSA**
* Added PSS signing/verifying support
* Signing now supports `'md5'`, `'ripemd160'`, `'sha1'`, `'sha256'`, `'sha512'` hash algorithms in both environments
and additional `'md4'`, `'sha'`, `'sha224'`, `'sha384'` for nodejs env.
* **`options.signingAlgorithm` was renamed to `options.signingScheme`**
* Added `encryptingScheme` option
* Property `key.options` now mark as private. Added `key.setOptions(options)` method.


### 0.1.54
* Added support for loading PEM key from Buffer (`fs.readFileSync()` output)
* Added `isEmpty()` method
Expand Down
12 changes: 5 additions & 7 deletions gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
module.exports = function(grunt) {
module.exports = function (grunt) {
grunt.initConfig({
jshint: {
options: {
},
options: {},
default: {
files: {
src: ['src/**/*.js', '!src/libs/**/*']
src: ['gruntfile.js', 'src/**/*.js', '!src/libs/jsbn.js']
}
},
libs: {
Expand All @@ -19,17 +18,16 @@ module.exports = function(grunt) {
options: {
reporter: 'List'
},
all: { src: ['test/**/*.js'] }
all: {src: ['test/**/*.js']}
}
});

require('jit-grunt')(grunt, {
'simplemocha': 'grunt-simple-mocha'
});


grunt.registerTask('lint', ['jshint:default']);
grunt.registerTask('test', ['simplemocha']);

grunt.registerTask('default', ['lint', 'test']);
}
};
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-rsa",
"version": "0.1.54",
"version": "0.2.0",
"description": "Node.js RSA library",
"main": "src/NodeRSA.js",
"scripts": {
Expand All @@ -18,7 +18,10 @@
"encryption",
"decryption",
"sign",
"verify"
"verify",
"pkcs1",
"oaep",
"pss"
],
"author": "rzcoder",
"license": "BSD",
Expand Down
Loading

0 comments on commit 4c20232

Please sign in to comment.