/// <summary> /// Creates a symmetric decryptor object with the current Key property and one-time use state parameter. /// </summary> /// <param name="key">The secret that will be used during decryption.</param> /// <param name="nonce">The one-time use state parameter.</param> public override ICryptoTransform CreateDecryptor(byte[] key, byte[] nonce) { var ivLow = m_iv; var ivHigh = BinaryPrimitives.ReadUInt32LittleEndian(nonce.AsSpan(0, ChaChaTransform.WordLength)); return(ChaChaTransform.New(Initialize(key, nonce, ivLow), BitwiseHelpers.ConcatBits(ivHigh, ivLow), 20U)); }
/// <summary> /// Creates a symmetric decryptor object with the current Key property and one-time use state parameter. /// </summary> /// <param name="key">The secret that will be used during decryption.</param> /// <param name="nonce">The one-time use state parameter.</param> public override ICryptoTransform CreateDecryptor(byte[] key, byte[] nonce) { var ivLow = ((uint)BitwiseHelpers.ExtractLow(m_iv)); return(ChaChaTransform.New(Initialize(key, nonce, ivLow), m_iv, 20U)); }