Skip to main content

Class: AbstractCryptoEngine

Hierarchy

Implements

Constructors

constructor

new AbstractCryptoEngine(parameters): AbstractCryptoEngine

Constructor for CryptoEngine class

Parameters

NameType
parametersCryptoEngineParameters

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

NameType
algorithmAesCbcParams | AesCtrParams | AesGcmParams | AlgorithmIdentifier | RsaOaepParams
keyCryptoKey
dataBufferSource

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.decrypt


decryptEncryptedContentInfo

decryptEncryptedContentInfo(parameters): Promise<ArrayBuffer>

Decrypt data stored in "EncryptedContentInfo" object using parameters

Parameters

NameType
parametersCryptoEngineDecryptParams

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.decryptEncryptedContentInfo


deriveBits

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

MDN Reference

Parameters

NameType
algorithmEcdhKeyDeriveParams | AlgorithmIdentifier | HkdfParams | Pbkdf2Params
baseKeyCryptoKey
lengthnumber

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.deriveBits


deriveKey

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

MDN Reference

Parameters

NameType
algorithmEcdhKeyDeriveParams | AlgorithmIdentifier | HkdfParams | Pbkdf2Params
baseKeyCryptoKey
derivedKeyTypeAesDerivedKeyParams | AlgorithmIdentifier | HkdfParams | HmacImportParams | Pbkdf2Params
extractableboolean
keyUsagesKeyUsage[]

Returns

Promise<CryptoKey>

Implementation of

ICryptoEngine.deriveKey

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

MDN Reference

Parameters

NameType
algorithmEcdhKeyDeriveParams | AlgorithmIdentifier | HkdfParams | Pbkdf2Params
baseKeyCryptoKey
derivedKeyTypeAesDerivedKeyParams | AlgorithmIdentifier | HkdfParams | HmacImportParams | Pbkdf2Params
extractableboolean
keyUsagesIterable<KeyUsage>

Returns

Promise<CryptoKey>

Implementation of

ICryptoEngine.deriveKey


digest

digest(algorithm, data): Promise<ArrayBuffer>

MDN Reference

Parameters

NameType
algorithmAlgorithmIdentifier
dataBufferSource

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.digest


encrypt

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

MDN Reference

Parameters

NameType
algorithmAesCbcParams | AesCtrParams | AesGcmParams | AlgorithmIdentifier | RsaOaepParams
keyCryptoKey
dataBufferSource

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.encrypt


encryptEncryptedContentInfo

encryptEncryptedContentInfo(parameters): Promise<EncryptedContentInfo>

Specialized function encrypting "EncryptedContentInfo" object using parameters

Parameters

NameType
parametersCryptoEngineEncryptParams

Returns

Promise<EncryptedContentInfo>

Implementation of

ICryptoEngine.encryptEncryptedContentInfo


exportKey

exportKey(format, key): Promise<JsonWebKey>

MDN Reference

Parameters

NameType
format"jwk"
keyCryptoKey

Returns

Promise<JsonWebKey>

Implementation of

ICryptoEngine.exportKey

exportKey(format, key): Promise<ArrayBuffer>

Parameters

NameType
format"raw" | "pkcs8" | "spki"
keyCryptoKey

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.exportKey


generateKey

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

MDN Reference

Parameters

NameType
algorithmEcKeyGenParams | RsaHashedKeyGenParams
extractableboolean
keyUsagesKeyUsage[]

Returns

Promise<CryptoKeyPair>

Implementation of

ICryptoEngine.generateKey

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

Parameters

NameType
algorithmAesKeyGenParams | HmacKeyGenParams | Pbkdf2Params
extractableboolean
keyUsagesKeyUsage[]

Returns

Promise<CryptoKey>

Implementation of

ICryptoEngine.generateKey

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

Parameters

NameType
algorithmAlgorithmIdentifier
extractableboolean
keyUsagesKeyUsage[]

