Skip to main content

abstract AbstractCryptoEngine

Extended by

Implements

Constructors

new AbstractCryptoEngine()

new AbstractCryptoEngine(parameters): AbstractCryptoEngine

Constructor for CryptoEngine class

Parameters

parameters: CryptoEngineParameters

Returns

AbstractCryptoEngine

Properties

crypto

crypto: Crypto

Implementation of

ICryptoEngine.crypto


name

name: string

Implementation of

ICryptoEngine.name


subtle

subtle: SubtleCrypto

Implementation of

ICryptoEngine.subtle

Methods

decrypt()

decrypt(algorithm, key, data): Promise<ArrayBuffer>

MDN Reference

Parameters

algorithm: AesCbcParams | AesCtrParams | AesGcmParams | AlgorithmIdentifier | RsaOaepParams

key: CryptoKey

data: BufferSource

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.decrypt


decryptEncryptedContentInfo()

abstract decryptEncryptedContentInfo(parameters): Promise<ArrayBuffer>

Decrypt data stored in "EncryptedContentInfo" object using parameters

Parameters

parameters: CryptoEngineDecryptParams

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.decryptEncryptedContentInfo


deriveBits()

deriveBits(algorithm, baseKey, length): Promise<ArrayBuffer>

MDN Reference

Parameters

algorithm: EcdhKeyDeriveParams | AlgorithmIdentifier | HkdfParams | Pbkdf2Params

baseKey: CryptoKey

length: number

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.deriveBits


deriveKey()

deriveKey(algorithm, baseKey, derivedKeyType, extractable, keyUsages)

