Options
All
  • Public
  • Public/Protected
  • All
Menu

Class responsible for encryption of streams of data.

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

isFinished

isFinished: boolean = false

Indicates whether the final method has been called.

Protected seqCipher

seqCipher: WrappedVirgilSeqCipher

Instance of VirgilSeqCipher native class.

Methods

dispose

  • dispose(): void

final

  • final(dispose?: boolean): Buffer
  • Returns any remaining encrypted or decrypted data depending on current mode. Once final has been called, this instance cannot be used to encrypt or decrypt data, attempts to call any method including final will result in an error being thrown. This method also automatically calls dispose.

    Parameters

    • Default value dispose: boolean = true

      Optional. Indicating whether to automatically free the memory occupied by internal seqSigner object in the browser. Default is true. false is used to perform operations in inherited classes. If you pass false as an argument you should call dispose method manually.

      In node.js this argument is ignored because the memory will be freed by the garbage collector.

    Returns Buffer

start

  • start(): Buffer
  • Starts sequential encryption process following the algorithm below:

    1. Generates random AES-256 key - KEY1
    2. Generates ephemeral keypair for each recipient public key
    3. Uses Diffie-Hellman to obtain shared secret with each recipient public key & ephemeral private key
    4. Computes KDF to obtain AES-256 key - KEY2 - from shared secret for each recipient
    5. Encrypts KEY1 with KEY2 using AES-256-CBC for each recipient
    6. Returns the ASN.1 structure containing the encrypted KEY2 for each recipient public key (content_info)

    The data passed to the VirgilStreamCipher.update method after this method is called will be encrypted with the KEY1

    Returns Buffer

update

  • update(data: Data, encoding?: StringEncoding): Buffer
  • Encrypt of decrypt chunk of data based on current mode.

    Parameters

    • data: Data

      Chunk of data to encrypt \ decrypt

    • Default value encoding: StringEncoding = "utf8"

      If data is a string, specifies its encoding, otherwise is ignored. Default is 'utf8'.

    Returns Buffer

    • Encrypted or decrypted chunk