Returns

Promise<CryptoKeyPair | CryptoKey>

Implementation of

ICryptoEngine.generateKey


getAlgorithmByOID

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

Gets WebCrypto algorithm by wel-known OID

Type parameters

NameType
Textends Algorithm = Algorithm

Parameters

NameTypeDescription
oidstringalgorithm identifier
safety?booleanif true throws exception on unknown algorithm identifier
target?stringname of the target

Returns

object | T

Returns WebCrypto algorithm or an empty object

Implementation of

ICryptoEngine.getAlgorithmByOID

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

Gets WebCrypto algorithm by wel-known OID

Type parameters

NameType
Textends Algorithm = Algorithm

Parameters

NameTypeDescription
oidstringalgorithm identifier
safetytrueif true throws exception on unknown algorithm identifier
target?stringname of the target

Returns

T

Returns WebCrypto algorithm

Throws

Throws Error exception if unknown algorithm identifier

Implementation of

ICryptoEngine.getAlgorithmByOID

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

Parameters

NameType
oidany
safety?any
target?any

Returns

object

Implementation of

type.ICryptoEngine.getAlgorithmByOID


getAlgorithmParameters

getAlgorithmParameters(algorithmName, operation): CryptoEngineAlgorithmParams

Get default algorithm parameters for each kind of operation

Parameters

NameTypeDescription
algorithmNamestringAlgorithm name to get common parameters for
operationCryptoEngineAlgorithmOperationKind of operation: "sign", "encrypt", "generateKey", "importKey", "exportKey", "verify"

Returns

CryptoEngineAlgorithmParams

Implementation of

ICryptoEngine.getAlgorithmParameters


getHashAlgorithm

getHashAlgorithm(signatureAlgorithm): string

Getting hash algorithm by signature algorithm

Parameters

NameTypeDescription
signatureAlgorithmAlgorithmIdentifierSignature algorithm

Returns

string

Implementation of

ICryptoEngine.getHashAlgorithm


getOIDByAlgorithm

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

Get OID for each specific algorithm

Parameters

NameTypeDescription
algorithmAlgorithmWebCrypto Algorithm
safety?booleanIf true throws exception on unknown algorithm. Default is false
target?stringName of the target

Returns

string

Throws

Throws Error exception if unknown WebCrypto algorithm

Implementation of

ICryptoEngine.getOIDByAlgorithm


getPublicKey

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

Parameters

NameType
publicKeyInfoPublicKeyInfo
signatureAlgorithmAlgorithmIdentifier
parameters?CryptoEnginePublicKeyParams

Returns

Promise<CryptoKey>

Implementation of

ICryptoEngine.getPublicKey


getRandomValues

getRandomValues<T>(array): T

Type parameters

NameType
Textends null | ArrayBufferView

Parameters

NameType
arrayT

Returns

T

Implementation of

ICryptoEngine.getRandomValues


getSignatureParameters

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

Get signature parameters by analyzing private key algorithm

Parameters

NameTypeDescription
privateKeyCryptoKeyThe private key user would like to use
hashAlgorithm?stringHash algorithm user would like to use. Default is SHA-1

Returns

Promise<CryptoEngineSignatureParams>

Implementation of

ICryptoEngine.getSignatureParameters


importKey

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

MDN Reference

Parameters

NameType
format"jwk"
keyDataJsonWebKey
algorithmAesKeyAlgorithm | EcKeyImportParams | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams
extractableboolean
keyUsagesKeyUsage[]

Returns

Promise<CryptoKey>

Implementation of

ICryptoEngine.importKey

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

Parameters

NameType
format"raw" | "pkcs8" | "spki"
keyDataBufferSource
algorithmAesKeyAlgorithm | EcKeyImportParams | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams
extractableboolean
keyUsagesKeyUsage[]

Returns

Promise<CryptoKey>

Implementation of

ICryptoEngine.importKey

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

