I'm looking at RFC 8446 section 7.1 and trying to understand the following:
HKDF-Expand-Label(Secret, Label, Context, Length) =
HKDF-Expand(Secret, HkdfLabel, Length)
Where HkdfLabel is specified as:
struct {
uint16 length = Length;
opaque label<7..255> = "tls13 " + Label;
opaque context<0..255> = Context;
} HkdfLabel;
Derive-Secret(Secret, Label, Messages) =
HKDF-Expand-Label(Secret, Label,
Transcript-Hash(Messages), Hash.length)
HkdfLabel
appears to be a concatenation of a few fields, to make it "fit" into the signature of Hkdf.Expand(...)
. A few things I'm unclear on:
- Are the pieces that make up the struct of
HkdfLabel
expected to be concatenated in the order they're defined? e.g.length||label||context
length
= the hash length in bytes?- the first
0..6
bits oflabel
are not specified, assuming 0? "tls13 " + Label
may be more or less bits than7..255
allows for the assignment tolabel
. Is the expectation that it's zeroes if not long enough, or truncated to 256 bits if too long?- same basic uncertainty around
context
, is the idea thatcontext
will always be exactly 256 bits? - Assuming the above is correct, does that mean
HkdfLabel
will always be exactly 528 bits?HkdfLabel = hashLength<0..15>||label<0..255>||context<0..255>