Add shared secret functions to hz_key_master #32

Open
zxq9 wants to merge 2 commits from shared_secrets into master
Showing only changes of commit bb7b4c3629 - Show all commits
+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>>,