Replace case with a simpler assertion

This commit is contained in:
2026-05-30 15:33:43 +09:00
parent 11a9b36681
commit bb7b4c3629
+4 -8
View File
@@ -342,14 +342,10 @@ extract(Hash, Salt, IKM) ->
expand(Hash, PRK, Info, OutLen) ->
HashLen = hash_size(Hash),
BlockCount = (OutLen + HashLen - 1) div HashLen,
case BlockCount > 255 of
true ->
error(hkdf_length_too_long);
false ->
FullBlocks = expand_loop(Hash, PRK, Info, BlockCount, 1, <<>>, <<>>),
<<Output:OutLen/binary, _/binary>> = FullBlocks,
Output
end.
true = BlockCount =< 255,
FullBlocks = expand_loop(Hash, PRK, Info, BlockCount, 1, <<>>, <<>>),
<<Output:OutLen/binary, _/binary>> = FullBlocks,
Output.
expand_loop(Hash, PRK, Info, N, Counter, PrevT, Acc) when Counter =< N ->
Payload = <<PrevT/binary, Info/binary, Counter:8>>,