Commit 281c3e8f authored by Jesper Louis Andersen's avatar Jesper Louis Andersen
Browse files

Provide (scheduler) blocking variants of all the expensive calls.

parent 2d39e253
......@@ -567,37 +567,50 @@ static ErlNifFunc nif_funcs[] = {
{"crypto_box_PUBLICKEYBYTES", 0, enif_crypto_box_PUBLICKEYBYTES},
{"crypto_box_SECRETKEYBYTES", 0, enif_crypto_box_SECRETKEYBYTES},
{"crypto_box_keypair", 0, enif_crypto_box_keypair},
{"crypto_box_b", 4, enif_crypto_box},
{"crypto_box", 4, enif_crypto_box, ERL_NIF_DIRTY_JOB_CPU_BOUND},
{"crypto_box_open_b", 4, enif_crypto_box_open},
{"crypto_box_open", 4, enif_crypto_box_open, ERL_NIF_DIRTY_JOB_CPU_BOUND},
{"crypto_sign_PUBLICKEYBYTES", 0, enif_crypto_sign_PUBLICKEYBYTES},
{"crypto_sign_SECRETKEYBYTES", 0, enif_crypto_sign_SECRETKEYBYTES},
{"crypto_sign_keypair", 0, enif_crypto_sign_keypair},
{"crypto_sign_b", 2, enif_crypto_sign},
{"crypto_sign", 2, enif_crypto_sign, ERL_NIF_DIRTY_JOB_CPU_BOUND},
{"crypto_sign_open_b", 2, enif_crypto_sign_open},
{"crypto_sign_open", 2, enif_crypto_sign_open, ERL_NIF_DIRTY_JOB_CPU_BOUND},
{"crypto_secretbox_NONCEBYTES", 0, enif_crypto_secretbox_NONCEBYTES},
{"crypto_secretbox_ZEROBYTES", 0, enif_crypto_secretbox_ZEROBYTES},
{"crypto_secretbox_BOXZEROBYTES", 0, enif_crypto_secretbox_BOXZEROBYTES},
{"crypto_secretbox_KEYBYTES", 0, enif_crypto_secretbox_KEYBYTES},
{"crypto_secretbox_b", 3, enif_crypto_secretbox},
{"crypto_secretbox", 3, enif_crypto_secretbox, ERL_NIF_DIRTY_JOB_CPU_BOUND},
{"crypto_secretbox_open_b", 3, enif_crypto_secretbox_open},
{"crypto_secretbox_open", 3, enif_crypto_secretbox_open, ERL_NIF_DIRTY_JOB_CPU_BOUND},
{"crypto_stream_KEYBYTES", 0, enif_crypto_stream_KEYBYTES},
{"crypto_stream_NONCEBYTES", 0, enif_crypto_stream_NONCEBYTES},
{"crypto_stream_b", 3, enif_crypto_stream},
{"crypto_stream", 3, enif_crypto_stream, ERL_NIF_DIRTY_JOB_CPU_BOUND},
{"crypto_stream_xor_b", 3, enif_crypto_stream_xor},
{"crypto_stream_xor", 3, enif_crypto_stream_xor, ERL_NIF_DIRTY_JOB_CPU_BOUND},
{"crypto_auth_BYTES", 0, enif_crypto_auth_BYTES},
{"crypto_auth_KEYBYTES", 0, enif_crypto_auth_KEYBYTES},
{"crypto_auth_b", 2, enif_crypto_auth},
{"crypto_auth", 2, enif_crypto_auth, ERL_NIF_DIRTY_JOB_CPU_BOUND},
{"crypto_auth_verify_b", 3, enif_crypto_auth_verify},
{"crypto_auth_verify", 3, enif_crypto_auth_verify, ERL_NIF_DIRTY_JOB_CPU_BOUND},
{"crypto_onetimeauth_BYTES", 0, enif_crypto_onetimeauth_BYTES},
{"crypto_onetimeauth_KEYBYTES", 0, enif_crypto_onetimeauth_KEYBYTES},
{"crypto_onetimeauth_b", 2, enif_crypto_onetimeauth},
{"crypto_onetimeauth", 2, enif_crypto_onetimeauth, ERL_NIF_DIRTY_JOB_CPU_BOUND},
{"crypto_onetimeauth_verify_b", 3, enif_crypto_onetimeauth_verify},
{"crypto_onetimeauth_verify", 3, enif_crypto_onetimeauth_verify, ERL_NIF_DIRTY_JOB_CPU_BOUND},
{"crypto_hash_b", 1, enif_crypto_hash},
{"crypto_hash", 1, enif_crypto_hash, ERL_NIF_DIRTY_JOB_CPU_BOUND},
{"crypto_verify_16", 2, enif_crypto_verify_16},
{"crypto_verify_32", 2, enif_crypto_verify_32}
......
......@@ -5,50 +5,69 @@
%% Public key auth
-export([
crypto_box_keypair/0,
crypto_box/4,
crypto_box_open/4,
crypto_box_NONCEBYTES/0,
crypto_box_ZEROBYTES/0,
crypto_box_BOXZEROBYTES/0,
crypto_box_NONCEBYTES/0,
crypto_box_PUBLICKEYBYTES/0,
crypto_box_SECRETKEYBYTES/0,
crypto_box_ZEROBYTES/0,
crypto_box/4,
crypto_box_b/4,
crypto_box_keypair/0,
crypto_box_open/4,
crypto_box_open_b/4,
crypto_sign_PUBLICKEYBYTES/0,
crypto_sign_SECRETKEYBYTES/0,
crypto_sign_keypair/0,
crypto_sign/2,
crypto_sign_open/2
crypto_sign_b/2,
crypto_sign_keypair/0,
crypto_sign_open/2,
crypto_sign_open_b/2
]).
%% Secret key crypto
-export([
crypto_secretbox/3,
crypto_secretbox_open/3,
crypto_secretbox_NONCEBYTES/0,
crypto_secretbox_ZEROBYTES/0,
crypto_secretbox_BOXZEROBYTES/0,
crypto_secretbox_KEYBYTES/0,
crypto_secretbox_NONCEBYTES/0,
crypto_secretbox_ZEROBYTES/0,
crypto_secretbox/3,
crypto_secretbox_b/3,
crypto_secretbox_open/3,
crypto_secretbox_open_b/3,
crypto_stream_KEYBYTES/0,
crypto_stream_NONCEBYTES/0,
crypto_stream/3,
crypto_stream_b/3,
crypto_stream_xor/3,
crypto_stream_xor_b/3,
crypto_auth_BYTES/0,
crypto_auth_KEYBYTES/0,
crypto_auth/2,
crypto_auth_b/2,
crypto_auth_verify/3,
crypto_auth_verify_b/3,
crypto_onetimeauth_BYTES/0,
crypto_onetimeauth_KEYBYTES/0,
crypto_onetimeauth/2,
crypto_onetimeauth_verify/3
crypto_onetimeauth_b/2,
crypto_onetimeauth_verify/3,
crypto_onetimeauth_verify_b/3
]).
%% Miscellaneous helper functions
-export([
crypto_hash/1,
crypto_hash_b/1,
crypto_verify_16/2,
crypto_verify_32/2
]).
......@@ -73,39 +92,55 @@ crypto_box_ZEROBYTES() -> not_loaded().
crypto_box_BOXZEROBYTES() -> not_loaded().
crypto_box_PUBLICKEYBYTES() -> not_loaded().
crypto_box_SECRETKEYBYTES() -> not_loaded().
crypto_box_keypair() -> not_loaded().
crypto_box(_PaddedMsg, _Nonce, _PK, _SK) -> not_loaded().
crypto_box_b(_PaddedMsg, _Nonce, _PK, _SK) -> not_loaded().
crypto_box_open(_CipherText, _Nonce, _PK, _SK) -> not_loaded().
crypto_box_open_b(_CipherText, _Nonce, _PK, _SK) -> not_loaded().
crypto_sign_PUBLICKEYBYTES() -> not_loaded().
crypto_sign_SECRETKEYBYTES() -> not_loaded().
crypto_sign_keypair() -> not_loaded().
crypto_sign(_M, _SK) -> not_loaded().
crypto_sign_b(_M, _SK) -> not_loaded().
crypto_sign_open(_SignedMessage, _PK) -> not_loaded().
crypto_sign_open_b(_SignedMessage, _PK) -> not_loaded().
crypto_secretbox_NONCEBYTES() -> not_loaded().
crypto_secretbox_ZEROBYTES() -> not_loaded().
crypto_secretbox_KEYBYTES() -> not_loaded().
crypto_secretbox_BOXZEROBYTES() -> not_loaded().
crypto_secretbox(_CipherText, _Nonce, _Key) -> not_loaded().
crypto_secretbox_b(_CipherText, _Nonce, _Key) -> not_loaded().
crypto_secretbox_open(_CipherText, _Nonce, _Key) -> not_loaded().
crypto_secretbox_open_b(_CipherText, _Nonce, _Key) -> not_loaded().
crypto_stream_KEYBYTES() -> not_loaded().
crypto_stream_NONCEBYTES() -> not_loaded().
crypto_stream(_Bytes, _Nonce, _Key) -> not_loaded().
crypto_stream_b(_Bytes, _Nonce, _Key) -> not_loaded().
crypto_stream_xor(_M, _Nonce, _Key) -> not_loaded().
crypto_stream_xor_b(_M, _Nonce, _Key) -> not_loaded().
crypto_auth_BYTES() -> not_loaded().
crypto_auth_KEYBYTES() -> not_loaded().
crypto_auth(_Msg, _Key) -> not_loaded().
crypto_auth_b(_Msg, _Key) -> not_loaded().
crypto_auth_verify(_Authenticator, _Msg, _Key) -> not_loaded().
crypto_auth_verify_b(_Authenticator, _Msg, _Key) -> not_loaded().
crypto_onetimeauth_BYTES() -> not_loaded().
crypto_onetimeauth_KEYBYTES() -> not_loaded().
crypto_onetimeauth(_Msg, _Key) -> not_loaded().
crypto_onetimeauth_b(_Msg, _Key) -> not_loaded().
crypto_onetimeauth_verify(_Authenticator, _Msg, _Key) -> not_loaded().
crypto_onetimeauth_verify_b(_Authenticator, _Msg, _Key) -> not_loaded().
crypto_hash(Input) when is_binary(Input) -> not_loaded().
crypto_hash_b(Input) when is_binary(Input) -> not_loaded().
crypto_verify_16(_X, _Y) -> not_loaded().
crypto_verify_32(_X, _Y) -> not_loaded().
......
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