deriveKey(algorithm, baseKey, derivedKeyType, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

Parameters

algorithm: EcdhKeyDeriveParams | AlgorithmIdentifier | HkdfParams | Pbkdf2Params

baseKey: CryptoKey

derivedKeyType: AesDerivedKeyParams | AlgorithmIdentifier | HkdfParams | HmacImportParams | Pbkdf2Params

extractable: boolean

keyUsages: KeyUsage[]

Returns

Promise<CryptoKey>

Implementation of

ICryptoEngine.deriveKey

deriveKey(algorithm, baseKey, derivedKeyType, extractable, keyUsages)

deriveKey(algorithm, baseKey, derivedKeyType, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

Parameters

algorithm: EcdhKeyDeriveParams | AlgorithmIdentifier | HkdfParams | Pbkdf2Params

baseKey: CryptoKey

derivedKeyType: AesDerivedKeyParams | AlgorithmIdentifier | HkdfParams | HmacImportParams | Pbkdf2Params

extractable: boolean

keyUsages: Iterable<KeyUsage>

Returns

Promise<CryptoKey>

Implementation of

ICryptoEngine.deriveKey


digest()

digest(algorithm, data): Promise<ArrayBuffer>

MDN Reference

Parameters

algorithm: AlgorithmIdentifier

data: BufferSource

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.digest


encrypt()

encrypt(algorithm, key, data): Promise<ArrayBuffer>

MDN Reference

Parameters

algorithm: AesCbcParams | AesCtrParams | AesGcmParams | AlgorithmIdentifier | RsaOaepParams

key: CryptoKey

data: BufferSource

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.encrypt


encryptEncryptedContentInfo()

abstract encryptEncryptedContentInfo(parameters): Promise<EncryptedContentInfo>

Specialized function encrypting "EncryptedContentInfo" object using parameters

Parameters

parameters: CryptoEngineEncryptParams

Returns

Promise<EncryptedContentInfo>

Implementation of

ICryptoEngine.encryptEncryptedContentInfo


exportKey()

exportKey(format, key)

exportKey(format, key): Promise<JsonWebKey>

MDN Reference

Parameters

format: "jwk"

key: CryptoKey

Returns

Promise<JsonWebKey>

Implementation of

ICryptoEngine.exportKey

exportKey(format, key)

exportKey(format, key): Promise<ArrayBuffer>

MDN Reference

Parameters

format: "raw" | "pkcs8" | "spki"

key: CryptoKey

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.exportKey


generateKey()

generateKey(algorithm, extractable, keyUsages)

generateKey(algorithm, extractable, keyUsages): Promise<CryptoKeyPair>

MDN Reference

Parameters

algorithm: "Ed25519"

extractable: boolean

keyUsages: readonly ("sign" | "verify")[]

Returns

Promise<CryptoKeyPair>

Implementation of

ICryptoEngine.generateKey

generateKey(algorithm, extractable, keyUsages)

generateKey(algorithm, extractable, keyUsages): Promise<CryptoKeyPair>

MDN Reference

Parameters

algorithm: EcKeyGenParams | RsaHashedKeyGenParams

extractable: boolean

keyUsages: KeyUsage[]

Returns

Promise<CryptoKeyPair>

Implementation of

ICryptoEngine.generateKey

generateKey(algorithm, extractable, keyUsages)

generateKey(algorithm, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

Parameters

algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params

extractable: boolean

keyUsages: KeyUsage[]

Returns

Promise<CryptoKey>

Implementation of

ICryptoEngine.generateKey

generateKey(algorithm, extractable, keyUsages)

generateKey(algorithm, extractable, keyUsages): Promise<CryptoKeyPair | CryptoKey>

MDN Reference

Parameters

algorithm: AlgorithmIdentifier

extractable: boolean

keyUsages: KeyUsage[]

Returns

Promise<CryptoKeyPair | CryptoKey>

Implementation of

ICryptoEngine.generateKey


getAlgorithmByOID()

getAlgorithmByOID(oid, safety, target)

abstract getAlgorithmByOID<T>(oid, safety?, target?): object | T

Gets WebCrypto algorithm by wel-known OID

Type Parameters

T extends Algorithm = Algorithm

Parameters

oid: string

algorithm identifier

safety?: boolean

if true throws exception on unknown algorithm identifier

target?: string

name of the target

Returns

object | T

Returns WebCrypto algorithm or an empty object

Implementation of

ICryptoEngine.getAlgorithmByOID

getAlgorithmByOID(oid, safety, target)

abstract getAlgorithmByOID<T>(oid, safety, target?): T

Gets WebCrypto algorithm by wel-known OID

Type Parameters

T extends Algorithm = Algorithm

Parameters

oid: string

algorithm identifier

safety: true

if true throws exception on unknown algorithm identifier

target?: string

name of the target

Returns

T

Returns WebCrypto algorithm or an empty object

Implementation of

ICryptoEngine.getAlgorithmByOID

getAlgorithmByOID(oid, safety, target)

abstract getAlgorithmByOID(oid, safety?, target?): object

Gets WebCrypto algorithm by wel-known OID

Parameters

oid: any

algorithm identifier

safety?: any

if true throws exception on unknown algorithm identifier

target?: any

name of the target

Returns

object

Returns WebCrypto algorithm or an empty object

Implementation of

type.ICryptoEngine.getAlgorithmByOID


getAlgorithmParameters()

abstract getAlgorithmParameters(algorithmName, operation): CryptoEngineAlgorithmParams

Get default algorithm parameters for each kind of operation

Parameters

algorithmName: string

Algorithm name to get common parameters for

operation: CryptoEngineAlgorithmOperation

Kind of operation: "sign", "encrypt", "generateKey", "importKey", "exportKey", "verify"

Returns

CryptoEngineAlgorithmParams

Implementation of

ICryptoEngine.getAlgorithmParameters


getHashAlgorithm()

abstract getHashAlgorithm(signatureAlgorithm): string

Getting hash algorithm by signature algorithm

Parameters

signatureAlgorithm: AlgorithmIdentifier

Signature algorithm

Returns

string

Implementation of

ICryptoEngine.getHashAlgorithm


getOIDByAlgorithm()

abstract getOIDByAlgorithm(algorithm, safety?, target?): string

Get OID for each specific algorithm

Parameters

algorithm: Algorithm

WebCrypto Algorithm

safety?: boolean

If true throws exception on unknown algorithm. Default is false

target?: string

Name of the target

Returns

string

Throws

Throws Error exception if unknown WebCrypto algorithm

Implementation of

ICryptoEngine.getOIDByAlgorithm


getPublicKey()

abstract getPublicKey(publicKeyInfo, signatureAlgorithm, parameters?): Promise<CryptoKey>

Parameters

publicKeyInfo: PublicKeyInfo

signatureAlgorithm: AlgorithmIdentifier

parameters?: CryptoEnginePublicKeyParams

Returns

Promise<CryptoKey>

Implementation of

ICryptoEngine.getPublicKey


getRandomValues()

getRandomValues<T>(array): T

Type Parameters

T extends null | ArrayBufferView

Parameters

array: T

Returns

T

Implementation of

ICryptoEngine.getRandomValues


getSignatureParameters()

abstract getSignatureParameters(privateKey, hashAlgorithm?): Promise<CryptoEngineSignatureParams>

Get signature parameters by analyzing private key algorithm

Parameters

privateKey: CryptoKey

The private key user would like to use

hashAlgorithm?: string

Hash algorithm user would like to use. Default is SHA-1

Returns

Promise<CryptoEngineSignatureParams>

Implementation of

ICryptoEngine.getSignatureParameters


importKey()

importKey(format, keyData, algorithm, extractable, keyUsages)

importKey(format, keyData, algorithm, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

Parameters

format: "jwk"

keyData: JsonWebKey

algorithm: AesKeyAlgorithm | EcKeyImportParams | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams

extractable: boolean

keyUsages: KeyUsage[]

Returns

Promise<CryptoKey>

Implementation of

ICryptoEngine.importKey

importKey(format, keyData, algorithm, extractable, keyUsages)

importKey(format, keyData, algorithm, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

Parameters

format: "raw" | "pkcs8" | "spki"

keyData: BufferSource

algorithm: AesKeyAlgorithm | EcKeyImportParams | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams

extractable: boolean

keyUsages: KeyUsage[]

Returns

Promise<CryptoKey>

Implementation of

ICryptoEngine.importKey

importKey(format, keyData, algorithm, extractable, keyUsages)

importKey(format, keyData, algorithm, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

Parameters

format: "jwk"

keyData: JsonWebKey

algorithm: AesKeyAlgorithm | EcKeyImportParams | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams

extractable: boolean

keyUsages: KeyUsage[]

Returns

Promise<CryptoKey>

Implementation of

ICryptoEngine.importKey

importKey(format, keyData, algorithm, extractable, keyUsages)

importKey(format, keyData, algorithm, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

Parameters

format: "raw" | "pkcs8" | "spki"

keyData: BufferSource

algorithm: AesKeyAlgorithm | EcKeyImportParams | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams

extractable: boolean

keyUsages: Iterable<KeyUsage>

Returns

Promise<CryptoKey>

Implementation of

ICryptoEngine.importKey


sign()

sign(algorithm, key, data): Promise<ArrayBuffer>

MDN Reference

Parameters

algorithm: EcdsaParams | AlgorithmIdentifier | RsaPssParams

key: CryptoKey

data: BufferSource

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.sign


signWithPrivateKey()

abstract signWithPrivateKey(data, privateKey, parameters): Promise<ArrayBuffer>

Sign data with pre-defined private key

Parameters

data: BufferSource

Data to be signed

privateKey: CryptoKey

Private key to use

parameters: CryptoEngineSignWithPrivateKeyParams

Parameters for used algorithm

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.signWithPrivateKey


stampDataWithPassword()

abstract stampDataWithPassword(parameters): Promise<ArrayBuffer>

Stamping (signing) data using algorithm similar to HMAC

Parameters

parameters: CryptoEngineStampDataWithPasswordParams

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.stampDataWithPassword


unwrapKey()

unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)

unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

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>

Implementation of

ICryptoEngine.unwrapKey

unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)

unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

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>

Implementation of

ICryptoEngine.unwrapKey


verify()

verify(algorithm, key, signature, data): Promise<boolean>

MDN Reference

Parameters

algorithm: EcdsaParams | AlgorithmIdentifier | RsaPssParams

key: CryptoKey

signature: BufferSource

data: BufferSource

Returns

Promise<boolean>

Implementation of

ICryptoEngine.verify


verifyDataStampedWithPassword()

abstract verifyDataStampedWithPassword(parameters): Promise<boolean>

Parameters

parameters: CryptoEngineVerifyDataStampedWithPasswordParams

Returns

Promise<boolean>

Implementation of

ICryptoEngine.verifyDataStampedWithPassword


verifyWithPublicKey()

abstract verifyWithPublicKey(data, signature, publicKeyInfo, signatureAlgorithm, shaAlgorithm?): Promise<boolean>

Verify data with the public key

Parameters

data: BufferSource

Data to be verified

signature: OctetString | BitString

Signature value

publicKeyInfo: PublicKeyInfo

Public key information

signatureAlgorithm: AlgorithmIdentifier

Signature algorithm

shaAlgorithm?: string

Hash algorithm

Returns

Promise<boolean>

Implementation of

ICryptoEngine.verifyWithPublicKey


wrapKey()

wrapKey(format, key, wrappingKey, wrapAlgorithm): Promise<ArrayBuffer>

MDN Reference

Parameters

format: KeyFormat

key: CryptoKey

wrappingKey: CryptoKey

wrapAlgorithm: AesCbcParams | AesCtrParams | AesGcmParams | AlgorithmIdentifier | RsaOaepParams

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.wrapKey