Table of Contents

Class KeyExpansion

Namespace
Kdf108
Assembly
Kdf108.dll

Describes one SP 800-108 expansion: the iteration mode, the fixed input data, and the counter layout. Use FixedInput(ReadOnlySpan<byte>, ReadOnlySpan<byte>, BitLength) for the conventional Label || 0x00 || Context || [L] fixed input. Instances are immutable.

public sealed class KeyExpansion
Inheritance
KeyExpansion
Inherited Members

Properties

CounterBits

The counter width r in bits, or 0 when the mode runs without a counter.

public int CounterBits { get; }

Property Value

int

Mode

The iteration mode.

public KdfMode Mode { get; }

Property Value

KdfMode

Methods

Counter(ReadOnlySpan<byte>, int, CounterPosition)

Counter mode with the counter before or after the fixed input.

public static KeyExpansion Counter(ReadOnlySpan<byte> fixedInput, int counterBits = 32, CounterPosition position = CounterPosition.BeforeFixedInput)

Parameters

fixedInput ReadOnlySpan<byte>

The fixed input data, typically from FixedInput(ReadOnlySpan<byte>, ReadOnlySpan<byte>, BitLength).

counterBits int

The counter width r: 8, 16, 24, or 32.

position CounterPosition

Where the counter goes.

Returns

KeyExpansion

CounterInMiddle(ReadOnlySpan<byte>, ReadOnlySpan<byte>, int)

Counter mode with the counter in the middle of the fixed input: Before || [i] || After.

public static KeyExpansion CounterInMiddle(ReadOnlySpan<byte> beforeCounter, ReadOnlySpan<byte> afterCounter, int counterBits = 32)

Parameters

beforeCounter ReadOnlySpan<byte>
afterCounter ReadOnlySpan<byte>
counterBits int

Returns

KeyExpansion

DoublePipeline(ReadOnlySpan<byte>, bool, int, IterationCounterPosition)

Double-pipeline iteration mode. A(0) is the fixed input.

public static KeyExpansion DoublePipeline(ReadOnlySpan<byte> fixedInput, bool useCounter = true, int counterBits = 32, IterationCounterPosition position = IterationCounterPosition.AfterIteration)

Parameters

fixedInput ReadOnlySpan<byte>

The fixed input data.

useCounter bool

Whether each PRF input includes the counter [i].

counterBits int

The counter width r: 8, 16, 24, or 32. Ignored without a counter.

position IterationCounterPosition

Where the counter goes relative to A(i).

Returns

KeyExpansion

Feedback(ReadOnlySpan<byte>, ReadOnlySpan<byte>, bool, int, IterationCounterPosition)

Feedback mode. K(0) is iv, which may be empty.

public static KeyExpansion Feedback(ReadOnlySpan<byte> fixedInput, ReadOnlySpan<byte> iv, bool useCounter = true, int counterBits = 32, IterationCounterPosition position = IterationCounterPosition.AfterIteration)

Parameters

fixedInput ReadOnlySpan<byte>

The fixed input data.

iv ReadOnlySpan<byte>

The initial chaining value K(0).

useCounter bool

Whether each PRF input includes the counter [i].

counterBits int

The counter width r: 8, 16, 24, or 32. Ignored without a counter.

position IterationCounterPosition

Where the counter goes relative to K(i-1).

Returns

KeyExpansion