5
5
var BigInteger = require ( '../libs/jsbn' ) ;
6
6
var crypt = require ( 'crypto' ) ;
7
7
var constants = require ( 'constants' ) ;
8
- var _ = require ( 'lodash' ) ;
9
8
var SIGN_INFO_HEAD = {
10
9
md2 : new Buffer ( '3020300c06082a864886f70d020205000410' , 'hex' ) ,
11
10
md5 : new Buffer ( '3020300c06082a864886f70d020505000410' , 'hex' ) ,
@@ -24,11 +23,6 @@ var SIGN_ALG_TO_HASH_ALIASES = {
24
23
25
24
var DEFAULT_HASH_FUNCTION = 'sha256' ;
26
25
27
- if ( typeof constants . RSA_NO_PADDING == "undefined" ) {
28
- //patch for node v0.10.x, constants do not defined
29
- constants . RSA_NO_PADDING = 3 ;
30
- }
31
-
32
26
module . exports = {
33
27
isEncryption : true ,
34
28
isSignature : true
@@ -41,7 +35,7 @@ module.exports.makeScheme = function (key, options) {
41
35
}
42
36
43
37
Scheme . prototype . maxMessageLength = function ( ) {
44
- if ( ! _ . isEmpty ( this . options . encryptionSchemeOptions ) && this . options . encryptionSchemeOptions . padding == constants . RSA_NO_PADDING ) {
38
+ if ( this . options . encryptionSchemeOptions && this . options . encryptionSchemeOptions . padding == constants . RSA_NO_PADDING ) {
45
39
return this . key . encryptedDataLength ;
46
40
}
47
41
return this . key . encryptedDataLength - 11 ;
@@ -59,7 +53,7 @@ module.exports.makeScheme = function (key, options) {
59
53
if ( buffer . length > this . key . maxMessageLength ) {
60
54
throw new Error ( "Message too long for RSA (n=" + this . key . encryptedDataLength + ", l=" + buffer . length + ")" ) ;
61
55
}
62
- if ( ! _ . isEmpty ( this . options . encryptionSchemeOptions ) && this . options . encryptionSchemeOptions . padding == constants . RSA_NO_PADDING ) {
56
+ if ( this . options . encryptionSchemeOptions && this . options . encryptionSchemeOptions . padding == constants . RSA_NO_PADDING ) {
63
57
//RSA_NO_PADDING treated like JAVA left pad with zero character
64
58
filled = new Buffer ( this . key . maxMessageLength - buffer . length ) ;
65
59
filled . fill ( 0 ) ;
@@ -102,7 +96,7 @@ module.exports.makeScheme = function (key, options) {
102
96
options = options || { } ;
103
97
var i = 0 ;
104
98
105
- if ( ! _ . isEmpty ( this . options . encryptionSchemeOptions ) && this . options . encryptionSchemeOptions . padding == constants . RSA_NO_PADDING ) {
99
+ if ( this . options . encryptionSchemeOptions && this . options . encryptionSchemeOptions . padding == constants . RSA_NO_PADDING ) {
106
100
//RSA_NO_PADDING treated like JAVA left pad with zero character
107
101
var unPad ;
108
102
if ( typeof buffer . lastIndexOf == "function" ) { //patch for old node version
@@ -164,7 +158,7 @@ module.exports.makeScheme = function (key, options) {
164
158
Scheme . prototype . verify = function ( buffer , signature , signature_encoding ) {
165
159
if ( this . options . encryptionSchemeOptions && this . options . encryptionSchemeOptions . padding == constants . RSA_NO_PADDING ) {
166
160
//RSA_NO_PADDING has no verify data
167
- return true ;
161
+ return false ;
168
162
}
169
163
var hashAlgorithm = this . options . signingSchemeOptions . hash || DEFAULT_HASH_FUNCTION ;
170
164
if ( this . options . environment === 'browser' ) {
0 commit comments