Replace case with a simpler assertion
This commit is contained in:
@@ -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>>,
|
||||||
|
|||||||
Reference in New Issue
Block a user