Skip to content

Commit 5ea1a58

Browse 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

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

‎lib/internal/crypto/cipher.js‎

Lines 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-
functionrsaPublic(method,defaultPadding){
36+
functionrsaFunctionFor(method,defaultPadding){
3737
returnfunction(options,buffer){
3838
constkey=options.key||options;
3939
constpadding=options.padding||defaultPadding;
@@ -42,19 +42,10 @@ function rsaPublic(method, defaultPadding) {
4242
};
4343
}
4444

45-
functionrsaPrivate(method,defaultPadding){
46-
returnfunction(options,buffer){
47-
constkey=options.key||options;
48-
constpassphrase=options.passphrase||null;
49-
constpadding=options.padding||defaultPadding;
50-
returnmethod(toBuf(key),buffer,padding,passphrase);
51-
};
52-
}
53-
54-
constpublicEncrypt=rsaPublic(_publicEncrypt,RSA_PKCS1_OAEP_PADDING);
55-
constpublicDecrypt=rsaPublic(_publicDecrypt,RSA_PKCS1_PADDING);
56-
constprivateEncrypt=rsaPrivate(_privateEncrypt,RSA_PKCS1_PADDING);
57-
constprivateDecrypt=rsaPrivate(_privateDecrypt,RSA_PKCS1_OAEP_PADDING);
45+
constpublicEncrypt=rsaFunctionFor(_publicEncrypt,RSA_PKCS1_OAEP_PADDING);
46+
constpublicDecrypt=rsaFunctionFor(_publicDecrypt,RSA_PKCS1_PADDING);
47+
constprivateEncrypt=rsaFunctionFor(_privateEncrypt,RSA_PKCS1_PADDING);
48+
constprivateDecrypt=rsaFunctionFor(_privateDecrypt,RSA_PKCS1_OAEP_PADDING);
5849

5950
functiongetDecoder(decoder,encoding){
6051
encoding=normalizeEncoding(encoding);

0 commit comments

Comments
 (0)