How to use the webcrypto-core.ProviderCrypto function in webcrypto-core

To help you get started, we’ve selected a few webcrypto-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PeculiarVentures / webcrypto-liner / src / mechs / rsa / rsa_es.ts View on Github external
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)) {
github PeculiarVentures / node-webcrypto-p11 / src / mechs / sha / sha_1.ts View on Github external
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);
  }

}
github PeculiarVentures / node-webcrypto-p11 / src / mechs / aes / aes_ecb.ts View on Github external
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,