MDN Reference

Parameters

NameType
format"jwk"
keyDataJsonWebKey
algorithmAesKeyAlgorithm | EcKeyImportParams | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams
extractableboolean
keyUsagesKeyUsage[]

Returns

Promise<CryptoKey>

Implementation of

ICryptoEngine.importKey

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

Parameters

NameType
format"raw" | "pkcs8" | "spki"
keyDataBufferSource
algorithmAesKeyAlgorithm | EcKeyImportParams | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams
extractableboolean
keyUsagesIterable<KeyUsage>

Returns

Promise<CryptoKey>

Implementation of

ICryptoEngine.importKey


sign

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

MDN Reference

Parameters

NameType
algorithmEcdsaParams | AlgorithmIdentifier | RsaPssParams
keyCryptoKey
dataBufferSource

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.sign


signWithPrivateKey

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

Sign data with pre-defined private key

Parameters

NameTypeDescription
dataBufferSourceData to be signed
privateKeyCryptoKeyPrivate key to use
parametersCryptoEngineSignWithPrivateKeyParamsParameters for used algorithm

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.signWithPrivateKey


stampDataWithPassword

stampDataWithPassword(parameters): Promise<ArrayBuffer>

Stamping (signing) data using algorithm similar to HMAC

Parameters

NameType
parametersCryptoEngineStampDataWithPasswordParams

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.stampDataWithPassword


unwrapKey

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

MDN Reference

Parameters

NameType
formatKeyFormat
wrappedKeyBufferSource
unwrappingKeyCryptoKey
unwrapAlgorithmAesCbcParams | AesCtrParams | AesGcmParams | AlgorithmIdentifier | RsaOaepParams
unwrappedKeyAlgorithmAesKeyAlgorithm | EcKeyImportParams | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams
extractableboolean
keyUsagesKeyUsage[]

Returns

Promise<CryptoKey>

Implementation of

ICryptoEngine.unwrapKey

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

MDN Reference

Parameters

NameType
formatKeyFormat
wrappedKeyBufferSource
unwrappingKeyCryptoKey
unwrapAlgorithmAesCbcParams | AesCtrParams | AesGcmParams | AlgorithmIdentifier | RsaOaepParams
unwrappedKeyAlgorithmAesKeyAlgorithm | EcKeyImportParams | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams
extractableboolean
keyUsagesIterable<KeyUsage>

Returns

Promise<CryptoKey>

Implementation of

ICryptoEngine.unwrapKey


verify

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

MDN Reference

Parameters

NameType
algorithmEcdsaParams | AlgorithmIdentifier | RsaPssParams
keyCryptoKey
signatureBufferSource
dataBufferSource

Returns

Promise<boolean>

Implementation of

ICryptoEngine.verify


verifyDataStampedWithPassword

verifyDataStampedWithPassword(parameters): Promise<boolean>

Parameters

NameType
parametersCryptoEngineVerifyDataStampedWithPasswordParams

Returns

Promise<boolean>

Implementation of

ICryptoEngine.verifyDataStampedWithPassword


verifyWithPublicKey

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

Verify data with the public key

Parameters

NameTypeDescription
dataBufferSourceData to be verified
signatureOctetString | BitStringSignature value
publicKeyInfoPublicKeyInfoPublic key information
signatureAlgorithmAlgorithmIdentifierSignature algorithm
shaAlgorithm?stringHash algorithm

Returns

Promise<boolean>

Implementation of

ICryptoEngine.verifyWithPublicKey


wrapKey

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

MDN Reference

Parameters

NameType
formatKeyFormat
keyCryptoKey
wrappingKeyCryptoKey
wrapAlgorithmAesCbcParams | AesCtrParams | AesGcmParams | AlgorithmIdentifier | RsaOaepParams

Returns

Promise<ArrayBuffer>

Implementation of

ICryptoEngine.wrapKey