Skip to content

KeySizeFloors Class

The smallest keys RFC 7518 permits, and the section stating each floor, so a refusal can cite the paragraph that refused.

C#
public static class KeySizeFloors

Inheritance System.Object → KeySizeFloors

Fields

KeySizeFloors.MinimumRsaKeyBits Field

The smallest RSA modulus RFC 7518 permits. Four sections state it, one per family: Section 3.3 and Section 3.5 for signing, Section 4.2 and Section 4.3 for key encryption. Almost the same words - 3.3 and 4.3 govern several algorithms and say "these", 3.5 and 4.2 govern one and say "this". One number here, so the sites that enforce it cannot drift apart.

C#
public const int MinimumRsaKeyBits = 2048;

Field Value

System.Int32

Methods

KeySizeFloors.RsaSectionFor(string) Method

The RFC 7518 section that carries the key-size requirement for algorithm.

C#
public static string RsaSectionFor(string algorithm);

Parameters

algorithm System.String

Returns

System.String

Exceptions

System.ArgumentException
The algorithm is not one this library enforces a floor for.

Remarks

A refusal has to send the operator to the paragraph that refused them. Sections 3 and 4 are container headings and state no size requirement at all, so citing either leaves the reader looking at a table of algorithm names and no MUST - which reads as the library inventing the rule.

KeySizeFloors.RsaSectionForOrNothing(string) Method

The WHOLE citation phrase, ready to drop into a refusal message - "per RFC 7518 Section 3.3", or "for RSA signatures" when the algorithm has no section of its own.

C#
public static string RsaSectionForOrNothing(string algorithm);

Parameters

algorithm System.String

Returns

System.String

Remarks

Two differences from RsaSectionFor(string), and both matter at a call site. This one never throws for a non-null algorithm, because an unknown algorithm must not replace the refusal the operator was about to read with a complaint about the citation - and it is reachable, since an RSA key carrying no alg resolves to SigningAlgorithms.None. And this one carries the words "per RFC 7518" itself, where RsaSectionFor(string) returns the bare section and leaves them to the caller. Interpolate this one into a sentence that writes them too and the message says them twice.