public override void SetIV(ReadOnlySpan <byte> iv) { var span = State.AsSpan(); var sigma = Sigma32.AsSpan(); sigma.CopyTo(span); var keySpan = MemoryMarshal.Cast <byte, uint>(Key.Span); keySpan.CopyTo(span.Slice(4)); var ivSpan = MemoryMarshal.Cast <byte, uint>(iv); ivSpan.Slice(0, 4).CopyTo(span.Slice(12)); ChaChaRound(State); span.Slice(12).CopyTo(span.Slice(8)); span.Slice(0, 4).CopyTo(span.Slice(4)); sigma.CopyTo(span); State[14] = ivSpan[4]; State[15] = ivSpan[5]; }
public void SetIV(ReadOnlySpan <byte> iv) { var span = State.AsSpan(); var sigma = Sigma32.AsSpan(); sigma.CopyTo(span); var keySpan = MemoryMarshal.Cast <byte, uint>(Key.Span); keySpan.CopyTo(span[4..]);