@@ -74,7 +74,7 @@ const assert = require('assert');
74
74
const StringDecoder = require ( 'string_decoder' ) . StringDecoder ;
75
75
76
76
77
- exports . createHash = exports . Hash = Hash ;
77
+ exports . Hash = Hash ;
78
78
function Hash ( algorithm , options ) {
79
79
if ( ! ( this instanceof Hash ) )
80
80
return new Hash ( algorithm , options ) ;
@@ -108,7 +108,7 @@ Hash.prototype.digest = function digest(outputEncoding) {
108
108
} ;
109
109
110
110
111
- exports . createHmac = exports . Hmac = Hmac ;
111
+ exports . Hmac = Hmac ;
112
112
113
113
function Hmac ( hmac , key , options ) {
114
114
if ( ! ( this instanceof Hmac ) )
@@ -134,7 +134,7 @@ function getDecoder(decoder, encoding) {
134
134
}
135
135
136
136
137
- exports . createCipher = exports . Cipher = Cipher ;
137
+ exports . Cipher = Cipher ;
138
138
function Cipher ( cipher , password , options ) {
139
139
if ( ! ( this instanceof Cipher ) )
140
140
return new Cipher ( cipher , password , options ) ;
@@ -211,7 +211,7 @@ Cipher.prototype.setAAD = function setAAD(aadbuf) {
211
211
return this ;
212
212
} ;
213
213
214
- exports . createCipheriv = exports . Cipheriv = Cipheriv ;
214
+ exports . Cipheriv = Cipheriv ;
215
215
function Cipheriv ( cipher , key , iv , options ) {
216
216
if ( ! ( this instanceof Cipheriv ) )
217
217
return new Cipheriv ( cipher , key , iv , options ) ;
@@ -233,7 +233,7 @@ Cipheriv.prototype.getAuthTag = Cipher.prototype.getAuthTag;
233
233
Cipheriv . prototype . setAuthTag = Cipher . prototype . setAuthTag ;
234
234
Cipheriv . prototype . setAAD = Cipher . prototype . setAAD ;
235
235
236
- exports . createDecipher = exports . Decipher = Decipher ;
236
+ exports . Decipher = Decipher ;
237
237
function Decipher ( cipher , password , options ) {
238
238
if ( ! ( this instanceof Decipher ) )
239
239
return new Decipher ( cipher , password , options ) ;
@@ -258,7 +258,7 @@ Decipher.prototype.setAuthTag = Cipher.prototype.setAuthTag;
258
258
Decipher . prototype . setAAD = Cipher . prototype . setAAD ;
259
259
260
260
261
- exports . createDecipheriv = exports . Decipheriv = Decipheriv ;
261
+ exports . Decipheriv = Decipheriv ;
262
262
function Decipheriv ( cipher , key , iv , options ) {
263
263
if ( ! ( this instanceof Decipheriv ) )
264
264
return new Decipheriv ( cipher , key , iv , options ) ;
@@ -283,7 +283,7 @@ Decipheriv.prototype.setAuthTag = Cipher.prototype.setAuthTag;
283
283
Decipheriv . prototype . setAAD = Cipher . prototype . setAAD ;
284
284
285
285
286
- exports . createSign = exports . Sign = Sign ;
286
+ exports . Sign = Sign ;
287
287
function Sign ( algorithm , options ) {
288
288
if ( ! ( this instanceof Sign ) )
289
289
return new Sign ( algorithm , options ) ;
@@ -339,7 +339,7 @@ Sign.prototype.sign = function sign(options, encoding) {
339
339
} ;
340
340
341
341
342
- exports . createVerify = exports . Verify = Verify ;
342
+ exports . Verify = Verify ;
343
343
function Verify ( algorithm , options ) {
344
344
if ( ! ( this instanceof Verify ) )
345
345
return new Verify ( algorithm , options ) ;
@@ -410,7 +410,7 @@ exports.privateDecrypt = rsaPrivate(binding.privateDecrypt,
410
410
constants . RSA_PKCS1_OAEP_PADDING ) ;
411
411
412
412
413
- exports . createDiffieHellman = exports . DiffieHellman = DiffieHellman ;
413
+ exports . DiffieHellman = DiffieHellman ;
414
414
415
415
function DiffieHellman ( sizeOrKey , keyEncoding , generator , genEncoding ) {
416
416
if ( ! ( this instanceof DiffieHellman ) )
@@ -452,9 +452,7 @@ function DiffieHellman(sizeOrKey, keyEncoding, generator, genEncoding) {
452
452
}
453
453
454
454
455
- exports . DiffieHellmanGroup =
456
- exports . createDiffieHellmanGroup =
457
- exports . getDiffieHellman = DiffieHellmanGroup ;
455
+ exports . DiffieHellmanGroup = DiffieHellmanGroup ;
458
456
459
457
function DiffieHellmanGroup ( name ) {
460
458
if ( ! ( this instanceof DiffieHellmanGroup ) )
@@ -561,7 +559,7 @@ DiffieHellman.prototype.setPrivateKey = function setPrivateKey(key, encoding) {
561
559
} ;
562
560
563
561
564
- exports . createECDH = exports . ECDH = ECDH ;
562
+ exports . ECDH = ECDH ;
565
563
function ECDH ( curve ) {
566
564
if ( ! ( this instanceof ECDH ) )
567
565
return new ECDH ( curve ) ;
@@ -607,6 +605,66 @@ ECDH.prototype.getPublicKey = function getPublicKey(encoding, format) {
607
605
} ;
608
606
609
607
608
+ // These helper functions are needed because the constructors can
609
+ // use new, in which case V8 cannot inline the recursive constructor call
610
+ function createHash ( algorithm , options ) {
611
+ return new Hash ( algorithm , options ) ;
612
+ }
613
+
614
+ function createCipher ( cipher , password , options ) {
615
+ return new Cipher ( cipher , password , options ) ;
616
+ }
617
+
618
+ function createCipheriv ( cipher , key , iv , options ) {
619
+ return new Cipheriv ( cipher , key , iv , options ) ;
620
+ }
621
+
622
+ function createDecipher ( cipher , password , options ) {
623
+ return new Decipher ( cipher , password , options ) ;
624
+ }
625
+
626
+ function createDecipheriv ( cipher , key , iv , options ) {
627
+ return new Decipheriv ( cipher , key , iv , options ) ;
628
+ }
629
+
630
+ function createDiffieHellman ( sizeOrKey , keyEncoding , generator , genEncoding ) {
631
+ return new DiffieHellman ( sizeOrKey , keyEncoding , generator , genEncoding ) ;
632
+ }
633
+
634
+ function createDiffieHellmanGroup ( name ) {
635
+ return new DiffieHellmanGroup ( name ) ;
636
+ }
637
+
638
+ function createECDH ( curve ) {
639
+ return new ECDH ( curve ) ;
640
+ }
641
+
642
+ function createHmac ( hmac , key , options ) {
643
+ return new Hmac ( hmac , key , options ) ;
644
+ }
645
+
646
+ function createSign ( algorithm , options ) {
647
+ return new Sign ( algorithm , options ) ;
648
+ }
649
+
650
+ function createVerify ( algorithm , options ) {
651
+ return new Verify ( algorithm , options ) ;
652
+ }
653
+
654
+ exports . createHash = createHash ;
655
+ exports . createCipher = createCipher ;
656
+ exports . createCipheriv = createCipheriv ;
657
+ exports . createDecipher = createDecipher ;
658
+ exports . createDecipheriv = createDecipheriv ;
659
+ exports . createDiffieHellman = createDiffieHellman ;
660
+ exports . createDiffieHellmanGroup =
661
+ exports . getDiffieHellman = createDiffieHellmanGroup ;
662
+ exports . createECDH = createECDH ;
663
+ exports . createHmac = createHmac ;
664
+ exports . createSign = createSign ;
665
+ exports . createVerify = createVerify ;
666
+
667
+
610
668
exports . pbkdf2 = function ( password ,
611
669
salt ,
612
670
iterations ,
0 commit comments