write edoc

This commit is contained in:
SUZUKI Tetsuya 2012-10-03 17:33:04 +09:00
parent d9d541dce8
commit e20d5d08c4

View File

@ -5,7 +5,10 @@
-on_load(init/0). -on_load(init/0).
-type bitlen() :: 224 | 256 | 384 | 512. -type bitlen() :: 224 | 256 | 384 | 512.
-type context() :: binary(). -type context() :: binary().
%% State of hash operation return.
-type digest() :: <<_:224>> | <<_:256>> | <<_:384>> | <<_:512>>. -type digest() :: <<_:224>> | <<_:256>> | <<_:384>> | <<_:512>>.
-define(nif_stub, nif_stub_error(?LINE)). -define(nif_stub, nif_stub_error(?LINE)).
@ -23,18 +26,31 @@ init() ->
end, end,
erlang:load_nif(filename:join(PrivDir, sha3_nif), 0). erlang:load_nif(filename:join(PrivDir, sha3_nif), 0).
%% @doc Returns a new context for hash operation.
%% Bit length of digest (`BitLen') must be one of 224, 256, 384 and 512.
%% @see hash_update/2
-spec hash_init(bitlen()) -> context(). -spec hash_init(bitlen()) -> context().
hash_init(_BitLen) -> hash_init(_BitLen) ->
?nif_stub. ?nif_stub.
%% @doc Updates the digest by `Context' generated with `hash_init/1'
%% using the given `Data' and returns a new updated context.
%% `Data' can be any length.
%% The returned context can e used `hash_update/2' or `hash_final/1'.
%% @see hash_final/1
-spec hash_update(context(), binary()) -> context(). -spec hash_update(context(), binary()) -> context().
hash_update(_Context, _Binary) -> hash_update(_Context, _Binary) ->
?nif_stub. ?nif_stub.
%% @doc Finalizes the hash operation with `Context' and
%% returns a message digest.
%% Length of the digest is determined by an argument of `hash_init/1'.
-spec hash_final(context()) -> digest(). -spec hash_final(context()) -> digest().
hash_final(_Context) -> hash_final(_Context) ->
?nif_stub. ?nif_stub.
%% @doc Computes a message digest from `Binary'.
%% Bit length of digest (`BitLen') must be one of 224, 256, 384 and 512.
-spec hash(bitlen(), binary()) -> digest(). -spec hash(bitlen(), binary()) -> digest().
hash(_BitLen, _Binary) -> hash(_BitLen, _Binary) ->
?nif_stub. ?nif_stub.