added bindings for crypto_box_seal_open\' functions
This commit is contained in:
+33
-2
@@ -35,8 +35,11 @@
|
||||
sign_keypair/0,
|
||||
sign/2,
|
||||
sign_open/2,
|
||||
sign_detached/2,
|
||||
sign_verify_detached/3
|
||||
sign_detached/2,
|
||||
sign_verify_detached/3,
|
||||
|
||||
seal_box/2,
|
||||
seal_box_open/3
|
||||
]).
|
||||
|
||||
%% Secret key crypto
|
||||
@@ -196,6 +199,7 @@ box_keypair() ->
|
||||
{PK, SK} = enacl_nif:crypto_box_keypair(),
|
||||
#{ public => PK, secret => SK}.
|
||||
|
||||
|
||||
%% @doc box/4 encrypts+authenticates a message to another party.
|
||||
%%
|
||||
%% Encrypt a `Msg' to the party identified by public key `PK' using your own secret key `SK' to
|
||||
@@ -414,6 +418,33 @@ sign_verify_detached(SIG, M, PK) ->
|
||||
box_secret_key_bytes() ->
|
||||
enacl_nif:crypto_box_SECRETKEYBYTES().
|
||||
|
||||
%% @doc seal_box/2 encrypts an anonymous message to another party.
|
||||
%%
|
||||
%% Encrypt a `Msg' to a party using his public key, `PK'. This generates an ephemeral
|
||||
%% keypair and then uses `box'. Ephemeral public key will sent to other party. Returns the
|
||||
%% enciphered message `SealedCipherText' which includes ephemeral public key at head.
|
||||
%% @end
|
||||
-spec seal_box(Msg, PK) -> SealedCipherText
|
||||
when Msg :: iodata(),
|
||||
PK :: binary(),
|
||||
SealedCipherText :: binary().
|
||||
seal_box(Msg, PK) ->
|
||||
enacl_nif:crypto_box_seal(Msg, PK).
|
||||
|
||||
%% @doc seal_box_open/3 decrypts+check message integrity from an unknown sender.
|
||||
%%
|
||||
%% Decrypt a `SealedCipherText' which contains an ephemeral public key from another party
|
||||
%% into a `Msg' using that key and your public and secret keys, `PK' and `SK'. Returns the
|
||||
%% plaintext message.
|
||||
%% @end
|
||||
-spec seal_box_open(SealedCipherText, PK, SK) -> {ok, Msg} | {error, failed_verification}
|
||||
when SealedCipherText :: iodata(),
|
||||
PK :: binary(),
|
||||
SK :: binary(),
|
||||
Msg :: binary().
|
||||
seal_box_open(SealedCipherText, PK, SK) ->
|
||||
enacl_nif:crypto_box_seal_open(SealedCipherText, PK, SK).
|
||||
|
||||
%% @doc secretbox/3 encrypts a message with a key
|
||||
%%
|
||||
%% Given a `Msg', a `Nonce' and a `Key' encrypt the message with the Key while taking the
|
||||
|
||||
+10
-2
@@ -33,8 +33,12 @@
|
||||
crypto_sign_open/2,
|
||||
crypto_sign_open_b/2,
|
||||
|
||||
crypto_sign_detached/2,
|
||||
crypto_sign_verify_detached/3
|
||||
crypto_sign_detached/2,
|
||||
crypto_sign_verify_detached/3,
|
||||
|
||||
crypto_box_seal/2,
|
||||
crypto_box_seal_open/3,
|
||||
crypto_box_SEALBYTES/0
|
||||
|
||||
]).
|
||||
|
||||
@@ -151,6 +155,10 @@ crypto_sign_open_b(_SignedMessage, _PK) -> erlang:nif_error(nif_not_loaded).
|
||||
crypto_sign_detached(_M, _SK) -> erlang:nif_error(nif_not_loaded).
|
||||
crypto_sign_verify_detached(_SIG, _M, _PK) -> erlang:nif_error(nif_not_loaded).
|
||||
|
||||
crypto_box_seal(_Msg, _PK) -> erlang:nif_error(nif_not_loaded).
|
||||
crypto_box_seal_open(_CipherText, _PK, _SK) -> erlang:nif_error(nif_not_loaded).
|
||||
crypto_box_SEALBYTES() -> erlang:nif_error(nif_not_loaded).
|
||||
|
||||
crypto_secretbox_NONCEBYTES() -> erlang:nif_error(nif_not_loaded).
|
||||
crypto_secretbox_ZEROBYTES() -> erlang:nif_error(nif_not_loaded).
|
||||
crypto_secretbox_KEYBYTES() -> erlang:nif_error(nif_not_loaded).
|
||||
|
||||
Reference in New Issue
Block a user