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) -> expand(Hash, PRK, Info, OutLen) ->
HashLen = hash_size(Hash), HashLen = hash_size(Hash),
BlockCount = (OutLen + HashLen - 1) div HashLen, BlockCount = (OutLen + HashLen - 1) div HashLen,
case BlockCount > 255 of true = BlockCount =< 255,
true -> FullBlocks = expand_loop(Hash, PRK, Info, BlockCount, 1, <<>>, <<>>),
error(hkdf_length_too_long); <<Output:OutLen/binary, _/binary>> = FullBlocks,
false -> Output.
FullBlocks = expand_loop(Hash, PRK, Info, BlockCount, 1, <<>>, <<>>),
<<Output:OutLen/binary, _/binary>> = FullBlocks,
Output
end.
expand_loop(Hash, PRK, Info, N, Counter, PrevT, Acc) when Counter =< N -> expand_loop(Hash, PRK, Info, N, Counter, PrevT, Acc) when Counter =< N ->
Payload = <<PrevT/binary, Info/binary, Counter:8>>, Payload = <<PrevT/binary, Info/binary, Counter:8>>,