Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CryptoEngine

Default cryptographic engine for Web Cryptography API

Hierarchy

Index

Constructors

Properties

crypto: Crypto
name: string
subtle: SubtleCrypto

Methods

  • convert(inputFormat: KeyFormat, outputFormat: KeyFormat, keyData: ArrayBuffer | JsonWebKey, algorithm: Algorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise<ArrayBuffer | JsonWebKey>
  • Convert WebCrypto keys between different export formats

    Parameters

    • inputFormat: KeyFormat
    • outputFormat: KeyFormat
    • keyData: ArrayBuffer | JsonWebKey
    • algorithm: Algorithm
    • extractable: boolean
    • keyUsages: KeyUsage[]

    Returns Promise<ArrayBuffer | JsonWebKey>

  • decrypt(algorithm: AesCbcParams | AesCtrParams | AesGcmParams | AlgorithmIdentifier | RsaOaepParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>
  • deriveBits(algorithm: EcdhKeyDeriveParams | AlgorithmIdentifier | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise<ArrayBuffer>
  • deriveKey(algorithm: EcdhKeyDeriveParams | AlgorithmIdentifier | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AesDerivedKeyParams | AlgorithmIdentifier | HkdfParams | HmacImportParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>
  • deriveKey(algorithm: EcdhKeyDeriveParams | AlgorithmIdentifier | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AesDerivedKeyParams | AlgorithmIdentifier | HkdfParams | HmacImportParams | Pbkdf2Params, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKey>
  • Parameters

    • algorithm: EcdhKeyDeriveParams | AlgorithmIdentifier | HkdfParams | Pbkdf2Params
    • baseKey: CryptoKey
    • derivedKeyType: AesDerivedKeyParams | AlgorithmIdentifier | HkdfParams | HmacImportParams | Pbkdf2Params
    • extractable: boolean
    • keyUsages: KeyUsage[]

    Returns Promise<CryptoKey>

  • Parameters

    • algorithm: EcdhKeyDeriveParams | AlgorithmIdentifier | HkdfParams | Pbkdf2Params
    • baseKey: CryptoKey
    • derivedKeyType: AesDerivedKeyParams | AlgorithmIdentifier | HkdfParams | HmacImportParams | Pbkdf2Params
    • extractable: boolean
    • keyUsages: Iterable<KeyUsage>

    Returns Promise<CryptoKey>

  • digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<ArrayBuffer>
  • encrypt(algorithm: AesCbcParams | AesCtrParams | AesGcmParams | AlgorithmIdentifier | RsaOaepParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>
  • exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>
  • exportKey(format: "raw" | "pkcs8" | "spki", key: CryptoKey): Promise<ArrayBuffer>
  • exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>
  • generateKey(algorithm: EcKeyGenParams | RsaHashedKeyGenParams, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKeyPair>
  • generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>
  • generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKeyPair | CryptoKey>
  • getAlgorithmByOID<T>(oid: string, safety?: boolean, target?: string): object | T
  • getAlgorithmByOID<T>(oid: string, safety: true, target?: string): T
  • Gets WebCrypto algorithm by wel-known OID

    Type Parameters

    • T extends Algorithm = Algorithm

    Parameters

    • oid: string

      algorithm identifier

    • Optional safety: boolean

      if true throws exception on unknown algorithm identifier

    • Optional target: string

      name of the target

    Returns object | T

    Returns WebCrypto algorithm or an empty object

  • Gets WebCrypto algorithm by wel-known OID

    throws

    Throws {@link Error} exception if unknown algorithm identifier

    Type Parameters

    • T extends Algorithm = Algorithm

    Parameters

    • oid: string

      algorithm identifier

    • safety: true

      if true throws exception on unknown algorithm identifier

    • Optional target: string

      name of the target

    Returns T

    Returns WebCrypto algorithm

  • getOIDByAlgorithm(algorithm: Algorithm, safety?: boolean, target?: string): string
  • getRandomValues<T>(array: T): T
  • importKey(format: KeyFormat, keyData: BufferSource | JsonWebKey, algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>
  • sign(algorithm: EcdsaParams | AlgorithmIdentifier | RsaPssParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>
  • unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCbcParams | AesCtrParams | AesGcmParams | AlgorithmIdentifier | RsaOaepParams, unwrappedKeyAlgorithm: AesKeyAlgorithm | EcKeyImportParams | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>
  • unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AesCbcParams | AesCtrParams | AesGcmParams | AlgorithmIdentifier | RsaOaepParams, unwrappedKeyAlgorithm: AesKeyAlgorithm | EcKeyImportParams | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKey>
  • Parameters

    • format: KeyFormat
    • wrappedKey: BufferSource
    • unwrappingKey: CryptoKey
    • unwrapAlgorithm: AesCbcParams | AesCtrParams | AesGcmParams | AlgorithmIdentifier | RsaOaepParams
    • unwrappedKeyAlgorithm: AesKeyAlgorithm | EcKeyImportParams | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams
    • extractable: boolean
    • keyUsages: KeyUsage[]

    Returns Promise<CryptoKey>

  • Parameters

    • format: KeyFormat
    • wrappedKey: BufferSource
    • unwrappingKey: CryptoKey
    • unwrapAlgorithm: AesCbcParams | AesCtrParams | AesGcmParams | AlgorithmIdentifier | RsaOaepParams
    • unwrappedKeyAlgorithm: AesKeyAlgorithm | EcKeyImportParams | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams
    • extractable: boolean
    • keyUsages: Iterable<KeyUsage>

    Returns Promise<CryptoKey>

  • verify(algorithm: EcdsaParams | AlgorithmIdentifier | RsaPssParams, key: CryptoKey, signature: BufferSource, data: BufferSource): Promise<boolean>
  • verifyWithPublicKey(data: BufferSource, signature: OctetString | BitString, publicKeyInfo: PublicKeyInfo, signatureAlgorithm: AlgorithmIdentifier, shaAlgorithm?: string): Promise<boolean>
  • wrapKey(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: AesCbcParams | AesCtrParams | AesGcmParams | AlgorithmIdentifier | RsaOaepParams): Promise<ArrayBuffer>

Generated using TypeDoc