Commit 35515e46 authored by Parnell Springmeyer's avatar Parnell Springmeyer
Browse files

Improvements re: suggestions from @jlouis.

parent 7e7ac67f
...@@ -522,7 +522,7 @@ ERL_NIF_TERM enif_crypto_sign_detached(ErlNifEnv* env, int argc, ERL_NIF_TERM co ...@@ -522,7 +522,7 @@ ERL_NIF_TERM enif_crypto_sign_detached(ErlNifEnv* env, int argc, ERL_NIF_TERM co
crypto_sign_detached(sig.data, &siglen, m.data, m.size, sk.data); crypto_sign_detached(sig.data, &siglen, m.data, m.size, sk.data);
return enif_make_sub_binary(env, enif_make_binary(env, &sig), 0, siglen); return enif_make_binary(env, &sig);
} }
/* /*
...@@ -955,8 +955,8 @@ static ErlNifFunc nif_funcs[] = { ...@@ -955,8 +955,8 @@ static ErlNifFunc nif_funcs[] = {
{"crypto_sign_open_b", 2, enif_crypto_sign_open}, {"crypto_sign_open_b", 2, enif_crypto_sign_open},
{"crypto_sign_open", 2, enif_crypto_sign_open, ERL_NIF_DIRTY_JOB_CPU_BOUND}, {"crypto_sign_open", 2, enif_crypto_sign_open, ERL_NIF_DIRTY_JOB_CPU_BOUND},
{"crypto_sign_detached", 2, enif_crypto_sign_detached, ERL_NIF_DIRTY_JOB_CPU_BOUND}, {"crypto_sign_detached", 2, enif_crypto_sign_detached, ERL_NIF_DIRTY_JOB_CPU_BOUND},
{"crypto_sign_verify_detached", 3, enif_crypto_sign_verify_detached, ERL_NIF_DIRTY_JOB_CPU_BOUND}, {"crypto_sign_verify_detached", 3, enif_crypto_sign_verify_detached, ERL_NIF_DIRTY_JOB_CPU_BOUND},
{"crypto_secretbox_NONCEBYTES", 0, enif_crypto_secretbox_NONCEBYTES}, {"crypto_secretbox_NONCEBYTES", 0, enif_crypto_secretbox_NONCEBYTES},
{"crypto_secretbox_ZEROBYTES", 0, enif_crypto_secretbox_ZEROBYTES}, {"crypto_secretbox_ZEROBYTES", 0, enif_crypto_secretbox_ZEROBYTES},
......
...@@ -398,12 +398,16 @@ sign_detached(M, SK) -> enacl_nif:crypto_sign_detached(M, SK). ...@@ -398,12 +398,16 @@ sign_detached(M, SK) -> enacl_nif:crypto_sign_detached(M, SK).
%% %%
%% Given a signature `SIG', a message `M', and a public key `PK', the function computes %% Given a signature `SIG', a message `M', and a public key `PK', the function computes
%% true iff the `SIG' is valid for `M' and `PK'. %% true iff the `SIG' is valid for `M' and `PK'.
-spec sign_verify_detached(SIG, M, PK) -> boolean() -spec sign_verify_detached(SIG, M, PK) -> {ok, M} | {error, failed_verification}
when when
SIG :: binary(), SIG :: binary(),
M :: iodata(), M :: iodata(),
PK :: binary(). PK :: binary().
sign_verify_detached(SIG, M, PK) -> enacl_nif:crypto_sign_verify_detached(SIG, M, PK). sign_verify_detached(SIG, M, PK) ->
case enacl_nif:crypto_sign_verify_detached(SIG, M, PK) of
true -> {ok, M};
false -> {error, failed_verification}
end.
%% @private %% @private
-spec box_secret_key_bytes() -> pos_integer(). -spec box_secret_key_bytes() -> pos_integer().
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment