Clean up code that generates session keys
This patch simply reworks the code to make it more understandable and
reduce if() branches.
It also avoids reallocs, and instead uses a support buffer to hold
intermediate results of the hmac function so that no buffer overrides
happen when the requested size is not an exact mutiple of the digest_len.
Signed-off-by: Simo Sorce <email@example.com>
Reviewed-by: Anderson Toshiyuki Sasaki <firstname.lastname@example.org>
Reviewed-by: Andreas Schneider <email@example.com>