How to use the webcrypto-core.CryptoKey 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 / node-webcrypto-p11 / src / key.ts View on Github external
// Core
import * as core from "webcrypto-core";

import { ITemplate, Key, ObjectClass, PrivateKey, PublicKey, SecretKey } from "graphene-pk11";

export interface ITemplatePair {
  privateKey: ITemplate;
  publicKey: ITemplate;
}

export class CryptoKey extends core.CryptoKey {

  public static getID(p11Key: Key) {
    let name: string;
    switch (p11Key.class) {
      case ObjectClass.PRIVATE_KEY:
        name = "private";
        break;
      case ObjectClass.PUBLIC_KEY:
        name = "public";
        break;
      case ObjectClass.SECRET_KEY:
        name = "secret";
        break;
      default:
        throw new Error(`Unsupported Object type '${ObjectClass[p11Key.class]}'`);
    }
github PeculiarVentures / webcrypto-liner / src / key.ts View on Github external
import * as core from "webcrypto-core";

export class CryptoKey extends core.CryptoKey {
  public algorithm: KeyAlgorithm;
  constructor(
    algorithm: KeyAlgorithm,
    public extractable: boolean,
    public type: KeyType,
    public usages: KeyUsage[],
  ) {
    super();
    this.algorithm = { ...algorithm };
  }
}

// export class CryptoKey implements NativeCryptoKey {
//     public key: any;
//     public algorithm: KeyAlgorithm;
//     public extractable: boolean;
github PeculiarVentures / webcrypto / src / keys / key.ts View on Github external
import { JsonProp, JsonPropTypes } from "@peculiar/json-schema";
import * as core from "webcrypto-core";

export class CryptoKey extends core.CryptoKey {
  public data: Buffer = Buffer.alloc(0);

  public algorithm: KeyAlgorithm = { name: "" };

  @JsonProp({ name: "ext", type: JsonPropTypes.Boolean, optional: true })
  public extractable: boolean = false;

  public type: KeyType = "secret";

  @JsonProp({ name: "key_ops", type: JsonPropTypes.String, repeated: true, optional: true })
  public usages: KeyUsage[] = [];

  @JsonProp({ type: JsonPropTypes.String })
  protected kty: string = "oct";

  @JsonProp({ type: JsonPropTypes.String })