Module: crypto/crypto

Provides functions for asymmetric encryption and decryption as well as key generation and parameter handling for all public-key cryptosystems.

Source:

Requires

Methods

(async, static) generateParams(algo, bits, oid) → {Array}

Generate algorithm-specific key parameters

Parameters:
Name Type Description
algo String

The public key algorithm

bits Integer

Bit length for RSA keys

oid module:type/oid

Object identifier for ECC keys

Source:
Returns:

The array of parameters

Type
Array

(async, static) generateSessionKey(algo) → {Uint8Array}

Generating a session key for the specified symmetric algorithm See RFC 4880 9.2 for algorithms.

Parameters:
Name Type Description
algo module:enums.symmetric

Symmetric encryption algorithm

Source:
Returns:

Random bytes as a string to be used as a key

Type
Uint8Array

(static) getEncSessionKeyParamTypes(algo) → {Array.<String>}

Returns the types comprising the encrypted session key of an algorithm

Parameters:
Name Type Description
algo String

The public key algorithm

Source:
Returns:

The array of types

Type
Array.<String>

(async, static) getPrefixRandom(algo) → {Uint8Array}

Generates a random byte prefix for the specified algorithm See RFC 4880 9.2 for algorithms.

Parameters:
Name Type Description
algo module:enums.symmetric

Symmetric encryption algorithm

Source:
Returns:

Random bytes with length equal to the block size of the cipher

Type
Uint8Array

(static) getPrivKeyParamTypes(algo) → {Array.<String>}

Returns the types comprising the private key of an algorithm

Parameters:
Name Type Description
algo String

The public key algorithm

Source:
Returns:

The array of types

Type
Array.<String>

(static) getPubKeyParamTypes(algo) → {Array.<String>}

Returns the types comprising the public key of an algorithm

Parameters:
Name Type Description
algo String

The public key algorithm

Source:
Returns:

The array of types

Type
Array.<String>

(async, static) publicKeyDecrypt(algo, key_params, data_params, fingerprint) → {module:type/mpi}

Decrypts data using specified algorithm and private key parameters. See RFC 4880 9.1 for public key algorithms.

Parameters:
Name Type Description
algo module:enums.publicKey

Public key algorithm

key_params Array.<(module:type/mpi|module:type/oid|module:type/kdf_params)>

Algorithm-specific public, private key parameters

data_params Array.<(module:type/mpi|module:type/ecdh_symkey)>

encrypted session key parameters

fingerprint String

Recipient fingerprint

Source:
Returns:

An MPI containing the decrypted data

Type
module:type/mpi

(async, static) publicKeyEncrypt(algo, pub_params, data, fingerprint) → {Array.<(module:type/mpi|module:type/ecdh_symkey)>}

Encrypts data using specified algorithm and public key parameters. See RFC 4880 9.1 for public key algorithms.

Parameters:
Name Type Description
algo module:enums.publicKey

Public key algorithm

pub_params Array.<(module:type/mpi|module:type/oid|module:type/kdf_params)>

Algorithm-specific public key parameters

data module:type/mpi

Data to be encrypted as MPI

fingerprint String

Recipient fingerprint

Source:
Returns:

encrypted session key parameters

Type
Array.<(module:type/mpi|module:type/ecdh_symkey)>