Recommend this page to a friend! |
Classes of Jose Luis Lucas | PHP ChaCha20-Poly1305 | README.md | Download |
|
DownloadAEAD_CHACHA20_POLY1305Implemented from rtf8439 https://tools.ietf.org/html/rfc7539#section-2.5 https://tools.ietf.org/html/rfc8439 The Poly1305-AES message-authentication codehttp://cr.yp.to/mac/poly1305-20050329.pdf Adapted from https://asecuritysite.com/encryption/poly1305 USAGE$x = new AEAD_CHACHA20_POLY1305; $poly_mac = $x->poly($r_key , $s_key , $msg) o K_LEN (key length) is 32 octets. o P_MAX (maximum size of the plaintext) is 274,877,906,880 bytes, or
o A_MAX (maximum size of the associated data) is set to 2^64-1
o N_MIN = N_MAX = 12 octets. o C_MAX = P_MAX + tag length = 274,877,906,896 octets. for the nonce
32-bit fixed-common part = Constant = '07000000' from rtf8439 $cipher = $x->chacha20_aead_encrypt($aad, $Key, $Iv, '07000000', $plaintext)
$plaintext = $x->chacha20_aead_decrypt($aad, $Key, $Iv, '07000000', $cipher)
TEST VECTORS$x->test_poly1305(); $x->test_Chacha(); $x->test_AEAD_CHACHA20_POLY1305();
LicenseThis code is placed in the public domain. |