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 core from "webcrypto-core";
import { Crypto } from "../../crypto";
import { CryptoKey } from "../../key";
import { AesCrypto } from "./crypto";
export class AesCbcProvider extends core.AesCbcProvider {
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,
keyUsages);
return key;
import * as core from "webcrypto-core";
import { AesCrypto } from "./crypto";
import { AesCryptoKey } from "./key";
export class AesCbcProvider extends core.AesCbcProvider {
public async onGenerateKey(algorithm: AesKeyGenParams, extractable: boolean, keyUsages: KeyUsage[]): Promise {
const key = await AesCrypto.generateKey(
{
name: this.name,
length: algorithm.length,
},
extractable,
keyUsages);
return key;
}
public async onEncrypt(algorithm: Algorithm, key: AesCryptoKey, data: ArrayBuffer): Promise {
return AesCrypto.encrypt(algorithm, key, new Uint8Array(data));
}
import * as core from "webcrypto-core";
import { AesCrypto } from "./crypto";
import { AesCryptoKey } from "./key";
export class AesCbcProvider extends core.AesCbcProvider {
public async onGenerateKey(algorithm: AesKeyGenParams, extractable: boolean, keyUsages: KeyUsage[]): Promise {
return AesCrypto.generateKey(algorithm, extractable, keyUsages);
}
public async onEncrypt(algorithm: AesCbcParams, key: AesCryptoKey, data: ArrayBuffer): Promise {
return AesCrypto.encrypt(algorithm, key, data);
}
public async onDecrypt(algorithm: AesCbcParams, key: AesCryptoKey, data: ArrayBuffer): Promise {
return AesCrypto.decrypt(algorithm, key, data);
}
public async onExportKey(format: KeyFormat, key: AesCryptoKey): Promise {
return AesCrypto.exportKey(format, key);
}