crypto: simplify diffiehellman getFormat function
This commit aims to simplify the getFormat function in diffiehellman.js. PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
2a30bfe295
commit
3b8ab2ac7f
@ -219,21 +219,15 @@ function encode(buffer, encoding) {
|
||||
}
|
||||
|
||||
function getFormat(format) {
|
||||
let f;
|
||||
if (format) {
|
||||
if (format === 'compressed')
|
||||
f = POINT_CONVERSION_COMPRESSED;
|
||||
else if (format === 'hybrid')
|
||||
f = POINT_CONVERSION_HYBRID;
|
||||
// Default
|
||||
else if (format === 'uncompressed')
|
||||
f = POINT_CONVERSION_UNCOMPRESSED;
|
||||
else
|
||||
return POINT_CONVERSION_COMPRESSED;
|
||||
if (format === 'hybrid')
|
||||
return POINT_CONVERSION_HYBRID;
|
||||
if (format !== 'uncompressed')
|
||||
throw new ERR_CRYPTO_ECDH_INVALID_FORMAT(format);
|
||||
} else {
|
||||
f = POINT_CONVERSION_UNCOMPRESSED;
|
||||
}
|
||||
return f;
|
||||
return POINT_CONVERSION_UNCOMPRESSED;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user