From 233c924b70e5e324d319a946da4c75c4cd962230 Mon Sep 17 00:00:00 2001 From: Amir Ghassemi Nasr Date: Sun, 9 Aug 2015 17:24:12 +0430 Subject: [PATCH] correct enacl:seal_box_open return value --- src/enacl.erl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/enacl.erl b/src/enacl.erl index 54e1c10..b29adbf 100644 --- a/src/enacl.erl +++ b/src/enacl.erl @@ -429,8 +429,8 @@ box_secret_key_bytes() -> PK :: binary(), SealedCipherText :: binary(). seal_box(Msg, PK) -> - enacl_nif:crypto_box_seal(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 @@ -443,7 +443,10 @@ seal_box(Msg, PK) -> SK :: binary(), Msg :: binary(). seal_box_open(SealedCipherText, PK, SK) -> - enacl_nif:crypto_box_seal_open(SealedCipherText, PK, SK). + case enacl_nif:crypto_box_seal_open(SealedCipherText, PK, SK) of + {error, Err} -> {error, Err}; + Bin when is_binary(Bin) -> Bin + end. %% @doc secretbox/3 encrypts a message with a key %%