Move C level NIFs into the Erlang interface for these.

This enables the ability to call the C NIFs from Erlang.
This commit is contained in:
Jesper Louis Andersen 2014-11-25 13:57:34 +01:00
parent c33225cb77
commit dc78d268e6

View File

@ -11,7 +11,13 @@
crypto_box_ZEROBYTES/0, crypto_box_ZEROBYTES/0,
crypto_box_BOXZEROBYTES/0, crypto_box_BOXZEROBYTES/0,
crypto_box_PUBLICKEYBYTES/0, crypto_box_PUBLICKEYBYTES/0,
crypto_box_SECRETKEYBYTES/0 crypto_box_SECRETKEYBYTES/0,
crypto_sign_PUBLICKEYBYTES/0,
crypto_sign_SECRETKEYBYTES/0,
crypto_sign_keypair/0,
crypto_sign/2,
crypto_sign_open/2
]). ]).
%% Secret key crypto %% Secret key crypto
@ -21,12 +27,27 @@
crypto_secretbox_NONCEBYTES/0, crypto_secretbox_NONCEBYTES/0,
crypto_secretbox_ZEROBYTES/0, crypto_secretbox_ZEROBYTES/0,
crypto_secretbox_BOXZEROBYTES/0, crypto_secretbox_BOXZEROBYTES/0,
crypto_secretbox_KEYBYTES/0 crypto_secretbox_KEYBYTES/0,
crypto_stream_KEYBYTES/0,
crypto_stream_NONCEBYTES/0,
crypto_stream/3,
crypto_stream_xor/3,
crypto_auth_KEYBYTES/0,
crypto_auth/2,
crypto_auth_verify/3,
crypto_onetimeauth_KEYBYTES/0,
crypto_onetimeauth/2,
crypto_onetimeauth_verify/3
]). ]).
%% Miscellaneous helper functions %% Miscellaneous helper functions
-export([ -export([
crypto_hash/1 crypto_hash/1,
crypto_verify_16/2,
crypto_verify_32/2
]). ]).
-on_load(init/0). -on_load(init/0).
@ -49,19 +70,39 @@ crypto_box_ZEROBYTES() -> not_loaded().
crypto_box_BOXZEROBYTES() -> not_loaded(). crypto_box_BOXZEROBYTES() -> not_loaded().
crypto_box_PUBLICKEYBYTES() -> not_loaded(). crypto_box_PUBLICKEYBYTES() -> not_loaded().
crypto_box_SECRETKEYBYTES() -> not_loaded(). crypto_box_SECRETKEYBYTES() -> not_loaded().
crypto_box_keypair() -> not_loaded(). crypto_box_keypair() -> not_loaded().
crypto_box(_PaddedMsg, _Nonce, _PK, _SK) -> not_loaded(). crypto_box(_PaddedMsg, _Nonce, _PK, _SK) -> not_loaded().
crypto_box_open(_CipherText, _Nonce, _PK, _SK) -> not_loaded(). crypto_box_open(_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_open(_SignedMessage, _PK) -> not_loaded().
crypto_secretbox_NONCEBYTES() -> not_loaded(). crypto_secretbox_NONCEBYTES() -> not_loaded().
crypto_secretbox_ZEROBYTES() -> not_loaded(). crypto_secretbox_ZEROBYTES() -> not_loaded().
crypto_secretbox_KEYBYTES() -> not_loaded(). crypto_secretbox_KEYBYTES() -> not_loaded().
crypto_secretbox_BOXZEROBYTES() -> not_loaded(). crypto_secretbox_BOXZEROBYTES() -> not_loaded().
crypto_secretbox(_CipherText, _Nonce, _Key) -> not_loaded(). crypto_secretbox(_CipherText, _Nonce, _Key) -> not_loaded().
crypto_secretbox_open(_CipherText, _Nonce, _Key) -> not_loaded(). crypto_secretbox_open(_CipherText, _Nonce, _Key) -> not_loaded().
crypto_stream_KEYBYTES() -> not_loaded().
crypto_stream_NONCEBYTES() -> not_loaded().
crypto_stream(_Bytes, _Nonce, _Key) -> not_loaded().
crypto_stream_xor(_M, _Nonce, _Key) -> not_loaded().
crypto_auth_KEYBYTES() -> not_loaded().
crypto_auth(_Msg, _Key) -> not_loaded().
crypto_auth_verify(_Authenticator, _Msg, _Key) -> not_loaded().
crypto_onetimeauth_KEYBYTES() -> not_loaded().
crypto_onetimeauth(_Msg, _Key) -> not_loaded().
crypto_onetimeauth_verify(_Authenticator, _Msg, _Key) -> not_loaded().
crypto_hash(Input) when is_binary(Input) -> not_loaded(). crypto_hash(Input) when is_binary(Input) -> not_loaded().
crypto_verify_16(_X, _Y) -> not_loaded().
crypto_verify_32(_X, _Y) -> not_loaded().