How to use the webcrypto-core.EcdsaProvider 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 / ec / ec_dsa.ts View on Github external
res += char.length % 2 ? "0" + char : char;
  }

  // BN padding
  if (padded) {
    let len = buffer.length;
    len = len > 32 ? len > 48 ? 66 : 48 : 32;
    if ((res.length / 2) < len) {
      res = new Array(len * 2 - res.length + 1).join("0") + res;
    }
  }

  return res;
}

export class EcdsaProvider extends core.EcdsaProvider {

  public async onGenerateKey(algorithm: EcKeyGenParams, extractable: boolean, keyUsages: KeyUsage[]): Promise {
    return EcCrypto.generateKey(algorithm, extractable, keyUsages);
  }

  public async onExportKey(format: KeyFormat, key: EcCryptoKey): Promise {
    return EcCrypto.exportKey(format, key);
  }

  public async onImportKey(format: KeyFormat, keyData: ArrayBuffer | JsonWebKey, algorithm: EcKeyImportParams, extractable: boolean, keyUsages: KeyUsage[]): Promise {
    return EcCrypto.importKey(format, keyData, algorithm, extractable, keyUsages);
  }

  public async onSign(algorithm: EcdsaParams, key: EcCryptoKey, data: ArrayBuffer): Promise {
    EcCrypto.checkLib();
github PeculiarVentures / webcrypto / src / mechs / ec / ec_dsa.ts View on Github external
import * as core from "webcrypto-core";
import { CryptoKey } from "../../keys";
import { EcCrypto } from "./crypto";
import { EcPrivateKey } from "./private_key";
import { EcPublicKey } from "./public_key";

export class EcdsaProvider extends core.EcdsaProvider {

  public namedCurves = ["P-256", "P-384", "P-521", "K-256"];

  public async onGenerateKey(algorithm: EcKeyGenParams, extractable: boolean, keyUsages: KeyUsage[]): Promise {
    const key = await EcCrypto.generateKey(
      {
        ...algorithm,
        name: this.name,
      },
      extractable,
      keyUsages);

    return key;
  }

  public async onSign(algorithm: EcdsaParams, key: EcPrivateKey, data: ArrayBuffer): Promise {
github PeculiarVentures / node-webcrypto-p11 / src / mechs / ec / ec_dsa.ts View on Github external
import * as graphene from "graphene-pk11";
import * as core from "webcrypto-core";
import { Crypto } from "../../crypto";
import { CryptoKey } from "../../key";
import { EcCrypto } from "./crypto";
import { EcCryptoKey } from "./key";

export class EcdsaProvider extends core.EcdsaProvider {

  public namedCurves = ["P-256", "P-384", "P-521", "K-256"];

  constructor(private crypto: Crypto) {
    super();
  }

  public async onGenerateKey(algorithm: EcKeyGenParams, extractable: boolean, keyUsages: KeyUsage[]): Promise {
    const key = await EcCrypto.generateKey(
      this.crypto.session,
      {
        ...algorithm,
        name: this.name,
      },
      extractable,
      keyUsages);