Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as asmCrypto from "asmcrypto.js";
import { Convert } from "pvtsutils";
import * as core from "webcrypto-core";
import { Crypto } from "../../crypto";
import { RsaCrypto } from "./crypto";
import { RsaCryptoKey } from "./key";
export type RsaPkcs1Params = Algorithm;
export type RsaPkcs1SignParams = core.HashedAlgorithm;
export class RsaEsProvider extends core.ProviderCrypto {
public name = "RSAES-PKCS1-v1_5";
public usages = {
publicKey: ["encrypt", "wrapKey"] as core.KeyUsages,
privateKey: ["decrypt", "unwrapKey"] as core.KeyUsages,
};
public hashAlgorithms = ["SHA-1", "SHA-256", "SHA-384", "SHA-512"];
public async onGenerateKey(algorithm: RsaKeyGenParams, extractable: boolean, keyUsages: KeyUsage[]): Promise {
return RsaCrypto.generateKey(algorithm, extractable, keyUsages);
}
public checkGenerateKeyParams(algorithm: RsaKeyGenParams) {
// public exponent
this.checkRequiredProperty(algorithm, "publicExponent");
if (!(algorithm.publicExponent && algorithm.publicExponent instanceof Uint8Array)) {
import * as core from "webcrypto-core";
import { Crypto } from "../../crypto";
import { ShaCrypto } from "./crypto";
export class Sha1Provider extends core.ProviderCrypto {
public name = "SHA-1";
public usages: KeyUsage[] = [];
constructor(public crypto: Crypto) {
super();
}
public async onDigest(algorithm: Algorithm, data: ArrayBuffer): Promise {
return ShaCrypto.digest(this.crypto.session, algorithm, data);
}
}
import * as core from "webcrypto-core";
import { Crypto } from "../../crypto";
import { CryptoKey } from "../../key";
import { AesCrypto } from "./crypto";
export class AesEcbProvider extends core.ProviderCrypto {
public name = "AES-ECB";
public usages: KeyUsage[] = ["encrypt", "decrypt", "wrapKey", "unwrapKey"];
constructor(public crypto: Crypto) {
super();
}
public async onGenerateKey(algorithm: AesKeyGenParams, extractable: boolean, keyUsages: KeyUsage[]): Promise {
const key = await AesCrypto.generateKey(
this.crypto.session,
{
name: this.name,
length: algorithm.length,
},
extractable,