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