2021-02-04 19:51:19 +00:00
|
|
|
import * as process from "process";
|
2019-01-25 10:43:13 +00:00
|
|
|
import * as core from "webcrypto-core";
|
|
|
|
import {
|
2019-10-12 07:33:10 +00:00
|
|
|
AesCbcProvider, AesCmacProvider, AesCtrProvider, AesEcbProvider, AesGcmProvider, AesKwProvider,
|
|
|
|
DesCbcProvider,
|
2019-08-20 09:21:56 +00:00
|
|
|
DesEde3CbcProvider, EcdhProvider,
|
|
|
|
EcdsaProvider, HkdfProvider,
|
2021-02-04 19:51:19 +00:00
|
|
|
EdDsaProvider,
|
|
|
|
EcdhEsProvider,
|
2019-08-20 09:21:56 +00:00
|
|
|
HmacProvider,
|
2019-03-02 20:57:59 +00:00
|
|
|
Pbkdf2Provider,
|
2019-08-26 20:41:57 +00:00
|
|
|
RsaEsProvider, RsaOaepProvider, RsaPssProvider, RsaSsaProvider,
|
2019-01-25 10:43:13 +00:00
|
|
|
Sha1Provider, Sha256Provider, Sha384Provider, Sha512Provider,
|
|
|
|
} from "./mechs";
|
|
|
|
|
|
|
|
export class SubtleCrypto extends core.SubtleCrypto {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
//#region AES
|
|
|
|
this.providers.set(new AesCbcProvider());
|
|
|
|
this.providers.set(new AesCtrProvider());
|
|
|
|
this.providers.set(new AesGcmProvider());
|
2019-08-20 09:21:56 +00:00
|
|
|
this.providers.set(new AesCmacProvider());
|
2019-03-02 04:40:35 +00:00
|
|
|
this.providers.set(new AesKwProvider());
|
2019-10-12 07:33:10 +00:00
|
|
|
this.providers.set(new AesEcbProvider());
|
2019-01-25 10:43:13 +00:00
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region DES
|
|
|
|
this.providers.set(new DesCbcProvider());
|
|
|
|
this.providers.set(new DesEde3CbcProvider());
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region RSA
|
|
|
|
this.providers.set(new RsaSsaProvider());
|
|
|
|
this.providers.set(new RsaPssProvider());
|
2019-05-22 18:26:25 +00:00
|
|
|
this.providers.set(new RsaOaepProvider());
|
2019-08-26 20:41:57 +00:00
|
|
|
this.providers.set(new RsaEsProvider());
|
2019-01-25 10:43:13 +00:00
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region EC
|
|
|
|
this.providers.set(new EcdsaProvider());
|
|
|
|
this.providers.set(new EcdhProvider());
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region SHA
|
|
|
|
this.providers.set(new Sha1Provider());
|
|
|
|
this.providers.set(new Sha256Provider());
|
|
|
|
this.providers.set(new Sha384Provider());
|
|
|
|
this.providers.set(new Sha512Provider());
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region PBKDF
|
|
|
|
this.providers.set(new Pbkdf2Provider());
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region HMAC
|
|
|
|
this.providers.set(new HmacProvider());
|
|
|
|
//#endregion
|
2019-03-02 20:06:33 +00:00
|
|
|
|
|
|
|
//#region HKDF
|
|
|
|
this.providers.set(new HkdfProvider());
|
|
|
|
//#endregion
|
2021-02-04 19:51:19 +00:00
|
|
|
|
|
|
|
const nodeMajorVersion = /^v(\d+)/.exec(process.version)?.[1];
|
|
|
|
if (nodeMajorVersion && parseInt(nodeMajorVersion, 10) >= 14) {
|
|
|
|
//#region EdDSA
|
|
|
|
this.providers.set(new EdDsaProvider());
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region ECDH-ES
|
|
|
|
this.providers.set(new EcdhEsProvider());
|
|
|
|
//#endregion
|
|
|
|
}
|
2019-01-25 10:43:13 +00:00
|
|
|
}
|
|
|
|
}
|