@@ -79,23 +79,69 @@ const {
79
79
} = require ( 'internal/crypto/util' ) ;
80
80
const Certificate = require ( 'internal/crypto/certificate' ) ;
81
81
82
+ // These helper functions are needed because the constructors can
83
+ // use new, in which case V8 cannot inline the recursive constructor call
84
+ function createHash ( algorithm , options ) {
85
+ return new Hash ( algorithm , options ) ;
86
+ }
87
+
88
+ function createCipher ( cipher , password , options ) {
89
+ return new Cipher ( cipher , password , options ) ;
90
+ }
91
+
92
+ function createCipheriv ( cipher , key , iv , options ) {
93
+ return new Cipheriv ( cipher , key , iv , options ) ;
94
+ }
95
+
96
+ function createDecipher ( cipher , password , options ) {
97
+ return new Decipher ( cipher , password , options ) ;
98
+ }
99
+
100
+ function createDecipheriv ( cipher , key , iv , options ) {
101
+ return new Decipheriv ( cipher , key , iv , options ) ;
102
+ }
103
+
104
+ function createDiffieHellman ( sizeOrKey , keyEncoding , generator , genEncoding ) {
105
+ return new DiffieHellman ( sizeOrKey , keyEncoding , generator , genEncoding ) ;
106
+ }
107
+
108
+ function createDiffieHellmanGroup ( name ) {
109
+ return new DiffieHellmanGroup ( name ) ;
110
+ }
111
+
112
+ function createECDH ( curve ) {
113
+ return new ECDH ( curve ) ;
114
+ }
115
+
116
+ function createHmac ( hmac , key , options ) {
117
+ return new Hmac ( hmac , key , options ) ;
118
+ }
119
+
120
+ function createSign ( algorithm , options ) {
121
+ return new Sign ( algorithm , options ) ;
122
+ }
123
+
124
+ function createVerify ( algorithm , options ) {
125
+ return new Verify ( algorithm , options ) ;
126
+ }
127
+
82
128
module . exports = exports = {
83
129
// Methods
84
130
_toBuf : toBuf ,
85
- createCipher : Cipher ,
86
- createCipheriv : Cipheriv ,
87
- createDecipher : Decipher ,
88
- createDecipheriv : Decipheriv ,
89
- createDiffieHellman : DiffieHellman ,
90
- createDiffieHellmanGroup : DiffieHellmanGroup ,
91
- createECDH : ECDH ,
92
- createHash : Hash ,
93
- createHmac : Hmac ,
94
- createSign : Sign ,
95
- createVerify : Verify ,
131
+ createCipher,
132
+ createCipheriv,
133
+ createDecipher,
134
+ createDecipheriv,
135
+ createDiffieHellman,
136
+ createDiffieHellmanGroup,
137
+ createECDH,
138
+ createHash,
139
+ createHmac,
140
+ createSign,
141
+ createVerify,
96
142
getCiphers,
97
143
getCurves,
98
- getDiffieHellman : DiffieHellmanGroup ,
144
+ getDiffieHellman : createDiffieHellmanGroup ,
99
145
getHashes,
100
146
pbkdf2,
101
147
pbkdf2Sync,
0 commit comments