Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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]}'`);
}
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;
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 })