abstract
AbstractCryptoEngine
Extended by
Implements
Constructors
new AbstractCryptoEngine()
new AbstractCryptoEngine(
parameters
):AbstractCryptoEngine
Constructor for CryptoEngine class
Parameters
• parameters: CryptoEngineParameters
Returns
Properties
crypto
crypto:
Crypto
Implementation of
name
name:
string
Implementation of
subtle
subtle:
SubtleCrypto
Implementation of
Methods
decrypt()
decrypt(
algorithm
,key
,data
):Promise
<ArrayBuffer
>
Parameters
• algorithm: AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams
• key: CryptoKey
• data: BufferSource
Returns
Promise
<ArrayBuffer
>
Implementation of
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
>
Parameters
• algorithm: EcdhKeyDeriveParams
| AlgorithmIdentifier
| HkdfParams
| Pbkdf2Params
• baseKey: CryptoKey
• length: number
Returns
Promise
<ArrayBuffer
>
Implementation of
deriveKey()
deriveKey(algorithm, baseKey, derivedKeyType, extractable, keyUsages)
deriveKey(
algorithm
,baseKey
,derivedKeyType
,extractable
,keyUsages
):Promise
<CryptoKey
>
Parameters
• algorithm: EcdhKeyDeriveParams
| AlgorithmIdentifier
| HkdfParams
| Pbkdf2Params
• baseKey: CryptoKey
• derivedKeyType: AesDerivedKeyParams
| AlgorithmIdentifier
| HkdfParams
| HmacImportParams
| Pbkdf2Params
• extractable: boolean
• keyUsages: KeyUsage
[]
Returns
Promise
<CryptoKey
>
Implementation of
deriveKey(algorithm, baseKey, derivedKeyType, extractable, keyUsages)
deriveKey(
algorithm
,baseKey
,derivedKeyType
,extractable
,keyUsages
):Promise
<CryptoKey
>
Parameters
• algorithm: EcdhKeyDeriveParams
| AlgorithmIdentifier
| HkdfParams
| Pbkdf2Params
• baseKey: CryptoKey
• derivedKeyType: AesDerivedKeyParams
| AlgorithmIdentifier
| HkdfParams
| HmacImportParams
| Pbkdf2Params
• extractable: boolean
• keyUsages: Iterable
<KeyUsage
>
Returns
Promise
<CryptoKey
>
Implementation of
digest()
digest(
algorithm
,data
):Promise
<ArrayBuffer
>
Parameters
• algorithm: AlgorithmIdentifier
• data: BufferSource
Returns
Promise
<ArrayBuffer
>
Implementation of
encrypt()
encrypt(
algorithm
,key
,data
):Promise
<ArrayBuffer
>
Parameters
• algorithm: AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams
• key: CryptoKey
• data: BufferSource
Returns
Promise
<ArrayBuffer
>
Implementation of
encryptEncryptedContentInfo()
abstract
encryptEncryptedContentInfo(parameters
):Promise
<EncryptedContentInfo
>
Specialized function encrypting "EncryptedContentInfo" object using parameters
Parameters
• parameters: CryptoEngineEncryptParams
Returns
Promise
<EncryptedContentInfo
>
Implementation of
ICryptoEngine
.encryptEncryptedContentInfo
exportKey()
exportKey(format, key)
exportKey(
format
,key
):Promise
<JsonWebKey
>
Parameters
• format: "jwk"
• key: CryptoKey
Returns
Promise
<JsonWebKey
>
Implementation of
exportKey(format, key)
exportKey(
format
,key
):Promise
<ArrayBuffer
>
Parameters
• format: "raw"
| "pkcs8"
| "spki"
• key: CryptoKey
Returns
Promise
<ArrayBuffer
>
Implementation of
generateKey()
generateKey(algorithm, extractable, keyUsages)
generateKey(
algorithm
,extractable
,keyUsages
):Promise
<CryptoKeyPair
>
Parameters
• algorithm: "Ed25519"
• extractable: boolean
• keyUsages: readonly ("sign"
| "verify"
)[]
Returns
Promise
<CryptoKeyPair
>
Implementation of
generateKey(algorithm, extractable, keyUsages)
generateKey(
algorithm
,extractable
,keyUsages
):Promise
<CryptoKeyPair
>
Parameters
• algorithm: EcKeyGenParams
| RsaHashedKeyGenParams
• extractable: boolean
• keyUsages: KeyUsage
[]
Returns
Promise
<CryptoKeyPair
>
Implementation of
generateKey(algorithm, extractable, keyUsages)
generateKey(
algorithm
,extractable
,keyUsages
):Promise
<CryptoKey
>
Parameters
• algorithm: AesKeyGenParams
| HmacKeyGenParams
| Pbkdf2Params
• extractable: boolean
• keyUsages: KeyUsage
[]
Returns
Promise
<CryptoKey
>
Implementation of
generateKey(algorithm, extractable, keyUsages)
generateKey(
algorithm
,extractable
,keyUsages
):Promise
<CryptoKeyPair
|CryptoKey
>
Parameters
• algorithm: AlgorithmIdentifier
• extractable: boolean
• keyUsages: KeyUsage
[]
Returns
Promise
<CryptoKeyPair
| CryptoKey
>
Implementation of
getAlgorithmByOID()
getAlgorithmByOID(oid, safety, target)
abstract
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
Implementation of
ICryptoEngine
.getAlgorithmByOID
getAlgorithmByOID(oid, safety, target)
abstract
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 or an empty object
Implementation of
ICryptoEngine
.getAlgorithmByOID
getAlgorithmByOID(oid, safety, target)
abstract
getAlgorithmByOID(oid
,safety
?,target
?):object
Gets WebCrypto algorithm by wel-known OID
Parameters
• oid: any
algorithm identifier
• safety?: any
if true
throws exception on unknown algorithm identifier
• target?: any
name of the target
Returns
object
Returns WebCrypto algorithm or an empty 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
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
getRandomValues()
getRandomValues<
T
>(array
):T
Type Parameters
• T extends null
| ArrayBufferView
Parameters
• array: T
Returns
T
Implementation of
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()
importKey(format, keyData, algorithm, extractable, keyUsages)
importKey(
format
,keyData
,algorithm
,extractable
,keyUsages
):Promise
<CryptoKey
>
Parameters
• format: "jwk"
• keyData: JsonWebKey
• algorithm: AesKeyAlgorithm
| EcKeyImportParams
| AlgorithmIdentifier
| HmacImportParams
| RsaHashedImportParams
• extractable: boolean
• keyUsages: KeyUsage
[]
Returns
Promise
<CryptoKey
>
Implementation of
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
>
Implementation of
importKey(format, keyData, algorithm, extractable, keyUsages)
importKey(
format
,keyData
,algorithm
,extractable
,keyUsages
):Promise
<CryptoKey
>
Parameters
• format: "jwk"
• keyData: JsonWebKey
• algorithm: AesKeyAlgorithm
| EcKeyImportParams
| AlgorithmIdentifier
| HmacImportParams
| RsaHashedImportParams
• extractable: boolean
• keyUsages: KeyUsage
[]
Returns
Promise
<CryptoKey
>
Implementation of
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
>
Implementation of
sign()
sign(
algorithm
,key
,data
):Promise
<ArrayBuffer
>
Parameters
• algorithm: EcdsaParams
| AlgorithmIdentifier
| RsaPssParams
• key: CryptoKey
• data: BufferSource
Returns
Promise
<ArrayBuffer
>
Implementation of
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()
unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)
unwrapKey(
format
,wrappedKey
,unwrappingKey
,unwrapAlgorithm
,unwrappedKeyAlgorithm
,extractable
,keyUsages
):Promise
<CryptoKey
>
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
>
Implementation of
unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)
unwrapKey(
format
,wrappedKey
,unwrappingKey
,unwrapAlgorithm
,unwrappedKeyAlgorithm
,extractable
,keyUsages
):Promise
<CryptoKey
>
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
>
Implementation of
verify()
verify(
algorithm
,key
,signature
,data
):Promise
<boolean
>
Parameters
• algorithm: EcdsaParams
| AlgorithmIdentifier
| RsaPssParams
• key: CryptoKey
• signature: BufferSource
• data: BufferSource
Returns
Promise
<boolean
>
Implementation of
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: OctetString
| BitString
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
>
Parameters
• format: KeyFormat
• key: CryptoKey
• wrappingKey: CryptoKey
• wrapAlgorithm: AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams
Returns
Promise
<ArrayBuffer
>