Skip to content

Commit

Permalink
Address Node 20 compatibility
Browse files Browse the repository at this point in the history
- use pure RSA implementation (not native) for decryption; Node 20 deprecates it due to CVE-2023-46809
  • Loading branch information
tylerccarson committed Jan 20, 2025
1 parent 4af0223 commit de5ed76
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions keeperapi/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion keeperapi/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@keeper-security/keeperapi",
"description": "Keeper API Javascript SDK",
"version": "16.0.67",
"version": "16.0.68",
"browser": "dist/index.es.js",
"main": "dist/index.cjs.js",
"types": "dist/node/index.d.ts",
Expand Down
13 changes: 5 additions & 8 deletions keeperapi/src/node/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,11 @@ export const nodePlatform: Platform = class {
}

static privateDecrypt(data: Uint8Array, key: Uint8Array): Uint8Array {
return crypto.privateDecrypt({
key: crypto.createPrivateKey({
key: Buffer.from(key),
type: 'pkcs1',
format: 'der',
}),
padding: RSA_PKCS1_PADDING
}, data);
const rsaPrivateKey = new NodeRSA(Buffer.from(key), 'pkcs1-private-der', {
encryptionScheme: 'pkcs1'
})
rsaPrivateKey.setOptions({environment: 'browser'}) // use pure implementation, not native (CVE-2023-46809)
return rsaPrivateKey.decrypt(Buffer.from(data))
}

static async privateDecryptEC(data: Uint8Array, privateKey: Uint8Array, publicKey?: Uint8Array, id?: Uint8Array, useHKDF?: boolean): Promise<Uint8Array> {
Expand Down

0 comments on commit de5ed76

Please sign in to comment.