Concat

Purpose

Sometimes it is necessary to concatenate data together to form an input or output. This is represented via the || symbol in pseudocode.

For example, an AEAD ciphertext is usually a ciphertext concatenated with a tag.

Usage

Concat

Fills a span with the concatenation of two spans.

Spans.Concat(Span<byte> buffer, ReadOnlySpan<byte> a, ReadOnlySpan<byte> b)

Exceptions

ArgumentOutOfRangeException

buffer has a length not equal to a.Length + b.Length.

ArgumentOutOfRangeException

a has a length not equal to buffer.Length - b.Length.

ArgumentOutOfRangeException

b has a length not equal to buffer.Length - a.Length.

Concat

Fills a span with the concatenation of three spans.

Spans.Concat(Span<byte> buffer, ReadOnlySpan<byte> a, ReadOnlySpan<byte> b, ReadOnlySpan<byte> c)

Exceptions

ArgumentOutOfRangeException

buffer has a length not equal to a.Length + b.Length + c.Length.

ArgumentOutOfRangeException

a has a length not equal to buffer.Length - b.Length - c.Length.

ArgumentOutOfRangeException

b has a length not equal to buffer.Length - a.Length - c.Length.

ArgumentOutOfRangeException

c has a length not equal to buffer.Length - a.Length - b.Length.

Concat

Fills a span with the concatenation of four spans.

Spans.Concat(Span<byte> buffer, ReadOnlySpan<byte> a, ReadOnlySpan<byte> b, ReadOnlySpan<byte> c, ReadOnlySpan<byte> d)

Exceptions

ArgumentOutOfRangeException

buffer has a length not equal to a.Length + b.Length + c.Length + d.Length.

ArgumentOutOfRangeException

a has a length not equal to buffer.Length - b.Length - c.Length - d.Length.

ArgumentOutOfRangeException

b has a length not equal to buffer.Length - a.Length - c.Length - d.Length.

ArgumentOutOfRangeException

c has a length not equal to buffer.Length - a.Length - b.Length - d.Length.

ArgumentOutOfRangeException

d has a length not equal to buffer.Length - a.Length - b.Length - c.Length.

Concat

Fills a span with the concatenation of five spans.

Spans.Concat(Span<byte> buffer, ReadOnlySpan<byte> a, ReadOnlySpan<byte> b, ReadOnlySpan<byte> c, ReadOnlySpan<byte> d, ReadOnlySpan<byte> e)

Exceptions

ArgumentOutOfRangeException

buffer has a length not equal to a.Length + b.Length + c.Length + d.Length + e.Length.

ArgumentOutOfRangeException

a has a length not equal to buffer.Length - b.Length - c.Length - d.Length - e.Length.

ArgumentOutOfRangeException

b has a length not equal to buffer.Length - a.Length - c.Length - d.Length - e.Length.

ArgumentOutOfRangeException

c has a length not equal to buffer.Length - a.Length - b.Length - d.Length - e.Length.

ArgumentOutOfRangeException

d has a length not equal to buffer.Length - a.Length - b.Length - c.Length - e.Length.

ArgumentOutOfRangeException

e has a length not equal to buffer.Length - a.Length - b.Length - c.Length - d.Length.

Concat

Fills a span with the concatenation of six spans.

Spans.Concat(Span<byte> buffer, ReadOnlySpan<byte> a, ReadOnlySpan<byte> b, ReadOnlySpan<byte> c, ReadOnlySpan<byte> d, ReadOnlySpan<byte> e, ReadOnlySpan<byte> f)

Exceptions

ArgumentOutOfRangeException

buffer has a length not equal to a.Length + b.Length + c.Length + d.Length + e.Length + f.Length.

ArgumentOutOfRangeException

a has a length not equal to buffer.Length - b.Length - c.Length - d.Length - e.Length - f.Length.

ArgumentOutOfRangeException

b has a length not equal to buffer.Length - a.Length - c.Length - d.Length - e.Length - f.Length.

ArgumentOutOfRangeException

c has a length not equal to buffer.Length - a.Length - b.Length - d.Length - e.Length - f.Length.

ArgumentOutOfRangeException

d has a length not equal to buffer.Length - a.Length - b.Length - c.Length - e.Length - f.Length.

ArgumentOutOfRangeException

e has a length not equal to buffer.Length - a.Length - b.Length - c.Length - d.Length - f.Length.

ArgumentOutOfRangeException

f has a length not equal to buffer.Length - a.Length - b.Length - c.Length - d.Length - e.Length.

Notes

There is unfortunately no Concat() function for arrays or spans in .NET, and there is not even a Span<T>.CopyTo(Span<T> destination, int index). This class fills that gap.

Last updated