-
Notifications
You must be signed in to change notification settings - Fork 2
/
PrivateKey.ts
28 lines (21 loc) · 914 Bytes
/
PrivateKey.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// tslint:disable:max-classes-per-file
import { CryptoKey, KeyAlgorithm, KeyUsages, ProviderCrypto } from 'webcrypto-core';
import { HashingAlgorithm } from '../algorithms';
import { CryptoKeyWithProvider } from './CryptoKeyWithProvider';
export class PrivateKey extends CryptoKey implements CryptoKeyWithProvider {
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;
constructor(hashingAlgorithm: HashingAlgorithm, provider: ProviderCrypto) {
const algorithm = { name: 'RSA-PSS', hash: { name: hashingAlgorithm } };
super(algorithm, provider);
}
}