cryptal  latest
Cryptography Abstraction Layer
fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20Openssh Class Reference
+ Inheritance diagram for fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20Openssh:

Public Member Functions

 __construct (CipherEnum $cipher, ModeEnum $mode, PaddingInterface $padding, $key, $tagLength=self::DEFAULT_TAG_LENGTH)
 
 decrypt ($iv, $data, $tag=null, $aad= '')
 
 encrypt ($iv, $data, &$tag=null, $aad= '')
 
 getIVSize ()
 
- Public Member Functions inherited from fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20
 __construct (CipherEnum $cipher, ModeEnum $mode, PaddingInterface $padding, $key, $tagLength=self::DEFAULT_TAG_LENGTH)
 
 decrypt ($iv, $data, $tag=null, $aad= '')
 
 encrypt ($iv, $data, &$tag=null, $aad= '')
 
 getBlockSize ()
 
 getCipher ()
 
 getIVSize ()
 
 getKey ()
 

Protected Attributes

 $cipher
 
 $header
 Header encryptor.
 
 $key
 
 $main
 Main encryptor.
 
- Protected Attributes inherited from fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20
 $cipher
 
 $key
 Secret key used to encrypt/decrypt data.
 
 $tagLength
 Tag length in bytes; 16 when AEAD is enabled, 0 otherwise.
 

Additional Inherited Members

- Public Attributes inherited from fpoirotte\Cryptal\Implementers\CryptoInterface
const DEFAULT_TAG_LENGTH = 16
 
- Protected Member Functions inherited from fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20
 basicXcrypt ($plain, $iv, $counter=0)
 
 block ($iv, $counter)
 
- Static Protected Member Functions inherited from fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20
static quarterRound (&$a, &$b, &$c, &$d)
 

Detailed Description

ChaCha20 block cipher with AEAD (OpenSSH variante).

Note
This class implements the AEAD construction defined in http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.chacha20poly1305.
See also
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.chacha20poly1305

Definition at line 25 of file ChaCha20Openssh.php.

Constructor & Destructor Documentation

fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20Openssh::__construct ( CipherEnum  $cipher,
ModeEnum  $mode,
PaddingInterface  $padding,
  $key,
  $tagLength = self::DEFAULT_TAG_LENGTH 
)

Construct a new encryption/decryption context.

Parameters
CipherEnum$cipherCipher algorithm to use.
ModeEnum$modeCryptography mode to apply to the cipher.
PaddingInterface$paddingPadding scheme to use.
string$keySecret key used for encryption/decryption.
int$tagLengthLength (in bytes) of the authentication tags to generate.
Note
The $tagLength parameter is unused unless the supplied mode supports Authenticated Encryption with Additional Data (AEAD).

Implements fpoirotte\Cryptal\Implementers\CryptoInterface.

Definition at line 36 of file ChaCha20Openssh.php.

References fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20\$tagLength.

Member Function Documentation

fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20Openssh::decrypt (   $iv,
  $data,
  $tag = null,
  $aad = '' 
)

Decrypt some data.

Parameters
string$ivInitialization Vector for the operation.
string$dataData to decrypt.
string$tagAuthentication tag.
string$aadAdditional authenticated data.
Return values
stringPlaintext (decrypted data).
Note
The $iv parameter is unused for some modes of operations (namely MODE_ECB). Still, this parameter is mandatory and an empty string may be passed for those modes.
An exception is thrown in case decryption fails, or the given authentication tag is incorrect (AEAD-only).
The $aad & $tag parameters are unused unless the required mode supports Authenticated Encryption with Additional Data (AEAD). MODE_GCM & MODE_EAX are known to support AEAD.

Implements fpoirotte\Cryptal\Implementers\CryptoInterface.

Definition at line 92 of file ChaCha20Openssh.php.

References fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20Openssh\getIVSize(), and fpoirotte\Cryptal\Implementers\AbstractMac\mac().

fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20Openssh::encrypt (   $iv,
  $data,
$tag = null,
  $aad = '' 
)

Encrypt some data.

Parameters
string$ivInitialization Vector for the operation.
string$dataData to encrypt.
string$tagVariable where the generated tag will be stored.
string$aadAdditional authenticated data.
Return values
stringCiphertext (encrypted data).
Note
The $iv parameter is unused for some modes of operations (namely MODE_ECB). Still, this parameter is mandatory and an empty string may be passed for those modes.
An exception is thrown in case encryption fails.
The $aad & $tag parameters are unused unless the required mode supports Authenticated Encryption with Additional Data (AEAD). MODE_GCM & MODE_EAX are known to support AEAD.

Implements fpoirotte\Cryptal\Implementers\CryptoInterface.

Definition at line 69 of file ChaCha20Openssh.php.

References fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20Openssh\getIVSize(), and fpoirotte\Cryptal\Implementers\AbstractMac\mac().

fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20Openssh::getIVSize ( )

Get the size of the Initialization Vector, in bytes.

Return values
intRequired size for the Initialization Vector. Might be zero in case the given cipher/mode combination does not require an initialization vector.

Implements fpoirotte\Cryptal\Implementers\CryptoInterface.

Definition at line 118 of file ChaCha20Openssh.php.

Referenced by fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20Openssh\decrypt(), and fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20Openssh\encrypt().


The documentation for this class was generated from the following file: