Home Reference Source
import CryptoEngine from 'pkijs/src/CryptoEngine.js'
public class | source

CryptoEngine

Default cryptographic engine for Web Cryptography API

Constructor Summary

Public Constructor
public

constructor(parameters: Object)

Constructor for CryptoEngine class

Member Summary

Public Members
public
public
public

Method Summary

Public Methods
public

convert(inputFormat: string, outputFormat: string, keyData: ArrayBuffer | Object, algorithm: Object, extractable: boolean, keyUsages: Array): Promise

Convert WebCrypto keys between different export formats

public

decrypt(args: *): Promise

Wrapper for standard function "decrypt"

public

Decrypt data stored in "EncryptedContentInfo" object using parameters

public

deriveBits(args: *): Promise

Wrapper for standard function "deriveBits"

public

deriveKey(args: *): Promise

Wrapper for standard function "deriveKey"

public

digest(args: *): Promise

Wrapper for standard function "digest"

public

encrypt(args: *): Promise

Wrapper for standard function "encrypt"

public

Specialized function encrypting "EncryptedContentInfo" object using parameters

public

exportKey(format: string, key: Object): Promise

Export WebCrypto keys to different formats

public

fillPublicKeyParameters(publicKeyInfo: *, signatureAlgorithm: *): *

public

generateKey(args: *): Promise

Wrapper for standard function "generateKey"

public

Get WebCrypto algorithm by wel-known OID

public

getAlgorithmParameters(algorithmName: string, operation: string): *

Get default algorithm parameters for each kind of operation

public

Getting hash algorithm by signature algorithm

public

Get OID for each specific algorithm

public

getPublicKey(publicKeyInfo: *, signatureAlgorithm: *, parameters: undefined): *

public

Initialize input Uint8Array by random values (with help from current "crypto engine")

public

getSignatureParameters(privateKey: Object, hashAlgorithm: string): Promise<T> | Promise

Get signature parameters by analyzing private key algorithm

public

importKey(format: string, keyData: ArrayBuffer | Uint8Array, algorithm: Object, extractable: boolean, keyUsages: Array): Promise

Import WebCrypto keys from different formats

public

sign(args: *): Promise

Wrapper for standard function "sign"

public

signWithPrivateKey(data: ArrayBuffer, privateKey: Object, parameters: Object): Promise<T> | Promise

Sign data with pre-defined private key

public

Stamping (signing) data using algorithm simular to HMAC

public

unwrapKey(args: *): Promise

Wrapper for standard function "unwrapKey"

public

verify(args: *): Promise

Wrapper for standard function "verify"

public

verifyDataStampedWithPassword(parameters: *): *

public

verifyWithPublicKey(data: *, signature: *, publicKeyInfo: *, signatureAlgorithm: *, shaAlgorithm: undefined): *

public

wrapKey(args: *): Promise

Wrapper for standard function "wrapKey"

Public Constructors

public constructor(parameters: Object) source

Constructor for CryptoEngine class

Params:

NameTypeAttributeDescription
parameters Object
  • optional
  • default: {}

Public Members

public crypto: Object source

public name: string source

public subtle: Object source

Public Methods

public convert(inputFormat: string, outputFormat: string, keyData: ArrayBuffer | Object, algorithm: Object, extractable: boolean, keyUsages: Array): Promise source

Convert WebCrypto keys between different export formats

Params:

NameTypeAttributeDescription
inputFormat string
outputFormat string
keyData ArrayBuffer | Object
algorithm Object
extractable boolean
keyUsages Array

Return:

Promise

public decrypt(args: *): Promise source

Wrapper for standard function "decrypt"

Params:

NameTypeAttributeDescription
args *

Return:

Promise

public decryptEncryptedContentInfo(parameters: *): Promise source

Decrypt data stored in "EncryptedContentInfo" object using parameters

Params:

NameTypeAttributeDescription
parameters *

Return:

Promise

public deriveBits(args: *): Promise source

Wrapper for standard function "deriveBits"

Params:

NameTypeAttributeDescription
args *

Return:

Promise

public deriveKey(args: *): Promise source

Wrapper for standard function "deriveKey"

Params:

NameTypeAttributeDescription
args *

Return:

Promise

public digest(args: *): Promise source

Wrapper for standard function "digest"

Params:

NameTypeAttributeDescription
args *

Return:

Promise

public encrypt(args: *): Promise source

Wrapper for standard function "encrypt"

Params:

NameTypeAttributeDescription
args *

Return:

Promise

public encryptEncryptedContentInfo(parameters: Object): Promise source

