summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpukkamustard <pukkamustard@posteo.net>2020-11-30 09:37:01 +0100
committerpukkamustard <pukkamustard@posteo.net>2020-11-30 11:17:23 +0100
commit414e4eb55750090ccae9001797a89351bf2722fd (patch)
tree12bb2ee78adf9edab6b33ed42dab18526f756ee5
parent2ff5c6c70a2308665b6e594b4b9fbb195f458673 (diff)
monocypher: add more useful type specifications
-rw-r--r--src/monocypher.erl18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/monocypher.erl b/src/monocypher.erl
index acdf488..41c5c24 100644
--- a/src/monocypher.erl
+++ b/src/monocypher.erl
@@ -16,11 +16,14 @@
%% Authenticated Encryption
--spec crypto_lock(binary(), binary(), binary(), binary()) -> binary().
+-type crypto_lock_mac() :: <<_:128>>.
+-type crypto_lock_key() :: <<_:256>>.
+-type crypto_lock_nonce() :: <<_:192>>.
+-spec crypto_lock(crypto_lock_mac(), crypto_lock_key(), crypto_lock_nonce(), binary()) -> binary().
crypto_lock(_,_,_,_) ->
not_loaded(?LINE).
--spec crypto_unlock(binary(), binary(), binary(), binary()) -> {'ok', binary()} | {'error', integer()}.
+-spec crypto_unlock(crypto_lock_key(), crypto_lock_nonce(), crypto_lock_mac(), binary()) -> {'ok', binary()} | {'error', integer()}.
crypto_unlock(_,_,_,_) ->
not_loaded(?LINE).
@@ -30,17 +33,22 @@ crypto_unlock(_,_,_,_) ->
crypto_blake2b(_) ->
not_loaded(?LINE).
--spec crypto_blake2b_general(integer(), binary(), binary()) -> binary().
+
+-type crypto_blake2b_hash_size() :: 1..64.
+-type crypto_blake2b_key() :: <<_:_*8>>.
+-spec crypto_blake2b_general(crypto_blake2b_hash_size(), crypto_blake2b_key(), binary()) -> binary().
crypto_blake2b_general(_,_,_) ->
not_loaded(?LINE).
%% IETF ChaCha20
--spec crypto_ietf_chacha20(binary(), binary(), binary()) -> binary().
+-type crypto_ietf_chacha20_key() :: <<_:256>>.
+-type crypto_ietf_chacha20_nonce() :: <<_:96>>.
+-spec crypto_ietf_chacha20(binary(), crypto_ietf_chacha20_key(), crypto_ietf_chacha20_nonce()) -> binary().
crypto_ietf_chacha20(_,_,_) ->
not_loaded(?LINE).
--spec crypto_ietf_chacha20_ctr(binary(), binary(), binary(), pos_integer()) -> binary().
+-spec crypto_ietf_chacha20_ctr(binary(), crypto_ietf_chacha20_key(), crypto_ietf_chacha20_nonce(), pos_integer()) -> binary().
crypto_ietf_chacha20_ctr(_,_,_,_) ->
not_loaded(?LINE).