AbstractCryptoEngine
Extended by
Implements
Constructors
Constructor
new AbstractCryptoEngine(
parameters):AbstractCryptoEngine
Constructor for CryptoEngine class
Parameters
parameters
Returns
AbstractCryptoEngine
Properties
crypto
crypto:
Crypto
Implementation of
name
name:
string
Implementation of
subtle
subtle:
SubtleCrypto
Implementation of
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").
Parameters
algorithm
AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams
key
CryptoKey
data
BufferSource
Returns
Promise<ArrayBuffer>
Implementation of
decryptEncryptedContentInfo()
abstractdecryptEncryptedContentInfo(parameters):Promise<ArrayBuffer>
Decrypt data stored in "EncryptedContentInfo" object using parameters
Parameters
parameters
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.
Parameters
algorithm
AlgorithmIdentifier | Pbkdf2Params | EcdhKeyDeriveParams | HkdfParams
baseKey
CryptoKey
length
number
Returns
Promise<ArrayBuffer>
Implementation of
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.
Parameters
algorithm
AlgorithmIdentifier | Pbkdf2Params | EcdhKeyDeriveParams | HkdfParams
baseKey
CryptoKey
derivedKeyType
AlgorithmIdentifier | Pbkdf2Params | HkdfParams | AesDerivedKeyParams | HmacImportParams
extractable
boolean
keyUsages
KeyUsage[]
Returns
Promise<CryptoKey>
Implementation of
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
algorithm
AlgorithmIdentifier | Pbkdf2Params | EcdhKeyDeriveParams | HkdfParams
baseKey
CryptoKey
derivedKeyType
AlgorithmIdentifier | Pbkdf2Params | HkdfParams | AesDerivedKeyParams | HmacImportParams
extractable
boolean
keyUsages
Iterable<KeyUsage>
Returns
Promise<CryptoKey>
Implementation of
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
algorithm
AlgorithmIdentifier
data
BufferSource
Returns
Promise<ArrayBuffer>
Implementation of
encrypt()
encrypt(
algorithm,key,data):Promise<ArrayBuffer>
The encrypt() method of the SubtleCrypto interface encrypts data.
Parameters
algorithm
AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams
key
CryptoKey
data
BufferSource
Returns
Promise<ArrayBuffer>
Implementation of
encryptEncryptedContentInfo()
abstractencryptEncryptedContentInfo(parameters):Promise<EncryptedContentInfo>
Specialized function encrypting "EncryptedContentInfo" object using parameters
Parameters
parameters
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.
Parameters
format
"jwk"
key
CryptoKey
Returns
Promise<JsonWebKey>
Implementation of
Call Signature
exportKey(
format,key):Promise<ArrayBuffer>
Parameters
format
"pkcs8" | "raw" | "spki"
key
CryptoKey
Returns
Promise<ArrayBuffer>
Implementation of
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).
Parameters
algorithm
"Ed25519"
extractable
boolean
keyUsages
readonly ("sign" | "verify")[]
Returns
Promise<CryptoKeyPair>
Implementation of
Call Signature
generateKey(
algorithm,extractable,keyUsages):Promise<CryptoKeyPair>
Parameters
algorithm
"X25519" | { name: "X25519"; }
extractable
boolean
keyUsages
readonly ("deriveBits" | "deriveKey")[]
Returns
Promise<CryptoKeyPair>
Implementation of
Call Signature
generateKey(
algorithm,extractable,keyUsages):Promise<CryptoKeyPair>
Parameters
algorithm
RsaHashedKeyGenParams | EcKeyGenParams
extractable
boolean
keyUsages
KeyUsage[]
Returns
Promise<CryptoKeyPair>
Implementation of
Call Signature
generateKey(
algorithm,extractable,keyUsages):Promise<CryptoKey>
Parameters
algorithm
AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params
extractable
boolean
keyUsages
KeyUsage[]
Returns
Promise<CryptoKey>
Implementation of
Call Signature
generateKey(
algorithm,extractable,keyUsages):Promise<CryptoKey|CryptoKeyPair>
Parameters
algorithm
AlgorithmIdentifier
extractable
boolean
keyUsages
KeyUsage[]
Returns
Promise<CryptoKey | CryptoKeyPair>
Implementation of
getAlgorithmByOID()
Call Signature
abstractgetAlgorithmByOID<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
abstractgetAlgorithmByOID<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
abstractgetAlgorithmByOID(oid,safety?,target?):object
Parameters
oid
any
safety?
any
target?
any
Returns
object
Implementation of
type.ICryptoEngine.getAlgorithmByOID
getAlgorithmParameters()
abstractgetAlgorithmParameters(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
Implementation of
ICryptoEngine.getAlgorithmParameters
getHashAlgorithm()
abstractgetHashAlgorithm(signatureAlgorithm):string
Getting hash algorithm by signature algorithm
Parameters
signatureAlgorithm
Signature algorithm
Returns
string
Implementation of
ICryptoEngine.getHashAlgorithm
getOIDByAlgorithm()
abstractgetOIDByAlgorithm(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()
abstractgetPublicKey(publicKeyInfo,signatureAlgorithm,parameters?):Promise<CryptoKey>
Parameters
publicKeyInfo
signatureAlgorithm
parameters?
Returns
Promise<CryptoKey>
Implementation of
getRandomValues()
getRandomValues<
T>(array):T
Type Parameters
T
T extends ArrayBufferView<ArrayBufferLike> | null
Parameters
array
T
Returns
T
Implementation of
getSignatureParameters()
abstractgetSignatureParameters(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.
Parameters
format
"jwk"
keyData
JsonWebKey
algorithm
AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm
extractable
boolean
keyUsages
KeyUsage[]
Returns
Promise<CryptoKey>
Implementation of
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
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
format
"jwk"
keyData
JsonWebKey
algorithm
AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm
extractable
boolean
keyUsages
KeyUsage[]
Returns
Promise<CryptoKey>
Implementation of
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
sign()
sign(
algorithm,key,data):Promise<ArrayBuffer>
The sign() method of the SubtleCrypto interface generates a digital signature.
Parameters
algorithm
AlgorithmIdentifier | RsaPssParams | EcdsaParams
key
CryptoKey
data
BufferSource
Returns
Promise<ArrayBuffer>
Implementation of
signWithPrivateKey()
abstractsignWithPrivateKey(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()
abstractstampDataWithPassword(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.
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
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
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
verify()
verify(
algorithm,key,signature,data):Promise<boolean>
The verify() method of the SubtleCrypto interface verifies a digital signature.
Parameters
algorithm
AlgorithmIdentifier | RsaPssParams | EcdsaParams
key
CryptoKey
signature
BufferSource
data
BufferSource
Returns
Promise<boolean>
Implementation of
verifyDataStampedWithPassword()
abstractverifyDataStampedWithPassword(parameters):Promise<boolean>
Parameters
parameters
CryptoEngineVerifyDataStampedWithPasswordParams
Returns
Promise<boolean>
Implementation of
ICryptoEngine.verifyDataStampedWithPassword
verifyWithPublicKey()
abstractverifyWithPublicKey(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
Public key information
signatureAlgorithm
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.
Parameters
format
KeyFormat
key
CryptoKey
wrappingKey
CryptoKey
wrapAlgorithm
AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams
Returns
Promise<ArrayBuffer>