Skip to content

Conversation

@tmael
Copy link
Contributor

@tmael tmael commented May 6, 2020

This PR adds a length check in wc_HKDF_Expand() to address issues reported in ZD#10261 and GitHub issues #2951.

RFC 5869 section 2.3 states that the length of output keying material in octets must be L <= 255*HashLen

where HashLen is the size in octets of the hash function's digest.

However, wc_HKDF_Expand was missing this check.

word32 outIdx = 0;
word32 hashSz = wc_HmacSizeByType(type);
byte n = 0x1;
word32 N = 0; /* rf5869: N = ceil(L/HashLen)*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add an additional variable to the stack when we can just check that L <= (255 * hashSz)? Also please put a comment on why 255 is used here to explain the hard set number

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JacobBarthelmeh, Good point. Fixed. FYI. The additional variable was for clarity and I wanted to avoid multiplications.

@tmael tmael assigned JacobBarthelmeh and unassigned tmael May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants