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
**encoding** - encoding for result string. Can also take `'buffer'` for raw Buffer object, or `'json'` for automatic JSON.parse result. Default `'buffer'`.
136
140
137
141
### Signing/Verifying
142
+
143
+
*As of v0.1.55 the default signature scheme is RSASSA-PSS using sha1.
144
+
PKCS1 is still available with the following configuring*
145
+
146
+
```javascript
147
+
key.schemeSignature=NodeRSA.RSA.PKCS1.Default;
148
+
```
149
+
138
150
```javascript
139
151
key.sign(buffer, [encoding], [source_encoding]);
140
152
```
@@ -149,12 +161,45 @@ Return result of check, `true` or `false`.<br/>
149
161
**source_encoding** - same as for `encrypt` method.<br/>
150
162
**signature_encoding** - encoding of given signature. May be `'buffer'`, `'binary'`, `'hex'` or `'base64'`. Default `'buffer'`.
151
163
164
+
### Changing Encryption/Signature schemes.
165
+
166
+
Schemes are the way RSA packs up it's data before encrypting/decrypting/signing/verifying and there are a few ways that it can do it. The most common are RSAES-OAEP, RSASSA-PSS, RSAES-PKCS1-v1_5(encryption/decryption), and RSASSA-PKCS1-v1_5(signing/verifying).
167
+
As of v0.1.55 these 4 mentioned schemes are included in the package with the ability to easily add more later and by users. See below for how to configure NodeRSA to use these different schemes.
168
+
169
+
*Note: The default encryption / signature schemes have been changed from PKCS1 to the more secure OAEP(encryption) and PSS(signature) schemes as per the recommendations of the spec, this can be breaking.*
170
+
171
+
```javascript
172
+
key.schemeSignature=NodeRSA.RSA.PSS.Default; // This is an object that has been automatically instantiated and has the default settings for PSS signing.
173
+
key.schemeSignature=NodeRSA.RSA.PKCS1.Default; // This is an object that has been automatically instantiated and has the default settings for PKCS1 signing/encrypting.
174
+
175
+
key.schemeEncryption=NodeRSA.RSA.OAEP.Default; // This is an object that has been automatically instantiated and has the default settings for OAEP encrypting.
176
+
key.schemeEncryption=NodeRSA.RSA.PKCS1.Default; // This is an object that has been automatically instantiated and has the default settings for PKCS1 signing/encrypting.
177
+
```
178
+
To change schemes between the various defaults, each provided scheme class has a property named "Default" that provides a scheme object with the default settings for that scheme.
179
+
180
+
```javascript
181
+
var pssMD5Scheme =newNodeRSA.RSA.PSS({
182
+
// The options a scheme accepts should be documented in the scheme definition.
183
+
hash:"md5", // Use a different type of hashing function instead of sha1
184
+
mgf: customMaskGenerationFunction // Use a custom mask generation function that accepts 3 parameters (seed, maskLength, hashFunction)
185
+
});
186
+
key.schemeSignature= pssMD5Scheme;
187
+
key2.schemeSignature= pssMD5Scheme;
188
+
```
189
+
Schemes can also be initialized with custom options and can be shared between keys.
190
+
152
191
## Contributing
153
192
154
193
Questions, comments, bug reports, and pull requests are all welcome.
155
194
156
195
## Changelog
157
196
197
+
### 0.1.55
198
+
***The default schemes used to encrypt and sign data have changed from PKCS1 to the recommended OAEP and PSS standards**
199
+
* Overhauled the rsa.js library to allow for schemes and to allow for easy addition of schemes in the future and custom schemes.
200
+
* Modified NodeRSA functions to work with new rsa.js file.
201
+
* All changes should be backwards compatible
202
+
158
203
### 0.1.54
159
204
* Added support for loading PEM key from Buffer (`fs.readFileSync()` output)
console.warn("There are no more options and the parameter is deprecated. It may be removed in the future.");
31
+
if(options.signingAlgorithm){
32
+
console.warn("options.signingAlgorithm has been removed. In order to change the signature hashing algorithm create a signature scheme with the appropriate options and set NodeRSA.schemeSignature to that object. Schemes are defined in src/libs/rsa.js Default is RSASSA-PSS (RSA.PSS) with the hashing function sha1");
0 commit comments