55var BigInteger = require ( '../libs/jsbn' ) ;
66var crypt = require ( 'crypto' ) ;
77var constants = require ( 'constants' ) ;
8- var _ = require ( 'lodash' ) ;
98var SIGN_INFO_HEAD = {
109 md2 : new Buffer ( '3020300c06082a864886f70d020205000410' , 'hex' ) ,
1110 md5 : new Buffer ( '3020300c06082a864886f70d020505000410' , 'hex' ) ,
@@ -24,11 +23,6 @@ var SIGN_ALG_TO_HASH_ALIASES = {
2423
2524var DEFAULT_HASH_FUNCTION = 'sha256' ;
2625
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-
3226module . exports = {
3327 isEncryption : true ,
3428 isSignature : true
@@ -41,7 +35,7 @@ module.exports.makeScheme = function (key, options) {
4135 }
4236
4337 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 ) {
4539 return this . key . encryptedDataLength ;
4640 }
4741 return this . key . encryptedDataLength - 11 ;
@@ -59,7 +53,7 @@ module.exports.makeScheme = function (key, options) {
5953 if ( buffer . length > this . key . maxMessageLength ) {
6054 throw new Error ( "Message too long for RSA (n=" + this . key . encryptedDataLength + ", l=" + buffer . length + ")" ) ;
6155 }
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 ) {
6357 //RSA_NO_PADDING treated like JAVA left pad with zero character
6458 filled = new Buffer ( this . key . maxMessageLength - buffer . length ) ;
6559 filled . fill ( 0 ) ;
@@ -102,7 +96,7 @@ module.exports.makeScheme = function (key, options) {
10296 options = options || { } ;
10397 var i = 0 ;
10498
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 ) {
106100 //RSA_NO_PADDING treated like JAVA left pad with zero character
107101 var unPad ;
108102 if ( typeof buffer . lastIndexOf == "function" ) { //patch for old node version
@@ -164,7 +158,7 @@ module.exports.makeScheme = function (key, options) {
164158 Scheme . prototype . verify = function ( buffer , signature , signature_encoding ) {
165159 if ( this . options . encryptionSchemeOptions && this . options . encryptionSchemeOptions . padding == constants . RSA_NO_PADDING ) {
166160 //RSA_NO_PADDING has no verify data
167- return true ;
161+ return false ;
168162 }
169163 var hashAlgorithm = this . options . signingSchemeOptions . hash || DEFAULT_HASH_FUNCTION ;
170164 if ( this . options . environment === 'browser' ) {
0 commit comments