CryptoEngine
Default cryptographic engine for Web Cryptography API
Extends
Constructors
new CryptoEngine()
new CryptoEngine(
parameters
):CryptoEngine
Constructor for CryptoEngine class
Parameters
• parameters: CryptoEngineParameters
Returns
Inherited from
AbstractCryptoEngine
.constructor
Properties
crypto
crypto:
Crypto
Inherited from
name
name:
string
Inherited from
subtle
subtle:
SubtleCrypto
Inherited from
Methods
convert()
convert(
inputFormat
,outputFormat
,keyData
,algorithm
,extractable
,keyUsages
):Promise
<ArrayBuffer
|JsonWebKey
>
Convert WebCrypto keys between different export formats
Parameters
• inputFormat: KeyFormat
• outputFormat: KeyFormat
• keyData: ArrayBuffer
| JsonWebKey
• algorithm: Algorithm
• extractable: boolean
• keyUsages: KeyUsage
[]
Returns
Promise
<ArrayBuffer
| JsonWebKey
>
decrypt()
decrypt(
algorithm
,key
,data
):Promise
<ArrayBuffer
>
Parameters
• algorithm: AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams
• key: CryptoKey
• data: BufferSource
Returns
Promise
<ArrayBuffer
>
Inherited from
decryptEncryptedContentInfo()
decryptEncryptedContentInfo(
parameters
):Promise
<ArrayBuffer
>
Decrypt data stored in "EncryptedContentInfo" object using parameters
Parameters
• parameters: CryptoEngineDecryptParams
Returns
Promise
<ArrayBuffer
>
Overrides
AbstractCryptoEngine
.decryptEncryptedContentInfo
deriveBits()
deriveBits(
algorithm
,baseKey
,length
):Promise
<ArrayBuffer
>
Parameters
• algorithm: EcdhKeyDeriveParams
| AlgorithmIdentifier
| HkdfParams
| Pbkdf2Params
• baseKey: CryptoKey
• length: number
Returns
Promise
<ArrayBuffer
>
Inherited from
AbstractCryptoEngine
.deriveBits
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
>
Inherited from
AbstractCryptoEngine
.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: Iterable
<KeyUsage
>
Returns
Promise
<CryptoKey
>
Inherited from
AbstractCryptoEngine
.deriveKey
digest()
digest(
algorithm
,data
):Promise
<ArrayBuffer
>
Parameters
• algorithm: AlgorithmIdentifier
• data: BufferSource
Returns
Promise
<ArrayBuffer
>
Inherited from
encrypt()
encrypt(
algorithm
,key
,data
):Promise
<ArrayBuffer
>
Parameters
• algorithm: AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams
• key: CryptoKey
• data: BufferSource
Returns
Promise
<ArrayBuffer
>
Inherited from
encryptEncryptedContentInfo()
encryptEncryptedContentInfo(
parameters
):Promise
<EncryptedContentInfo
>
Specialized function encrypting "EncryptedContentInfo" object using parameters
Parameters
• parameters: CryptoEngineEncryptParams
Returns
Promise
<EncryptedContentInfo
>
Overrides
AbstractCryptoEngine
.encryptEncryptedContentInfo
exportKey()
exportKey(format, key)
exportKey(
format
,key
):Promise
<JsonWebKey
>
Export WebCrypto keys to different formats
Parameters
• format: "jwk"
• key: CryptoKey
Returns
Promise
<JsonWebKey
>
Overrides
AbstractCryptoEngine
.exportKey
exportKey(format, key)
exportKey(
format
,key
):Promise
<ArrayBuffer
>
Parameters
• format: "raw"
| "pkcs8"
| "spki"
• key: CryptoKey
Returns
Promise
<ArrayBuffer
>
Overrides
AbstractCryptoEngine
.exportKey
exportKey(format, key)
exportKey(
format
,key
):Promise
<ArrayBuffer
|JsonWebKey
>
Parameters
• format: string
• key: CryptoKey
Returns
Promise
<ArrayBuffer
| JsonWebKey
>
Overrides
AbstractCryptoEngine.exportKey
fillPublicKeyParameters()
fillPublicKeyParameters(
publicKeyInfo
,signatureAlgorithm
):CryptoEnginePublicKeyParams
Parameters
• publicKeyInfo: PublicKeyInfo
• signatureAlgorithm: AlgorithmIdentifier
Returns
generateKey()
generateKey(algorithm, extractable, keyUsages)
generateKey(
algorithm
,extractable
,keyUsages
):Promise
<CryptoKeyPair
>
Parameters
• algorithm: "Ed25519"
• extractable: boolean
• keyUsages: readonly ("sign"
| "verify"
)[]
Returns
Promise
<CryptoKeyPair
>
Inherited from
AbstractCryptoEngine
.generateKey
generateKey(algorithm, extractable, keyUsages)
generateKey(
algorithm
,extractable
,keyUsages
):Promise
<CryptoKeyPair
>
Parameters
• algorithm: EcKeyGenParams
| RsaHashedKeyGenParams
• extractable: boolean
• keyUsages: KeyUsage
[]
Returns
Promise
<CryptoKeyPair
>
Inherited from
AbstractCryptoEngine
.generateKey
generateKey(algorithm, extractable, keyUsages)
generateKey(
algorithm
,extractable
,keyUsages
):Promise
<CryptoKey
>
Parameters
• algorithm: AesKeyGenParams
| HmacKeyGenParams
| Pbkdf2Params
• extractable: boolean
• keyUsages: KeyUsage
[]
Returns
Promise
<CryptoKey
>
Inherited from
AbstractCryptoEngine
.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
AbstractCryptoEngine
.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
Overrides
AbstractCryptoEngine
.getAlgorithmByOID
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