Skip to main content

ICryptoEngine

Extends

  • SubtleCrypto

Properties

crypto

crypto: Crypto


name

name: string


subtle

subtle: SubtleCrypto

Methods

decrypt()

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

MDN Reference

Parameters

algorithm: AesCbcParams | AesCtrParams | AesGcmParams | AlgorithmIdentifier | RsaOaepParams

key: CryptoKey

data: BufferSource

Returns

Promise<ArrayBuffer>

Inherited from

SubtleCrypto.decrypt


decryptEncryptedContentInfo()

decryptEncryptedContentInfo(parameters): Promise<ArrayBuffer>

Decrypt data stored in "EncryptedContentInfo" object using parameters

Parameters

parameters: CryptoEngineDecryptParams

Returns

Promise<ArrayBuffer>


deriveBits()

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

MDN Reference

Parameters

algorithm: EcdhKeyDeriveParams | AlgorithmIdentifier | HkdfParams | Pbkdf2Params

baseKey: CryptoKey

length: number

Returns

Promise<ArrayBuffer>

Inherited from

SubtleCrypto.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>

Inherited from

SubtleCrypto.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>

Inherited from

SubtleCrypto.deriveKey


digest()

digest(algorithm, data): Promise<ArrayBuffer>

MDN Reference

Parameters

algorithm: AlgorithmIdentifier

data: BufferSource

Returns

Promise<ArrayBuffer>

Inherited from

SubtleCrypto.digest


encrypt()

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

MDN Reference

Parameters

algorithm: AesCbcParams | AesCtrParams | AesGcmParams | AlgorithmIdentifier | RsaOaepParams

key: CryptoKey

data: BufferSource

Returns

Promise<ArrayBuffer>

Inherited from

SubtleCrypto.encrypt


encryptEncryptedContentInfo()

encryptEncryptedContentInfo(parameters): Promise<EncryptedContentInfo>

Specialized function encrypting "EncryptedContentInfo" object using parameters

Parameters

parameters: CryptoEngineEncryptParams

Returns

Promise<EncryptedContentInfo>


exportKey()

exportKey(format, key)

exportKey(format, key): Promise<JsonWebKey>

MDN Reference

Parameters

format: "jwk"

key: CryptoKey

Returns

Promise<JsonWebKey>

Inherited from

SubtleCrypto.exportKey

exportKey(format, key)

exportKey(format, key): Promise<ArrayBuffer>

Parameters

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

key: CryptoKey

Returns

Promise<ArrayBuffer>

Inherited from

SubtleCrypto.exportKey

exportKey(format, key)

exportKey(format, key): Promise<ArrayBuffer | JsonWebKey>

Parameters

format: KeyFormat

key: CryptoKey

Returns

Promise<ArrayBuffer | JsonWebKey>

Inherited from

SubtleCrypto.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>

Inherited from

SubtleCrypto.generateKey

generateKey(algorithm, extractable, keyUsages)

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

Parameters

algorithm: EcKeyGenParams | RsaHashedKeyGenParams

extractable: boolean

keyUsages: readonly KeyUsage[]

Returns

Promise<CryptoKeyPair>

Inherited from

SubtleCrypto.generateKey

generateKey(algorithm, extractable, keyUsages)

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

Parameters

algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params

extractable: boolean

keyUsages: readonly KeyUsage[]

Returns

Promise<CryptoKey>

Inherited from

SubtleCrypto.generateKey

generateKey(algorithm, extractable, keyUsages)

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

Parameters

algorithm: AlgorithmIdentifier

extractable: boolean

keyUsages: KeyUsage[]

Returns

Promise<CryptoKeyPair | CryptoKey>

Inherited from

SubtleCrypto.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>

Inherited from

SubtleCrypto.generateKey

generateKey(algorithm, extractable, keyUsages)

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

Parameters

algorithm: EcKeyGenParams | RsaHashedKeyGenParams

extractable: boolean

keyUsages: readonly KeyUsage[]

Returns

Promise<CryptoKeyPair>

Inherited from

SubtleCrypto.generateKey

generateKey(algorithm, extractable, keyUsages)

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

Parameters

algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params

extractable: boolean

keyUsages: readonly KeyUsage[]

Returns

Promise<CryptoKey>

Inherited from

SubtleCrypto.generateKey

generateKey(algorithm, extractable, keyUsages)

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

Parameters

algorithm: AlgorithmIdentifier

extractable: boolean

keyUsages: Iterable<KeyUsage>

Returns

Promise<CryptoKeyPair | CryptoKey>

Inherited from

SubtleCrypto.generateKey


getAlgorithmByOID()

getAlgorithmByOID(oid, safety, target)

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

getAlgorithmByOID(oid, safety, target)

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

Throws

Throws Error exception if unknown algorithm identifier


getAlgorithmParameters()

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


getHashAlgorithm()

getHashAlgorithm(signatureAlgorithm): string

Getting hash algorithm by signature algorithm

Parameters

signatureAlgorithm: AlgorithmIdentifier

Signature algorithm

Returns

string


getOIDByAlgorithm()

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


getPublicKey()

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

Parameters

publicKeyInfo: PublicKeyInfo

signatureAlgorithm: AlgorithmIdentifier

parameters?: CryptoEnginePublicKeyParams

Returns

Promise<CryptoKey>


getRandomValues()

getRandomValues<T>(array): T

Type Parameters

T extends null | ArrayBufferView

Parameters

array: T

Returns

T


getSignatureParameters()

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>


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: readonly KeyUsage[]

Returns

Promise<CryptoKey>

Inherited from

SubtleCrypto.importKey

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

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

Parameters

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

keyData: BufferSource

algorithm: AesKeyAlgorithm | EcKeyImportParams | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams

extractable: boolean

keyUsages: KeyUsage[]

Returns

Promise<CryptoKey>

Inherited from

SubtleCrypto.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: readonly KeyUsage[]

Returns

Promise<CryptoKey>

Inherited from

SubtleCrypto.importKey

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

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

Parameters

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

keyData: BufferSource

algorithm: AesKeyAlgorithm | EcKeyImportParams | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams

extractable: boolean

keyUsages: Iterable<KeyUsage>

Returns

Promise<CryptoKey>

Inherited from

SubtleCrypto.importKey


sign()

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

MDN Reference

Parameters

algorithm: EcdsaParams | AlgorithmIdentifier | RsaPssParams

key: CryptoKey

data: BufferSource

Returns

Promise<ArrayBuffer>

Inherited from

SubtleCrypto.sign


signWithPrivateKey()

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>


stampDataWithPassword()

stampDataWithPassword(parameters): Promise<ArrayBuffer>

Stamping (signing) data using algorithm similar to HMAC

Parameters

parameters: CryptoEngineStampDataWithPasswordParams

Returns

Promise<ArrayBuffer>


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>

Inherited from

SubtleCrypto.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>

Inherited from

SubtleCrypto.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>

Inherited from

SubtleCrypto.verify


verifyDataStampedWithPassword()

verifyDataStampedWithPassword(parameters): Promise<boolean>

Parameters

parameters: CryptoEngineVerifyDataStampedWithPasswordParams

Returns

Promise<boolean>


verifyWithPublicKey()

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>


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>

Inherited from

SubtleCrypto.wrapKey