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 5ea1a58

Browse filesBrowse files
danbevaddaleax
authored andcommitted
crypto: remove rsaPrivate and rename rsaPublic
This commit renames rsaPublic and removes the rsaPrivate function as the code in these two functions are identical. Backport-PR-URL: #20706 PR-URL: #20164 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 503844e commit 5ea1a58
Copy full SHA for 5ea1a58

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

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

‎lib/internal/crypto/cipher.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/cipher.js
+5-14Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const { StringDecoder } = require('string_decoder');
3333
const { inherits } = require('util');
3434
const { deprecate, normalizeEncoding } = require('internal/util');
3535

36-
function rsaPublic(method, defaultPadding) {
36+
function rsaFunctionFor(method, defaultPadding) {
3737
return function(options, buffer) {
3838
const key = options.key || options;
3939
const padding = options.padding || defaultPadding;
@@ -42,19 +42,10 @@ function rsaPublic(method, defaultPadding) {
4242
};
4343
}
4444

45-
function rsaPrivate(method, defaultPadding) {
46-
return function(options, buffer) {
47-
const key = options.key || options;
48-
const passphrase = options.passphrase || null;
49-
const padding = options.padding || defaultPadding;
50-
return method(toBuf(key), buffer, padding, passphrase);
51-
};
52-
}
53-
54-
const publicEncrypt = rsaPublic(_publicEncrypt, RSA_PKCS1_OAEP_PADDING);
55-
const publicDecrypt = rsaPublic(_publicDecrypt, RSA_PKCS1_PADDING);
56-
const privateEncrypt = rsaPrivate(_privateEncrypt, RSA_PKCS1_PADDING);
57-
const privateDecrypt = rsaPrivate(_privateDecrypt, RSA_PKCS1_OAEP_PADDING);
45+
const publicEncrypt = rsaFunctionFor(_publicEncrypt, RSA_PKCS1_OAEP_PADDING);
46+
const publicDecrypt = rsaFunctionFor(_publicDecrypt, RSA_PKCS1_PADDING);
47+
const privateEncrypt = rsaFunctionFor(_privateEncrypt, RSA_PKCS1_PADDING);
48+
const privateDecrypt = rsaFunctionFor(_privateDecrypt, RSA_PKCS1_OAEP_PADDING);
5849

5950
function getDecoder(decoder, encoding) {
6051
encoding = normalizeEncoding(encoding);

0 commit comments

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