Skip to main content

AbstractCryptoEngine

Extended by​

Implements​

Constructors​

Constructor​

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>

The decrypt() method of the SubtleCrypto interface decrypts some encrypted data. It takes as arguments a key to decrypt with, some optional extra parameters, and the data to decrypt (also known as "ciphertext"). It returns a Promise which will be fulfilled with the decrypted data (also known as "plaintext").

MDN Reference

Parameters​

algorithm​

AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams

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>

The deriveBits() method of the SubtleCrypto interface can be used to derive an array of bits from a base key.

MDN Reference

Parameters​

algorithm​

AlgorithmIdentifier | Pbkdf2Params | EcdhKeyDeriveParams | HkdfParams

baseKey​

CryptoKey

length​

number

Returns​

Promise<ArrayBuffer>

Implementation of​

ICryptoEngine.deriveBits


deriveKey()​

Call Signature​

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

The deriveKey() method of the SubtleCrypto interface can be used to derive a secret key from a master key.

MDN Reference

Parameters​
algorithm​

AlgorithmIdentifier | Pbkdf2Params | EcdhKeyDeriveParams | HkdfParams

baseKey​

CryptoKey

derivedKeyType​

AlgorithmIdentifier | Pbkdf2Params | HkdfParams | AesDerivedKeyParams | HmacImportParams

extractable​

boolean

keyUsages​

KeyUsage[]

Returns​

Promise<CryptoKey>

Implementation of​

ICryptoEngine.deriveKey

Call Signature​

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

The deriveKey() method of the SubtleCrypto interface can be used to derive a secret key from a master key.

MDN Reference

Parameters​
algorithm​

AlgorithmIdentifier | Pbkdf2Params | EcdhKeyDeriveParams | HkdfParams

baseKey​

CryptoKey

derivedKeyType​

AlgorithmIdentifier | Pbkdf2Params | HkdfParams | AesDerivedKeyParams | HmacImportParams

extractable​

boolean

keyUsages​

Iterable<KeyUsage>

Returns​

Promise<CryptoKey>

Implementation of​

ICryptoEngine.deriveKey


digest()​

digest(algorithm, data): Promise<ArrayBuffer>

The digest() method of the SubtleCrypto interface generates a digest of the given data, using the specified hash function. A digest is a short fixed-length value derived from some variable-length input. Cryptographic digests should exhibit collision-resistance, meaning that it's hard to come up with two different inputs that have the same digest value.

MDN Reference

Parameters​

algorithm​

AlgorithmIdentifier

data​

BufferSource

Returns​

Promise<ArrayBuffer>

Implementation of​

ICryptoEngine.digest


encrypt()​

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

The encrypt() method of the SubtleCrypto interface encrypts data.

MDN Reference

Parameters​

algorithm​

AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams

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()​

Call Signature​

exportKey(format, key): Promise<JsonWebKey>

The exportKey() method of the SubtleCrypto interface exports a key: that is, it takes as input a CryptoKey object and gives you the key in an external, portable format.

MDN Reference

Parameters​
format​

"jwk"

key​

CryptoKey

Returns​

Promise<JsonWebKey>

Implementation of​

ICryptoEngine.exportKey

Call Signature​

exportKey(format, key): Promise<ArrayBuffer>

Parameters​
format​

"pkcs8" | "raw" | "spki"

key​

CryptoKey

Returns​

Promise<ArrayBuffer>

Implementation of​

ICryptoEngine.exportKey


generateKey()​

Call Signature​

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

The generateKey() method of the SubtleCrypto interface is used to generate a new key (for symmetric algorithms) or key pair (for public-key algorithms).

MDN Reference

Parameters​
algorithm​

"Ed25519"

extractable​

boolean

keyUsages​

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

Returns​

Promise<CryptoKeyPair>

Implementation of​

ICryptoEngine.generateKey

Call Signature​

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

Parameters​
algorithm​

"X25519" | { name: "X25519"; }

extractable​

boolean

keyUsages​

readonly ("deriveBits" | "deriveKey")[]

Returns​

Promise<CryptoKeyPair>

Implementation of​

ICryptoEngine.generateKey

Call Signature​

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

Parameters​
algorithm​

RsaHashedKeyGenParams | EcKeyGenParams

extractable​

boolean

keyUsages​

KeyUsage[]

Returns​

Promise<CryptoKeyPair>

Implementation of​

ICryptoEngine.generateKey

Call Signature​

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

Parameters​
algorithm​

AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params

extractable​

boolean

keyUsages​

KeyUsage[]

Returns​

Promise<CryptoKey>

Implementation of​

ICryptoEngine.generateKey

Call Signature​

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

