2017 © Pedro Peláez
 

library aead-chacha20-poly1305

RFC 7539 ChaCha20/Poly1305 AEAD construction

image

leigh/aead-chacha20-poly1305

RFC 7539 ChaCha20/Poly1305 AEAD construction

  • Friday, February 5, 2016
  • by lt
  • Repository
  • 0 Watchers
  • 5 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 3 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

RFC 7539 ChaCha20/Poly1305 AEAD construction

This library contains a pure PHP implementation of the RFC 7539 ChaCha20/Poly1305 AEAD construction., (*1)

Usage:

Remember that a nonce must not be used more than once for a particular key, (*2)

The library contains both one-shot functions for small amounts of data, and methods for processing streams of information without consuming large amounts of memory., (*3)

One-shot functions, (*4)

// Encrypt and produce a ciphertext and tag.
list($ciphertext, $tag) = \ChaCha20Poly1305\encrypt($key, $nonce, $aad, $plaintext);

// Decrypt and produce a plaintext, throw an exception if the tag is invalid.
$plaintext = \ChaCha20Poly1305\decrypt($key, $nonce, $aad, $plaintext, $tag);

// Verify without decryption, return true/false depending the tag being valid.
$valid = \ChaCha20Poly1305\verify($key, $nonce, $aad, $plaintext, $tag);

The Context object maintains the current state of all of the moving parts so they can be used for streaming. A separate context is needed for each stream., (*5)

Stream methods, (*6)

$cipher = new \ChaCha20Poly1305\Cipher;
$encCtx = $cipher->init($key, $nonce);

$cipher->aad($encCtx, $additionalData);
$cipher->aad($encCtx, $moreData);

$ciphertext = $cipher->encrypt($encCtx, $plaintext);
$ciphertext .= $cipher->encrypt($encCtx, $morePlaintext);

$tag = $cipher->finish($encCtx);

// Or

$cipher = new \ChaCha20Poly1305\Cipher;
$decCtx = $cipher->init($key, $nonce);

$cipher->aad($decCtx, $additionalData);
$cipher->aad($decCtx, $moreData);

// Could also $cipher->verify() to skip decryption overhead.
$plaintext = $cipher->decrypt($decCtx, $ciphertext);
$plaintext .= $cipher->decrypt($decCtx, $moreCiphertext);

try {
    $cipher->finish($decCtx, $tag);
}
catch (\ChaCha20Poly1305\AuthenticationException $e) {
    // Tag was not valid
}

The Versions

05/02 2016

0.2.1

0.2.1.0 https://github.com/lt/PHP-AEAD-ChaCha20-Poly1305

RFC 7539 ChaCha20/Poly1305 AEAD construction

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication security encryption cipher mac aead authenticated

14/01 2016

dev-master

9999999-dev https://github.com/lt/PHP-AEAD-ChaCha20-Poly1305

RFC 7539 ChaCha20/Poly1305 AEAD construction

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication security encryption cipher mac aead authenticated

14/01 2016

0.2.0

0.2.0.0 https://github.com/lt/PHP-AEAD-ChaCha20-Poly1305

RFC 7539 ChaCha20/Poly1305 AEAD construction

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication security encryption cipher mac aead authenticated

21/12 2015

0.1.0

0.1.0.0 https://github.com/lt/PHP-AEAD-ChaCha20-Poly1305

RFC 7539 ChaCha20/Poly1305 AEAD construction

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication security encryption cipher mac aead authenticated