Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @stablelib/xsalsa20

Index

Functions

  • hsalsa(key: Uint8Array, src: Uint8Array, dst: Uint8Array): Uint8Array
  • HSalsa20 is a one-way function used in XSalsa20 to extend nonce, and in NaCl to hash X25519 shared keys. It takes 32-byte key and 16-byte src and writes 32-byte result into dst and returns it.

    Parameters

    • key: Uint8Array
    • src: Uint8Array
    • dst: Uint8Array

    Returns Uint8Array

  • stream(key: Uint8Array, nonce: Uint8Array, dst: Uint8Array, nonceInplaceCounterLength?: number): Uint8Array
  • Generate Salsa20/20 stream for the given 32-byte key and 24-byte nonce and write it into dst and return it.

    Never use the same key and nonce to generate more than one stream.

    stream is like streamXOR with all-zero src.

    Parameters

    • key: Uint8Array
    • nonce: Uint8Array
    • dst: Uint8Array
    • nonceInplaceCounterLength: number = 0

    Returns Uint8Array

  • streamXOR(key: Uint8Array, nonce: Uint8Array, src: Uint8Array, dst: Uint8Array, nonceInplaceCounterLength?: number): Uint8Array
  • Encrypt src with Salsa20/20 stream generated for the given 32-byte key and 24-byte and write the result into dst and return it.

    dst and src may be the same, but otherwise must not overlap.

    Never use the same key and nonce to encrypt more than one message.

    Parameters

    • key: Uint8Array
    • nonce: Uint8Array
    • src: Uint8Array
    • dst: Uint8Array
    • nonceInplaceCounterLength: number = 0

    Returns Uint8Array

Generated using TypeDoc