Interface CryptoAlgorithm<I, Asym, G>

WebCrypto based algorithm implementation.

interface CryptoAlgorithm<I, Asym, G> {
    cryptoGenerate: ((params: G, extractable: boolean) => Promise<If<Asym, GeneratedKeyPair<I>, GeneratedSecretKey<I>, never>>);
    importSpki?: ((spki: Uint8Array, der: ElementBuffer) => Promise<CryptoAlgorithm.PublicKey<I>>);
    keyUsages: If<Asym, Record<"private" | "public", readonly KeyUsage[]>, Record<"secret", readonly KeyUsage[]>, {}>;
    uuid: string;
}

Type Parameters

  • I = any

    Algorithm-specific per-key information.

  • Asym extends boolean = any

    Whether the algorithm is asymmetric.

  • G = any

    Key generation parameters.

Hierarchy (view full)

Properties

cryptoGenerate: ((params: G, extractable: boolean) => Promise<If<Asym, GeneratedKeyPair<I>, GeneratedSecretKey<I>, never>>)

Generate key pair (for asymmetric algorithm) or secret key (for symmetric algorithm).

Type declaration

Some algorithms allow importing an existing key pair from a serialization format such as PKCS#8 or JWK. This could be supported by passing the serialized key as part of params, and then importing instead of generating in this method.

importSpki?: ((spki: Uint8Array, der: ElementBuffer) => Promise<CryptoAlgorithm.PublicKey<I>>)

Import public key from SubjectPublicKeyInfo.

This should only appear on asymmetric algorithm.

keyUsages: If<Asym, Record<"private" | "public", readonly KeyUsage[]>, Record<"secret", readonly KeyUsage[]>, {}>

WebCrypto KeyUsages for generated keys. These are specified separately for private/public/secret keys.

uuid: string

Identifies an algorithm in storage.

This should be changed when the serialization format changes.