Skip to content

Commit 9329a20

Browse files
committed
Add support for PSS RSA family of Signers
1 parent 2642e5f commit 9329a20

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "strontium",
3-
"version": "2.6.5",
3+
"version": "2.6.6",
44
"description": "Strontium is a TypeScript toolkit for High Performance API servers built for Production not Projects.",
55
"main": "lib/src/index.js",
66
"types": "lib/src/index.d.ts",
@@ -68,7 +68,7 @@
6868
"base64url": "^3.0.0",
6969
"fastify": "^1.12.1",
7070
"inversify": "^5.0.1",
71-
"jwa": "^1.1.6",
71+
"jwa": "^1.2.0",
7272
"lodash": "^4.17.11",
7373
"mysql": "^2.16.0",
7474
"pg": "^7.5.0",

src/cryptography/drivers/node/RSASHA256Signer.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,23 @@ import { InvalidSignatureError } from "../../../errors/InvalidSignatureError"
55
// @ts-ignore
66
import * as JWA from "jwa"
77

8-
const RS256 = JWA("RS256")
9-
108
export class RSASHA256Signer extends AsymmetricSigner {
9+
private signer = JWA(this.algorithm)
10+
11+
constructor(
12+
public publicKey: Buffer,
13+
public privateKey?: Buffer,
14+
private algorithm: "RS256" | "PS256" = "RS256"
15+
) {
16+
super(publicKey, privateKey)
17+
}
18+
1119
public async sign(plaintext: Buffer): Promise<Buffer> {
12-
return RS256.sign(plaintext, this.privateKey)
20+
return this.signer.sign(plaintext, this.privateKey)
1321
}
1422

1523
public async verify(plaintext: Buffer, signature: Buffer): Promise<Buffer> {
16-
let isValid = await RS256.verify(
24+
let isValid = await this.signer.verify(
1725
plaintext,
1826
signature.toString(),
1927
this.publicKey

0 commit comments

Comments
 (0)