encrypt/aead_xchacha20_poly1305
library
Classes
-
AEADxChaCha20poly1305
-
-
AEADxChaCha20poly1305withPrefix
-
With AEAD XChaCha20 Poly1305, regardless whether with or without prefix, the plaintext is first encrypted with XChaCha20. From constants and the iv
(Initialization Vector) the nonce for the one time key is created. An onetimekey for Poly1305 is created from the nonce and the secret key.
The information for the MAC is created as follows: The AAD is incremented to a length divisible by 32, the Encrypted Text is incremented to a length
divisible by 32, the length of the original AAD is converted to hexadecimal and the length is incremented until it is divisible by 16, the length of
the original Encrypted Text is converted to hexadecimal and incremented to a length until it is divisible by 16. These four values and the onetimekey
are used to create a tag.
During decryption, a tag is also created and compared with the tag from encryption. If this should deviate, then this is regarded as wrong and/or
manipulated, since with the same values also the same tag must be computed.