/// <summary> /// Prepares a <see cref="Poly1305"/> instance using <see cref="ChaCha20"/> /// and Counter=0 to generate the corresponding key. /// </summary> /// <param name="Key">Key</param> /// <param name="Nonce">Nonce</param> /// <returns>Authenticator</returns> public static Poly1305 FromChaCha20(byte[] Key, byte[] Nonce) { ChaCha20 Cipher = new ChaCha20(Key, 0, Nonce); byte[] Key2 = Cipher.GetBytes(32); return(new Poly1305(Key2)); }
/// <summary> /// Class implementing the authenticated encryption with additional /// data algorithm AEAD_CHACHA20_POLY1305. /// </summary> /// <param name="Key">Key</param> /// <param name="Nonce">Nonce value</param> public AeadChaCha20Poly1305(byte[] Key, byte[] Nonce) { this.chaCha20 = new ChaCha20(Key, 0, Nonce); this.poly1305 = new Poly1305(this.chaCha20.GetBytes(32)); this.chaCha20.NextBlock(); }