AbstractCryptoEngine
Extended by
Section titled “Extended by”Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AbstractCryptoEngine(
parameters):AbstractCryptoEngine
Constructor for CryptoEngine class
Parameters
Section titled “Parameters”parameters
Section titled “parameters”Returns
Section titled “Returns”AbstractCryptoEngine
Properties
Section titled “Properties”crypto
Section titled “crypto”crypto:
Crypto
Implementation of
Section titled “Implementation of”name:
string
Implementation of
Section titled “Implementation of”subtle
Section titled “subtle”subtle:
SubtleCrypto
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”decrypt()
Section titled “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”).
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams
CryptoKey
BufferSource
Returns
Section titled “Returns”Promise<ArrayBuffer>
Implementation of
Section titled “Implementation of”decryptEncryptedContentInfo()
Section titled “decryptEncryptedContentInfo()”
abstractdecryptEncryptedContentInfo(parameters):Promise<ArrayBuffer>
Decrypt data stored in “EncryptedContentInfo” object using parameters
Parameters
Section titled “Parameters”parameters
Section titled “parameters”Returns
Section titled “Returns”Promise<ArrayBuffer>
Implementation of
Section titled “Implementation of”ICryptoEngine.decryptEncryptedContentInfo
deriveBits()
Section titled “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.
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”AlgorithmIdentifier | Pbkdf2Params | EcdhKeyDeriveParams | HkdfParams
baseKey
Section titled “baseKey”CryptoKey
length
Section titled “length”number
Returns
Section titled “Returns”Promise<ArrayBuffer>
Implementation of
Section titled “Implementation of”deriveKey()
Section titled “deriveKey()”Call Signature
Section titled “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.
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”AlgorithmIdentifier | Pbkdf2Params | EcdhKeyDeriveParams | HkdfParams
baseKey
Section titled “baseKey”CryptoKey
derivedKeyType
Section titled “derivedKeyType”AlgorithmIdentifier | Pbkdf2Params | HkdfParams | AesDerivedKeyParams | HmacImportParams
extractable
Section titled “extractable”boolean
keyUsages
Section titled “keyUsages”KeyUsage[]
Returns
Section titled “Returns”Promise<CryptoKey>
Implementation of
Section titled “Implementation of”Call Signature
Section titled “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.
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”AlgorithmIdentifier | Pbkdf2Params | EcdhKeyDeriveParams | HkdfParams
baseKey
Section titled “baseKey”CryptoKey
derivedKeyType
Section titled “derivedKeyType”AlgorithmIdentifier | Pbkdf2Params | HkdfParams | AesDerivedKeyParams | HmacImportParams
extractable
Section titled “extractable”boolean
keyUsages
Section titled “keyUsages”Iterable<KeyUsage>
Returns
Section titled “Returns”Promise<CryptoKey>
Implementation of
Section titled “Implementation of”digest()
Section titled “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.
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”AlgorithmIdentifier
BufferSource
Returns
Section titled “Returns”Promise<ArrayBuffer>
Implementation of
Section titled “Implementation of”encrypt()
Section titled “encrypt()”encrypt(
algorithm,key,data):Promise<ArrayBuffer>
The encrypt() method of the SubtleCrypto interface encrypts data.
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams
CryptoKey
BufferSource
Returns
Section titled “Returns”Promise<ArrayBuffer>
Implementation of
Section titled “Implementation of”encryptEncryptedContentInfo()
Section titled “encryptEncryptedContentInfo()”
abstractencryptEncryptedContentInfo(parameters):Promise<EncryptedContentInfo>
Specialized function encrypting “EncryptedContentInfo” object using parameters
Parameters
Section titled “Parameters”parameters
Section titled “parameters”Returns
Section titled “Returns”Promise<EncryptedContentInfo>
Implementation of
Section titled “Implementation of”ICryptoEngine.encryptEncryptedContentInfo
exportKey()
Section titled “exportKey()”Call Signature
Section titled “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.
Parameters
Section titled “Parameters”format
Section titled “format”"jwk"
CryptoKey
Returns
Section titled “Returns”Promise<JsonWebKey>
Implementation of
Section titled “Implementation of”Call Signature
Section titled “Call Signature”exportKey(
format,key):Promise<ArrayBuffer>
Parameters
Section titled “Parameters”format
Section titled “format”"pkcs8" | "raw" | "spki"
CryptoKey
Returns
Section titled “Returns”Promise<ArrayBuffer>
Implementation of
Section titled “Implementation of”generateKey()
Section titled “generateKey()”Call Signature
Section titled “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).
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”"Ed25519"
extractable
Section titled “extractable”boolean
keyUsages
Section titled “keyUsages”readonly ("sign" | "verify")[]
Returns
Section titled “Returns”Promise<CryptoKeyPair>
Implementation of
Section titled “Implementation of”Call Signature
Section titled “Call Signature”generateKey(
algorithm,extractable,keyUsages):Promise<CryptoKeyPair>
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”"X25519" | { name: "X25519"; }
extractable
Section titled “extractable”boolean
keyUsages
Section titled “keyUsages”readonly ("deriveBits" | "deriveKey")[]
Returns
Section titled “Returns”Promise<CryptoKeyPair>
Implementation of
Section titled “Implementation of”Call Signature
Section titled “Call Signature”generateKey(
algorithm,extractable,keyUsages):Promise<CryptoKeyPair>
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”RsaHashedKeyGenParams | EcKeyGenParams
extractable
Section titled “extractable”boolean
keyUsages
Section titled “keyUsages”KeyUsage[]
Returns
Section titled “Returns”Promise<CryptoKeyPair>
Implementation of
Section titled “Implementation of”Call Signature
Section titled “Call Signature”generateKey(
algorithm,extractable,keyUsages):Promise<CryptoKey>
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params
extractable
Section titled “extractable”boolean
keyUsages
Section titled “keyUsages”KeyUsage[]
Returns
Section titled “Returns”Promise<CryptoKey>
Implementation of
Section titled “Implementation of”Call Signature
Section titled “Call Signature”generateKey(
algorithm,extractable,keyUsages):Promise<CryptoKey|CryptoKeyPair>
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”AlgorithmIdentifier
extractable
Section titled “extractable”boolean
keyUsages
Section titled “keyUsages”KeyUsage[]
Returns
Section titled “Returns”Promise<CryptoKey | CryptoKeyPair>
Implementation of
Section titled “Implementation of”getAlgorithmByOID()
Section titled “getAlgorithmByOID()”Call Signature
Section titled “Call Signature”
abstractgetAlgorithmByOID<T>(oid,safety?,target?):object|T
Gets WebCrypto algorithm by wel-known OID
Type Parameters
Section titled “Type Parameters”T extends Algorithm = Algorithm
Parameters
Section titled “Parameters”string
algorithm identifier
safety?
Section titled “safety?”boolean
if true throws exception on unknown algorithm identifier
target?
Section titled “target?”string
name of the target
Returns
Section titled “Returns”object | T
Returns WebCrypto algorithm or an empty object
Implementation of
Section titled “Implementation of”ICryptoEngine.getAlgorithmByOID
Call Signature
Section titled “Call Signature”
abstractgetAlgorithmByOID<T>(oid,safety,target?):T
Gets WebCrypto algorithm by wel-known OID
Type Parameters
Section titled “Type Parameters”T extends Algorithm = Algorithm
Parameters
Section titled “Parameters”string
algorithm identifier
safety
Section titled “safety”true
if true throws exception on unknown algorithm identifier
target?
Section titled “target?”string
name of the target
Returns
Section titled “Returns”T
Returns WebCrypto algorithm
Throws
Section titled “Throws”Throws Error exception if unknown algorithm identifier
Implementation of
Section titled “Implementation of”ICryptoEngine.getAlgorithmByOID
Call Signature
Section titled “Call Signature”
abstractgetAlgorithmByOID(oid,safety?,target?):object
Parameters
Section titled “Parameters”any
safety?
Section titled “safety?”any
target?
Section titled “target?”any
Returns
Section titled “Returns”object
Implementation of
Section titled “Implementation of”type.ICryptoEngine.getAlgorithmByOID
getAlgorithmParameters()
Section titled “getAlgorithmParameters()”
abstractgetAlgorithmParameters(algorithmName,operation):CryptoEngineAlgorithmParams
Get default algorithm parameters for each kind of operation
Parameters
Section titled “Parameters”algorithmName
Section titled “algorithmName”string
Algorithm name to get common parameters for
operation
Section titled “operation”CryptoEngineAlgorithmOperation
Kind of operation: “sign”, “encrypt”, “generateKey”, “importKey”, “exportKey”, “verify”
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”ICryptoEngine.getAlgorithmParameters
getHashAlgorithm()
Section titled “getHashAlgorithm()”
abstractgetHashAlgorithm(signatureAlgorithm):string
Getting hash algorithm by signature algorithm
Parameters
Section titled “Parameters”signatureAlgorithm
Section titled “signatureAlgorithm”Signature algorithm
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”ICryptoEngine.getHashAlgorithm
getOIDByAlgorithm()
Section titled “getOIDByAlgorithm()”
abstractgetOIDByAlgorithm(algorithm,safety?,target?):string
Get OID for each specific algorithm
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”Algorithm
WebCrypto Algorithm
safety?
Section titled “safety?”boolean
If true throws exception on unknown algorithm. Default is false
target?
Section titled “target?”string
Name of the target
Returns
Section titled “Returns”string
Throws
Section titled “Throws”Throws Error exception if unknown WebCrypto algorithm
Implementation of
Section titled “Implementation of”ICryptoEngine.getOIDByAlgorithm
getPublicKey()
Section titled “getPublicKey()”
abstractgetPublicKey(publicKeyInfo,signatureAlgorithm,parameters?):Promise<CryptoKey>
Parameters
Section titled “Parameters”publicKeyInfo
Section titled “publicKeyInfo”signatureAlgorithm
Section titled “signatureAlgorithm”parameters?
Section titled “parameters?”Returns
Section titled “Returns”Promise<CryptoKey>
Implementation of
Section titled “Implementation of”getRandomValues()
Section titled “getRandomValues()”getRandomValues<
T>(array):T
Type Parameters
Section titled “Type Parameters”T extends ArrayBufferView<ArrayBufferLike> | null
Parameters
Section titled “Parameters”T
Returns
Section titled “Returns”T
Implementation of
Section titled “Implementation of”getSignatureParameters()
Section titled “getSignatureParameters()”
abstractgetSignatureParameters(privateKey,hashAlgorithm?):Promise<CryptoEngineSignatureParams>
Get signature parameters by analyzing private key algorithm
Parameters
Section titled “Parameters”privateKey
Section titled “privateKey”CryptoKey
The private key user would like to use
hashAlgorithm?
Section titled “hashAlgorithm?”string
Hash algorithm user would like to use. Default is SHA-1
Returns
Section titled “Returns”Promise<CryptoEngineSignatureParams>
Implementation of
Section titled “Implementation of”ICryptoEngine.getSignatureParameters
importKey()
Section titled “importKey()”Call Signature
Section titled “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.
Parameters
Section titled “Parameters”format
Section titled “format”"jwk"
keyData
Section titled “keyData”JsonWebKey
algorithm
Section titled “algorithm”AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm
extractable
Section titled “extractable”boolean
keyUsages
Section titled “keyUsages”KeyUsage[]
Returns
Section titled “Returns”Promise<CryptoKey>
Implementation of
Section titled “Implementation of”Call Signature
Section titled “Call Signature”importKey(
format,keyData,algorithm,extractable,keyUsages):Promise<CryptoKey>
Parameters
Section titled “Parameters”format
Section titled “format”"pkcs8" | "raw" | "spki"
keyData
Section titled “keyData”BufferSource
algorithm
Section titled “algorithm”AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm
extractable
Section titled “extractable”boolean
keyUsages
Section titled “keyUsages”KeyUsage[]
Returns
Section titled “Returns”Promise<CryptoKey>
Implementation of
Section titled “Implementation of”Call Signature
Section titled “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.
Parameters
Section titled “Parameters”format
Section titled “format”"jwk"
keyData
Section titled “keyData”JsonWebKey
algorithm
Section titled “algorithm”AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm
extractable
Section titled “extractable”boolean
keyUsages
Section titled “keyUsages”KeyUsage[]
Returns
Section titled “Returns”Promise<CryptoKey>
Implementation of
Section titled “Implementation of”Call Signature
Section titled “Call Signature”importKey(
format,keyData,algorithm,extractable,keyUsages):Promise<CryptoKey>
Parameters
Section titled “Parameters”format
Section titled “format”"pkcs8" | "raw" | "spki"
keyData
Section titled “keyData”BufferSource
algorithm
Section titled “algorithm”AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm
extractable
Section titled “extractable”boolean
keyUsages
Section titled “keyUsages”Iterable<KeyUsage>
Returns
Section titled “Returns”Promise<CryptoKey>
Implementation of
Section titled “Implementation of”sign()
Section titled “sign()”sign(
algorithm,key,data):Promise<ArrayBuffer>
The sign() method of the SubtleCrypto interface generates a digital signature.
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”AlgorithmIdentifier | RsaPssParams | EcdsaParams
CryptoKey
BufferSource
Returns
Section titled “Returns”Promise<ArrayBuffer>
Implementation of
Section titled “Implementation of”signWithPrivateKey()
Section titled “signWithPrivateKey()”
abstractsignWithPrivateKey(data,privateKey,parameters):Promise<ArrayBuffer>
Sign data with pre-defined private key
Parameters
Section titled “Parameters”BufferSource
Data to be signed
privateKey
Section titled “privateKey”CryptoKey
Private key to use
parameters
Section titled “parameters”CryptoEngineSignWithPrivateKeyParams
Parameters for used algorithm
Returns
Section titled “Returns”Promise<ArrayBuffer>
Implementation of
Section titled “Implementation of”ICryptoEngine.signWithPrivateKey
stampDataWithPassword()
Section titled “stampDataWithPassword()”
abstractstampDataWithPassword(parameters):Promise<ArrayBuffer>
Stamping (signing) data using algorithm similar to HMAC
Parameters
Section titled “Parameters”parameters
Section titled “parameters”CryptoEngineStampDataWithPasswordParams
Returns
Section titled “Returns”Promise<ArrayBuffer>
Implementation of
Section titled “Implementation of”ICryptoEngine.stampDataWithPassword
unwrapKey()
Section titled “unwrapKey()”Call Signature
Section titled “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.
Parameters
Section titled “Parameters”format
Section titled “format”KeyFormat
wrappedKey
Section titled “wrappedKey”BufferSource
unwrappingKey
Section titled “unwrappingKey”CryptoKey
unwrapAlgorithm
Section titled “unwrapAlgorithm”AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams
unwrappedKeyAlgorithm
Section titled “unwrappedKeyAlgorithm”AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm
extractable
Section titled “extractable”boolean
keyUsages
Section titled “keyUsages”KeyUsage[]
Returns
Section titled “Returns”Promise<CryptoKey>
Implementation of
Section titled “Implementation of”Call Signature
Section titled “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.
Parameters
Section titled “Parameters”format
Section titled “format”KeyFormat
wrappedKey
Section titled “wrappedKey”BufferSource
unwrappingKey
Section titled “unwrappingKey”CryptoKey
unwrapAlgorithm
Section titled “unwrapAlgorithm”AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams
unwrappedKeyAlgorithm
Section titled “unwrappedKeyAlgorithm”AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm
extractable
Section titled “extractable”boolean
keyUsages
Section titled “keyUsages”Iterable<KeyUsage>
Returns
Section titled “Returns”Promise<CryptoKey>
Implementation of
Section titled “Implementation of”verify()
Section titled “verify()”verify(
algorithm,key,signature,data):Promise<boolean>
The verify() method of the SubtleCrypto interface verifies a digital signature.
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”AlgorithmIdentifier | RsaPssParams | EcdsaParams
CryptoKey
signature
Section titled “signature”BufferSource
BufferSource
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”verifyDataStampedWithPassword()
Section titled “verifyDataStampedWithPassword()”
abstractverifyDataStampedWithPassword(parameters):Promise<boolean>
Parameters
Section titled “Parameters”parameters
Section titled “parameters”CryptoEngineVerifyDataStampedWithPasswordParams
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”ICryptoEngine.verifyDataStampedWithPassword
verifyWithPublicKey()
Section titled “verifyWithPublicKey()”
abstractverifyWithPublicKey(data,signature,publicKeyInfo,signatureAlgorithm,shaAlgorithm?):Promise<boolean>
Verify data with the public key
Parameters
Section titled “Parameters”BufferSource
Data to be verified
signature
Section titled “signature”BitString | OctetString
Signature value
publicKeyInfo
Section titled “publicKeyInfo”Public key information
signatureAlgorithm
Section titled “signatureAlgorithm”Signature algorithm
shaAlgorithm?
Section titled “shaAlgorithm?”string
Hash algorithm
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”ICryptoEngine.verifyWithPublicKey
wrapKey()
Section titled “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.
Parameters
Section titled “Parameters”format
Section titled “format”KeyFormat
CryptoKey
wrappingKey
Section titled “wrappingKey”CryptoKey
wrapAlgorithm
Section titled “wrapAlgorithm”AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams
Returns
Section titled “Returns”Promise<ArrayBuffer>