[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/vendor/phpseclib/phpseclib/phpseclib/Crypt/ -> Salsa20.php (summary)

Pure-PHP implementation of Salsa20. PHP version 5

Author: Jim Wigginton
Copyright: 2019 Jim Wigginton
License: http://www.opensource.org/licenses/mit-license.html MIT License
Link: http://phpseclib.sourceforge.net
File Size: 526 lines (15 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Salsa20:: (17 methods):
  usesNonce()
  setKey()
  setNonce()
  setCounter()
  createPoly1305Key()
  setup()
  setupKey()
  encrypt()
  decrypt()
  encryptBlock()
  decryptBlock()
  crypt()
  leftRotate()
  quarterRound()
  doubleRound()
  salsa20()
  poly1305()


Class: Salsa20  - X-Ref

Pure-PHP implementation of Salsa20.

usesNonce()   X-Ref
Salsa20 uses a nonce

return: bool

setKey($key)   X-Ref
Sets the key.

param: string $key

setNonce($nonce)   X-Ref
Sets the nonce.

param: string $nonce

setCounter($counter)   X-Ref
Sets the counter.

param: int $counter

createPoly1305Key()   X-Ref
Creates a Poly1305 key using the method discussed in RFC8439

See https://tools.ietf.org/html/rfc8439#section-2.6.1

setup()   X-Ref
Setup the self::ENGINE_INTERNAL $engine

(re)init, if necessary, the internal cipher $engine

_setup() will be called each time if $changed === true
typically this happens when using one or more of following public methods:

- setKey()

- setNonce()

- First run of encrypt() / decrypt() with no init-settings

see: self::setKey()
see: self::setNonce()
see: self::disableContinuousBuffer()

setupKey()   X-Ref
Setup the key (expansion)


encrypt($plaintext)   X-Ref
Encrypts a message.

return: string $ciphertext
param: string $plaintext
see: \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
see: self::crypt()

decrypt($ciphertext)   X-Ref
Decrypts a message.

$this->decrypt($this->encrypt($plaintext)) == $this->encrypt($this->encrypt($plaintext)).
At least if the continuous buffer is disabled.

return: string $plaintext
param: string $ciphertext
see: \phpseclib3\Crypt\Common\SymmetricKey::encrypt()
see: self::crypt()

encryptBlock($in)   X-Ref
Encrypts a block

param: string $in

decryptBlock($in)   X-Ref
Decrypts a block

param: string $in

crypt($text, $mode)   X-Ref
Encrypts or decrypts a message.

return: string $text
param: string $text
param: int $mode
see: self::encrypt()
see: self::decrypt()

leftRotate($x, $n)   X-Ref
Left Rotate

return: int
param: int $x
param: int $n

quarterRound(&$a, &$b, &$c, &$d)   X-Ref
The quarterround function

param: int $a
param: int $b
param: int $c
param: int $d

doubleRound(&$x0, &$x1, &$x2, &$x3, &$x4, &$x5, &$x6, &$x7, &$x8, &$x9, &$x10, &$x11, &$x12, &$x13, &$x14, &$x15)   X-Ref
The doubleround function

param: int $x0 (by reference)
param: int $x1 (by reference)
param: int $x2 (by reference)
param: int $x3 (by reference)
param: int $x4 (by reference)
param: int $x5 (by reference)
param: int $x6 (by reference)
param: int $x7 (by reference)
param: int $x8 (by reference)
param: int $x9 (by reference)
param: int $x10 (by reference)
param: int $x11 (by reference)
param: int $x12 (by reference)
param: int $x13 (by reference)
param: int $x14 (by reference)
param: int $x15 (by reference)

salsa20($x)   X-Ref
The Salsa20 hash function function

param: string $x

poly1305($ciphertext)   X-Ref
Calculates Poly1305 MAC

return: string
param: string $ciphertext
see: self::decrypt()
see: self::encrypt()