Specialized function encrypting "EncryptedContentInfo" object using parameters

Params:

NameTypeAttributeDescription
parameters Object

Return:

Promise

public exportKey(format: string, key: Object): Promise source

Export WebCrypto keys to different formats

Params:

NameTypeAttributeDescription
format string
key Object

Return:

Promise

public fillPublicKeyParameters(publicKeyInfo: *, signatureAlgorithm: *): * source

Params:

NameTypeAttributeDescription
publicKeyInfo *
signatureAlgorithm *

Return:

*

public generateKey(args: *): Promise source

Wrapper for standard function "generateKey"

Params:

NameTypeAttributeDescription
args *

Return:

Promise

public getAlgorithmByOID(oid: string): Object source

Get WebCrypto algorithm by wel-known OID

Params:

NameTypeAttributeDescription
oid string

well-known OID to search for

Return:

Object

public getAlgorithmParameters(algorithmName: string, operation: string): * source

Get default algorithm parameters for each kind of operation

Params:

NameTypeAttributeDescription
algorithmName string

Algorithm name to get common parameters for

operation string

Kind of operation: "sign", "encrypt", "generatekey", "importkey", "exportkey", "verify"

Return:

*

public getHashAlgorithm(signatureAlgorithm: AlgorithmIdentifier): string source

Getting hash algorithm by signature algorithm

Params:

NameTypeAttributeDescription
signatureAlgorithm AlgorithmIdentifier

Signature algorithm

Return:

string

public getOIDByAlgorithm(algorithm: Object): string source

Get OID for each specific algorithm

Params:

NameTypeAttributeDescription
algorithm Object

Return:

string

public getPublicKey(publicKeyInfo: *, signatureAlgorithm: *, parameters: undefined): * source

Params:

NameTypeAttributeDescription
publicKeyInfo *
signatureAlgorithm *
parameters undefined
  • optional
  • default: undefined

Return:

*

public getRandomValues(view: Uint8Array): * source

Initialize input Uint8Array by random values (with help from current "crypto engine")

Params:

NameTypeAttributeDescription
view Uint8Array
  • nullable: false

Return:

*

public getSignatureParameters(privateKey: Object, hashAlgorithm: string): Promise<T> | Promise source

Get signature parameters by analyzing private key algorithm

Params:

NameTypeAttributeDescription
privateKey Object

The private key user would like to use

hashAlgorithm string
  • optional
  • default: "SHA-1"

Hash algorithm user would like to use

Return:

Promise<T> | Promise

public importKey(format: string, keyData: ArrayBuffer | Uint8Array, algorithm: Object, extractable: boolean, keyUsages: Array): Promise source

Import WebCrypto keys from different formats

Params:

NameTypeAttributeDescription
format string
keyData ArrayBuffer | Uint8Array
algorithm Object
extractable boolean
keyUsages Array

Return:

Promise

public sign(args: *): Promise source

Wrapper for standard function "sign"

Params:

NameTypeAttributeDescription
args *

Return:

Promise

public signWithPrivateKey(data: ArrayBuffer, privateKey: Object, parameters: Object): Promise<T> | Promise source

Sign data with pre-defined private key

Params:

NameTypeAttributeDescription
data ArrayBuffer

Data to be signed

privateKey Object

Private key to use

parameters Object

Parameters for used algorithm

Return:

Promise<T> | Promise

public stampDataWithPassword(parameters: Object): Promise<T> | Promise source

Stamping (signing) data using algorithm simular to HMAC

Params:

NameTypeAttributeDescription
parameters Object

Return:

Promise<T> | Promise

public unwrapKey(args: *): Promise source

Wrapper for standard function "unwrapKey"

Params:

NameTypeAttributeDescription
args *

Return:

Promise

public verify(args: *): Promise source

Wrapper for standard function "verify"

Params:

NameTypeAttributeDescription
args *

Return:

Promise

public verifyDataStampedWithPassword(parameters: *): * source

Params:

NameTypeAttributeDescription
parameters *

Return:

*

public verifyWithPublicKey(data: *, signature: *, publicKeyInfo: *, signatureAlgorithm: *, shaAlgorithm: undefined): * source

Params:

NameTypeAttributeDescription
data *
signature *
publicKeyInfo *
signatureAlgorithm *
shaAlgorithm undefined
  • optional
  • default: undefined

Return:

*

public wrapKey(args: *): Promise source

Wrapper for standard function "wrapKey"

Params:

NameTypeAttributeDescription
args *

Return:

Promise