-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(PrivateKey): Support public key export from KMS-backed providers (#…
- Loading branch information
Showing
10 changed files
with
182 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,27 @@ | ||
import { CryptoKey, ProviderCrypto } from 'webcrypto-core'; | ||
// tslint:disable:max-classes-per-file | ||
|
||
import { CryptoKey, KeyAlgorithm, KeyUsages, ProviderCrypto } from 'webcrypto-core'; | ||
|
||
import { HashingAlgorithm } from './algorithms'; | ||
|
||
export class PrivateKey extends CryptoKey { | ||
constructor(public readonly provider: ProviderCrypto) { | ||
public override readonly extractable = true; // The **public** key is extractable as SPKI | ||
|
||
public override readonly type = 'private' as KeyType; | ||
|
||
constructor( | ||
public override readonly algorithm: KeyAlgorithm, | ||
public readonly provider: ProviderCrypto, | ||
) { | ||
super(); | ||
} | ||
} | ||
|
||
export class RsaPssPrivateKey extends PrivateKey { | ||
public override readonly usages = ['sign'] as KeyUsages; | ||
|
||
this.type = 'private'; | ||
constructor(hashingAlgorithm: HashingAlgorithm, provider: ProviderCrypto) { | ||
const algorithm = { name: 'RSA-PSS', hash: { name: hashingAlgorithm } }; | ||
super(algorithm, provider); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
import { AesKwProvider } from 'webcrypto-core'; | ||
/* tslint:disable:max-classes-per-file */ | ||
|
||
import { AesKwProvider, RsaPssProvider } from 'webcrypto-core'; | ||
|
||
export class MockAesKwProvider extends AesKwProvider { | ||
public readonly onGenerateKey = jest.fn(); | ||
public readonly onExportKey = jest.fn(); | ||
public readonly onImportKey = jest.fn(); | ||
public override readonly onGenerateKey = jest.fn(); | ||
public override readonly onExportKey = jest.fn(); | ||
public override readonly onImportKey = jest.fn(); | ||
} | ||
|
||
export class MockRsaPssProvider extends RsaPssProvider { | ||
public override readonly onGenerateKey = jest.fn(); | ||
public override readonly onSign = jest.fn(); | ||
public override readonly onVerify = jest.fn(); | ||
public override readonly onExportKey = jest.fn(); | ||
public override readonly onImportKey = jest.fn(); | ||
} |
Oops, something went wrong.