Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 391d2f8

Browse filesBrowse 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
Copy full SHA for 391d2f8

File tree

Expand file treeCollapse file tree

1 file changed

+5
-11
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-11
lines changed
Open diff view settings
Collapse file

‎lib/internal/crypto/diffiehellman.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/diffiehellman.js
+5-11Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,15 @@ function encode(buffer, encoding) {
219219
}
220220

221221
function getFormat(format) {
222-
let f;
223222
if (format) {
224223
if (format === 'compressed')
225-
f = POINT_CONVERSION_COMPRESSED;
226-
else if (format === 'hybrid')
227-
f = POINT_CONVERSION_HYBRID;
228-
// Default
229-
else if (format === 'uncompressed')
230-
f = POINT_CONVERSION_UNCOMPRESSED;
231-
else
224+
return POINT_CONVERSION_COMPRESSED;
225+
if (format === 'hybrid')
226+
return POINT_CONVERSION_HYBRID;
227+
if (format !== 'uncompressed')
232228
throw new ERR_CRYPTO_ECDH_INVALID_FORMAT(format);
233-
} else {
234-
f = POINT_CONVERSION_UNCOMPRESSED;
235229
}
236-
return f;
230+
return POINT_CONVERSION_UNCOMPRESSED;
237231
}
238232

239233
module.exports = {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.