Parameters​
algorithm​

AlgorithmIdentifier

extractable​

boolean

keyUsages​

KeyUsage[]

Returns​

Promise<CryptoKey | CryptoKeyPair>

Implementation of​

ICryptoEngine.generateKey


getAlgorithmByOID()​

Call Signature​

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

Gets WebCrypto algorithm by wel-known OID

Type Parameters​
T​

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

Call Signature​

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

Gets WebCrypto algorithm by wel-known OID

Type Parameters​
T​

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

Throws​

Throws Error exception if unknown algorithm identifier

Implementation of​

ICryptoEngine.getAlgorithmByOID

Call Signature​

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

Parameters​
oid​

any

safety?​

any

target?​

any

Returns​

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​

T extends ArrayBufferView<ArrayBufferLike> | null

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()​

Call Signature​

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

The importKey() method of the SubtleCrypto interface imports a key: that is, it takes as input a key in an external, portable format and gives you a CryptoKey object that you can use in the Web Crypto API.

MDN Reference

Parameters​
format​

"jwk"

keyData​

JsonWebKey

algorithm​

AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm

extractable​

boolean

keyUsages​

KeyUsage[]

Returns​

Promise<CryptoKey>

Implementation of​

ICryptoEngine.importKey

Call Signature​

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

Parameters​
format​

"pkcs8" | "raw" | "spki"

keyData​

BufferSource

algorithm​

AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm

extractable​

boolean

keyUsages​

KeyUsage[]

Returns​

Promise<CryptoKey>

Implementation of​

ICryptoEngine.importKey

Call Signature​

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

The importKey() method of the SubtleCrypto interface imports a key: that is, it takes as input a key in an external, portable format and gives you a CryptoKey object that you can use in the Web Crypto API.

MDN Reference

Parameters​
format​

"jwk"

keyData​

JsonWebKey

algorithm​

AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm

extractable​

boolean

keyUsages​

KeyUsage[]

Returns​

Promise<CryptoKey>

Implementation of​

ICryptoEngine.importKey

Call Signature​

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

Parameters​
format​

"pkcs8" | "raw" | "spki"

keyData​

BufferSource

algorithm​

AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm

extractable​

boolean

keyUsages​

Iterable<KeyUsage>

Returns​

Promise<CryptoKey>

Implementation of​

ICryptoEngine.importKey


sign()​

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

The sign() method of the SubtleCrypto interface generates a digital signature.

MDN Reference

Parameters​

algorithm​

AlgorithmIdentifier | RsaPssParams | EcdsaParams

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()​

Call Signature​

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

The unwrapKey() method of the SubtleCrypto interface "unwraps" a key. This means that it takes as its input a key that has been exported and then encrypted (also called "wrapped"). It decrypts the key and then imports it, returning a CryptoKey object that can be used in the Web Crypto API.

MDN Reference

Parameters​
format​

KeyFormat

wrappedKey​

BufferSource

unwrappingKey​

CryptoKey

unwrapAlgorithm​

AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams

unwrappedKeyAlgorithm​

AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm

extractable​

boolean

keyUsages​

KeyUsage[]

Returns​

Promise<CryptoKey>

Implementation of​

ICryptoEngine.unwrapKey

Call Signature​

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

The unwrapKey() method of the SubtleCrypto interface "unwraps" a key. This means that it takes as its input a key that has been exported and then encrypted (also called "wrapped"). It decrypts the key and then imports it, returning a CryptoKey object that can be used in the Web Crypto API.

MDN Reference

Parameters​
format​

KeyFormat

wrappedKey​

BufferSource

unwrappingKey​

CryptoKey

unwrapAlgorithm​

AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams

unwrappedKeyAlgorithm​

AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm

extractable​

boolean

keyUsages​

Iterable<KeyUsage>

Returns​

Promise<CryptoKey>

Implementation of​

ICryptoEngine.unwrapKey


verify()​

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

The verify() method of the SubtleCrypto interface verifies a digital signature.

MDN Reference

Parameters​

algorithm​

AlgorithmIdentifier | RsaPssParams | EcdsaParams

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​

BitString | OctetString

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>

The wrapKey() method of the SubtleCrypto interface "wraps" a key. This means that it exports the key in an external, portable format, then encrypts the exported key. Wrapping a key helps protect it in untrusted environments, such as inside an otherwise unprotected data store or in transmission over an unprotected network.

MDN Reference

Parameters​

format​

KeyFormat

key​

CryptoKey

wrappingKey​

CryptoKey

wrapAlgorithm​

AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams

Returns​

Promise<ArrayBuffer>

Implementation of​

ICryptoEngine.wrapKey