Skip to content

Commit 391d2f8

Browse files
danbevMylesBorins
authored andcommitted
crypto: simplify diffiehellman getFormat function
This commit aims to simplify the getFormat function in diffiehellman.js. PR-URL: #20246 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 7f6172b commit 391d2f8

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

‎lib/internal/crypto/diffiehellman.js‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,15 @@ function encode(buffer, encoding) {
219219
}
220220

221221
functiongetFormat(format){
222-
letf;
223222
if(format){
224223
if(format==='compressed')
225-
f=POINT_CONVERSION_COMPRESSED;
226-
elseif(format==='hybrid')
227-
f=POINT_CONVERSION_HYBRID;
228-
// Default
229-
elseif(format==='uncompressed')
230-
f=POINT_CONVERSION_UNCOMPRESSED;
231-
else
224+
returnPOINT_CONVERSION_COMPRESSED;
225+
if(format==='hybrid')
226+
returnPOINT_CONVERSION_HYBRID;
227+
if(format!=='uncompressed')
232228
thrownewERR_CRYPTO_ECDH_INVALID_FORMAT(format);
233-
}else{
234-
f=POINT_CONVERSION_UNCOMPRESSED;
235229
}
236-
returnf;
230+
returnPOINT_CONVERSION_UNCOMPRESSED;
237231
}
238232

239233
module.exports={

0 commit comments

Comments
 (0)