Class ResponseKeyDerivation
- Namespace
- Tessio.Verifier.AspNetCore
- Assembly
- Tessio.Verifier.AspNetCore.dll
Derives a P-256 response-encryption key from a master secret and a salt, so any instance holding the master can recreate the key for a request from its salt alone, and no private key is stored anywhere.
public static class ResponseKeyDerivation
- Inheritance
-
ResponseKeyDerivation
- Inherited Members
Remarks
HKDF-SHA256 (RFC 5869) expands the master and salt into 48 bytes, which are reduced to a private scalar d in [1, n - 1] by the step NIST SP 800-56A Rev. 3 section 5.6.1.2.1 uses for key-establishment key pairs: d = (c mod (n - 1)) + 1. That section draws c from a random bit generator; here it comes from HKDF, so this follows its reduction and is not its approved key-pair generation. The derivation is fixed by its info string: changing anything here changes every key, so a new derivation takes a new info string rather than editing this one.
Fields
MinimumMasterLength
The shortest master accepted: as long as the private scalar it derives.
public const int MinimumMasterLength = 32
Field Value
MinimumSaltLength
The shortest salt accepted, enough that two random salts colliding is negligible.
public const int MinimumSaltLength = 16
Field Value
Methods
Derive(ReadOnlySpan<byte>, ReadOnlySpan<byte>)
The P-256 key that master and salt derive. The caller owns and
disposes it.
public static ECDsa Derive(ReadOnlySpan<byte> master, ReadOnlySpan<byte> salt)
Parameters
masterReadOnlySpan<byte>saltReadOnlySpan<byte>
Returns
Exceptions
- ArgumentException
The master is shorter than MinimumMasterLength bytes or all zeros, or the salt is shorter than MinimumSaltLength.